提交 6cf2aa9d 编写于 作者: Y yanglifeng1217

<modified>

Signed-off-by: Nyanglifeng1217 <yanglifeng5@huawei.com>
上级 4b707a6e
...@@ -107,6 +107,155 @@ export default function preferencesDataGroupIdCallback() { ...@@ -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*************"); console.log(TAG + "*************Unit Test End*************");
}) })
} }
\ No newline at end of file
...@@ -132,6 +132,114 @@ export default function preferencesDataGroupIdPromise() { ...@@ -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*************"); console.log(TAG + "*************Unit Test End*************");
}) })
} }
\ No newline at end of file
...@@ -143,42 +143,41 @@ export default function relationalStoreDataGroupIdCallback() { ...@@ -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.name relationalStore dataGroupId callback test
* @tc.desc relationalStore dataGroupId callback test * @tc.desc relationalStore dataGroupId callback test
*/ */
// it('SUB_DDM_RelationalStore_DataGroupId_Callback_0100', 0, async function (done) { it('SUB_DDM_RelationalStore_DataGroupId_Callback_0400', 0, async function (done) {
// const STORE_CONFIG = { const STORE_CONFIG = {
// name: "RdbTest.db", name: "RdbTest.db",
// securityLevel: relationalStore.SecurityLevel.S1, securityLevel: relationalStore.SecurityLevel.S1,
// dataGroupId: '123456' dataGroupId: '123456'
// }; };
// try { try {
// relationalStore.getRdbStore(globalThis.abilityContext, STORE_CONFIG, async function (err, store) { relationalStore.getRdbStore(globalThis.abilityContext, STORE_CONFIG, async function (err, rdbStore) {
// rdbStore = store; if (err) {
// if (err) { console.error(TAG, `Get RdbStore failed, code is ${err.code},message is ${err.message}`);
// console.error(TAG, `Get RdbStore failed, code is ${err.code},message is ${err.message}`); return false;
// return false; }
// } console.info(TAG, `Get RdbStore successfully.` + ` rdbStore = ${rdbStore} , err = ${err}`);
// console.info(TAG, `Get RdbStore successfully.`); await rdbStore.executeSql(CREATE_TABLE_TEST);
// await rdbStore.executeSql(CREATE_TABLE_TEST); relationalStore.deleteRdbStore(globalThis.abilityContext, STORE_CONFIG, function (err) {
// relationalStore.deleteRdbStore(globalThis.abilityContext, STORE_CONFIG, function (err) { if (err) {
// if (err) { console.error(TAG, `Delete RdbStore failed, code is ${err.code},message is ${err.message}`);
// console.error(TAG, `Delete RdbStore failed, code is ${err.code},message is ${err.message}`); return false;
// return false; }
// } console.info(TAG, `Delete RdbStore successfully.` + ` rdbStore = ${rdbStore} , err = ${err}`);
// console.info(TAG, `Delete RdbStore successfully.`); expect(err === undefined).assertTrue()
// expect(err === null).assertTrue() done();
// done(); })
// }) })
// }) } catch (errInfo) {
// } catch (errInfo) { console.error(TAG, `failed, code is ${errInfo.code},message is ${errInfo.message}`);
// console.error(TAG, `failed, code is ${errInfo.code},message is ${errInfo.message}`); expect(errInfo !== undefined).assertFail()
// expect(errInfo !== null).assertFail() done();
// done(); }
// } })
//
// })
console.log(TAG + "*************Unit Test End*************"); console.log(TAG + "*************Unit Test End*************");
......
...@@ -149,6 +149,43 @@ export default function relationalStoreDataGroupIdPromise() { ...@@ -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*************"); console.info(TAG + "*************Unit Test End*************");
}) })
} }
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册