From d7e6864a8232e4151e8491d8877e37415edb322d Mon Sep 17 00:00:00 2001 From: zgf Date: Mon, 15 Jul 2024 16:34:07 +0800 Subject: [PATCH] =?UTF-8?q?ImageKnife3.x=E5=88=86=E6=94=AF=E5=90=88?= =?UTF-8?q?=E5=B9=B6master?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zgf --- build-profile.json5 | 12 -- entry/src/main/ets/pages/index.ets | 146 ------------------ .../src/ohosTest/ets/test/imageknife.test.ets | 67 ++++++++ library/src/main/ets/SendableData.ets | 0 sharedlibrary/src/main/ets/Index.ets | 0 5 files changed, 67 insertions(+), 158 deletions(-) delete mode 100644 entry/src/main/ets/pages/index.ets delete mode 100644 library/src/main/ets/SendableData.ets delete mode 100644 sharedlibrary/src/main/ets/Index.ets diff --git a/build-profile.json5 b/build-profile.json5 index d198844..415c514 100644 --- a/build-profile.json5 +++ b/build-profile.json5 @@ -53,18 +53,6 @@ ] } ] - }, - { - "name": "sharedlibrary2", - "srcPath": "./sharedlibrary2", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] } ] } \ No newline at end of file diff --git a/entry/src/main/ets/pages/index.ets b/entry/src/main/ets/pages/index.ets deleted file mode 100644 index 2053dc2..0000000 --- a/entry/src/main/ets/pages/index.ets +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Copyright (C) 2024 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 router from '@system.router'; - -@Entry -@Component -struct Index { - - - aboutToAppear(): void { - - } - - build() { - Scroll(){ - Column() { - Button("测试加载多张相同图片").onClick(()=>{ - router.push({ - uri: 'pages/TestCommonImage', - - }); - }) - Button("测试HSP场景预加载").margin({top:10}).onClick(()=>{ - router.push({ - uri: 'pages/TestHspPreLoadImage', - - }); - }) - Button("单个图片使用").margin({top:10}).onClick(()=>{ - router.push({ - uri: 'pages/SingleImage', - - }); - }) - Button("多图 + LazyForEach").margin({top:10}).onClick(()=>{ - router.push({ - uri: 'pages/ManyPhotoShowPage', - - }); - }) - Button("多图 + reuse + LazyForeach").margin({top:10}).onClick(()=>{ - router.push({ - uri: 'pages/UserPage', - - }); - }) - Button("长图显示").margin({top:10}).onClick(()=>{ - router.push({ - uri: 'pages/LongImagePage', - - }); - }) - Button("缩放图片").margin({top:10}).onClick(()=>{ - router.push({ - uri: 'pages/TransformPage', - - }); - }) - Button("消息+List").margin({top:10}).onClick(()=>{ - router.push({ - uri: 'pages/TestImageFlash', - - }); - }) - Button("自定义缓存key").margin({top:10}).onClick(()=>{ - router.push({ - uri: 'pages/SignatureTestPage', - - }); - }) - Button("预加载图片到文件缓存").margin({top:10}).onClick(()=>{ - router.push({ - uri: 'pages/TestPrefetchToFileCache', - - }); - }) - Button("从缓存获取图片显示").margin({top:10}).onClick(()=>{ - router.push({ - uri: 'pages/TestIsUrlExist', - - }); - }) - Button("测试单个请求头").margin({top:10}).onClick(()=>{ - router.push({ - uri: 'pages/TestHeader', - - }); - }) - Button("测试写入缓存策略").margin({top:10}).onClick(()=>{ - router.push({ - uri: 'pages/TestWriteCacheStage', - - }); - }) - Button("图片变换").margin({top:10}).onClick(()=>{ - router.push({ - uri: 'pages/ImageTransformation', - - }); - - }) - - Button("不同的ObjectFit").margin({top:10}).onClick(()=>{ - router.push({ - uri: 'pages/ObjectFitPage', - - }); - - }) - - Button('测试图片加载成功/失败事件').margin({top:10}).onClick(()=>{ - router.push({ - uri: 'pages/LoadStatePage', - }) - }) - - Button('测试移除图片缓存接口').margin({top:10}).onClick(()=>{ - router.push({ - uri: 'pages/TestRemoveCache', - }); - }) - - Button("测试媒体url").margin({top:10}).onClick(()=>{ - router.push({ - uri: 'pages/dataShareUriLoadPage', - - }); - }) - - } - } .width('100%') - .height('100%') - } -} \ No newline at end of file diff --git a/entry/src/ohosTest/ets/test/imageknife.test.ets b/entry/src/ohosTest/ets/test/imageknife.test.ets index e69de29..89a2578 100644 --- a/entry/src/ohosTest/ets/test/imageknife.test.ets +++ b/entry/src/ohosTest/ets/test/imageknife.test.ets @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2024 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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; +import { ImageKnife, ImageKnifeOption } from '@ohos/imageknife'; +import { ImageKnifeRequestSource } from '@ohos/imageknife/src/main/ets/model/ImageKnifeData'; + +export default function ImageKnifeTest() { + describe('ImageKnifeTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // 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(() => { + // 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(() => { + // 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(() => { + // 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('removeMemoryCache', 0, async () => { + let a = 'https://hbimg.huabanimg.com/95a6d37a39aa0b70d48fa18dc7df8309e2e0e8e85571e-x4hhks_fw658/format/webp'; + let option: ImageKnifeOption = { + loadSrc: 'https://hbimg.huabanimg.com/95a6d37a39aa0b70d48fa18dc7df8309e2e0e8e85571e-x4hhks_fw658/format/webp', + signature: '' + } + let key = ImageKnife.getInstance() + .getEngineKeyImpl() + .generateMemoryKey('https://hbimg.huabanimg.com/95a6d37a39aa0b70d48fa18dc7df8309e2e0e8e85571e-x4hhks_fw658/format/webp', ImageKnifeRequestSource.SRC, option) + ImageKnife.getInstance() + .removeMemoryCache(a) + expect(ImageKnife.getInstance() + .loadFromMemoryCache(key)).assertEqual(undefined) + }); + + it('removeFileCache', 0, async () => { + let a = 'https://hbimg.huabanimg.com/95a6d37a39aa0b70d48fa18dc7df8309e2e0e8e85571e-x4hhks_fw658/format/webp'; + let key = ImageKnife.getInstance() + .getEngineKeyImpl() + .generateFileKey('https://hbimg.huabanimg.com/95a6d37a39aa0b70d48fa18dc7df8309e2e0e8e85571e-x4hhks_fw658/format/webp'); + ImageKnife.getInstance() + .removeFileCache(a) + expect(ImageKnife.getInstance() + .loadFromFileCache(key)).assertEqual(undefined) + }); + }); +} diff --git a/library/src/main/ets/SendableData.ets b/library/src/main/ets/SendableData.ets deleted file mode 100644 index e69de29..0000000 diff --git a/sharedlibrary/src/main/ets/Index.ets b/sharedlibrary/src/main/ets/Index.ets deleted file mode 100644 index e69de29..0000000