1.update OAT and add .eslintignore file

Signed-off-by: zhoulisheng1 <zhoulisheng1@huawei.com>
This commit is contained in:
zhoulisheng1 2023-04-07 14:24:26 +08:00
parent bb700b42f4
commit 69e8551d60
24 changed files with 685 additions and 159 deletions

2
.eslintignore Normal file
View File

@ -0,0 +1,2 @@
imageknife/src/main/ets/components/3rd_party/**/*
hvigor/hvigor-wrapper.js

21
OAT.xml
View File

@ -3,29 +3,25 @@
<oatconfig>
<filefilterlist>
<filefilter name="copyrightPolicyFilter" desc="Filters for compatibilitylicense header policies">
<filteritem type="filename" name="hvigorfile.js" desc="hvigor构建脚本DevEco Studio自动生成不手动修改"/>
<filteritem type="filename" name="hvigorfile.*" desc="hvigor配置文件DevEco Studio自动生成不手动修改"/>
<filteritem type="filename" name="*.json5" desc="hvigor配置文件DevEco Studio自动生成不手动修改"/>
<filteritem type="filepath" name="imageknife/src/main/ets/components/imageknife/pngj/UPNG.js" desc="使用开源库UPNG,使用其默认版权头,无需修改"/>
<filteritem type="filepath" name="imageknife/src/main/ets/components/imageknife/utils/gif/parse/lzw.js" desc="使用开源库gifuct-js,使用其默认版权头,无需修改"/>
<filteritem type="filename" name="LICENSE" desc="版权文件,不添加版权头"/>
<filteritem type="filename" name="NOTICE" desc="NOTICE文件不添加版权头"/>
<filteritem type="filename" name="hvigorw.bat" desc="hvigorw配置文件DevEco Studio自动生成不手动修改"/>
<filteritem type="filename" name="hvigorw" desc="hvigorw配置文件DevEco Studio自动生成不手动修改"/>
<filteritem type="filename" name="hvigorw.bat" desc="hvigorw配置文件DevEco Studio自动生成不手动修改"/>
<filteritem type="filename" name="hvigor-wrapper.js" desc="hvigorw配置文件DevEco Studio自动生成不手动修改"/>
<filteritem type="filepath" name="imageknife/src/main/ets/components/3rd_party/.*" desc="第三方开源软件源码,不修改版权头,以防有修改版权风险"/>
</filefilter>
<filefilter name="defaultPolicyFilter" desc="Filters for compatibilitylicense header policies">
<filteritem type="filename" name="hvigorfile.js" desc="hvigor构建脚本DevEco Studio自动生成不手动修改"/>
<filteritem type="filename" name="*.json5" desc="hvigor配置文件DevEco Studio自动生成不手动修改"/>
<filteritem type="filepath" name="imageknife/src/main/ets/components/imageknife/pngj/UPNG.js" desc="使用开源库UPNG,使用其默认版权头,无需修改"/>
<filteritem type="filepath" name="imageknife/src/main/ets/components/imageknife/utils/gif/parse/lzw.js" desc="使用开源库gifuct-js,使用其默认版权头,无需修改"/>
<filteritem type="filename" name="hvigorfile.*" desc="hvigor配置文件DevEco Studio自动生成不手动修改"/>
<filteritem type="filename" name="*.json5" desc="hvigor等配置文件DevEco Studio自动生成且不支持注释"/>
<filteritem type="filename" name="LICENSE" desc="版权文件,不添加版权头"/>
<filteritem type="filename" name="NOTICE" desc="NOTICE文件不添加版权头"/>
<filteritem type="filename" name="hvigorw.bat" desc="hvigorw配置文件DevEco Studio自动生成不手动修改"/>
<filteritem type="filename" name="hvigorw" desc="hvigorw配置文件DevEco Studio自动生成不手动修改"/>
<filteritem type="filename" name="hvigorw.bat" desc="hvigorw配置文件DevEco Studio自动生成不手动修改"/>
<filteritem type="filename" name="hvigor-wrapper.js" desc="hvigorw配置文件DevEco Studio自动生成不手动修改"/>
<filteritem type="filepath" name="imageknife/src/main/ets/components/3rd_party/.*" desc="第三方开源软件源码,不修改版权头,以防有修改版权风险"/>
</filefilter>
<filefilter name="defaultPolicyFilter" desc="Filters for copyright header policies">
</filefilter>
<filefilter name="binaryFileTypePolicyFilter" desc="Filters for binary file policies">
<filteritem type="filename" name="*.dpg" desc="dpg图片格式文件,用于展示示例"/>
<filteritem type="filename" name="*.png" desc="png图片格式文件,用于展示示例"/>
@ -35,6 +31,9 @@
<filteritem type="filename" name="*.gif" desc="gif图片格式文件,用于展示示例"/>
<filteritem type="filename" name="*.jpg" desc="jpg图片格式文件,用于展示示例"/>
<filteritem type="filename" name="*.jpeg" desc="jpeg图片格式文件,用于展示示例"/>
<filteritem type="filename" name="*.json5" desc="hvigor配置文件"/>
</filefilter>
<filefilter name="defaultFilter" desc="Files not to check">
<filteritem type="filepath" name="imageknife/src/main/ets/components/3rd_party/.*" desc="第三方开源软件源码,不修改版权头,以防有修改版权风险"/>
</filefilter>
</filefilterlist>

View File

@ -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"
}
]

View File

@ -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')

View File

@ -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'),

View File

@ -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() {
}
}

View File

@ -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() {
}
};

View File

@ -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)
})
})
}

View File

@ -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()
}

View File

@ -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 () {
})
})
}

View File

@ -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("你好! 第二条消息可以查看!")
})
})
}

View File

@ -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<string, any>(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<string, any>(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<string, any>(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<string, any>(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<string, any>(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<string, any>(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");
})
})
}

View File

@ -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()
})
})
}

View File

@ -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:")
})
})
}

View File

@ -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');
}
}

View File

@ -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() {

View File

@ -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');
}
};
}

View File

@ -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": [

View File

@ -1,7 +1,7 @@
{
"color": [
{
"name": "white",
"name": "start_window_background",
"value": "#FFFFFF"
}
]

View File

@ -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"
}
]
}

View File

@ -1,5 +1,5 @@
{
"src": [
"TestAbility/pages/index"
"testability/pages/index"
]
}

View File

@ -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"
}
}

View File

@ -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;

View File

@ -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 ====================================================================*/