From 877c43a3305d3401b0e3eabae4083d4b0e885829 Mon Sep 17 00:00:00 2001 From: xingfei Date: Tue, 25 May 2021 16:37:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9source=E6=96=87=E4=BB=B6?= =?UTF-8?q?=EF=BC=8C=E5=A2=9E=E5=8A=A0=E5=8D=95=E5=85=83=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 2 + README.OPENSOURCE | 12 +++--- changeLog.md | 8 ---- entry/build.gradle | 1 + entry/src/ohosTest/config.json | 40 +++++++++++++++++++ .../chaos/view/example/ExampleOhosTest.java | 17 ++++++++ .../com/chaos/view/example/PinViewTest.java | 13 ++++++ pinview/build.gradle | 2 + .../src/main/java/com/chaos/view/PinView.java | 2 +- 9 files changed, 82 insertions(+), 15 deletions(-) create mode 100644 CHANGELOG.md delete mode 100644 changeLog.md create mode 100644 entry/src/ohosTest/config.json create mode 100644 entry/src/ohosTest/java/com/chaos/view/example/ExampleOhosTest.java create mode 100644 entry/src/ohosTest/java/com/chaos/view/example/PinViewTest.java diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..cae93e3 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,2 @@ +# 0.0.1-SNAPSHOT: +- ohos 第一个版本,完整实现了原库的全部 api diff --git a/README.OPENSOURCE b/README.OPENSOURCE index ac96d90..10f6a46 100644 --- a/README.OPENSOURCE +++ b/README.OPENSOURCE @@ -2,17 +2,17 @@ { - "Name": "PinView", + "Name": " PinView ", - "License": "Apache License 2.0", + "License": " Apache License 2.0 ", - "License File": "https://github.com/ChaosLeung/PinView/blob/master/LICENSE", + "License File": " LICENSE ", - "Version Number": "1.4.3", + "Version Number": " v1.4.3 ", - "Upstream URL": "https://github.com/ChaosLeung/PinView", + "Upstream URL": " https://github.com/ChaosLeung/PinView/archive/1.4.3.tar.gz ", - "Description": "输入框的背景颜色的动态变化,基线的显示与隐藏,明文密文的切换" + "Description": " 输入框的背景颜色的动态变化,基线的显示与隐藏,明文密文的切换 " } diff --git a/changeLog.md b/changeLog.md deleted file mode 100644 index 63dc57e..0000000 --- a/changeLog.md +++ /dev/null @@ -1,8 +0,0 @@ -# 基本功能: -- 输入框的背景颜色的动态变化,基线的显示与隐藏,明文密文的切换 - -# 修改点: -1. EditText 鸿蒙使用TextField替换实现 - -# 遗留问题(暂不支持的功能): -无 \ No newline at end of file diff --git a/entry/build.gradle b/entry/build.gradle index c75cfa0..9eb1f5b 100644 --- a/entry/build.gradle +++ b/entry/build.gradle @@ -23,6 +23,7 @@ dependencies { implementation fileTree(dir: 'libs', include: ['*.jar', '*.har']) implementation project(path: ':pinview') testImplementation 'junit:junit:4.13' + ohosTestImplementation 'com.huawei.ohos.testkit:runner:1.0.0.100' } decc { supportType = ['html', 'xml'] diff --git a/entry/src/ohosTest/config.json b/entry/src/ohosTest/config.json new file mode 100644 index 0000000..0dc0598 --- /dev/null +++ b/entry/src/ohosTest/config.json @@ -0,0 +1,40 @@ +{ + "app": { + "bundleName": "com.chaos.view.example", + "vendor": "chaos", + "version": { + "code": 1, + "name": "1.0" + }, + "apiVersion": { + "compatible": 5, + "target": 5 + } + }, + "deviceConfig": {}, + "module": { + "package": "com.chaos.view.example", + "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": "$string:app_name", + "launchType": "standard", + "orientation": "landscape", + "visible": true, + "type": "page" + } + ] + } +} \ No newline at end of file diff --git a/entry/src/ohosTest/java/com/chaos/view/example/ExampleOhosTest.java b/entry/src/ohosTest/java/com/chaos/view/example/ExampleOhosTest.java new file mode 100644 index 0000000..f5efac0 --- /dev/null +++ b/entry/src/ohosTest/java/com/chaos/view/example/ExampleOhosTest.java @@ -0,0 +1,17 @@ +package com.chaos.view.example; + +import ohos.aafwk.ability.delegation.AbilityDelegatorRegistry; +import org.junit.Test; + + +import static org.junit.Assert.assertEquals; + +public class ExampleOhosTest { + + + @Test + public void testBundleName() { + final String actualBundleName = AbilityDelegatorRegistry.getArguments().getTestBundleName(); + assertEquals("com.chaos.view.example", actualBundleName); + } +} \ No newline at end of file diff --git a/entry/src/ohosTest/java/com/chaos/view/example/PinViewTest.java b/entry/src/ohosTest/java/com/chaos/view/example/PinViewTest.java new file mode 100644 index 0000000..68d2289 --- /dev/null +++ b/entry/src/ohosTest/java/com/chaos/view/example/PinViewTest.java @@ -0,0 +1,13 @@ +package com.chaos.view.example; + +import com.chaos.view.PinView; +import junit.framework.TestCase; +import org.junit.Test; + +public class PinViewTest extends TestCase { + @Test + public void testIsNumeric() { + assertTrue(PinView.isNumeric("655")); + assertFalse(PinView.isNumeric("ddd")); + } +} diff --git a/pinview/build.gradle b/pinview/build.gradle index e1bc016..c531a17 100644 --- a/pinview/build.gradle +++ b/pinview/build.gradle @@ -9,6 +9,8 @@ ohos { dependencies { implementation fileTree(dir: 'libs', include: ['*.jar', '*.har']) testImplementation 'junit:junit:4.13' + testImplementation 'org.powermock:powermock-api-mockito2:2.0.2' + testImplementation 'org.powermock:powermock-module-junit4:2.0.2' } /** diff --git a/pinview/src/main/java/com/chaos/view/PinView.java b/pinview/src/main/java/com/chaos/view/PinView.java index d6061c0..53d17ba 100644 --- a/pinview/src/main/java/com/chaos/view/PinView.java +++ b/pinview/src/main/java/com/chaos/view/PinView.java @@ -311,7 +311,7 @@ public class PinView extends TextField implements Component.BindStateChangedList * @param str 传进来的文本 * @return boolean */ - public boolean isNumeric(String str) { + public static boolean isNumeric(String str) { Pattern pattern = Pattern.compile("[0-9]*"); Matcher isNum = pattern.matcher(str); if (!isNum.matches()) { -- Gitee