From 65da5f717e42bcb784d4759de8534c689db56cdb Mon Sep 17 00:00:00 2001 From: TFStudy <3202410880@qq.com> Date: Tue, 1 Jun 2021 16:43:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example/build.gradle | 20 +++++++-- example/src/ohosTest/config.json | 41 +++++++++++++++++++ .../goodiebag/pinview/ExampleOhosTest.java | 17 ++++++++ 3 files changed, 75 insertions(+), 3 deletions(-) create mode 100644 example/src/ohosTest/config.json create mode 100644 example/src/ohosTest/java/com/goodiebag/pinview/ExampleOhosTest.java diff --git a/example/build.gradle b/example/build.gradle index 9a01645..642c86d 100644 --- a/example/build.gradle +++ b/example/build.gradle @@ -1,14 +1,28 @@ apply plugin: 'com.huawei.ohos.hap' +apply plugin: 'com.huawei.ohos.decctest' ohos { compileSdkVersion 5 defaultConfig { compatibleSdkVersion 5 } - + buildTypes { + release { + proguardOpt { + proguardEnabled false + rulesFiles 'proguard-rules.pro' + } + } + } + } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar', '*.har']) - testCompile 'junit:junit:4.12' - implementation(project(":pinview")) + implementation 'org.jetbrains:annotations:19.0.0' + testImplementation 'junit:junit:4.13' + implementation project(":pinview") + ohosTestImplementation 'com.huawei.ohos.testkit:runner:1.0.0.100' } +decc { + supportType = ['html','xml'] +} \ No newline at end of file diff --git a/example/src/ohosTest/config.json b/example/src/ohosTest/config.json new file mode 100644 index 0000000..5420f40 --- /dev/null +++ b/example/src/ohosTest/config.json @@ -0,0 +1,41 @@ +{ + "app": { + "bundleName": "com.goodiebag.pinview", + "vendor": "goodiebag", + "version": { + "code": 1, + "name": "1.0" + }, + "apiVersion": { + "compatible": 5, + "target": 5, + "releaseType": "Release" + } + }, + "deviceConfig": {}, + "module": { + "package": "com.goodiebag.pinview", + "name": "testModule", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry_test", + "moduleType": "feature", + "installationFree": true + }, + "abilities": [ + { + "name": "decc.testkit.runner.EntryAbility", + "description": "Test Entry Ability", + "icon": "$media:icon", + "label": "Pinview", + "launchType": "standard", + "orientation": "landscape", + "visible": true, + "type": "page" + } + ] + } +} \ No newline at end of file diff --git a/example/src/ohosTest/java/com/goodiebag/pinview/ExampleOhosTest.java b/example/src/ohosTest/java/com/goodiebag/pinview/ExampleOhosTest.java new file mode 100644 index 0000000..34786d0 --- /dev/null +++ b/example/src/ohosTest/java/com/goodiebag/pinview/ExampleOhosTest.java @@ -0,0 +1,17 @@ +package com.goodiebag.pinview; + +import ohos.aafwk.ability.delegation.AbilityDelegatorRegistry; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +public class ExampleOhosTest { + /** + * 全UI应用、不支持Context,不支持单元测试 + */ + @Test + public void testBundleName() { + final String actualBundleName = AbilityDelegatorRegistry.getArguments().getTestBundleName(); + assertEquals("com.goodiebag.pinview", actualBundleName); + } +} \ No newline at end of file -- Gitee