From 642c5323489d1dee7ec5584dbd0ea13cb97ac15e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A8=8A=E6=99=AF=E4=B9=90?= Date: Mon, 16 Jun 2025 15:13:14 +0800 Subject: [PATCH] add appspawn test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 樊景乐 --- ..._startup_appspawn_nativedmscheck_0100.json | 12 +++ ...ub_startup_appspawn_nativedmscheck_0100.py | 62 +++++++++++++ ..._startup_appspawn_nativedmscheck_0200.json | 12 +++ ...ub_startup_appspawn_nativedmscheck_0200.py | 67 ++++++++++++++ ..._startup_appspawn_nativedmscheck_0300.json | 12 +++ ...ub_startup_appspawn_nativedmscheck_0300.py | 80 +++++++++++++++++ ..._startup_appspawn_nativedmscheck_0400.json | 12 +++ ...ub_startup_appspawn_nativedmscheck_0400.py | 90 +++++++++++++++++++ .../sub_startup_appspawn_nativepack_0100.json | 12 +++ .../sub_startup_appspawn_nativepack_0100.py | 78 ++++++++++++++++ .../sub_startup_appspawn_nativepack_0200.json | 12 +++ .../sub_startup_appspawn_nativepack_0200.py | 68 ++++++++++++++ .../sub_startup_appspawn_nativepack_0300.json | 12 +++ .../sub_startup_appspawn_nativepack_0300.py | 77 ++++++++++++++++ .../sub_startup_appspawn_nativepack_0400.json | 12 +++ .../sub_startup_appspawn_nativepack_0400.py | 77 ++++++++++++++++ .../sub_startup_appspawn_nativepack_0500.json | 12 +++ .../sub_startup_appspawn_nativepack_0500.py | 88 ++++++++++++++++++ .../sub_startup_appspawn_nativepack_0600.json | 12 +++ .../sub_startup_appspawn_nativepack_0600.py | 86 ++++++++++++++++++ .../sub_startup_appspawn_nativeprocess.json | 20 +++++ .../sub_startup_appspawn_nativeprocess.py | 41 +++++++++ ...sub_startup_appspawn_nativeprocess_0100.py | 39 ++++++++ ...sub_startup_appspawn_nativeprocess_0200.py | 42 +++++++++ ...sub_startup_appspawn_nativeprocess_0400.py | 39 ++++++++ ...sub_startup_appspawn_nativeprocess_0500.py | 39 ++++++++ ...sub_startup_appspawn_nativeprocess_0600.py | 42 +++++++++ ...b_startup_appspawn_nativesandbox_0100.json | 12 +++ ...sub_startup_appspawn_nativesandbox_0100.py | 84 +++++++++++++++++ ...b_startup_appspawn_nativesandbox_0200.json | 13 +++ ...sub_startup_appspawn_nativesandbox_0200.py | 84 +++++++++++++++++ 31 files changed, 1348 insertions(+) create mode 100644 test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0100.json create mode 100644 test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0100.py create mode 100644 test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0200.json create mode 100644 test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0200.py create mode 100644 test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0300.json create mode 100644 test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0300.py create mode 100644 test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0400.json create mode 100644 test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0400.py create mode 100644 test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0100.json create mode 100644 test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0100.py create mode 100644 test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0200.json create mode 100644 test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0200.py create mode 100644 test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0300.json create mode 100644 test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0300.py create mode 100644 test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0400.json create mode 100644 test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0400.py create mode 100644 test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0500.json create mode 100644 test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0500.py create mode 100644 test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0600.json create mode 100644 test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0600.py create mode 100644 test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess.json create mode 100644 test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess.py create mode 100644 test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess_0100.py create mode 100644 test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess_0200.py create mode 100644 test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess_0400.py create mode 100644 test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess_0500.py create mode 100644 test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess_0600.py create mode 100644 test/autotest/sub_startup_appspawn_nativesandbox/sub_startup_appspawn_nativesandbox_0100.json create mode 100644 test/autotest/sub_startup_appspawn_nativesandbox/sub_startup_appspawn_nativesandbox_0100.py create mode 100644 test/autotest/sub_startup_appspawn_nativesandbox/sub_startup_appspawn_nativesandbox_0200.json create mode 100644 test/autotest/sub_startup_appspawn_nativesandbox/sub_startup_appspawn_nativesandbox_0200.py diff --git a/test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0100.json b/test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0100.json new file mode 100644 index 00000000..c467494b --- /dev/null +++ b/test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0100.json @@ -0,0 +1,12 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["sub_startup_appspawn_nativedmscheck/SubStartupAppspawnNativedmscheck0100.py"] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0100.py b/test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0100.py new file mode 100644 index 00000000..a3f4c191 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0100.py @@ -0,0 +1,62 @@ +#!/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 time +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 SubStartupAppspawnNativedmscheck0100(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:创建公有hnp存放目录") + self.driver.shell("mkdir -p data/no_sign/public") + Step("步骤2:导入安装包文件hnp") + 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/no_sign/hnpsample.hnp')) + hap = os.path.abspath( + os.path.join(os.path.join(path, "testFile"), + 'SUB_STARTUP_APPSPAWN_NATIVE/no_sign/entry-default-signedArm64.hap')) + self.driver.push_file(hnp, "data/no_sign/public/") + self.driver.push_file(hap, "data/no_sign") + Step("步骤3:执行安装命令") + result = self.driver.shell( + "hnp install -u 100 -p wechat_sign -i /data/no_sign -s /data/no_sign/entry-default-signedArm64-test11.hap -a arm64 -f") + Step("步骤4:预期结果校验") + self.driver.Assert.contains(result, "hnp uninstall start now! name=hnpsample") + self.driver.Assert.contains(result, "native manager process exit. ret=8393475") + + def teardown(self): + self.driver.shell("rm -rf data/no_sign") diff --git a/test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0200.json b/test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0200.json new file mode 100644 index 00000000..676d65fa --- /dev/null +++ b/test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0200.json @@ -0,0 +1,12 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["sub_startup_appspawn_nativedmscheck/SubStartupAppspawnNativedmscheck0200.py"] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0200.py b/test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0200.py new file mode 100644 index 00000000..6e495429 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0200.py @@ -0,0 +1,67 @@ +#!/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 time +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 SubStartupAppspawnNativedmscheck0200(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:创建公有hnp存放目录") + self.driver.shell("mkdir -p data/wechat_sign/public") + Step("步骤2:导入安装包文件hnp") + 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/sign/hnpsample.hnp')) + hap = os.path.abspath( + os.path.join(os.path.join(path, "testFile"), + 'SUB_STARTUP_APPSPAWN_NATIVE/sign/entry-default-signedArm64-test11.hap')) + self.driver.push_file(hnp, "data/wechat_sign/public/") + self.driver.push_file(hap, "data/wechat_sign") + Step("步骤3:执行安装命令") + result1 = self.driver.shell( + "hnp install -u 100 -p wechat_sign -i /data/wechat_sign -s /data/wechat_sign/entry-default-signedArm64-test11.hap -a arm64 -f") + Step("步骤4:预期结果校验") + public = self.driver.shell("ls /data/app/el1/bundle/100/hnppublic/") + self.driver.Assert.contains(public, "hnpsample.org") + result = self.driver.shell("cat /data/service/el1/startup/hnp_info.json") + self.driver.Assert.contains(result, "wechat_sign") + self.driver.Assert.contains(result1, "native manager process exit. ret=0") + self.driver.Assert.contains(result1, "hnp install start now! src file=/data/wechat_sign/public/hnpsample.hnp, dst path=/data/app/el1/bundle/100/hnppublic") + + def teardown(self): + self.driver.shell("rm -rf data/sign") + self.driver.shell("hnp uninstall -u 100 -p wechat_sign") diff --git a/test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0300.json b/test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0300.json new file mode 100644 index 00000000..7edfe4b8 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0300.json @@ -0,0 +1,12 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["sub_startup_appspawn_nativedmscheck/SubStartupAppspawnNativedmscheck0300.py"] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0300.py b/test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0300.py new file mode 100644 index 00000000..54d9d5e7 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0300.py @@ -0,0 +1,80 @@ +#!/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 time +from devicetest.core.test_case import TestCase, Step, CheckPoint +from devicetest.core.test_case import Step, TestCase +from hypium.action.os_hypium.device_logger import DeviceLogger +from hypium.model import UiParam, WindowFilter +import os + + +class SubStartupAppspawnNativedmscheck0300(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() + Step('开启DEBUG日志') + self.driver.shell("hilog -b I -D 0xC02C11") + self.driver.shell("hilog -b DEBUG -T APPSPAWN") + self.driver.shell("hilog -b D -D 0xDC02C11") + self.driver.shell("hilog -G 16M") + host.shell('hdc shell "hilog -r"') + + def test_step1(self): + Step("步骤1:安装私有路径hap包") + path = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) + hap1 = os.path.abspath( + os.path.join(os.path.join(path, "testFile"), + 'SUB_STARTUP_APPSPAWN_NATIVE/entry-default-signedArm64Pri-test.hap')) + hap2 = os.path.abspath( + os.path.join(os.path.join(path, "testFile"), + 'SUB_STARTUP_APPSPAWN_NATIVE/entry-default-signed-hnpselinux.hap')) + self.driver.install_app(hap1) + self.driver.install_app(hap2) + Step("步骤2:过滤日志") + device_logger = DeviceLogger(self.driver) + device_logger.set_filter_string("MY_TAG") + Step("步骤3:开始抓取日志") + device_logger.start_log(path + '\\testFile\\log\\%s.log' % (self.TAG)) + Step("步骤4:打开测试应用") + self.driver.start_app("com.example.hnpselinuxtestapplication", "EntryAbility") + time.sleep(60) + Step("步骤4:关闭日志") + device_logger.stop_log() + time.sleep(4) + device_logger.check_log('Open public cfg file to read failed, errno=[2]') + device_logger.check_log('Open public cfg file to write failed, errno=[2]') + device_logger.check_log('Open private cfg file to read failed, errno=[2]') + device_logger.check_log('Open private cfg file to write failed, errno=[2]') + + def teardown(self): + Step("收尾工作:删除hap") + self.driver.uninstall_app("com.example.hnp_test") + self.driver.uninstall_app("com.example.hnpselinuxtestapplication") + self.driver.shell("hilog -b I") diff --git a/test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0400.json b/test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0400.json new file mode 100644 index 00000000..1aafb7c2 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0400.json @@ -0,0 +1,12 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["sub_startup_appspawn_nativedmscheck/SubStartupAppspawnNativedmscheck0400.py"] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0400.py b/test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0400.py new file mode 100644 index 00000000..2cdbd51e --- /dev/null +++ b/test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0400.py @@ -0,0 +1,90 @@ +#!/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 time +from devicetest.core.test_case import TestCase, Step, CheckPoint +from devicetest.core.test_case import Step, TestCase +from hypium.action.os_hypium.device_logger import DeviceLogger +from hypium.model import UiParam, WindowFilter +import os + + +class SubStartupAppspawnNativedmscheck0400(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() + Step('开启DEBUG日志') + self.driver.shell("hilog -b I -D 0xC02C11") + self.driver.shell("hilog -b DEBUG -T APPSPAWN") + self.driver.shell("hilog -b D -D 0xDC02C11") + self.driver.shell("hilog -G 16M") + host.shell('hdc shell "hilog -r"') + + def test_step1(self): + Step("步骤1:安装私有路径hap包") + path = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) + hap1 = os.path.abspath( + os.path.join(os.path.join(path, "testFile"), + 'SUB_STARTUP_APPSPAWN_NATIVE/entry-default-signedArm64-test.hap')) + hap2 = os.path.abspath( + os.path.join(os.path.join(path, "testFile"), + 'SUB_STARTUP_APPSPAWN_NATIVE/entry-default-signed-hnpselinux.hap')) + self.driver.install_app(hap1) + self.driver.install_app(hap2) + Step("步骤2:过滤日志") + device_logger = DeviceLogger(self.driver) + device_logger.set_filter_string("MY_TAG") + Step("步骤3:开始抓取日志") + device_logger.start_log(path + '\\testFile\\log\\%s.log' % (self.TAG)) + Step("步骤4:打开测试应用") + self.driver.start_app("com.example.hnpselinuxtestapplication", "EntryAbility") + time.sleep(60) + Step("步骤4:关闭日志") + device_logger.stop_log() + time.sleep(4) + Step("识别设备型号...............................") + device = self.driver.shell("param get const.product.model") + device = device.replace("\n", "").replace(" ", "") + device = str(device) + if ("HYM" in device or "HAD" in device): + device_logger.check_log("cfg file content:") + device_logger.check_log("[This is hnp sample config file.].") + device_logger.check_log("cfg file end") + device_logger.check_log('Open public cfg file to write failed, errno=[13]') + else: + device_logger.check_log('Open public cfg file to read failed, errno=[2]') + device_logger.check_log('Open public cfg file to write failed, errno=[2]') + device_logger.check_log('Open private cfg file to read failed, errno=[2]') + device_logger.check_log('Open private cfg file to write failed, errno=[2]') + + def teardown(self): + Step("收尾工作:删除hap") + self.driver.uninstall_app("com.example.hnp_test") + self.driver.uninstall_app("com.example.hnpselinuxtestapplication") + self.driver.shell("hilog -b I") diff --git a/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0100.json b/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0100.json new file mode 100644 index 00000000..a8e61cc2 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0100.json @@ -0,0 +1,12 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["sub_startup_appspawn_nativepack/SubStartupAppspawnNativepack0100.py"] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0100.py b/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0100.py new file mode 100644 index 00000000..60b3688b --- /dev/null +++ b/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0100.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 Step, TestCase +from hypium.model import UiParam, WindowFilter +import os +import time + + +class SubStartupAppspawnNativepack0100(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() + Step('预置工作:新增一个123.txt文件') + path = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) + file = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/window/sample')) + with open(file + "\\lib\\123.txt", "a+") as f1: + f1.write("12345678hdaskheiwoi4eliqwkldsajoejqooiudsisa") + + def test_step1(self): + Step("获取bat文件路径") + path = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) + bat = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/window/run.bat')) + Step("执行bat文件") + host.shell(bat) + Step("复制压缩文件") + out = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/window/out/')) + sample = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/window/sample/')) + file1 = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/window/out/hnpsample.hnp')) + file2 = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/window/out/hnpsample.zip')) + host.shell("copy "+file1 + " " + file2) + Step("步骤7:解压hnpsample.zip文件") + host.unzip_file(file2, out) + Step("步骤8:比较2个文件内容是否一致") + time.sleep(1) + dif1 = f.read() + with open(out+"\\sample\\cfg\\hnpsample.cfg") as f: + dif2 = f.read() + self.driver.Assert.equal(dif1, dif2) + dif1 = f.read() + dif2 = f.read() + self.driver.Assert.equal(dif1, dif2) + with open(sample + "\\lib\\123.txt") as f: + dif1 = f.read() + with open(out + "\\sample\\lib\\123.txt") as f: + dif2 = f.read() + self.driver.Assert.equal(dif1, dif2) + + def teardown(self): + Step("收尾工作:删除out目录文件") + path = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) + out = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/window/out/')) \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0200.json b/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0200.json new file mode 100644 index 00000000..f42ce0d5 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0200.json @@ -0,0 +1,12 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["sub_startup_appspawn_nativepack/SubStartupAppspawnNativepack0200.py"] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0200.py b/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0200.py new file mode 100644 index 00000000..1a38d824 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0200.py @@ -0,0 +1,68 @@ +#!/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 hypium.model import UiParam, WindowFilter +import os +import time + + +class SubStartupAppspawnNativepack0200(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("获取bat文件路径") + path = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) + bat = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/window/run.bat')) + Step("执行bat文件") + host.shell(bat) + Step("复制压缩文件") + out = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/window/out/')) + sample = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/window/sample/')) + file1 = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/window/out/hnpsample.hnp')) + file2 = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/window/out/hnpsample.zip')) + host.shell("copy "+file1 + " " + file2) + Step("步骤7:解压hnpsample.zip文件") + host.unzip_file(file2, out) + Step("步骤8:比较2个文件内容是否一致") + time.sleep(1) + dif1 = f.read() + with open(out+"\\sample\\cfg\\hnpsample.cfg") as f: + dif2 = f.read() + self.driver.Assert.equal(dif1, dif2) + dif1 = f.read() + dif2 = f.read() + self.driver.Assert.equal(dif1, dif2) + + def teardown(self): + Step("收尾工作:删除out目录文件") + path = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) + out = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/window/out/')) \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0300.json b/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0300.json new file mode 100644 index 00000000..376a9a5f --- /dev/null +++ b/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0300.json @@ -0,0 +1,12 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["sub_startup_appspawn_nativepack/SubStartupAppspawnNativepack0300.py"] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0300.py b/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0300.py new file mode 100644 index 00000000..9a1631cc --- /dev/null +++ b/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0300.py @@ -0,0 +1,77 @@ +#!/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 hypium.model import UiParam, WindowFilter +import os +import time + + +class SubStartupAppspawnNativepack0300(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() + Step('预置工作:修改打包的文件') + path = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) + file = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/window/sample')) + with open(file+"\\cfg\\hnpsample.cfg", "a") as f1: + f1.write("weuhriqj82hs9九jisapojhwkeioqw8321093nskjdlajejnphoneklv") + time.sleep(2) + + def test_step1(self): + Step("获取bat文件路径") + path = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) + bat = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/window/run.bat')) + Step("执行bat文件") + host.shell(bat) + Step("复制压缩文件") + out = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/window/out/')) + sample = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/window/sample/')) + file1 = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/window/out/hnpsample.hnp')) + file2 = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/window/out/hnpsample.zip')) + host.shell("copy "+file1 + " " + file2) + Step("步骤7:解压hnpsample.zip文件") + host.unzip_file(file2, out) + Step("步骤8:比较2个文件内容是否一致") + time.sleep(1) + dif1 = f.read() + with open(out+"\\sample\\cfg\\hnpsample.cfg") as f: + dif2 = f.read() + self.driver.Assert.equal(dif1, dif2) + dif1 = f.read() + dif2 = f.read() + self.driver.Assert.equal(dif1, dif2) + + def teardown(self): + Step("收尾工作:删除out目录文件") + path = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) + out = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/window/out/')) + file = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/sample')) + with open(file + "\\cfg\\hnpsample.cfg", "w") as f1: + f1.write("This is hnp sample config file.") \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0400.json b/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0400.json new file mode 100644 index 00000000..b615cf06 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0400.json @@ -0,0 +1,12 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["sub_startup_appspawn_nativepack/SubStartupAppspawnNativepack0400.py"] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0400.py b/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0400.py new file mode 100644 index 00000000..ed43fa77 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0400.py @@ -0,0 +1,77 @@ +#!/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 hypium.model import UiParam, WindowFilter +import os +import time + + +class SubStartupAppspawnNativepack0400(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:添加读写权限") + self.driver.hdc("target mount") + Step("步骤2:导入打包所需的文件到设备data/usr目录") + self.driver.shell("mkdir data/usr") + path = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) + file1 = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/hnpcli')) + file2 = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/sample')) + self.driver.hdc("hdc file send " + file1 + " /data") + self.driver.hdc("hdc file send " + file2 + " /data/usr") + Step("步骤3:添加权限") + self.driver.shell("chmod +x /data/hnpcli") + Step("步骤4:执行打包命令") + self.driver.shell("data/hnpcli pack -i /data/usr/sample -o /data ") + Step("步骤5:复制hnp文件为zip文件") + self.driver.shell("cp /data/hnpsample.hnp /data/hnpsample.zip") + Step("步骤6:导出生成的zip包到本地") + out = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/out/')) + self.driver.hdc("hdc file recv /data/hnpsample.zip "+out) + Step("步骤7:解压hnpsample.zip文件") + Step("步骤8:比较2个文件内容是否一致") + time.sleep(1) + with open(file2+"\\cfg\\hnpsample.cfg") as f: + dif1 = f.read() + with open(out+"\\sample\\cfg\\hnpsample.cfg") as f: + dif2 = f.read() + self.driver.Assert.equal(dif1, dif2) + dif1 = f.read() + dif2 = f.read() + self.driver.Assert.equal(dif1, dif2) + + def teardown(self): + Step("收尾工作:删除out目录文件") + path = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) + out = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/out/')) + self.driver.shell("rm -rf /data/hnpsample.zip") + self.driver.shell("rm -rf /data/hnpsample.hnp") \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0500.json b/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0500.json new file mode 100644 index 00000000..ecdac029 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0500.json @@ -0,0 +1,12 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["sub_startup_appspawn_nativepack/SubStartupAppspawnNativepack0500.py"] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0500.py b/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0500.py new file mode 100644 index 00000000..a50cf5e1 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0500.py @@ -0,0 +1,88 @@ +#!/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 time + +from devicetest.core.test_case import Step, TestCase +from hypium.model import UiParam, WindowFilter +import os + + +class SubStartupAppspawnNativepack0500(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() + Step('预置工作:修改打包的文件') + path = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) + file = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/sample')) + with open(file+"\\cfg\\hnpsample.cfg", "a") as f1: + f1.write("weuhriqj82hs9九jisapojhwkeioqw8321093nskjdlajejnphoneklv") + time.sleep(2) + + def test_step1(self): + Step("步骤1:添加读写权限") + self.driver.hdc("target mount") + Step("步骤2:导入打包所需的文件到设备data/usr目录") + self.driver.shell("mkdir data/usr") + path = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) + file1 = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/hnpcli')) + file2 = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/sample')) + self.driver.hdc("hdc file send " + file1 + " /data") + self.driver.hdc("hdc file send " + file2 + " /data/usr") + Step("步骤3:添加权限") + self.driver.shell("chmod +x /data/hnpcli") + Step("步骤4:执行打包命令") + self.driver.shell("data/hnpcli pack -i /data/usr/sample -o /data ") + Step("步骤5:复制hnp文件为zip文件") + self.driver.shell("cp /data/hnpsample.hnp /data/hnpsample.zip") + Step("步骤6:导出生成的zip包到本地") + out = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/out/')) + self.driver.hdc("hdc file recv /data/hnpsample.zip " + out) + Step("步骤7:解压hnpsample.zip文件") + host.unzip_file(out + "\\hnpsample.zip", out) + Step("步骤8:比较2个文件内容是否一致") + time.sleep(1) + dif1 = f.read() + dif2 = f.read() + self.driver.Assert.equal(dif1, dif2) + dif1 = f.read() + dif2 = f.read() + self.driver.Assert.equal(dif1, dif2) + + def teardown(self): + Step("收尾工作:删除&修改相关文件") + path = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) + out = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/out/')) + self.driver.shell("rm -rf /data/hnpsample.zip") + self.driver.shell("rm -rf /data/hnpsample.hnp") + file = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/sample')) + with open(file + "\\cfg\\hnpsample.cfg", "w") as f1: + f1.write("This is hnp sample config file.") + + diff --git a/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0600.json b/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0600.json new file mode 100644 index 00000000..434e339a --- /dev/null +++ b/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0600.json @@ -0,0 +1,12 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["sub_startup_appspawn_nativepack/SubStartupAppspawnNativepack0600.py"] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0600.py b/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0600.py new file mode 100644 index 00000000..49a7f75c --- /dev/null +++ b/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0600.py @@ -0,0 +1,86 @@ +#!/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 time + +from devicetest.core.test_case import Step, TestCase +from hypium.model import UiParam, WindowFilter +import os + + +class SubStartupAppspawnNativepack0600(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() + Step('预置工作:新增一个123.txt文件') + path = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) + file = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/sample')) + f1.write("12345678hdaskheiwoi4eliqwkldsajoejqooiudsisa") + + def test_step1(self): + Step("步骤1:添加读写权限") + self.driver.hdc("target mount") + Step("步骤2:导入打包所需的文件到设备data/usr目录") + self.driver.shell("mkdir data/usr") + path = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) + file1 = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/hnpcli')) + file2 = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/sample')) + self.driver.hdc("hdc file send " + file1 + " /data") + self.driver.hdc("hdc file send " + file2 + " /data/usr") + Step("步骤3:添加权限") + self.driver.shell("chmod +x /data/hnpcli") + Step("步骤4:执行打包命令") + self.driver.shell("data/hnpcli pack -i /data/usr/sample -o /data ") + Step("步骤5:复制hnp文件为zip文件") + self.driver.shell("cp /data/hnpsample.hnp /data/hnpsample.zip") + Step("步骤6:导出生成的zip包到本地") + out = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/out/')) + self.driver.hdc("hdc file recv /data/hnpsample.zip " + out) + Step("步骤7:解压hnpsample.zip文件") + host.unzip_file(out + "\\hnpsample.zip", out) + Step("步骤8:比较2个文件内容是否一致") + time.sleep(1) + dif1 = f.read() + dif2 = f.read() + self.driver.Assert.equal(dif1, dif2) + dif1 = f.read() + dif2 = f.read() + self.driver.Assert.equal(dif1, dif2) + dif1 = f.read() + with open(out + "\\sample\\lib\\123.txt") as f: + dif2 = f.read() + self.driver.Assert.equal(dif1, dif2) + + def teardown(self): + Step("收尾工作:删除相关文件") + path = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) + out = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/out/')) + file = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/sample')) + self.driver.shell("rm -rf /data/hnpsample.zip") + self.driver.shell("rm -rf /data/hnpsample.hnp") diff --git a/test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess.json b/test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess.json new file mode 100644 index 00000000..8c1a9c37 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess.json @@ -0,0 +1,20 @@ +{ + "description": "Config for OpenHarmony app test suites", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTestSuite", + "testsuite": "sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess.py", + "suitecases": [ + "sub_startup_appspawn_nativeprocess/SubStartupAppspawnNativeprocess0100.py", + "sub_startup_appspawn_nativeprocess/SubStartupAppspawnNativeprocess0200.py", + "sub_startup_appspawn_nativeprocess/SubStartupAppspawnNativeprocess0300.py", + "sub_startup_appspawn_nativeprocess/SubStartupAppspawnNativeprocess0400.py", + "sub_startup_appspawn_nativeprocess/SubStartupAppspawnNativeprocess0500.py", + "sub_startup_appspawn_nativeprocess/SubStartupAppspawnNativeprocess0600.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess.py b/test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess.py new file mode 100644 index 00000000..3ef49829 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess.py @@ -0,0 +1,41 @@ +#!/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 +from devicetest.core.suite.test_suite import TestSuite +from aw import Common + + +class SubStartupAppspawnNativeprocess(TestSuite): + + def setup(self): + Step("TestCase: setup") + self.driver = UiDriver(self.device1) + Step("预置工作:初始化手机开始.................") + Step(self.devices[0].device_id) + Step("导入配置文件.................") + self.driver.hdc("target mount") + sourpath = Common.sourcepath("AppSpawnTest", "sub_startup_appspawn_nativeprocess") + destpath = "/data/AppSpawnTest" + self.driver.push_file(sourpath, destpath) + sleep(3) + Step("给测试文件AppSpawnTest可执行权限.................") + self.driver.shell('chmod +x /data/AppSpawnTest') + self.driver.shell('./data/AppSpawnTest') + + def teardown(self): + Step("收尾工作,删除文件.................") + self.driver.shell("rm /data/AppSpawnTest") diff --git a/test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess_0100.py b/test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess_0100.py new file mode 100644 index 00000000..26b96df1 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess_0100.py @@ -0,0 +1,39 @@ +#!/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 + + +class SubStartupAppspawnNativeprocess0100(TestCase): + + def __init__(self, controllers): + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.TAG, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("TestCase: setup") + Step("预置工作:初始化手机开始.................") + Step(self.devices[0].device_id) + + def test_step1(self): + Step("执行AppSpawnTest'.................") + result = self.driver.shell('./data/AppSpawnTest') + self.driver.Assert.contains(result, "Failed spawn new app result", "默认启动孵化APPSPAWN失败") + + def teardown(self): + Step("TestCase: teardown") diff --git a/test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess_0200.py b/test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess_0200.py new file mode 100644 index 00000000..27866f8d --- /dev/null +++ b/test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess_0200.py @@ -0,0 +1,42 @@ +#!/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 + + +class SubStartupAppspawnNativeprocess0200(TestCase): + + def __init__(self, controllers): + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.TAG, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("TestCase: setup") + Step("预置工作:初始化手机开始.................") + Step(self.devices[0].device_id) + + def test_step1(self): + Step("执行AppSpawnTest'.................") + result = self.driver.shell('./data/AppSpawnTest -s -b moduleTestProcessName') + self.driver.Assert.contains(result, "Failed spawn new app result", "带沙盒启动孵化APPSPAWN失败") + Step("执行AppSpawnTest'.................") + failresult = self.driver.shell('./data/AppSpawnTest -s') + self.driver.Assert.contains(failresult, "Failed spawn new app result -1", "模拟'带沙盒启动孵化APPSPAWN失败'失败") + + def teardown(self): + Step("TestCase: teardown") diff --git a/test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess_0400.py b/test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess_0400.py new file mode 100644 index 00000000..c16add36 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess_0400.py @@ -0,0 +1,39 @@ +#!/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 + + +class SubStartupAppspawnNativeprocess0400(TestCase): + + def __init__(self, controllers): + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.TAG, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("TestCase: setup") + Step("预置工作:初始化手机开始.................") + Step(self.devices[0].device_id) + + def test_step1(self): + Step("执行AppSpawnTest'.................") + result = self.driver.shell('./data/AppSpawnTest -b ohos.xxxxxx.xxxxxxxx') + self.driver.Assert.contains(result, "Failed spawn new app result", "模拟新app启动孵化APPSPAWN失败") + + def teardown(self): + Step("TestCase: teardown") diff --git a/test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess_0500.py b/test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess_0500.py new file mode 100644 index 00000000..f10dd2c7 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess_0500.py @@ -0,0 +1,39 @@ +#!/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 + + +class SubStartupAppspawnNativeprocess0500(TestCase): + + def __init__(self, controllers): + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.TAG, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("TestCase: setup") + Step("预置工作:初始化手机开始.................") + Step(self.devices[0].device_id) + + def test_step1(self): + Step("执行AppSpawnTest'.................") + result = self.driver.shell('./data/AppSpawnTest -b ohos.xxxxxx.xxxxxxxx -s') + self.driver.Assert.contains(result, "Failed spawn new app result -1", "指定不存在app启动孵化APPSPAWN失败") + + def teardown(self): + Step("TestCase: teardown") diff --git a/test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess_0600.py b/test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess_0600.py new file mode 100644 index 00000000..dc1c2248 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess_0600.py @@ -0,0 +1,42 @@ +#!/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 + + +class SubStartupAppspawnNativeprocess0600(TestCase): + + def __init__(self, controllers): + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.TAG, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("TestCase: setup") + Step("预置工作:初始化手机开始.................") + Step(self.devices[0].device_id) + + def test_step1(self): + Step("执行AppSpawnTest'.................") + result = self.driver.shell('./data/AppSpawnTest -b ohos.xxxxxx.xxxxxxxx -s') + self.driver.Assert.contains(result, "Failed spawn new app result -1", "指定不存在app启动孵化APPSPAWN失败") + Step("执行AppSpawnTest'.................") + successresult = self.driver.shell('./data/AppSpawnTest -C') + self.driver.Assert.contains(result, "Failed spawn new app result", "模拟指定不存在的app启动孵化APPSPAWN失败后,重新启动测试失败") + + def teardown(self): + Step("TestCase: teardown") diff --git a/test/autotest/sub_startup_appspawn_nativesandbox/sub_startup_appspawn_nativesandbox_0100.json b/test/autotest/sub_startup_appspawn_nativesandbox/sub_startup_appspawn_nativesandbox_0100.json new file mode 100644 index 00000000..9f5581fd --- /dev/null +++ b/test/autotest/sub_startup_appspawn_nativesandbox/sub_startup_appspawn_nativesandbox_0100.json @@ -0,0 +1,12 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["sub_startup_appspawn_nativesandbox/SubStartupAppspawnNativesandbox0100.py"] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_nativesandbox/sub_startup_appspawn_nativesandbox_0100.py b/test/autotest/sub_startup_appspawn_nativesandbox/sub_startup_appspawn_nativesandbox_0100.py new file mode 100644 index 00000000..982ae508 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_nativesandbox/sub_startup_appspawn_nativesandbox_0100.py @@ -0,0 +1,84 @@ +#!/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 time +from devicetest.core.test_case import Step, TestCase +from hypium.model import UiParam, WindowFilter +import os + + +class SubStartupAppspawnNativesandbox0100(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.shell("power-shell timeout -o 2147483647") + + def test_step1(self): + Step("步骤1:创建公有hnp存放目录") + self.driver.shell("mkdir -p data/UCbrowser/public") + Step("步骤2:导入安装包文件hnp") + 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/sign/hnpsample.hnp')) + hap = os.path.abspath( + os.path.join(os.path.join(path, "testFile"), 'SUB_STARTUP_APPSPAWN_NATIVE/sign/entry-default-signedArm64-test11.hap')) + self.driver.push_file(hnp, "data/UCbrowser/public/") + self.driver.push_file(hap, "data/UCbrowser") + Step("步骤3:执行安装命令") + self.driver.shell( + "hnp install -u 100 -p uc_browser -i data/UCbrowser -s data/UCbrowser/entry-default-signedArm64-test11.hap -a arm64 -f") + Step("步骤4:查看是是否安装成功") + public = self.driver.shell("ls /data/app/el1/bundle/100/hnppublic/") + self.driver.Assert.contains(public, "hnpsample.org") + result = self.driver.shell("cat /data/service/el1/startup/hnp_info.json") + self.driver.Assert.contains(result, "uc_browser") + Step("步骤5:安装测试hap包") + ishap = self.driver.has_app("com.example.hnptestapplication") + if (ishap): + hap1 = os.path.abspath( + os.path.join(os.path.join(path, "testFile"), + 'SUB_STARTUP_APPSPAWN_NATIVE/entry-default-sandbox.hap')) + self.driver.install_app(hap1) + Step("步骤6:打开测试hap包") + self.driver.shell("aa start -a EntryAbility -b com.example.hnptestapplication") + Step("步骤7:获取测试应用pid") + time.sleep(3) + pid = self.driver.System.get_pid("com.example.hnptestapplication") + Step("步骤8:查看测试应用公有沙箱路径") + result = self.driver.shell("ls /proc/%d/root/data/service/hnp" % pid) + Step("步骤9:预期结果校验") + Step("识别设备型号...............................") + device = self.driver.shell("param get const.product.model") + device = device.replace("\n", "").replace(" ", "") + device = str(device) + if ("HYM" in device or "HAD" in device): + self.driver.Assert.contains(result, "bin") + self.driver.Assert.contains(result, "hnpsample.org") + else: + self.driver.Assert.contains(result, "No such file or directory") + diff --git a/test/autotest/sub_startup_appspawn_nativesandbox/sub_startup_appspawn_nativesandbox_0200.json b/test/autotest/sub_startup_appspawn_nativesandbox/sub_startup_appspawn_nativesandbox_0200.json new file mode 100644 index 00000000..700785e5 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_nativesandbox/sub_startup_appspawn_nativesandbox_0200.json @@ -0,0 +1,13 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["sub_startup_appspawn_nativesandbox/SubStartupAppspawnNativesandbox0200.py"] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_nativesandbox/sub_startup_appspawn_nativesandbox_0200.py b/test/autotest/sub_startup_appspawn_nativesandbox/sub_startup_appspawn_nativesandbox_0200.py new file mode 100644 index 00000000..d26ab39d --- /dev/null +++ b/test/autotest/sub_startup_appspawn_nativesandbox/sub_startup_appspawn_nativesandbox_0200.py @@ -0,0 +1,84 @@ +#!/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 time +from devicetest.core.test_case import Step, TestCase +from hypium.model import UiParam, WindowFilter +import os + + +class SubStartupAppspawnNativesandbox0200(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.shell("power-shell timeout -o 2147483647") + + def test_step1(self): + Step("步骤1:创建公有hnp存放目录") + self.driver.shell("mkdir -p data/com.example.hnptestapplication/private") + Step("步骤2:导入安装包文件hnp") + 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/sign/hnpsample.hnp')) + hap = os.path.abspath( + os.path.join(os.path.join(path, "testFile"), 'SUB_STARTUP_APPSPAWN_NATIVE/sign/entry-default-signedArm64-test11.hap')) + self.driver.push_file(hnp, "data/com.example.hnptestapplication/private/") + self.driver.push_file(hap, "data/com.example.hnptestapplication") + Step("步骤3:执行安装命令") + self.driver.shell( + "hnp install -u 100 -p com.example.hnptestapplication -i data/com.example.hnptestapplication -s data/com.example.hnptestapplication/entry-default-signedArm64-test11.hap -a arm64 -f") + Step("步骤4:查看是是否安装成功") + public = self.driver.shell("ls /data/app/el1/bundle/100/hnp/com.example.hnptestapplication") + self.driver.Assert.contains(public, "hnpsample.org") + Step("步骤5:安装测试hap包") + ishap = self.driver.has_app("com.example.hnptestapplication") + if (ishap): + hap1 = os.path.abspath( + os.path.join(os.path.join(path, "testFile"), + 'SUB_STARTUP_APPSPAWN_NATIVE/entry-default-sandbox.hap')) + self.driver.install_app(hap1) + Step("步骤6:打开测试hap包") + self.driver.shell("aa start -a EntryAbility -b com.example.hnptestapplication") + Step("步骤7:获取测试应用pid") + time.sleep(1) + pid = self.driver.System.get_pid("com.example.hnptestapplication") + Step("步骤8:查看测试应用公有沙箱路径") + result = self.driver.shell("ls /proc/%d/root/data/app" % pid) + Step("步骤9:预期结果校验") + Step("识别设备型号...............................") + device = self.driver.shell("param get const.product.model") + device = device.replace("\n", "").replace(" ", "") + device = str(device) + if ("HYM" in device or "HAD" in device): + self.driver.Assert.contains(result, "bin") + self.driver.Assert.contains(result, "hnpsample.org") + else: + self.driver.Assert.contains(result, "No such file or directory") + + def teardown(self): + self.driver.shell("hnp uninstall -u 100 -p com.example.hnptestapplication") -- Gitee