diff --git a/distributeddatamgr/BUILD.gn b/distributeddatamgr/BUILD.gn index d21bd66eaa67f263b6d620e59a6d0af4ecf38153..3ee5e3909110acbf36eddea4e480269a4d17d266 100644 --- a/distributeddatamgr/BUILD.gn +++ b/distributeddatamgr/BUILD.gn @@ -23,8 +23,10 @@ group("distributeddatamgr") { "dataSharejstest/hap:dataShare_js_test", "distributedKVStoretest:distributedKVStoretest", "kvStoretest:kvStoretest", + "preferencesdatagroupidtest:ActsPreferencesDataGroupIdTest", "preferencesjstest/hap:preferences_js_test", "relationalStoretest:relationalStoretest", + "relationalstoredatagroupidtest:ActsRelationalstoreDataGroupIdTest", ] } else { deps = [ diff --git a/distributeddatamgr/preferencesdatagroupidtest/AppScope/app.json b/distributeddatamgr/preferencesdatagroupidtest/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..74ce7515f453ee62a927c4a7f7cc17968099d580 --- /dev/null +++ b/distributeddatamgr/preferencesdatagroupidtest/AppScope/app.json @@ -0,0 +1,16 @@ +{ + "app": { + "bundleName": "ohos.acts.preferencesdatagroupidtest", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name", + "minAPIVersion": 10, + "targetAPIVersion": 10, + "car": { + "apiCompatibleVersion": 10, + "singleUser": false + } + } +} diff --git a/distributeddatamgr/preferencesdatagroupidtest/AppScope/resources/base/element/string.json b/distributeddatamgr/preferencesdatagroupidtest/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..3811bc441fc0f128eb4d14c53ed463ffb8dc3811 --- /dev/null +++ b/distributeddatamgr/preferencesdatagroupidtest/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "xtsDemo1" + } + ] +} diff --git a/distributeddatamgr/preferencesdatagroupidtest/AppScope/resources/base/media/app_icon.png b/distributeddatamgr/preferencesdatagroupidtest/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/distributeddatamgr/preferencesdatagroupidtest/AppScope/resources/base/media/app_icon.png differ diff --git a/distributeddatamgr/preferencesdatagroupidtest/BUILD.gn b/distributeddatamgr/preferencesdatagroupidtest/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..29190526f4c432c8c57717ce30c74f42372e5bec --- /dev/null +++ b/distributeddatamgr/preferencesdatagroupidtest/BUILD.gn @@ -0,0 +1,43 @@ +# Copyright (C) 2023 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("ActsPreferencesDataGroupIdTest") { + hap_profile = "src/main/module.json" + deps = [ + ":preferencesDataGroupId_js_assets", + ":preferencesDataGroupId_resources", + ] + ets2abc = true + certificate_profile = "./signature/openharmony_sx.p7b" + + hap_name = "ActsPreferencesDataGroupIdTest" + subsystem_name = "distributeddatamgr" + part_name = "preferences" +} +ohos_app_scope("preferencesDataGroupId_app_profile") { + app_profile = "AppScope/app.json" + + sources = [ "AppScope/resources" ] +} +ohos_js_assets("preferencesDataGroupId_js_assets") { + source_dir = "src/main/ets" +} +ohos_resources("preferencesDataGroupId_resources") { + sources = [ "src/main/resources" ] + + deps = [ ":preferencesDataGroupId_app_profile" ] + + hap_profile = "src/main/module.json" +} diff --git a/distributeddatamgr/preferencesdatagroupidtest/Test.json b/distributeddatamgr/preferencesdatagroupidtest/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..72b929eda6da78ffd3a6e6ef8231bc1c20f6ea80 --- /dev/null +++ b/distributeddatamgr/preferencesdatagroupidtest/Test.json @@ -0,0 +1,19 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "OHJSUnitTest", + "test-timeout": "60000", + "shell-timeout": "60000", + "bundle-name": "ohos.acts.preferencesdatagroupidtest", + "module-name": "preferencesDataGroupId" + }, + "kits": [ + { + "test-file-name": [ + "ActsPreferencesDataGroupIdTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} \ No newline at end of file diff --git a/distributeddatamgr/preferencesdatagroupidtest/signature/openharmony_sx.p7b b/distributeddatamgr/preferencesdatagroupidtest/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..539c7fac576cff33b82f0735c3675464a1229ad4 Binary files /dev/null and b/distributeddatamgr/preferencesdatagroupidtest/signature/openharmony_sx.p7b differ diff --git a/distributeddatamgr/preferencesdatagroupidtest/src/main/ets/TestAbility/TestAbility.ets b/distributeddatamgr/preferencesdatagroupidtest/src/main/ets/TestAbility/TestAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..dac63ae78615c5762d40e44e94c5be2d33a1b546 --- /dev/null +++ b/distributeddatamgr/preferencesdatagroupidtest/src/main/ets/TestAbility/TestAbility.ets @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2023 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 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"); + globalThis.abilityContext = this.context; + windowStage.loadContent("TestAbility/pages/Index", (err, data) => { + if (err.code) { + hilog.error(0x0000, "testTag", "Failed to load the content. Cause: %{public}s", JSON.stringify(err) ?? ""); + return; + } + hilog.info(0x0000, "testTag", "Succeeded in loading the content. Data: %{public}s", JSON.stringify(data) ?? ""); + }); + } + + 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"); + } +} diff --git a/distributeddatamgr/preferencesdatagroupidtest/src/main/ets/TestAbility/pages/Index.ets b/distributeddatamgr/preferencesdatagroupidtest/src/main/ets/TestAbility/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..7063c2427f471eb22dc9ea361188d2bbd6c24c57 --- /dev/null +++ b/distributeddatamgr/preferencesdatagroupidtest/src/main/ets/TestAbility/pages/Index.ets @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2023 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.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/distributeddatamgr/preferencesdatagroupidtest/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/distributeddatamgr/preferencesdatagroupidtest/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..92a16d84e8870da219c51d9f1342c79203c1f42d --- /dev/null +++ b/distributeddatamgr/preferencesdatagroupidtest/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,49 @@ +import hilog from '@ohos.hilog'; +import TestRunner from '@ohos.application.testRunner'; +import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; + +var abilityDelegator = undefined +var abilityDelegatorArguments = undefined + +async function onAbilityCreateCallback() { + hilog.info(0x0000, 'testTag', '%{public}s', 'onAbilityCreateCallback'); +} + +async function addAbilityMonitorCallback(err: any) { + hilog.info(0x0000, 'testTag', 'addAbilityMonitorCallback : %{public}s', JSON.stringify(err) ?? ''); +} + +export default class OpenHarmonyTestRunner implements TestRunner { + constructor() { + } + + onPrepare() { + hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner OnPrepare '); + } + + async onRun() { + hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun run'); + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var testAbilityName = abilityDelegatorArguments.bundleName + '.TestAbility' + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + var cmd = 'aa start -d 0 -a TestAbility' + ' -b ' + abilityDelegatorArguments.bundleName + var debug = abilityDelegatorArguments.parameters['-D'] + if (debug == 'true') + { + cmd += ' -D' + } + hilog.info(0x0000, 'testTag', 'cmd : %{public}s', cmd); + abilityDelegator.executeShellCommand(cmd, + (err: any, d: any) => { + hilog.info(0x0000, 'testTag', 'executeShellCommand : err : %{public}s', JSON.stringify(err) ?? ''); + hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', d.stdResult ?? ''); + hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', d.exitCode ?? ''); + }) + hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun end'); + } +} \ No newline at end of file diff --git a/distributeddatamgr/preferencesdatagroupidtest/src/main/ets/test/List.test.ets b/distributeddatamgr/preferencesdatagroupidtest/src/main/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..3ef220f15be70c25ea2e7b6d7ad4166e76737d6b --- /dev/null +++ b/distributeddatamgr/preferencesdatagroupidtest/src/main/ets/test/List.test.ets @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2023 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 preferencesDataGroupIdCallback from './preferencesDataGroupIdCallback.test' +import preferencesDataGroupIdPromise from './preferencesDataGroupIdPromise.test' + +export default function testsuite() { + preferencesDataGroupIdCallback() + preferencesDataGroupIdPromise() +} \ No newline at end of file diff --git a/distributeddatamgr/preferencesdatagroupidtest/src/main/ets/test/preferencesDataGroupIdCallback.test.ets b/distributeddatamgr/preferencesdatagroupidtest/src/main/ets/test/preferencesDataGroupIdCallback.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..a1adf32cc1d722cc0f8edcd5b4e77fd0d02194fa --- /dev/null +++ b/distributeddatamgr/preferencesdatagroupidtest/src/main/ets/test/preferencesDataGroupIdCallback.test.ets @@ -0,0 +1,261 @@ +/* + * Copyright (c) 2023 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 dataPreferences from '@ohos.data.preferences'; + +const TAG = "[ttt]" + + +export default function preferencesDataGroupIdCallback() { + describe('preferencesDataGroupIdCallback', function () { + + console.log(TAG + "*************Unit Test Begin*************"); + + /** + * @tc.number SUB_DDM_Preferences_DataGroupId_Callback_0100 + * @tc.name preferencesgetPreferences dataGroupId null callback test + * @tc.desc preferences getPreferences dataGroupId null callback test + */ + it('SUB_DDM_Preferences_DataGroupId_Callback_0100', 0, async function (done) { + const Options = { + name: "test_preferences_callback", + dataGroupId: null, + }; + try { + dataPreferences.getPreferences(globalThis.abilityContext, Options, async function (err) { + console.info(TAG, `getPreferences successfully.`); + expect().assertFail(); + done(); + dataPreferences.deletePreferences(globalThis.abilityContext, Options, function (error) { + console.info(TAG, `deletePreferences successfully.`); + expect().assertFail(); + done(); + }) + }) + } catch (errInfo) { + console.error(TAG, `failed, code is ${errInfo.code},message is ${errInfo.message}`); + expect(errInfo.code).assertEqual('401'); + done(); + } + }) + + /** + * @tc.number SUB_DDM_Preferences_DataGroupId_Callback_0200 + * @tc.name preferences dataGroupId undefined callback test + * @tc.desc preferences getPreferences dataGroupId undefined callback test + */ + it('SUB_DDM_Preferences_DataGroupId_Callback_0200', 0, async function (done) { + const Options = { + name: "test_preferences_callback", + dataGroupId: undefined, + }; + try { + dataPreferences.getPreferences(globalThis.abilityContext, Options, async function (err) { + console.info(TAG, `getPreferences successfully.`); + expect().assertFail(); + done(); + dataPreferences.deletePreferences(globalThis.abilityContext, Options, function (error) { + console.info(TAG, `deletePreferences successfully.`); + expect().assertFail(); + done(); + }) + }) + } catch (errInfo) { + console.error(TAG, `failed, code is ${errInfo.code},message is ${errInfo.message}`); + expect(errInfo.code).assertEqual('401'); + done(); + } + }) + /** + * @tc.number SUB_DDM_Preferences_DataGroupId_Callback_0300 + * @tc.name preferences dataGroupId callback test + * @tc.desc preferences getPreferences dataGroupId callback test + */ + it('SUB_DDM_Preferences_DataGroupId_Callback_0300', 0, async function (done) { + const Options = { + name: "test_preferences_callback", + dataGroupId: '112233', + }; + try { + dataPreferences.getPreferences(globalThis.abilityContext, Options, async function (err) { + console.info(TAG, `getPreferences successfully.`); + expect().assertFail(); + done(); + dataPreferences.deletePreferences(globalThis.abilityContext, Options, function (error) { + console.info(TAG, `deletePreferences successfully.`); + expect().assertFail(); + done(); + }) + }) + } catch (errInfo) { + console.error(TAG, `failed, code is ${errInfo.code},message is ${errInfo.message}`); + expect(errInfo.code).assertEqual('15501002'); + done(); + } + }) + + /** + * @tc.number SUB_DDM_Preferences_DataGroupId_Callback_0400 + * @tc.name preferences dataGroupId callback test + * @tc.desc preferences deletePreferences dataGroupId callback test + */ + it('SUB_DDM_Preferences_DataGroupId_Callback_0400', 0, async function (done) { + const Options = { + name: "test_preferences_callback", + dataGroupId: '123456', + }; + try { + dataPreferences.getPreferences(globalThis.abilityContext, Options, async function (err) { + if (err) { + console.error(TAG, `getPreferences failed, code is ${err.code},message is ${err.message}`); + return false; + } + console.info(TAG, `getPreferences successfully.`); + dataPreferences.deletePreferences(globalThis.abilityContext, Options, function (error) { + if (error) { + console.error(TAG, `deletePreferences failed, code is ${error.code},message is ${error.message}`); + return false; + } + console.info(TAG, `deletePreferences successfully.`); + expect(error === undefined).assertTrue(); + done(); + }) + }) + } catch (errInfo) { + console.error(TAG, `failed, code is ${errInfo.code},message is ${errInfo.message}`); + expect(errInfo !== null).assertFail(); + } + }) + + /** + * @tc.number SUB_DDM_Preferences_DataGroupId_Callback_0500 + * @tc.name preferences dataGroupId null callback test + * @tc.desc preferences getPreferences dataGroupId null callback test + */ + it('SUB_DDM_Preferences_DataGroupId_Callback_0500', 0, async function (done) { + const Options = { + name: "test_preferences_callback", + dataGroupId: null, + }; + try { + dataPreferences.getPreferences(globalThis.abilityContext, Options, async function (err) { + console.info(TAG, `getPreferences successfully.`); + expect().assertFail(); + done(); + dataPreferences.removePreferencesFromCache(globalThis.abilityContext, Options, function (error) { + console.info(TAG, `removePreferencesFromCache successfully.`); + expect().assertFail(); + done(); + }) + }) + } catch (errInfo) { + console.error(TAG, `failed, code is ${errInfo.code},message is ${errInfo.message}`); + expect(errInfo.code).assertEqual('401'); + done(); + } + }) + + /** + * @tc.number SUB_DDM_Preferences_DataGroupId_Callback_0600 + * @tc.name preferences dataGroupId undefined callback test + * @tc.desc preferences removePreferencesFromCache dataGroupId undefined callback test + */ + it('SUB_DDM_Preferences_DataGroupId_Callback_0600', 0, async function (done) { + const Options = { + name: "test_preferences_callback", + dataGroupId: undefined, + }; + try { + dataPreferences.getPreferences(globalThis.abilityContext, Options, async function (err) { + console.info(TAG, `getPreferences successfully.`); + expect().assertFail(); + done(); + dataPreferences.removePreferencesFromCache(globalThis.abilityContext, Options, function (error) { + console.info(TAG, `removePreferencesFromCache successfully.`); + expect().assertFail(); + done(); + }) + }) + } catch (errInfo) { + console.error(TAG, `failed, code is ${errInfo.code},message is ${errInfo.message}`); + expect(errInfo.code).assertEqual('401'); + done(); + } + }) + /** + * @tc.number SUB_DDM_Preferences_DataGroupId_Callback_0700 + * @tc.name preferences dataGroupId callback test + * @tc.desc preferences removePreferencesFromCache dataGroupId callback test + */ + it('SUB_DDM_Preferences_DataGroupId_Callback_0700', 0, async function (done) { + const Options = { + name: "test_preferences_callback", + dataGroupId: '112233', + }; + try { + dataPreferences.getPreferences(globalThis.abilityContext, Options, async function (err) { + console.info(TAG, `getPreferences successfully.`); + expect().assertFail(); + done(); + dataPreferences.removePreferencesFromCache(globalThis.abilityContext, Options, function (error) { + console.info(TAG, `removePreferencesFromCache successfully.`); + expect().assertFail(); + done(); + }) + }) + } catch (errInfo) { + console.error(TAG, `failed, code is ${errInfo.code},message is ${errInfo.message}`); + expect(errInfo.code).assertEqual('15501002'); + done(); + } + }) + + /** + * @tc.number SUB_DDM_Preferences_DataGroupId_Callback_0800 + * @tc.name preferences dataGroupId callback test + * @tc.desc preferences removePreferencesFromCache dataGroupId callback test + */ + it('SUB_DDM_Preferences_DataGroupId_Callback_0800', 0, async function (done) { + const Options = { + name: "test_preferences_callback", + dataGroupId: '123456', + }; + try { + dataPreferences.getPreferences(globalThis.abilityContext, Options, async function (err) { + if (err) { + console.error(TAG, `getPreferences failed, code is ${err.code},message is ${err.message}`); + return false; + } + console.info(TAG, `getPreferences successfully.`); + dataPreferences.removePreferencesFromCache(globalThis.abilityContext, Options, function (error) { + if (error) { + console.error(TAG, `removePreferencesFromCache failed, code is ${error.code},message is ${error.message}`); + return false; + } + console.info(TAG, `removePreferencesFromCache successfully.`); + expect(error === undefined).assertTrue(); + done(); + }) + }) + } catch (errInfo) { + console.error(TAG, `failed, code is ${errInfo.code},message is ${errInfo.message}`); + expect(errInfo !== null).assertFail(); + } + }) + + console.log(TAG + "*************Unit Test End*************"); + }) +} \ No newline at end of file diff --git a/distributeddatamgr/preferencesdatagroupidtest/src/main/ets/test/preferencesDataGroupIdPromise.test.ets b/distributeddatamgr/preferencesdatagroupidtest/src/main/ets/test/preferencesDataGroupIdPromise.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..afe7aa35dfd6ce519a539858b3c1d1a885b49c79 --- /dev/null +++ b/distributeddatamgr/preferencesdatagroupidtest/src/main/ets/test/preferencesDataGroupIdPromise.test.ets @@ -0,0 +1,245 @@ +/* + * Copyright (C) 2023 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 dataPreferences from '@ohos.data.preferences'; + +const TAG = "[ttt]" + +export default function preferencesDataGroupIdPromise() { + describe('preferencesDataGroupIdPromise', function () { + + console.log(TAG + "*************Unit Test Begin*************"); + + + /** + * @tc.number SUB_DDM_Preferences_DataGroupId_Promise_0100 + * @tc.name preferences dataGroupId null promise test + * @tc.desc preferences getPreferences dataGroupId null promise test + */ + it('SUB_DDM_Preferences_DataGroupId_Promise_0100', 0, async function (done) { + const Options = { + name: "test_preferences_callback", + dataGroupId: null, + }; + try{ + dataPreferences.getPreferences(globalThis.abilityContext, Options).then(async (data) => { + console.info(TAG, `getPreferences successfully.`); + expect().assertFail(); + done(); + dataPreferences.deletePreferences(globalThis.abilityContext, Options).then(async (val) => { + console.info(TAG, `deletePreferences successfully.`); + expect().assertFail(); + done(); + }).catch((error) => { + console.error(TAG, `deletePreferences failed, code is ${error.code},message is ${error.message}`); + expect(error !== null).assertFail(); + done(); + }) + }).catch((err) => { + console.error(TAG, `getPreferences failed, code is ${err.code},message is ${err.message}`); + expect(err !== null).assertFail(); + done(); + }) + }catch(errInfo){ + console.error(TAG, `failed, code is ${errInfo.code},message is ${errInfo.message}`); + expect(errInfo.code).assertEqual('401'); + done(); + } + }) + + /** + * @tc.number SUB_DDM_Preferences_DataGroupId_Promise_0200 + * @tc.name preferences dataGroupId undefined promise test + * @tc.desc preferences getPreferences dataGroupId undefined promise test + */ + it('SUB_DDM_Preferences_DataGroupId_Promise_0200', 0, async function (done) { + const Options = { + name: "test_preferences_callback", + dataGroupId: undefined, + }; + try{ + dataPreferences.getPreferences(globalThis.abilityContext, Options).then(async (data) => { + console.info(TAG, `getPreferences successfully.`); + expect().assertFail(); + done(); + dataPreferences.deletePreferences(globalThis.abilityContext, Options).then(async (val) => { + console.info(TAG, `deletePreferences successfully.`); + expect().assertFail(); + done(); + }).catch((error) => { + console.error(TAG, `deletePreferences failed, code is ${error.code},message is ${error.message}`); + expect(error !== null).assertFail(); + done(); + }) + }).catch((err) => { + console.error(TAG, `getPreferences failed, code is ${err.code},message is ${err.message}`); + expect(err !== null).assertFail(); + done(); + }) + }catch(errInfo){ + console.error(TAG, `failed, code is ${errInfo.code},message is ${errInfo.message}`); + expect(errInfo.code).assertEqual('401'); + done(); + } + }) + + /** + * @tc.number SUB_DDM_Preferences_DataGroupId_Promise_0300 + * @tc.name preferences dataGroupId promise test + * @tc.desc preferences getPreferences dataGroupId promise test + */ + it('SUB_DDM_Preferences_DataGroupId_Promise_0300', 0, async function (done) { + const Options = { + name: "test_preferences_callback", + dataGroupId: '112233', + }; + try{ + dataPreferences.getPreferences(globalThis.abilityContext, Options).then(async (data) => { + console.info(TAG, `getPreferences successfully.`); + expect().assertFail(); + done(); + dataPreferences.deletePreferences(globalThis.abilityContext, Options).then(async (val) => { + console.info(TAG, `deletePreferences successfully.`); + expect().assertFail(); + done(); + }).catch((error) => { + console.error(TAG, `deletePreferences failed, code is ${error.code},message is ${error.message}`); + expect(error !== null).assertFail(); + done(); + }) + }).catch((err) => { + console.error(TAG, `getPreferences failed, code is ${err.code},message is ${err.message}`); + expect(err !== null).assertFail(); + done(); + }) + }catch(errInfo){ + console.error(TAG, `failed, code is ${errInfo.code},message is ${errInfo.message}`); + expect(errInfo.code).assertEqual('15501002'); + done(); + } + }) + + /** + * @tc.number SUB_DDM_Preferences_DataGroupId_Promise_0400 + * @tc.name preferences dataGroupId null promise test + * @tc.desc preferences getPreferences dataGroupId null promise test + */ + it('SUB_DDM_Preferences_DataGroupId_Promise_0400', 0, async function (done) { + const Options = { + name: "test_preferences_callback", + dataGroupId: null, + }; + try{ + dataPreferences.getPreferences(globalThis.abilityContext, Options).then(async (data) => { + console.info(TAG, `getPreferences successfully.`); + expect().assertFail(); + done(); + dataPreferences.removePreferencesFromCache(globalThis.abilityContext, Options).then(async (val) => { + console.info(TAG, `removePreferencesFromCache successfully.`); + expect().assertFail(); + done(); + }).catch((error) => { + console.error(TAG, `removePreferencesFromCache failed, code is ${error.code},message is ${error.message}`); + expect(error !== null).assertFail(); + done(); + }) + }).catch((err) => { + console.error(TAG, `getPreferences failed, code is ${err.code},message is ${err.message}`); + expect(err !== null).assertFail(); + done(); + }) + }catch(errInfo){ + console.error(TAG, `failed, code is ${errInfo.code},message is ${errInfo.message}`); + expect(errInfo.code).assertEqual('401'); + done(); + } + }) + + /** + * @tc.number SUB_DDM_Preferences_DataGroupId_Promise_0500 + * @tc.name preferences dataGroupId undefined promise test + * @tc.desc preferences removePreferencesFromCache dataGroupId undefined promise test + */ + it('SUB_DDM_Preferences_DataGroupId_Promise_0500', 0, async function (done) { + const Options = { + name: "test_preferences_callback", + dataGroupId: undefined, + }; + try{ + dataPreferences.getPreferences(globalThis.abilityContext, Options).then(async (data) => { + console.info(TAG, `getPreferences successfully.`); + expect().assertFail(); + done(); + dataPreferences.removePreferencesFromCache(globalThis.abilityContext, Options).then(async (val) => { + console.info(TAG, `removePreferencesFromCache successfully.`); + expect().assertFail(); + done(); + }).catch((error) => { + console.error(TAG, `removePreferencesFromCache failed, code is ${error.code},message is ${error.message}`); + expect(error !== null).assertFail(); + done(); + }) + }).catch((err) => { + console.error(TAG, `getPreferences failed, code is ${err.code},message is ${err.message}`); + expect(err !== null).assertFail(); + done(); + }) + }catch(errInfo){ + console.error(TAG, `failed, code is ${errInfo.code},message is ${errInfo.message}`); + expect(errInfo.code).assertEqual('401'); + done(); + } + }) + + /** + * @tc.number SUB_DDM_Preferences_DataGroupId_Promise_0600 + * @tc.name preferences dataGroupId promise test + * @tc.desc preferences removePreferencesFromCache dataGroupId promise test + */ + it('SUB_DDM_Preferences_DataGroupId_Promise_0600', 0, async function (done) { + const Options = { + name: "test_preferences_callback", + dataGroupId: '112233', + }; + try{ + dataPreferences.getPreferences(globalThis.abilityContext, Options).then(async (data) => { + console.info(TAG, `getPreferences successfully.`); + expect().assertFail(); + done(); + dataPreferences.removePreferencesFromCache(globalThis.abilityContext, Options).then(async (val) => { + console.info(TAG, `removePreferencesFromCache successfully.`); + expect().assertFail(); + done(); + }).catch((error) => { + console.error(TAG, `removePreferencesFromCache failed, code is ${error.code},message is ${error.message}`); + expect(error !== null).assertFail(); + done(); + }) + }).catch((err) => { + console.error(TAG, `getPreferences failed, code is ${err.code},message is ${err.message}`); + expect(err !== null).assertFail(); + done(); + }) + }catch(errInfo){ + console.error(TAG, `failed, code is ${errInfo.code},message is ${errInfo.message}`); + expect(errInfo.code).assertEqual('15501002'); + done(); + } + }) + + console.log(TAG + "*************Unit Test End*************"); + }) +} \ No newline at end of file diff --git a/distributeddatamgr/preferencesdatagroupidtest/src/main/module.json b/distributeddatamgr/preferencesdatagroupidtest/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..9781a30a69aa969c19010da8fa32ff68e3d26d37 --- /dev/null +++ b/distributeddatamgr/preferencesdatagroupidtest/src/main/module.json @@ -0,0 +1,39 @@ +{ + "module": { + "name": "preferencesDataGroupId", + "type": "feature", + "description": "$string:module_test_desc", + "mainElement": "TestAbility", + "deviceTypes": [ + "default", + "tablet", + "phone", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:test_pages", + "abilities": [ + { + "name": "TestAbility", + "srcEntry": "./ets/TestAbility/TestAbility.ets", + "description": "$string:TestAbility_desc", + "icon": "$media:icon", + "label": "$string:TestAbility_label", + "exported": true, + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + } + ] + } +} diff --git a/distributeddatamgr/preferencesdatagroupidtest/src/main/resources/base/element/color.json b/distributeddatamgr/preferencesdatagroupidtest/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/distributeddatamgr/preferencesdatagroupidtest/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/distributeddatamgr/preferencesdatagroupidtest/src/main/resources/base/element/string.json b/distributeddatamgr/preferencesdatagroupidtest/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..65d8fa5a7cf54aa3943dcd0214f58d1771bc1f6c --- /dev/null +++ b/distributeddatamgr/preferencesdatagroupidtest/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "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/distributeddatamgr/preferencesdatagroupidtest/src/main/resources/base/media/icon.png b/distributeddatamgr/preferencesdatagroupidtest/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/distributeddatamgr/preferencesdatagroupidtest/src/main/resources/base/media/icon.png differ diff --git a/distributeddatamgr/preferencesdatagroupidtest/src/main/resources/base/profile/test_pages.json b/distributeddatamgr/preferencesdatagroupidtest/src/main/resources/base/profile/test_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..77e90731b5a38d861663029b483df3d3ac9ec74b --- /dev/null +++ b/distributeddatamgr/preferencesdatagroupidtest/src/main/resources/base/profile/test_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "TestAbility/pages/Index" + ] +} diff --git a/distributeddatamgr/preferencesjstest/hap/src/main/js/test/PreferencesSyncJsunit.test.js b/distributeddatamgr/preferencesjstest/hap/src/main/js/test/PreferencesSyncJsunit.test.js index a84a65c82c0c0251854a83d1fbf3f6e77ce8cdf6..aeb4ed39548b0c31b716b8d2bbfe81e57a44d123 100644 --- a/distributeddatamgr/preferencesjstest/hap/src/main/js/test/PreferencesSyncJsunit.test.js +++ b/distributeddatamgr/preferencesjstest/hap/src/main/js/test/PreferencesSyncJsunit.test.js @@ -378,5 +378,31 @@ export default function PreferencesSyncTest() { expect("default").assertEqual(mPreferences.getSync(KEY_TEST_STRING_ELEMENT, "default")); done(); }) + + /** + * @tc.number SUB_DDM_Preferences_removePreferencesFromCacheSync_0100 + * @tc.name removePreferencesFromCacheSync interface test + * @tc.desc removePreferencesFromCacheSync interface test + */ + it('SUB_DDM_Preferences_removePreferencesFromCacheSync_0100', 0, async function (done) { + console.log("SUB_DDM_Preferences_removePreferencesFromCacheSync_0100 begin."); + mPreferences = await dataPreferences.getPreferences(context, NAME); + await mPreferences.clearSync(); + await mPreferences.putSync(KEY_TEST_STRING_ELEMENT, 'test') + await mPreferences.getSync(KEY_TEST_STRING_ELEMENT, "defaultvalue") + mPreferences.flush(async function (err, val) { + if (err) { + console.log("flush err."); + expect().assertFail(); + } + console.log("flush done."); + await dataPreferences.removePreferencesFromCacheSync(context, NAME); + let value = mPreferences.getSync(KEY_TEST_STRING_ELEMENT, "defaultvalue") + console.log("SUB_DDM_Preferences_removePreferencesFromCacheSync_0100 end." + value); + expect('test').assertEqual(value); + done(); + console.log("SUB_DDM_Preferences_removePreferencesFromCacheSync_0100 end."); + }); + }) }) } \ No newline at end of file diff --git a/distributeddatamgr/relationalStoretest/relationalStoreStagetest/entry/src/main/ets/test/List.test.ets b/distributeddatamgr/relationalStoretest/relationalStoreStagetest/entry/src/main/ets/test/List.test.ets index 26e665417fee9f94bf10adbc231d0854538a72e9..3a224a7683c3aeb1eb9e910b570f41a75f8855fe 100644 --- a/distributeddatamgr/relationalStoretest/relationalStoreStagetest/entry/src/main/ets/test/List.test.ets +++ b/distributeddatamgr/relationalStoretest/relationalStoreStagetest/entry/src/main/ets/test/List.test.ets @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2023 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 @@ -16,8 +16,11 @@ import relationalStoreDistributedTest from './relationalStoreDistributedEtsunit.test.ets' import relationalStoreTest from './relationalStoreEtsunit.test.ets' import relationalStoreResultSetTest from './relationalStoreTestResultsetEtsunit.test.ets' +import relationalStoreEmitTest from './relationalStoreEmit.test' + export default function testsuite() { relationalStoreDistributedTest(globalThis.abilityContext) relationalStoreTest(globalThis.abilityContext) relationalStoreResultSetTest(globalThis.abilityContext) + relationalStoreEmitTest() } diff --git a/distributeddatamgr/relationalStoretest/relationalStoreStagetest/entry/src/main/ets/test/relationalStoreEmit.test.ets b/distributeddatamgr/relationalStoretest/relationalStoreStagetest/entry/src/main/ets/test/relationalStoreEmit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..5aaa5c2c2315e99365f0e5d28bfdc8bf3dc3e127 --- /dev/null +++ b/distributeddatamgr/relationalStoretest/relationalStoreStagetest/entry/src/main/ets/test/relationalStoreEmit.test.ets @@ -0,0 +1,92 @@ +/* + * Copyright (C) 2023 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 data_Rdb from '@ohos.data.relationalStore'; + +const TAG = "[RelationalStore_Emit_TEST]"; +const CREATE_TABLE_TEST = "CREATE TABLE IF NOT EXISTS test (" ++ "id INTEGER PRIMARY KEY AUTOINCREMENT, " ++ "name TEXT NOT NULL, " ++ "age INTEGER, " ++ "salary REAL, " ++ "blobType BLOB)"; + +let rdbStore; +const STORE_CONFIG = { + name: "rdbstoreEmit.db", + securityLevel: data_Rdb.SecurityLevel.S1 +}; + +function sleep(ms) { + return new Promise(resolve => setTimeout(resolve, ms)); +} + +export default function relationalStoreEmitTest() { + describe('relationalStoreEmitTest', function () { + beforeAll(async function () { + console.info(TAG + 'beforeAll'); + }) + + beforeEach(async function () { + console.info(TAG + 'beforeEach'); + rdbStore = await data_Rdb.getRdbStore(globalThis.abilityContext, STORE_CONFIG) + await rdbStore.executeSql(CREATE_TABLE_TEST); + }) + + afterEach(async function () { + console.info(TAG + 'afterAll'); + data_Rdb.deleteRdbStore(globalThis.abilityContext, "rdbstoreEmit.db"); + }) + + afterAll(async function () { + console.info(TAG + 'afterAll'); + }) + + console.info(TAG + "*************Unit Test Begin*************"); + + /** + * @tc.number SUB_DDM_RelationalStore_Emit_0100 + * @tc.name relationalStore emit test + * @tc.desc relationalStore emit test + */ + it('testRdbStoreDistributed0012', 0, async function (done) { + async function subscribeInsert() { + console.info(TAG + "subscribeInsert start"); + const valueBucket = { + "name": "zhangsan" + } + await rdbStore.insert("test", valueBucket) + console.info(TAG + "subscribeInsert end"); + } + + try { + await rdbStore.on('storeObserverInsert', false, subscribeInsert); + await rdbStore.emit('storeObserverInsert'); + await sleep(2000); + let resultSet = await rdbStore.querySql("SELECT * FROM test"); + console.info(TAG + "resultSet = " + resultSet.rowCount); + expect(1).assertEqual(resultSet.rowCount); + + done(); + } catch (err) { + console.error(`failed, code is ${err.code},message is ${err.message}`); + expect().assertFail() + done(); + } + }) + + }) +} \ No newline at end of file diff --git a/distributeddatamgr/relationalstoredatagroupidtest/AppScope/app.json b/distributeddatamgr/relationalstoredatagroupidtest/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..4b321db661f16f9aa49a5d8d08d8c8858a0659cb --- /dev/null +++ b/distributeddatamgr/relationalstoredatagroupidtest/AppScope/app.json @@ -0,0 +1,16 @@ +{ + "app": { + "bundleName": "ohos.acts.relationalstoredatagroupidtest", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name", + "minAPIVersion": 10, + "targetAPIVersion": 10, + "car": { + "apiCompatibleVersion": 10, + "singleUser": false + } + } +} diff --git a/distributeddatamgr/relationalstoredatagroupidtest/AppScope/resources/base/element/string.json b/distributeddatamgr/relationalstoredatagroupidtest/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..3811bc441fc0f128eb4d14c53ed463ffb8dc3811 --- /dev/null +++ b/distributeddatamgr/relationalstoredatagroupidtest/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "xtsDemo1" + } + ] +} diff --git a/distributeddatamgr/relationalstoredatagroupidtest/AppScope/resources/base/media/app_icon.png b/distributeddatamgr/relationalstoredatagroupidtest/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/distributeddatamgr/relationalstoredatagroupidtest/AppScope/resources/base/media/app_icon.png differ diff --git a/distributeddatamgr/relationalstoredatagroupidtest/BUILD.gn b/distributeddatamgr/relationalstoredatagroupidtest/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..1b83088d8aedb5260edf64a15ba92afeeedc3ab0 --- /dev/null +++ b/distributeddatamgr/relationalstoredatagroupidtest/BUILD.gn @@ -0,0 +1,43 @@ +# Copyright (C) 2023 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("ActsRelationalstoreDataGroupIdTest") { + hap_profile = "src/main/module.json" + deps = [ + ":relationalstoreDataGroupId_js_assets", + ":relationalstoreDataGroupId_resources", + ] + ets2abc = true + certificate_profile = "./signature/openharmony_sx.p7b" + + hap_name = "ActsRelationalstoreDataGroupIdTest" + subsystem_name = "distributeddatamgr" + part_name = "relational_store" +} +ohos_app_scope("relationalstoreDataGroupId_app_profile") { + app_profile = "AppScope/app.json" + + sources = [ "AppScope/resources" ] +} +ohos_js_assets("relationalstoreDataGroupId_js_assets") { + source_dir = "src/main/ets" +} +ohos_resources("relationalstoreDataGroupId_resources") { + sources = [ "src/main/resources" ] + + deps = [ ":relationalstoreDataGroupId_app_profile" ] + + hap_profile = "src/main/module.json" +} diff --git a/distributeddatamgr/relationalstoredatagroupidtest/Test.json b/distributeddatamgr/relationalstoredatagroupidtest/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..14457e96de5c75eb4b42ca11a5981e61b9bdf714 --- /dev/null +++ b/distributeddatamgr/relationalstoredatagroupidtest/Test.json @@ -0,0 +1,19 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "OHJSUnitTest", + "test-timeout": "60000", + "shell-timeout": "60000", + "bundle-name": "ohos.acts.relationalstoredatagroupidtest", + "module-name": "relationalstoreDataGroupId" + }, + "kits": [ + { + "test-file-name": [ + "ActsRelationalstoreDataGroupIdTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} \ No newline at end of file diff --git a/distributeddatamgr/relationalstoredatagroupidtest/signature/openharmony_sx.p7b b/distributeddatamgr/relationalstoredatagroupidtest/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..d98a1473b50b4080dba358fd3603984ca47a66ba Binary files /dev/null and b/distributeddatamgr/relationalstoredatagroupidtest/signature/openharmony_sx.p7b differ diff --git a/distributeddatamgr/relationalstoredatagroupidtest/src/main/ets/TestAbility/TestAbility.ets b/distributeddatamgr/relationalstoredatagroupidtest/src/main/ets/TestAbility/TestAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..dac63ae78615c5762d40e44e94c5be2d33a1b546 --- /dev/null +++ b/distributeddatamgr/relationalstoredatagroupidtest/src/main/ets/TestAbility/TestAbility.ets @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2023 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 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"); + globalThis.abilityContext = this.context; + windowStage.loadContent("TestAbility/pages/Index", (err, data) => { + if (err.code) { + hilog.error(0x0000, "testTag", "Failed to load the content. Cause: %{public}s", JSON.stringify(err) ?? ""); + return; + } + hilog.info(0x0000, "testTag", "Succeeded in loading the content. Data: %{public}s", JSON.stringify(data) ?? ""); + }); + } + + 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"); + } +} diff --git a/distributeddatamgr/relationalstoredatagroupidtest/src/main/ets/TestAbility/pages/Index.ets b/distributeddatamgr/relationalstoredatagroupidtest/src/main/ets/TestAbility/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..7063c2427f471eb22dc9ea361188d2bbd6c24c57 --- /dev/null +++ b/distributeddatamgr/relationalstoredatagroupidtest/src/main/ets/TestAbility/pages/Index.ets @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2023 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.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/distributeddatamgr/relationalstoredatagroupidtest/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/distributeddatamgr/relationalstoredatagroupidtest/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..92a16d84e8870da219c51d9f1342c79203c1f42d --- /dev/null +++ b/distributeddatamgr/relationalstoredatagroupidtest/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,49 @@ +import hilog from '@ohos.hilog'; +import TestRunner from '@ohos.application.testRunner'; +import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; + +var abilityDelegator = undefined +var abilityDelegatorArguments = undefined + +async function onAbilityCreateCallback() { + hilog.info(0x0000, 'testTag', '%{public}s', 'onAbilityCreateCallback'); +} + +async function addAbilityMonitorCallback(err: any) { + hilog.info(0x0000, 'testTag', 'addAbilityMonitorCallback : %{public}s', JSON.stringify(err) ?? ''); +} + +export default class OpenHarmonyTestRunner implements TestRunner { + constructor() { + } + + onPrepare() { + hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner OnPrepare '); + } + + async onRun() { + hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun run'); + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var testAbilityName = abilityDelegatorArguments.bundleName + '.TestAbility' + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + var cmd = 'aa start -d 0 -a TestAbility' + ' -b ' + abilityDelegatorArguments.bundleName + var debug = abilityDelegatorArguments.parameters['-D'] + if (debug == 'true') + { + cmd += ' -D' + } + hilog.info(0x0000, 'testTag', 'cmd : %{public}s', cmd); + abilityDelegator.executeShellCommand(cmd, + (err: any, d: any) => { + hilog.info(0x0000, 'testTag', 'executeShellCommand : err : %{public}s', JSON.stringify(err) ?? ''); + hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', d.stdResult ?? ''); + hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', d.exitCode ?? ''); + }) + hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun end'); + } +} \ No newline at end of file diff --git a/distributeddatamgr/relationalstoredatagroupidtest/src/main/ets/test/List.test.ets b/distributeddatamgr/relationalstoredatagroupidtest/src/main/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..514733983ad93c3c3dfb14895b6b4926775d5b57 --- /dev/null +++ b/distributeddatamgr/relationalstoredatagroupidtest/src/main/ets/test/List.test.ets @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2023 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 relationalStoreDataGroupIdCallback from './relationalStoreDataGroupIdCallback.test' +import relationalStoreDataGroupIdPromise from './relationalStoreDataGroupIdPromise.test' + +export default function testsuite() { + relationalStoreDataGroupIdCallback() + relationalStoreDataGroupIdPromise() +} \ No newline at end of file diff --git a/distributeddatamgr/relationalstoredatagroupidtest/src/main/ets/test/relationalStoreDataGroupIdCallback.test.ets b/distributeddatamgr/relationalstoredatagroupidtest/src/main/ets/test/relationalStoreDataGroupIdCallback.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..105608401d429ae589480accc881605a7822ede3 --- /dev/null +++ b/distributeddatamgr/relationalstoredatagroupidtest/src/main/ets/test/relationalStoreDataGroupIdCallback.test.ets @@ -0,0 +1,185 @@ + /* + * Copyright (c) 2023 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 relationalStore from '@ohos.data.relationalStore'; + +const TAG = "[ttt]" +const CREATE_TABLE_TEST = "CREATE TABLE IF NOT EXISTS test (" ++ "id INTEGER PRIMARY KEY AUTOINCREMENT, " ++ "name TEXT NOT NULL, " ++ "age INTEGER, " ++ "salary REAL, " ++ "blobType BLOB)"; + +let context = globalThis.abilityContext; + +//let rdbStore; + + +export default function relationalStoreDataGroupIdCallback() { + describe('relationalStoreDataGroupIdCallback', function () { + beforeAll(function () { + console.info(TAG + 'beforeAll') + }) + + beforeEach(function () { + console.info(TAG + 'beforeEach') + }) + + afterEach(function () { + console.info(TAG + 'afterEach') + }) + + afterAll(async function () { + console.info(TAG + 'afterAll') + }) + + console.log(TAG + "*************Unit Test Begin*************"); + + + /** + * @tc.number SUB_DDM_RelationalStore_DataGroupId_Callback_0100 + * @tc.name relationalStore dataGroupId null callback test + * @tc.desc relationalStore getRdbStore dataGroupId null callback test + */ + it('SUB_DDM_RelationalStore_DataGroupId_Callback_0100', 0, async function (done) { + const STORE_CONFIG = { + name: "RdbTest.db", + securityLevel: relationalStore.SecurityLevel.S1, + dataGroupId: null, + }; + try { + relationalStore.getRdbStore(globalThis.abilityContext, STORE_CONFIG, async function (err, rdbStore) { + console.info(TAG, `Get RdbStore successfully.`); + expect().assertFail(); + done(); + await rdbStore.executeSql(CREATE_TABLE_TEST); + relationalStore.deleteRdbStore(globalThis.abilityContext, STORE_CONFIG, function (error) { + expect(error).assertFail(); + console.info(TAG, `Delete RdbStore successfully.`); + done(); + }) + }) + } catch (errInfo) { + console.error(TAG, `failed, code is ${errInfo.code},message is ${errInfo.message}`); + expect(errInfo.code).assertEqual('401'); + done(); + } + }) + + /** + * @tc.number SUB_DDM_RelationalStore_DataGroupId_Callback_0200 + * @tc.name relationalStore dataGroupId undefined callback test + * @tc.desc relationalStore getRdbStore dataGroupId undefined callback test + */ + it('SUB_DDM_RelationalStore_DataGroupId_Callback_0200', 0, async function (done) { + const STORE_CONFIG = { + name: "RdbTest.db", + securityLevel: relationalStore.SecurityLevel.S1, + dataGroupId: undefined, + }; + try { + relationalStore.getRdbStore(globalThis.abilityContext, STORE_CONFIG, async function (err, rdbStore) { + console.info(TAG, `Get RdbStore successfully.`); + expect().assertFail(); + done(); + await rdbStore.executeSql(CREATE_TABLE_TEST); + relationalStore.deleteRdbStore(globalThis.abilityContext, STORE_CONFIG, function (error) { + expect(error).assertFail(); + console.info(TAG, `Delete RdbStore successfully.`); + done(); + }) + }) + } catch (errInfo) { + console.error(TAG, `failed, code is ${errInfo.code},message is ${errInfo.message}`); + expect(errInfo.code).assertEqual('401'); + done(); + } + }) + + + /** + * @tc.number SUB_DDM_RelationalStore_DataGroupId_Callback_0300 + * @tc.name relationalStore dataGroupId callback test + * @tc.desc relationalStore getRdbStore dataGroupId callback test + */ + it('SUB_DDM_RelationalStore_DataGroupId_Callback_0300', 0, async function (done) { + const STORE_CONFIG = { + name: "RdbTest.db", + securityLevel: relationalStore.SecurityLevel.S1, + dataGroupId: '112233', + }; + try { + relationalStore.getRdbStore(globalThis.abilityContext, STORE_CONFIG, async function (err, rdbStore) { + console.info(TAG, `Get RdbStore successfully.`); + expect().assertFail(); + done(); + await rdbStore.executeSql(CREATE_TABLE_TEST); + relationalStore.deleteRdbStore(globalThis.abilityContext, STORE_CONFIG, function (error) { + expect(error).assertFail(); + console.info(TAG, `Delete RdbStore successfully.`); + done(); + }) + }) + } catch (errInfo) { + console.error(TAG, `failed, code is ${errInfo.code},message is ${errInfo.message}`); + expect(errInfo.code).assertEqual('14801002') + done(); + } + }) + + /** + * @tc.number SUB_DDM_RelationalStore_DataGroupId_Callback_0400 + * @tc.name relationalStore dataGroupId callback test + * @tc.desc relationalStore deleteRdbStore dataGroupId callback test + */ + it('SUB_DDM_RelationalStore_DataGroupId_Callback_0400', 0, async function (done) { + const STORE_CONFIG = { + name: "RdbTest.db", + securityLevel: relationalStore.SecurityLevel.S1, + dataGroupId: '123456' + }; + try { + relationalStore.getRdbStore(globalThis.abilityContext, STORE_CONFIG, async function (err, rdbStore) { + if (err) { + console.error(TAG, `Get RdbStore failed, code is ${err.code},message is ${err.message}`); + return false; + } + console.info(TAG, `Get RdbStore successfully.` + ` rdbStore = ${rdbStore} , err = ${err}`); + await rdbStore.executeSql(CREATE_TABLE_TEST); + relationalStore.deleteRdbStore(globalThis.abilityContext, STORE_CONFIG, function (err) { + if (err) { + console.error(TAG, `Delete RdbStore failed, code is ${err.code},message is ${err.message}`); + return false; + } + console.info(TAG, `Delete RdbStore successfully.` + ` rdbStore = ${rdbStore} , err = ${err}`); + expect(err === undefined).assertTrue() + done(); + }) + }) + } catch (errInfo) { + console.error(TAG, `failed, code is ${errInfo.code},message is ${errInfo.message}`); + expect(errInfo !== undefined).assertFail() + done(); + } + }) + + + + console.log(TAG + "*************Unit Test End*************"); + }) +} \ No newline at end of file diff --git a/distributeddatamgr/relationalstoredatagroupidtest/src/main/ets/test/relationalStoreDataGroupIdPromise.test.ets b/distributeddatamgr/relationalstoredatagroupidtest/src/main/ets/test/relationalStoreDataGroupIdPromise.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..fc0b403c3e8ee1b8b2a98406e9c1b40d5f17549a --- /dev/null +++ b/distributeddatamgr/relationalstoredatagroupidtest/src/main/ets/test/relationalStoreDataGroupIdPromise.test.ets @@ -0,0 +1,191 @@ +/* + * Copyright (c) 2023 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 relationalStore from '@ohos.data.relationalStore'; + +const TAG = "[ttt]" +const CREATE_TABLE_TEST = "CREATE TABLE IF NOT EXISTS test (" ++ "id INTEGER PRIMARY KEY AUTOINCREMENT, " ++ "name TEXT NOT NULL, " ++ "age INTEGER, " ++ "salary REAL, " ++ "blobType BLOB)"; + +let rdbStore; + + +export default function relationalStoreDataGroupIdPromise() { + describe('relationalStoreDataGroupIdPromise', function () { + + + console.log(TAG + "*************Unit Test Begin*************"); + + /** + * @tc.number SUB_DDM_RelationalStore_DataGroupId_Promise_0100 + * @tc.name relationalStore dataGroupId null promise test + * @tc.desc relationalStore getRdbStore dataGroupId null promise test + */ + it('SUB_DDM_RelationalStore_DataGroupId_Promise_0100', 0, async function (done) { + const STORE_CONFIG = { + name: "RdbTest.db", + securityLevel: relationalStore.SecurityLevel.S1, + dataGroupId: null, + }; + try { + relationalStore.getRdbStore(globalThis.abilityContext, STORE_CONFIG).then(async (rdbStore) => { + console.info(TAG, `Get RdbStore successfully.`); + expect().assertFail(); + done(); + await rdbStore.executeSql(CREATE_TABLE_TEST); + relationalStore.deleteRdbStore(globalThis.abilityContext, STORE_CONFIG).then(async () => { + expect().assertFail(); + console.info(TAG, `Delete RdbStore successfully.`); + done(); + }).catch((error) => { + console.info(TAG, `Delete RdbStore fail, code is ${error.code},message is ${error.message}.`); + expect(error !== null).assertFail(); + done(); + }) + }).catch((err) => { + console.info(TAG, `Get RdbStore fail, code is ${err.code},message is ${err.message}.`); + expect(err !== null).assertFail(); + done(); + }) + } catch (errInfo) { + console.error(TAG, `failed, code is ${errInfo.code},message is ${errInfo.message}`); + expect(errInfo.code).assertEqual('401'); + done(); + } + }) + + /** + * @tc.number SUB_DDM_RelationalStore_DataGroupId_Promise_0200 + * @tc.name relationalStore dataGroupId undefined callback test + * @tc.desc relationalStore getRdbStore dataGroupId undefined callback test + */ + it('SUB_DDM_RelationalStore_DataGroupId_Promise_0200', 0, async function (done) { + const STORE_CONFIG = { + name: "RdbTest.db", + securityLevel: relationalStore.SecurityLevel.S1, + dataGroupId: undefined, + }; + try { + relationalStore.getRdbStore(globalThis.abilityContext, STORE_CONFIG).then(async (rdbStore) => { + console.info(TAG, `Get RdbStore successfully.`); + expect().assertFail(); + done(); + await rdbStore.executeSql(CREATE_TABLE_TEST); + relationalStore.deleteRdbStore(globalThis.abilityContext, STORE_CONFIG).then(async () => { + expect().assertFail(); + console.info(TAG, `Delete RdbStore successfully.`); + done(); + }).catch((error) => { + console.info(TAG, `Delete RdbStore fail, code is ${error.code},message is ${error.message}.`); + expect(error !== null).assertFail(); + done(); + }) + }).catch((err) => { + console.info(TAG, `Get RdbStore fail, code is ${err.code},message is ${err.message}.`); + expect(err !== null).assertFail(); + done(); + }) + } catch (errInfo) { + console.error(TAG, `failed, code is ${errInfo.code},message is ${errInfo.message}`); + expect(errInfo.code).assertEqual('401'); + done(); + } + }) + + + /** + * @tc.number SUB_DDM_RelationalStore_DataGroupId_Promise_0300 + * @tc.name relationalStore dataGroupId callback test + * @tc.desc relationalStore getRdbStore dataGroupId callback test + */ + it('SUB_DDM_RelationalStore_DataGroupId_Promise_0300', 0, async function (done) { + const STORE_CONFIG = { + name: "RdbTest.db", + securityLevel: relationalStore.SecurityLevel.S1, + dataGroupId: '112233', + }; + try { + relationalStore.getRdbStore(globalThis.abilityContext, STORE_CONFIG).then(async (rdbStore) => { + console.info(TAG, `Get RdbStore successfully.`); + expect().assertFail(); + done(); + await rdbStore.executeSql(CREATE_TABLE_TEST); + relationalStore.deleteRdbStore(globalThis.abilityContext, STORE_CONFIG).then(async () => { + expect().assertFail(); + console.info(TAG, `Delete RdbStore successfully.`); + done(); + }).catch((error) => { + console.info(TAG, `Delete RdbStore fail, code is ${error.code},message is ${error.message}.`); + expect(error !== null).assertFail(); + done(); + }) + }).catch((err) => { + console.info(TAG, `Get RdbStore fail, code is ${err.code},message is ${err.message}.`); + expect(err !== null).assertFail(); + done(); + }) + } catch (errInfo) { + console.error(TAG, `failed, code is ${errInfo.code},message is ${errInfo.message}`); + expect(errInfo.code).assertEqual('14801002'); + done(); + } + }) + + /** + * @tc.number SUB_DDM_RelationalStore_DataGroupId_Promise_0400 + * @tc.name relationalStore dataGroupId callback test + * @tc.desc relationalStore deleteRdbStore dataGroupId callback test + */ + it('SUB_DDM_RelationalStore_DataGroupId_Promise_0400', 0, async function (done) { + const STORE_CONFIG = { + name: "RdbTest.db", + securityLevel: relationalStore.SecurityLevel.S1, + dataGroupId: '123456', + }; + try { + relationalStore.getRdbStore(globalThis.abilityContext, STORE_CONFIG).then(async (rdbStore) => { + console.info(TAG, `Get RdbStore successfully.`); + // await rdbStore.executeSql(CREATE_TABLE_TEST); + rdbStore.executeSql(CREATE_TABLE_TEST, [], async function (error) { + if (error) { + console.error(TAG, `ExecuteSql failed, code is ${error.code},message is ${error.message}`); + return; + } + console.info(TAG, `executeSql1 done.` + error); + expect(error === undefined).assertTrue(); + await relationalStore.deleteRdbStore(globalThis.abilityContext, STORE_CONFIG) + done(); + }) + }).catch((err) => { + console.info(TAG, `Get RdbStore fail, code is ${err.code},message is ${err.message}.`); + expect(err !== null).assertFail(); + done(); + }) + } catch (errInfo) { + console.error(TAG, `failed, code is ${errInfo.code},message is ${errInfo.message}`); + expect(errInfo !== null).assertFail(); + done(); + } + }) + + console.info(TAG + "*************Unit Test End*************"); + }) +} \ No newline at end of file diff --git a/distributeddatamgr/relationalstoredatagroupidtest/src/main/module.json b/distributeddatamgr/relationalstoredatagroupidtest/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..766cc11af93df1b5fad8748ad7d7ab28f8c0b8b2 --- /dev/null +++ b/distributeddatamgr/relationalstoredatagroupidtest/src/main/module.json @@ -0,0 +1,39 @@ +{ + "module": { + "name": "relationalstoreDataGroupId", + "type": "feature", + "description": "$string:module_test_desc", + "mainElement": "TestAbility", + "deviceTypes": [ + "default", + "tablet", + "phone", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:test_pages", + "abilities": [ + { + "name": "TestAbility", + "srcEntry": "./ets/TestAbility/TestAbility.ets", + "description": "$string:TestAbility_desc", + "icon": "$media:icon", + "label": "$string:TestAbility_label", + "exported": true, + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + } + ] + } +} diff --git a/distributeddatamgr/relationalstoredatagroupidtest/src/main/resources/base/element/color.json b/distributeddatamgr/relationalstoredatagroupidtest/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/distributeddatamgr/relationalstoredatagroupidtest/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/distributeddatamgr/relationalstoredatagroupidtest/src/main/resources/base/element/string.json b/distributeddatamgr/relationalstoredatagroupidtest/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..65d8fa5a7cf54aa3943dcd0214f58d1771bc1f6c --- /dev/null +++ b/distributeddatamgr/relationalstoredatagroupidtest/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "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/distributeddatamgr/relationalstoredatagroupidtest/src/main/resources/base/media/icon.png b/distributeddatamgr/relationalstoredatagroupidtest/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/distributeddatamgr/relationalstoredatagroupidtest/src/main/resources/base/media/icon.png differ diff --git a/distributeddatamgr/relationalstoredatagroupidtest/src/main/resources/base/profile/test_pages.json b/distributeddatamgr/relationalstoredatagroupidtest/src/main/resources/base/profile/test_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..77e90731b5a38d861663029b483df3d3ac9ec74b --- /dev/null +++ b/distributeddatamgr/relationalstoredatagroupidtest/src/main/resources/base/profile/test_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "TestAbility/pages/Index" + ] +}