From f9988603336a83af7a830595ba6c93483f3d65c9 Mon Sep 17 00:00:00 2001 From: xzling Date: Fri, 1 Sep 2023 20:13:04 +0800 Subject: [PATCH] =?UTF-8?q?ArkTS=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: xzling --- .../main/ets/pages/page/CustomTransition2.ets | 12 +- .../src/main/ets/pages/share/ShareItem.ets | 30 +- .../src/main/ets/pages/share/SharePage.ets | 7 +- .../src/ohosTest/ets/test/Ability.test.ets | 51 --- .../entry/src/ohosTest/ets/test/List.test.ets | 20 -- .../ohosTest/ets/testability/TestAbility.ets | 72 ----- .../ohosTest/ets/testability/pages/Index.ets | 53 --- .../ets/testrunner/OpenHarmonyTestRunner.ts | 85 ----- .../entry/src/ohosTest/module.json5 | 51 --- .../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 - .../entry/src/main/ets/common/PlayList.ets | 6 +- .../src/main/ets/common/PlayListCover.ets | 4 +- .../entry/src/main/ets/model/MediaData.ets | 15 +- .../entry/src/main/ets/model/SongList.ets | 16 +- .../entry/src/main/ets/model/SongModule.ets | 2 +- .../src/ohosTest/ets/test/Ability.test.ets | 51 --- .../entry/src/ohosTest/ets/test/List.test.ets | 20 -- .../ohosTest/ets/testability/TestAbility.ets | 72 ----- .../ohosTest/ets/testability/pages/Index.ets | 53 --- .../ets/testrunner/OpenHarmonyTestRunner.ts | 85 ----- .../entry/src/ohosTest/module.json5 | 51 --- .../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 - .../Image/entry/src/main/ets/pages/Index.ets | 31 +- media/Image/entry/src/main/ets/utils/utils.ts | 3 + .../ohosTest/ets/Application/AbilityStage.ts | 22 -- .../ets/Application/TestAbilityStage.ts | 25 -- .../entry/src/ohosTest/ets/module.json5.ftl | 49 --- .../src/ohosTest/ets/test/Ability.test.ets | 35 -- .../entry/src/ohosTest/ets/test/List.test.ets | 20 -- .../entry/src/ohosTest/ets/test/app.test.ets | 59 ---- .../ohosTest/ets/testability/TestAbility.ets | 48 --- .../ohosTest/ets/testability/TestAbility.ts | 60 ---- .../ohosTest/ets/testability/pages/index.ets | 52 --- .../ets/testrunner/OpenHarmonyTestRunner.ts | 78 ----- media/Image/entry/src/ohosTest/module.json5 | 54 ---- .../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 - .../main/ets/components/pages/ChoicePhoto.ets | 175 +++++----- .../main/ets/components/pages/EditPage.ets | 306 +++++++++--------- .../src/main/ets/MainAbility/MainAbility.ts | 1 + .../entry/src/main/ets/pages/Index.ets | 84 ++--- .../entry/src/main/ets/utils/utils.ts | 4 + .../ohosTest/ets/Application/AbilityStage.ts | 25 -- .../ets/Application/TestAbilityStage.ts | 25 -- .../entry/src/ohosTest/ets/module.json5.ftl | 49 --- .../src/ohosTest/ets/test/Ability.test.ets | 31 -- .../entry/src/ohosTest/ets/test/List.test.ets | 20 -- .../ohosTest/ets/testability/TestAbility.ets | 48 --- .../ohosTest/ets/testability/TestAbility.ts | 61 ---- .../ohosTest/ets/testability/pages/index.ets | 52 --- .../ets/testrunner/OpenHarmonyTestRunner.ts | 80 ----- .../ImageShow/entry/src/ohosTest/module.json5 | 54 ---- .../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 - .../ets/components/pages/ChoicePhotos.ets | 243 ++++++++------ 65 files changed, 526 insertions(+), 2140 deletions(-) delete mode 100644 ETSUI/TransitionAnimation/entry/src/ohosTest/ets/test/Ability.test.ets delete mode 100644 ETSUI/TransitionAnimation/entry/src/ohosTest/ets/test/List.test.ets delete mode 100644 ETSUI/TransitionAnimation/entry/src/ohosTest/ets/testability/TestAbility.ets delete mode 100644 ETSUI/TransitionAnimation/entry/src/ohosTest/ets/testability/pages/Index.ets delete mode 100644 ETSUI/TransitionAnimation/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts delete mode 100644 ETSUI/TransitionAnimation/entry/src/ohosTest/module.json5 delete mode 100644 ETSUI/TransitionAnimation/entry/src/ohosTest/resources/base/element/color.json delete mode 100644 ETSUI/TransitionAnimation/entry/src/ohosTest/resources/base/element/string.json delete mode 100644 ETSUI/TransitionAnimation/entry/src/ohosTest/resources/base/media/icon.png delete mode 100644 ETSUI/TransitionAnimation/entry/src/ohosTest/resources/base/profile/test_pages.json delete mode 100644 MultiDeviceAppDev/MusicAlbum/entry/src/ohosTest/ets/test/Ability.test.ets delete mode 100644 MultiDeviceAppDev/MusicAlbum/entry/src/ohosTest/ets/test/List.test.ets delete mode 100644 MultiDeviceAppDev/MusicAlbum/entry/src/ohosTest/ets/testability/TestAbility.ets delete mode 100644 MultiDeviceAppDev/MusicAlbum/entry/src/ohosTest/ets/testability/pages/Index.ets delete mode 100644 MultiDeviceAppDev/MusicAlbum/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts delete mode 100644 MultiDeviceAppDev/MusicAlbum/entry/src/ohosTest/module.json5 delete mode 100644 MultiDeviceAppDev/MusicAlbum/entry/src/ohosTest/resources/base/element/color.json delete mode 100644 MultiDeviceAppDev/MusicAlbum/entry/src/ohosTest/resources/base/element/string.json delete mode 100644 MultiDeviceAppDev/MusicAlbum/entry/src/ohosTest/resources/base/media/icon.png delete mode 100644 MultiDeviceAppDev/MusicAlbum/entry/src/ohosTest/resources/base/profile/test_pages.json create mode 100644 media/Image/entry/src/main/ets/utils/utils.ts delete mode 100644 media/Image/entry/src/ohosTest/ets/Application/AbilityStage.ts delete mode 100644 media/Image/entry/src/ohosTest/ets/Application/TestAbilityStage.ts delete mode 100644 media/Image/entry/src/ohosTest/ets/module.json5.ftl delete mode 100644 media/Image/entry/src/ohosTest/ets/test/Ability.test.ets delete mode 100644 media/Image/entry/src/ohosTest/ets/test/List.test.ets delete mode 100644 media/Image/entry/src/ohosTest/ets/test/app.test.ets delete mode 100644 media/Image/entry/src/ohosTest/ets/testability/TestAbility.ets delete mode 100644 media/Image/entry/src/ohosTest/ets/testability/TestAbility.ts delete mode 100644 media/Image/entry/src/ohosTest/ets/testability/pages/index.ets delete mode 100644 media/Image/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts delete mode 100644 media/Image/entry/src/ohosTest/module.json5 delete mode 100644 media/Image/entry/src/ohosTest/resources/base/element/color.json delete mode 100644 media/Image/entry/src/ohosTest/resources/base/element/string.json delete mode 100644 media/Image/entry/src/ohosTest/resources/base/media/icon.png delete mode 100644 media/Image/entry/src/ohosTest/resources/base/profile/test_pages.json create mode 100644 media/ImageShow/entry/src/main/ets/utils/utils.ts delete mode 100644 media/ImageShow/entry/src/ohosTest/ets/Application/AbilityStage.ts delete mode 100644 media/ImageShow/entry/src/ohosTest/ets/Application/TestAbilityStage.ts delete mode 100644 media/ImageShow/entry/src/ohosTest/ets/module.json5.ftl delete mode 100644 media/ImageShow/entry/src/ohosTest/ets/test/Ability.test.ets delete mode 100644 media/ImageShow/entry/src/ohosTest/ets/test/List.test.ets delete mode 100644 media/ImageShow/entry/src/ohosTest/ets/testability/TestAbility.ets delete mode 100644 media/ImageShow/entry/src/ohosTest/ets/testability/TestAbility.ts delete mode 100644 media/ImageShow/entry/src/ohosTest/ets/testability/pages/index.ets delete mode 100644 media/ImageShow/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts delete mode 100644 media/ImageShow/entry/src/ohosTest/module.json5 delete mode 100644 media/ImageShow/entry/src/ohosTest/resources/base/element/color.json delete mode 100644 media/ImageShow/entry/src/ohosTest/resources/base/element/string.json delete mode 100644 media/ImageShow/entry/src/ohosTest/resources/base/media/icon.png delete mode 100644 media/ImageShow/entry/src/ohosTest/resources/base/profile/test_pages.json diff --git a/ETSUI/TransitionAnimation/entry/src/main/ets/pages/page/CustomTransition2.ets b/ETSUI/TransitionAnimation/entry/src/main/ets/pages/page/CustomTransition2.ets index b18dcec0..f68cf913 100644 --- a/ETSUI/TransitionAnimation/entry/src/main/ets/pages/page/CustomTransition2.ets +++ b/ETSUI/TransitionAnimation/entry/src/main/ets/pages/page/CustomTransition2.ets @@ -38,14 +38,18 @@ struct CustomTransition2 { pageTransition() { // 页面入场组件: 进场过程中会逐帧触发onEnter回调,入参为动效的归一化进度(0% -- 100%) PageTransitionEnter({ duration: 800, curve: Curve.Smooth }) - .onEnter((type: RouteType, progress: number) => { - this.myProgress = progress // 页面入场时myProgress从0变化到1 + .onEnter((type?: RouteType, progress?: number) => { + if(progress !== undefined){ + this.myProgress = progress // 页面入场时myProgress从0变化到1 + } }) // 页面退场组件: 进场过程中会逐帧触发onExit回调,入参为动效的归一化进度(0% -- 100%) PageTransitionExit({ duration: 1000, curve: Curve.Smooth }) - .onExit((type: RouteType, progress: number) => { - this.myProgress = 1 - progress // 页面退场式myProgress从1变化到0 + .onExit((type?: RouteType, progress?: number) => { + if(progress !== undefined){ + this.myProgress = 1 - progress // 页面退场式myProgress从1变化到0 + } }) } } \ No newline at end of file diff --git a/ETSUI/TransitionAnimation/entry/src/main/ets/pages/share/ShareItem.ets b/ETSUI/TransitionAnimation/entry/src/main/ets/pages/share/ShareItem.ets index 3235da9f..f6e2f173 100644 --- a/ETSUI/TransitionAnimation/entry/src/main/ets/pages/share/ShareItem.ets +++ b/ETSUI/TransitionAnimation/entry/src/main/ets/pages/share/ShareItem.ets @@ -33,7 +33,7 @@ class BasicDataSource implements IDataSource { return 0 } - public getData(index: number) { + public getData(index: number):undefined | Resource{ return undefined } @@ -51,31 +51,31 @@ class BasicDataSource implements IDataSource { } notifyDataReload() { - this.listeners.forEach(listener => { + this.listeners.forEach((listener:DataChangeListener) => { listener.onDataReloaded() }) } notifyDataAdd(index: number) { - this.listeners.forEach(listener => { + this.listeners.forEach((listener:DataChangeListener) => { listener.onDataAdd(index) }) } notifyDataChange(index: number) { - this.listeners.forEach(listener => { + this.listeners.forEach((listener:DataChangeListener) => { listener.onDataChange(index) }) } notifyDataDelete(index: number) { - this.listeners.forEach(listener => { + this.listeners.forEach((listener:DataChangeListener) => { listener.onDataDelete(index) }) } notifyDataMove(from: number, to: number) { - this.listeners.forEach(listener => { + this.listeners.forEach((listener:DataChangeListener) => { listener.onDataMove(from, to) }) } @@ -88,7 +88,7 @@ class MyDataSource extends BasicDataSource { return this.dataArray.length } - public getData(index: number) { + public getData(index: number) :undefined | Resource{ return this.dataArray[index] } @@ -102,7 +102,7 @@ class MyDataSource extends BasicDataSource { this.notifyDataAdd(this.dataArray.length - 1) } - public replaceData(result: any[]) { + public replaceData(result:Resource[]) { this.dataArray = result } } @@ -122,12 +122,14 @@ struct ShareItem { .textAlign(TextAlign.Center) .margin(10) Grid() { - LazyForEach(this.info, (item, index) => { + LazyForEach(this.info, (item: MyDataSource, index?:number) => { GridItem() { - Image(item) - .width(120) - .aspectRatio(1) - .sharedTransition(index.toString(), { duration: 600, curve: Curve.Smooth, delay: 100 }) + if(index !== undefined){ + Image(item) + .width(120) + .aspectRatio(1) + .sharedTransition(index.toString(), { duration: 600, curve: Curve.Smooth, delay: 100 }) + } } .padding(10) .backgroundColor('#F5F5F5') @@ -140,7 +142,7 @@ struct ShareItem { } }) }) - }, item => JSON.stringify(item)) + }, (item: MyDataSource) => JSON.stringify(item)) } .columnsTemplate('1fr 1fr 1fr') .columnsGap(10) diff --git a/ETSUI/TransitionAnimation/entry/src/main/ets/pages/share/SharePage.ets b/ETSUI/TransitionAnimation/entry/src/main/ets/pages/share/SharePage.ets index 2c5de8ae..fd23c873 100644 --- a/ETSUI/TransitionAnimation/entry/src/main/ets/pages/share/SharePage.ets +++ b/ETSUI/TransitionAnimation/entry/src/main/ets/pages/share/SharePage.ets @@ -16,10 +16,15 @@ import router from '@ohos.router' import TitleBar from '../../common/TitleBar' import { SHARE_IMAGES } from './ShareItem' +interface Params extends Object{ + index: number +} + + @Entry @Component struct SharePage { - private index: number = router.getParams()['index'] + private index: number = (router.getParams() as Params).index build() { Column() { diff --git a/ETSUI/TransitionAnimation/entry/src/ohosTest/ets/test/Ability.test.ets b/ETSUI/TransitionAnimation/entry/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100644 index 675703dc..00000000 --- a/ETSUI/TransitionAnimation/entry/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,51 +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 hilog from '@ohos.hilog' -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' - -export default function abilityTest() { - 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.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO) - 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) - }) - }) -} \ No newline at end of file diff --git a/ETSUI/TransitionAnimation/entry/src/ohosTest/ets/test/List.test.ets b/ETSUI/TransitionAnimation/entry/src/ohosTest/ets/test/List.test.ets deleted file mode 100644 index 7e05ea60..00000000 --- a/ETSUI/TransitionAnimation/entry/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +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 abilityTest from './Ability.test' - -export default function testsuite() { - abilityTest() -} \ No newline at end of file diff --git a/ETSUI/TransitionAnimation/entry/src/ohosTest/ets/testability/TestAbility.ets b/ETSUI/TransitionAnimation/entry/src/ohosTest/ets/testability/TestAbility.ets deleted file mode 100644 index c400b428..00000000 --- a/ETSUI/TransitionAnimation/entry/src/ohosTest/ets/testability/TestAbility.ets +++ /dev/null @@ -1,72 +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 hilog from '@ohos.hilog' -import Ability from '@ohos.application.Ability' -import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' -import { Hypium } from '@ohos/hypium' -import testsuite from '../test/List.test' -import Window from '@ohos.window' - -export default class TestAbility extends Ability { - onCreate(want, launchParam) { - hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO) - 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.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO) - hilog.info(0x0000, 'testTag', '%{public}s', 'start run testcase!!!') - Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) - } - - onDestroy() { - hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO) - hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onDestroy') - } - - onWindowStageCreate(windowStage: Window.WindowStage) { - hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO) - hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageCreate') - windowStage.loadContent('testability/pages/Index', (err, data) => { - if (err.code) { - hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.ERROR) - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '') - return - } - hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO) - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', - JSON.stringify(data) ?? '') - }) - } - - onWindowStageDestroy() { - hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO) - hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageDestroy') - } - - onForeground() { - hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO) - hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onForeground') - } - - onBackground() { - hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO) - hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onBackground') - } -} \ No newline at end of file diff --git a/ETSUI/TransitionAnimation/entry/src/ohosTest/ets/testability/pages/Index.ets b/ETSUI/TransitionAnimation/entry/src/ohosTest/ets/testability/pages/Index.ets deleted file mode 100644 index 7bdfcfcf..00000000 --- a/ETSUI/TransitionAnimation/entry/src/ohosTest/ets/testability/pages/Index.ets +++ /dev/null @@ -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 hilog from '@ohos.hilog' - -@Entry -@Component -struct Index { - aboutToAppear() { - hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO) - hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility index aboutToAppear') - } - - @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/ETSUI/TransitionAnimation/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts b/ETSUI/TransitionAnimation/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts deleted file mode 100644 index 14767fda..00000000 --- a/ETSUI/TransitionAnimation/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts +++ /dev/null @@ -1,85 +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 hilog from '@ohos.hilog' -import TestRunner from '@ohos.application.testRunner' -import AbilityDelegatorRegistry from '@ohos.application.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', - '-s dryRun' - ]) - let targetParams = '' - for (const key in parameters) { - if (keySet.has(key)) { - targetParams = `${targetParams} ${key} ${parameters[key]}` - } - } - return targetParams.trim() -} - -async function onAbilityCreateCallback() { - hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); - hilog.info(0x0000, 'testTag', '%{public}s', 'onAbilityCreateCallback') -} - -async function addAbilityMonitorCallback(err: any) { - hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO) - hilog.info(0x0000, 'testTag', 'addAbilityMonitorCallback : %{public}s', JSON.stringify(err) ?? '') -} - -export default class OpenHarmonyTestRunner implements TestRunner { - constructor() { - } - - onPrepare() { - hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO) - hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner OnPrepare ') - } - - async onRun() { - hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO) - 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 - cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters) - var debug = abilityDelegatorArguments.parameters['-D'] - if (debug == 'true') { - cmd += ' -D' - } - hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO) - hilog.info(0x0000, 'testTag', 'cmd : %{public}s', cmd) - abilityDelegator.executeShellCommand(cmd, - (err: any, d: any) => { - hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); - 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/ETSUI/TransitionAnimation/entry/src/ohosTest/module.json5 b/ETSUI/TransitionAnimation/entry/src/ohosTest/module.json5 deleted file mode 100644 index fd36ba53..00000000 --- a/ETSUI/TransitionAnimation/entry/src/ohosTest/module.json5 +++ /dev/null @@ -1,51 +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. - */ - -{ - "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", - "srcEntrance": "./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/ETSUI/TransitionAnimation/entry/src/ohosTest/resources/base/element/color.json b/ETSUI/TransitionAnimation/entry/src/ohosTest/resources/base/element/color.json deleted file mode 100644 index 3c712962..00000000 --- a/ETSUI/TransitionAnimation/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/ETSUI/TransitionAnimation/entry/src/ohosTest/resources/base/element/string.json b/ETSUI/TransitionAnimation/entry/src/ohosTest/resources/base/element/string.json deleted file mode 100644 index 65d8fa5a..00000000 --- a/ETSUI/TransitionAnimation/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/ETSUI/TransitionAnimation/entry/src/ohosTest/resources/base/media/icon.png b/ETSUI/TransitionAnimation/entry/src/ohosTest/resources/base/media/icon.png deleted file mode 100644 index ce307a8827bd75456441ceb57d530e4c8d45d36c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6790 zcmX|G1ymHk)?T_}Vd;>R?p|tHQo6fg38|$UVM!6BLrPFWk?s;$LOP{GmJpBl$qoSA!PUg~PA65-S00{{S`XKG6NkG0RgjEntPrmV+?0|00mu7;+5 zrdpa{2QLqPJ4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x*l|*Ia@ECeXo2E4h2f!aV=cHAhi_E_mfUth(sM4^hJq7B zQsGWqdZUm9S%F`$nQ*_#NcuD`&)Ek%_s{&^78{9Hm ztri&rYLOxgFdG>O@+XHy z9#;|&vBCPXH5Mon^I`jSuR$&~ZWtyB67ujzFSj!51>#C}C17~TffQ{c-!QFQkTQ%! zIR^b1`zHx|*1GU?tbBx23weFLz5H?y_Q%N&t$}k?w+``2A=aotj0;2v$~AL z{scF-cL{wsdrmPvf#a9OHyYLcwQD4Kcm)`LLwMh4WT~p29f7M!iafJSU`IV}QY5Wa z(n44-9oA}?J{a+ah*@31WTs#&J#o1`H98#6IQf;Wv0N_!);f&9g7o-k(lW5rWnDUR zQBFIRG+X=6NnsI@mxnwm;tf5;_Uxg?jZ8m-m0}&6+DA!qam(p$mN5R})yA_7m$q@| zFEd|dpS595rxQr-n#GjI5i-AhnUE>Cr;jpCqSrD~EwK_DqI^7%3#p5)%T_od!t3SOmH9MyXeeGO2(UQL;ax|x?Ncixmeo1=$ z{-);Au{*tfzOG?KQ~K|ak8-HQ?`Pekhe2WM(8s{xv-p>Zmu_6{G!-oE$7$mY`MOJorI=+mMx?H;`pr!;fVYz?5~yXBACruWB`Ph zZM}90_<^OBxIhyZ9BW$`>6JvO;%VFpqVr8|7t3~AmxYak6?`Pp#c;**_SYmi`&z23 z`p6_~ePvH)C6x-G9$hgL=eVALq`-AiamN>!3~Lxw&{H(b{B(7xSRm6<3<{%{yXiH# zos5Rv1L+8fUKJLo%P>4I&$}y { + LazyForEach(new MyDataSource(songList), (item:SongListType) => { ListItem() { Column() { this.SongItem(item.title, item.label, item.singer) @@ -89,7 +89,7 @@ export default struct PlayList { .opacity(0.1) }.padding({ left: 14, right: 14 }) } - }, item => item.id) + }, (item:SongListType) => item.id.toString()) } .width('100%') .height('100%') diff --git a/MultiDeviceAppDev/MusicAlbum/entry/src/main/ets/common/PlayListCover.ets b/MultiDeviceAppDev/MusicAlbum/entry/src/main/ets/common/PlayListCover.ets index c99ee0e6..1df22f8f 100644 --- a/MultiDeviceAppDev/MusicAlbum/entry/src/main/ets/common/PlayListCover.ets +++ b/MultiDeviceAppDev/MusicAlbum/entry/src/main/ets/common/PlayListCover.ets @@ -13,7 +13,7 @@ * limitations under the License. */ -import { optionList } from '../model/SongList' +import { optionList, OptionListType } from '../model/SongList' @Component export default struct PlayListCover { @@ -71,7 +71,7 @@ export default struct PlayListCover { @Builder CoverOptions() { Flex({ justifyContent: FlexAlign.SpaceBetween }) { - ForEach(optionList, item => { + ForEach(optionList, (item:OptionListType) => { Column({ space: 4 }) { Image(item.image).height(30).width(30) Text(item.text) diff --git a/MultiDeviceAppDev/MusicAlbum/entry/src/main/ets/model/MediaData.ets b/MultiDeviceAppDev/MusicAlbum/entry/src/main/ets/model/MediaData.ets index 67cf961c..34b47848 100644 --- a/MultiDeviceAppDev/MusicAlbum/entry/src/main/ets/model/MediaData.ets +++ b/MultiDeviceAppDev/MusicAlbum/entry/src/main/ets/model/MediaData.ets @@ -14,12 +14,15 @@ */ import mediaQuery from '@ohos.mediaquery' +interface MediaQueryResult { + matches: boolean +} export default class BreakpointSystem { private currentBreakpoint: string = 'md' - private smListener: mediaQuery.MediaQueryListener - private mdListener: mediaQuery.MediaQueryListener - private lgListener: mediaQuery.MediaQueryListener + private smListener: mediaQuery.MediaQueryListener = {} as mediaQuery.MediaQueryListener + private mdListener: mediaQuery.MediaQueryListener = {} as mediaQuery.MediaQueryListener + private lgListener: mediaQuery.MediaQueryListener = {} as mediaQuery.MediaQueryListener private updateCurrentBreakpoint(breakpoint: string) { if (this.currentBreakpoint !== breakpoint) { @@ -28,21 +31,21 @@ export default class BreakpointSystem { } } - private isBreakpointSM = (mediaQueryResult) => { + private isBreakpointSM = (mediaQueryResult:MediaQueryResult) => { if (mediaQueryResult.matches) { this.updateCurrentBreakpoint('sm') AppStorage.Set('fontSize', 14) AppStorage.Set('coverMargin', 10) } } - private isBreakpointMD = (mediaQueryResult) => { + private isBreakpointMD = (mediaQueryResult:MediaQueryResult) => { if (mediaQueryResult.matches) { this.updateCurrentBreakpoint('md') AppStorage.Set('fontSize', 16) AppStorage.Set('coverMargin', 30) } } - private isBreakpointLG = (mediaQueryResult) => { + private isBreakpointLG = (mediaQueryResult:MediaQueryResult) => { if (mediaQueryResult.matches) { this.updateCurrentBreakpoint('lg') AppStorage.Set('fontSize', 18) diff --git a/MultiDeviceAppDev/MusicAlbum/entry/src/main/ets/model/SongList.ets b/MultiDeviceAppDev/MusicAlbum/entry/src/main/ets/model/SongList.ets index 133711c3..cf691778 100644 --- a/MultiDeviceAppDev/MusicAlbum/entry/src/main/ets/model/SongList.ets +++ b/MultiDeviceAppDev/MusicAlbum/entry/src/main/ets/model/SongList.ets @@ -12,8 +12,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +interface SongListType { + id: number + title: string + singer: string + label: Resource +} +interface OptionListType { + image:Resource + text: Resource | string +} -const songList = [ +const songList:SongListType[] = [ { id: 1, title: '不知道', singer: '小碗你好', label: $r('app.media.ic_vip') }, { id: 2, title: '歌名你好', singer: '张三-你好我好都好', label: $r('app.media.ic_SQ') }, { id: 3, title: '还是歌名', singer: '不知道你是谁', label: $r('app.media.ic_SQ') }, @@ -39,11 +49,11 @@ const songList = [ { id: 24, title: '安心安心', singer: '小安安', label: $r('app.media.ic_SQ') }, { id: 25, title: 'Notebook', singer: '小安安', label: $r('app.media.ic_SQ') } ] -const optionList = [ +const optionList:OptionListType[] = [ { image: $r('app.media.ic_collect'), text: '999+' }, { image: $r('app.media.ic_download'), text: $r('app.string.download') }, { image: $r("app.media.icon_comments"), text: $r('app.string.comment') }, { image: $r('app.media.icon_share'), text: $r('app.string.share') } ] -export { songList, optionList } \ No newline at end of file +export { songList, optionList, OptionListType, SongListType } \ No newline at end of file diff --git a/MultiDeviceAppDev/MusicAlbum/entry/src/main/ets/model/SongModule.ets b/MultiDeviceAppDev/MusicAlbum/entry/src/main/ets/model/SongModule.ets index c030c27c..d6faa71c 100644 --- a/MultiDeviceAppDev/MusicAlbum/entry/src/main/ets/model/SongModule.ets +++ b/MultiDeviceAppDev/MusicAlbum/entry/src/main/ets/model/SongModule.ets @@ -13,7 +13,7 @@ * limitations under the License. */ -type SongItem = { +interface SongItem { id: number, title: string, singer: string, diff --git a/MultiDeviceAppDev/MusicAlbum/entry/src/ohosTest/ets/test/Ability.test.ets b/MultiDeviceAppDev/MusicAlbum/entry/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100644 index 675703dc..00000000 --- a/MultiDeviceAppDev/MusicAlbum/entry/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,51 +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 hilog from '@ohos.hilog' -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' - -export default function abilityTest() { - 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.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO) - 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) - }) - }) -} \ No newline at end of file diff --git a/MultiDeviceAppDev/MusicAlbum/entry/src/ohosTest/ets/test/List.test.ets b/MultiDeviceAppDev/MusicAlbum/entry/src/ohosTest/ets/test/List.test.ets deleted file mode 100644 index 7e05ea60..00000000 --- a/MultiDeviceAppDev/MusicAlbum/entry/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +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 abilityTest from './Ability.test' - -export default function testsuite() { - abilityTest() -} \ No newline at end of file diff --git a/MultiDeviceAppDev/MusicAlbum/entry/src/ohosTest/ets/testability/TestAbility.ets b/MultiDeviceAppDev/MusicAlbum/entry/src/ohosTest/ets/testability/TestAbility.ets deleted file mode 100644 index aec33414..00000000 --- a/MultiDeviceAppDev/MusicAlbum/entry/src/ohosTest/ets/testability/TestAbility.ets +++ /dev/null @@ -1,72 +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 hilog from '@ohos.hilog' -import Ability from '@ohos.application.Ability' -import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' -import { Hypium } from '@ohos/hypium' -import testsuite from '../test/List.test' -import Window from '@ohos.window' - -export default class TestAbility extends Ability { - onCreate(want, launchParam) { - hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO) - 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.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); - hilog.info(0x0000, 'testTag', '%{public}s', 'start run testcase!!!') - Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) - } - - onDestroy() { - hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO) - hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onDestroy') - } - - onWindowStageCreate(windowStage: Window.WindowStage) { - hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO) - hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageCreate') - windowStage.loadContent('testability/pages/Index', (err, data) => { - if (err.code) { - hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.ERROR) - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '') - return - } - hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO) - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', - JSON.stringify(data) ?? '') - }) - } - - onWindowStageDestroy() { - hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO) - hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageDestroy') - } - - onForeground() { - hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO) - hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onForeground') - } - - onBackground() { - hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO) - hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onBackground') - } -} \ No newline at end of file diff --git a/MultiDeviceAppDev/MusicAlbum/entry/src/ohosTest/ets/testability/pages/Index.ets b/MultiDeviceAppDev/MusicAlbum/entry/src/ohosTest/ets/testability/pages/Index.ets deleted file mode 100644 index db9979b6..00000000 --- a/MultiDeviceAppDev/MusicAlbum/entry/src/ohosTest/ets/testability/pages/Index.ets +++ /dev/null @@ -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 hilog from '@ohos.hilog' - -@Entry -@Component -struct Index { - aboutToAppear() { - hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); - hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility index aboutToAppear') - } - - @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/MultiDeviceAppDev/MusicAlbum/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts b/MultiDeviceAppDev/MusicAlbum/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts deleted file mode 100644 index c3335700..00000000 --- a/MultiDeviceAppDev/MusicAlbum/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts +++ /dev/null @@ -1,85 +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 hilog from '@ohos.hilog' -import TestRunner from '@ohos.application.testRunner' -import AbilityDelegatorRegistry from '@ohos.application.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', - '-s dryRun' - ]) - let targetParams = '' - for (const key in parameters) { - if (keySet.has(key)) { - targetParams = `${targetParams} ${key} ${parameters[key]}` - } - } - return targetParams.trim() -} - -async function onAbilityCreateCallback() { - hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO) - hilog.info(0x0000, 'testTag', '%{public}s', 'onAbilityCreateCallback') -} - -async function addAbilityMonitorCallback(err: any) { - hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO) - hilog.info(0x0000, 'testTag', 'addAbilityMonitorCallback : %{public}s', JSON.stringify(err) ?? '') -} - -export default class OpenHarmonyTestRunner implements TestRunner { - constructor() { - } - - onPrepare() { - hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO) - hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner OnPrepare ') - } - - async onRun() { - hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO) - 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 - cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters) - var debug = abilityDelegatorArguments.parameters['-D'] - if (debug == 'true') { - cmd += ' -D' - } - hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO) - hilog.info(0x0000, 'testTag', 'cmd : %{public}s', cmd) - abilityDelegator.executeShellCommand(cmd, - (err: any, d: any) => { - hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO) - 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/MultiDeviceAppDev/MusicAlbum/entry/src/ohosTest/module.json5 b/MultiDeviceAppDev/MusicAlbum/entry/src/ohosTest/module.json5 deleted file mode 100644 index fd36ba53..00000000 --- a/MultiDeviceAppDev/MusicAlbum/entry/src/ohosTest/module.json5 +++ /dev/null @@ -1,51 +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. - */ - -{ - "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", - "srcEntrance": "./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/MultiDeviceAppDev/MusicAlbum/entry/src/ohosTest/resources/base/element/color.json b/MultiDeviceAppDev/MusicAlbum/entry/src/ohosTest/resources/base/element/color.json deleted file mode 100644 index 3c712962..00000000 --- a/MultiDeviceAppDev/MusicAlbum/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/MultiDeviceAppDev/MusicAlbum/entry/src/ohosTest/resources/base/element/string.json b/MultiDeviceAppDev/MusicAlbum/entry/src/ohosTest/resources/base/element/string.json deleted file mode 100644 index 65d8fa5a..00000000 --- a/MultiDeviceAppDev/MusicAlbum/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/MultiDeviceAppDev/MusicAlbum/entry/src/ohosTest/resources/base/media/icon.png b/MultiDeviceAppDev/MusicAlbum/entry/src/ohosTest/resources/base/media/icon.png deleted file mode 100644 index ce307a8827bd75456441ceb57d530e4c8d45d36c..0000000000000000000000000000000000000000 GIT binary patch literal 0 H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-w>JPl2UJpafrPaL5@2j}%{VE-) zBI%6Qpj*dsdH<;g!S!avA~bv^0E+ zfyJbSjPb+j;J52U)<|cIcntQBI2T#>2;tOxu{%D?kML476AErF(qN9hPva5Nkc@BF zC-tLF@3ZFb%Kpj)M<{)x*l|*Ia@ECeXo2E4h2f!aV=cHAhi_E_mfUth(sM4^hJq7B zQsGWqdZUm9S%F`$nQ*_#NcuD`&)Ek%_s{&^78{9Hm ztri&rYLOxgFdG>O@+XHy z9#;|&vBCPXH5Mon^I`jSuR$&~ZWtyB67ujzFSj!51>#C}C17~TffQ{c-!QFQkTQ%! zIR^b1`zHx|*1GU?tbBx23weFLz5H?y_Q%N&t$}k?w+``2A=aotj0;2v$~AL z{scF-cL{wsdrmPvf#a9OHyYLcwQD4Kcm)`LLwMh4WT~p29f7M!iafJSU`IV}QY5Wa z(n44-9oA}?J{a+ah*@31WTs#&J#o1`H98#6IQf;Wv0N_!);f&9g7o-k(lW5rWnDUR zQBFIRG+X=6NnsI@mxnwm;tf5;_Uxg?jZ8m-m0}&6+DA!qam(p$mN5R})yA_7m$q@| zFEd|dpS595rxQr-n#GjI5i-AhnUE>Cr;jpCqSrD~EwK_DqI^7%3#p5)%T_od!t3SOmH9MyXeeGO2(UQL;ax|x?Ncixmeo1=$ z{-);Au{*tfzOG?KQ~K|ak8-HQ?`Pekhe2WM(8s{xv-p>Zmu_6{G!-oE$7$mY`MOJorI=+mMx?H;`pr!;fVYz?5~yXBACruWB`Ph zZM}90_<^OBxIhyZ9BW$`>6JvO;%VFpqVr8|7t3~AmxYak6?`Pp#c;**_SYmi`&z23 z`p6_~ePvH)C6x-G9$hgL=eVALq`-AiamN>!3~Lxw&{H(b{B(7xSRm6<3<{%{yXiH# zos5Rv1L+8fUKJLo%P>4I&$}y { let context = getContext(this) - this.terminateSelf(context) + terminateSelf(context) }) Text($r('app.string.publish_comments')) @@ -100,13 +101,13 @@ struct Index { if (this.isShowCamera) { Grid() { - ForEach(this.pixelMaps, (item, index) => { - GridItem() { - if (index < this.pixelMaps.length - 1) { - Image(item) - .width('100%') - .height(100) - .borderRadius(10) + ForEach(this.pixelMaps, (item:image.PixelMap,index?:number) => { + GridItem() { + if (index !==undefined && (index < this.pixelMaps.length - 1)) { + Image(item) + .width('100%') + .height(100) + .borderRadius(10) } else { Column() { diff --git a/media/Image/entry/src/main/ets/utils/utils.ts b/media/Image/entry/src/main/ets/utils/utils.ts new file mode 100644 index 00000000..ea9a1531 --- /dev/null +++ b/media/Image/entry/src/main/ets/utils/utils.ts @@ -0,0 +1,3 @@ +export function terminateSelf(context:any) { + context.terminateSelf() +} \ No newline at end of file diff --git a/media/Image/entry/src/ohosTest/ets/Application/AbilityStage.ts b/media/Image/entry/src/ohosTest/ets/Application/AbilityStage.ts deleted file mode 100644 index be959bc4..00000000 --- a/media/Image/entry/src/ohosTest/ets/Application/AbilityStage.ts +++ /dev/null @@ -1,22 +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() { - console.log("[Demo] TestAbilityStage onCreate") - } -} diff --git a/media/Image/entry/src/ohosTest/ets/Application/TestAbilityStage.ts b/media/Image/entry/src/ohosTest/ets/Application/TestAbilityStage.ts deleted file mode 100644 index 8fb2fb85..00000000 --- a/media/Image/entry/src/ohosTest/ets/Application/TestAbilityStage.ts +++ /dev/null @@ -1,25 +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' -import { logger } from '../../../../../photomodify/src/main/ets/components/util/Logger' - -const TAG: string = 'TestAbilityStage' - -export default class TestAbilityStage extends AbilityStage { - onCreate() { - logger.info(TAG, `[Demo] TestAbilityStage onCreate`) - } -} \ No newline at end of file diff --git a/media/Image/entry/src/ohosTest/ets/module.json5.ftl b/media/Image/entry/src/ohosTest/ets/module.json5.ftl deleted file mode 100644 index 57569df3..00000000 --- a/media/Image/entry/src/ohosTest/ets/module.json5.ftl +++ /dev/null @@ -1,49 +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. - */ - -{ - "module": { - "name": "${moduleName}_test", - "type": "feature", - "srcEntrance": "./ets/Application/AbilityStage.ts", - "description": "$string:entry_test_desc", - "mainElement": "TestAbility", - "deviceTypes": [${deviceTypes ?replace("[","")?replace("]","")}], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:test_pages", - "uiSyntax": "ets", - "abilities": [ - { - "name": "TestAbility", - "srcEntrance": "./ets/TestAbility/TestAbility.ts", - "description": "$string:TestAbility_desc", - "icon": "$media:icon", - "label": "$string:TestAbility_label", - "visible": true, - "skills": [ - { - "actions": [ - "action.system.home" - ], - "entities": [ - "entity.system.home" - ] - } - ] - } - ] - } -} diff --git a/media/Image/entry/src/ohosTest/ets/test/Ability.test.ets b/media/Image/entry/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100644 index 8abf7f2f..00000000 --- a/media/Image/entry/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,35 +0,0 @@ -import hilog from '@ohos.hilog'; -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' - -export default function abilityTest() { - 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) - }) - }) -} \ No newline at end of file diff --git a/media/Image/entry/src/ohosTest/ets/test/List.test.ets b/media/Image/entry/src/ohosTest/ets/test/List.test.ets deleted file mode 100644 index f7a71bf3..00000000 --- a/media/Image/entry/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +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 appTest from './app.test' - -export default function testsuite() { - appTest() -} diff --git a/media/Image/entry/src/ohosTest/ets/test/app.test.ets b/media/Image/entry/src/ohosTest/ets/test/app.test.ets deleted file mode 100644 index b2521038..00000000 --- a/media/Image/entry/src/ohosTest/ets/test/app.test.ets +++ /dev/null @@ -1,59 +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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' -import { UiDriver, BY, UiComponent, MatchPattern } from '@ohos.uitest' -import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' -import featureAbility from '@ohos.ability.featureAbility' -import hilog from '@ohos.hilog' - -const TAG = '[Sample_Image]' -const DOMAIN = 0xF811 -const BUNDLE = 'Image_' - -export default function appTest() { - describe('appTest', function () { - it(BUNDLE + 'StartAbility_001', 0, async function (done) { - hilog.info(DOMAIN, TAG, BUNDLE + 'StartAbility_001 begin') - let want = { - bundleName: "ohos.samples.image", - abilityName: "MainAbility" - } - var abilityDelegator: any - abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() - await abilityDelegator.startAbility(want, (err, data) => { - hilog.info(DOMAIN, TAG, BUNDLE + 'StartAbility_001,err.code:' + err.code) - expect(0).assertEqual(err.code) - done() - hilog.info(DOMAIN, TAG, BUNDLE + 'StartAbility_001 end') - }) - }) - - /** - * 进入预置相机进行拍照 - */ - it(BUNDLE + 'CameraFunction_001', 0, async function () { - hilog.info(DOMAIN, TAG, BUNDLE + 'CameraFunction_001 begin') - let driver = await UiDriver.create() - await driver.delayMs(1000) - hilog.info(DOMAIN, TAG, BUNDLE + 'CameraFunction_001 enter') - await driver.assertComponentExist(BY.text('允许', MatchPattern.CONTAINS)) - let btnEnter = await driver.findComponent(BY.text('允许', MatchPattern.CONTAINS)) - await btnEnter.click() - await driver.delayMs(2000) - hilog.info(DOMAIN, TAG, BUNDLE + 'CameraFunction_001 end') - }) - }) -} \ No newline at end of file diff --git a/media/Image/entry/src/ohosTest/ets/testability/TestAbility.ets b/media/Image/entry/src/ohosTest/ets/testability/TestAbility.ets deleted file mode 100644 index e3f6e911..00000000 --- a/media/Image/entry/src/ohosTest/ets/testability/TestAbility.ets +++ /dev/null @@ -1,48 +0,0 @@ -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'); - } -} \ No newline at end of file diff --git a/media/Image/entry/src/ohosTest/ets/testability/TestAbility.ts b/media/Image/entry/src/ohosTest/ets/testability/TestAbility.ts deleted file mode 100644 index 6f7f80c1..00000000 --- a/media/Image/entry/src/ohosTest/ets/testability/TestAbility.ts +++ /dev/null @@ -1,60 +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 '@ohos/hypium' -import testsuite from '../test/List.test' - -export default class TestAbility extends Ability { - onCreate(want, launchParam) { - console.log('TestAbility onCreate') - } - - onDestroy() { - console.log('TestAbility onDestroy') - } - - onWindowStageCreate(windowStage) { - console.log('TestAbility onWindowStageCreate') - windowStage.loadContent("TestAbility/pages/index", (err, data) => { - if (err.code) { - console.error('Failed to load the content. Cause:' + JSON.stringify(err)) - return - } - console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)) - }) - - globalThis.abilityContext = this.context - var abilityDelegator: any - abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() - var abilityDelegatorArguments: any - abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() - console.info('start run testcase!!!') - Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) - } - - onWindowStageDestroy() { - console.log('TestAbility onWindowStageDestroy') - } - - onForeground() { - console.log('TestAbility onForeground') - } - - onBackground() { - console.log('TestAbility onBackground') - } -} \ No newline at end of file diff --git a/media/Image/entry/src/ohosTest/ets/testability/pages/index.ets b/media/Image/entry/src/ohosTest/ets/testability/pages/index.ets deleted file mode 100644 index 7d93696f..00000000 --- a/media/Image/entry/src/ohosTest/ets/testability/pages/index.ets +++ /dev/null @@ -1,52 +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 router from '@ohos.router' - -@Entry -@Component -struct Index { - aboutToAppear() { - console.info('TestAbility index aboutToAppear') - } - - @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/media/Image/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts b/media/Image/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts deleted file mode 100644 index 7b0f409c..00000000 --- a/media/Image/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts +++ /dev/null @@ -1,78 +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 TestRunner from '@ohos.application.testRunner' -import AbilityDelegatorRegistry from '@ohos.application.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', - '-s dryRun' - ]) - let targetParams = '' - for (const key in parameters) { - if (keySet.has(key)) { - targetParams = `${targetParams} ${key} ${parameters[key]}` - } - } - return targetParams.trim() -} - -async function onAbilityCreateCallback() { - console.log("onAbilityCreateCallback") -} - -async function addAbilityMonitorCallback(err: any) { - console.info("addAbilityMonitorCallback : " + JSON.stringify(err)) -} - -export default class OpenHarmonyTestRunner implements TestRunner { - constructor() { - } - - onPrepare() { - console.info("OpenHarmonyTestRunner OnPrepare ") - } - - async onRun() { - console.log('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 - cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters) - var debug = abilityDelegatorArguments.parameters["-D"] - if (debug == 'true') { - cmd += ' -D' - } - console.info('cmd : ' + cmd) - abilityDelegator.executeShellCommand(cmd, - (err: any, d: any) => { - console.info('executeShellCommand : err : ' + JSON.stringify(err)) - console.info('executeShellCommand : data : ' + d.stdResult) - console.info('executeShellCommand : data : ' + d.exitCode) - }) - console.info('OpenHarmonyTestRunner onRun end') - } -} \ No newline at end of file diff --git a/media/Image/entry/src/ohosTest/module.json5 b/media/Image/entry/src/ohosTest/module.json5 deleted file mode 100644 index 187f19d5..00000000 --- a/media/Image/entry/src/ohosTest/module.json5 +++ /dev/null @@ -1,54 +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. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "srcEntrance": "./ets/TestAbility/TestAbility.ts", - "description": "$string:entry_test_desc", - "mainElement": "TestAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:test_pages", - "uiSyntax": "ets", - "abilities": [ - { - "name": "TestAbility", - "srcEntrance": "./ets/TestAbility/TestAbility.ts", - "description": "$string:TestAbility_desc", - "icon": "$media:icon", - "label": "$string:TestAbility_label", - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:white", - "visible": true, - "skills": [ - { - "actions": [ - "action.system.home" - ], - "entities": [ - "entity.system.home" - ] - } - ] - } - ] - } -} diff --git a/media/Image/entry/src/ohosTest/resources/base/element/color.json b/media/Image/entry/src/ohosTest/resources/base/element/color.json deleted file mode 100644 index 1bbc9aa9..00000000 --- a/media/Image/entry/src/ohosTest/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "white", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/media/Image/entry/src/ohosTest/resources/base/element/string.json b/media/Image/entry/src/ohosTest/resources/base/element/string.json deleted file mode 100644 index 36d4230c..00000000 --- a/media/Image/entry/src/ohosTest/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "entry_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/media/Image/entry/src/ohosTest/resources/base/media/icon.png b/media/Image/entry/src/ohosTest/resources/base/media/icon.png deleted file mode 100644 index ce307a8827bd75456441ceb57d530e4c8d45d36c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6790 zcmX|G1ymHk)?T_}Vd;>R?p|tHQo6fg38|$UVM!6BLrPFWk?s;$LOP{GmJpBl$qoSA!PUg~PA65-S00{{S`XKG6NkG0RgjEntPrmV+?0|00mu7;+5 zrdpa{2QLqPJ4Y{j7=Mrl{BaxrkdY69+c~(w{Fv-v&aR%aEI&JYSeRTLWm!zbv;?)_ ziZB;fwGbbeL5Q}YLx`J$lp~A09KK8t_z}PZ=4ZzgdeKtgoc+o5EvN9A1K1_<>M?MBqb#!ASf&# zEX?<)!RH(7>1P+j=jqG(58}TVN-$psA6K}atCuI!KTJD&FMmH-78ZejBm)0qc{ESp z|LuG1{QnBUJRg_E=h1#XMWt2%fcoN@l7eAS!Es?Q+;XsRNPhiiE=@AqlLkJzF`O18 zbsbSmKN=aaq8k3NFYZfDWpKmM!coBU0(XnL8R{4=i|wi{!uWYM2je{U{B*K2PVdu&=E zTq*-XsEsJ$u5H4g6DIm2Y!DN`>^v|AqlwuCD;w45K0@eqauiqWf7l&o)+YLHm~|L~ z7$0v5mkobriU!H<@mVJHLlmQqzQ3d6Rh_-|%Yy2li*tHO>_vcnuZ7OR_xkAIuIU&x z-|8Y0wj|6|a6_I(v91y%k_kNw6pnkNdxjqG8!%Vz_d%c_!X+6-;1`GC9_FpjoHev5fEV7RhJ>r=mh-jp$fqbqRJ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pekhe2WM(8s{xv-p>Zmu_6{G!-oE$7$mY`MOJorI=+mMx?H;`pr!;fVYz?5~yXBACruWB`Ph zZM}90_<^OBxIhyZ9BW$`>6JvO;%VFpqVr8|7t3~AmxYak6?`Pp#c;**_SYmi`&z23 z`p6_~ePvH)C6x-G9$hgL=eVALq`-AiamN>!3~Lxw&{H(b{B(7xSRm6<3<{%{yXiH# zos5Rv1L+8fUKJLo%P>4I&$}y = [true, false] - @State medias: Array = [] - @State choiceShow: Array = [$r('app.string.choice_photo'), $r('app.string.choice_video')] - @State taskShow: Array = [$r('app.media.photo'), $r('app.media.video')] - @State textShow: Array = [$r('app.string.photograph'), $r('app.string.take_video')] - @State isShowChoices: Array = new Array(this.medias.length).fill(false) - @State @Watch('choiceChange') choiceMedias: Array = [] - @State mediaUris: Array = [] - @State isChoice: boolean = false - @State nextText: string = '' - @State isLand: boolean = false - private mediaLibraryInstance: mediaLibrary.MediaLibrary = mediaLibrary.getMediaLibrary(getContext(this) as any) + @State whichShow:boolean[] = [true, false] + @State medias:Array = [] + @State choiceShow:Array = [$r('app.string.choice_photo'), $r('app.string.choice_video')] + @State taskShow:Array = [$r('app.media.photo'), $r('app.media.video')] + @State textShow:Array = [$r('app.string.photograph'), $r('app.string.take_video')] + @State isShowChoices:Array = new Array(this.medias.length).fill(false) + @State @Watch('choiceChange') choiceMedias:Array = [] + @State mediaUris:Array = [] + @State isChoice:boolean = false + @State nextText:string = '' + @State isLand:boolean = false + private mediaLibraryInstance:mediaLibrary.MediaLibrary = mediaLibrary.getMediaLibrary(getContext(this)) private listener = mediaQuery.matchMediaSync('screen and (min-aspect-ratio: 1.5) or (orientation: landscape)') - onLand = (mediaQueryResult) => { + + onLand(mediaQueryResult:mediaQuery.MediaQueryResult) { if (mediaQueryResult.matches) { this.isLand = true } else { @@ -52,7 +53,8 @@ export struct ChoicePhoto { } } - @Builder showChoiceBuild(backGround: string, showNumber: number) { + @Builder + showChoiceBuild(backGround:string, showNumber:number) { Column() { Text(showNumber === 0 ? '' : `${showNumber}`) .fontSize(14) @@ -68,16 +70,16 @@ export struct ChoicePhoto { .backgroundColor(backGround) } - async getFileAssetsFromType(mediaType: mediaLibrary.MediaType) { + async getFileAssetsFromType(mediaType:mediaLibrary.MediaType) { logger.info(TAG, `getFileAssetsFromType`) - let context = getContext(this) as any + let context = getContext(this) as Context let mediaLibraryInstance = mediaLibrary.getMediaLibrary(context) if (!mediaLibraryInstance) { return } logger.info(TAG, `mediaLibraryInstance = ${JSON.stringify(mediaLibraryInstance)}`) let fileKeyObj = mediaLibrary.FileKey - let fetchOp = { + let fetchOp:mediaLibrary.MediaFetchOptions = { selections: `${fileKeyObj.MEDIA_TYPE}=?`, selectionArgs: [`${mediaType}`], } @@ -89,12 +91,12 @@ export struct ChoicePhoto { logger.info(TAG, `this.medias = ${JSON.stringify(this.medias)}`) } - convertContext(context: any) { + convertContext(context:Context):Context { return context } - async convertResourceToString(resource: Resource) { - return await this.convertContext(getContext(this)).resourceManager.getString(resource) + async convertResourceToString(resource:Resource):Promise { + return await this.convertContext(getContext(this)).resourceManager.getString(resource.id) } async aboutToAppear() { @@ -104,14 +106,14 @@ export struct ChoicePhoto { this.getFileAssetsFromType(mediaLibrary.MediaType.IMAGE) } - getMaxHeight() { + getMaxHeight():ConstraintSizeOptions { if (!this.isLand && this.isChoice) { return { maxHeight: '64%' } } else if (!this.isLand && !this.isChoice) { return { maxHeight: '75%' } } else if (this.isLand && this.isChoice) { return { maxHeight: '62%' } - } else if (this.isLand && !this.isChoice) { + } else { return { maxHeight: '73%' } } } @@ -150,7 +152,7 @@ export struct ChoicePhoto { if (this.isChoice === false) { return } - this.mediaUris = this.choiceMedias.map((item) => { + this.mediaUris = this.choiceMedias.map((item:mediaLibrary.FileAsset) => { return item.uri }) router.push({ @@ -167,37 +169,40 @@ export struct ChoicePhoto { Column() { Row() { - ForEach(this.choiceShow, (item, index) => { + ForEach(this.choiceShow, (item:Resource, index?:number) => { Column() { - Text(item) - .fontSize(20) - .fontWeight(500) - .fontColor(this.whichShow[index] === true ? '#0000000' : '#99182431') - .onClick(() => { - this.whichShow.fill(false) - if (this.whichShow.length > index) { - this.whichShow[index] = true - } - this.medias = [] - if (index == 0) { - this.getFileAssetsFromType(mediaLibrary.MediaType.IMAGE) - } else { - prompt.showDialog({ message: $r('app.string.user_tip') }) - this.choiceMedias = [] - this.isShowChoices = new Array(this.medias.length).fill(false) - } - }) - if (this.whichShow[index]) { - Divider() - .vertical(false) - .strokeWidth(3) - .color('#ffff0000') - .lineCap(LineCapStyle.Round) - .width('40%') - .margin({ top: 4 }) + if (index !== undefined) { + Text(item) + .fontSize(20) + .fontWeight(500) + .fontColor(this.whichShow[index] === true ? '#0000000' : '#99182431') + .onClick(() => { + this.whichShow.fill(false) + if (this.whichShow.length > index) { + if (index) { + this.whichShow[index] = true + } + } + this.medias = [] + if (index == 0) { + this.getFileAssetsFromType(mediaLibrary.MediaType.IMAGE) + } else { + prompt.showDialog({ message: $r('app.string.user_tip') }) + this.choiceMedias = [] + this.isShowChoices = new Array(this.medias.length).fill(false) + } + }) + if (this.whichShow[index]) { + Divider() + .vertical(false) + .strokeWidth(3) + .color('#ffff0000') + .lineCap(LineCapStyle.Round) + .width('40%') + .margin({ top: 4 }) + } } - } - .width('30%') + }.width('30%') }) } .margin({ top: 20 }) @@ -206,7 +211,7 @@ export struct ChoicePhoto { Scroll() { Column() { Grid() { - ForEach(this.medias, (item, index) => { + ForEach(this.medias, (item:mediaLibrary.FileAsset, index?:number) => { GridItem() { Stack({ alignContent: Alignment.TopEnd }) { Image(item.uri) @@ -214,8 +219,7 @@ export struct ChoicePhoto { .height('100%') .borderRadius(10) .objectFit(ImageFit.Fill) - - if (this.isShowChoices[index]) { + if (index !== undefined && this.isShowChoices[index]) { this.showChoiceBuild('#e92f4f', this.choiceMedias.indexOf(item) + 1) } else { this.showChoiceBuild('#ffb7b4b4', 0) @@ -224,22 +228,24 @@ export struct ChoicePhoto { .width('100%') .height('100%') .onClick(() => { - this.isShowChoices[index] = !this.isShowChoices[index] - if (this.isShowChoices[index]) { - if (this.choiceMedias.length > 5) { - prompt.showDialog({ message: $r('app.string.choice_number') }) - this.isShowChoices[index] = !this.isShowChoices[index] - return - } - this.choiceMedias.push(item) - } else { - if (this.choiceMedias.indexOf(item) != -1) { - this.choiceMedias.splice(this.choiceMedias.indexOf(item), 1) + if (index !== undefined) { + this.isShowChoices[index] = !this.isShowChoices[index] + if (this.isShowChoices[index]) { + if (this.choiceMedias.length > 5) { + prompt.showDialog({ message: $r('app.string.choice_number') }) + this.isShowChoices[index] = !this.isShowChoices[index] + return + } + this.choiceMedias.push(item) + } else { + if (this.choiceMedias.indexOf(item) != -1) { + this.choiceMedias.splice(this.choiceMedias.indexOf(item), 1) + } } } }) - } - .aspectRatio(1) + }.aspectRatio(1) + }) } .columnsTemplate('1fr 1fr 1fr 1fr') @@ -257,7 +263,7 @@ export struct ChoicePhoto { if (this.isChoice) { Grid() { - ForEach(this.choiceMedias, (item, index) => { + ForEach(this.choiceMedias, (item:mediaLibrary.FileAsset, index?:number) => { GridItem() { Stack({ alignContent: Alignment.TopEnd }) { Image(item.uri) @@ -269,12 +275,14 @@ export struct ChoicePhoto { .height(20) .margin({ top: 5, right: 5 }) .onClick(() => { - for (let i = 0;i < this.medias.length; i++) { - if (this.choiceMedias[index] && this.isShowChoices.length > i && this.medias[i] === this.choiceMedias[index]) { - this.isShowChoices[i] = false + if (index !== undefined) { + for (let i = 0;i < this.medias.length; i++) { + if (this.choiceMedias[index] && this.isShowChoices.length > i && this.medias[i] === this.choiceMedias[index]) { + this.isShowChoices[i] = false + } } + this.choiceMedias.splice(index, 1) } - this.choiceMedias.splice(index, 1) }) } .width('100%') @@ -298,18 +306,19 @@ export struct ChoicePhoto { } Row() { - ForEach(this.taskShow, (item, index) => { - Column() { - Image(item) - .width(30) - .height(30) + ForEach(this.taskShow, (item:Resource, index?:number) => { + if (index !== undefined) { + Column() { + Image(item) + .width(30) + .height(30) - Text(this.textShow[index]) - .fontSize(14) - .fontColor('#99182431') - .margin({ top: 2 }) + Text(this.textShow[index]) + .fontSize(14) + .fontColor('#99182431') + .margin({ top: 2 }) + }.width('50%') } - .width('50%') }) } .margin({ top: 8 }) diff --git a/media/Image/photomodify/src/main/ets/components/pages/EditPage.ets b/media/Image/photomodify/src/main/ets/components/pages/EditPage.ets index ddf525dc..506db42f 100644 --- a/media/Image/photomodify/src/main/ets/components/pages/EditPage.ets +++ b/media/Image/photomodify/src/main/ets/components/pages/EditPage.ets @@ -18,47 +18,52 @@ import image from '@ohos.multimedia.image' import mediaLibrary from '@ohos.multimedia.mediaLibrary' import { logger } from '../util/Logger' -const TAG: string = 'EditPage' +const TAG:string = 'EditPage' + + +interface MediaUris extends Object { + mediaUris:Array + isLand:boolean +} @Component export struct EditPage { - @State mediaUris: Array = router.getParams()['mediaUris'] - @State pixelMaps: Array = [] - @State tasks: Array = [$r('app.media.scale'), $r('app.media.crop'), $r('app.media.rotate')] - @State tempTasks: Array = [$r('app.media.scale'), $r('app.media.crop'), $r('app.media.rotate')] - @State choiceTasks: Array = [$r('app.media.scale_red'), $r('app.media.crop_red'), $r('app.media.rotate_red')] - @State taskText: Array = [$r('app.string.scale'), $r('app.string.crop'), $r('app.string.rotate')] - @State cropRatios: Array = [$r('app.string.origin_photo'), $r('app.string.proportion_one_one'), $r('app.string.proportion_three_four'), $r('app.string.proportion_nine_sixth')] - @State cropMedias: Array = [$r('app.media.origin_gray'), $r('app.media.one_one_gray'), $r('app.media.three_four_gray'), $r('app.media.nine_sixth_gray')] - @State tempCropMedias: Array = [$r('app.media.origin_gray'), $r('app.media.one_one_gray'), $r('app.media.three_four_gray'), $r('app.media.nine_sixth_gray')] - @State cropChoiceMedias: Array = [$r('app.media.origin_red'), $r('app.media.one_one_red'), $r('app.media.three_four_red'), $r('app.media.nine_sixth_red')] - @State scaleTexts: Array = [$r('app.string.narrow'), $r('app.string.amplification')] - @State scaleMedias: Array = [$r('app.media.scale_small'), $r('app.media.scale_big')] - @State cropFrontShows: Array = new Array(4).fill(false) - @State tasksFrontShows: Array = new Array(3).fill(false) - @State borderShows: Array = new Array(this.mediaUris.length).fill(false) - @State pixelMap: image.PixelMap = undefined - @State tempPixelMap: image.PixelMap = undefined - @State single: number = 0 - @State isCrop: boolean = false - @State isScale: boolean = false - @State scaleSliderValue: number = 0 - @State selectIndex: number = 0 - @State isLand: boolean = false - private mediaLibraryInstance: mediaLibrary.MediaLibrary = mediaLibrary.getMediaLibrary(getContext(this) as any) - + @State mediaUris:Array = (router.getParams() as MediaUris).mediaUris + @State pixelMaps:Array = [] + @State tasks:Array = [$r('app.media.scale'), $r('app.media.crop'), $r('app.media.rotate')] + @State tempTasks:Array = [$r('app.media.scale'), $r('app.media.crop'), $r('app.media.rotate')] + @State choiceTasks:Array = [$r('app.media.scale_red'), $r('app.media.crop_red'), $r('app.media.rotate_red')] + @State taskText:Array = [$r('app.string.scale'), $r('app.string.crop'), $r('app.string.rotate')] + @State cropRatios:Array = [$r('app.string.origin_photo'), $r('app.string.proportion_one_one'), $r('app.string.proportion_three_four'), $r('app.string.proportion_nine_sixth')] + @State cropMedias:Array = [$r('app.media.origin_gray'), $r('app.media.one_one_gray'), $r('app.media.three_four_gray'), $r('app.media.nine_sixth_gray')] + @State tempCropMedias:Array = [$r('app.media.origin_gray'), $r('app.media.one_one_gray'), $r('app.media.three_four_gray'), $r('app.media.nine_sixth_gray')] + @State cropChoiceMedias:Array = [$r('app.media.origin_red'), $r('app.media.one_one_red'), $r('app.media.three_four_red'), $r('app.media.nine_sixth_red')] + @State scaleTexts:Array = [$r('app.string.narrow'), $r('app.string.amplification')] + @State scaleMedias:Array = [$r('app.media.scale_small'), $r('app.media.scale_big')] + @State cropFrontShows:Array = new Array(4).fill(false) + @State tasksFrontShows:Array = new Array(3).fill(false) + @State borderShows:Array = new Array(this.mediaUris.length).fill(false) + @State pixelMap:image.PixelMap = {} as image.PixelMap + @State tempPixelMap:image.PixelMap = {} as image.PixelMap + @State single:number = 0 + @State isCrop:boolean = false + @State isScale:boolean = false + @State scaleSliderValue:number = 0 + @State selectIndex:number = 0 + @State isLand:boolean = false + private mediaLibraryInstance:mediaLibrary.MediaLibrary = mediaLibrary.getMediaLibrary(getContext(this) as Context) flushPage() { this.tempPixelMap = this.pixelMap - this.pixelMap = undefined + this.pixelMap = {} as image.PixelMap this.pixelMap = this.tempPixelMap } - async queryFile(dataUri: string) { + async queryFile(dataUri:string):Promise { logger.info(TAG, `enter queryFile`) let fileKeyObj = mediaLibrary.FileKey logger.info(TAG, `fileKeyObj = ${fileKeyObj}`) - let fetchOp = { + let fetchOp:mediaLibrary.MediaFetchOptions = { selections: '', selectionArgs: [], uri: dataUri @@ -66,39 +71,39 @@ export struct EditPage { const fetchFileResult = await this.mediaLibraryInstance.getFileAssets(fetchOp) logger.info(TAG, `fetchFileResult = ${JSON.stringify(fetchFileResult)} ,count = ${JSON.stringify(fetchFileResult.getCount())}`) if (!fetchFileResult) { - return + return {} as mediaLibrary.FileAsset } const fileAsset = await fetchFileResult.getFirstObject() if (!fileAsset) { - return + return {} as mediaLibrary.FileAsset } logger.info(TAG, `fileAsset = ${JSON.stringify(fileAsset)}`) return fileAsset } - async getPixelMap(uri: string) { - let fileAssert: mediaLibrary.FileAsset = await this.queryFile(uri) + async getPixelMap(uri:string):Promise { + let fileAssert:mediaLibrary.FileAsset = await this.queryFile(uri) if (!fileAssert) { - return + return {} as image.PixelMap } let fd = await fileAssert.open('Rw') if (!fd) { - return + return {} as image.PixelMap } logger.info(TAG, `fd = ${fd}`) let imageSourceApi = image.createImageSource(fd) if (!imageSourceApi) { - return + return {} as image.PixelMap } let pixmap = await imageSourceApi.createPixelMap() if (!pixmap) { - return + return {} as image.PixelMap } return pixmap } - async cropImage(proportion: number) { - let imageInfo: image.ImageInfo = await this.pixelMap.getImageInfo() + async cropImage(proportion:number) { + let imageInfo:image.ImageInfo = await this.pixelMap.getImageInfo() if (!imageInfo) { return } @@ -127,10 +132,11 @@ export struct EditPage { } async aboutToAppear() { - logger.info(TAG, `enter aboutToAppear uris = ${JSON.stringify(router.getParams()['mediaUris'])}`) + logger.info(TAG, `enter aboutToAppear uris = ${JSON.stringify(this.mediaUris)}`) this.pixelMaps = [] - if(router.getParams() && router.getParams()['isLand']){ - this.isLand = router.getParams()['isLand'] + + if (router.getParams() && (router.getParams() as MediaUris).isLand) { + this.isLand = (router.getParams() as MediaUris).isLand } for (let i = 0; i < this.mediaUris.length; i++) { let pixelMap = await this.getPixelMap(this.mediaUris[i]) @@ -198,29 +204,31 @@ export struct EditPage { if (!this.isCrop && !this.isScale) { Row() { - ForEach(this.pixelMaps, (item, index) => { - Image(item) - .width(60) - .height(60) - .borderRadius(15) - .margin({ left: 8 }) - .border({ - style: BorderStyle.Solid, - width: 2, - color: (this.borderShows[index] === true ? '#e92f4f' : '#ffffff') - }) - .onClick(async () => { - if (this.pixelMap === item) { - return - } - this.borderShows.fill(false) - if (this.borderShows.length > index) { - this.borderShows[index] = true - } - this.single = 0 - this.pixelMap = item - this.selectIndex = index - }) + ForEach(this.pixelMaps, (item:image.PixelMap, index?:number) => { + if (index !== undefined) { + Image(item) + .width(60) + .height(60) + .borderRadius(15) + .margin({ left: 8 }) + .border({ + style: BorderStyle.Solid, + width: 2, + color: (this.borderShows[index] === true ? '#e92f4f' : '#ffffff') + }) + .onClick(async () => { + if (this.pixelMap === item) { + return + } + this.borderShows.fill(false) + if (this.borderShows.length > index) { + this.borderShows[index] = true + } + this.single = 0 + this.pixelMap = item + this.selectIndex = index + }) + } }) Row() { Image($r('app.media.add')) @@ -244,40 +252,44 @@ export struct EditPage { } else if (this.isCrop) { Row() { - ForEach(this.cropMedias, (item, index) => { + ForEach(this.cropMedias, (item:Resource, index?:number) => { Column() { Image(item) .width(30) .height(30) - Text(this.cropRatios[index]) - .fontSize(15) - .fontColor(this.cropFrontShows[index] === true ? '#e92f4f' : '#acabab') - .margin({ top: 5 }) + if (index !== undefined) { + Text(this.cropRatios[index]) + .fontSize(15) + .fontColor(this.cropFrontShows[index] === true ? '#e92f4f' : '#acabab') + .margin({ top: 5 }) + } } .layoutWeight(1) .onClick(async () => { - this.cropMedias = this.tempCropMedias.map((item) => { + this.cropMedias = this.tempCropMedias.map((item:Resource) => { return item }) - if (index === 0) { - if (this.mediaUris.length > this.selectIndex && this.pixelMaps.length > this.selectIndex) { - this.pixelMap = await this.getPixelMap(this.mediaUris[this.selectIndex]) - this.pixelMaps[this.selectIndex] = this.pixelMap + if (index !== undefined) { + if (index === 0) { + if (this.mediaUris.length > this.selectIndex && this.pixelMaps.length > this.selectIndex) { + this.pixelMap = await this.getPixelMap(this.mediaUris[this.selectIndex]) + this.pixelMaps[this.selectIndex] = this.pixelMap + } + } + else if (index === 1) { + await this.cropImage(1) + } else if (index === 2) { + await this.cropImage(3 / 4) + } else if (index === 3) { + await this.cropImage(9 / 16) + } + if (this.cropMedias.length > index && this.cropChoiceMedias.length > index) { + this.cropMedias[index] = this.cropChoiceMedias[index] + } + this.cropFrontShows.fill(false) + if (this.cropFrontShows.length > index) { + this.cropFrontShows[index] = true } - } - else if (index === 1) { - await this.cropImage(1) - } else if (index === 2) { - await this.cropImage(3 / 4) - } else if (index === 3) { - await this.cropImage(9 / 16) - } - if (this.cropMedias.length > index && this.cropChoiceMedias.length > index) { - this.cropMedias[index] = this.cropChoiceMedias[index] - } - this.cropFrontShows.fill(false) - if (this.cropFrontShows.length > index) { - this.cropFrontShows[index] = true } }) }) @@ -286,24 +298,26 @@ export struct EditPage { .margin({ top: 15 }) } else if (this.isScale) { Row() { - ForEach(this.scaleMedias, (item, index) => { - Column() { - Image(item) - .height(30) - .width(30) - Text(this.scaleTexts[index]) - .fontSize(15) - .margin({ top: 5 }) - } - .layoutWeight(1) - .onClick(async () => { - if (index === 0) { - await this.pixelMap.scale(0.8, 0.8) - } else if (index === 1) { - await this.pixelMap.scale(1.25, 1.25) + ForEach(this.scaleMedias, (item:Resource, index?:number) => { + if (index !== undefined) { + Column() { + Image(item) + .height(30) + .width(30) + Text(this.scaleTexts[index]) + .fontSize(15) + .margin({ top: 5 }) } - this.flushPage() - }) + .layoutWeight(1) + .onClick(async () => { + if (index === 0) { + await this.pixelMap.scale(0.8, 0.8) + } else if (index === 1) { + await this.pixelMap.scale(1.25, 1.25) + } + this.flushPage() + }) + } }) } .width('100%') @@ -325,47 +339,49 @@ export struct EditPage { .margin({ top: 8 }) Row() { - ForEach(this.tasks, (item, index) => { - Column() { - Image(item) - .width(30) - .height(30) - Text(this.taskText[index]) - .fontSize(15) - .fontColor(this.tasksFrontShows[index] === true ? '#e92f4f' : '#acabab') - } - .height(60) - .width(60) - .layoutWeight(1) - .onClick(async () => { - if (index === 0) { - this.isScale = !this.isScale - this.isCrop = false - } else if (index === 1) { - this.isCrop = !this.isCrop - this.isScale = false - } else if (index === 2) { - await this.pixelMap.rotate(90) - this.isCrop = false - this.isScale = false - this.flushPage() - - } - this.tasksFrontShows.fill(false) - if (this.tasksFrontShows.length > index) { - this.tasksFrontShows[index] = true - } - this.tasks = this.tempTasks.map((item) => { - return item - }) - if (this.tasks.length > index && this.choiceTasks.length > index) { - this.tasks[index] = this.choiceTasks[index] + ForEach(this.tasks, (item:Resource, index?:number) => { + if (index !== undefined) { + Column() { + Image(item) + .width(30) + .height(30) + Text(this.taskText[index]) + .fontSize(15) + .fontColor(this.tasksFrontShows[index] === true ? '#e92f4f' : '#acabab') } - this.cropFrontShows.fill(false) - this.cropMedias = this.tempCropMedias.map((item) => { - return item + .height(60) + .width(60) + .layoutWeight(1) + .onClick(async () => { + if (index === 0) { + this.isScale = !this.isScale + this.isCrop = false + } else if (index === 1) { + this.isCrop = !this.isCrop + this.isScale = false + } else if (index === 2) { + await this.pixelMap.rotate(90) + this.isCrop = false + this.isScale = false + this.flushPage() + + } + this.tasksFrontShows.fill(false) + if (this.tasksFrontShows.length > index) { + this.tasksFrontShows[index] = true + } + this.tasks = this.tempTasks.map((item:Resource) => { + return item + }) + if (this.tasks.length > index && this.choiceTasks.length > index) { + this.tasks[index] = this.choiceTasks[index] + } + this.cropFrontShows.fill(false) + this.cropMedias = this.tempCropMedias.map((item:Resource) => { + return item + }) }) - }) + } }) } .width('100%') diff --git a/media/ImageShow/entry/src/main/ets/MainAbility/MainAbility.ts b/media/ImageShow/entry/src/main/ets/MainAbility/MainAbility.ts index 33d8802c..5febe675 100644 --- a/media/ImageShow/entry/src/main/ets/MainAbility/MainAbility.ts +++ b/media/ImageShow/entry/src/main/ets/MainAbility/MainAbility.ts @@ -16,6 +16,7 @@ import Ability from '@ohos.app.ability.UIAbility' import abilityAccessCtrl from '@ohos.abilityAccessCtrl' import Logger from '../../../../../imagelibrary/src/main/ets/components/data/Logger' +import window from '@ohos.window' const TAG: string = 'MainAbility' diff --git a/media/ImageShow/entry/src/main/ets/pages/Index.ets b/media/ImageShow/entry/src/main/ets/pages/Index.ets index 8f5d8988..5723eb4e 100644 --- a/media/ImageShow/entry/src/main/ets/pages/Index.ets +++ b/media/ImageShow/entry/src/main/ets/pages/Index.ets @@ -14,36 +14,48 @@ */ import router from '@ohos.router' +import { DrawableDescriptor } from '@ohos.arkui.drawableDescriptor'; import Logger from '../../../../../imagelibrary/src/main/ets/components/data/Logger' - +import {terminateSelf} from '../utils/utils' const TAG: string = 'Index' + + +interface paramsType{ + mediaUris: Array +} +class routerParamsType{ + isShowCamera?:boolean; + mediaUris?: Array +} + @Entry @Component struct Index { - @State mediaUris: Array = [] + @State mediaUris: Array= [] @State stars: Array = new Array(5).fill(false) @State countStar: number = 0 @State isShowCamera: boolean = false @State isShowComment: boolean = true + private params = router.getParams() as routerParamsType + private paramsObj: paramsType = { + mediaUris: this.mediaUris + } async onPageShow() { Logger.info(TAG, 'enter onPageShow') - if (router.getParams()['isShowCamera'] !== undefined && router.getParams()['isShowCamera'] !== null) { - this.isShowCamera = router.getParams()['isShowCamera'] + if (this.params.isShowCamera !== undefined && this.params.isShowCamera !== null ) { + this.isShowCamera = this.params.isShowCamera Logger.info(TAG, `this.isShowCamera = ${this.isShowCamera}`) } - if (router.getParams()['mediaUris'] !== undefined && router.getParams()['mediaUris'] !== null) { - this.mediaUris = router.getParams()['mediaUris'] + if (this.params.mediaUris !== undefined && this.params.mediaUris !== null) { + this.mediaUris = this.params.mediaUris this.mediaUris.push('') } Logger.info(TAG, 'end onPageShow') } - terminateSelf(context: any) { - context.terminateSelf() - } build() { Column() { @@ -54,16 +66,14 @@ struct Index { .objectFit(ImageFit.Contain) .onClick(() => { let context = getContext(this) - this.terminateSelf(context) + terminateSelf(context) }) Text($r('app.string.publish_comments')) .fontSize(22) .margin({ left: 130 }) .textAlign(TextAlign.Center) - Blank() - Button($r('app.string.submit')) .fontSize(20) .height(32) @@ -106,34 +116,36 @@ struct Index { if (this.isShowCamera) { Grid() { - ForEach(this.mediaUris, (item, index) => { - GridItem() { - if (index < this.mediaUris.length - 1) { - Image(item) + ForEach(this.mediaUris, (item: PixelMap | ResourceStr | DrawableDescriptor, index?: number) => { + if(typeof index !=="undefined"){ + GridItem() { + if (index < this.mediaUris.length - 1) { + Image(item) + .width('100%') + .height(100) + .borderRadius(10) + + } else { + Column() { + Image($r('app.media.photo')) + .height(40) + .width(40) + .onClick(() => { + router.push({ + url: 'pages/ChoicePhoto', + params: this.paramsObj + }) + }) + Text($r('app.string.add_picture')) + .fontSize(13) + } + .alignItems(HorizontalAlign.Center) + .justifyContent(FlexAlign.Center) .width('100%') .height(100) .borderRadius(10) - - } else { - Column() { - Image($r('app.media.photo')) - .height(40) - .width(40) - .onClick(() => { - router.push({ - url: 'pages/ChoicePhoto', - params: { 'mediaUris': this.mediaUris } - }) - }) - Text($r('app.string.add_picture')) - .fontSize(13) + .backgroundColor('#F1F3F5') } - .alignItems(HorizontalAlign.Center) - .justifyContent(FlexAlign.Center) - .width('100%') - .height(100) - .borderRadius(10) - .backgroundColor('#F1F3F5') } } }) diff --git a/media/ImageShow/entry/src/main/ets/utils/utils.ts b/media/ImageShow/entry/src/main/ets/utils/utils.ts new file mode 100644 index 00000000..003caa6b --- /dev/null +++ b/media/ImageShow/entry/src/main/ets/utils/utils.ts @@ -0,0 +1,4 @@ + +export function terminateSelf(context:any) { + context.terminateSelf() +} diff --git a/media/ImageShow/entry/src/ohosTest/ets/Application/AbilityStage.ts b/media/ImageShow/entry/src/ohosTest/ets/Application/AbilityStage.ts deleted file mode 100644 index 50cd4e95..00000000 --- a/media/ImageShow/entry/src/ohosTest/ets/Application/AbilityStage.ts +++ /dev/null @@ -1,25 +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" -import Logger from '../../../../../imagelibrary/src/main/ets/components/data/Logger' - -const TAG: string = 'TestAbilityStage' - -export default class TestAbilityStage extends AbilityStage { - onCreate() { - Logger.info(TAG, `[Demo] TestAbilityStage onCreate`) - } -} \ No newline at end of file diff --git a/media/ImageShow/entry/src/ohosTest/ets/Application/TestAbilityStage.ts b/media/ImageShow/entry/src/ohosTest/ets/Application/TestAbilityStage.ts deleted file mode 100644 index fc6f95c5..00000000 --- a/media/ImageShow/entry/src/ohosTest/ets/Application/TestAbilityStage.ts +++ /dev/null @@ -1,25 +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' -import Logger from '../../../../../imagelibrary/src/main/ets/components/data/Logger' - -const TAG: string = 'TestAbilityStage' - -export default class TestAbilityStage extends AbilityStage { - onCreate() { - Logger.info(TAG, `[Demo] TestAbilityStage onCreate`) - } -} \ No newline at end of file diff --git a/media/ImageShow/entry/src/ohosTest/ets/module.json5.ftl b/media/ImageShow/entry/src/ohosTest/ets/module.json5.ftl deleted file mode 100644 index 57569df3..00000000 --- a/media/ImageShow/entry/src/ohosTest/ets/module.json5.ftl +++ /dev/null @@ -1,49 +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. - */ - -{ - "module": { - "name": "${moduleName}_test", - "type": "feature", - "srcEntrance": "./ets/Application/AbilityStage.ts", - "description": "$string:entry_test_desc", - "mainElement": "TestAbility", - "deviceTypes": [${deviceTypes ?replace("[","")?replace("]","")}], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:test_pages", - "uiSyntax": "ets", - "abilities": [ - { - "name": "TestAbility", - "srcEntrance": "./ets/TestAbility/TestAbility.ts", - "description": "$string:TestAbility_desc", - "icon": "$media:icon", - "label": "$string:TestAbility_label", - "visible": true, - "skills": [ - { - "actions": [ - "action.system.home" - ], - "entities": [ - "entity.system.home" - ] - } - ] - } - ] - } -} diff --git a/media/ImageShow/entry/src/ohosTest/ets/test/Ability.test.ets b/media/ImageShow/entry/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100644 index a33c8ba8..00000000 --- a/media/ImageShow/entry/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,31 +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 { describe, it, expect } from '@ohos/hypium' -import Logger from '../../../../../imagelibrary/src/main/ets/components/data/Logger' - -const TAG: string = 'abilityTest' - -export default function abilityTest() { - describe('ActsAbilityTest', function () { - it('assertContain', 0, function () { - Logger.info(TAG, `it begin`) - let a = 'abc' - let b = 'b' - expect(a).assertContain(b) - expect(a).assertEqual(a) - }) - }) -} \ No newline at end of file diff --git a/media/ImageShow/entry/src/ohosTest/ets/test/List.test.ets b/media/ImageShow/entry/src/ohosTest/ets/test/List.test.ets deleted file mode 100644 index 7e05ea60..00000000 --- a/media/ImageShow/entry/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,20 +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 abilityTest from './Ability.test' - -export default function testsuite() { - abilityTest() -} \ No newline at end of file diff --git a/media/ImageShow/entry/src/ohosTest/ets/testability/TestAbility.ets b/media/ImageShow/entry/src/ohosTest/ets/testability/TestAbility.ets deleted file mode 100644 index e3f6e911..00000000 --- a/media/ImageShow/entry/src/ohosTest/ets/testability/TestAbility.ets +++ /dev/null @@ -1,48 +0,0 @@ -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'); - } -} \ No newline at end of file diff --git a/media/ImageShow/entry/src/ohosTest/ets/testability/TestAbility.ts b/media/ImageShow/entry/src/ohosTest/ets/testability/TestAbility.ts deleted file mode 100644 index bd190286..00000000 --- a/media/ImageShow/entry/src/ohosTest/ets/testability/TestAbility.ts +++ /dev/null @@ -1,61 +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 '@ohos/hypium' -import testsuite from '../test/List.test' -import Logger from '../../../../../imagelibrary/src/main/ets/components/data/Logger' - -const TAG: string = 'TestAbility' - -export default class TestAbility extends Ability { - onCreate(want, launchParam) { - Logger.info(TAG, `TestAbility onCreate`) - let abilityDelegator: any - abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() - let abilityDelegatorArguments: any - abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() - Logger.info(TAG, `start run testcase!!!`) - Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) - } - - onDestroy() { - Logger.info(TAG, `TestAbility onDestroy`) - } - - onWindowStageCreate(windowStage) { - Logger.info(TAG, `TestAbility onWindowStageCreate`) - windowStage.loadContent("TestAbility/pages/index", (err, data) => { - if (err.code) { - Logger.info(TAG, `Failed to load the content. Cause = ${JSON.stringify(err)}`); - return - } - Logger.info(TAG, `Succeeded in loading the content. Data = ${JSON.stringify(data)}`) - }) - } - - onWindowStageDestroy() { - Logger.info(TAG, `TestAbility onWindowStageDestroy`) - } - - onForeground() { - Logger.info(TAG, `TestAbility onForeground`) - } - - onBackground() { - Logger.info(TAG, `TestAbility onBackground`) - } -} \ No newline at end of file diff --git a/media/ImageShow/entry/src/ohosTest/ets/testability/pages/index.ets b/media/ImageShow/entry/src/ohosTest/ets/testability/pages/index.ets deleted file mode 100644 index 47ce04c2..00000000 --- a/media/ImageShow/entry/src/ohosTest/ets/testability/pages/index.ets +++ /dev/null @@ -1,52 +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 Logger from '../../../../../../imagelibrary/src/main/ets/components/data/Logger' - -const TAG: string = 'Index' - -@Entry -@Component -struct Index { - @State message: string = 'Hello World' - - aboutToAppear() { - Logger.info(TAG, `TestAbility index aboutToAppear`) - } - - 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/media/ImageShow/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts b/media/ImageShow/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts deleted file mode 100644 index 2d1370d8..00000000 --- a/media/ImageShow/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts +++ /dev/null @@ -1,80 +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 TestRunner from '@ohos.application.testRunner' -import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' -import Logger from '../../../../../imagelibrary/src/main/ets/components/data/Logger' - -let abilityDelegator = undefined -let abilityDelegatorArguments = undefined -const TAG: string = 'OpenHarmonyTestRunner' - -function translateParamsToString(parameters) { - const keySet = new Set([ - '-s class', '-s notClass', '-s suite', '-s it', - '-s level', '-s testType', '-s size', '-s timeout', - '-s dryRun' - ]) - let targetParams = ''; - for (const key in parameters) { - if (keySet.has(key)) { - targetParams = `${targetParams} ${key} ${parameters[key]}` - } - } - return targetParams.trim() -} - -async function onAbilityCreateCallback() { - Logger.info(TAG, `onAbilityCreateCallback`); -} - -async function addAbilityMonitorCallback(err: any) { - Logger.info(TAG, `addAbilityMonitorCallback = ${JSON.stringify(err)}`) -} - -export default class OpenHarmonyTestRunner implements TestRunner { - constructor() { - } - - onPrepare() { - Logger.info(TAG, `OpenHarmonyTestRunner OnPrepare`) - } - - async onRun() { - Logger.info(TAG, `OpenHarmonyTestRunner onRun run`) - abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() - abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() - let testAbilityName = abilityDelegatorArguments.bundleName + '.TestAbility' - let lMonitor = { - abilityName: testAbilityName, - onAbilityCreate: onAbilityCreateCallback, - }; - abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) - let cmd = 'aa start -d 0 -a TestAbility' + ' -b ' + abilityDelegatorArguments.bundleName - cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters) - let debug = abilityDelegatorArguments.parameters["-D"] - if (debug == 'true') { - cmd += ' -D' - } - Logger.info(TAG, `cmd = ${cmd}`) - abilityDelegator.executeShellCommand(cmd, - (err: any, d: any) => { - Logger.info(TAG, `executeShellCommand : err = ${JSON.stringify(err)}`) - Logger.info(TAG, `executeShellCommand : data = ${d.stdResult}`) - Logger.info(TAG, `executeShellCommand : data = ${d.exitCode}`) - }) - Logger.info(TAG, `OpenHarmonyTestRunner onRun end`) - } -} \ No newline at end of file diff --git a/media/ImageShow/entry/src/ohosTest/module.json5 b/media/ImageShow/entry/src/ohosTest/module.json5 deleted file mode 100644 index 187f19d5..00000000 --- a/media/ImageShow/entry/src/ohosTest/module.json5 +++ /dev/null @@ -1,54 +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. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "srcEntrance": "./ets/TestAbility/TestAbility.ts", - "description": "$string:entry_test_desc", - "mainElement": "TestAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:test_pages", - "uiSyntax": "ets", - "abilities": [ - { - "name": "TestAbility", - "srcEntrance": "./ets/TestAbility/TestAbility.ts", - "description": "$string:TestAbility_desc", - "icon": "$media:icon", - "label": "$string:TestAbility_label", - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:white", - "visible": true, - "skills": [ - { - "actions": [ - "action.system.home" - ], - "entities": [ - "entity.system.home" - ] - } - ] - } - ] - } -} diff --git a/media/ImageShow/entry/src/ohosTest/resources/base/element/color.json b/media/ImageShow/entry/src/ohosTest/resources/base/element/color.json deleted file mode 100644 index 1bbc9aa9..00000000 --- a/media/ImageShow/entry/src/ohosTest/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "white", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/media/ImageShow/entry/src/ohosTest/resources/base/element/string.json b/media/ImageShow/entry/src/ohosTest/resources/base/element/string.json deleted file mode 100644 index 36d4230c..00000000 --- a/media/ImageShow/entry/src/ohosTest/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "entry_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/media/ImageShow/entry/src/ohosTest/resources/base/media/icon.png b/media/ImageShow/entry/src/ohosTest/resources/base/media/icon.png deleted file mode 100644 index ce307a8827bd75456441ceb57d530e4c8d45d36c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6790 zcmX|G1ymHk)?T_}Vd;>R?p|tHQo6fg38|$UVM!6BLrPFWk?s;$LOP{GmJpBl$qoSA!PUg~PA65-S00{{S`XKG6NkG0RgjEntPrmV+?0|00mu7;+5 zrdpa{2QLqPJ4Y{j7=Mrl{BaxrkdY69+c~(w{Fv-v&aR%aEI&JYSeRTLWm!zbv;?)_ ziZB;fwGbbeL5Q}YLx`J$lp~A09KK8t_z}PZ=4ZzgdeKtgoc+o5EvN9A1K1_<>M?MBqb#!ASf&# zEX?<)!RH(7>1P+j=jqG(58}TVN-$psA6K}atCuI!KTJD&FMmH-78ZejBm)0qc{ESp z|LuG1{QnBUJRg_E=h1#XMWt2%fcoN@l7eAS!Es?Q+;XsRNPhiiE=@AqlLkJzF`O18 zbsbSmKN=aaq8k3NFYZfDWpKmM!coBU0(XnL8R{4=i|wi{!uWYM2je{U{B*K2PVdu&=E zTq*-XsEsJ$u5H4g6DIm2Y!DN`>^v|AqlwuCD;w45K0@eqauiqWf7l&o)+YLHm~|L~ z7$0v5mkobriU!H<@mVJHLlmQqzQ3d6Rh_-|%Yy2li*tHO>_vcnuZ7OR_xkAIuIU&x z-|8Y0wj|6|a6_I(v91y%k_kNw6pnkNdxjqG8!%Vz_d%c_!X+6-;1`GC9_FpjoHev5fEV7RhJ>r=mh-jp$fqbqRJ=obwdgLDVP5+s zy1=_DWG0Y-Jb3t^WXmkr(d9~08k-|#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H;`pr!;fVYz?5~yXBACruWB`Ph zZM}90_<^OBxIhyZ9BW$`>6JvO;%VFpqVr8|7t3~AmxYak6?`Pp#c;**_SYmi`&z23 z`p6_~ePvH)C6x-G9$hgL=eVALq`-AiamN>!3~Lxw&{H(b{B(7xSRm6<3<{%{yXiH# zos5Rv1L+8fUKJLo%P>4I&$}y +} + +interface maxHeightType { + maxHeight: string +} + +interface paramsType { + mediaUris: Array; + isShowCamera: boolean; +} + @Entry @Component export struct ChoicePhotos { @@ -36,7 +54,19 @@ export struct ChoicePhotos { @State nextText: string = '' @State isLand: boolean = false private listener = mediaQuery.matchMediaSync('screen and (min-aspect-ratio: 1.5) or (orientation: landscape)') - onLand = (mediaQueryResult) => { + private maxHeightObj1: maxHeightType = { + maxHeight: '64%' + } + private maxHeightObj2: maxHeightType = { + maxHeight: '75.5%' + } + private maxHeightObj3: maxHeightType = { + maxHeight: '60%' + } + private maxHeightObj4: maxHeightType = { + maxHeight: '71%' + } + onLand = (mediaQueryResult: mediaQueryResultType) => { if (mediaQueryResult.matches) { this.isLand = true } else { @@ -70,10 +100,10 @@ export struct ChoicePhotos { async getFileAssetsFromType(mediaType: mediaLibrary.MediaType) { Logger.info(TAG, `getFileAssetsFromType`) - let mediaLibraryInstance = mediaLibrary.getMediaLibrary(getContext(this) as any) + let mediaLibraryInstance = mediaLibrary.getMediaLibrary(getContext(this) as Context) Logger.info(TAG, `mediaLibraryInstance = ${JSON.stringify(mediaLibraryInstance)}`) let fileKeyObj = mediaLibrary.FileKey - let fetchOp = { + let fetchOp:mediaLibrary.MediaFetchOptions = { selections: `${fileKeyObj.MEDIA_TYPE}=?`, selectionArgs: [`${mediaType}`], } @@ -85,24 +115,26 @@ export struct ChoicePhotos { Logger.info(TAG, `this.medias = ${JSON.stringify(this.medias)}`) } - convertContext(context: any) { + convertContext(context: Context) { return context } async convertResourceToString(resource: Resource) { - Logger.info(TAG, `result = ${JSON.stringify(await this.convertContext(getContext(this)).resourceManager.getString(resource))}`) - return await this.convertContext(getContext(this)).resourceManager.getString(resource) + Logger.info(TAG, `result = ${JSON.stringify(await this.convertContext(getContext(this)) + .resourceManager + .getString(resource.id))}`) + return await this.convertContext(getContext(this)).resourceManager.getString(resource.id) } - getMaxHeight() { + getMaxHeight():ConstraintSizeOptions { if (!this.isLand && this.isChoice) { - return { maxHeight: '64%' } + return this.maxHeightObj1 } else if (!this.isLand && !this.isChoice) { - return { maxHeight: '75.5%' } + return this.maxHeightObj2 } else if (this.isLand && this.isChoice) { - return { maxHeight: '60%' } - } else if (this.isLand && !this.isChoice) { - return { maxHeight: '71%' } + return this.maxHeightObj3 + } else{ + return this.maxHeightObj4 } } @@ -147,13 +179,16 @@ export struct ChoicePhotos { if (this.isChoice === false) { return } - this.mediaUris = this.choiceMedias.map((item) => { + this.mediaUris = this.choiceMedias.map((item: mediaLibrary.FileAsset) => { return item.uri }) + let paramsObj: paramsType = { + mediaUris: this.mediaUris, + isShowCamera: true + } router.push({ url: 'pages/Index', - params: { mediaUris: this.mediaUris, isShowCamera: true } - + params: paramsObj }) }) } @@ -164,33 +199,35 @@ export struct ChoicePhotos { Column() { Row() { - ForEach(this.choiceShow, (item, index) => { - Column() { - Text(item) - .fontSize(20) - .fontWeight(500) - .fontColor(this.whichShow[index] === true ? '#0000000' : '#99182431') - .onClick(() => { - this.whichShow.fill(false) - this.whichShow[index] = true - this.medias = [] - if (index == 0) { - this.getFileAssetsFromType(mediaLibrary.MediaType.IMAGE) - } else { - prompt.showDialog({ message: $r('app.string.user_tip') }) - this.choiceMedias = [] - this.isShowChoices = new Array(this.medias.length).fill(false) - } - }) - if (this.whichShow[index]) { - Divider() - .vertical(false) - .strokeWidth(3) - .color('#ffff0000') - .lineCap(LineCapStyle.Round) - .width('40%') - .margin({ top: 4 }) - } + ForEach(this.choiceShow, (item: Resource, index?: number) => { + if(typeof index!=="undefined"){ + Column() { + Text(item) + .fontSize(20) + .fontWeight(500) + .fontColor(this.whichShow[index] === true ? '#0000000' : '#99182431') + .onClick(() => { + this.whichShow.fill(false) + this.whichShow[index] = true + this.medias = [] + if (index == 0) { + this.getFileAssetsFromType(mediaLibrary.MediaType.IMAGE) + } else { + prompt.showDialog({ message: $r('app.string.user_tip') }) + this.choiceMedias = [] + this.isShowChoices = new Array(this.medias.length).fill(false) + } + }) + if (this.whichShow[index]) { + Divider() + .vertical(false) + .strokeWidth(3) + .color('#ffff0000') + .lineCap(LineCapStyle.Round) + .width('40%') + .margin({ top: 4 }) + } + }.width('30%') } .width('30%') }) @@ -201,37 +238,39 @@ export struct ChoicePhotos { Scroll() { Column() { Grid() { - ForEach(this.medias, (item, index) => { - GridItem() { - Stack({ alignContent: Alignment.TopEnd }) { - Image(item.uri) - .width('100%') - .height('100%') - .borderRadius(10) - .objectFit(ImageFit.Fill) - if (this.isShowChoices[index]) { - this.showChoiceBuild('#fffc0303', this.choiceMedias.indexOf(item) + 1) - } else { - this.showChoiceBuild('#ffb7b4b4', 0) - } - } - .width('100%') - .height('100%') - .onClick(() => { - this.isShowChoices[index] = !this.isShowChoices[index] - if (this.isShowChoices[index]) { - if (this.choiceMedias.length > 5) { - prompt.showDialog({ message: $r('app.string.choice_number') }) - this.isShowChoices[index] = !this.isShowChoices[index] - return - } - this.choiceMedias.push(item) - } else { - if (this.choiceMedias.indexOf(item) != -1) { - this.choiceMedias.splice(this.choiceMedias.indexOf(item), 1) + ForEach(this.medias, (item: mediaLibrary.FileAsset, index?: number) => { + if(typeof index !=="undefined"){ + GridItem() { + Stack({ alignContent: Alignment.TopEnd }) { + Image(item.uri) + .width('100%') + .height('100%') + .borderRadius(10) + .objectFit(ImageFit.Fill) + if (this.isShowChoices[index]) { + this.showChoiceBuild('#fffc0303', this.choiceMedias.indexOf(item) + 1) + } else { + this.showChoiceBuild('#ffb7b4b4', 0) } } - }) + .width('100%') + .height('100%') + .onClick(() => { + this.isShowChoices[index] = !this.isShowChoices[index] + if (this.isShowChoices[index]) { + if (this.choiceMedias.length > 5) { + prompt.showDialog({ message: $r('app.string.choice_number') }) + this.isShowChoices[index] = !this.isShowChoices[index] + return + } + this.choiceMedias.push(item) + } else { + if (this.choiceMedias.indexOf(item) != -1) { + this.choiceMedias.splice(this.choiceMedias.indexOf(item), 1) + } + } + }) + }.aspectRatio(1) } .aspectRatio(1) }) @@ -251,27 +290,29 @@ export struct ChoicePhotos { if (this.isChoice) { Grid() { - ForEach(this.choiceMedias, (item, index) => { - GridItem() { - Stack({ alignContent: Alignment.TopEnd }) { - Image(item.uri) - .width('100%') - .height(70) - .borderRadius(10) - Image($r('app.media.delete')) - .width(20) - .height(20) - .margin({ top: 5, right: 5 }) - .onClick(() => { - for (let i = 0;i < this.medias.length; i++) { - if (this.medias[i] === this.choiceMedias[index]) { - this.isShowChoices[i] = false + ForEach(this.choiceMedias, (item: mediaLibrary.FileAsset, index?: number) => { + if(typeof index !=="undefined"){ + GridItem() { + Stack({ alignContent: Alignment.TopEnd }) { + Image(item.uri) + .width('100%') + .height(70) + .borderRadius(10) + Image($r('app.media.delete')) + .width(20) + .height(20) + .margin({ top: 5, right: 5 }) + .onClick(() => { + for (let i = 0;i < this.medias.length; i++) { + if (this.medias[i] === this.choiceMedias[index]) { + this.isShowChoices[i] = false + } } - } - this.choiceMedias.splice(index, 1) - }) + this.choiceMedias.splice(index, 1) + }) + } + .width('100%') } - .width('100%') } }) } @@ -292,18 +333,20 @@ export struct ChoicePhotos { } Row() { - ForEach(this.taskShow, (item, index) => { - Column() { - Image(item) - .width(30) - .height(30) + ForEach(this.taskShow, (item: Resource, index?: number) => { + if(typeof index !=="undefined"){ + Column() { + Image(item) + .width(30) + .height(30) - Text(this.textShow[index]) - .fontSize(14) - .fontColor('#99182431') - .margin({ top: 2 }) + Text(this.textShow[index]) + .fontSize(14) + .fontColor('#99182431') + .margin({ top: 2 }) + } + .width('50%') } - .width('50%') }) } .margin({ top: 8 }) -- Gitee