提交 4783e082 编写于 作者: Y yanglifeng1217

<modified>

Signed-off-by: Nyanglifeng1217 <yanglifeng5@huawei.com>
上级 dfe0d829
......@@ -23,10 +23,10 @@ group("distributeddatamgr") {
"dataSharejstest/hap:dataShare_js_test",
"distributedKVStoretest:distributedKVStoretest",
"kvStoretest:kvStoretest",
"preferencesdatagroupidtest:ActsPreferencesDataGroupIdTest",
"preferencesjstest/hap:preferences_js_test",
"relationalStoretest:relationalStoretest",
"relationalstoredatagroupidtest:ActsRelationalstoreDataGroupIdTest",
"preferencesdatagroupidtest:ActsPreferencesDataGroupIdTest",
]
} else {
deps = [
......
......@@ -26,8 +26,8 @@ export default function preferencesDataGroupIdCallback() {
/**
* @tc.number SUB_DDM_Preferences_DataGroupId_Callback_0100
* @tc.name preferences dataGroupId null callback test
* @tc.desc preferences dataGroupId null callback test
* @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 = {
......@@ -55,7 +55,7 @@ export default function preferencesDataGroupIdCallback() {
/**
* @tc.number SUB_DDM_Preferences_DataGroupId_Callback_0200
* @tc.name preferences dataGroupId undefined callback test
* @tc.desc 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 = {
......@@ -82,7 +82,7 @@ export default function preferencesDataGroupIdCallback() {
/**
* @tc.number SUB_DDM_Preferences_DataGroupId_Callback_0300
* @tc.name preferences dataGroupId callback test
* @tc.desc preferences dataGroupId callback test
* @tc.desc preferences getPreferences dataGroupId callback test
*/
it('SUB_DDM_Preferences_DataGroupId_Callback_0300', 0, async function (done) {
const Options = {
......@@ -110,7 +110,7 @@ export default function preferencesDataGroupIdCallback() {
/**
* @tc.number SUB_DDM_Preferences_DataGroupId_Callback_0400
* @tc.name preferences dataGroupId callback test
* @tc.desc preferences dataGroupId callback test
* @tc.desc preferences deletePreferences dataGroupId callback test
*/
it('SUB_DDM_Preferences_DataGroupId_Callback_0400', 0, async function (done) {
const Options = {
......@@ -143,7 +143,7 @@ export default function preferencesDataGroupIdCallback() {
/**
* @tc.number SUB_DDM_Preferences_DataGroupId_Callback_0500
* @tc.name preferences dataGroupId null callback test
* @tc.desc 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 = {
......@@ -171,7 +171,7 @@ export default function preferencesDataGroupIdCallback() {
/**
* @tc.number SUB_DDM_Preferences_DataGroupId_Callback_0600
* @tc.name preferences dataGroupId undefined callback test
* @tc.desc 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 = {
......@@ -198,7 +198,7 @@ export default function preferencesDataGroupIdCallback() {
/**
* @tc.number SUB_DDM_Preferences_DataGroupId_Callback_0700
* @tc.name preferences dataGroupId callback test
* @tc.desc preferences dataGroupId callback test
* @tc.desc preferences removePreferencesFromCache dataGroupId callback test
*/
it('SUB_DDM_Preferences_DataGroupId_Callback_0700', 0, async function (done) {
const Options = {
......@@ -226,7 +226,7 @@ export default function preferencesDataGroupIdCallback() {
/**
* @tc.number SUB_DDM_Preferences_DataGroupId_Callback_0800
* @tc.name preferences dataGroupId callback test
* @tc.desc preferences dataGroupId callback test
* @tc.desc preferences removePreferencesFromCache dataGroupId callback test
*/
it('SUB_DDM_Preferences_DataGroupId_Callback_0800', 0, async function (done) {
const Options = {
......
......@@ -27,7 +27,7 @@ export default function preferencesDataGroupIdPromise() {
/**
* @tc.number SUB_DDM_Preferences_DataGroupId_Promise_0100
* @tc.name preferences dataGroupId null promise test
* @tc.desc 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 = {
......@@ -63,7 +63,7 @@ export default function preferencesDataGroupIdPromise() {
/**
* @tc.number SUB_DDM_Preferences_DataGroupId_Promise_0200
* @tc.name preferences dataGroupId undefined promise test
* @tc.desc 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 = {
......@@ -99,7 +99,7 @@ export default function preferencesDataGroupIdPromise() {
/**
* @tc.number SUB_DDM_Preferences_DataGroupId_Promise_0300
* @tc.name preferences dataGroupId promise test
* @tc.desc preferences dataGroupId promise test
* @tc.desc preferences getPreferences dataGroupId promise test
*/
it('SUB_DDM_Preferences_DataGroupId_Promise_0300', 0, async function (done) {
const Options = {
......@@ -135,7 +135,7 @@ 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
* @tc.desc preferences getPreferences dataGroupId null promise test
*/
it('SUB_DDM_Preferences_DataGroupId_Promise_0400', 0, async function (done) {
const Options = {
......@@ -171,7 +171,7 @@ export default function preferencesDataGroupIdPromise() {
/**
* @tc.number SUB_DDM_Preferences_DataGroupId_Promise_0500
* @tc.name preferences dataGroupId undefined promise test
* @tc.desc 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 = {
......@@ -207,7 +207,7 @@ export default function preferencesDataGroupIdPromise() {
/**
* @tc.number SUB_DDM_Preferences_DataGroupId_Promise_0600
* @tc.name preferences dataGroupId promise test
* @tc.desc preferences dataGroupId promise test
* @tc.desc preferences removePreferencesFromCache dataGroupId promise test
*/
it('SUB_DDM_Preferences_DataGroupId_Promise_0600', 0, async function (done) {
const Options = {
......
......@@ -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('testPreferencesCallback0172', 0, async function (done) {
console.log(TAG + "testPreferencesCallback0172 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(TAG + "flush err.");
expect().assertFail();
}
console.log(TAG + "flush done.");
await dataPreferences.removePreferencesFromCacheSync(context, NAME);
let value = mPreferences.getSync(KEY_TEST_STRING_ELEMENT, "defaultvalue")
console.log(TAG + "testPreferencesCallback0172 end." + value);
expect('test').assertEqual(value);
done();
console.log(TAG + "testPreferencesCallback0172 end.");
});
})
})
}
\ No newline at end of file
/*
* 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()
}
/*
* 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
......@@ -54,7 +54,7 @@ export default function relationalStoreDataGroupIdCallback() {
/**
* @tc.number SUB_DDM_RelationalStore_DataGroupId_Callback_0100
* @tc.name relationalStore dataGroupId null callback test
* @tc.desc 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 = {
......@@ -84,7 +84,7 @@ export default function relationalStoreDataGroupIdCallback() {
/**
* @tc.number SUB_DDM_RelationalStore_DataGroupId_Callback_0200
* @tc.name relationalStore dataGroupId undefined callback test
* @tc.desc 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 = {
......@@ -95,7 +95,7 @@ export default function relationalStoreDataGroupIdCallback() {
try {
relationalStore.getRdbStore(globalThis.abilityContext, STORE_CONFIG, async function (err, rdbStore) {
console.info(TAG, `Get RdbStore successfully.`);
expect(err !== null && rdbStore !== null).assertFail();
expect().assertFail();
done();
await rdbStore.executeSql(CREATE_TABLE_TEST);
relationalStore.deleteRdbStore(globalThis.abilityContext, STORE_CONFIG, function (error) {
......@@ -115,7 +115,7 @@ export default function relationalStoreDataGroupIdCallback() {
/**
* @tc.number SUB_DDM_RelationalStore_DataGroupId_Callback_0300
* @tc.name relationalStore dataGroupId callback test
* @tc.desc 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 = {
......@@ -126,7 +126,7 @@ export default function relationalStoreDataGroupIdCallback() {
try {
relationalStore.getRdbStore(globalThis.abilityContext, STORE_CONFIG, async function (err, rdbStore) {
console.info(TAG, `Get RdbStore successfully.`);
expect(err !== null && rdbStore !== null).assertFail();
expect().assertFail();
done();
await rdbStore.executeSql(CREATE_TABLE_TEST);
relationalStore.deleteRdbStore(globalThis.abilityContext, STORE_CONFIG, function (error) {
......@@ -145,7 +145,7 @@ export default function relationalStoreDataGroupIdCallback() {
/**
* @tc.number SUB_DDM_RelationalStore_DataGroupId_Callback_0400
* @tc.name relationalStore dataGroupId callback test
* @tc.desc 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 = {
......
......@@ -37,7 +37,7 @@ export default function relationalStoreDataGroupIdPromise() {
/**
* @tc.number SUB_DDM_RelationalStore_DataGroupId_Promise_0100
* @tc.name relationalStore dataGroupId null promise test
* @tc.desc 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 = {
......@@ -75,7 +75,7 @@ export default function relationalStoreDataGroupIdPromise() {
/**
* @tc.number SUB_DDM_RelationalStore_DataGroupId_Promise_0200
* @tc.name relationalStore dataGroupId undefined callback test
* @tc.desc 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 = {
......@@ -114,7 +114,7 @@ export default function relationalStoreDataGroupIdPromise() {
/**
* @tc.number SUB_DDM_RelationalStore_DataGroupId_Promise_0300
* @tc.name relationalStore dataGroupId callback test
* @tc.desc 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 = {
......@@ -152,7 +152,7 @@ export default function relationalStoreDataGroupIdPromise() {
/**
* @tc.number SUB_DDM_RelationalStore_DataGroupId_Promise_0400
* @tc.name relationalStore dataGroupId callback test
* @tc.desc 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 = {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册