diff --git a/.eslintignore b/.eslintignore
new file mode 100644
index 0000000..6609ebd
--- /dev/null
+++ b/.eslintignore
@@ -0,0 +1,2 @@
+imageknife/src/main/ets/components/3rd_party/**/*
+hvigor/hvigor-wrapper.js
diff --git a/OAT.xml b/OAT.xml
index e7ff899..f6e8ede 100644
--- a/OAT.xml
+++ b/OAT.xml
@@ -3,29 +3,25 @@
-
+
-
-
-
+
+
-
-
-
-
+
+
-
+
+
-
-
@@ -35,8 +31,11 @@
+
+
+
-
+
\ No newline at end of file
diff --git a/README.OpenSource b/README.OpenSource
index 20e0927..83b7fef 100644
--- a/README.OpenSource
+++ b/README.OpenSource
@@ -66,6 +66,24 @@
"Owner" : "satazor",
"Upstream URL": "https://github.com/satazor/js-spark-md5",
"Description": "Lightning fast normal and incremental md5 for javascript"
+ },
+ {
+ "Name": "gifuct-js",
+ "License": "MIT",
+ "License File": "https://github.com/matt-way/gifuct-js/blob/master/LICENSE",
+ "Version Number": "1.0.0",
+ "Owner" : "matt-way",
+ "Upstream URL": "https://github.com/matt-way/gifuct-js",
+ "Description": "Fastest javascript .GIF decoder/parser"
+ },
+ {
+ "Name": "jsBinarySchemaParser",
+ "License": "MIT",
+ "License File": "https://github.com/matt-way/jsBinarySchemaParser/blob/master/LICENSE",
+ "Version Number": "v1.0.1",
+ "Owner" : "matt-way",
+ "Upstream URL": "https://github.com/matt-way/jsBinarySchemaParser",
+ "Description": "Parse binary files in javascript using clean schema objects"
}
]
\ No newline at end of file
diff --git a/entry/src/main/ets/pages/testImageKnifeOptionChangedPage.ets b/entry/src/main/ets/pages/testImageKnifeOptionChangedPage.ets
index 3ca6d1e..1e8ed32 100644
--- a/entry/src/main/ets/pages/testImageKnifeOptionChangedPage.ets
+++ b/entry/src/main/ets/pages/testImageKnifeOptionChangedPage.ets
@@ -141,7 +141,7 @@ struct TestImageKnifeOptionChangedPage {
Button('svg')
.onClick(()=>{
this.imageKnifeOption1 = {
- loadSrc: 'http://design-svc.fat.lunz.cn/StaticFiles/BP9999999772/BV9999999422/SA9999998420/30df266a-485e-411e-b178-b9fb1d8e0748.svg',
+ loadSrc: 'http://124.222.187.78/download/test.svg',
placeholderSrc: $r('app.media.icon_loading'),
errorholderSrc: $r('app.media.icon_failed')
diff --git a/entry/src/main/ets/pages/testPreloadPage.ets b/entry/src/main/ets/pages/testPreloadPage.ets
index eb8ca3d..8b88655 100644
--- a/entry/src/main/ets/pages/testPreloadPage.ets
+++ b/entry/src/main/ets/pages/testPreloadPage.ets
@@ -258,7 +258,7 @@ struct TestPreloadPage {
Button('预加载网络资源svg')
.onClick(() => {
let request = new RequestOption();
- request.load('http://design-svc.fat.lunz.cn/StaticFiles/BP9999999772/BV9999999422/SA9999998420/4dc8463e-8ac6-4eb4-862c-783bf486a242.svg')
+ request.load('http://124.222.187.78/download/test.svg')
.setImageViewSize({ width: 300, height: 300 })
.addListener((err, data) => {
if (err && err.length > 0) {
@@ -276,7 +276,7 @@ struct TestPreloadPage {
Button('网络资源svg')
.onClick(() => {
this.imageKnifeOption = {
- loadSrc: 'http://design-svc.fat.lunz.cn/StaticFiles/BP9999999772/BV9999999422/SA9999998420/4dc8463e-8ac6-4eb4-862c-783bf486a242.svg',
+ loadSrc: 'http://124.222.187.78/download/test.svg',
placeholderSrc: $r('app.media.icon_loading'),
errorholderSrc: $r('app.media.icon_failed'),
diff --git a/entry/src/ohosTest/ets/Application/TestAbilityStage.ts b/entry/src/ohosTest/ets/Application/TestAbilityStage.ts
deleted file mode 100644
index 71364e9..0000000
--- a/entry/src/ohosTest/ets/Application/TestAbilityStage.ts
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright (C) 2022 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 AbilityStage from "@ohos.application.AbilityStage"
-
-export default class TestAbilityStage extends AbilityStage {
- onCreate() {
-
- }
-}
\ No newline at end of file
diff --git a/entry/src/ohosTest/ets/TestAbility/TestAbility.ts b/entry/src/ohosTest/ets/TestAbility/TestAbility.ts
deleted file mode 100644
index e525c09..0000000
--- a/entry/src/ohosTest/ets/TestAbility/TestAbility.ts
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (C) 2022 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 Ability from '@ohos.application.Ability'
-import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
-import { Hypium } from 'hypium/index'
-import testsuite from '../test/List.test'
-
-export default class TestAbility extends Ability {
- onCreate(want, launchParam) {
-
- var abilityDelegator: any
- abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
- var abilityDelegatorArguments: any
- abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
-
- Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
- }
-
- onDestroy() {
-
- }
-
- onWindowStageCreate(windowStage) {
-
- windowStage.setUIContent(this.context, 'TestAbility/pages/index', null)
-
- globalThis.abilityContext = this.context;
- }
-
- onWindowStageDestroy() {
-
- }
-
- onForeground() {
-
- }
-
- onBackground() {
-
- }
-};
\ No newline at end of file
diff --git a/entry/src/ohosTest/ets/test/Ability.test.ets b/entry/src/ohosTest/ets/test/Ability.test.ets
index 22f7b08..08d3135 100644
--- a/entry/src/ohosTest/ets/test/Ability.test.ets
+++ b/entry/src/ohosTest/ets/test/Ability.test.ets
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2022 Huawei Device Co., Ltd.
+ * Copyright (C) 2023 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
@@ -12,16 +12,39 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'hypium/index'
+import hilog from '@ohos.hilog';
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
+
export default function abilityTest() {
- describe('ActsAbilityTest', function () {
- it('assertContain',0, function () {
- console.info("it begin")
- let a = 'abc'
- let b = 'b'
- expect(a).assertContain(b)
- expect(a).assertEqual(a)
- })
+ describe('ActsAbilityTest', function () {
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
+ beforeAll(function () {
+ // Presets an action, which is performed only once before all test cases of the test suite start.
+ // This API supports only one parameter: preset action function.
})
+ beforeEach(function () {
+ // Presets an action, which is performed before each unit test case starts.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: preset action function.
+ })
+ afterEach(function () {
+ // Presets a clear action, which is performed after each unit test case ends.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: clear action function.
+ })
+ afterAll(function () {
+ // Presets a clear action, which is performed after all test cases of the test suite end.
+ // This API supports only one parameter: clear action function.
+ })
+ it('assertContain',0, function () {
+ // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
+ hilog.info(0x0000, 'testTag', '%{public}s', 'it begin');
+ let a = 'abc'
+ let b = 'b'
+ // Defines a variety of assertion methods, which are used to declare expected boolean conditions.
+ expect(a).assertContain(b)
+ expect(a).assertEqual(a)
+ })
+ })
}
\ No newline at end of file
diff --git a/entry/src/ohosTest/ets/test/List.test.ets b/entry/src/ohosTest/ets/test/List.test.ets
index d3c6829..6d232b7 100644
--- a/entry/src/ohosTest/ets/test/List.test.ets
+++ b/entry/src/ohosTest/ets/test/List.test.ets
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2022 Huawei Device Co., Ltd.
+ * Copyright (C) 2023 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
@@ -13,7 +13,15 @@
* limitations under the License.
*/
import abilityTest from './Ability.test'
+import lruCacheTest from './lrucache'
+import LogUtilTest from './logutil'
+import Transform from './transfrom'
+import RequestOptionTest from './requestoption'
export default function testsuite() {
abilityTest()
+ lruCacheTest()
+ LogUtilTest()
+ Transform()
+ RequestOptionTest()
}
\ No newline at end of file
diff --git a/entry/src/ohosTest/ets/test/imageknife.ets b/entry/src/ohosTest/ets/test/imageknife.ets
new file mode 100644
index 0000000..11527f8
--- /dev/null
+++ b/entry/src/ohosTest/ets/test/imageknife.ets
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2023 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 hilog from '@ohos.hilog';
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
+import {ImageKnife,ImageKnifeDrawFactory} from '@ohos/imageknife'
+
+export default function LogUtilTest() {
+ describe('LogUtilTest', function () {
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
+ beforeAll(function () {
+ // Presets an action, which is performed only once before all test cases of the test suite start.
+ // This API supports only one parameter: preset action function.
+ })
+ beforeEach(function () {
+ // Presets an action, which is performed before each unit test case starts.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: preset action function.
+ })
+ afterEach(function () {
+ // Presets a clear action, which is performed after each unit test case ends.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: clear action function.
+ })
+ afterAll(function () {
+ // Presets a clear action, which is performed after all test cases of the test suite end.
+ // This API supports only one parameter: clear action function.
+ })
+
+
+ it('TestGlobalImageKnife',0, function () {
+ expect(globalThis.ImageKnife).assertEqual(undefined)
+ globalThis.ImageKnife = ImageKnife.with(getContext())
+ expect((globalThis.ImageKnife == undefined)).assertFalse()
+ })
+
+
+ it('TestGlobalDefaultLifeCycle',1, function () {
+ globalThis.ImageKnife = ImageKnife.with(getContext())
+ globalThis.ImageKnife.setDefaultLifeCycle(ImageKnifeDrawFactory.createProgressLifeCycle("#10a5ff", 0.5))
+ let globalLifeCycle = globalThis.ImageKnife.getDefaultLifeCycle();
+ expect(globalLifeCycle == undefined).assertFalse();
+ })
+
+ it('TestGlobalCacheKey',2, function () {
+
+ })
+
+
+
+
+
+ })
+}
\ No newline at end of file
diff --git a/entry/src/ohosTest/ets/test/logutil.ets b/entry/src/ohosTest/ets/test/logutil.ets
new file mode 100644
index 0000000..c6c600c
--- /dev/null
+++ b/entry/src/ohosTest/ets/test/logutil.ets
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2023 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 hilog from '@ohos.hilog';
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
+import {LogUtil} from '@ohos/imageknife'
+
+export default function LogUtilTest() {
+ describe('LogUtilTest', function () {
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
+ beforeAll(function () {
+ // Presets an action, which is performed only once before all test cases of the test suite start.
+ // This API supports only one parameter: preset action function.
+ })
+ beforeEach(function () {
+ // Presets an action, which is performed before each unit test case starts.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: preset action function.
+ })
+ afterEach(function () {
+ // Presets a clear action, which is performed after each unit test case ends.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: clear action function.
+ })
+ afterAll(function () {
+ // Presets a clear action, which is performed after all test cases of the test suite end.
+ // This API supports only one parameter: clear action function.
+ })
+ it('TestLogUtilLevel',0, function () {
+
+ console.log("tag:LogUtil LogUtil.mLogLevel="+LogUtil.mLogLevel);
+ LogUtil.mLogLevel = LogUtil.OFF;
+ expect(LogUtil.mLogLevel).assertEqual(LogUtil.OFF);
+
+ LogUtil.debug("你好! 第一条消息看不到!")
+ LogUtil.mLogLevel = LogUtil.DEBUG;
+ expect(LogUtil.mLogLevel).assertEqual(LogUtil.DEBUG)
+ LogUtil.debug("你好! 第二条消息可以查看!")
+ })
+ })
+}
\ No newline at end of file
diff --git a/entry/src/ohosTest/ets/test/lrucache.ets b/entry/src/ohosTest/ets/test/lrucache.ets
new file mode 100644
index 0000000..38f68f9
--- /dev/null
+++ b/entry/src/ohosTest/ets/test/lrucache.ets
@@ -0,0 +1,132 @@
+/*
+ * Copyright (C) 2023 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 hilog from '@ohos.hilog';
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
+import {LruCache} from '@ohos/imageknife' // DiskLruCache用例由DiskLruCache三方库提供
+
+export default function lruCacheTest() {
+ describe('lruCacheTest', function () {
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
+ beforeAll(function () {
+ // Presets an action, which is performed only once before all test cases of the test suite start.
+ // This API supports only one parameter: preset action function.
+ })
+ beforeEach(function () {
+ // Presets an action, which is performed before each unit test case starts.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: preset action function.
+ })
+ afterEach(function () {
+ // Presets a clear action, which is performed after each unit test case ends.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: clear action function.
+ })
+ afterAll(function () {
+ // Presets a clear action, which is performed after all test cases of the test suite end.
+ // This API supports only one parameter: clear action function.
+ })
+ it('testLruCacheSize',0, function () {
+ // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
+ let memoryCache = new LruCache(100);
+ expect(memoryCache.size).assertEqual(0);
+ expect(memoryCache.maxsize).assertEqual(100)
+ })
+ it('testLruCachePut',1, function () {
+ // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
+ let memoryCache = new LruCache(5);
+ memoryCache.put("1","1");
+ memoryCache.put("2","2");
+ memoryCache.put("3","3");
+ memoryCache.put("4","4");
+ memoryCache.put("5","5");
+ memoryCache.put("6","6");
+
+ expect(memoryCache.maxsize).assertEqual(5)
+ let result = memoryCache.get("1")
+ expect(result).assertEqual(undefined)
+ })
+ it('testLruCacheGet',2, function () {
+ // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
+ let memoryCache = new LruCache(5);
+ memoryCache.put("1","1");
+ memoryCache.put("2","2");
+ memoryCache.put("3","3");
+ memoryCache.put("4","4");
+ memoryCache.put("5","5");
+ memoryCache.put("6","6");
+
+ expect(memoryCache.maxsize).assertEqual(5)
+ let result = memoryCache.get("2")
+ expect(result).assertEqual("2")
+ })
+ it('testLruCacheAlgorithm',3, function () {
+ // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
+ let memoryCache = new LruCache(5);
+ memoryCache.put("1","1");
+ memoryCache.put("2","2");
+ memoryCache.put("3","3");
+ memoryCache.put("4","4");
+ memoryCache.put("5","5");
+
+ memoryCache.get("1");
+ memoryCache.get("2");
+
+ memoryCache.foreachLruCache(function (value, key, index) {
+ if(index == 0){
+ expect(key).assertEqual("2")
+ expect(value).assertEqual("2")
+ }
+ })
+ })
+ it('testLruCacheRemove',4, function () {
+ // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
+ let memoryCache = new LruCache(5);
+ memoryCache.put("1","1");
+ memoryCache.put("2","2");
+ memoryCache.put("3","3");
+ memoryCache.put("4","4");
+ memoryCache.put("5","5");
+
+ memoryCache.get("1");
+ memoryCache.get("2");
+
+ memoryCache.remove("2");
+
+ memoryCache.foreachLruCache(function (value, key, index) {
+ if(index == 0){
+ expect(key).assertEqual("1")
+ expect(value).assertEqual("1")
+ }
+ })
+ })
+ it('testLruCacheResize',5, function () {
+ // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
+ let memoryCache = new LruCache(5);
+ memoryCache.put("1","1");
+ memoryCache.put("2","2");
+ memoryCache.put("3","3");
+ memoryCache.put("4","4");
+ memoryCache.put("5","5");
+
+ memoryCache.resize(4);
+
+ let result1 = memoryCache.get("1");
+ expect(result1).assertEqual(undefined);
+ let result2 = memoryCache.get("2");
+ expect(result2).assertEqual("2");
+
+ })
+ })
+}
\ No newline at end of file
diff --git a/entry/src/ohosTest/ets/test/requestoption.ets b/entry/src/ohosTest/ets/test/requestoption.ets
new file mode 100644
index 0000000..9162cec
--- /dev/null
+++ b/entry/src/ohosTest/ets/test/requestoption.ets
@@ -0,0 +1,75 @@
+
+/*
+ * Copyright (C) 2023 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 hilog from '@ohos.hilog';
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
+import {RequestOption} from '@ohos/imageknife'
+
+export default function RequestOptionTest() {
+ describe('RequestOptionTest', function () {
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
+ beforeAll(function () {
+ // Presets an action, which is performed only once before all test cases of the test suite start.
+ // This API supports only one parameter: preset action function.
+ })
+ beforeEach(function () {
+ // Presets an action, which is performed before each unit test case starts.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: preset action function.
+ })
+ afterEach(function () {
+ // Presets a clear action, which is performed after each unit test case ends.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: clear action function.
+ })
+ afterAll(function () {
+ // Presets a clear action, which is performed after all test cases of the test suite end.
+ // This API supports only one parameter: clear action function.
+ })
+ it('TestRequestOption',0, function () {
+ let option = new RequestOption();
+ expect(option.requestListeners.length == 0).assertTrue()
+ })
+ it('TestConfigLoadSrc',1, function () {
+ let option = new RequestOption();
+ expect(option.loadSrc).assertEqual(undefined)
+ option.loadSrc = $r('app.media.icon')
+ expect(JSON.stringify(option.loadSrc)).assertEqual(JSON.stringify($r('app.media.icon')))
+ })
+ it('TestConfigViewSize',2, function () {
+ let option = new RequestOption();
+ option.loadSrc = $r('app.media.icon')
+ option.setImageViewSize({width:100,height:100})
+ expect(JSON.stringify(option.size)).assertEqual(JSON.stringify({width:100,height:100}))
+ })
+ it('TestNormalConfigInfo',3, function () {
+ let option = new RequestOption();
+ expect(option.strategy.getName()).assertEqual('AUTOMATIC')
+
+ expect(option.dontAnimateFlag).assertFail()
+
+ expect(option.onlyRetrieveFromCache).assertFail()
+
+ expect(option.isCacheable).assertTrue()
+
+ expect(option.gpuEnabled).assertFail()
+ expect(option.loadMainReady).assertFail()
+ expect(option.loadErrorReady).assertFail()
+ expect(option.loadRetryReady).assertFail()
+ expect(option.loadThumbnailReady).assertFail()
+
+ })
+ })
+}
\ No newline at end of file
diff --git a/entry/src/ohosTest/ets/test/transfrom.ets b/entry/src/ohosTest/ets/test/transfrom.ets
new file mode 100644
index 0000000..5705c25
--- /dev/null
+++ b/entry/src/ohosTest/ets/test/transfrom.ets
@@ -0,0 +1,160 @@
+/*
+ * Copyright (C) 2023 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 hilog from '@ohos.hilog';
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
+import {
+ BlurTransformation,
+ BrightnessFilterTransformation,
+ ContrastFilterTransformation,
+ CropCircleTransformation,
+ CropCircleWithBorderTransformation,
+ CropSquareTransformation,
+ CropTransformation,
+ CropType,
+ GrayscaleTransformation,
+ InvertFilterTransformation,
+ PixelationFilterTransformation,
+ RotateImageTransformation,
+ RoundedCornersTransformation,
+ SepiaFilterTransformation,
+ SketchFilterTransformation,
+ MaskTransformation,
+ SwirlFilterTransformation,
+ KuwaharaFilterTransform,
+ ToonFilterTransform,
+ VignetteFilterTransform,
+
+} from '@ohos/imageknife'
+
+export default function Transform() {
+ describe('Transform', function () {
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
+ beforeAll(function () {
+ // Presets an action, which is performed only once before all test cases of the test suite start.
+ // This API supports only one parameter: preset action function.
+ })
+ beforeEach(function () {
+ // Presets an action, which is performed before each unit test case starts.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: preset action function.
+ })
+ afterEach(function () {
+ // Presets a clear action, which is performed after each unit test case ends.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: clear action function.
+ })
+ afterAll(function () {
+ // Presets a clear action, which is performed after all test cases of the test suite end.
+ // This API supports only one parameter: clear action function.
+ })
+ it('TestBlurTransformation', 0, function () {
+ let blur = new BlurTransformation(15);
+ expect(blur.getName()).assertEqual('BlurTransformation _mRadius:15')
+ })
+ it('TestBrightnessFilterTransformation', 1, function () {
+ let bright = new BrightnessFilterTransformation(20);
+ expect(bright.getName()).assertEqual("BrightnessFilterTransformation:20")
+ })
+ it('TestContrastFilterTransformation', 2, function () {
+ let constrast = new ContrastFilterTransformation(30);
+ expect(constrast.getName()).assertEqual("ContrastFilterTransformation:30")
+ })
+ it('TestCropCircleTransformation', 3, function () {
+ let cropCircle = new CropCircleTransformation();
+ expect(cropCircle.getName()).assertContain("CropCircleTransformation")
+ expect(cropCircle.getName()).assertContain(";mCenterX:")
+ expect(cropCircle.getName()).assertContain(";mCenterY:")
+ expect(cropCircle.getName()).assertContain(";mRadius:")
+ })
+ it('TestCropCircleWithBorderTransformation', 4, function () {
+ let CropCircleWithBorder = new CropCircleWithBorderTransformation(10,{r_color:100,g_color:100,b_color:100 });
+ expect(CropCircleWithBorder.getName()).assertContain("CropCircleTransformation")
+ expect(CropCircleWithBorder.getName()).assertContain(";mCenterX:")
+ expect(CropCircleWithBorder.getName()).assertContain(";mCenterY:")
+ expect(CropCircleWithBorder.getName()).assertContain(";mRadius:")
+ expect(CropCircleWithBorder.getName()).assertContain(";mBorderSize:")
+ expect(CropCircleWithBorder.getName()).assertContain(";mRColor:")
+ expect(CropCircleWithBorder.getName()).assertContain(";mGColor:")
+ expect(CropCircleWithBorder.getName()).assertContain(";mBColor:")
+ })
+ it('TestCropSquareTransformation', 5, function () {
+ let CropSquare = new CropSquareTransformation();
+ expect(CropSquare.getName()).assertContain("CropSquareTransformation")
+ })
+ it('TestCropTransformation', 6, function () {
+ let crop = new CropTransformation(10,10,CropType.CENTER);
+ expect(crop.getName()).assertContain("CropCircleTransformation"+ ";mWidth:10" + ";mHeight:10" + ";mCropType:1" )
+ })
+ it('TestGrayscaleTransformation', 7, function () {
+ let grayscale = new GrayscaleTransformation();
+ expect(grayscale.getName()).assertContain("GrayscaleTransformation" )
+ })
+ it('TestInvertFilterTransformation', 8, function () {
+ let invert = new InvertFilterTransformation();
+ expect(invert.getName()).assertContain("InvertFilterTransformation" )
+ })
+ it('TestPixelationFilterTransformation', 9, function () {
+ let pixelation = new PixelationFilterTransformation();
+ expect(pixelation.getName()).assertContain("PixelationFilterTransformation" )
+ })
+ it('TestRotateImageTransformation', 10, function () {
+ let rotateImage = new RotateImageTransformation(180);
+ expect(rotateImage.getName()).assertContain("RotateImageTransformation" + ";degreesToRotate:180")
+ })
+ it('TestRoundedCornersTransformation', 11, function () {
+ let roundConer = new RoundedCornersTransformation({top_left:5,bottom_left:5,top_right:5,bottom_right:5});
+ expect(roundConer.getName()).assertContain("RoundedCornersTransformation" + ";mTop_left:" + 5
+ + ";mTop_right:" + 5
+ + ";mBottom_left:" + 5
+ + ";mBottom_right:" + 5)
+ })
+ it('TestRoundedCornersTransformation', 12, function () {
+ let speia = new SepiaFilterTransformation();
+ expect(speia.getName()).assertContain("SepiaFilterTransformation")
+ })
+ it('TestSepiaFilterTransformation', 13, function () {
+ let speia = new SepiaFilterTransformation();
+ expect(speia.getName()).assertContain("SepiaFilterTransformation")
+ })
+ it('TestSketchFilterTransformation', 13, function () {
+ let Sketch = new SketchFilterTransformation();
+ expect(Sketch.getName()).assertContain("SketchFilterTransformation")
+ })
+ it('TestMaskTransformation', 14, function () {
+ let mask = new MaskTransformation($r('app.media.icon'));
+ expect(mask.getName()).assertContain("MaskTransformation")
+ })
+ it('TestSwirlFilterTransformation', 15, function () {
+ let swirl = new SwirlFilterTransformation(10,180,[10,10]);
+ expect(swirl.getName()).assertContain("SwirlFilterTransformation")
+ })
+ it('TestKuwaharaFilterTransform', 16, function () {
+ let kuwahara = new KuwaharaFilterTransform(10);
+ expect(kuwahara.getName()).assertContain("KuwaharaFilterTransform _mRadius:10")
+ })
+ it('TestToonFilterTransform', 17, function () {
+ let toon = new ToonFilterTransform(10);
+ expect(toon.getName()).assertContain("ToonFilterTransform threshold:")
+ expect(toon.getName()).assertContain(";quantizationLevels:")
+ })
+ it('TestKuwaharaFilterTransform', 18, function () {
+ let vignette = new VignetteFilterTransform([0.5, 0.5],[0.0, 0.0, 0.0],[0.3, 0.75]);
+ expect(vignette.getName()).assertContain("VignetteFilterTransform centerPoint:")
+ expect(vignette.getName()).assertContain(";vignetteColor:")
+ expect(vignette.getName()).assertContain(";vignetteSpace:")
+ })
+
+ })
+}
\ No newline at end of file
diff --git a/entry/src/ohosTest/ets/testability/TestAbility.ets b/entry/src/ohosTest/ets/testability/TestAbility.ets
new file mode 100644
index 0000000..5521feb
--- /dev/null
+++ b/entry/src/ohosTest/ets/testability/TestAbility.ets
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2023 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 UIAbility from '@ohos.app.ability.UIAbility';
+import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
+import hilog from '@ohos.hilog';
+import { Hypium } from '@ohos/hypium';
+import testsuite from '../test/List.test';
+import window from '@ohos.window';
+
+export default class TestAbility extends UIAbility {
+ onCreate(want, launchParam) {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onCreate');
+ hilog.info(0x0000, 'testTag', '%{public}s', 'want param:' + JSON.stringify(want) ?? '');
+ hilog.info(0x0000, 'testTag', '%{public}s', 'launchParam:'+ JSON.stringify(launchParam) ?? '');
+ var abilityDelegator: any
+ abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
+ var abilityDelegatorArguments: any
+ abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
+ hilog.info(0x0000, 'testTag', '%{public}s', 'start run testcase!!!');
+ Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
+ }
+
+ onDestroy() {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onDestroy');
+ }
+
+ onWindowStageCreate(windowStage: window.WindowStage) {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageCreate');
+ windowStage.loadContent('testability/pages/Index', (err, data) => {
+ if (err.code) {
+ hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
+ return;
+ }
+ hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s',
+ JSON.stringify(data) ?? '');
+ });
+ }
+
+ onWindowStageDestroy() {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageDestroy');
+ }
+
+ onForeground() {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onForeground');
+ }
+
+ onBackground() {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onBackground');
+ }
+}
\ No newline at end of file
diff --git a/entry/src/ohosTest/ets/TestAbility/pages/index.ets b/entry/src/ohosTest/ets/testability/pages/Index.ets
similarity index 88%
rename from entry/src/ohosTest/ets/TestAbility/pages/index.ets
rename to entry/src/ohosTest/ets/testability/pages/Index.ets
index cc488e6..19ddc97 100644
--- a/entry/src/ohosTest/ets/TestAbility/pages/index.ets
+++ b/entry/src/ohosTest/ets/testability/pages/Index.ets
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2022 Huawei Device Co., Ltd.
+ * Copyright (C) 2023 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
@@ -12,14 +12,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import router from '@ohos.router';
+import hilog from '@ohos.hilog';
@Entry
@Component
struct Index {
+
aboutToAppear() {
- console.info('TestAbility index aboutToAppear')
+ hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility index aboutToAppear');
}
+
@State message: string = 'Hello World'
build() {
Row() {
diff --git a/entry/src/ohosTest/ets/TestRunner/OpenHarmonyTestRunner.ts b/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts
similarity index 56%
rename from entry/src/ohosTest/ets/TestRunner/OpenHarmonyTestRunner.ts
rename to entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts
index 22f1da4..063887c 100644
--- a/entry/src/ohosTest/ets/TestRunner/OpenHarmonyTestRunner.ts
+++ b/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2022 Huawei Device Co., Ltd.
+ * Copyright (C) 2023 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
@@ -12,32 +12,19 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import TestRunner from '@ohos.application.testRunner'
-import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
+import hilog from '@ohos.hilog';
+import TestRunner from '@ohos.application.testRunner';
+import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
var abilityDelegator = undefined
var abilityDelegatorArguments = undefined
-function translateParamsToString(parameters) {
- const keySet = new Set([
- '-s class', '-s notClass', '-s suite', '-s it',
- '-s level', '-s testType', '-s size', '-s timeout'
- ])
- let targetParams = '';
- for (const key in parameters) {
- if (keySet.has(key)) {
- targetParams = `${targetParams} ${key} ${parameters[key]}`
- }
- }
- return targetParams.trim()
-}
-
async function onAbilityCreateCallback() {
-
+ hilog.info(0x0000, 'testTag', '%{public}s', 'onAbilityCreateCallback');
}
async function addAbilityMonitorCallback(err: any) {
-
+ hilog.info(0x0000, 'testTag', 'addAbilityMonitorCallback : %{public}s', JSON.stringify(err) ?? '');
}
export default class OpenHarmonyTestRunner implements TestRunner {
@@ -45,11 +32,11 @@ export default class OpenHarmonyTestRunner implements TestRunner {
}
onPrepare() {
-
+ hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner OnPrepare ');
}
async onRun() {
-
+ hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun run');
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var testAbilityName = abilityDelegatorArguments.bundleName + '.TestAbility'
@@ -59,14 +46,18 @@ export default class OpenHarmonyTestRunner implements TestRunner {
};
abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback)
var cmd = 'aa start -d 0 -a TestAbility' + ' -b ' + abilityDelegatorArguments.bundleName
- cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters)
-
+ var debug = abilityDelegatorArguments.parameters['-D']
+ if (debug == 'true')
+ {
+ cmd += ' -D'
+ }
+ hilog.info(0x0000, 'testTag', 'cmd : %{public}s', cmd);
abilityDelegator.executeShellCommand(cmd,
(err: any, d: any) => {
-
-
-
+ hilog.info(0x0000, 'testTag', 'executeShellCommand : err : %{public}s', JSON.stringify(err) ?? '');
+ hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', d.stdResult ?? '');
+ hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', d.exitCode ?? '');
})
-
+ hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun end');
}
-};
\ No newline at end of file
+}
\ No newline at end of file
diff --git a/entry/src/ohosTest/module.json5 b/entry/src/ohosTest/module.json5
index 4cf8a1f..cf29076 100644
--- a/entry/src/ohosTest/module.json5
+++ b/entry/src/ohosTest/module.json5
@@ -2,25 +2,29 @@
"module": {
"name": "entry_test",
"type": "feature",
- "srcEntrance": "./ets/TestAbility/TestAbility.ts",
- "description": "$string:entry_test_desc",
+ "srcEntrance": "./ets/testability/TestAbility.ets",
+ "description": "$string:module_test_desc",
"mainElement": "TestAbility",
- "deviceTypes": [
- "default",
- "tablet"
- ],
+ "deviceTypes": ["default"],
"deliveryWithInstall": true,
"installationFree": false,
"pages": "$profile:test_pages",
- "uiSyntax": "ets",
+ "metadata": [
+ {
+ "name": "ArkTSPartialUpdate",
+ "value": "true"
+ }
+ ],
"abilities": [
{
"name": "TestAbility",
- "srcEntrance": "./ets/TestAbility/TestAbility.ts",
+ "srcEntry": "./ets/testability/TestAbility.ets",
"description": "$string:TestAbility_desc",
"icon": "$media:icon",
"label": "$string:TestAbility_label",
- "visible": true,
+ "exported": true,
+ "startWindowIcon": "$media:icon",
+ "startWindowBackground": "$color:start_window_background",
"skills": [
{
"actions": [
diff --git a/entry/src/ohosTest/resources/base/element/color.json b/entry/src/ohosTest/resources/base/element/color.json
index 1bbc9aa..3c71296 100644
--- a/entry/src/ohosTest/resources/base/element/color.json
+++ b/entry/src/ohosTest/resources/base/element/color.json
@@ -1,7 +1,7 @@
{
"color": [
{
- "name": "white",
+ "name": "start_window_background",
"value": "#FFFFFF"
}
]
diff --git a/entry/src/ohosTest/resources/base/element/string.json b/entry/src/ohosTest/resources/base/element/string.json
index 8407800..65d8fa5 100644
--- a/entry/src/ohosTest/resources/base/element/string.json
+++ b/entry/src/ohosTest/resources/base/element/string.json
@@ -1,16 +1,16 @@
{
"string": [
{
- "name": "entry_test_desc",
- "value": "i am an entry for tv"
+ "name": "module_test_desc",
+ "value": "test ability description"
},
{
"name": "TestAbility_desc",
- "value": "the tv entry test ability"
+ "value": "the test ability"
},
{
"name": "TestAbility_label",
- "value": "tvBase"
+ "value": "test label"
}
]
}
\ No newline at end of file
diff --git a/entry/src/ohosTest/resources/base/profile/test_pages.json b/entry/src/ohosTest/resources/base/profile/test_pages.json
index fcef82b..2d90c65 100644
--- a/entry/src/ohosTest/resources/base/profile/test_pages.json
+++ b/entry/src/ohosTest/resources/base/profile/test_pages.json
@@ -1,5 +1,5 @@
{
"src": [
- "TestAbility/pages/index"
+ "testability/pages/index"
]
}
diff --git a/hvigor/hvigor-config.json5 b/hvigor/hvigor-config.json5
index 6ab1d01..ff68812 100644
--- a/hvigor/hvigor-config.json5
+++ b/hvigor/hvigor-config.json5
@@ -1,6 +1,6 @@
{
- "hvigorVersion": "2.0.0-s",
+ "hvigorVersion": "2.0.0",
"dependencies": {
- "@ohos/hvigor-ohos-plugin": "2.0.0-s"
+ "@ohos/hvigor-ohos-plugin": "2.0.0"
}
-}
\ No newline at end of file
+}
diff --git a/imageknife/src/main/ets/components/3rd_party/pako/lib/inflate.js b/imageknife/src/main/ets/components/3rd_party/pako/lib/inflate.js
index e1764bb..3266896 100644
--- a/imageknife/src/main/ets/components/3rd_party/pako/lib/inflate.js
+++ b/imageknife/src/main/ets/components/3rd_party/pako/lib/inflate.js
@@ -2,11 +2,11 @@
import {inflateReset,inflateInit2,inflate as inflate1,inflateEnd,inflateGetHeader,inflateSetDictionary,inflateInfo } from './zlib/inflate'
-const utils = require('./utils/common');
-const strings = require('./utils/strings');
-const msg = require('./zlib/messages');
-const {ZStream} = require('./zlib/zstream');
-const {GZheader} = require('./zlib/gzheader');
+import {assign,flattenChunks} from './utils/common';
+import {string2buf,buf2string,utf8border} from './utils/strings';
+import msg from './zlib/messages';
+import {ZStream} from './zlib/zstream';
+import {GZheader} from './zlib/gzheader';
const toString = Object.prototype.toString;
diff --git a/imageknife/src/main/ets/components/3rd_party/pako/lib/zlib/inflate.js b/imageknife/src/main/ets/components/3rd_party/pako/lib/zlib/inflate.js
index 0556fcf..86d5df4 100644
--- a/imageknife/src/main/ets/components/3rd_party/pako/lib/zlib/inflate.js
+++ b/imageknife/src/main/ets/components/3rd_party/pako/lib/zlib/inflate.js
@@ -30,12 +30,19 @@ const DISTS = 2;
/* Public constants ==========================================================*/
/* ===========================================================================*/
+import constants from './constants'
+var Z_FINISH = constants.Z_FINISH
+var Z_BLOCK = constants.Z_BLOCK
+var Z_TREES = constants.Z_TREES
+var Z_OK = constants.Z_OK
+var Z_STREAM_END = constants.Z_STREAM_END
+var Z_NEED_DICT = constants.Z_NEED_DICT
+var Z_STREAM_ERROR = constants.Z_STREAM_ERROR
+var Z_DATA_ERROR = constants.Z_DATA_ERROR
+var Z_MEM_ERROR = constants.Z_MEM_ERROR
+var Z_BUF_ERROR = constants.Z_BUF_ERROR
+var Z_DEFLATED = constants.Z_DEFLATED
-const {
- Z_FINISH, Z_BLOCK, Z_TREES,
- Z_OK, Z_STREAM_END, Z_NEED_DICT, Z_STREAM_ERROR, Z_DATA_ERROR, Z_MEM_ERROR, Z_BUF_ERROR,
- Z_DEFLATED
-} = require('./constants');
/* STATES ====================================================================*/