diff --git a/distributeddatamgr/windowStage/dataShareRdbtest/Test.json b/distributeddatamgr/windowStage/dataShareRdbtest/Test.json index 8244a2b1e9f4f1385d1edd889c672ec29169c5e8..a18d3465d2e5462bfc75201f1cbb7a1a6080ffb5 100644 --- a/distributeddatamgr/windowStage/dataShareRdbtest/Test.json +++ b/distributeddatamgr/windowStage/dataShareRdbtest/Test.json @@ -1,10 +1,12 @@ { "description": "Configuration for hjunit demo Tests", "driver": { - "type": "JSUnitTest", + "type": "OHJSUnitTest", "test-timeout": "180000", - "package": "com.example.myapplication", - "shell-timeout": "600000" + "bundle-name": "com.example.myapplication", + "module-name": "entry", + "shell-timeout": "600000", + "testcase-timeout": 70000 }, "kits": [{ "test-file-name": [ diff --git a/distributeddatamgr/windowStage/dataShareRdbtest/entry/src/main/ets/MainAbility/MainAbility.ts b/distributeddatamgr/windowStage/dataShareRdbtest/entry/src/main/ets/MainAbility/MainAbility.ts index e9cf4fd08b1983e61c91558121799596cec3370a..163a930ecc6d600d968f294d4fdb5aa2aceba7fb 100644 --- a/distributeddatamgr/windowStage/dataShareRdbtest/entry/src/main/ets/MainAbility/MainAbility.ts +++ b/distributeddatamgr/windowStage/dataShareRdbtest/entry/src/main/ets/MainAbility/MainAbility.ts @@ -125,7 +125,7 @@ export default class MainAbility extends Ability { }); dseConnectionId = await context.connectAbility(dseWant, dseConnect); }) - windowStage.setUIContent(this.context, "pages/index", null) + windowStage.setUIContent(this.context, "MainAbility/pages/index", null) } onWindowStageDestroy() { diff --git a/distributeddatamgr/windowStage/dataShareRdbtest/entry/src/main/ets/pages/index.ets b/distributeddatamgr/windowStage/dataShareRdbtest/entry/src/main/ets/MainAbility/pages/index.ets similarity index 62% rename from distributeddatamgr/windowStage/dataShareRdbtest/entry/src/main/ets/pages/index.ets rename to distributeddatamgr/windowStage/dataShareRdbtest/entry/src/main/ets/MainAbility/pages/index.ets index 022c5e3aab6e41b72d84eb1f21be43abf1ee5dbf..bb3fd411adc1056b1ebba5b88699b322ef8209f6 100644 --- a/distributeddatamgr/windowStage/dataShareRdbtest/entry/src/main/ets/pages/index.ets +++ b/distributeddatamgr/windowStage/dataShareRdbtest/entry/src/main/ets/MainAbility/pages/index.ets @@ -13,9 +13,10 @@ * limitations under the License. */ import file from '@system.file'; - -import {Core, ExpectExtend} from "hypium/index" -import testsuite from "../Test/List.test" +import router from '@ohos.router'; +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import { Hypium } from '@ohos/hypium' +import testsuite from '../../test/List.test' //InstrumentLog, ReportExtend @@ -25,22 +26,12 @@ struct Index { aboutToAppear(){ console.info("start run testcase!!!!") - const core = Core.getInstance() - const expectExtend = new ExpectExtend({ - 'id': 'extend' - }) - core.addService('expect', expectExtend) - //const reportExtend = new ReportExtend(file) - - //core.addService('report', reportExtend) - core.init() - //core.subscribeEvent('task', reportExtend) - const configService = core.getDefaultService('config') - console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters)) - globalThis.abilityWant.parameters.timeout = 70000; - configService.setConfig(globalThis.abilityWant.parameters) - testsuite() - core.execute() + var abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) } build() { diff --git a/distributeddatamgr/windowStage/dataShareRdbtest/entry/src/main/ets/TestAbility/TestAbility.ts b/distributeddatamgr/windowStage/dataShareRdbtest/entry/src/main/ets/TestAbility/TestAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..89a84730505783ba229175ab4b55d37f91a16266 --- /dev/null +++ b/distributeddatamgr/windowStage/dataShareRdbtest/entry/src/main/ets/TestAbility/TestAbility.ts @@ -0,0 +1,50 @@ +/* + * 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 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; + } + + onWindowStageDestroy() { + console.log('TestAbility onWindowStageDestroy') + } + + onForeground() { + console.log('TestAbility onForeground') + } + + onBackground() { + console.log('TestAbility onBackground') + } +}; \ No newline at end of file diff --git a/distributeddatamgr/windowStage/dataShareRdbtest/entry/src/main/ets/TestAbility/pages/index.ets b/distributeddatamgr/windowStage/dataShareRdbtest/entry/src/main/ets/TestAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..b93567f962921124b282f78c8ef123965d1460c9 --- /dev/null +++ b/distributeddatamgr/windowStage/dataShareRdbtest/entry/src/main/ets/TestAbility/pages/index.ets @@ -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 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/distributeddatamgr/windowStage/dataShareRdbtest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/distributeddatamgr/windowStage/dataShareRdbtest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..a4ee2f1652b3d04ce83ece64ef70f8dfa62a2dc8 --- /dev/null +++ b/distributeddatamgr/windowStage/dataShareRdbtest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,78 @@ +/* + * 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 + '.MainAbility' + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + var cmd = 'aa start -d 0 -a com.example.myapplication.MainAbility' + ' -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/distributeddatamgr/windowStage/dataShareRdbtest/entry/src/main/ets/Test/DataShareCombinationRdb.ets b/distributeddatamgr/windowStage/dataShareRdbtest/entry/src/main/ets/test/DataShareCombinationRdb.ets similarity index 97% rename from distributeddatamgr/windowStage/dataShareRdbtest/entry/src/main/ets/Test/DataShareCombinationRdb.ets rename to distributeddatamgr/windowStage/dataShareRdbtest/entry/src/main/ets/test/DataShareCombinationRdb.ets index f271e7244bff40c904155734a2956dae51f49d23..292db2853b67991eb800fd444ce736cd954ebb2a 100644 --- a/distributeddatamgr/windowStage/dataShareRdbtest/entry/src/main/ets/Test/DataShareCombinationRdb.ets +++ b/distributeddatamgr/windowStage/dataShareRdbtest/entry/src/main/ets/test/DataShareCombinationRdb.ets @@ -13,7 +13,7 @@ * 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" import dataShare from '@ohos.data.dataShare' import * as pubfun from './DataSharePublicfunction_Promise' import dataSharePredicates from '@ohos.data.dataSharePredicates' diff --git a/distributeddatamgr/windowStage/dataShareRdbtest/entry/src/main/ets/Test/DataSharePredicatesRdb.ets b/distributeddatamgr/windowStage/dataShareRdbtest/entry/src/main/ets/test/DataSharePredicatesRdb.ets similarity index 97% rename from distributeddatamgr/windowStage/dataShareRdbtest/entry/src/main/ets/Test/DataSharePredicatesRdb.ets rename to distributeddatamgr/windowStage/dataShareRdbtest/entry/src/main/ets/test/DataSharePredicatesRdb.ets index 9e363a4e127aef53771928ba0c6333d55b6c7767..6b84801214d52b04d06f6db18f209a06e5acc9a1 100644 --- a/distributeddatamgr/windowStage/dataShareRdbtest/entry/src/main/ets/Test/DataSharePredicatesRdb.ets +++ b/distributeddatamgr/windowStage/dataShareRdbtest/entry/src/main/ets/test/DataSharePredicatesRdb.ets @@ -13,7 +13,7 @@ * 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" import dataShare from '@ohos.data.dataShare' import dataSharePredicates from '@ohos.data.dataSharePredicates' import * as pubfun from './DataSharePublicfunction_Promise' diff --git a/distributeddatamgr/windowStage/dataShareRdbtest/entry/src/main/ets/Test/DataSharePublicfunction_Callback.ets b/distributeddatamgr/windowStage/dataShareRdbtest/entry/src/main/ets/test/DataSharePublicfunction_Callback.ets similarity index 95% rename from distributeddatamgr/windowStage/dataShareRdbtest/entry/src/main/ets/Test/DataSharePublicfunction_Callback.ets rename to distributeddatamgr/windowStage/dataShareRdbtest/entry/src/main/ets/test/DataSharePublicfunction_Callback.ets index d423eac42cd7a53dd238054a24720d6a7af8aeb0..1e80d7a5081174eafcb98e329a0ee5b1ac147da7 100644 --- a/distributeddatamgr/windowStage/dataShareRdbtest/entry/src/main/ets/Test/DataSharePublicfunction_Callback.ets +++ b/distributeddatamgr/windowStage/dataShareRdbtest/entry/src/main/ets/test/DataSharePublicfunction_Callback.ets @@ -14,7 +14,7 @@ */ import file from '@system.file'; -import { describe, it, expect } from 'hypium/index' +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium" import dataShare from '@ohos.data.dataShare' import dataSharePredicates from '@ohos.data.dataSharePredicates' import DataShareResultSet from '@ohos.data.DataShareResultSet' diff --git a/distributeddatamgr/windowStage/dataShareRdbtest/entry/src/main/ets/Test/DataSharePublicfunction_Promise.ets b/distributeddatamgr/windowStage/dataShareRdbtest/entry/src/main/ets/test/DataSharePublicfunction_Promise.ets similarity index 95% rename from distributeddatamgr/windowStage/dataShareRdbtest/entry/src/main/ets/Test/DataSharePublicfunction_Promise.ets rename to distributeddatamgr/windowStage/dataShareRdbtest/entry/src/main/ets/test/DataSharePublicfunction_Promise.ets index a5f6785c2ab68db883121cd095a49409dc66b377..5fcd72c0609194fd1d88071fd168a682f19c7452 100644 --- a/distributeddatamgr/windowStage/dataShareRdbtest/entry/src/main/ets/Test/DataSharePublicfunction_Promise.ets +++ b/distributeddatamgr/windowStage/dataShareRdbtest/entry/src/main/ets/test/DataSharePublicfunction_Promise.ets @@ -14,7 +14,7 @@ */ import file from '@system.file'; -import { describe, it, expect } from 'hypium/index' +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium" import dataShare from '@ohos.data.dataShare' import dataSharePredicates from '@ohos.data.dataSharePredicates' import DataShareResultSet from '@ohos.data.DataShareResultSet' diff --git a/distributeddatamgr/windowStage/dataShareRdbtest/entry/src/main/ets/Test/DataShareSingleRdb_Callback.ets b/distributeddatamgr/windowStage/dataShareRdbtest/entry/src/main/ets/test/DataShareSingleRdb_Callback.ets similarity index 97% rename from distributeddatamgr/windowStage/dataShareRdbtest/entry/src/main/ets/Test/DataShareSingleRdb_Callback.ets rename to distributeddatamgr/windowStage/dataShareRdbtest/entry/src/main/ets/test/DataShareSingleRdb_Callback.ets index 2d9f966a40f13f8f646629848eddb388623e9557..1a5bd7a8c83155763685ad975420fb728583507c 100644 --- a/distributeddatamgr/windowStage/dataShareRdbtest/entry/src/main/ets/Test/DataShareSingleRdb_Callback.ets +++ b/distributeddatamgr/windowStage/dataShareRdbtest/entry/src/main/ets/test/DataShareSingleRdb_Callback.ets @@ -13,7 +13,7 @@ * 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" import dataShare from '@ohos.data.dataShare' import dataSharePredicates from '@ohos.data.dataSharePredicates' import * as pubfun from './DataSharePublicfunction_Callback' diff --git a/distributeddatamgr/windowStage/dataShareRdbtest/entry/src/main/ets/Test/DataShareSingleRdb_Promise.ets b/distributeddatamgr/windowStage/dataShareRdbtest/entry/src/main/ets/test/DataShareSingleRdb_Promise.ets similarity index 97% rename from distributeddatamgr/windowStage/dataShareRdbtest/entry/src/main/ets/Test/DataShareSingleRdb_Promise.ets rename to distributeddatamgr/windowStage/dataShareRdbtest/entry/src/main/ets/test/DataShareSingleRdb_Promise.ets index 93cbf7510567ca41dceeacd81102f7515683165f..900f6764a8a85b91017c7cd10d0f50cd045e8853 100644 --- a/distributeddatamgr/windowStage/dataShareRdbtest/entry/src/main/ets/Test/DataShareSingleRdb_Promise.ets +++ b/distributeddatamgr/windowStage/dataShareRdbtest/entry/src/main/ets/test/DataShareSingleRdb_Promise.ets @@ -13,7 +13,7 @@ * 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" import dataShare from '@ohos.data.dataShare' import dataSharePredicates from '@ohos.data.dataSharePredicates' import * as pubfun from './DataSharePublicfunction_Promise' diff --git a/distributeddatamgr/windowStage/dataShareRdbtest/entry/src/main/ets/Test/List.test.ets b/distributeddatamgr/windowStage/dataShareRdbtest/entry/src/main/ets/test/List.test.ets similarity index 100% rename from distributeddatamgr/windowStage/dataShareRdbtest/entry/src/main/ets/Test/List.test.ets rename to distributeddatamgr/windowStage/dataShareRdbtest/entry/src/main/ets/test/List.test.ets diff --git a/distributeddatamgr/windowStage/dataShareRdbtest/entry/src/main/resources/base/profile/main_pages.json b/distributeddatamgr/windowStage/dataShareRdbtest/entry/src/main/resources/base/profile/main_pages.json index feec276e105eeb8d621c20aaf838f318b0a94150..c1858c216308ad312862a877139a8ba6908ec3c6 100644 --- a/distributeddatamgr/windowStage/dataShareRdbtest/entry/src/main/resources/base/profile/main_pages.json +++ b/distributeddatamgr/windowStage/dataShareRdbtest/entry/src/main/resources/base/profile/main_pages.json @@ -1,5 +1,5 @@ { "src": [ - "pages/index" + "MainAbility/pages/index" ] }