From db5b9619a7fc7cf98d70da0437588dbbcdcbdf98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A8=8A=E6=99=AF=E4=B9=90?= Date: Thu, 12 Jun 2025 20:30:24 +0800 Subject: [PATCH] fix: add test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 樊景乐 --- .../sub_startup_appspawn_debughap_0100.json | 14 +++ .../sub_startup_appspawn_debughap_0100.py | 64 +++++++++++ .../sub_startup_appspawn_debughap_0200.json | 14 +++ .../sub_startup_appspawn_debughap_0200.py | 64 +++++++++++ .../sub_startup_appspawn_debughap_0300.json | 14 +++ .../sub_startup_appspawn_debughap_0300.py | 79 +++++++++++++ .../sub_startup_appspawn_debughap_0500.json | 14 +++ .../sub_startup_appspawn_debughap_0500.py | 64 +++++++++++ .../sub_startup_appspawn_debughap_0600.json | 15 +++ .../sub_startup_appspawn_debughap_0600.py | 64 +++++++++++ .../sub_startup_appspawn_debughap_0700.json | 15 +++ .../sub_startup_appspawn_debughap_0700.py | 78 +++++++++++++ .../sub_startup_appspawn_debughap_0800.json | 14 +++ .../sub_startup_appspawn_debughap_0800.py | 104 ++++++++++++++++++ .../sub_startup_appspawn_debughap_0900.json | 14 +++ .../sub_startup_appspawn_debughap_0900.py | 64 +++++++++++ .../sub_startup_appspawn_fd_0100.json | 14 +++ .../sub_startup_appspawn_fd_0100.py | 83 ++++++++++++++ .../sub_startup_appspawn_ftpd_0100.json | 15 +++ .../sub_startup_appspawn_ftpd_0100.py | 64 +++++++++++ .../sub_startup_appspawn_hnpinstall_0100.json | 12 ++ .../sub_startup_appspawn_hnpinstall_0100.py | 75 +++++++++++++ .../sub_startup_appspawn_hnpinstall_0200.json | 12 ++ .../sub_startup_appspawn_hnpinstall_0200.py | 69 ++++++++++++ .../sub_startup_appspawn_hnpinstall_0300.json | 12 ++ .../sub_startup_appspawn_hnpinstall_0300.py | 78 +++++++++++++ .../sub_startup_appspawn_hnpinstall_0400.json | 12 ++ .../sub_startup_appspawn_hnpinstall_0400.py | 73 ++++++++++++ .../sub_startup_appspawn_hnpinstall_0500.json | 12 ++ .../sub_startup_appspawn_hnpinstall_0500.py | 75 +++++++++++++ .../sub_startup_appspawn_hnpinstall_0600.json | 12 ++ .../sub_startup_appspawn_hnpinstall_0600.py | 75 +++++++++++++ .../sub_startup_appspawn_hnpinstall_0700.json | 12 ++ .../sub_startup_appspawn_hnpinstall_0700.py | 76 +++++++++++++ .../sub_startup_appspawn_hnpinstall_0800.json | 12 ++ .../sub_startup_appspawn_hnpinstall_0800.py | 79 +++++++++++++ .../sub_startup_appspawn_hnpinstall_0900.json | 12 ++ .../sub_startup_appspawn_hnpinstall_0900.py | 72 ++++++++++++ 38 files changed, 1651 insertions(+) create mode 100644 test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0100.json create mode 100644 test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0100.py create mode 100644 test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0200.json create mode 100644 test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0200.py create mode 100644 test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0300.json create mode 100644 test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0300.py create mode 100644 test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0500.json create mode 100644 test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0500.py create mode 100644 test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0600.json create mode 100644 test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0600.py create mode 100644 test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0700.json create mode 100644 test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0700.py create mode 100644 test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0800.json create mode 100644 test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0800.py create mode 100644 test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0900.json create mode 100644 test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0900.py create mode 100644 test/autotest/sub_startup_appspawn_fd/sub_startup_appspawn_fd_0100.json create mode 100644 test/autotest/sub_startup_appspawn_fd/sub_startup_appspawn_fd_0100.py create mode 100644 test/autotest/sub_startup_appspawn_ftpd/sub_startup_appspawn_ftpd_0100.json create mode 100644 test/autotest/sub_startup_appspawn_ftpd/sub_startup_appspawn_ftpd_0100.py create mode 100644 test/autotest/sub_startup_appspawn_hnpinstall/sub_startup_appspawn_hnpinstall_0100.json create mode 100644 test/autotest/sub_startup_appspawn_hnpinstall/sub_startup_appspawn_hnpinstall_0100.py create mode 100644 test/autotest/sub_startup_appspawn_hnpinstall/sub_startup_appspawn_hnpinstall_0200.json create mode 100644 test/autotest/sub_startup_appspawn_hnpinstall/sub_startup_appspawn_hnpinstall_0200.py create mode 100644 test/autotest/sub_startup_appspawn_hnpinstall/sub_startup_appspawn_hnpinstall_0300.json create mode 100644 test/autotest/sub_startup_appspawn_hnpinstall/sub_startup_appspawn_hnpinstall_0300.py create mode 100644 test/autotest/sub_startup_appspawn_hnpinstall/sub_startup_appspawn_hnpinstall_0400.json create mode 100644 test/autotest/sub_startup_appspawn_hnpinstall/sub_startup_appspawn_hnpinstall_0400.py create mode 100644 test/autotest/sub_startup_appspawn_hnpinstall/sub_startup_appspawn_hnpinstall_0500.json create mode 100644 test/autotest/sub_startup_appspawn_hnpinstall/sub_startup_appspawn_hnpinstall_0500.py create mode 100644 test/autotest/sub_startup_appspawn_hnpinstall/sub_startup_appspawn_hnpinstall_0600.json create mode 100644 test/autotest/sub_startup_appspawn_hnpinstall/sub_startup_appspawn_hnpinstall_0600.py create mode 100644 test/autotest/sub_startup_appspawn_hnpinstall/sub_startup_appspawn_hnpinstall_0700.json create mode 100644 test/autotest/sub_startup_appspawn_hnpinstall/sub_startup_appspawn_hnpinstall_0700.py create mode 100644 test/autotest/sub_startup_appspawn_hnpinstall/sub_startup_appspawn_hnpinstall_0800.json create mode 100644 test/autotest/sub_startup_appspawn_hnpinstall/sub_startup_appspawn_hnpinstall_0800.py create mode 100644 test/autotest/sub_startup_appspawn_hnpinstall/sub_startup_appspawn_hnpinstall_0900.json create mode 100644 test/autotest/sub_startup_appspawn_hnpinstall/sub_startup_appspawn_hnpinstall_0900.py diff --git a/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0100.json b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0100.json new file mode 100644 index 00000000..1fd513bc --- /dev/null +++ b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0100.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_debughap/SubStartupAppspawnDebughap0100.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0100.py b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0100.py new file mode 100644 index 00000000..a429b69f --- /dev/null +++ b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0100.py @@ -0,0 +1,64 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +import time +from devicetest.core.test_case import TestCase, Step +from hypium.action.os_hypium.device_logger import DeviceLogger +from aw import Common + + +class SubStartupAppspawnDebughap0100(TestCase): + + def __init__(self, controllers): + TestCase.__init__(self, self.TAG, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step(self.devices[0].device_id) + device = self.driver.shell("param get const.product.model") + device = device.replace("\n", "").replace(" ", "") + device = str(device) + Step(device) + # 解锁屏幕 + wake = self.driver.Screen.is_on() + time.sleep(0.5) + if wake: + self.driver.ScreenLock.unlock() + else: + self.driver.Screen.wake_up() + self.driver.ScreenLock.unlock() + self.driver.Screen.enable_stay_awake() + + def process(self): + Step("安装测试hap并打开") + bundle_name = "com.example.release" + hap_path = Common.sourcepath('release.hap', "sub_startup_appspawn_debughap") + hap = self.driver.AppManager.has_app(bundle_name) + if hap: + self.driver.AppManager.clear_app_data(bundle_name) + self.driver.AppManager.uninstall_app(bundle_name) + self.driver.AppManager.install_app(hap_path) + else: + self.driver.AppManager.install_app(hap_path) + self.driver.AppManager.start_app(bundle_name) + + release_has = self.driver.Storage.has_dir("/mnt/debug/100/debug_hap/%s" % bundle_name) + self.driver.Assert.equal(release_has, False) + + def teardown(self): + Step("收尾工作.................") + self.driver.AppManager.stop_app(bundle_name) + self.driver.AppManager.uninstall_app(bundle_name) \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0200.json b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0200.json new file mode 100644 index 00000000..66713d04 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0200.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_debughap/SubStartupAppspawnDebughap0200.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0200.py b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0200.py new file mode 100644 index 00000000..dec704a0 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0200.py @@ -0,0 +1,64 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +import time +from devicetest.core.test_case import TestCase, Step +from hypium.action.os_hypium.device_logger import DeviceLogger +from aw import Common + + +class SubStartupAppspawnDebughap0200(TestCase): + + def __init__(self, controllers): + TestCase.__init__(self, self.TAG, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step(self.devices[0].device_id) + device = self.driver.shell("param get const.product.model") + device = device.replace("\n", "").replace(" ", "") + device = str(device) + Step(device) + # 解锁屏幕 + wake = self.driver.Screen.is_on() + time.sleep(0.5) + if wake: + self.driver.ScreenLock.unlock() + else: + self.driver.Screen.wake_up() + self.driver.ScreenLock.unlock() + self.driver.Screen.enable_stay_awake() + + def process(self): + Step("安装测试hap并打开") + bundle_name = "com.example.myapplication" + hap_path = Common.sourcepath('debug.hap', "sub_startup_appspawn_debughap") + hap = self.driver.AppManager.has_app(bundle_name) + if hap: + self.driver.AppManager.uninstall_app(bundle_name) + self.driver.AppManager.install_app(hap_path) + else: + self.driver.AppManager.install_app(hap_path) + self.driver.shell("param set startup.appspawn.sandbox.debughap true") + self.driver.AppManager.start_app(bundle_name) + + result = self.driver.shell("ls /mnt/debug/100/debug_hap").split() + self.driver.Assert.contains(result, bundle_name) + + def teardown(self): + Step("收尾工作.................") + self.driver.AppManager.stop_app(bundle_name) + self.driver.AppManager.uninstall_app(bundle_name) \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0300.json b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0300.json new file mode 100644 index 00000000..4918b0b9 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0300.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_debughap/SubStartupAppspawnDebughap0300.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0300.py b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0300.py new file mode 100644 index 00000000..fb7609b2 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0300.py @@ -0,0 +1,79 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +import time +from devicetest.core.test_case import TestCase, Step +from hypium.action.os_hypium.device_logger import DeviceLogger +from aw import Common + + +class SubStartupAppspawnDebughap0300(TestCase): + + def __init__(self, controllers): + TestCase.__init__(self, self.TAG, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step(self.devices[0].device_id) + device = self.driver.shell("param get const.product.model") + device = device.replace("\n", "").replace(" ", "") + device = str(device) + Step(device) + # 解锁屏幕 + wake = self.driver.Screen.is_on() + time.sleep(0.5) + if wake: + self.driver.ScreenLock.unlock() + else: + self.driver.Screen.wake_up() + self.driver.ScreenLock.unlock() + self.driver.Screen.enable_stay_awake() + + def process(self): + Step("安装测试hap并打开") + bundle_name = "com.example.myapplication" + hap_path = Common.sourcepath('debug.hap', "sub_startup_appspawn_debughap") + hap = self.driver.AppManager.has_app(bundle_name) + if hap: + self.driver.AppManager.uninstall_app(bundle_name) + self.driver.AppManager.install_app(hap_path) + else: + self.driver.AppManager.install_app(hap_path) + self.driver.shell("param set startup.appspawn.sandbox.debughap true") + self.driver.AppManager.start_app(bundle_name) + + sandbox_list = [] + mount_dict = list(filter(None, self.driver.shell("mount|grep %s" % bundle_name).split("\n"))) + for mount in mount_dict: + if mount.split()[2].startswith("/mnt/debug"): + sandbox_list.append(mount.split()[2]) + else: + pass + + for i in range(1, 5): + for path in ["base", "database"]: + self.driver.Assert.contains(sandbox_list, "/mnt/debug/100/debug_hap/%s/data/storage/el%d/%s" + % (bundle_name, i, path)) + + list01 = ["el2/share", "el2/log", "el1/bundle", "el2/auth_groups", "el2/distributedfiles"] + for path in list01: + self.driver.Assert.contains(sandbox_list, "/mnt/debug/100/debug_hap/%s/data/storage/%s" + % (bundle_name, path)) + + def teardown(self): + Step("收尾工作.................") + self.driver.AppManager.stop_app(bundle_name) + self.driver.AppManager.uninstall_app(bundle_name) \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0500.json b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0500.json new file mode 100644 index 00000000..a8e1e788 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0500.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_debughap/SubStartupAppspawnDebughap0500.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0500.py b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0500.py new file mode 100644 index 00000000..e410e953 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0500.py @@ -0,0 +1,64 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +import time +from devicetest.core.test_case import TestCase, Step +from hypium.action.os_hypium.device_logger import DeviceLogger +from aw import Common + + +class SubStartupAppspawnDebughap0500(TestCase): + + def __init__(self, controllers): + TestCase.__init__(self, self.TAG, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step(self.devices[0].device_id) + device = self.driver.shell("param get const.product.model") + device = device.replace("\n", "").replace(" ", "") + device = str(device) + Step(device) + # 解锁屏幕 + wake = self.driver.Screen.is_on() + time.sleep(0.5) + if wake: + self.driver.ScreenLock.unlock() + else: + self.driver.Screen.wake_up() + self.driver.ScreenLock.unlock() + self.driver.Screen.enable_stay_awake() + + def process(self): + Step("安装测试hap并打开") + bundle_name = "com.example.myapplication" + hap_path = Common.sourcepath('debug.hap', "sub_startup_appspawn_debughap") + hap = self.driver.AppManager.has_app(bundle_name) + if hap: + self.driver.AppManager.clear_app_data(bundle_name) + self.driver.AppManager.uninstall_app(bundle_name) + self.driver.AppManager.install_app(hap_path) + else: + self.driver.AppManager.install_app(hap_path) + self.driver.AppManager.start_app(bundle_name) + + result = self.driver.shell("ls -Z /mnt/debug/100/debug_hap").split("\n") + self.driver.Assert.contains(result, "u:object_r:sharefs:s0 %s" % bundle_name) + + def teardown(self): + Step("收尾工作.................") + self.driver.AppManager.stop_app(bundle_name) + self.driver.AppManager.uninstall_app(bundle_name) \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0600.json b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0600.json new file mode 100644 index 00000000..7a19d9b4 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0600.json @@ -0,0 +1,15 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device", + "label": "" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_debughap/SubStartupAppspawnDebughap0600.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0600.py b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0600.py new file mode 100644 index 00000000..446185f8 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0600.py @@ -0,0 +1,64 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +import time +from devicetest.core.test_case import TestCase, Step +from hypium.action.os_hypium.device_logger import DeviceLogger +from aw import Common + + +class SubStartupAppspawnDebughap0600(TestCase): + + def __init__(self, controllers): + TestCase.__init__(self, self.TAG, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step(self.devices[0].device_id) + device = self.driver.shell("param get const.product.model") + device = device.replace("\n", "").replace(" ", "") + device = str(device) + Step(device) + # 解锁屏幕 + wake = self.driver.Screen.is_on() + time.sleep(0.5) + if wake: + self.driver.ScreenLock.unlock() + else: + self.driver.Screen.wake_up() + self.driver.ScreenLock.unlock() + self.driver.Screen.enable_stay_awake() + + def process(self): + Step("安装测试hap并打开") + bundle_name = "com.example.myapplication" + hap_path = Common.sourcepath('debug.hap', "sub_startup_appspawn_debughap") + hap = self.driver.AppManager.has_app(bundle_name) + if hap: + self.driver.AppManager.clear_app_data(bundle_name) + self.driver.AppManager.uninstall_app(bundle_name) + self.driver.AppManager.install_app(hap_path) + else: + self.driver.AppManager.install_app(hap_path) + self.driver.AppManager.start_app(bundle_name) + + result = self.driver.shell("ls /mnt/debug/100/debug_hap").split() + self.driver.Assert.contains(result, bundle_name) + + def teardown(self): + Step("收尾工作.................") + self.driver.AppManager.stop_app(bundle_name) + self.driver.AppManager.uninstall_app(bundle_name) \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0700.json b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0700.json new file mode 100644 index 00000000..5538e209 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0700.json @@ -0,0 +1,15 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device", + "label": "phone" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_debughap/SubStartupAppspawnDebughap0700.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0700.py b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0700.py new file mode 100644 index 00000000..e19ac7fd --- /dev/null +++ b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0700.py @@ -0,0 +1,78 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +import time +from devicetest.core.test_case import TestCase, Step +from hypium.action.os_hypium.device_logger import DeviceLogger +from aw import Common + + +class SubStartupAppspawnDebughap0700(TestCase): + + def __init__(self, controllers): + TestCase.__init__(self, self.TAG, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step(self.devices[0].device_id) + device = self.driver.shell("param get const.product.model") + device = device.replace("\n", "").replace(" ", "") + device = str(device) + Step(device) + + self.driver.hdc("target mount") + self.driver.shell("mv /system/etc/init/init_dec.cfg /system/etc/init/init_dec.cfg_bak") + cfg_path = Common.sourcepath('init_dec.cfg', "sub_startup_appspawn_debughap") + self.driver.push_file(cfg_path, "/system/etc/init") + self.driver.System.reboot() + # 解锁屏幕 + wake = self.driver.Screen.is_on() + time.sleep(0.5) + if wake: + self.driver.ScreenLock.unlock() + else: + self.driver.Screen.wake_up() + self.driver.ScreenLock.unlock() + self.driver.Screen.enable_stay_awake() + + def process(self): + Step("安装测试hap并打开") + bundle_name = "com.example.myapplication" + hap_path = Common.sourcepath('debug.hap', "sub_startup_appspawn_debughap") + hap = self.driver.AppManager.has_app(bundle_name) + if hap: + self.driver.AppManager.clear_app_data(bundle_name) + self.driver.AppManager.uninstall_app(bundle_name) + self.driver.AppManager.install_app(hap_path) + else: + self.driver.AppManager.install_app(hap_path) + self.driver.shell("param set startup.appspawn.sandbox.debughap true") + self.driver.AppManager.start_app(bundle_name) + + has_dir = self.driver.Storage.has_dir("/mnt/debug/100/debug_hap/%s" % bundle_name) + self.driver.Assert.equal(has_dir, True) + result = self.driver.shell("ls /mnt/debug/100/debug_hap/%s" % bundle_name) + self.driver.Assert.contains(result, "Operation not permitted") + + def teardown(self): + Step("收尾工作.................") + self.driver.hdc("target mount") + self.driver.shell("mv /system/etc/init/init_dec.cfg_bak /system/etc/init/init_dec.cfg") + self.driver.AppManager.stop_app(bundle_name) + self.driver.AppManager.uninstall_app(bundle_name) + self.driver.System.reboot() + self.driver.System.wait_for_boot_complete() + self.driver.shell("param set startup.appspawn.sandbox.debughap true") \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0800.json b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0800.json new file mode 100644 index 00000000..d17ff07f --- /dev/null +++ b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0800.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_debughap/SubStartupAppspawnDebughap0800.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0800.py b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0800.py new file mode 100644 index 00000000..7974ad11 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0800.py @@ -0,0 +1,104 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +import time +from devicetest.core.test_case import TestCase, Step +from hypium.action.os_hypium.device_logger import DeviceLogger +from aw import Common + + +class SubStartupAppspawnDebughap0800(TestCase): + + def __init__(self, controllers): + TestCase.__init__(self, self.TAG, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step(self.devices[0].device_id) + device = self.driver.shell("param get const.product.model") + device = device.replace("\n", "").replace(" ", "") + device = str(device) + Step(device) + # 解锁屏幕 + wake = self.driver.Screen.is_on() + time.sleep(0.5) + if wake: + self.driver.ScreenLock.unlock() + else: + self.driver.Screen.wake_up() + self.driver.ScreenLock.unlock() + self.driver.Screen.enable_stay_awake() + + def process(self): + Step("安装测试hap并打开") + bundle_name = "com.example.myapplication" + hap_path = Common.sourcepath('debug.hap', "sub_startup_appspawn_debughap") + hap = self.driver.AppManager.has_app(bundle_name) + if hap: + self.driver.AppManager.clear_app_data(bundle_name) + self.driver.AppManager.uninstall_app(bundle_name) + self.driver.AppManager.install_app(hap_path) + else: + self.driver.AppManager.install_app(hap_path) + self.driver.AppManager.start_app(bundle_name) + + for i in range(1, 5): + for path in {"database", "base"}: + mac_path = self.driver.Storage.has_dir("/data/app/el%d/100/%s/%s" % (i, path, bundle_name)) + sandbox_path = self.driver.Storage.has_dir("/mnt/debug/100/debug_hap/%s/data/storage/el%d/%s" + % (bundle_name, i, path)) + self.driver.Assert.equal(mac_path, sandbox_path) + + if mac_path is True: + mac_path_content = self.driver.shell("ls /data/app/el%d/100/%s/%s" % (i, path, bundle_name)) + sandbox_path_content = self.driver.shell("ls /mnt/debug/100/debug_hap/%s/data/storage/el%d/%s" + % (bundle_name, i, path)) + self.driver.Assert.equal(mac_path_content, sandbox_path_content) + + path_dict = { + "/mnt/hmdfs/100/non_account/merge_view/data": "el2/auth_groups", + "/mnt/hmdfs/100/account/merge_view/data": "el2/distributedfiles", + "/data/app/el2/100/log": "el2/log", + "/data/app/el1/bundle/public": "el1/bundle", + "/mnt/share/100": "el2/share" + } + + for mac, sandbox in path_dict.items(): + if mac != "/mnt/hmdfs/100/non_account/merge_view/data": + mac_path = self.driver.Storage.has_dir("%s/%s" % (mac, bundle_name)) + sandbox_path = self.driver.Storage.has_dir("/mnt/debug/100/debug_hap/%s/data/storage/%s" + % (bundle_name, sandbox)) + self.driver.Assert.equal(mac_path, sandbox_path) + if mac_path is True: + mac_path_content = self.driver.shell("ls %s/%s" % (mac, bundle_name)) + sandbox_path_content = self.driver.shell( + "ls /mnt/debug/100/debug_hap/%s/data/storage/%s" % (bundle_name, sandbox)) + self.driver.Assert.equal(mac_path_content, sandbox_path_content) + else: + mac_path = self.driver.Storage.has_dir("%s" % mac) + sandbox_path = self.driver.Storage.has_dir("/mnt/debug/100/debug_hap/%s/data/storage/%s" + % (bundle_name, sandbox)) + self.driver.Assert.equal(mac_path, sandbox_path) + if mac_path is True: + mac_path_content = self.driver.shell("ls %s" % mac) + sandbox_path_content = self.driver.shell("ls /mnt/debug/100/debug_hap/%s/data/storage/%s" + % (bundle_name, sandbox)) + self.driver.Assert.equal(mac_path_content, sandbox_path_content) + + def teardown(self): + Step("收尾工作.................") + self.driver.AppManager.stop_app(bundle_name) + self.driver.AppManager.uninstall_app(bundle_name) \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0900.json b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0900.json new file mode 100644 index 00000000..ab601307 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0900.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_debughap/SubStartupAppspawnDebughap0900.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0900.py b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0900.py new file mode 100644 index 00000000..67a388ef --- /dev/null +++ b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0900.py @@ -0,0 +1,64 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +import time +from devicetest.core.test_case import TestCase, Step +from hypium.action.os_hypium.device_logger import DeviceLogger +from aw import Common + + +class SubStartupAppspawnDebughap0900(TestCase): + + def __init__(self, controllers): + TestCase.__init__(self, self.TAG, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step(self.devices[0].device_id) + device = self.driver.shell("param get const.product.model") + device = device.replace("\n", "").replace(" ", "") + device = str(device) + Step(device) + # 解锁屏幕 + wake = self.driver.Screen.is_on() + time.sleep(0.5) + if wake: + self.driver.ScreenLock.unlock() + else: + self.driver.Screen.wake_up() + self.driver.ScreenLock.unlock() + self.driver.Screen.enable_stay_awake() + + def process(self): + Step("安装测试hap并打开") + bundle_name = "com.example.myapplication" + hap_path = Common.sourcepath('debug.hap', "sub_startup_appspawn_debughap") + hap = self.driver.AppManager.has_app(bundle_name) + if hap: + self.driver.AppManager.clear_app_data(bundle_name) + self.driver.AppManager.uninstall_app(bundle_name) + self.driver.AppManager.install_app(hap_path) + else: + self.driver.AppManager.install_app(hap_path) + self.driver.AppManager.start_app(bundle_name) + + result = self.driver.shell("ls -Z /mnt/debug/100") + self.driver.Assert.contains(result, "u:object_r:sharefs:s0 debug_hap") + + def teardown(self): + Step("收尾工作.................") + self.driver.AppManager.stop_app(bundle_name) + self.driver.AppManager.uninstall_app(bundle_name) \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_fd/sub_startup_appspawn_fd_0100.json b/test/autotest/sub_startup_appspawn_fd/sub_startup_appspawn_fd_0100.json new file mode 100644 index 00000000..d2ef15d1 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_fd/sub_startup_appspawn_fd_0100.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_fd/SubStartupAppspawnFd0100.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_fd/sub_startup_appspawn_fd_0100.py b/test/autotest/sub_startup_appspawn_fd/sub_startup_appspawn_fd_0100.py new file mode 100644 index 00000000..d65e7ce4 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_fd/sub_startup_appspawn_fd_0100.py @@ -0,0 +1,83 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +from time import sleep +from devicetest.core.test_case import Step, TestCase +from hypium.action.os_hypium.device_logger import DeviceLogger +from aw import Common + + +class SubStartupAppspawnFd0100(TestCase): + + def __init__(self, controllers): + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.TAG, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("预置工作:初始化手机开始.................") + Step(self.devices[0].device_id) + Step("安装测试hap.................") + sourpath = Common.sourcepath("fd.hap", "sub_startup_appspawn_fd") + Step(sourpath) + self.driver.AppManager.install_app(sourpath) + Step("设置系统参数.................") + self.driver.shell('param set persist.sys.abilityms.multi_process_model true') + Step("执行重启..........................") + self.driver.System.reboot() + sleep(3) + self.driver.System.wait_for_boot_complete() + Step("预置工作:检测屏幕是否亮.................") + self.driver.Screen.wake_up() + self.driver.ScreenLock.unlock() + self.driver.Screen.enable_stay_awake() + + def test_step1(self): + self.d = UiExplorer(self.device1) + device_logger = DeviceLogger(self.d) + Step("设置关键字..........................") + device_logger.set_filter_string("ldprocessmanager:OtherProcess") + Step("开启日志..........................") + device_logger.start_log("testFile/Log/log.txt") + Step("打开测试hap.................") + self.driver.start_app("com.acts.childprocessmanager", "EntryAbility") + sleep(3) + Step("点击Start Child Process.................") + self.driver.touch(BY.text("Start Child Process")) + Step("点击Start Ark Process.................") + self.driver.touch(BY.text("Start Ark Process")) + sleep(10) + Step("停止日志..........................") + device_logger.stop_log() + Step("校验日志内容..........................") + Step("查看childprocessmanager服务pid..........................") + pid = self.driver.System.get_pid('com.acts.childprocessmanager:OtherProcess1') + result = self.driver.shell("ls -al /proc/%d/fd" % pid) + Step("步骤6:预期结果校验") + self.driver.Assert.contains(result, "/data/storage/el2/base/haps/entry/files/test.txt") + self.driver.Assert.contains(result, "/data/storage/el2/base/haps/entry/files/test2.txt") + + def teardown(self): + Step("收尾工作.................") + Step("收尾工作:卸载hap......................") + self.driver.AppManager.clear_app_data('com.acts.childprocessmanager') + self.driver.AppManager.uninstall_app('com.acts.childprocessmanager') + Step("恢复系统参数.................") + self.driver.hdc('param set persist.sys.abilityms.multi_process_model false') + Step("执行重启..........................") + self.driver.System.reboot() + sleep(3) + self.driver.System.wait_for_boot_complete() diff --git a/test/autotest/sub_startup_appspawn_ftpd/sub_startup_appspawn_ftpd_0100.json b/test/autotest/sub_startup_appspawn_ftpd/sub_startup_appspawn_ftpd_0100.json new file mode 100644 index 00000000..850e6d6a --- /dev/null +++ b/test/autotest/sub_startup_appspawn_ftpd/sub_startup_appspawn_ftpd_0100.json @@ -0,0 +1,15 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device", + "label": "phone" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_ftpd/SubStartupAppspawnFtpd0100.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_ftpd/sub_startup_appspawn_ftpd_0100.py b/test/autotest/sub_startup_appspawn_ftpd/sub_startup_appspawn_ftpd_0100.py new file mode 100644 index 00000000..a2385b2d --- /dev/null +++ b/test/autotest/sub_startup_appspawn_ftpd/sub_startup_appspawn_ftpd_0100.py @@ -0,0 +1,64 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +from devicetest.core.test_case import Step, TestCase + +from aw import Common + + +class SubStartupAppspawnFtpd0100(TestCase): + + def __init__(self, controllers): + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.TAG, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("预置工作:初始化手机开始.................") + Step(self.devices[0].device_id) + Step("设置系统参数sysctl -w kernel.xpm.xpm_mode=0..........................") + self.driver.hdc("target mount") + self.driver.shell("sed -i 's%/proc/sys/kernel/xpm/xpm_mode 4%/proc/sys/kernel/xpm/xpm_mode 0%g' /system/etc/init/key_enable.cfg") + self.driver.shell("reboot") + self.driver.System.wait_for_boot_complete() + set_result = self.driver.shell("sysctl -w kernel.xpm.xpm_mode=0") + self.driver.Assert.contains(set_result, "kernel.xpm.xpm_mode = 0") + Step("安装测试hap.................") + sourpath = Common.sourcepath("ftpd.hap", "sub_startup_appspawn_ftpd") + Step(sourpath) + self.driver.AppManager.install_app(sourpath) + Step("预置工作:检测屏幕是否亮.................") + self.driver.Screen.wake_up() + self.driver.ScreenLock.unlock() + self.driver.Screen.enable_stay_awake() + + def test_step1(self): + Step("打开测试hap.................") + self.driver.start_app("com.ohos.myapplication", "EntryAbility") + Step("打开bftpd.................") + aa_resutl = self.driver.shell("aa process -b com.ohos.myapplication -a EntryAbility -D '/system/bin/bftpd -D -p 9021' -S") + self.driver.Assert.contains(aa_resutl, "start native process successfully") + Step("校验bftpd进程") + pid = self.driver.System.get_pid('bftpd') + + def teardown(self): + Step("收尾工作.................") + Step("收尾工作:卸载hap......................") + self.driver.AppManager.clear_app_data('com.ohos.myapplication') + self.driver.AppManager.uninstall_app('com.ohos.myapplication') + Step("恢复系统参数......................") + recovery_result = self.driver.shell("sysctl -w kernel.xpm.xpm_mode=4") + self.driver.Assert.contains(recovery_result, "kernel.xpm.xpm_mode = 4") diff --git a/test/autotest/sub_startup_appspawn_hnpinstall/sub_startup_appspawn_hnpinstall_0100.json b/test/autotest/sub_startup_appspawn_hnpinstall/sub_startup_appspawn_hnpinstall_0100.json new file mode 100644 index 00000000..12504c72 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnpinstall/sub_startup_appspawn_hnpinstall_0100.json @@ -0,0 +1,12 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["sub_startup_appspawn_hnpinstall/SubStartupAppspawnHnpinstall0100.py"] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_hnpinstall/sub_startup_appspawn_hnpinstall_0100.py b/test/autotest/sub_startup_appspawn_hnpinstall/sub_startup_appspawn_hnpinstall_0100.py new file mode 100644 index 00000000..8aa9ec00 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnpinstall/sub_startup_appspawn_hnpinstall_0100.py @@ -0,0 +1,75 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from devicetest.core.test_case import TestCase, Step, CheckPoint +from devicetest.core.test_case import Step, TestCase +from hypium.model import UiParam, WindowFilter +import os +from aw import Common + + +class SubStartupAppspawnHnpinstall0100(TestCase): + + def __init__(self, controllers): + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.TAG, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("预置工作:初始化手机开始.................") + self.driver = UiDriver(self.device1) + Step("预置工作:检测屏幕是否亮.................") + self.driver.enable_auto_wakeup(self.device1) + Step("预置工作:滑动解锁.................") + self.driver.swipe(UiParam.UP, side=UiParam.BOTTOM) + Step('设置屏幕常亮') + self.driver.Screen.enable_stay_awake() + + def test_step1(self): + Step("步骤1:安装测试应用") + path = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) + hnp = os.path.abspath(os.path.join( + os.path.join(path, "testFile"), 'SUB_STARTUP_APPSPAWN_NATIVE/entry-default-hnpinsall.hap')) + isHap = self.driver.has_app("com.example.hnp_test") + if(isHap): + self.driver.uninstall_app("com.example.hnp_test") + else: + pass + self.driver.install_app(hnp) + Step("是否刷root包") + isroot = self.driver.shell("ls") + Step("步骤2:展示公有目录列表") + result1 = self.driver.shell("ls /data/app/el1/bundle/100/hnppublic") + self.driver.Assert.contains(result1, "hnpsample.org") + if ("Permission denied" in isroot): + Step("步骤4:执行公有目录软链二进制") + th = Common.hnpexecute_async(self.driver, "/data/app/el1/bundle/100/hnppublic/bin/hnpsample 5") + th.start() + result3 = self.driver.shell("ps -ef | grep hnpsample | grep -v grep") + self.driver.Assert.contains(result3, "hnpsample") + else: + Step("步骤3:展示私有目录列表") + result2 = self.driver.shell("ls /data/app/el1/bundle/100/hnp/com.example.hnp_test") + self.driver.Assert.contains(result2, "node.org") + Step("步骤4:执行公有目录软链二进制") + result3 = self.driver.hdc("hdc shell /data/app/el1/bundle/100/hnppublic/bin/hnpsample") + self.driver.Assert.contains(result3, "start hnp sample") + self.driver.Assert.contains(result3, "hnp sample end") + + def teardown(self): + Step("收尾工作:卸载hap") + self.driver.uninstall_app("com.example.hnp_test") diff --git a/test/autotest/sub_startup_appspawn_hnpinstall/sub_startup_appspawn_hnpinstall_0200.json b/test/autotest/sub_startup_appspawn_hnpinstall/sub_startup_appspawn_hnpinstall_0200.json new file mode 100644 index 00000000..8a17d83b --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnpinstall/sub_startup_appspawn_hnpinstall_0200.json @@ -0,0 +1,12 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["sub_startup_appspawn_hnpinstall/SubStartupAppspawnHnpinstall0200.py"] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_hnpinstall/sub_startup_appspawn_hnpinstall_0200.py b/test/autotest/sub_startup_appspawn_hnpinstall/sub_startup_appspawn_hnpinstall_0200.py new file mode 100644 index 00000000..4831a3f7 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnpinstall/sub_startup_appspawn_hnpinstall_0200.py @@ -0,0 +1,69 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from devicetest.core.test_case import TestCase, Step, CheckPoint +from devicetest.core.test_case import Step, TestCase +from hypium.model import UiParam, WindowFilter +import os + + +class SubStartupAppspawnHnpinstall0200(TestCase): + + def __init__(self, controllers): + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.TAG, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("预置工作:初始化手机开始.................") + self.driver = UiDriver(self.device1) + Step("预置工作:检测屏幕是否亮.................") + self.driver.enable_auto_wakeup(self.device1) + Step("预置工作:滑动解锁.................") + self.driver.swipe(UiParam.UP, side=UiParam.BOTTOM) + Step('设置屏幕常亮') + self.driver.Screen.enable_stay_awake() + + def test_step1(self): + Step("步骤1:安装测试应用") + path = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) + hnp = os.path.abspath(os.path.join( + os.path.join(path, "testFile"), 'SUB_STARTUP_APPSPAWN_NATIVE/entry-default-hnpinsall.hap')) + isHap = self.driver.has_app("com.example.hnp_test") + if(isHap): + self.driver.uninstall_app("com.example.hnp_test") + else: + pass + self.driver.install_app(hnp) + Step("步骤2:读取公有目录列表") + result1 = self.driver.shell("cat /data/app/el1/bundle/100/hnppublic/hnpsample.org/hnpsample_1.1/hnp.json") + self.driver.Assert.contains(result1, "hnpsample") + Step("是否刷root包") + isroot = self.driver.shell("ls") + if("Permission denied" in isroot): + Step("步骤3:读取私有目录列表") + result2 = self.driver.shell( + "cat /data/app/el1/bundle/100/hnp/com.example.hnp_test/node.org/node_1.0/hnp.json") + self.driver.Assert.contains(result2, "Permission denied") + else: + Step("步骤3:读取私有目录列表") + result2 = self.driver.shell("cat /data/app/el1/bundle/100/hnp/com.example.hnp_test/node.org/node_1.0/hnp.json") + self.driver.Assert.contains(result2, "node") + + def teardown(self): + Step("收尾工作:卸载hap") + self.driver.uninstall_app("com.example.hnp_test") diff --git a/test/autotest/sub_startup_appspawn_hnpinstall/sub_startup_appspawn_hnpinstall_0300.json b/test/autotest/sub_startup_appspawn_hnpinstall/sub_startup_appspawn_hnpinstall_0300.json new file mode 100644 index 00000000..90f6a911 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnpinstall/sub_startup_appspawn_hnpinstall_0300.json @@ -0,0 +1,12 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["sub_startup_appspawn_hnpinstall/SubStartupAppspawnHnpinstall0300.py"] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_hnpinstall/sub_startup_appspawn_hnpinstall_0300.py b/test/autotest/sub_startup_appspawn_hnpinstall/sub_startup_appspawn_hnpinstall_0300.py new file mode 100644 index 00000000..268ea56f --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnpinstall/sub_startup_appspawn_hnpinstall_0300.py @@ -0,0 +1,78 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from devicetest.core.test_case import TestCase, Step, CheckPoint +from devicetest.core.test_case import Step, TestCase +from hypium.model import UiParam, WindowFilter +import os + + +class SubStartupAppspawnHnpinstall0300(TestCase): + + def __init__(self, controllers): + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.TAG, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("预置工作:初始化手机开始.................") + self.driver = UiDriver(self.device1) + Step("预置工作:检测屏幕是否亮.................") + self.driver.enable_auto_wakeup(self.device1) + Step("预置工作:滑动解锁.................") + self.driver.swipe(UiParam.UP, side=UiParam.BOTTOM) + Step('设置屏幕常亮') + self.driver.Screen.enable_stay_awake() + + def test_step1(self): + Step("步骤1:安装测试应用") + path = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) + hnp = os.path.abspath(os.path.join( + os.path.join(path, "testFile"), 'SUB_STARTUP_APPSPAWN_NATIVE/entry-default-hnpinsall.hap')) + isHap = self.driver.has_app("com.example.hnp_test") + if (isHap): + self.driver.uninstall_app("com.example.hnp_test") + else: + pass + self.driver.install_app(hnp) + isroot = self.driver.shell("ls") + if ("Permission denied" in isroot): + Step("步骤2:修改公有目录文件内容") + data = {"name": "zsj", "sex": "girl", "age": 31}; + result1 = self.driver.shell(f"echo {data} > /data/app/el1/bundle/100/hnppublic/hnpsample.org/hnpsample_1.1/hnp.json") + self.driver.Assert.contains(result1, "Permission denied") + Step("步骤3:修改私有目录文件内容") + data = {"name": "private", "sex": "girl", "age": 31}; + result2 = self.driver.shell(f"echo {data} > /data/app/el1/bundle/100/hnp/com.example.hnp_test/node.org/node_1.0/hnp.json") + self.driver.Assert.contains(result2, "Permission denied") + else: + Step("步骤2:修改公有目录文件内容") + data = {"name": "zsj", "sex": "girl", "age": 31}; + self.driver.shell(f"echo {data} > /data/app/el1/bundle/100/hnppublic/hnpsample.org/hnpsample_1.1/hnp.json") + result1 = self.driver.shell("cat /data/app/el1/bundle/100/hnppublic/hnpsample.org/hnpsample_1.1/hnp.json") + self.driver.Assert.contains(result1, "zsj") + Step("步骤3:修改私有目录文件内容") + data = {"name": "private", "sex": "girl", "age": 31}; + self.driver.shell( + f"echo {data} > /data/app/el1/bundle/100/hnp/com.example.hnp_test/node.org/node_1.0/hnp.json") + result2 = self.driver.shell( + "cat /data/app/el1/bundle/100/hnp/com.example.hnp_test/node.org/node_1.0/hnp.json") + self.driver.Assert.contains(result2, "private") + + def teardown(self): + Step("收尾工作:卸载hap") + self.driver.uninstall_app("com.example.hnp_test") diff --git a/test/autotest/sub_startup_appspawn_hnpinstall/sub_startup_appspawn_hnpinstall_0400.json b/test/autotest/sub_startup_appspawn_hnpinstall/sub_startup_appspawn_hnpinstall_0400.json new file mode 100644 index 00000000..eab617a8 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnpinstall/sub_startup_appspawn_hnpinstall_0400.json @@ -0,0 +1,12 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["sub_startup_appspawn_hnpinstall/SubStartupAppspawnHnpinstall0400.py"] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_hnpinstall/sub_startup_appspawn_hnpinstall_0400.py b/test/autotest/sub_startup_appspawn_hnpinstall/sub_startup_appspawn_hnpinstall_0400.py new file mode 100644 index 00000000..67daef31 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnpinstall/sub_startup_appspawn_hnpinstall_0400.py @@ -0,0 +1,73 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from devicetest.core.test_case import TestCase, Step, CheckPoint +from devicetest.core.test_case import Step, TestCase +from hypium.model import UiParam, WindowFilter +import os + + +class SubStartupAppspawnHnpinstall0400(TestCase): + + def __init__(self, controllers): + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.TAG, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("预置工作:初始化手机开始.................") + self.driver = UiDriver(self.device1) + Step("预置工作:检测屏幕是否亮.................") + self.driver.enable_auto_wakeup(self.device1) + Step("预置工作:滑动解锁.................") + self.driver.swipe(UiParam.UP, side=UiParam.BOTTOM) + Step('设置屏幕常亮') + self.driver.Screen.enable_stay_awake() + + def test_step1(self): + Step("步骤1:安装测试应用") + path = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) + hnp = os.path.abspath(os.path.join( + os.path.join(path, "testFile"), 'SUB_STARTUP_APPSPAWN_NATIVE/entry-default-hnpinsall.hap')) + isHap = self.driver.has_app("com.example.hnp_test") + if (isHap): + self.driver.uninstall_app("com.example.hnp_test") + else: + pass + self.driver.install_app(hnp) + isroot = self.driver.shell("ls") + if ("Permission denied" in isroot): + Step("步骤2:修改公有目录文件内容") + result1 = self.driver.shell(f"touch /data/app/el1/bundle/100/hnppublic/hnpsample.org/hnpsample_1.1/123.txt") + self.driver.Assert.contains(result1, "Permission denied") + Step("步骤3:修改私有目录文件内容") + result2 = self.driver.shell(f"touch /data/app/el1/bundle/100/hnp/com.example.hnp_test/node.org/node_1.0/abc.txt") + self.driver.Assert.contains(result2, "Permission denied") + else: + Step("步骤2:修改公有目录文件内容") + self.driver.shell(f"touch /data/app/el1/bundle/100/hnppublic/hnpsample.org/hnpsample_1.1/123.txt") + result1 = self.driver.shell("ls /data/app/el1/bundle/100/hnppublic/hnpsample.org/hnpsample_1.1/") + self.driver.Assert.contains(result1, "123.txt") + Step("步骤3:修改私有目录文件内容") + self.driver.shell(f"touch /data/app/el1/bundle/100/hnp/com.example.hnp_test/node.org/node_1.0/abc.txt") + result2 = self.driver.shell( + "ls /data/app/el1/bundle/100/hnp/com.example.hnp_test/node.org/node_1.0/") + self.driver.Assert.contains(result2, "abc.txt") + + def teardown(self): + Step("收尾工作:卸载hap") + self.driver.uninstall_app("com.example.hnp_test") diff --git a/test/autotest/sub_startup_appspawn_hnpinstall/sub_startup_appspawn_hnpinstall_0500.json b/test/autotest/sub_startup_appspawn_hnpinstall/sub_startup_appspawn_hnpinstall_0500.json new file mode 100644 index 00000000..2cd61186 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnpinstall/sub_startup_appspawn_hnpinstall_0500.json @@ -0,0 +1,12 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["sub_startup_appspawn_hnpinstall/SubStartupAppspawnHnpinstall0500.py"] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_hnpinstall/sub_startup_appspawn_hnpinstall_0500.py b/test/autotest/sub_startup_appspawn_hnpinstall/sub_startup_appspawn_hnpinstall_0500.py new file mode 100644 index 00000000..ad73decf --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnpinstall/sub_startup_appspawn_hnpinstall_0500.py @@ -0,0 +1,75 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from devicetest.core.test_case import TestCase, Step, CheckPoint +from devicetest.core.test_case import Step, TestCase +from hypium.model import UiParam, WindowFilter +import os + + +class SubStartupAppspawnHnpinstall0500(TestCase): + + def __init__(self, controllers): + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.TAG, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("预置工作:初始化手机开始.................") + self.driver = UiDriver(self.device1) + Step("预置工作:检测屏幕是否亮.................") + self.driver.enable_auto_wakeup(self.device1) + Step("预置工作:滑动解锁.................") + self.driver.swipe(UiParam.UP, side=UiParam.BOTTOM) + Step('设置屏幕常亮') + self.driver.Screen.enable_stay_awake() + + def test_step1(self): + Step("步骤1:安装测试应用") + path = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) + hnp = os.path.abspath(os.path.join( + os.path.join(path, "testFile"), 'SUB_STARTUP_APPSPAWN_NATIVE/entry-default-hnpinsall.hap')) + isHap = self.driver.has_app("com.example.hnp_test") + if (isHap): + self.driver.uninstall_app("com.example.hnp_test") + else: + pass + self.driver.install_app(hnp) + isroot = self.driver.shell("ls") + if ("Permission denied" in isroot): + Step("步骤2:修改公有目录文件内容") + result1 = self.driver.shell( + f"rm -rf /data/app/el1/bundle/100/hnppublic/hnpsample.org/hnpsample_1.1/hnp.json") + self.driver.Assert.contains(result1, "Permission denied") + Step("步骤3:修改私有目录文件内容") + result2 = self.driver.shell( + f"rm -rf /data/app/el1/bundle/100/hnp/com.example.hnp_test/node.org/node_1.0/hnp.json") + self.driver.Assert.contains(result2, "Permission denied") + else: + Step("步骤2:修改公有目录文件内容") + self.driver.shell(f"rm -rf /data/app/el1/bundle/100/hnppublic/hnpsample.org/hnpsample_1.1/hnp.json") + result1 = self.driver.shell("ls /data/app/el1/bundle/100/hnppublic/hnpsample.org/hnpsample_1.1/") + self.driver.Assert.is_true("hnp.json" not in result1) + Step("步骤3:修改私有目录文件内容") + self.driver.shell(f"rm -rf /data/app/el1/bundle/100/hnp/com.example.hnp_test/node.org/node_1.0/hnp.json") + result2 = self.driver.shell( + "ls /data/app/el1/bundle/100/hnp/com.example.hnp_test/node.org/node_1.0/") + self.driver.Assert.is_true("hnp.json" not in result2) + + def teardown(self): + Step("收尾工作:卸载hap") + self.driver.uninstall_app("com.example.hnp_test") diff --git a/test/autotest/sub_startup_appspawn_hnpinstall/sub_startup_appspawn_hnpinstall_0600.json b/test/autotest/sub_startup_appspawn_hnpinstall/sub_startup_appspawn_hnpinstall_0600.json new file mode 100644 index 00000000..009ebc7c --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnpinstall/sub_startup_appspawn_hnpinstall_0600.json @@ -0,0 +1,12 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["sub_startup_appspawn_hnpinstall/SubStartupAppspawnHnpinstall0600.py"] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_hnpinstall/sub_startup_appspawn_hnpinstall_0600.py b/test/autotest/sub_startup_appspawn_hnpinstall/sub_startup_appspawn_hnpinstall_0600.py new file mode 100644 index 00000000..20657682 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnpinstall/sub_startup_appspawn_hnpinstall_0600.py @@ -0,0 +1,75 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from devicetest.core.test_case import TestCase, Step, CheckPoint +from devicetest.core.test_case import Step, TestCase +from hypium.model import UiParam, WindowFilter +import os + + +class SubStartupAppspawnHnpinstall0600(TestCase): + + def __init__(self, controllers): + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.TAG, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("预置工作:初始化手机开始.................") + self.driver = UiDriver(self.device1) + Step("预置工作:检测屏幕是否亮.................") + self.driver.enable_auto_wakeup(self.device1) + Step("预置工作:滑动解锁.................") + self.driver.swipe(UiParam.UP, side=UiParam.BOTTOM) + Step('设置屏幕常亮') + self.driver.Screen.enable_stay_awake() + + def test_step1(self): + Step("步骤1:安装测试应用") + path = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) + hnp = os.path.abspath(os.path.join( + os.path.join(path, "testFile"), 'SUB_STARTUP_APPSPAWN_NATIVE/entry-default-hnpinsall.hap')) + isHap = self.driver.has_app("com.example.hnp_test") + if (isHap): + self.driver.uninstall_app("com.example.hnp_test") + else: + pass + self.driver.install_app(hnp) + isroot = self.driver.shell("ls") + if ("Permission denied" in isroot): + Step("步骤2:修改公有目录文件内容") + result1 = self.driver.shell( + f"chmod 777 /data/app/el1/bundle/100/hnppublic/hnpsample.org/hnpsample_1.1/hnp.json") + self.driver.Assert.contains(result1, "Operation not permitted") + Step("步骤3:修改私有目录文件内容") + result2 = self.driver.shell( + f"chmod 777 /data/app/el1/bundle/100/hnp/com.example.hnp_test/node.org/node_1.0/hnp.json") + self.driver.Assert.contains(result2, "Permission denied") + else: + Step("步骤2:修改公有目录文件内容") + self.driver.shell(f"chmod 777 /data/app/el1/bundle/100/hnppublic/hnpsample.org/hnpsample_1.1/hnp.json") + result1 = self.driver.shell("ls -l /data/app/el1/bundle/100/hnppublic/hnpsample.org/hnpsample_1.1/hnp.json") + self.driver.Assert.contains(result1, "rwxrwxrwx") + Step("步骤3:修改私有目录文件内容") + self.driver.shell(f"chmod 777 /data/app/el1/bundle/100/hnp/com.example.hnp_test/node.org/node_1.0/hnp.json") + result2 = self.driver.shell( + "ls -l /data/app/el1/bundle/100/hnp/com.example.hnp_test/node.org/node_1.0/hnp.json") + self.driver.Assert.contains(result2, "rwxrwxrwx") + + def teardown(self): + Step("收尾工作:卸载hap") + self.driver.uninstall_app("com.example.hnp_test") diff --git a/test/autotest/sub_startup_appspawn_hnpinstall/sub_startup_appspawn_hnpinstall_0700.json b/test/autotest/sub_startup_appspawn_hnpinstall/sub_startup_appspawn_hnpinstall_0700.json new file mode 100644 index 00000000..94f5f127 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnpinstall/sub_startup_appspawn_hnpinstall_0700.json @@ -0,0 +1,12 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["sub_startup_appspawn_hnpinstall/SubStartupAppspawnHnpinstall0700.py"] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_hnpinstall/sub_startup_appspawn_hnpinstall_0700.py b/test/autotest/sub_startup_appspawn_hnpinstall/sub_startup_appspawn_hnpinstall_0700.py new file mode 100644 index 00000000..e1bfc549 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnpinstall/sub_startup_appspawn_hnpinstall_0700.py @@ -0,0 +1,76 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from devicetest.core.test_case import TestCase, Step, CheckPoint +from devicetest.core.test_case import Step, TestCase +from hypium.model import UiParam, WindowFilter +import os + + +class SubStartupAppspawnHnpinstall0700(TestCase): + + def __init__(self, controllers): + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.TAG, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("预置工作:初始化手机开始.................") + self.driver = UiDriver(self.device1) + Step("预置工作:检测屏幕是否亮.................") + self.driver.enable_auto_wakeup(self.device1) + Step("预置工作:滑动解锁.................") + self.driver.swipe(UiParam.UP, side=UiParam.BOTTOM) + Step('设置屏幕常亮') + self.driver.Screen.enable_stay_awake() + + def test_step1(self): + Step("步骤1:安装测试应用") + path = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) + hnp = os.path.abspath(os.path.join( + os.path.join(path, "testFile"), 'SUB_STARTUP_APPSPAWN_NATIVE/entry-default-hnpinsall.hap')) + isHap = self.driver.has_app("com.example.hnp_test") + if (isHap): + self.driver.uninstall_app("com.example.hnp_test") + else: + pass + self.driver.install_app(hnp) + isroot = self.driver.shell("ls") + if ("Permission denied" in isroot): + Step("步骤2:修改公有目录文件内容") + result1 = self.driver.shell( + f"mv /data/app/el1/bundle/100/hnppublic/hnpsample.org/hnpsample_1.1/hnp.json /data/app/el1/bundle/100/hnppublic/hnpsample.org/hnpsample_1.1/zsj.json") + self.driver.Assert.contains(result1, "Permission denied") + Step("步骤3:修改私有目录文件内容") + result2 = self.driver.shell( + f"mv /data/app/el1/bundle/100/hnp/com.example.hnp_test/node.org/node_1.0/hnp.json /data/app/el1/bundle/100/hnp/com.example.hnp_test/node.org/node_1.0/zsj.json") + self.driver.Assert.contains(result2, "Permission denied") + else: + Step("步骤2:修改公有目录文件内容") + self.driver.shell(f"mv /data/app/el1/bundle/100/hnppublic/hnpsample.org/hnpsample_1.1/hnp.json /data/app/el1/bundle/100/hnppublic/hnpsample.org/hnpsample_1.1/zsj.json") + result1 = self.driver.shell("ls /data/app/el1/bundle/100/hnppublic/hnpsample.org/hnpsample_1.1/") + self.driver.Assert.contains(result1, "zsj.json") + Step("步骤3:修改私有目录文件内容") + self.driver.shell(f"mv /data/app/el1/bundle/100/hnp/com.example.hnp_test/node.org/node_1.0/hnp.json /data/app/el1/bundle/100/hnp/com.example.hnp_test/node.org/node_1.0/zsj.json") + result2 = self.driver.shell( + "ls /data/app/el1/bundle/100/hnp/com.example.hnp_test/node.org/node_1.0/") + self.driver.Assert.contains(result2, "zsj.json") + + +def teardown(self): + Step("收尾工作:卸载hap") + self.driver.uninstall_app("com.example.hnp_test") diff --git a/test/autotest/sub_startup_appspawn_hnpinstall/sub_startup_appspawn_hnpinstall_0800.json b/test/autotest/sub_startup_appspawn_hnpinstall/sub_startup_appspawn_hnpinstall_0800.json new file mode 100644 index 00000000..646ceb0d --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnpinstall/sub_startup_appspawn_hnpinstall_0800.json @@ -0,0 +1,12 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["sub_startup_appspawn_hnpinstall/SubStartupAppspawnHnpinstall0800.py"] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_hnpinstall/sub_startup_appspawn_hnpinstall_0800.py b/test/autotest/sub_startup_appspawn_hnpinstall/sub_startup_appspawn_hnpinstall_0800.py new file mode 100644 index 00000000..b43d38a0 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnpinstall/sub_startup_appspawn_hnpinstall_0800.py @@ -0,0 +1,79 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from devicetest.core.test_case import TestCase, Step, CheckPoint +from devicetest.core.test_case import Step, TestCase +from hypium.model import UiParam, WindowFilter +import os + + +class SubStartupAppspawnHnpinstall0800(TestCase): + + def __init__(self, controllers): + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.TAG, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("预置工作:初始化手机开始.................") + self.driver = UiDriver(self.device1) + Step("预置工作:检测屏幕是否亮.................") + self.driver.enable_auto_wakeup(self.device1) + Step("预置工作:滑动解锁.................") + self.driver.swipe(UiParam.UP, side=UiParam.BOTTOM) + Step('设置屏幕常亮') + self.driver.Screen.enable_stay_awake() + + def test_step1(self): + Step("步骤1:安装测试应用") + path = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) + hnp = os.path.abspath(os.path.join( + os.path.join(path, "testFile"), 'SUB_STARTUP_APPSPAWN_NATIVE/entry-default-hnpinsall.hap')) + isHap = self.driver.has_app("com.example.hnp_test") + if (isHap): + self.driver.uninstall_app("com.example.hnp_test") + else: + pass + self.driver.install_app(hnp) + isroot = self.driver.shell("ls") + if ("Permission denied" in isroot): + Step("步骤2:修改公有目录文件内容") + result1 = self.driver.shell( + f"cp /data/app/el1/bundle/100/hnppublic/hnpsample.org/hnpsample_1.1/hnp.json /data/app/el1/bundle/100/hnppublic/hnpsample.org/hnpsample_1.1/zsj.json") + self.driver.Assert.contains(result1, "Permission denied") + Step("步骤3:修改私有目录文件内容") + result2 = self.driver.shell( + f"cp /data/app/el1/bundle/100/hnp/com.example.hnp_test/node.org/node_1.0/hnp.json /data/app/el1/bundle/100/hnp/com.example.hnp_test/node.org/node_1.0/zsj.json") + self.driver.Assert.contains(result2, "Permission denied") + else: + Step("步骤2:修改公有目录文件内容") + self.driver.shell( + f"cp /data/app/el1/bundle/100/hnppublic/hnpsample.org/hnpsample_1.1/hnp.json /data/app/el1/bundle/100/hnppublic/hnpsample.org/hnpsample_1.1/zsj.json") + result1 = self.driver.shell("ls /data/app/el1/bundle/100/hnppublic/hnpsample.org/hnpsample_1.1/") + self.driver.Assert.contains(result1, "zsj.json") + self.driver.Assert.contains(result1, "hnp.json") + Step("步骤3:修改私有目录文件内容") + self.driver.shell( + f"cp /data/app/el1/bundle/100/hnp/com.example.hnp_test/node.org/node_1.0/hnp.json /data/app/el1/bundle/100/hnp/com.example.hnp_test/node.org/node_1.0/zsj.json") + result2 = self.driver.shell( + "ls /data/app/el1/bundle/100/hnp/com.example.hnp_test/node.org/node_1.0/") + self.driver.Assert.contains(result2, "zsj.json") + self.driver.Assert.contains(result2, "hnp.json") + + def teardown(self): + Step("收尾工作:卸载hap") + self.driver.uninstall_app("com.example.hnp_test") diff --git a/test/autotest/sub_startup_appspawn_hnpinstall/sub_startup_appspawn_hnpinstall_0900.json b/test/autotest/sub_startup_appspawn_hnpinstall/sub_startup_appspawn_hnpinstall_0900.json new file mode 100644 index 00000000..6598b823 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnpinstall/sub_startup_appspawn_hnpinstall_0900.json @@ -0,0 +1,12 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["sub_startup_appspawn_hnpinstall/SubStartupAppspawnHnpinstall0900.py"] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_hnpinstall/sub_startup_appspawn_hnpinstall_0900.py b/test/autotest/sub_startup_appspawn_hnpinstall/sub_startup_appspawn_hnpinstall_0900.py new file mode 100644 index 00000000..24bae3ed --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnpinstall/sub_startup_appspawn_hnpinstall_0900.py @@ -0,0 +1,72 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from devicetest.core.test_case import TestCase, Step, CheckPoint +from devicetest.core.test_case import Step, TestCase +from hypium.model import UiParam, WindowFilter +import os +from aw import Common + + +class SubStartupAppspawnHnpinstall0900(TestCase): + + def __init__(self, controllers): + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.TAG, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("预置工作:初始化手机开始.................") + self.driver = UiDriver(self.device1) + Step("预置工作:检测屏幕是否亮.................") + self.driver.enable_auto_wakeup(self.device1) + Step("预置工作:滑动解锁.................") + self.driver.swipe(UiParam.UP, side=UiParam.BOTTOM) + Step('设置屏幕常亮') + self.driver.Screen.enable_stay_awake() + + def test_step1(self): + Step("步骤1:安装测试应用") + path = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) + hnp = os.path.abspath(os.path.join( + os.path.join(path, "testFile"), 'SUB_STARTUP_APPSPAWN_NATIVE/entry-default-hnpinsall.hap')) + isHap = self.driver.has_app("com.example.hnp_test") + if (isHap): + self.driver.uninstall_app("com.example.hnp_test") + else: + pass + self.driver.install_app(hnp) + Step("是否刷root包") + isroot = self.driver.shell("ls") + if ("Permission denied" in isroot): + Step("步骤2:执行公有目录二进制文件") + th = Common.hnpexecute_async(self.driver, "/data/app/el1/bundle/100/hnppublic/bin/hnpsample 5") + th.start() + result3 = self.driver.shell("ps -ef | grep hnpsample | grep -v grep") + self.driver.Assert.contains(result3, "hnpsample") + Step("步骤3:读取私有目录列表") + result2 = self.driver.shell("./data/app/el1/bundle/100/hnp/com.example.hnp_test/node.org/node_1.0/bin/node") + self.driver.Assert.contains(result2, "inaccessible or not found") + else: + Step("步骤2:执行公有目录二进制文件") + result1 = self.driver.shell("./data/app/el1/bundle/100/hnppublic/hnpsample.org/hnpsample_1.1/bin/hnpsample") + self.driver.Assert.contains(result1, "start hnp sample") + self.driver.Assert.contains(result1, "hnp sample end") + + def teardown(self): + Step("收尾工作:卸载hap") + self.driver.uninstall_app("com.example.hnp_test") -- Gitee