diff --git a/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_0100.json b/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_0100.json new file mode 100644 index 0000000000000000000000000000000000000000..d8dcef8d6645dcd8bd860eb3c860a2c71f0bc9c6 --- /dev/null +++ b/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_0100.json @@ -0,0 +1,12 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_0100.py"] + } +} \ No newline at end of file diff --git a/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_0100.py b/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_0100.py new file mode 100644 index 0000000000000000000000000000000000000000..db4102e27167a653e9189412793befc2afefb151 --- /dev/null +++ b/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_0100.py @@ -0,0 +1,83 @@ +# Copyright (c) 2024 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 import * +from hypium.model import UiParam, WindowFilter +from aw import Common +import time + + +class SUB_STARTUP_APPSPAWN_NATIVESPAWN_0100(TestCase): + + def __init__(self, controllers): + self.TAG = self.__class__.__name__ + 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() + Step('获取权限状态') + isStatus = self.driver.shell("param get persist.sys.abilityms.multi_process_model") + if ("true" in isStatus): + pass + else: + Step('设置权限为true') + self.driver.shell("param set persist.sys.abilityms.multi_process_model true") + Step('重启生效') + self.driver.shell("reboot") + self.driver.System.wait_for_boot_complete() + self.driver.ScreenLock.unlock() + + def test_step1(self): + Step("步骤1:安装测试应用") + hap = Common.sourcepath('entry-default-nativespawn.hap', "SUB_STARTUP_STABILITY_APPSPAWN") + isHap = self.driver.has_app("com.acts.childprocessmanager") + if(isHap): + self.driver.uninstall_app("com.acts.childprocessmanager") + else: + pass + self.driver.install_app(hap) + Step("步骤2:打开测试应用") + self.driver.start_app("com.acts.childprocessmanager") + Step("步骤3:点击StartArk用例按钮") + self.driver.touch(BY.text("StartArk用例")) + Step("步骤4:首次获取nativesapwn进程号") + pid1 = self.driver.System.get_pid("nativespawn") + Step("步骤5:点击start Native Process Isolated按钮") + self.driver.touch(BY.text("start Native Process Isolated")) + Step("步骤6:第二次获取nativesapwn进程号") + pid2 = self.driver.System.get_pid("nativespawn") + Step("步骤7:关闭测试应用") + self.driver.stop_app("com.acts.childprocessmanager") + Step("步骤8:第三次获取nativesapwn进程号") + pid3 = self.driver.System.get_pid("nativespawn") + Step("步骤9:预期结果校验") + self.driver.Assert.equal(pid1, None) + self.driver.Assert.not_equal(pid2, None) + self.driver.Assert.equal(pid3, None) + + def teardown(self): + Step("收尾工作:卸载测试应用") + self.driver.uninstall_app("com.acts.childprocessmanager") \ No newline at end of file diff --git a/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_0200.json b/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_0200.json new file mode 100644 index 0000000000000000000000000000000000000000..9fb6cf253bc0e47d7b878a40f831a022ffc6a54c --- /dev/null +++ b/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_0200.json @@ -0,0 +1,12 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_0200.py"] + } +} \ No newline at end of file diff --git a/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_0200.py b/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_0200.py new file mode 100644 index 0000000000000000000000000000000000000000..439faf9ae8b739c5a629f916f619ed3104a710b3 --- /dev/null +++ b/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_0200.py @@ -0,0 +1,82 @@ +# Copyright (c) 2024 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 import * +from hypium.model import UiParam, WindowFilter +from aw import Common +import time + + +class SUB_STARTUP_APPSPAWN_NATIVESPAWN_0200(TestCase): + + def __init__(self, controllers): + self.TAG = self.__class__.__name__ + 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() + Step('获取权限状态') + isStatus = self.driver.shell("param get persist.sys.abilityms.multi_process_model") + if ("true" in isStatus): + pass + else: + Step('设置权限为true') + self.driver.shell("param set persist.sys.abilityms.multi_process_model true") + Step('重启生效') + self.driver.shell("reboot") + self.driver.System.wait_for_boot_complete() + self.driver.ScreenLock.unlock() + + def test_step1(self): + Step("步骤1:安装测试应用") + hap = Common.sourcepath('entry-default-nativespawn.hap', "SUB_STARTUP_STABILITY_APPSPAWN") + isHap = self.driver.has_app("com.acts.childprocessmanager") + if(isHap): + self.driver.uninstall_app("com.acts.childprocessmanager") + else: + pass + self.driver.install_app(hap) + Step("步骤2:打开测试应用") + self.driver.start_app("com.acts.childprocessmanager") + Step("步骤3:点击StartArk用例按钮") + self.driver.touch(BY.text("StartArk用例")) + Step("步骤4:点击start Ark Process按钮") + self.driver.touch(BY.text("Start Ark Process")) + Step("步骤5:获取测试应用pid") + pid = self.driver.System.get_pid("com.acts.childprocessmanager") + Step("步骤6:获取测试应用appspawn孵化子进程pid") + childpid = self.driver.System.get_pid("com.acts.childprocessmanager:ArkProcess0") + Step("步骤7:查看数据") + res = self.driver.shell("ls -l /proc/%d/ns/net" % pid) + childres = self.driver.shell("ls -l /proc/%d/ns/net" % childpid) + Step("步骤7:预期结果检验") + arr = res.split("-> ")[1] + childarr = childres.split("-> ")[1] + self.driver.Assert.equal(arr, childarr) + + def teardown(self): + Step("收尾工作:卸载测试应用") + self.driver.uninstall_app("com.acts.childprocessmanager") diff --git a/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_0300.json b/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_0300.json new file mode 100644 index 0000000000000000000000000000000000000000..abe637db1996b151bdf27f715e8c8d8bbf3b1fa8 --- /dev/null +++ b/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_0300.json @@ -0,0 +1,12 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_0300.py"] + } +} \ No newline at end of file diff --git a/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_0300.py b/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_0300.py new file mode 100644 index 0000000000000000000000000000000000000000..e3357d2212652a7f9c81ccfd8b78d6725b1becc3 --- /dev/null +++ b/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_0300.py @@ -0,0 +1,82 @@ +# Copyright (c) 2024 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 import * +from hypium.model import UiParam, WindowFilter +from aw import Common +import time + + +class SUB_STARTUP_APPSPAWN_NATIVESPAWN_0300(TestCase): + + def __init__(self, controllers): + self.TAG = self.__class__.__name__ + 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() + Step('获取权限状态') + isStatus = self.driver.shell("param get persist.sys.abilityms.multi_process_model") + if ("true" in isStatus): + pass + else: + Step('设置权限为true') + self.driver.shell("param set persist.sys.abilityms.multi_process_model true") + Step('重启生效') + self.driver.shell("reboot") + self.driver.System.wait_for_boot_complete() + self.driver.ScreenLock.unlock() + + def test_step1(self): + Step("步骤1:安装测试应用") + hap = Common.sourcepath('entry-default-nativespawn.hap', "SUB_STARTUP_STABILITY_APPSPAWN") + isHap = self.driver.has_app("com.acts.childprocessmanager") + if(isHap): + self.driver.uninstall_app("com.acts.childprocessmanager") + else: + pass + self.driver.install_app(hap) + Step("步骤2:打开测试应用") + self.driver.start_app("com.acts.childprocessmanager") + Step("步骤3:点击StartArk用例按钮") + self.driver.touch(BY.text("StartArk用例")) + Step("步骤4:点击start Ark Process按钮") + self.driver.touch(BY.text("Start Ark Process Isolated")) + Step("步骤5:获取测试应用pid") + pid = self.driver.System.get_pid("com.acts.childprocessmanager") + Step("步骤6:获取测试应用appspawn孵化子进程pid") + childpid = self.driver.System.get_pid("com.acts.childprocessmanager:ArkProcess0") + Step("步骤7:查看数据") + res = self.driver.shell("ls -l /proc/%d/ns/net" % pid) + childres = self.driver.shell("ls -l /proc/%d/ns/net" % childpid) + Step("步骤7:预期结果检验") + arr = res.split("-> ")[1] + childarr = childres.split("-> ")[1] + self.driver.Assert.not_equal(arr, childarr) + + def teardown(self): + Step("收尾工作:卸载测试应用") + self.driver.uninstall_app("com.acts.childprocessmanager") diff --git a/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_0400.json b/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_0400.json new file mode 100644 index 0000000000000000000000000000000000000000..d097c00230de208e78ad022031894ca8089f5daf --- /dev/null +++ b/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_0400.json @@ -0,0 +1,12 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_0400.py"] + } +} \ No newline at end of file diff --git a/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_0400.py b/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_0400.py new file mode 100644 index 0000000000000000000000000000000000000000..14e1fe3e02306dd1c858f1ff17a6c2c6ba0ef3f4 --- /dev/null +++ b/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_0400.py @@ -0,0 +1,82 @@ +# Copyright (c) 2024 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 import * +from hypium.model import UiParam, WindowFilter +from aw import Common +import time + + +class SUB_STARTUP_APPSPAWN_NATIVESPAWN_0400(TestCase): + + def __init__(self, controllers): + self.TAG = self.__class__.__name__ + 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() + Step('获取权限状态') + isStatus = self.driver.shell("param get persist.sys.abilityms.multi_process_model") + if ("true" in isStatus): + pass + else: + Step('设置权限为true') + self.driver.shell("param set persist.sys.abilityms.multi_process_model true") + Step('重启生效') + self.driver.shell("reboot") + self.driver.System.wait_for_boot_complete() + self.driver.ScreenLock.unlock() + + def test_step1(self): + Step("步骤1:安装测试应用") + hap = Common.sourcepath('entry-default-nativespawn.hap', "SUB_STARTUP_STABILITY_APPSPAWN") + isHap = self.driver.has_app("com.acts.childprocessmanager") + if(isHap): + self.driver.uninstall_app("com.acts.childprocessmanager") + else: + pass + self.driver.install_app(hap) + Step("步骤2:打开测试应用") + self.driver.start_app("com.acts.childprocessmanager") + Step("步骤3:点击StartArk用例按钮") + self.driver.touch(BY.text("StartArk用例")) + Step("步骤4:点击start Ark Process按钮") + self.driver.touch(BY.text("start Native Process")) + Step("步骤5:获取测试应用pid") + pid = self.driver.System.get_pid("com.acts.childprocessmanager") + Step("步骤6:获取测试应用nativespawn孵化子进程pid") + childpid = self.driver.System.get_pid("com.acts.childprocessmanager:Native_libentry0") + Step("步骤7:查看数据") + res = self.driver.shell("ls -l /proc/%d/ns/net" % pid) + childres = self.driver.shell("ls -l /proc/%d/ns/net" % childpid) + Step("步骤7:预期结果检验") + arr = res.split("-> ")[1] + childarr = childres.split("-> ")[1] + self.driver.Assert.equal(arr, childarr) + + def teardown(self): + Step("收尾工作:卸载测试应用") + self.driver.uninstall_app("com.acts.childprocessmanager") diff --git a/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_0500.json b/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_0500.json new file mode 100644 index 0000000000000000000000000000000000000000..f2e52e5996eb2f39c8c8bfb02a50a3caec0d0ea0 --- /dev/null +++ b/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_0500.json @@ -0,0 +1,12 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_0500.py"] + } +} \ No newline at end of file diff --git a/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_0500.py b/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_0500.py new file mode 100644 index 0000000000000000000000000000000000000000..7a67b18467bac41c69b6d725f155e25e6a968d3a --- /dev/null +++ b/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_0500.py @@ -0,0 +1,82 @@ +# Copyright (c) 2024 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 import * +from hypium.model import UiParam, WindowFilter +from aw import Common +import time + + +class SUB_STARTUP_APPSPAWN_NATIVESPAWN_0500(TestCase): + + def __init__(self, controllers): + self.TAG = self.__class__.__name__ + 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() + Step('获取权限状态') + isStatus = self.driver.shell("param get persist.sys.abilityms.multi_process_model") + if ("true" in isStatus): + pass + else: + Step('设置权限为true') + self.driver.shell("param set persist.sys.abilityms.multi_process_model true") + Step('重启生效') + self.driver.shell("reboot") + self.driver.System.wait_for_boot_complete() + self.driver.ScreenLock.unlock() + + def test_step1(self): + Step("步骤1:安装测试应用") + hap = Common.sourcepath('entry-default-nativespawn.hap', "SUB_STARTUP_STABILITY_APPSPAWN") + isHap = self.driver.has_app("com.acts.childprocessmanager") + if(isHap): + self.driver.uninstall_app("com.acts.childprocessmanager") + else: + pass + self.driver.install_app(hap) + Step("步骤2:打开测试应用") + self.driver.start_app("com.acts.childprocessmanager") + Step("步骤3:点击StartArk用例按钮") + self.driver.touch(BY.text("StartArk用例")) + Step("步骤4:点击start Ark Process按钮") + self.driver.touch(BY.text("start Native Process Isolated")) + Step("步骤5:获取测试应用pid") + pid = self.driver.System.get_pid("com.acts.childprocessmanager") + Step("步骤6:获取测试应用nativespawn孵化子进程pid") + childpid = self.driver.System.get_pid("com.acts.childprocessmanager:Native_libentry0") + Step("步骤7:查看数据") + res = self.driver.shell("ls -l /proc/%d/ns/net" % pid) + childres = self.driver.shell("ls -l /proc/%d/ns/net" % childpid) + Step("步骤7:预期结果检验") + arr = res.split("-> ")[1] + childarr = childres.split("-> ")[1] + self.driver.Assert.not_equal(arr, childarr) + + def teardown(self): + Step("收尾工作:卸载测试应用") + self.driver.uninstall_app("com.acts.childprocessmanager") diff --git a/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_0600.json b/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_0600.json new file mode 100644 index 0000000000000000000000000000000000000000..3900883df41647470a0c520c48654fc0da8924b8 --- /dev/null +++ b/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_0600.json @@ -0,0 +1,12 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_0600.py"] + } +} \ No newline at end of file diff --git a/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_0600.py b/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_0600.py new file mode 100644 index 0000000000000000000000000000000000000000..112a79c6f5c3af832ce256f2297e5a9b25190516 --- /dev/null +++ b/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_0600.py @@ -0,0 +1,84 @@ +# Copyright (c) 2024 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 import * +from hypium.model import UiParam, WindowFilter +from aw import Common +import time + + +class SUB_STARTUP_APPSPAWN_NATIVESPAWN_0600(TestCase): + + def __init__(self, controllers): + self.TAG = self.__class__.__name__ + 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() + Step('获取权限状态') + isStatus = self.driver.shell("param get persist.sys.abilityms.multi_process_model") + if ("true" in isStatus): + pass + else: + Step('设置权限为true') + self.driver.shell("param set persist.sys.abilityms.multi_process_model true") + Step('重启生效') + self.driver.shell("reboot") + self.driver.System.wait_for_boot_complete() + self.driver.ScreenLock.unlock() + + def test_step1(self): + Step("步骤1:安装测试应用") + hap = Common.sourcepath('entry-default-nativespawn.hap', "SUB_STARTUP_STABILITY_APPSPAWN") + isHap = self.driver.has_app("com.acts.childprocessmanager") + if(isHap): + self.driver.uninstall_app("com.acts.childprocessmanager") + else: + pass + self.driver.install_app(hap) + Step("步骤2:打开测试应用") + self.driver.start_app("com.acts.childprocessmanager") + Step("步骤3:点击StartArk用例按钮") + self.driver.touch(BY.text("StartArk用例")) + Step("步骤4:点击start Ark Process按钮") + self.driver.touch(BY.text("Start Ark Process")) + Step("步骤5:获取测试应用pid") + pid = self.driver.System.get_pid("com.acts.childprocessmanager") + Step("步骤6:获取孵化app子进程pid") + childpid = self.driver.System.get_pid("com.acts.childprocessmanager:ArkProcess0") + Step("步骤7:测试应用沙箱路径data/storage/el1生成一个123.txt") + self.driver.shell("echo 123456789 > /proc/%d/root/data/storage/el1/123.txt" % pid) + Step("步骤8:孵化app子进程查看沙箱路径data/storage/el1") + childres = self.driver.shell("cat /proc/%d/root/data/storage/el1/123.txt" % childpid) + Step("步骤8:预期结果检验") + self.driver.Assert.equal(int(childres), 123456789) + self.driver.shell("rm -rf /proc/%d/root/data/storage/el1/123.txt" % pid) + + + def teardown(self): + Step("收尾工作:卸载测试应用") + self.driver.uninstall_app("com.acts.childprocessmanager") + diff --git a/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_0700.json b/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_0700.json new file mode 100644 index 0000000000000000000000000000000000000000..472d57d4996573e0565f3bc05a8447081c96d5c7 --- /dev/null +++ b/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_0700.json @@ -0,0 +1,12 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_0700.py"] + } +} \ No newline at end of file diff --git a/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_0700.py b/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_0700.py new file mode 100644 index 0000000000000000000000000000000000000000..d12b6ce8ef25ec24a3310cdb2c7c84197724f9d0 --- /dev/null +++ b/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_0700.py @@ -0,0 +1,82 @@ +# Copyright (c) 2024 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 import * +from hypium.model import UiParam, WindowFilter +from aw import Common +import time + + +class SUB_STARTUP_APPSPAWN_NATIVESPAWN_0700(TestCase): + + def __init__(self, controllers): + self.TAG = self.__class__.__name__ + 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() + Step('获取权限状态') + isStatus = self.driver.shell("param get persist.sys.abilityms.multi_process_model") + if ("true" in isStatus): + pass + else: + Step('设置权限为true') + self.driver.shell("param set persist.sys.abilityms.multi_process_model true") + Step('重启生效') + self.driver.shell("reboot") + self.driver.System.wait_for_boot_complete() + self.driver.ScreenLock.unlock() + + def test_step1(self): + Step("步骤1:安装测试应用") + hap = Common.sourcepath('entry-default-nativespawn.hap', "SUB_STARTUP_STABILITY_APPSPAWN") + isHap = self.driver.has_app("com.acts.childprocessmanager") + if(isHap): + self.driver.uninstall_app("com.acts.childprocessmanager") + else: + pass + self.driver.install_app(hap) + Step("步骤2:打开测试应用") + self.driver.start_app("com.acts.childprocessmanager") + Step("步骤3:点击StartArk用例按钮") + self.driver.touch(BY.text("StartArk用例")) + Step("步骤4:点击start Ark Process按钮") + self.driver.touch(BY.text("Start Ark Process Isolated")) + Step("步骤5:获取测试应用pid") + pid = self.driver.System.get_pid("com.acts.childprocessmanager") + Step("步骤6:获取测试应用appspawn孵化子进程pid") + childpid = self.driver.System.get_pid("com.acts.childprocessmanager:ArkProcess0") + Step("步骤7:测试应用沙箱路径data/storage/el1生成一个123.txt") + self.driver.shell("echo 123456789 > /proc/%d/root/data/storage/el1/123.txt" % pid) + Step("步骤8:测试应用appspawn孵化子进程查看沙箱路径data/storage/el1") + childres = self.driver.shell("cat /proc/%d/root/data/storage/el1/123.txt" % childpid) + Step("步骤8:预期结果检验") + self.driver.Assert.contains(childres, "root/data/storage/el1/123.txt: No such file or directory") + self.driver.shell("rm -rf /proc/%d/root/data/storage/el1/123.txt" % pid) + + def teardown(self): + Step("收尾工作:卸载测试应用") + self.driver.uninstall_app("com.acts.childprocessmanager") \ No newline at end of file diff --git a/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_0800.json b/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_0800.json new file mode 100644 index 0000000000000000000000000000000000000000..3d989ee31564324cfaae959e56d98521838f74a6 --- /dev/null +++ b/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_0800.json @@ -0,0 +1,12 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_0800.py"] + } +} \ No newline at end of file diff --git a/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_0800.py b/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_0800.py new file mode 100644 index 0000000000000000000000000000000000000000..7408b7365f6175578ac709ec948843be93711afe --- /dev/null +++ b/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_0800.py @@ -0,0 +1,84 @@ +# Copyright (c) 2024 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 import * +from hypium.model import UiParam, WindowFilter +from aw import Common +import time + + +class SUB_STARTUP_APPSPAWN_NATIVESPAWN_0800(TestCase): + + def __init__(self, controllers): + self.TAG = self.__class__.__name__ + 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() + Step('获取权限状态') + isStatus = self.driver.shell("param get persist.sys.abilityms.multi_process_model") + if ("true" in isStatus): + pass + else: + Step('设置权限为true') + self.driver.shell("param set persist.sys.abilityms.multi_process_model true") + Step('重启生效') + self.driver.shell("reboot") + self.driver.System.wait_for_boot_complete() + self.driver.ScreenLock.unlock() + + def test_step1(self): + Step("步骤1:安装测试应用") + hap = Common.sourcepath('entry-default-nativespawn.hap', "SUB_STARTUP_STABILITY_APPSPAWN") + isHap = self.driver.has_app("com.acts.childprocessmanager") + if(isHap): + self.driver.uninstall_app("com.acts.childprocessmanager") + else: + pass + self.driver.install_app(hap) + Step("步骤2:打开测试应用") + self.driver.start_app("com.acts.childprocessmanager") + Step("步骤3:点击StartArk用例按钮") + self.driver.touch(BY.text("StartArk用例")) + Step("步骤4:点击start Ark Process按钮") + self.driver.touch(BY.text("start Native Process")) + Step("步骤5:获取测试应用pid") + pid = self.driver.System.get_pid("com.acts.childprocessmanager") + Step("步骤6:孵化native子进程pid") + childpid = self.driver.System.get_pid("com.acts.childprocessmanager:Native_libentry0") + Step("步骤7:测试应用沙箱路径data/storage/el1生成一个123.txt") + self.driver.shell("echo 123456789 > /proc/%d/root/data/storage/el1/123.txt" % pid) + Step("步骤8:孵化native子进程查看沙箱路径data/storage/el1") + childres = self.driver.shell("cat /proc/%d/root/data/storage/el1/123.txt" % childpid) + Step("步骤8:预期结果检验") + self.driver.Assert.equal(int(childres), 123456789) + self.driver.shell("rm -rf /proc/%d/root/data/storage/el1/123.txt" % pid) + + + def teardown(self): + Step("收尾工作:卸载测试应用") + self.driver.uninstall_app("com.acts.childprocessmanager") + diff --git a/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_0900.json b/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_0900.json new file mode 100644 index 0000000000000000000000000000000000000000..023668b664e00c3cb4f73372916a9f1769892419 --- /dev/null +++ b/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_0900.json @@ -0,0 +1,12 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_0900.py"] + } +} \ No newline at end of file diff --git a/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_0900.py b/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_0900.py new file mode 100644 index 0000000000000000000000000000000000000000..c3340021650ecd2214f54c5ee085668962b85c17 --- /dev/null +++ b/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_0900.py @@ -0,0 +1,84 @@ +# Copyright (c) 2024 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 import * +from hypium.model import UiParam, WindowFilter +from aw import Common +import time + + +class SUB_STARTUP_APPSPAWN_NATIVESPAWN_0900(TestCase): + + def __init__(self, controllers): + self.TAG = self.__class__.__name__ + 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() + Step('获取权限状态') + isStatus = self.driver.shell("param get persist.sys.abilityms.multi_process_model") + if ("true" in isStatus): + pass + else: + Step('设置权限为true') + self.driver.shell("param set persist.sys.abilityms.multi_process_model true") + Step('重启生效') + self.driver.shell("reboot") + self.driver.System.wait_for_boot_complete() + self.driver.ScreenLock.unlock() + + def test_step1(self): + Step("步骤1:安装测试应用") + hap = Common.sourcepath('entry-default-nativespawn.hap', "SUB_STARTUP_STABILITY_APPSPAWN") + isHap = self.driver.has_app("com.acts.childprocessmanager") + if(isHap): + self.driver.uninstall_app("com.acts.childprocessmanager") + else: + pass + self.driver.install_app(hap) + Step("步骤2:打开测试应用") + self.driver.start_app("com.acts.childprocessmanager") + Step("步骤3:点击StartArk用例按钮") + self.driver.touch(BY.text("StartArk用例")) + Step("步骤4:点击start Ark Process Isolated按钮") + self.driver.touch(BY.text("start Native Process Isolated")) + Step("步骤5:获取测试应用pid") + pid = self.driver.System.get_pid("com.acts.childprocessmanager") + Step("步骤6:获取测试应用孵化native进程pid") + childpid = self.driver.System.get_pid("com.acts.childprocessmanager:Native_libentry0") + Step("步骤7:测试应用沙箱路径data/storage/el1生成一个123.txt") + self.driver.shell("echo 0123456789 > /proc/%d/root/data/storage/el1/123.txt" % pid) + Step("步骤8:测试应用孵化native进程查看沙箱路径data/storage/el1") + childres = self.driver.shell("cat /proc/%d/root/data/storage/el1/123.txt" % childpid) + Step("步骤8:预期结果检验") + self.driver.Assert.contains(childres, "root/data/storage/el1/123.txt: No such file or directory") + self.driver.shell("rm -rf /proc/%d/root/data/storage/el1/123.txt" % pid) + + + def teardown(self): + Step("收尾工作:卸载测试应用") + self.driver.uninstall_app("com.acts.childprocessmanager") + diff --git a/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_1000.json b/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_1000.json new file mode 100644 index 0000000000000000000000000000000000000000..4788116bbc7f98147864d93e9ae8b0dff34a38fb --- /dev/null +++ b/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_1000.json @@ -0,0 +1,12 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_1000.py"] + } +} \ No newline at end of file diff --git a/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_1000.py b/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_1000.py new file mode 100644 index 0000000000000000000000000000000000000000..6ea57ea16e2623b13ddafbb002fac3f336d13f2c --- /dev/null +++ b/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_1000.py @@ -0,0 +1,91 @@ +# Copyright (c) 2024 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 import * +from hypium.model import UiParam, WindowFilter +from aw import Common +import time + + +class SUB_STARTUP_APPSPAWN_NATIVESPAWN_1000(TestCase): + + def __init__(self, controllers): + self.TAG = self.__class__.__name__ + 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() + Step('获取权限状态') + isStatus = self.driver.shell("param get persist.sys.abilityms.multi_process_model") + if ("true" in isStatus): + pass + else: + Step('设置权限为true') + self.driver.shell("param set persist.sys.abilityms.multi_process_model true") + Step('重启生效') + self.driver.shell("reboot") + self.driver.System.wait_for_boot_complete() + self.driver.ScreenLock.unlock() + + def test_step1(self): + Step("步骤1:安装测试应用") + hap = Common.sourcepath('entry-default-nativespawn.hap', "SUB_STARTUP_STABILITY_APPSPAWN") + isHap = self.driver.has_app("com.acts.childprocessmanager") + if(isHap): + self.driver.uninstall_app("com.acts.childprocessmanager") + else: + pass + self.driver.install_app(hap) + Step("步骤2:打开测试应用") + self.driver.start_app("com.acts.childprocessmanager") + Step("步骤3:点击StartArk用例按钮") + self.driver.touch(BY.text("StartArk用例")) + Step("步骤4:点击start Ark Process按钮") + self.driver.touch(BY.text("Start Ark Process")) + Step("步骤5:获取测试应用pid") + pid = self.driver.System.get_pid("com.acts.childprocessmanager") + Step("步骤6:获取测试应用appspawn孵化子进程pid") + childpid = self.driver.System.get_pid("com.acts.childprocessmanager:ArkProcess0") + Step("步骤7:测试应用沙箱路径data/storage/el1/bundle目录下,创建2个文件夹") + self.driver.shell("mkdir /proc/%d/root/data/storage/el1/bundle/test1 /proc/%d/root/data/storage/el1/bundle/test2" % (pid, pid)) + Step("步骤8:测试应用沙箱路径data/storage/el1/bundle/tets1,创建1个test.txt文件") + self.driver.shell("echo this is test1 > /proc/%d/root/data/storage/el1/bundle/test1/test.txt" % pid) + Step("步骤9:test1挂载test2") + self.driver.shell("mount /proc/%d/root/data/storage/el1/bundle/test1 /proc/%d/root/data/storage/el1/bundle/test2" % (pid, pid)) + Step("步骤10:查看test2目录下的文件是否和test1内容一致") + res = self.driver.shell("cat /proc/%d/root/data/storage/el1/bundle/test2/test.txt" % pid) + Step("步骤11:测试应用appspawn孵化子进程查看沙箱路径data/storage/el1/bundle/test2/test.txt") + childres = self.driver.shell("cat /proc/%d/root/data/storage/el1/bundle/test2/test.txt" % childpid) + Step("步骤12:预期结果检验") + self.driver.Assert.contains(res, "this is test1") + self.driver.Assert.contains(childres, "root/data/storage/el1/bundle/test2/test.txt: No such file or directory") + self.driver.shell("rm -rf /proc/%d/root/data/storage/el1/bundle/test1 /proc/%d/root/data/storage/el1/bundle/test2" % (pid, pid)) + + + def teardown(self): + Step("收尾工作:卸载测试应用") + self.driver.uninstall_app("com.acts.childprocessmanager") + diff --git a/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_1100.json b/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_1100.json new file mode 100644 index 0000000000000000000000000000000000000000..4db00ee42653ff64385aa6fc28ec377447a52569 --- /dev/null +++ b/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_1100.json @@ -0,0 +1,12 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_1100.py"] + } +} \ No newline at end of file diff --git a/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_1100.py b/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_1100.py new file mode 100644 index 0000000000000000000000000000000000000000..15895e8ad98fac25e6e1be90b816c818f4ca1132 --- /dev/null +++ b/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_1100.py @@ -0,0 +1,91 @@ +# Copyright (c) 2024 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 import * +from hypium.model import UiParam, WindowFilter +from aw import Common +import time + + +class SUB_STARTUP_APPSPAWN_NATIVESPAWN_1100(TestCase): + + def __init__(self, controllers): + self.TAG = self.__class__.__name__ + 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() + Step('获取权限状态') + isStatus = self.driver.shell("param get persist.sys.abilityms.multi_process_model") + if ("true" in isStatus): + pass + else: + Step('设置权限为true') + self.driver.shell("param set persist.sys.abilityms.multi_process_model true") + Step('重启生效') + self.driver.shell("reboot") + self.driver.System.wait_for_boot_complete() + self.driver.ScreenLock.unlock() + + def test_step1(self): + Step("步骤1:安装测试应用") + hap = Common.sourcepath('entry-default-nativespawn.hap', "SUB_STARTUP_STABILITY_APPSPAWN") + isHap = self.driver.has_app("com.acts.childprocessmanager") + if(isHap): + self.driver.uninstall_app("com.acts.childprocessmanager") + else: + pass + self.driver.install_app(hap) + Step("步骤2:打开测试应用") + self.driver.start_app("com.acts.childprocessmanager") + Step("步骤3:点击StartArk用例按钮") + self.driver.touch(BY.text("StartArk用例")) + Step("步骤4:点击start Ark Process Isolated按钮") + self.driver.touch(BY.text("Start Ark Process Isolated")) + Step("步骤5:获取测试应用pid") + pid = self.driver.System.get_pid("com.acts.childprocessmanager") + Step("步骤6:获取测试应用appspawn孵化子进程pid") + childpid = self.driver.System.get_pid("com.acts.childprocessmanager:ArkProcess0") + Step("步骤7:测试应用沙箱路径data/storage/el1/bundle目录下,创建2个文件夹") + self.driver.shell("mkdir /proc/%d/root/data/storage/el1/bundle/test1 /proc/%d/root/data/storage/el1/bundle/test2" % (pid, pid)) + Step("步骤8:测试应用沙箱路径data/storage/el1/bundle/tets1,创建1个test.txt文件") + self.driver.shell("echo this is test1 > /proc/%d/root/data/storage/el1/bundle/test1/test.txt" % pid) + Step("步骤9:test1挂载test2") + self.driver.shell("mount /proc/%d/root/data/storage/el1/bundle/test1 /proc/%d/root/data/storage/el1/bundle/test2" % (pid, pid)) + Step("步骤10:查看test2目录下的文件是否和test1内容一致") + res = self.driver.shell("cat /proc/%d/root/data/storage/el1/bundle/test2/test.txt" % pid) + Step("步骤11:测试应用appspawn孵化子进程查看沙箱路径data/storage/el1/bundle/test2/test.txt") + childres = self.driver.shell("cat /proc/%d/root/data/storage/el1/bundle/test2/test.txt" % childpid) + Step("步骤12:预期结果检验") + self.driver.Assert.contains(res, "this is test1") + self.driver.Assert.contains(childres, "root/data/storage/el1/bundle/test2/test.txt: No such file or directory") + self.driver.shell("rm -rf /proc/%d/root/data/storage/el1/bundle/test1 /proc/%d/root/data/storage/el1/bundle/test2" % (pid, pid)) + + + def teardown(self): + Step("收尾工作:卸载测试应用") + self.driver.uninstall_app("com.acts.childprocessmanager") + diff --git a/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_1200.json b/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_1200.json new file mode 100644 index 0000000000000000000000000000000000000000..15f329aa7cdaf3360b604e00395212a1073ff20a --- /dev/null +++ b/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_1200.json @@ -0,0 +1,12 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_1200.py"] + } +} \ No newline at end of file diff --git a/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_1200.py b/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_1200.py new file mode 100644 index 0000000000000000000000000000000000000000..bf361b75a959f66de2082e7e9a5723dd7d5f8f37 --- /dev/null +++ b/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_1200.py @@ -0,0 +1,91 @@ +# Copyright (c) 2024 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 import * +from hypium.model import UiParam, WindowFilter +from aw import Common +import time + + +class SUB_STARTUP_APPSPAWN_NATIVESPAWN_1200(TestCase): + + def __init__(self, controllers): + self.TAG = self.__class__.__name__ + 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() + Step('获取权限状态') + isStatus = self.driver.shell("param get persist.sys.abilityms.multi_process_model") + if ("true" in isStatus): + pass + else: + Step('设置权限为true') + self.driver.shell("param set persist.sys.abilityms.multi_process_model true") + Step('重启生效') + self.driver.shell("reboot") + self.driver.System.wait_for_boot_complete() + self.driver.ScreenLock.unlock() + + def test_step1(self): + Step("步骤1:安装测试应用") + hap = Common.sourcepath('entry-default-nativespawn.hap', "SUB_STARTUP_STABILITY_APPSPAWN") + isHap = self.driver.has_app("com.acts.childprocessmanager") + if(isHap): + self.driver.uninstall_app("com.acts.childprocessmanager") + else: + pass + self.driver.install_app(hap) + Step("步骤2:打开测试应用") + self.driver.start_app("com.acts.childprocessmanager") + Step("步骤3:点击StartArk用例按钮") + self.driver.touch(BY.text("StartArk用例")) + Step("步骤4:点击start Native Process按钮") + self.driver.touch(BY.text("start Native Process")) + Step("步骤5:获取测试应用pid") + pid = self.driver.System.get_pid("com.acts.childprocessmanager") + Step("步骤6:孵化native子进程pid") + childpid = self.driver.System.get_pid("com.acts.childprocessmanager:Native_libentry0") + Step("步骤7:测试应用沙箱路径data/storage/el1/bundle目录下,创建2个文件夹") + self.driver.shell("mkdir /proc/%d/root/data/storage/el1/bundle/zsj1 /proc/%d/root/data/storage/el1/bundle/zsj2" % (pid, pid)) + Step("步骤8:测试应用沙箱路径data/storage/el1/bundle/tets1,创建1个zsj.txt文件") + self.driver.shell("echo this is zsj1 > /proc/%d/root/data/storage/el1/bundle/zsj1/zsj.txt" % pid) + Step("步骤9:test1挂载test2") + self.driver.shell("mount /proc/%d/root/data/storage/el1/bundle/zsj1 /proc/%d/root/data/storage/el1/bundle/zsj2" % (pid, pid)) + Step("步骤10:查看test2目录下的文件是否和test1内容一致") + res = self.driver.shell("cat /proc/%d/root/data/storage/el1/bundle/zsj2/zsj.txt" % pid) + Step("步骤11:孵化native子进程查看沙箱路径data/storage/el1/bundle/zsj2/zsj.txt") + childres = self.driver.shell("cat /proc/%d/root/data/storage/el1/bundle/zsj2/zsj.txt" % childpid) + Step("步骤12:预期结果检验") + self.driver.Assert.contains(res, "this is zsj1") + self.driver.Assert.contains(childres, "root/data/storage/el1/bundle/zsj2/zsj.txt: No such file or directory") + self.driver.shell("rm -rf /proc/%d/root/data/storage/el1/bundle/zsj1 /proc/%d/root/data/storage/el1/bundle/zsj2" % (pid, pid)) + + + def teardown(self): + Step("收尾工作:卸载测试应用") + self.driver.uninstall_app("com.acts.childprocessmanager") + diff --git a/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_1300.json b/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_1300.json new file mode 100644 index 0000000000000000000000000000000000000000..02271da845398e05a3b0153b790c6b13ed728213 --- /dev/null +++ b/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_1300.json @@ -0,0 +1,12 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_1300.py"] + } +} \ No newline at end of file diff --git a/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_1300.py b/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_1300.py new file mode 100644 index 0000000000000000000000000000000000000000..a39b69230b87b011e2714ce0f00d2171dbde1d98 --- /dev/null +++ b/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_1300.py @@ -0,0 +1,91 @@ +# Copyright (c) 2024 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 import * +from hypium.model import UiParam, WindowFilter +from aw import Common +import time + + +class SUB_STARTUP_APPSPAWN_NATIVESPAWN_1300(TestCase): + + def __init__(self, controllers): + self.TAG = self.__class__.__name__ + 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() + Step('获取权限状态') + isStatus = self.driver.shell("param get persist.sys.abilityms.multi_process_model") + if ("true" in isStatus): + pass + else: + Step('设置权限为true') + self.driver.shell("param set persist.sys.abilityms.multi_process_model true") + Step('重启生效') + self.driver.shell("reboot") + self.driver.System.wait_for_boot_complete() + self.driver.ScreenLock.unlock() + + def test_step1(self): + Step("步骤1:安装测试应用") + hap = Common.sourcepath('entry-default-nativespawn.hap', "SUB_STARTUP_STABILITY_APPSPAWN") + isHap = self.driver.has_app("com.acts.childprocessmanager") + if(isHap): + self.driver.uninstall_app("com.acts.childprocessmanager") + else: + pass + self.driver.install_app(hap) + Step("步骤2:打开测试应用") + self.driver.start_app("com.acts.childprocessmanager") + Step("步骤3:点击StartArk用例按钮") + self.driver.touch(BY.text("StartArk用例")) + Step("步骤4:点击start Native Process Isolated按钮") + self.driver.touch(BY.text("start Native Process Isolated")) + Step("步骤5:获取测试应用pid") + pid = self.driver.System.get_pid("com.acts.childprocessmanager") + Step("步骤6:获取孵化native子进程pid") + childpid = self.driver.System.get_pid("com.acts.childprocessmanager:Native_libentry0") + Step("步骤7:测试应用沙箱路径data/storage/el1/bundle目录下,创建2个文件夹") + self.driver.shell("mkdir /proc/%d/root/data/storage/el1/bundle/zsj1 /proc/%d/root/data/storage/el1/bundle/zsj2" % (pid, pid)) + Step("步骤8:测试应用沙箱路径data/storage/el1/bundle/tets1,创建1个zsj.txt文件") + self.driver.shell("echo this is zsj1 > /proc/%d/root/data/storage/el1/bundle/zsj1/zsj.txt" % pid) + Step("步骤9:test1挂载test2") + self.driver.shell("mount /proc/%d/root/data/storage/el1/bundle/zsj1 /proc/%d/root/data/storage/el1/bundle/zsj2" % (pid, pid)) + Step("步骤10:查看test2目录下的文件是否和test1内容一致") + res = self.driver.shell("cat /proc/%d/root/data/storage/el1/bundle/zsj2/zsj.txt" % pid) + Step("步骤11:孵化native子进程查看沙箱路径data/storage/el1/bundle/zsj2/zsj.txt") + childres = self.driver.shell("cat /proc/%d/root/data/storage/el1/bundle/zsj2/zsj.txt" % childpid) + Step("步骤12:预期结果检验") + self.driver.Assert.contains(res, "this is zsj1") + self.driver.Assert.contains(childres, "root/data/storage/el1/bundle/zsj2/zsj.txt: No such file or directory") + self.driver.shell("rm -rf /proc/%d/root/data/storage/el1/bundle/zsj1 /proc/%d/root/data/storage/el1/bundle/zsj2" % (pid, pid)) + + + def teardown(self): + Step("收尾工作:卸载测试应用") + self.driver.uninstall_app("com.acts.childprocessmanager") + diff --git a/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_1400.json b/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_1400.json new file mode 100644 index 0000000000000000000000000000000000000000..cc72ef37be73847ef15bbe908421432ca83187da --- /dev/null +++ b/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_1400.json @@ -0,0 +1,12 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_1400.py"] + } +} \ No newline at end of file diff --git a/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_1400.py b/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_1400.py new file mode 100644 index 0000000000000000000000000000000000000000..aa476ee7efca5e970df3f40669a017c4dff55062 --- /dev/null +++ b/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_1400.py @@ -0,0 +1,90 @@ +# Copyright (c) 2024 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 import * +from hypium.model import UiParam, WindowFilter +from aw import Common +import time + + +class SUB_STARTUP_APPSPAWN_NATIVESPAWN_1400(TestCase): + + def __init__(self, controllers): + self.TAG = self.__class__.__name__ + 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() + Step('获取权限状态') + isStatus = self.driver.shell("param get persist.sys.abilityms.multi_process_model") + if ("true" in isStatus): + pass + else: + Step('设置权限为true') + self.driver.shell("param set persist.sys.abilityms.multi_process_model true") + Step('重启生效') + self.driver.shell("reboot") + self.driver.System.wait_for_boot_complete() + self.driver.ScreenLock.unlock() + + def test_step1(self): + Step("步骤1:安装测试应用") + hap = Common.sourcepath('entry-default-nativespawn.hap', "SUB_STARTUP_STABILITY_APPSPAWN") + isHap = self.driver.has_app("com.acts.childprocessmanager") + if(isHap): + self.driver.uninstall_app("com.acts.childprocessmanager") + else: + pass + self.driver.install_app(hap) + Step("步骤2:打开测试应用") + self.driver.start_app("com.acts.childprocessmanager") + Step("步骤3:点击StartArk用例按钮") + self.driver.touch(BY.text("StartArk用例")) + Step("步骤4:点击start Ark Process Isolated按钮") + self.driver.touch(BY.text("start Native Process Isolated")) + Step("步骤5:获取测试应用pid") + self.driver.System.get_pid("com.acts.childprocessmanager") + Step("步骤6:获取测试应用孵化native进程pid") + childpid1 = self.driver.System.get_pid("com.acts.childprocessmanager:Native_libentry0") + Step("步骤7:测试应用沙箱路径data/storage/el1生成一个native.txt") + self.driver.shell("echo this is native1 > /proc/%d/root/data/storage/el1/native.txt" % childpid1) + childres = self.driver.shell("cat /proc/%d/root/data/storage/el1/native.txt" % childpid1) + Step("步骤8:杀死孵化native进程") + self.driver.shell("kill -9 %d" % childpid1) + Step("步骤9:再次点击start Ark Process Isolated按钮") + self.driver.touch(BY.text("start Native Process Isolated")) + Step("步骤10:测试应用孵化native进程查看沙箱路径data/storage/el1") + childpid2 = self.driver.System.get_pid("com.acts.childprocessmanager:Native_libentry1") + childres2 = self.driver.shell("cat /proc/%d/root/data/storage/el1/native.txt" % childpid2) + Step("步骤11:预期结果检验") + self.driver.Assert.contains(childres, "this is native1") + self.driver.Assert.contains(childres2, "this is native1") + self.driver.shell("rm -rf /proc/%d/root/data/storage/el1/native.txt" % childpid2) + + def teardown(self): + Step("收尾工作:卸载测试应用") + self.driver.uninstall_app("com.acts.childprocessmanager") + diff --git a/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_1500.json b/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_1500.json new file mode 100644 index 0000000000000000000000000000000000000000..ca1fb6b6337d4000ff422483d4ac44ac23c5d69e --- /dev/null +++ b/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_1500.json @@ -0,0 +1,12 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_1500.py"] + } +} \ No newline at end of file diff --git a/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_1500.py b/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_1500.py new file mode 100644 index 0000000000000000000000000000000000000000..c379a6c70768b6228a556eb5b2a6148e86e571c1 --- /dev/null +++ b/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_1500.py @@ -0,0 +1,85 @@ +# Copyright (c) 2024 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 import * +from hypium.model import UiParam, WindowFilter +from aw import Common +import time + + +class SUB_STARTUP_APPSPAWN_NATIVESPAWN_1500(TestCase): + + def __init__(self, controllers): + self.TAG = self.__class__.__name__ + 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() + Step('获取权限状态') + isStatus = self.driver.shell("param get persist.sys.abilityms.multi_process_model") + if ("true" in isStatus): + pass + else: + Step('设置权限为true') + self.driver.shell("param set persist.sys.abilityms.multi_process_model true") + Step('重启生效') + self.driver.shell("reboot") + self.driver.System.wait_for_boot_complete() + self.driver.ScreenLock.unlock() + + def test_step1(self): + Step("步骤1:安装测试应用") + hap = Common.sourcepath('entry-default-nativespawn.hap', "SUB_STARTUP_STABILITY_APPSPAWN") + isHap = self.driver.has_app("com.acts.childprocessmanager") + if(isHap): + self.driver.uninstall_app("com.acts.childprocessmanager") + else: + pass + self.driver.install_app(hap) + Step("步骤2:打开测试应用") + self.driver.start_app("com.acts.childprocessmanager") + Step("步骤3:点击StartArk用例按钮") + self.driver.touch(BY.text("StartArk用例")) + Step("步骤4:点击start Ark Process Isolated按钮") + self.driver.touch(BY.text("start Native Process Isolated")) + Step("步骤5:获取测试应用pid") + pid = self.driver.System.get_pid("com.acts.childprocessmanager") + Step("步骤6:获取测试应用孵化native进程pid") + childpid1 = self.driver.System.get_pid("com.acts.childprocessmanager:Native_libentry0") + Step("步骤7:杀死nativespawn进程") + self.driver.shell("kill -9 `pidof nativespawn`") + Step("步骤8:查询测试应用") + result = self.driver.shell("ps -ef | grep com.acts.childprocessmanager") + Step("步骤9:查询nativespawn进程号") + nativepid = self.driver.System.get_pid("nativespawn") + self.driver.Assert.contains(result, str(childpid1)) + self.driver.Assert.contains(result, str(pid)) + self.driver.Assert.equal(nativepid, None) + + def teardown(self): + Step("收尾工作:卸载测试应用") + self.driver.uninstall_app("com.acts.childprocessmanager") + diff --git a/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_1600.json b/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_1600.json new file mode 100644 index 0000000000000000000000000000000000000000..a7aa5bc305f8d71152e8572c9ee1fc7fd27e3cdd --- /dev/null +++ b/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_1600.json @@ -0,0 +1,12 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_1600.py"] + } +} \ No newline at end of file diff --git a/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_1600.py b/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_1600.py new file mode 100644 index 0000000000000000000000000000000000000000..e8318223bbf3deff8bc07389a3f88d9daaeb0452 --- /dev/null +++ b/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_1600.py @@ -0,0 +1,78 @@ +# Copyright (c) 2024 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 import * +from hypium.model import UiParam, WindowFilter +from aw import Common +import time + + +class SUB_STARTUP_APPSPAWN_NATIVESPAWN_1600(TestCase): + + def __init__(self, controllers): + self.TAG = self.__class__.__name__ + 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() + Step('获取权限状态') + isStatus = self.driver.shell("param get persist.sys.abilityms.multi_process_model") + if("true" in isStatus): + pass + else: + Step('设置权限为true') + self.driver.shell("param set persist.sys.abilityms.multi_process_model true") + Step('重启生效') + self.driver.shell("reboot") + self.driver.System.wait_for_boot_complete() + self.driver.ScreenLock.unlock() + + def test_step1(self): + Step("步骤1:安装测试应用") + hap = Common.sourcepath('entry-default-nativespawn.hap', "SUB_STARTUP_STABILITY_APPSPAWN") + isHap = self.driver.has_app("com.acts.childprocessmanager") + if(isHap): + self.driver.uninstall_app("com.acts.childprocessmanager") + else: + pass + self.driver.install_app(hap) + Step("步骤2:打开测试应用") + self.driver.start_app("com.acts.childprocessmanager") + Step("步骤3:点击StartArk用例按钮") + self.driver.touch(BY.text("StartArk用例")) + Step("步骤4:点击start Ark Process按钮") + self.driver.touch(BY.text("start Native Process Isolated")) + Step("步骤5:获取测试应用nativespawn孵化子进程pid") + time.sleep(1) + childpid = self.driver.System.get_pid("com.acts.childprocessmanager:Native_libentry0") + Step("步骤6:孵化的native子进程(Isolated=true)selinux标签类型") + childres = self.driver.shell("ps -efZ | grep %d | grep -v grep" % childpid) + Step("步骤9: 预期结果校验") + self.driver.Assert.contains(childres, "u:r:isolated_render:s0") + + def teardown(self): + Step("收尾工作:卸载测试应用") + self.driver.uninstall_app("com.acts.childprocessmanager") diff --git a/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_1700.json b/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_1700.json new file mode 100644 index 0000000000000000000000000000000000000000..9bf978a0ec2026c20edd1fa1770dfe6b9a6f8bde --- /dev/null +++ b/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_1700.json @@ -0,0 +1,12 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_1700.py"] + } +} \ No newline at end of file diff --git a/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_1700.py b/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_1700.py new file mode 100644 index 0000000000000000000000000000000000000000..7dded4e348d26b948c11bb179260f96b8fa3f26c --- /dev/null +++ b/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_1700.py @@ -0,0 +1,83 @@ +# Copyright (c) 2024 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 import * +from hypium.model import UiParam, WindowFilter +from aw import Common +import time + + +class SUB_STARTUP_APPSPAWN_NATIVESPAWN_1700(TestCase): + + def __init__(self, controllers): + self.TAG = self.__class__.__name__ + 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() + Step('获取权限状态') + isStatus = self.driver.shell("param get persist.sys.abilityms.multi_process_model") + if ("true" in isStatus): + pass + else: + Step('设置权限为true') + self.driver.shell("param set persist.sys.abilityms.multi_process_model true") + Step('重启生效') + self.driver.shell("reboot") + self.driver.System.wait_for_boot_complete() + self.driver.ScreenLock.unlock() + + def test_step1(self): + Step("步骤1:安装测试应用") + hap = Common.sourcepath('entry-default-nativespawn.hap', "SUB_STARTUP_STABILITY_APPSPAWN") + isHap = self.driver.has_app("com.acts.childprocessmanager") + if(isHap): + self.driver.uninstall_app("com.acts.childprocessmanager") + else: + pass + self.driver.install_app(hap) + Step("步骤2:打开测试应用") + self.driver.start_app("com.acts.childprocessmanager") + Step("步骤3:点击StartArk用例按钮") + self.driver.touch(BY.text("StartArk用例")) + Step("步骤4:点击start Ark Process按钮") + self.driver.touch(BY.text("start Native Process")) + Step("步骤5:获取测试应用pid") + pid = self.driver.System.get_pid("com.acts.childprocessmanager") + Step("步骤6:获取测试应用nativespawn孵化子进程pid") + childpid = self.driver.System.get_pid("com.acts.childprocessmanager:Native_libentry0") + Step("步骤7:测试应用selinux标签类型") + res = self.driver.shell("ps -efZ | grep %d | grep -v grep" % pid) + Step("步骤8:孵化的native子进程(Isolated=false)selinux标签类型") + childres = self.driver.shell("ps -efZ | grep %d | grep -v grep" % childpid) + string = res.split(" ")[0] + childString = childres.split(" ")[0] + Step("步骤9: 预期结果校验") + self.driver.Assert.equal(string, childString) + + def teardown(self): + Step("收尾工作:卸载测试应用") + self.driver.uninstall_app("com.acts.childprocessmanager") diff --git a/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_1800.json b/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_1800.json new file mode 100644 index 0000000000000000000000000000000000000000..7989f1aab1cf13fb3310b76fee0bdef4a767080d --- /dev/null +++ b/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_1800.json @@ -0,0 +1,12 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_1800.py"] + } +} \ No newline at end of file diff --git a/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_1800.py b/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_1800.py new file mode 100644 index 0000000000000000000000000000000000000000..9f8c6b07df26d5d938b6821df04ecf18a10fa8fc --- /dev/null +++ b/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_1800.py @@ -0,0 +1,93 @@ +# Copyright (c) 2024 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 import * +from hypium.model import UiParam, WindowFilter +from aw import Common +import time + + +class SUB_STARTUP_APPSPAWN_NATIVESPAWN_1800(TestCase): + + def __init__(self, controllers): + self.TAG = self.__class__.__name__ + 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() + Step('获取权限状态') + isStatus = self.driver.shell("param get persist.sys.abilityms.multi_process_model") + if ("true" in isStatus): + pass + else: + Step('设置权限为true') + self.driver.shell("param set persist.sys.abilityms.multi_process_model true") + Step('重启生效') + self.driver.shell("reboot") + self.driver.System.wait_for_boot_complete() + self.driver.ScreenLock.unlock() + + def test_step1(self): + Step("步骤1:安装测试应用") + hap = Common.sourcepath('entry-default-nativespawn.hap', "SUB_STARTUP_STABILITY_APPSPAWN") + isHap = self.driver.has_app("com.acts.childprocessmanager") + if(isHap): + self.driver.uninstall_app("com.acts.childprocessmanager") + else: + pass + self.driver.install_app(hap) + Step("步骤2:打开测试应用") + self.driver.start_app("com.acts.childprocessmanager") + Step("步骤3:点击StartArk用例按钮") + self.driver.touch(BY.text("StartArk用例")) + Step("步骤4:首次获取nativesapwn进程号") + pid1 = self.driver.System.get_pid("nativespawn") + Step("步骤5:点击start Native Process Isolated按钮") + self.driver.touch(BY.text("start Native Process Isolated")) + time.sleep(1) + Step("步骤6:再次点击start Native Process Isolated按钮") + self.driver.touch(BY.text("start Native Process Isolated")) + Step("步骤7:第二次获取nativesapwn进程号") + pid2 = self.driver.System.get_pid("nativespawn") + Step("步骤8:杀掉孵化的一个nativ进程") + childPid = self.driver.System.get_pid("com.acts.childprocessmanager:Native_libentry0") + self.driver.shell("kill -9 %d" % childPid) + Step("步骤9:第三次获取nativesapwn进程号") + pid3 = self.driver.System.get_pid("nativespawn") + Step("步骤10:杀掉孵化的最后一个native子进程") + childPid1 = self.driver.System.get_pid("com.acts.childprocessmanager:Native_libentry1") + self.driver.shell("kill -9 %d" % childPid1) + Step("步骤11:第四次获取nativesapwn进程号") + pid4 = self.driver.System.get_pid("nativespawn") + Step("步骤12:预期结果校验") + self.driver.Assert.equal(pid1, None) + self.driver.Assert.not_equal(pid2, None) + self.driver.Assert.not_equal(pid3, None) + self.driver.Assert.equal(pid4, None) + + def teardown(self): + Step("收尾工作:卸载测试应用") + self.driver.uninstall_app("com.acts.childprocessmanager") \ No newline at end of file diff --git a/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_1900.json b/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_1900.json new file mode 100644 index 0000000000000000000000000000000000000000..fdb6509c6776aa8901be52d195876fd767324c8a --- /dev/null +++ b/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_1900.json @@ -0,0 +1,12 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_1900.py"] + } +} \ No newline at end of file diff --git a/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_1900.py b/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_1900.py new file mode 100644 index 0000000000000000000000000000000000000000..26347eeb6f4264b5600e5454834271c509d652d2 --- /dev/null +++ b/test/autotest/SUB_STARTUP_APPSPAWN_NATIVESPAWN/SUB_STARTUP_APPSPAWN_NATIVESPAWN_1900.py @@ -0,0 +1,102 @@ +# Copyright (c) 2024 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 import * +from hypium.model import UiParam, WindowFilter +from aw import Common +import time + + +class SUB_STARTUP_APPSPAWN_NATIVESPAWN_1900(TestCase): + + def __init__(self, controllers): + self.TAG = self.__class__.__name__ + 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() + Step('获取权限状态') + isStatus = self.driver.shell("param get persist.sys.abilityms.multi_process_model") + if ("true" in isStatus): + pass + else: + Step('设置权限为true') + self.driver.shell("param set persist.sys.abilityms.multi_process_model true") + Step('重启生效') + self.driver.shell("reboot") + self.driver.System.wait_for_boot_complete() + self.driver.ScreenLock.unlock() + + def test_step1(self): + Step("步骤1:安装测试应用") + hap1 = Common.sourcepath('entry-default-nativespawn.hap', "SUB_STARTUP_STABILITY_APPSPAWN") + hap2 = Common.sourcepath('entry-default-nativespawn1.hap', "SUB_STARTUP_STABILITY_APPSPAWN") + isHap = self.driver.has_app("com.acts.childprocessmanager") + if(isHap): + self.driver.uninstall_app("com.acts.childprocessmanager") + else: + pass + isHap = self.driver.has_app("com.acts.childprocessmanager1") + if (isHap): + self.driver.uninstall_app("com.acts.childprocessmanager1") + else: + pass + self.driver.install_app(hap1) + self.driver.install_app(hap2) + Step("步骤2:打开测试应用1") + self.driver.start_app("com.acts.childprocessmanager") + Step("步骤3:点击StartArk用例按钮") + self.driver.touch(BY.text("StartArk用例")) + Step("步骤4:首次获取nativesapwn进程号") + pid1 = self.driver.System.get_pid("nativespawn") + Step("步骤5:点击start Native Process Isolated按钮") + self.driver.touch(BY.text("start Native Process Isolated")) + Step("步骤6:第二次获取nativesapwn进程号") + pid2 = self.driver.System.get_pid("nativespawn") + Step("步骤7:打开测试应用2") + self.driver.start_app("com.acts.childprocessmanager1") + Step("步骤8:点击StartArk用例按钮") + self.driver.touch(BY.text("StartArk用例")) + Step("步骤9:点击start Native Process Isolated按钮") + self.driver.touch(BY.text("start Native Process Isolated")) + Step("步骤10:关闭测试应用1") + self.driver.stop_app("com.acts.childprocessmanager") + Step("步骤11:第三次获取nativesapwn进程号") + pid3 = self.driver.System.get_pid("nativespawn") + Step("步骤12:关闭测试应用1") + self.driver.stop_app("com.acts.childprocessmanager1") + Step("步骤13:第四次获取nativesapwn进程号") + pid4 = self.driver.System.get_pid("nativespawn") + Step("步骤12:预期结果校验") + self.driver.Assert.equal(pid1, None) + self.driver.Assert.not_equal(pid2, None) + self.driver.Assert.not_equal(pid3, None) + self.driver.Assert.equal(pid4, None) + + def teardown(self): + Step("收尾工作:卸载测试应用") + self.driver.uninstall_app("com.acts.childprocessmanager") + self.driver.uninstall_app("com.acts.childprocessmanager1") \ No newline at end of file