ImageKnife3.x分支合并master

Signed-off-by: zgf <zenggaofeng2@h-partners.com>
This commit is contained in:
zgf 2024-07-15 16:34:07 +08:00
parent 6b8151f42e
commit d7e6864a82
5 changed files with 67 additions and 158 deletions

View File

@ -53,18 +53,6 @@
]
}
]
},
{
"name": "sharedlibrary2",
"srcPath": "./sharedlibrary2",
"targets": [
{
"name": "default",
"applyToProducts": [
"default"
]
}
]
}
]
}

View File

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

View File

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