diff --git a/.gitignore b/.gitignore index a4e0bbef992c7bf2d352a1e40e2c0451cdf808bc..2d5fa39e0a45250d05c1088b350ac0d1f6e8ea61 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,4 @@ /local.properties /.idea **/build -.gradle +/package-lock.json \ No newline at end of file diff --git a/AppScope/app.json5 b/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..60e523757aec7f6798d7264076de8acbaf5ba070 --- /dev/null +++ b/AppScope/app.json5 @@ -0,0 +1,11 @@ +{ + "app": { + "bundleName": "cn.openharmony.multitype", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name", + "distributedNotificationEnabled": true + } +} diff --git a/AppScope/resources/base/element/string.json b/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..abae752a480108489b5a5e4522c595bc783191e5 --- /dev/null +++ b/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "MultiType" + } + ] +} diff --git a/AppScope/resources/base/media/app_icon.png b/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/AppScope/resources/base/media/app_icon.png differ diff --git a/OAT.xml b/OAT.xml index e349c2a4e75001c10d697388b064a167c79adfa8..ce44cdb5fb7f4c533b9a4e416f711537158ab0c4 100644 --- a/OAT.xml +++ b/OAT.xml @@ -5,6 +5,8 @@ + + @@ -14,19 +16,23 @@ - - - - - - - - - + + + + + + + + + + + + + diff --git a/build-profile.json5 b/build-profile.json5 index 1daa57e139a0d166ea9feaec550a907b0b0a5b8b..6e48c87107612bdbd0fc9ad2ab049065a48b570f 100644 --- a/build-profile.json5 +++ b/build-profile.json5 @@ -1,8 +1,9 @@ { "app": { - "signingConfigs": [], - "compileSdkVersion": 8, - "compatibleSdkVersion": 8, + "signingConfigs": [ + ], + "compileSdkVersion": 9, + "compatibleSdkVersion": 9, "products": [ { "name": "default", diff --git a/entry/.gitignore b/entry/.gitignore index 4f9a973815d0b5e49bc8547681a6b4bc7a178d12..10cfd88107d54051db1ccf7e53816db12beea915 100644 --- a/entry/.gitignore +++ b/entry/.gitignore @@ -1,3 +1,4 @@ /node_modules /.preview -/build \ No newline at end of file +/build +/package-lock.json \ No newline at end of file diff --git a/entry/build-profile.json5 b/entry/build-profile.json5 index ae58d1d0a70c602c9cfe1909b00dfec899ba1944..7dc37bb919dada5132609c409200db266559004f 100644 --- a/entry/build-profile.json5 +++ b/entry/build-profile.json5 @@ -1,5 +1,5 @@ { - "apiType": 'faMode', + "apiType": 'stageMode', "buildOption": { }, "targets": [ diff --git a/entry/hvigorfile.js b/entry/hvigorfile.js index bcec4c99653062cbf17702c40a2dd2a7b809b81a..d7720ee6a7aad5c617d1fd2f6fc8c87067bfa32c 100644 --- a/entry/hvigorfile.js +++ b/entry/hvigorfile.js @@ -1,2 +1,2 @@ // Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. -module.exports = require('@ohos/hvigor-ohos-plugin').legacyHapTasks +module.exports = require('@ohos/hvigor-ohos-plugin').hapTasks diff --git a/entry/package.json b/entry/package.json index 78046c6c1bffa98122e2e2e654bc6a4374a0084c..5c6122c2a7888ecd325d35e0ee7deb47b7db5392 100644 --- a/entry/package.json +++ b/entry/package.json @@ -1,15 +1,16 @@ { - "name": "entry", - "version": "1.0.0", - "ohos": { - "org": "huawei", - "buildTool": "hvigor", - "directoryLevel": "module" - }, - "description":"example description", - "repository":{}, - "license":"Apache-2.0", - "dependencies": { - "@ohos/multitype" : "file:../multitype" - } + "license":"Apache-2.0", + "devDependencies":{}, + "name":"entry", + "ohos":{ + "org":"huawei", + "directoryLevel":"module", + "buildTool":"hvigor" + }, + "description":"example description", + "repository":{}, + "version":"1.0.0", + "dependencies":{ + "@ohos/multitype":"file:../multitype" + } } \ No newline at end of file diff --git a/entry/src/main/config.json b/entry/src/main/config.json deleted file mode 100644 index 7761121f055e1318c926cd162ac0fdbc629c9406..0000000000000000000000000000000000000000 --- a/entry/src/main/config.json +++ /dev/null @@ -1,75 +0,0 @@ -{ - "app": { - "vendor": "example", - "bundleName": "cn.openharmony.multitype", - "version": { - "code": 1000000, - "name": "1.0.0" - } - }, - "deviceConfig": {}, - "module": { - "mainAbility": ".MainAbility", - "deviceType": [ - "phone", - "tablet" - ], - "abilities": [ - { - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ], - "orientation": "unspecified", - "visible": true, - "srcPath": "MainAbility", - "name": ".MainAbility", - "srcLanguage": "ets", - "icon": "$media:icon", - "description": "$string:app_name", - "formsEnabled": false, - "label": "$string:app_name", - "type": "page", - "launchType": "standard" - } - ], - "distro": { - "moduleType": "entry", - "installationFree": false, - "deliveryWithInstall": true, - "moduleName": "entry" - }, - "package": "com.example.entry", - "srcPath": "", - "name": ".entry", - "js": [ - { - "mode": { - "syntax": "ets", - "type": "pageAbility" - }, - "pages": [ - "pages/bilibili/BilibiliPage", - "pages/more/MoreApisPlaygroundPage", - "pages/payload/TestPayloadPage", - "pages/one2many/OneDataToManPage", - "pages/weibo/WeiboPage", - "pages/communication/CommunicateWithBinderPage", - "pages/selectable/MultiSelectablePage", - "pages/normal/NormalPage" - ], - "name": ".MainAbility", - "window": { - "designWidth": 720, - "autoDesignWidth": false - } - } - ] - } -} \ No newline at end of file diff --git a/entry/src/main/ets/Application/AbilityStage.ts b/entry/src/main/ets/Application/AbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..0ec61b0ca8661dbfa0770d6f94b68e06bbac04d6 --- /dev/null +++ b/entry/src/main/ets/Application/AbilityStage.ts @@ -0,0 +1,21 @@ +/* + * 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 MyAbilityStage extends AbilityStage { + onCreate() { + console.log("[Demo] MyAbilityStage onCreate") + } +} \ No newline at end of file diff --git a/entry/src/main/ets/MainAbility/MainAbility.ts b/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..de5965a2e61dba9a5eb9d5f1850478d643cacfaf --- /dev/null +++ b/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,48 @@ +/* + * 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' + +export default class MainAbility extends Ability { + onCreate(want, launchParam) { + console.log("[Demo] MainAbility onCreate") + globalThis.abilityWant = want; + } + + onDestroy() { + console.log("[Demo] MainAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("[Demo] MainAbility onWindowStageCreate") + + windowStage.setUIContent(this.context, "pages/bilibili/BilibiliPage", null) + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("[Demo] MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("[Demo] MainAbility onForeground") + } + + onBackground() { + // Ability has back to background + console.log("[Demo] MainAbility onBackground") + } +}; diff --git a/entry/src/main/ets/MainAbility/pages/bilibili/BilibiliPage.ets b/entry/src/main/ets/pages/bilibili/BilibiliPage.ets similarity index 96% rename from entry/src/main/ets/MainAbility/pages/bilibili/BilibiliPage.ets rename to entry/src/main/ets/pages/bilibili/BilibiliPage.ets index 19b96055f59e4077e120744fda37d45c58070843..ec58e96d1156e989602c7e1f84729077310f396e 100644 --- a/entry/src/main/ets/MainAbility/pages/bilibili/BilibiliPage.ets +++ b/entry/src/main/ets/pages/bilibili/BilibiliPage.ets @@ -12,9 +12,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import {Post} from './Post' -import {TitleBar} from '../common/TitleBar' -import {TitleMore} from '../common/CategoryHolderInflater' +import {Post} from './post' +import {TitleBar} from '../common/titlebar' +import {TitleMore} from '../common/categoryholderinflater' @Entry @Component diff --git a/entry/src/main/ets/MainAbility/pages/bilibili/Post.ets b/entry/src/main/ets/pages/bilibili/Post.ets similarity index 100% rename from entry/src/main/ets/MainAbility/pages/bilibili/Post.ets rename to entry/src/main/ets/pages/bilibili/Post.ets diff --git a/entry/src/main/ets/MainAbility/pages/common/CategoryHolderInflater.ets b/entry/src/main/ets/pages/common/CategoryHolderInflater.ets similarity index 100% rename from entry/src/main/ets/MainAbility/pages/common/CategoryHolderInflater.ets rename to entry/src/main/ets/pages/common/CategoryHolderInflater.ets diff --git a/entry/src/main/ets/MainAbility/pages/common/TitleBar.ets b/entry/src/main/ets/pages/common/TitleBar.ets similarity index 100% rename from entry/src/main/ets/MainAbility/pages/common/TitleBar.ets rename to entry/src/main/ets/pages/common/TitleBar.ets diff --git a/entry/src/main/ets/MainAbility/pages/communication/CommunicateWithBinderPage.ets b/entry/src/main/ets/pages/communication/CommunicateWithBinderPage.ets similarity index 100% rename from entry/src/main/ets/MainAbility/pages/communication/CommunicateWithBinderPage.ets rename to entry/src/main/ets/pages/communication/CommunicateWithBinderPage.ets diff --git a/entry/src/main/ets/MainAbility/pages/more/MoreApisPlaygroundPage.ets b/entry/src/main/ets/pages/more/MoreApisPlaygroundPage.ets similarity index 100% rename from entry/src/main/ets/MainAbility/pages/more/MoreApisPlaygroundPage.ets rename to entry/src/main/ets/pages/more/MoreApisPlaygroundPage.ets diff --git a/entry/src/main/ets/MainAbility/pages/normal/ItemType.ets b/entry/src/main/ets/pages/normal/ItemType.ets similarity index 100% rename from entry/src/main/ets/MainAbility/pages/normal/ItemType.ets rename to entry/src/main/ets/pages/normal/ItemType.ets diff --git a/entry/src/main/ets/MainAbility/pages/normal/NormalPage.ets b/entry/src/main/ets/pages/normal/NormalPage.ets similarity index 100% rename from entry/src/main/ets/MainAbility/pages/normal/NormalPage.ets rename to entry/src/main/ets/pages/normal/NormalPage.ets diff --git a/entry/src/main/ets/MainAbility/pages/normal/TextItem.ets b/entry/src/main/ets/pages/normal/TextItem.ets similarity index 100% rename from entry/src/main/ets/MainAbility/pages/normal/TextItem.ets rename to entry/src/main/ets/pages/normal/TextItem.ets diff --git a/entry/src/main/ets/MainAbility/pages/one2many/OneDataToManPage.ets b/entry/src/main/ets/pages/one2many/OneDataToManPage.ets similarity index 100% rename from entry/src/main/ets/MainAbility/pages/one2many/OneDataToManPage.ets rename to entry/src/main/ets/pages/one2many/OneDataToManPage.ets diff --git a/entry/src/main/ets/MainAbility/pages/payload/TestPayloadPage.ets b/entry/src/main/ets/pages/payload/TestPayloadPage.ets similarity index 100% rename from entry/src/main/ets/MainAbility/pages/payload/TestPayloadPage.ets rename to entry/src/main/ets/pages/payload/TestPayloadPage.ets diff --git a/entry/src/main/ets/MainAbility/pages/selectable/MultiSelectablePage.ets b/entry/src/main/ets/pages/selectable/MultiSelectablePage.ets similarity index 100% rename from entry/src/main/ets/MainAbility/pages/selectable/MultiSelectablePage.ets rename to entry/src/main/ets/pages/selectable/MultiSelectablePage.ets diff --git a/entry/src/main/ets/MainAbility/pages/selectable/Square.ets b/entry/src/main/ets/pages/selectable/Square.ets similarity index 100% rename from entry/src/main/ets/MainAbility/pages/selectable/Square.ets rename to entry/src/main/ets/pages/selectable/Square.ets diff --git a/entry/src/main/ets/MainAbility/pages/weibo/WeiboPage.ets b/entry/src/main/ets/pages/weibo/WeiboPage.ets similarity index 100% rename from entry/src/main/ets/MainAbility/pages/weibo/WeiboPage.ets rename to entry/src/main/ets/pages/weibo/WeiboPage.ets diff --git a/entry/src/main/module.json5 b/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..4ef29eabc33b46b84b058eaa869a364af8e452af --- /dev/null +++ b/entry/src/main/module.json5 @@ -0,0 +1,39 @@ +{ + "module": { + "name": "entry", + "type": "entry", + "srcEntrance": "./ets/Application/AbilityStage.ts", + "description": "$string:app_name", + "mainElement": "MainAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "uiSyntax": "ets", + "abilities": [ + { + "name": "MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:app_name", + "icon": "$media:icon", + "label": "$string:app_name", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:white", + "visible": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ] + } +} \ No newline at end of file diff --git a/entry/src/main/resources/base/element/color.json b/entry/src/main/resources/base/element/color.json index ce1119f0ac21f1bc985d28b9851b797b5ce244d2..f66c0f67970d0ec62bd26d8498453cbf81f19e93 100644 --- a/entry/src/main/resources/base/element/color.json +++ b/entry/src/main/resources/base/element/color.json @@ -3,6 +3,10 @@ { "name": "color_text", "value": "#000000" + }, + { + "name": "white", + "value": "#FFFFFF" } ] } \ No newline at end of file diff --git a/entry/src/main/resources/base/profile/main_pages.json b/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..a6f00d47b0a8c4bd3d240045d2c24e0a5658de97 --- /dev/null +++ b/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,12 @@ +{ + "src": [ + "pages/bilibili/BilibiliPage", + "pages/more/MoreApisPlaygroundPage", + "pages/payload/TestPayloadPage", + "pages/one2many/OneDataToManPage", + "pages/weibo/WeiboPage", + "pages/communication/CommunicateWithBinderPage", + "pages/selectable/MultiSelectablePage", + "pages/normal/NormalPage" + ] +} diff --git a/entry/src/ohosTest/config.json b/entry/src/ohosTest/config.json deleted file mode 100644 index 3d62cd2b9c72faffc7a82cbf51749104a199be7d..0000000000000000000000000000000000000000 --- a/entry/src/ohosTest/config.json +++ /dev/null @@ -1,68 +0,0 @@ -{ - "app": { - "bundleName": "com.drakeet.multitype.sample", - "vendor": "example", - "version": { - "code": 1000000, - "name": "1.0.0" - } - }, - "deviceConfig": {}, - "module": { - "package": "com.example.entry_test", - "name": ".entry_test", - "mainAbility": ".TestAbility", - "srcPath": "", - "deviceType": [ - "phone", - "tablet" - ], - "distro": { - "deliveryWithInstall": true, - "moduleName": "entry_test", - "moduleType": "feature", - "installationFree": false - }, - "abilities": [ - { - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ], - "orientation": "unspecified", - "visible": true, - "srcPath": "TestAbility", - "name": ".TestAbility", - "srcLanguage": "ets", - "icon": "$media:icon", - "description": "$string:description_TestAbility", - "formsEnabled": false, - "label": "$string:entry_TestAbility", - "type": "page", - "launchType": "standard" - } - ], - "js": [ - { - "mode": { - "syntax": "ets", - "type": "pageAbility" - }, - "pages": [ - "pages/index" - ], - "name": ".TestAbility", - "window": { - "designWidth": 720, - "autoDesignWidth": false - } - } - ] - } -} \ No newline at end of file diff --git a/entry/src/main/ets/MainAbility/app.ets b/entry/src/ohosTest/ets/Application/AbilityStage.ts similarity index 74% rename from entry/src/main/ets/MainAbility/app.ets rename to entry/src/ohosTest/ets/Application/AbilityStage.ts index 6e469e960018df972e802f51ed407411b67a47f2..04272e2596fb1baf3a2e625d20fd97b3b60612b7 100644 --- a/entry/src/main/ets/MainAbility/app.ets +++ b/entry/src/ohosTest/ets/Application/AbilityStage.ts @@ -12,12 +12,10 @@ 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 { - onCreate() { - console.info('Application onCreate') - }, - onDestroy() { - console.info('Application onDestroy') - }, +export default class TestAbilityStage extends AbilityStage { + onCreate() { + console.log("[Demo] TestAbilityStage onCreate") + } } \ No newline at end of file diff --git a/entry/src/ohosTest/ets/TestAbility/app.ets b/entry/src/ohosTest/ets/TestAbility/TestAbility.ts similarity index 33% rename from entry/src/ohosTest/ets/TestAbility/app.ets rename to entry/src/ohosTest/ets/TestAbility/TestAbility.ts index 4d14a89bad4d3fd1b35a18bac7c9da762f94ca02..1deccab0f485fcadf6da08566658f2108333f34b 100644 --- a/entry/src/ohosTest/ets/TestAbility/app.ets +++ b/entry/src/ohosTest/ets/TestAbility/TestAbility.ts @@ -12,22 +12,48 @@ 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 'hypium/index' +import { Hypium } from '@ohos/hypium' import testsuite from '../test/List.test' -export default { - onCreate() { - console.info('Application onCreate') - var abilityDelegator: any - abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() - var abilityDelegatorArguments: any - abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() - console.info('start run testcase!!!') - Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) - }, - onDestroy() { - console.info('Application onDestroy') - }, -} \ No newline at end of file +export default class TestAbility extends Ability { + onCreate(want, launchParam) { + console.log('TestAbility onCreate') + var abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + } + + 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; + } + + onWindowStageDestroy() { + console.log('TestAbility onWindowStageDestroy') + } + + onForeground() { + console.log('TestAbility onForeground') + } + + onBackground() { + console.log('TestAbility onBackground') + } +}; \ No newline at end of file diff --git a/entry/src/ohosTest/ets/TestAbility/pages/index.ets b/entry/src/ohosTest/ets/TestAbility/pages/index.ets index fbf6d2f46bfae28328445ad4931c69b11dbb4aac..a92e99c1b84eb221bea30ac5029531e327cc6b47 100644 --- a/entry/src/ohosTest/ets/TestAbility/pages/index.ets +++ b/entry/src/ohosTest/ets/TestAbility/pages/index.ets @@ -12,8 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ - -import router from '@system.router'; +import router from '@ohos.router'; @Entry @Component @@ -21,7 +20,6 @@ struct Index { aboutToAppear() { console.info('TestAbility index aboutToAppear') } - @State message: string = 'Hello World' build() { Row() { diff --git a/entry/src/ohosTest/ets/TestRunner/OpenHarmonyTestRunner.ts b/entry/src/ohosTest/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..8b609338ebac18a535007bc57b714836fe4df3ec --- /dev/null +++ b/entry/src/ohosTest/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,78 @@ +/* +Copyright (c) 2021 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/entry/src/ohosTest/ets/module.json5.ftl b/entry/src/ohosTest/ets/module.json5.ftl new file mode 100644 index 0000000000000000000000000000000000000000..73bc4cf36eef25035357e0c4412f3c94dd721682 --- /dev/null +++ b/entry/src/ohosTest/ets/module.json5.ftl @@ -0,0 +1,34 @@ +{ + "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/entry/src/ohosTest/ets/test/Ability.test.ets b/entry/src/ohosTest/ets/test/Ability.test.ets index 7c7a12bfc8535efd920f2e88e53a73b0a507c870..d850ed4e54c2e7a0402d29cb6a3e014611e71c3d 100644 --- a/entry/src/ohosTest/ets/test/Ability.test.ets +++ b/entry/src/ohosTest/ets/test/Ability.test.ets @@ -12,8 +12,7 @@ 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 'hypium/index' +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' export default function abilityTest() { describe('ActsAbilityTest', function () { diff --git a/entry/src/ohosTest/ets/test/List.test.ets b/entry/src/ohosTest/ets/test/List.test.ets index d66beba798b576f54ebb7d873dd3e97952399fdb..d3f20aaa5dda1673747533050da0fa908c8237c6 100644 --- a/entry/src/ohosTest/ets/test/List.test.ets +++ b/entry/src/ohosTest/ets/test/List.test.ets @@ -12,7 +12,6 @@ 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() { diff --git a/entry/src/ohosTest/module.json5 b/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..956fc59074ce631232c4e4c2a8aa859f6a3e9843 --- /dev/null +++ b/entry/src/ohosTest/module.json5 @@ -0,0 +1,39 @@ +{ + "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/entry/src/ohosTest/resources/base/element/color.json b/entry/src/ohosTest/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..1bbc9aa9617e97c45440e1d3d66afc1154837012 --- /dev/null +++ b/entry/src/ohosTest/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "white", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/entry/src/ohosTest/resources/base/element/string.json b/entry/src/ohosTest/resources/base/element/string.json index a0901cfced5abc1cb836b55896884b769adc7175..36d4230c53e9f5a07ae343ad8dc9808341975e3b 100644 --- a/entry/src/ohosTest/resources/base/element/string.json +++ b/entry/src/ohosTest/resources/base/element/string.json @@ -1,12 +1,16 @@ { "string": [ { - "name": "description_TestAbility", - "value": "eTS_Empty Ability" + "name": "entry_test_desc", + "value": "test ability description" }, { - "name": "entry_TestAbility", - "value": "entry_TestAbility" + "name": "TestAbility_desc", + "value": "the test ability" + }, + { + "name": "TestAbility_label", + "value": "test label" } ] } \ No newline at end of file diff --git a/entry/src/ohosTest/resources/base/profile/test_pages.json b/entry/src/ohosTest/resources/base/profile/test_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..fcef82b4dfc18e28106ff9ecd1c8b48ec74d18a4 --- /dev/null +++ b/entry/src/ohosTest/resources/base/profile/test_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "TestAbility/pages/index" + ] +} diff --git a/hvigorfile.js b/hvigorfile.js index cff9f0dfcf8cb00cca34e7f50d61380cf5496868..5f2735e3deeaf655828407544bbed9365c258278 100644 --- a/hvigorfile.js +++ b/hvigorfile.js @@ -1,2 +1,2 @@ // Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. -module.exports = require('@ohos/hvigor-ohos-plugin').legacyAppTasks \ No newline at end of file +module.exports = require('@ohos/hvigor-ohos-plugin').appTasks \ No newline at end of file diff --git a/multitype/.gitignore b/multitype/.gitignore index 4f9a973815d0b5e49bc8547681a6b4bc7a178d12..10cfd88107d54051db1ccf7e53816db12beea915 100644 --- a/multitype/.gitignore +++ b/multitype/.gitignore @@ -1,3 +1,4 @@ /node_modules /.preview -/build \ No newline at end of file +/build +/package-lock.json \ No newline at end of file diff --git a/multitype/build-profile.json5 b/multitype/build-profile.json5 index 107d8c761a767ae4bd6c3798021d9fad61751005..35dff6d53cb3a241f8de4fb68bd01d38ade0f108 100644 --- a/multitype/build-profile.json5 +++ b/multitype/build-profile.json5 @@ -1,5 +1,5 @@ { - "apiType": "faMode", + "apiType": "stageMode", "buildOption": { } } diff --git a/multitype/hvigorfile.js b/multitype/hvigorfile.js index 3a7c40cd644527fdf586c81b110e346329f38c9a..42ed4b4a54a873e2b53441556aae93fab24b794f 100644 --- a/multitype/hvigorfile.js +++ b/multitype/hvigorfile.js @@ -1,3 +1,3 @@ // Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. -module.exports = require('@ohos/hvigor-ohos-plugin').legacyHarTasks +module.exports = require('@ohos/hvigor-ohos-plugin').harTasks diff --git a/multitype/index.ets b/multitype/index.ets index fd60aad6f31162d50bf536701db5d697323c763f..56a8aba402cb996cf3371fa0ce34b511480f37d8 100644 --- a/multitype/index.ets +++ b/multitype/index.ets @@ -12,5 +12,4 @@ 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. */ - export { MultiTypeAdapter } from './src/main/ets/components/MainPage/MultiTypeAdapter' diff --git a/multitype/package.json b/multitype/package.json index 02b6e637b9987d63d7839bece1afe6c69ec06483..2c1a93396f39d9160eb6da3873f723e935d42914 100644 --- a/multitype/package.json +++ b/multitype/package.json @@ -1,23 +1,14 @@ { - "types": "", - "name": "@ohos/multitype", - "description": "更轻松、更灵活地为 List 创建多种类型布局", - "keywords":[ - "OpenHarmony", - "multitype" - ], - "ohos": { - "org": "opensource" - }, - "author": "hihope", - "version": "1.0.3", - "main": "index.ets", - "repository": "https://gitee.com/openharmony-sig/MultiType", - "license": "Apache-2.0", - "tags":[ - "OpenHarmony", - "multitype" - ], - "dependencies": {}, - "devDependencies": {} -} + "license":"Apache-2.0", + "types":"", + "devDependencies":{}, + "name":"@ohos/multitype", + "description":"更轻松、更灵活地为 List 创建多种类型布局", + "ohos":{ + "org":"" + }, + "main":"index.ets", + "repository":{}, + "version":"1.0.0", + "dependencies":{} +} \ No newline at end of file diff --git a/multitype/src/main/config.json b/multitype/src/main/config.json deleted file mode 100644 index 8ec5b495d817d4effaf9739c9c85dc739186655f..0000000000000000000000000000000000000000 --- a/multitype/src/main/config.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "app": { - "bundleName": "cn.openharmony.multitype", - "vendor": "example", - "version": { - "code": 1000000, - "name": "1.0.0" - } - }, - "deviceConfig": {}, - "module": { - "package": "com.example.multitype", - "deviceType": [ - "phone", - "tablet" - ], - "distro": { - "deliveryWithInstall": true, - "moduleName": "multitype", - "moduleType": "har" - }, - "uiSyntax": "ets" - } -} diff --git a/multitype/src/main/module.json5 b/multitype/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..1d23faa8b73eb7f41dafb7f0dd1f0c8a98b7abf7 --- /dev/null +++ b/multitype/src/main/module.json5 @@ -0,0 +1,11 @@ +{ + "module": { + "name": "multitype", + "type": "har", + "deviceTypes": [ + "default", + "tablet" + ], + "uiSyntax": "ets" + } +} diff --git a/package.json b/package.json index de35db8aa864f2a955fccfb3c976bfb6c3e162c9..c52be64860f86c16c0d89501a48b280d7e6c12ca 100644 --- a/package.json +++ b/package.json @@ -1,17 +1,18 @@ { - "name": "ohos_app_multitype", - "version": "1.0.0", - "ohos": { - "org": "huawei", - "buildTool": "hvigor", - "directoryLevel": "project" - }, - "description":"example description", - "repository":{}, - "license":"Apache-2.0", - "dependencies": { - "hypium": "^1.0.0", - "@ohos/hvigor": "1.0.6", - "@ohos/hvigor-ohos-plugin": "1.0.6" - } + "license":"Apache-2.0", + "devDependencies":{}, + "name":"multitype", + "ohos":{ + "org":"huawei", + "directoryLevel":"project", + "buildTool":"hvigor" + }, + "description":"example description", + "repository":{}, + "version":"1.0.0", + "dependencies":{ + "@ohos/hypium":"1.0.0", + "@ohos/hvigor-ohos-plugin":"1.1.3", + "@ohos/hvigor":"1.1.3" + } } \ No newline at end of file