From 06ab9131ed9a58fbcd04922b6ea0187fb4cf07c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=BB=E4=BC=9Fx?= Date: Wed, 24 Apr 2024 15:53:49 +0800 Subject: [PATCH] =?UTF-8?q?ImageKnife=E6=94=AF=E6=8C=81=E6=A0=B9=E6=8D=AE?= =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89key=E8=8E=B7=E5=8F=96=E5=B7=B2?= =?UTF-8?q?=E7=BC=93=E5=AD=98=E7=9A=84=E5=9B=BE=E7=89=87-=E6=96=B0?= =?UTF-8?q?=E5=A2=9Exts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 任伟x --- entry/src/ohosTest/ets/test/List.test.ets | 2 + .../ohosTest/ets/test/SendableData.test.ets | 52 +++++++++++++++++++ .../ohosTest/ets/test/requestoption.test.ets | 12 +++++ 3 files changed, 66 insertions(+) create mode 100644 entry/src/ohosTest/ets/test/SendableData.test.ets diff --git a/entry/src/ohosTest/ets/test/List.test.ets b/entry/src/ohosTest/ets/test/List.test.ets index 489b341..d0b99cf 100644 --- a/entry/src/ohosTest/ets/test/List.test.ets +++ b/entry/src/ohosTest/ets/test/List.test.ets @@ -19,6 +19,7 @@ import Transfrom from './transfrom.test' import RequestOptionTest from './requestoption.test' import ImageKnifeTest from './imageknife.test' import DiskLruCacheTest from './diskLruCache.test' +import SendableDataTest from './SendableData.test' export default function testsuite() { abilityTest() @@ -28,4 +29,5 @@ export default function testsuite() { Transfrom() RequestOptionTest() ImageKnifeTest(); + SendableDataTest(); } \ No newline at end of file diff --git a/entry/src/ohosTest/ets/test/SendableData.test.ets b/entry/src/ohosTest/ets/test/SendableData.test.ets new file mode 100644 index 0000000..e98f65d --- /dev/null +++ b/entry/src/ohosTest/ets/test/SendableData.test.ets @@ -0,0 +1,52 @@ +/* + * 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 { SendableData } from '@ohos/imageknife/src/main/ets/components/imageknife/SendableData' + +export default function SendableDataTest() { + describe('SendableDataTest', ()=> { + // 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('TestPlaceHolderCacheKey', 0, () => { + let value: string = "placeholderRegisterCacheKey"; + let data: SendableData = new SendableData(); + data.setPlaceHolderRegisterCacheKey(value); + expect(data.getPlaceHolderRegisterCacheKey()).assertEqual(value); + }) + it('TestPlaceHolderMemoryCacheKey', 1, () => { + let value: string = "placeholderRegisterMemoryCacheKey"; + let data: SendableData = new SendableData(); + data.setPlaceHolderRegisterMemoryCacheKey(value); + expect(data.getPlaceHolderRegisterMemoryCacheKey()).assertEqual(value); + }) + }) +} \ No newline at end of file diff --git a/entry/src/ohosTest/ets/test/requestoption.test.ets b/entry/src/ohosTest/ets/test/requestoption.test.ets index 52becb3..5a219e2 100644 --- a/entry/src/ohosTest/ets/test/requestoption.test.ets +++ b/entry/src/ohosTest/ets/test/requestoption.test.ets @@ -91,6 +91,18 @@ export default function RequestOptionTest() { expect(option.loadThumbnailReady).assertFalse() }) + it('TestPlaceHolder', 4, () => { + let url: string = "https://gd-hbimg.huaban.com/e0a25a7cab0d7c2431978726971d61720732728a315ae-57EskW_fw658"; + let option = new RequestOption(); + option.placeholder(url); + expect(option.placeholderSrc).assertEqual(url); + }) + it('TestFallBack', 5, () => { + let url: PixelMap | Resource = $r('app.media.icon_loading'); + let option = new RequestOption(); + option.fallback(url); + expect(JSON.stringify(option.fallbackSrc)).assertEqual(JSON.stringify(url)); + }) }) }