From ed1fb2e35b8e781b37d698f153e94f0951d70995 Mon Sep 17 00:00:00 2001 From: lloyd <353627866@qq.com> Date: Fri, 12 Sep 2025 14:34:42 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E5=9F=BA=E4=BA=8EDataCache=E5=BA=93?= =?UTF-8?q?=E6=8F=90=E5=8D=87=E5=BA=94=E7=94=A8=E5=86=B7=E5=90=AF=E5=8A=A8?= =?UTF-8?q?=E9=80=9F=E5=BA=A6=E3=80=91=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 6 +- README_EN.md | 6 +- build-profile.json5 | 3 +- entry/obfuscation-rules.txt | 6 +- entry/src/main/ets/common/utils/Refresh.ets | 17 +- .../ohosTest/ets/test/AverageTime.test.ets | 178 ------------------ .../src/ohosTest/ets/test/DataCache.test.ets | 82 -------- entry/src/ohosTest/ets/test/Get.test.ets | 61 ------ .../ohosTest/ets/test/GetInstance.test.ets | 43 ----- entry/src/ohosTest/ets/test/GetSync.test.ets | 54 ------ entry/src/ohosTest/ets/test/List.test.ets | 37 ---- entry/src/ohosTest/ets/test/Put.test.ets | 133 ------------- .../ohosTest/ets/test/PutHasSaveTime.test.ets | 148 --------------- entry/src/ohosTest/ets/test/PutSync.test.ets | 120 ------------ .../ets/test/PutSyncHasSaveTime.test.ets | 158 ---------------- .../ets/testability/GlobalContext.ets | 41 ---- .../ohosTest/ets/testability/TestAbility.ets | 46 ----- .../ohosTest/ets/testability/pages/Index.ets | 46 ----- .../ets/testrunner/OpenHarmonyTestRunner.ts | 63 ------- entry/src/ohosTest/module.json5 | 36 ---- .../resources/base/element/color.json | 8 - .../resources/base/element/string.json | 16 -- .../ohosTest/resources/base/media/icon.png | Bin 6790 -> 0 bytes .../resources/base/profile/test_pages.json | 5 - hvigor/hvigor-config.json5 | 2 +- oh-package.json5 | 3 +- 26 files changed, 27 insertions(+), 1291 deletions(-) delete mode 100644 entry/src/ohosTest/ets/test/AverageTime.test.ets delete mode 100644 entry/src/ohosTest/ets/test/DataCache.test.ets delete mode 100644 entry/src/ohosTest/ets/test/Get.test.ets delete mode 100644 entry/src/ohosTest/ets/test/GetInstance.test.ets delete mode 100644 entry/src/ohosTest/ets/test/GetSync.test.ets delete mode 100644 entry/src/ohosTest/ets/test/List.test.ets delete mode 100644 entry/src/ohosTest/ets/test/Put.test.ets delete mode 100644 entry/src/ohosTest/ets/test/PutHasSaveTime.test.ets delete mode 100644 entry/src/ohosTest/ets/test/PutSync.test.ets delete mode 100644 entry/src/ohosTest/ets/test/PutSyncHasSaveTime.test.ets delete mode 100644 entry/src/ohosTest/ets/testability/GlobalContext.ets delete mode 100644 entry/src/ohosTest/ets/testability/TestAbility.ets delete mode 100644 entry/src/ohosTest/ets/testability/pages/Index.ets delete mode 100644 entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts delete mode 100644 entry/src/ohosTest/module.json5 delete mode 100644 entry/src/ohosTest/resources/base/element/color.json delete mode 100644 entry/src/ohosTest/resources/base/element/string.json delete mode 100644 entry/src/ohosTest/resources/base/media/icon.png delete mode 100644 entry/src/ohosTest/resources/base/profile/test_pages.json diff --git a/README.md b/README.md index ed78c37..c1ec2f2 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,6 @@ ### 约束与限制 1. 本示例仅支持标准系统上运行,支持设备:华为手机。 -2. HarmonyOS系统:HarmonyOS 5.0.0 Release及以上。 -3. DevEco Studio版本:DevEco Studio 5.0.0 Release及以上。 -4. HarmonyOS SDK版本:HarmonyOS 5.0.0 Release SDK及以上。 +2. HarmonyOS系统:HarmonyOS 5.0.5 Release及以上。 +3. DevEco Studio版本:DevEco Studio 5.0.5 Release及以上。 +4. HarmonyOS SDK版本:HarmonyOS 5.0.5 Release SDK及以上。 diff --git a/README_EN.md b/README_EN.md index 60ab11e..d868411 100644 --- a/README_EN.md +++ b/README_EN.md @@ -70,6 +70,6 @@ Use the APIs provided by `@hadss/datacache` to read and write data. The overall ### Constraints 1. The sample app is supported only on Huawei phones running the standard system. -2. The HarmonyOS version must be HarmonyOS 5.0.0 Release or later. -3. The DevEco Studio version must be DevEco Studio 5.0.0 Release or later. -4. The HarmonyOS SDK version must be HarmonyOS 5.0.0 Release or later. +2. The HarmonyOS version must be HarmonyOS 5.0.5 Release or later. +3. The DevEco Studio version must be DevEco Studio 5.0.5 Release or later. +4. The HarmonyOS SDK version must be HarmonyOS 5.0.5 Release or later. diff --git a/build-profile.json5 b/build-profile.json5 index c033ce4..b2ca56e 100644 --- a/build-profile.json5 +++ b/build-profile.json5 @@ -5,7 +5,8 @@ { "name": "default", "signingConfig": "default", - "compatibleSdkVersion": "5.0.0(12)", + "compatibleSdkVersion": "5.0.5(17)", + "targetSdkVersion": "5.0.5(17)", "runtimeOS": "HarmonyOS", } ], diff --git a/entry/obfuscation-rules.txt b/entry/obfuscation-rules.txt index 69c4d6a..fdbb5b9 100644 --- a/entry/obfuscation-rules.txt +++ b/entry/obfuscation-rules.txt @@ -15,4 +15,8 @@ # Keep options: # -keep-property-name: specifies property names that you want to keep -# -keep-global-name: specifies names that you want to keep in the global scope \ No newline at end of file +# -keep-global-name: specifies names that you want to keep in the global scope +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/entry/src/main/ets/common/utils/Refresh.ets b/entry/src/main/ets/common/utils/Refresh.ets index b51973f..06a8c35 100644 --- a/entry/src/main/ets/common/utils/Refresh.ets +++ b/entry/src/main/ets/common/utils/Refresh.ets @@ -13,6 +13,7 @@ * limitations under the License. */ +import { BusinessError } from '@kit.BasicServicesKit'; import { hilog } from '@kit.PerformanceAnalysisKit'; import { http } from '@kit.NetworkKit'; import * as Const from '../constant/CommonConstants'; @@ -39,8 +40,14 @@ export function refreshState(that: ListModel, state: number): void { } export function getUrl(context: Context): string { - const FILENAME = context.resourceManager.getStringSync($r('app.string.fileName').id); - return `https://devecostudio-drcn.op.hicloud.com/solution/v1/getSceneMockData?scene=newsData&fileName=${FILENAME}.json&`; + let filename = ''; + try { + filename = context.resourceManager.getStringSync($r('app.string.fileName').id); + } catch (error) { + let err = error as BusinessError; + hilog.error(0x0000, 'refreshing', `getStringSync failed, error code=${err.code}, message=${err.message}`); + } + return `https://devecostudio-drcn.op.hicloud.com/solution/v1/getSceneMockData?scene=newsData&fileName=${filename}.json&`; } export function refreshing(that: ListModel, url: string): Promise { @@ -57,7 +64,7 @@ export function refreshing(that: ListModel, url: string): Promise { } that.newsData = data; }).catch(() => { - hilog.info(0x0000, 'refreshing', 'http request fail'); + hilog.error(0x0000, 'refreshing', 'http request fail'); }); } @@ -79,7 +86,7 @@ export function loadMore(that: ListModel, url: string): void { } that.newsData = that.newsData.concat(data); }).catch(() => { - hilog.info(0x0000, 'loadMore', 'http request fail'); - }); + hilog.error(0x0000, 'loadMore', 'http request fail'); + }); } } \ No newline at end of file diff --git a/entry/src/ohosTest/ets/test/AverageTime.test.ets b/entry/src/ohosTest/ets/test/AverageTime.test.ets deleted file mode 100644 index 51f5f10..0000000 --- a/entry/src/ohosTest/ets/test/AverageTime.test.ets +++ /dev/null @@ -1,178 +0,0 @@ -/* - * The MIT License (MIT) - * Copyright (C) 2024 Huawei Device Co., Ltd. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - */ - -import { describe, it, expect, beforeEach } from '@ohos/hypium' -import { DataCache } from '@hadss/datacache'; -import { GlobalContext } from '../testability/GlobalContext'; - -export default function AverageTimeTest() { - - describe('AverageTimeTest', () => { - const COUNT = 2000; - const KEY = 'TEST'; - const VAL = '111'; - const TIME = 1; - let dataCache: DataCache; - - beforeEach(async () => { - const CONTEXT: Context = GlobalContext.getContext().getObject("context") as Context; - dataCache = DataCache.getInstance(CONTEXT); - await dataCache.clear(); - }) - - // get method - it('get', 0, async (done: Function) => { - dataCache.putSync(KEY, VAL); - let startTime = new Date().getTime(); - let configTest: (index: number) => void = async (index) => { - dataCache.get(KEY).then(() => { - if (index < COUNT) { - configTest(index + 1); - } else { - let endTime = new Date().getTime(); - let averageTime = (endTime - startTime) / COUNT; - expect(averageTime).assertLess(5); - done(); - } - }) - }; - configTest(0); - }) - - // put method - it('put', 1, async (done: Function) => { - let startTime = new Date().getTime(); - let configTest: (index: number) => void = async (index) => { - dataCache.put(KEY, VAL).then(() => { - if (index < COUNT) { - configTest(index + 1); - } else { - let endTime = new Date().getTime(); - let averageTime = (endTime - startTime) / COUNT; - expect(averageTime).assertLess(5); - done(); - } - }) - }; - configTest(0); - }) - - // put method - it('put has time', 2, async (done: Function) => { - let startTime = new Date().getTime(); - let configTest: (index: number) => void = async (index) => { - dataCache.put(KEY, VAL, TIME).then(() => { - if (index < COUNT) { - configTest(index + 1); - } else { - let endTime = new Date().getTime(); - let averageTime = (endTime - startTime) / COUNT; - expect(averageTime).assertLess(5); - done(); - } - }) - }; - configTest(0); - }) - - // putSync method - it('putSync', 3, () => { - let startTime = new Date().getTime(); - let configTest: (index: number) => void = async (index) => { - dataCache.putSync(KEY, VAL); - if (index < COUNT) { - configTest(index + 1); - } else { - let endTime = new Date().getTime(); - let averageTime = (endTime - startTime) / COUNT; - expect(averageTime).assertLess(5); - } - }; - configTest(0); - }) - - // putSync method - it('putSync has time', 4, () => { - let startTime = new Date().getTime(); - let configTest: (index: number) => void = async (index) => { - dataCache.putSync(KEY, VAL, TIME); - if (index < COUNT) { - configTest(index + 1); - } else { - let endTime = new Date().getTime(); - let averageTime = (endTime - startTime) / COUNT; - expect(averageTime).assertLess(5); - } - }; - configTest(0); - }) - - // getSync method - it('getSync', 5, () => { - dataCache.putSync(KEY, VAL); - let startTime = new Date().getTime(); - let configTest: (index: number) => void = async (index) => { - dataCache.getSync(KEY); - if (index < COUNT) { - configTest(index + 1); - } else { - let endTime = new Date().getTime(); - let averageTime = (endTime - startTime) / COUNT; - expect(averageTime).assertLess(5); - } - }; - configTest(0); - }) - - // delete method - it('delete', 6, async (done: Function) => { - let sum: number = 0; - let configTest = async (index: number): Promise => { - dataCache.putSync(KEY, VAL); - let startTime = new Date().getTime(); - await dataCache.delete(KEY); - let endTime = new Date().getTime(); - sum += endTime - startTime; - if (index < COUNT) { - await configTest(index + 1); - } else { - let averageTime = sum / COUNT; - expect(averageTime).assertLess(5); - done(); - } - }; - await configTest(0); - }) - - // clear method - it('clear', 7, async (done: Function) => { - let sum: number = 0; - let configTest = async (index: number): Promise => { - let startTime = new Date().getTime(); - await dataCache.clear(); - let endTime = new Date().getTime(); - sum += endTime - startTime; - if (index < COUNT) { - await configTest(index + 1); - } else { - let averageTime = sum / COUNT; - expect(averageTime).assertLess(5); - done(); - } - }; - await configTest(0); - }) - }) -} diff --git a/entry/src/ohosTest/ets/test/DataCache.test.ets b/entry/src/ohosTest/ets/test/DataCache.test.ets deleted file mode 100644 index 8f7d544..0000000 --- a/entry/src/ohosTest/ets/test/DataCache.test.ets +++ /dev/null @@ -1,82 +0,0 @@ -/* - * The MIT License (MIT) - * Copyright (C) 2024 Huawei Device Co., Ltd. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - */ - -import { describe, it, expect, beforeEach } from '@ohos/hypium' -import { DataCache } from '@hadss/datacache'; -import { BusinessError } from '@kit.BasicServicesKit'; -import { GlobalContext } from '../testability/GlobalContext'; - -export default function DataCacheTest() { - const KEY = 'instance'; - - describe('DataCacheTest', () => { - beforeEach(async () => { - const context: Context = GlobalContext.getContext().getObject("context") as Context; - const dataCache = DataCache.getInstance(context); - await dataCache.clear(); - }) - - it('delete', 0, async (done: Function) => { - const context: Context = GlobalContext.getContext().getObject("context") as Context; - const dataCache = DataCache.getInstance(context); - const data = '111'; - dataCache.putSync(KEY, data); - dataCache.delete(KEY).then(() => { - expect(dataCache.getSync('test')).assertUndefined(); - done(); - }) - }) - - it('delete when key is empty', 1, async (done: Function) => { - const context: Context = GlobalContext.getContext().getObject("context") as Context; - const dataCache = DataCache.getInstance(context); - dataCache.delete('').catch((error: BusinessError) => { - expect(error.code).assertEqual(15500000); - done(); - }) - }) - - it('delete when key is not exit', 2, async (done: Function) => { - const context: Context = GlobalContext.getContext().getObject("context") as Context; - const dataCache = DataCache.getInstance(context); - dataCache.delete(KEY).then(() => { - expect(true).assertTrue(); - done(); - }); - }) - - it('clear', 3, async (done: Function) => { - const context: Context = GlobalContext.getContext().getObject("context") as Context; - const dataCache = DataCache.getInstance(context); - const data = '111'; - dataCache.putSync('test1', data); - dataCache.putSync('test2', data); - dataCache.clear().then(() => { - expect(dataCache.getSync('test1')).assertUndefined(); - expect(dataCache.getSync('test2')).assertUndefined(); - done(); - }) - }) - - it('clear when not cache', 4, async (done: Function) => { - const context: Context = GlobalContext.getContext().getObject("context") as Context; - const dataCache = DataCache.getInstance(context); - dataCache.clear().then(() => { - expect(true).assertTrue(); - done(); - }); - }) - }) -} diff --git a/entry/src/ohosTest/ets/test/Get.test.ets b/entry/src/ohosTest/ets/test/Get.test.ets deleted file mode 100644 index a717379..0000000 --- a/entry/src/ohosTest/ets/test/Get.test.ets +++ /dev/null @@ -1,61 +0,0 @@ -/* - * The MIT License (MIT) - * Copyright (C) 2024 Huawei Device Co., Ltd. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - */ - -import { describe, it, expect, beforeEach } from '@ohos/hypium' -import { DataCache } from '@hadss/datacache'; -import { GlobalContext } from '../testability/GlobalContext'; - -export default function GetTest() { - const KEY = 'GET'; - - describe('GetTest', () => { - beforeEach(async () => { - const context: Context = GlobalContext.getContext().getObject("context") as Context; - const dataCache = DataCache.getInstance(context); - await dataCache.clear(); - }) - - it('get', 0, async (done: Function) => { - const context: Context = GlobalContext.getContext().getObject("context") as Context; - const dataCache = DataCache.getInstance(context); - const data = '111'; - dataCache.putSync(KEY, data); - dataCache.get(KEY).then((val) => { - expect(val).assertEqual(data); - done(); - }) - }) - - it('get when key is empty', 1, async (done: Function) => { - const context: Context = GlobalContext.getContext().getObject("context") as Context; - const dataCache = DataCache.getInstance(context); - try { - await dataCache.get(''); - } catch (error) { - expect(error.code).assertEqual(401); - done(); - } - }) - - it('get when key is not exit', 2, async (done: Function) => { - const context: Context = GlobalContext.getContext().getObject("context") as Context; - const dataCache = DataCache.getInstance(context); - dataCache.get(KEY).then((val) => { - expect(val).assertUndefined(); - done(); - }) - }) - }) -} diff --git a/entry/src/ohosTest/ets/test/GetInstance.test.ets b/entry/src/ohosTest/ets/test/GetInstance.test.ets deleted file mode 100644 index 298935f..0000000 --- a/entry/src/ohosTest/ets/test/GetInstance.test.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * The MIT License (MIT) - * Copyright (C) 2024 Huawei Device Co., Ltd. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - */ - -import { describe, it, expect, beforeEach } from '@ohos/hypium' -import { DataCache } from '@hadss/datacache'; -import { GlobalContext } from '../testability/GlobalContext'; - -export default function GetInstanceTest() { - - describe('GetInstanceTest', () => { - beforeEach(async () => { - const context: Context = GlobalContext.getContext().getObject("context") as Context; - const dataCache = DataCache.getInstance(context); - await dataCache.clear(); - }) - - it('getInstance method success', 0, () => { - const context: Context = GlobalContext.getContext().getObject("context") as Context; - const dataCache = DataCache.getInstance(context); - expect(dataCache instanceof DataCache).assertTrue(); - }) - - it('getInstance method when param error', 1, () => { - try { - DataCache.getInstance({} as Context); - } catch (error) { - expect(error.code).assertEqual(401); - } - }) - }) -} diff --git a/entry/src/ohosTest/ets/test/GetSync.test.ets b/entry/src/ohosTest/ets/test/GetSync.test.ets deleted file mode 100644 index 4596957..0000000 --- a/entry/src/ohosTest/ets/test/GetSync.test.ets +++ /dev/null @@ -1,54 +0,0 @@ -/* - * The MIT License (MIT) - * Copyright (C) 2024 Huawei Device Co., Ltd. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - */ - -import { describe, it, expect, beforeEach } from '@ohos/hypium' -import { DataCache } from '@hadss/datacache'; -import { GlobalContext } from '../testability/GlobalContext'; - -export default function GetSyncTest() { - const KEY = 'GetSyncTest'; - - describe('GetSyncTest', () => { - beforeEach(async () => { - const context: Context = GlobalContext.getContext().getObject("context") as Context; - const dataCache = DataCache.getInstance(context); - await dataCache.clear(); - }) - - it('getSync', 0, () => { - const context: Context = GlobalContext.getContext().getObject("context") as Context; - const dataCache = DataCache.getInstance(context); - const data = '111'; - dataCache.putSync(KEY, data); - expect(dataCache.getSync(KEY)).assertEqual(data); - }) - - it('getSync when key is empty', 1, () => { - const context: Context = GlobalContext.getContext().getObject("context") as Context; - const dataCache = DataCache.getInstance(context); - try { - dataCache.getSync(''); - } catch (error) { - expect(error.code).assertEqual(401); - } - }) - - it('getSync when key is not exit', 2, () => { - const context: Context = GlobalContext.getContext().getObject("context") as Context; - const dataCache = DataCache.getInstance(context); - expect(dataCache.getSync(KEY)).assertUndefined(); - }) - }) -} diff --git a/entry/src/ohosTest/ets/test/List.test.ets b/entry/src/ohosTest/ets/test/List.test.ets deleted file mode 100644 index e5be7c2..0000000 --- a/entry/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,37 +0,0 @@ -/* - * The MIT License (MIT) - * Copyright (C) 2024 Huawei Device Co., Ltd. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - */ -import AverageTimeTest from './AverageTime.test'; - -import DataCacheTest from './DataCache.test'; -import GetTest from './Get.test'; -import GetInstanceTest from './GetInstance.test'; -import GetSyncTest from './GetSync.test'; -import PutTest from './Put.test'; -import PutHasSaveTimeTest from './PutHasSaveTime.test'; -import PutSyncTest from './PutSync.test'; -import PutSyncHasSaveTimeTest from './PutSyncHasSaveTime.test'; - -export default function testsuite() { - GetInstanceTest(); - GetTest(); - GetSyncTest(); - PutTest(); - PutHasSaveTimeTest(); - PutSyncTest(); - PutSyncHasSaveTimeTest(); - DataCacheTest(); - AverageTimeTest(); -} - diff --git a/entry/src/ohosTest/ets/test/Put.test.ets b/entry/src/ohosTest/ets/test/Put.test.ets deleted file mode 100644 index 6926cdc..0000000 --- a/entry/src/ohosTest/ets/test/Put.test.ets +++ /dev/null @@ -1,133 +0,0 @@ -/* - * The MIT License (MIT) - * Copyright (C) 2024 Huawei Device Co., Ltd. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - */ - -import { describe, it, expect, beforeEach } from '@ohos/hypium' -import { DataCache } from '@hadss/datacache'; -import { GlobalContext, TestObjectData } from '../testability/GlobalContext'; - -export default function PutTest() { - const KEY = 'PutTest'; - - describe('PutTest', () => { - beforeEach(async () => { - const context: Context = GlobalContext.getContext().getObject("context") as Context; - const dataCache = DataCache.getInstance(context); - await dataCache.clear(); - }) - - it('put uint8array', 0, async (done: Function) => { - const context: Context = GlobalContext.getContext().getObject("context") as Context; - const dataCache = DataCache.getInstance(context); - const data = new Uint8Array(); - dataCache.put(KEY, data).then(() => { - expect(dataCache.getSync(KEY)).assertInstanceOf('Uint8Array'); - done(); - }); - }) - - it('put string', 1, async (done: Function) => { - const context: Context = GlobalContext.getContext().getObject("context") as Context; - const dataCache = DataCache.getInstance(context); - const data = '111'; - dataCache.put(KEY, data).then(() => { - expect(dataCache.getSync(KEY)).assertEqual(data); - done(); - }); - }) - - it('put boolean', 2, async (done: Function) => { - const context: Context = GlobalContext.getContext().getObject("context") as Context; - const dataCache = DataCache.getInstance(context); - const data = true; - dataCache.put(KEY, data).then(() => { - expect(dataCache.getSync(KEY)).assertEqual(data); - done(); - }); - }) - - it('put number', 3, async (done: Function) => { - const context: Context = GlobalContext.getContext().getObject("context") as Context; - const dataCache = DataCache.getInstance(context); - const data = 11; - dataCache.put(KEY, data).then(() => { - expect(dataCache.getSync(KEY)).assertEqual(data); - done(); - }); - }) - - it('put object', 4, async (done: Function) => { - const context: Context = GlobalContext.getContext().getObject("context") as Context; - const dataCache = DataCache.getInstance(context); - const data: TestObjectData = { - test: 'test' - }; - await dataCache.put(KEY, data).then(() => { - expect(dataCache.getSync(KEY)?.test).assertEqual(data.test); - done(); - }); - }) - - it('put when key is empty', 5, async (done: Function) => { - const context: Context = GlobalContext.getContext().getObject("context") as Context; - const dataCache = DataCache.getInstance(context); - const data = '111'; - try { - await dataCache.put('', data); - } catch (error) { - expect(error.code).assertEqual(15500000); - done(); - } - }) - - it('put when value is empty', 6, async (done: Function) => { - const context: Context = GlobalContext.getContext().getObject("context") as Context; - const dataCache = DataCache.getInstance(context); - const data = ''; - dataCache.put(KEY, data).then(() => { - expect(true).assertTrue(); - done(); - }); - }) - - it('put when cache is empty', 7, async (done: Function) => { - const context: Context = GlobalContext.getContext().getObject("context") as Context; - const dataCache = DataCache.getInstance(context); - const data = '111'; - await dataCache.put(KEY, data); - expect(dataCache.getSync(KEY)).assertEqual(data); - done(); - }) - - it('put when cache is not empty', 8, async (done: Function) => { - const context: Context = GlobalContext.getContext().getObject("context") as Context; - const dataCache = DataCache.getInstance(context); - dataCache.putSync('key1', '222'); - const data = '111'; - await dataCache.put(KEY, data); - expect(dataCache.getSync(KEY)).assertEqual(data); - done(); - }) - - it('put when key is repeat', 9, async (done: Function) => { - const context: Context = GlobalContext.getContext().getObject("context") as Context; - const dataCache = DataCache.getInstance(context); - await dataCache.put(KEY, '222'); - const data = '111'; - await dataCache.put(KEY, data); - expect(dataCache.getSync(KEY)).assertEqual(data); - done(); - }) - }) -} diff --git a/entry/src/ohosTest/ets/test/PutHasSaveTime.test.ets b/entry/src/ohosTest/ets/test/PutHasSaveTime.test.ets deleted file mode 100644 index 26a62be..0000000 --- a/entry/src/ohosTest/ets/test/PutHasSaveTime.test.ets +++ /dev/null @@ -1,148 +0,0 @@ -/* - * The MIT License (MIT) - * Copyright (C) 2024 Huawei Device Co., Ltd. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - */ - -import { describe, it, expect, beforeEach } from '@ohos/hypium' -import { DataCache } from '@hadss/datacache'; -import { GlobalContext, TestObjectData } from '../testability/GlobalContext'; - -export default function PutHasSaveTimeTest() { - const KEY = 'PutHasSaveTimeTest'; - - describe('PutHasSaveTimeTest', () => { - beforeEach(async () => { - const context: Context = GlobalContext.getContext().getObject("context") as Context; - const dataCache = DataCache.getInstance(context); - await dataCache.clear(); - }) - - it('put uint8array save 1s', 0, async (done: Function) => { - const context: Context = GlobalContext.getContext().getObject("context") as Context; - const dataCache = DataCache.getInstance(context); - const data = new Uint8Array(); - await dataCache.put(KEY, data, 1).then(() => { - expect(dataCache.getSync(KEY)).assertInstanceOf('Uint8Array'); - setTimeout(() => { - expect(dataCache.getSync(KEY)).assertUndefined(); - done(); - }, 2100); - }); - }) - - it('put string save 1s', 1, async (done: Function) => { - const context: Context = GlobalContext.getContext().getObject("context") as Context; - const dataCache = DataCache.getInstance(context); - const data = '111'; - await dataCache.put(KEY, data, 1).then(() => { - expect(dataCache.getSync(KEY)).assertEqual(data); - setTimeout(() => { - expect(dataCache.getSync(KEY)).assertUndefined(); - done(); - }, 2100); - }); - }) - - it('put boolean save 1s', 2, async (done: Function) => { - const context: Context = GlobalContext.getContext().getObject("context") as Context; - const dataCache = DataCache.getInstance(context); - const data = true; - await dataCache.put(KEY, data, 1).then(() => { - expect(dataCache.getSync(KEY)).assertEqual(data); - setTimeout(() => { - expect(dataCache.getSync(KEY)).assertUndefined(); - done(); - }, 2100); - }); - }) - - it('put number save 1s', 3, async (done: Function) => { - const context: Context = GlobalContext.getContext().getObject("context") as Context; - const dataCache = DataCache.getInstance(context); - const data = 12; - await dataCache.put(KEY, data, 1).then(() => { - expect(dataCache.getSync(KEY)).assertEqual(data); - setTimeout(() => { - expect(dataCache.getSync(KEY)).assertUndefined(); - done(); - }, 2100); - }); - }) - - it('put object save 1s', 4, async (done: Function) => { - const context: Context = GlobalContext.getContext().getObject("context") as Context; - const dataCache = DataCache.getInstance(context); - const data: TestObjectData = { - test: 'test' - }; - dataCache.put(KEY, data, 1).then(() => { - expect(dataCache.getSync(KEY)?.test).assertEqual(data.test); - setTimeout(() => { - expect(dataCache.getSync(KEY)).assertUndefined(); - done(); - }, 2100); - }); - }) - - it('put when key is empty', 5, async (done: Function) => { - const context: Context = GlobalContext.getContext().getObject("context") as Context; - const dataCache = DataCache.getInstance(context); - const data = '111'; - try { - await dataCache.put('', data, 1); - } catch (error) { - expect(error.code).assertEqual(15500000); - done(); - } - }) - - it('put when value is empty', 6, async (done: Function) => { - const context: Context = GlobalContext.getContext().getObject("context") as Context; - const dataCache = DataCache.getInstance(context); - const data = ''; - dataCache.put(KEY, data, 1).then(() => { - expect(true).assertTrue(); - done(); - }); - }) - - it('put when cache is empty', 8, async (done: Function) => { - const context: Context = GlobalContext.getContext().getObject("context") as Context; - const dataCache = DataCache.getInstance(context); - const data = '111'; - await dataCache.put(KEY, data, 1); - expect(dataCache.getSync(KEY)).assertEqual(data); - done(); - }) - - it('put when cache is not empty', 9, async (done: Function) => { - const context: Context = GlobalContext.getContext().getObject("context") as Context; - const dataCache = DataCache.getInstance(context); - dataCache.putSync('key1', '222'); - const data = '111'; - await dataCache.put(KEY, data, 1); - expect(dataCache.getSync(KEY)).assertEqual(data); - done(); - }) - - it('put when key is repeat', 10, async (done: Function) => { - const context: Context = GlobalContext.getContext().getObject("context") as Context; - const dataCache = DataCache.getInstance(context); - await dataCache.put(KEY, '222', 1); - const data = '111'; - await dataCache.put(KEY, data, 1); - expect(dataCache.getSync(KEY)).assertEqual(data); - done(); - }) - }) -} diff --git a/entry/src/ohosTest/ets/test/PutSync.test.ets b/entry/src/ohosTest/ets/test/PutSync.test.ets deleted file mode 100644 index 7de9360..0000000 --- a/entry/src/ohosTest/ets/test/PutSync.test.ets +++ /dev/null @@ -1,120 +0,0 @@ -/* - * The MIT License (MIT) - * Copyright (C) 2024 Huawei Device Co., Ltd. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - */ - -import { describe, it, expect, beforeEach } from '@ohos/hypium' -import { DataCache } from '@hadss/datacache'; -import { GlobalContext, TestObjectData } from '../testability/GlobalContext'; - -export default function PutSyncTest() { - const KEY = 'PutSyncTest'; - - describe('PutSyncTest', () => { - beforeEach(async () => { - const context: Context = GlobalContext.getContext().getObject("context") as Context; - const dataCache = DataCache.getInstance(context); - await dataCache.clear(); - }) - - it('putSync uint8array', 0, () => { - const context: Context = GlobalContext.getContext().getObject("context") as Context; - const dataCache = DataCache.getInstance(context); - const data = new Uint8Array(); - dataCache.putSync(KEY, data); - expect(dataCache.getSync(KEY)).assertInstanceOf('Uint8Array'); - }) - - it('putSync string', 1, () => { - const context: Context = GlobalContext.getContext().getObject("context") as Context; - const dataCache = DataCache.getInstance(context); - const data = '111'; - dataCache.putSync(KEY, data); - expect(dataCache.getSync(KEY)).assertEqual(data); - }) - - it('putSync boolean', 2, () => { - const context: Context = GlobalContext.getContext().getObject("context") as Context; - const dataCache = DataCache.getInstance(context); - const data = true; - dataCache.putSync(KEY, data); - expect(dataCache.getSync(KEY)).assertEqual(data); - }) - - it('putSync number', 3, () => { - const context: Context = GlobalContext.getContext().getObject("context") as Context; - const dataCache = DataCache.getInstance(context); - const data = 12; - dataCache.putSync(KEY, data); - expect(dataCache.getSync(KEY)).assertEqual(data); - }) - - it('putSync object', 4, () => { - const context: Context = GlobalContext.getContext().getObject("context") as Context; - const dataCache = DataCache.getInstance(context); - const data: TestObjectData = { - test: 'test' - }; - dataCache.putSync(KEY, data); - expect(dataCache.getSync(KEY)?.test).assertEqual(data.test); - }) - - it('putSync when key is empty', 5, () => { - const context: Context = GlobalContext.getContext().getObject("context") as Context; - const dataCache = DataCache.getInstance(context); - const data = '111'; - try { - dataCache.putSync('', data); - } catch (error) { - expect(error.code).assertEqual(401); - } - }) - - it('putSync when value is empty', 6, () => { - const context: Context = GlobalContext.getContext().getObject("context") as Context; - const dataCache = DataCache.getInstance(context); - const data = ''; - try { - dataCache.putSync(KEY, data); - } catch (error) { - expect(error.code).assertEqual(401); - } - }) - - it('putSync when cache is empty', 7, () => { - const context: Context = GlobalContext.getContext().getObject("context") as Context; - const dataCache = DataCache.getInstance(context); - const data = '111'; - dataCache.putSync(KEY, data); - expect(dataCache.getSync(KEY)).assertEqual(data); - }) - - it('putSync when cache is not empty', 8, () => { - const context: Context = GlobalContext.getContext().getObject("context") as Context; - const dataCache = DataCache.getInstance(context); - dataCache.putSync('key1', '222'); - const data = '111'; - dataCache.putSync(KEY, data); - expect(dataCache.getSync(KEY)).assertEqual(data); - }) - - it('putSync when key is repeat', 9, () => { - const context: Context = GlobalContext.getContext().getObject("context") as Context; - const dataCache = DataCache.getInstance(context); - dataCache.putSync(KEY, '222'); - const data = '111'; - dataCache.putSync(KEY, data); - expect(dataCache.getSync(KEY)).assertEqual(data); - }) - }) -} diff --git a/entry/src/ohosTest/ets/test/PutSyncHasSaveTime.test.ets b/entry/src/ohosTest/ets/test/PutSyncHasSaveTime.test.ets deleted file mode 100644 index d70aaf3..0000000 --- a/entry/src/ohosTest/ets/test/PutSyncHasSaveTime.test.ets +++ /dev/null @@ -1,158 +0,0 @@ -/* - * The MIT License (MIT) - * Copyright (C) 2024 Huawei Device Co., Ltd. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - */ - -import { describe, it, expect, beforeEach } from '@ohos/hypium' -import { DataCache } from '@hadss/datacache'; -import { GlobalContext, TestObjectData } from '../testability/GlobalContext'; - -export default function PutSyncHasSaveTimeTest() { - const KEY = 'PutSyncHasSaveTimeTest'; - - describe('PutSyncHasSaveTimeTest', () => { - beforeEach(async () => { - const context: Context = GlobalContext.getContext().getObject("context") as Context; - const dataCache = DataCache.getInstance(context); - await dataCache.clear(); - }) - - it('putSync uint8array save 1s', 0, async (done: Function) => { - const context: Context = GlobalContext.getContext().getObject("context") as Context; - const dataCache = DataCache.getInstance(context); - const data = new Uint8Array(); - dataCache.putSync(KEY, data, 1); - expect(dataCache.getSync(KEY)).assertInstanceOf('Uint8Array'); - await new Promise((resolve) => { - setTimeout(() => { - resolve(); - }, 2100); - }); - expect(dataCache.getSync(KEY)).assertUndefined(); - done(); - }) - - it('putSync string save 1s', 1, async (done: Function) => { - const context: Context = GlobalContext.getContext().getObject("context") as Context; - const dataCache = DataCache.getInstance(context); - const data = '111'; - dataCache.putSync(KEY, data, 1); - expect(dataCache.getSync(KEY)).assertEqual(data); - await new Promise((resolve) => { - setTimeout(() => { - resolve(); - }, 2100); - }); - expect(dataCache.getSync(KEY)).assertUndefined(); - done(); - }) - - it('putSync boolean save 1s', 2, async (done: Function) => { - const context: Context = GlobalContext.getContext().getObject("context") as Context; - const dataCache = DataCache.getInstance(context); - const data = false; - dataCache.putSync(KEY, data, 1); - expect(dataCache.getSync(KEY)).assertEqual(data); - await new Promise((resolve) => { - setTimeout(() => { - resolve(); - }, 2100); - }).then(() => { - expect(dataCache.getSync(KEY)).assertUndefined(); - done(); - }); - }) - - it('putSync number save 1s', 3, async (done: Function) => { - const context: Context = GlobalContext.getContext().getObject("context") as Context; - const dataCache = DataCache.getInstance(context); - const data = 111; - dataCache.putSync(KEY, data, 1); - expect(dataCache.getSync(KEY)).assertEqual(data); - await new Promise((resolve) => { - setTimeout(() => { - resolve(); - }, 2100); - }).then(() => { - expect(dataCache.getSync(KEY)).assertUndefined(); - done(); - }); - }) - - it('putSync object save 1s', 4, async (done: Function) => { - const context: Context = GlobalContext.getContext().getObject("context") as Context; - const dataCache = DataCache.getInstance(context); - const data: TestObjectData = { - test: 'test' - }; - dataCache.putSync(KEY, data, 1); - expect(dataCache.getSync(KEY)?.test).assertEqual(data.test); - await new Promise((resolve) => { - setTimeout(() => { - resolve(); - }, 2100); - }).then(() => { - expect(dataCache.getSync(KEY)).assertUndefined(); - done(); - }); - }) - - it('putSync when key is empty', 5, () => { - const context: Context = GlobalContext.getContext().getObject("context") as Context; - const dataCache = DataCache.getInstance(context); - const data = '111'; - try { - dataCache.putSync('', data, 1); - } catch (error) { - expect(error.code).assertEqual(401); - } - }) - - it('putSync when value is empty', 6, () => { - const context: Context = GlobalContext.getContext().getObject("context") as Context; - const dataCache = DataCache.getInstance(context); - const data = ''; - try { - dataCache.putSync(KEY, data, 1); - } catch (error) { - expect(error.code).assertEqual(401); - } - }) - - it('putSync when cache is empty', 8, () => { - const context: Context = GlobalContext.getContext().getObject("context") as Context; - const dataCache = DataCache.getInstance(context); - const data = '111'; - dataCache.putSync(KEY, data, 1); - expect(dataCache.getSync(KEY)).assertEqual(data); - }) - - it('putSync when cache is not empty', 9, () => { - const context: Context = GlobalContext.getContext().getObject("context") as Context; - const dataCache = DataCache.getInstance(context); - dataCache.putSync('key1', '222'); - const data = '111'; - dataCache.putSync(KEY, data, 1); - expect(dataCache.getSync(KEY)).assertEqual(data); - }) - - it('putSync when key is repeat', 10, () => { - const context: Context = GlobalContext.getContext().getObject("context") as Context; - const dataCache = DataCache.getInstance(context); - dataCache.putSync(KEY, '222', 1); - const data = '111'; - dataCache.putSync(KEY, data, 1); - expect(dataCache.getSync(KEY)).assertEqual(data); - }) - }) -} diff --git a/entry/src/ohosTest/ets/testability/GlobalContext.ets b/entry/src/ohosTest/ets/testability/GlobalContext.ets deleted file mode 100644 index 56f4cad..0000000 --- a/entry/src/ohosTest/ets/testability/GlobalContext.ets +++ /dev/null @@ -1,41 +0,0 @@ -/* - * The MIT License (MIT) - * Copyright (C) 2024 Huawei Device Co., Ltd. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - */ - -export interface TestObjectData { - test: string; -} - -export class GlobalContext { - private constructor() { - } - - private static instance: GlobalContext; - private _objects = new Map(); - - public static getContext(): GlobalContext { - if (!GlobalContext.instance) { - GlobalContext.instance = new GlobalContext(); - } - return GlobalContext.instance; - } - - getObject(value: string): Object | undefined { - return this._objects.get(value); - } - - setObject(key: string, objectClass: Object): void { - this._objects.set(key, objectClass); - } -} \ No newline at end of file diff --git a/entry/src/ohosTest/ets/testability/TestAbility.ets b/entry/src/ohosTest/ets/testability/TestAbility.ets deleted file mode 100644 index 8014ea6..0000000 --- a/entry/src/ohosTest/ets/testability/TestAbility.ets +++ /dev/null @@ -1,46 +0,0 @@ -/* - * The MIT License (MIT) - * Copyright (C) 2024 Huawei Device Co., Ltd. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - */ - -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 window from '@ohos.window'; -import { GlobalContext } from './GlobalContext'; -import testsuite from '../test/List.test'; - -export default class TestAbility extends UIAbility { - onCreate() { - hilog.info(0x0000, 'testTag', '%{public}s', 'start run testcase!!!'); - Hypium.hypiumTest(AbilityDelegatorRegistry.getAbilityDelegator(), AbilityDelegatorRegistry.getArguments(), testsuite) - } - - onDestroy() { - hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onDestroy'); - } - - onWindowStageCreate(windowStage: window.WindowStage) { - hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageCreate'); - GlobalContext.getContext().setObject("context", this.context); - 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) ?? ''); - }); - } -} \ 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 deleted file mode 100644 index 5e4e98f..0000000 --- a/entry/src/ohosTest/ets/testability/pages/Index.ets +++ /dev/null @@ -1,46 +0,0 @@ -/* - * The MIT License (MIT) - * Copyright (C) 2024 Huawei Device Co., Ltd. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - */ - -@Entry -@Component -struct Index { - @State message: string = 'Hello World' - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(50) - .fontWeight(FontWeight.Bold) - Button() { - Text('next page') - .fontSize(20) - .fontWeight(FontWeight.Bold) - } - .type(ButtonType.Capsule) - .margin({ - top: 20 - }) - .backgroundColor('#0D9FFB') - .width('35%') - .height('5%') - .onClick(() => { - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts b/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts deleted file mode 100644 index eb5e22c..0000000 --- a/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts +++ /dev/null @@ -1,63 +0,0 @@ -/* - * The MIT License (MIT) - * Copyright (C) 2024 Huawei Device Co., Ltd. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - */ - -import hilog from '@ohos.hilog'; -import TestRunner from '@ohos.application.testRunner'; -import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; -var abilityDelegator:AbilityDelegatorRegistry.AbilityDelegator -var abilityDelegatorArguments:AbilityDelegatorRegistry.AbilityDelegatorArgs - -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 { - constructor() { - } - - 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' - let lMonitor = { - abilityName: testAbilityName, - onAbilityCreate: onAbilityCreateCallback, - }; - abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) - var cmd = 'aa start -d 0 -a TestAbility' + ' -b ' + abilityDelegatorArguments.bundleName - 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 diff --git a/entry/src/ohosTest/module.json5 b/entry/src/ohosTest/module.json5 deleted file mode 100644 index 87a6ee4..0000000 --- a/entry/src/ohosTest/module.json5 +++ /dev/null @@ -1,36 +0,0 @@ -{ - "module": { - "name": "entry_test", - "type": "feature", - "description": "$string:module_test_desc", - "mainElement": "TestAbility", - "deviceTypes": [ - "phone" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:test_pages", - "abilities": [ - { - "name": "TestAbility", - "srcEntry": "./ets/testability/TestAbility.ets", - "description": "$string:TestAbility_desc", - "icon": "$media:icon", - "label": "$string:TestAbility_label", - "visible": true, - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "skills": [ - { - "actions": [ - "action.system.home" - ], - "entities": [ - "entity.system.home" - ] - } - ] - } - ] - } -} diff --git a/entry/src/ohosTest/resources/base/element/color.json b/entry/src/ohosTest/resources/base/element/color.json deleted file mode 100644 index 3c71296..0000000 --- a/entry/src/ohosTest/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/entry/src/ohosTest/resources/base/element/string.json b/entry/src/ohosTest/resources/base/element/string.json deleted file mode 100644 index 65d8fa5..0000000 --- a/entry/src/ohosTest/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_test_desc", - "value": "test ability description" - }, - { - "name": "TestAbility_desc", - "value": "the test ability" - }, - { - "name": "TestAbility_label", - "value": "test label" - } - ] -} \ No newline at end of file diff --git a/entry/src/ohosTest/resources/base/media/icon.png b/entry/src/ohosTest/resources/base/media/icon.png deleted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