diff --git a/distributeddatamgr/preferencesdatagroupidtest/src/main/ets/test/preferencesDataGroupIdCallback.test.ets b/distributeddatamgr/preferencesdatagroupidtest/src/main/ets/test/preferencesDataGroupIdCallback.test.ets index 0d508dadd46ba8546c1697f02bb090aaabb22876..7df725d55d9f785af2f3cf30925e7d58ac8d7fd9 100644 --- a/distributeddatamgr/preferencesdatagroupidtest/src/main/ets/test/preferencesDataGroupIdCallback.test.ets +++ b/distributeddatamgr/preferencesdatagroupidtest/src/main/ets/test/preferencesDataGroupIdCallback.test.ets @@ -107,6 +107,155 @@ export default function preferencesDataGroupIdCallback() { } }) + /** + * @tc.number SUB_DDM_Preferences_DataGroupId_Callback_0400 + * @tc.name preferences dataGroupId callback test + * @tc.desc preferences 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 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 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 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('14801002'); + done(); + } + }) + + /** + * @tc.number SUB_DDM_Preferences_DataGroupId_Callback_0800 + * @tc.name preferences dataGroupId callback test + * @tc.desc preferences 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 index b24afbfa9ded9a2bc30774e8d3d13ae109d092f9..676be246125b83bfd17c58a60c64424af270e6e9 100644 --- a/distributeddatamgr/preferencesdatagroupidtest/src/main/ets/test/preferencesDataGroupIdPromise.test.ets +++ b/distributeddatamgr/preferencesdatagroupidtest/src/main/ets/test/preferencesDataGroupIdPromise.test.ets @@ -132,6 +132,114 @@ export default function preferencesDataGroupIdPromise() { } }) + /** + * @tc.number SUB_DDM_Preferences_DataGroupId_Promise_0400 + * @tc.name preferences dataGroupId null promise test + * @tc.desc preferences 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 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 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('14801002'); + done(); + } + }) + console.log(TAG + "*************Unit Test End*************"); }) } \ 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 index 95efef0ab7aea55608941e59b6cda8cb48b1412f..358e547463e731c7f4db7bfdcc73ba791f2b6c7a 100644 --- a/distributeddatamgr/relationalstoredatagroupidtest/src/main/ets/test/relationalStoreDataGroupIdCallback.test.ets +++ b/distributeddatamgr/relationalstoredatagroupidtest/src/main/ets/test/relationalStoreDataGroupIdCallback.test.ets @@ -143,42 +143,41 @@ export default function relationalStoreDataGroupIdCallback() { }) /** - * @tc.number SUB_DDM_RelationalStore_DataGroupId_Callback_0100 + * @tc.number SUB_DDM_RelationalStore_DataGroupId_Callback_0400 * @tc.name relationalStore dataGroupId callback test * @tc.desc relationalStore dataGroupId callback test */ - // it('SUB_DDM_RelationalStore_DataGroupId_Callback_0100', 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, store) { - // rdbStore = store; - // if (err) { - // console.error(TAG, `Get RdbStore failed, code is ${err.code},message is ${err.message}`); - // return false; - // } - // console.info(TAG, `Get RdbStore successfully.`); - // 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.`); - // expect(err === null).assertTrue() - // done(); - // }) - // }) - // } catch (errInfo) { - // console.error(TAG, `failed, code is ${errInfo.code},message is ${errInfo.message}`); - // expect(errInfo !== null).assertFail() - // done(); - // } - // - // }) + 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*************"); diff --git a/distributeddatamgr/relationalstoredatagroupidtest/src/main/ets/test/relationalStoreDataGroupIdPromise.test.ets b/distributeddatamgr/relationalstoredatagroupidtest/src/main/ets/test/relationalStoreDataGroupIdPromise.test.ets index 4f6246500ab698e9183b5592103e764771bb8894..c660647722337a58e91a619973fe329d2decc3cb 100644 --- a/distributeddatamgr/relationalstoredatagroupidtest/src/main/ets/test/relationalStoreDataGroupIdPromise.test.ets +++ b/distributeddatamgr/relationalstoredatagroupidtest/src/main/ets/test/relationalStoreDataGroupIdPromise.test.ets @@ -149,6 +149,43 @@ export default function relationalStoreDataGroupIdPromise() { } }) + /** + * @tc.number SUB_DDM_RelationalStore_DataGroupId_Promise_0400 + * @tc.name relationalStore dataGroupId callback test + * @tc.desc relationalStore 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