From 1cdab4a1a77a05331396bb78b0c7d8111b105549 Mon Sep 17 00:00:00 2001 From: renpengfei Date: Fri, 21 May 2021 17:33:30 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E6=9B=B4=E6=94=B9Readme=202=E3=80=81?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0OPENSOURCE=203=E3=80=81=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=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 --- README.OPENSOURCE | 19 +++ build.gradle | 2 +- entry/build.gradle | 10 +- entry/src/main/config.json | 4 +- .../main/resources/base/element/string.json | 2 +- entry/src/ohosTest/config.json | 41 ++++++ .../ExampleOhosTest.java | 139 ++++++++++++++++++ 7 files changed, 211 insertions(+), 6 deletions(-) create mode 100644 README.OPENSOURCE create mode 100644 entry/src/ohosTest/config.json create mode 100644 entry/src/ohosTest/java/com/glidebitmappoolsample/ExampleOhosTest.java diff --git a/README.OPENSOURCE b/README.OPENSOURCE new file mode 100644 index 0000000..a535d7e --- /dev/null +++ b/README.OPENSOURCE @@ -0,0 +1,19 @@ +[ + + { + + "Name": "GlideBitmapPool", + + "License": "Apache License", + + "License File": "https://github.com/Sunzxyong/GlideBitmapPool/blob/master/README.md", + + "Version Number": "0.0.1", + + "Upstream URL": "https://github.com/Sunzxyong/GlideBitmapPool", + + "Description": "用于重用位图内存的内存管理库" + + } + +] \ No newline at end of file diff --git a/build.gradle b/build.gradle index 65297cc..092b53d 100644 --- a/build.gradle +++ b/build.gradle @@ -20,7 +20,7 @@ buildscript { } dependencies { classpath 'com.huawei.ohos:hap:2.4.2.7' - classpath 'com.huawei.ohos:decctest:1.0.0.6' + classpath 'com.huawei.ohos:decctest:1.0.0.7' } } diff --git a/entry/build.gradle b/entry/build.gradle index 968754d..2d3b390 100644 --- a/entry/build.gradle +++ b/entry/build.gradle @@ -1,13 +1,19 @@ apply plugin: 'com.huawei.ohos.hap' +apply plugin: 'com.huawei.ohos.decctest' ohos { compileSdkVersion 5 defaultConfig { - compatibleSdkVersion 4 + compatibleSdkVersion 5 } } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar', '*.har']) - testCompile 'junit:junit:4.12' + testImplementation 'junit:junit:4.13' + ohosTestImplementation 'com.huawei.ohos.testkit:runner:1.0.0.100' implementation('com.gitee.chinasoft_ohos:GlideBitmapPool:0.0.1-SNAPSHOT') } + +decc { + supportType = ['html','xml'] +} diff --git a/entry/src/main/config.json b/entry/src/main/config.json index e9636f9..4b3104d 100644 --- a/entry/src/main/config.json +++ b/entry/src/main/config.json @@ -1,7 +1,7 @@ { "app": { "bundleName": "com.glidebitmappoolsample", - "vendor": "work", + "vendor": "glidebitmappoolsample", "version": { "code": 1, "name": "1.0" @@ -62,7 +62,7 @@ "name": "com.glidebitmappoolsample.MainAbility", "icon": "$media:icon", "description": "$string:mainability_description", - "label": "HM_GlideBitmapPool_master", + "label": "GlideBitmapPool_master", "type": "page", "launchType": "standard" } diff --git a/entry/src/main/resources/base/element/string.json b/entry/src/main/resources/base/element/string.json index 8237584..3104a46 100644 --- a/entry/src/main/resources/base/element/string.json +++ b/entry/src/main/resources/base/element/string.json @@ -2,7 +2,7 @@ "string": [ { "name": "app_name", - "value": "HM_GlideBitmapPool_master" + "value": "GlideBitmapPool_master" }, { "name": "mainability_description", diff --git a/entry/src/ohosTest/config.json b/entry/src/ohosTest/config.json new file mode 100644 index 0000000..94b2351 --- /dev/null +++ b/entry/src/ohosTest/config.json @@ -0,0 +1,41 @@ +{ + "app": { + "bundleName": "com.glidebitmappoolsample", + "vendor": "glidebitmappoolsample", + "version": { + "code": 1, + "name": "1.0" + }, + "apiVersion": { + "compatible": 5, + "target": 5, + "releaseType": "Release" + } + }, + "deviceConfig": {}, + "module": { + "package": "com.glidebitmappoolsample", + "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": "GlideBitmapPool_master", + "launchType": "standard", + "orientation": "landscape", + "visible": true, + "type": "page" + } + ] + } +} \ No newline at end of file diff --git a/entry/src/ohosTest/java/com/glidebitmappoolsample/ExampleOhosTest.java b/entry/src/ohosTest/java/com/glidebitmappoolsample/ExampleOhosTest.java new file mode 100644 index 0000000..e1ccb5f --- /dev/null +++ b/entry/src/ohosTest/java/com/glidebitmappoolsample/ExampleOhosTest.java @@ -0,0 +1,139 @@ +package com.glidebitmappoolsample; + +import ohos.aafwk.ability.delegation.AbilityDelegatorRegistry; +import org.junit.Test; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +import static org.junit.Assert.assertEquals; + +public class ExampleOhosTest { + @Test + public void testBundleName() { + final String actualBundleName = AbilityDelegatorRegistry.getArguments().getTestBundleName(); + assertEquals("com.glidebitmappoolsample", actualBundleName); + } + + @Test + public void releaseBitmapMethod(){ + try { + Class mainAbilitySlice = Class.forName("com.glidebitmappoolsample.slice.MainAbilitySlice"); + Method releaseBitmapMethod = mainAbilitySlice.getMethod("releaseBitmapMethod"); + Object object = mainAbilitySlice.getConstructor().newInstance(); + releaseBitmapMethod.invoke(object); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } catch (InstantiationException e) { + e.printStackTrace(); + } catch (InvocationTargetException e) { + e.printStackTrace(); + } + } + + @Test + public void runNormalFile(){ + try { + Class mainAbilitySlice = Class.forName("com.glidebitmappoolsample.slice.MainAbilitySlice"); + Method runNormalFile = mainAbilitySlice.getMethod("runNormalFile"); + Object object = mainAbilitySlice.getConstructor().newInstance(); + runNormalFile.invoke(object); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } catch (InstantiationException e) { + e.printStackTrace(); + } catch (InvocationTargetException e) { + e.printStackTrace(); + } + } + + @Test + public void runResourceOptimized(){ + try { + Class mainAbilitySlice = Class.forName("com.glidebitmappoolsample.slice.MainAbilitySlice"); + Method runResourceOptimized = mainAbilitySlice.getMethod("runResourceOptimized"); + Object object = mainAbilitySlice.getConstructor().newInstance(); + runResourceOptimized.invoke(object); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } catch (InstantiationException e) { + e.printStackTrace(); + } catch (InvocationTargetException e) { + e.printStackTrace(); + } + } + + @Test + public void runFileOptimized(){ + try { + Class mainAbilitySlice = Class.forName("com.glidebitmappoolsample.slice.MainAbilitySlice"); + Method runFileOptimized = mainAbilitySlice.getMethod("runFileOptimized"); + Object object = mainAbilitySlice.getConstructor().newInstance(); + runFileOptimized.invoke(object); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } catch (InstantiationException e) { + e.printStackTrace(); + } catch (InvocationTargetException e) { + e.printStackTrace(); + } + } + + @Test + public void runDownSample(){ + try { + Class mainAbilitySlice = Class.forName("com.glidebitmappoolsample.slice.MainAbilitySlice"); + Method runDownSample = mainAbilitySlice.getMethod("runDownSample"); + Object object = mainAbilitySlice.getConstructor().newInstance(); + runDownSample.invoke(object); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } catch (InstantiationException e) { + e.printStackTrace(); + } catch (InvocationTargetException e) { + e.printStackTrace(); + } + } + + @Test + public void clearMemory(){ + try { + Class mainAbilitySlice = Class.forName("com.glidebitmappoolsample.slice.MainAbilitySlice"); + Method clearMemory = mainAbilitySlice.getMethod("clearMemory"); + Object object = mainAbilitySlice.getConstructor().newInstance(); + clearMemory.invoke(object); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } catch (InstantiationException e) { + e.printStackTrace(); + } catch (InvocationTargetException e) { + e.printStackTrace(); + } + } + + +} \ No newline at end of file -- Gitee