提交 28830aa8 编写于 作者: L liangzhenyu123

用例整改

Signed-off-by: Nliangzhenyu123 <liangzhenyu6@huawei.com>
上级 02e1bd1f
......@@ -17,8 +17,7 @@
"name": ".entry",
"mainAbility": ".MainAbility",
"deviceType": [
"tablet",
"default",
"default",
"phone"
],
"distro": {
......@@ -27,6 +26,23 @@
"moduleType": "entry",
"installationFree": false
},
"defPermissions": [
{
"availableScope": [],
"grantMode": "user_grant",
"name": "ohos.permission.DISTRIBUTED_DATASYNC"
}
],
"reqPermissions": [
{
"name": "ohos.permission.GRANT_SENSITIVE_PERMISSIONS",
"reason": "ceshi"
},
{
"name": "ohos.permission.DISTRIBUTED_DATASYNC",
"reason": "ceshi"
}
],
"abilities": [
{
"skills": [
......
......@@ -13,6 +13,8 @@
* limitations under the License.
*/
import objectStoreTest from './ObjectStoreJsunit.test.js'
import objectStoreTestV9 from './ObjectStoreJsunitV9.test.js'
export default function testsuite() {
objectStoreTest()
objectStoreTestV9()
}
......@@ -18,7 +18,6 @@
"mainAbility": ".MainAbility",
"srcPath":"",
"deviceType": [
"tablet",
"default",
"phone"
],
......
......@@ -13,30 +13,30 @@
* limitations under the License.
*/
import SingleKvStorePromiseTest from './SingleKvStoreKVPromiseJsTest.js'
import deviceKvStoreCallbackTest from './DeviceKvStoreKVCallbackJsTest.js'
import deviceKvStorePromiseTest from './DeviceKvStoreKVPromiseJsTest.js'
import kvManagerCallbackTest from './KvManagerKVCallbackJsTest.js'
import KVManagerPromiseTest from './KvManagerKVPromiseJsTest.js'
import KvStoreResultSetTest from './KvStoreResultSetKVJsTest.js'
// import deviceKvStoreCallbackTest from './DeviceKvStoreKVCallbackJsTest.js'
// import deviceKvStorePromiseTest from './DeviceKvStoreKVPromiseJsTest.js'
// import kvManagerCallbackTest from './KvManagerKVCallbackJsTest.js'
// import KVManagerPromiseTest from './KvManagerKVPromiseJsTest.js'
// import KvStoreResultSetTest from './KvStoreResultSetKVJsTest.js'
import queryTest from './QueryKVJsTest.js'
import SingleKvStoreCallbackTest from './SingleKvStoreKVCallbackJsTest.js'
import FieldNodeTest from './FieldNodeJsTest.js'
import kvStoreBackupCallbackJsunittest from './KvStoreBackupCallbackJsTest.js'
import kvStoreBackupPromiseJsunittest from './KvStoreBackupPromiseJsTest.js'
import schemaTest from './SchemaJsTest.js'
import singleKvStoreEnumTest from './SingleKvStoreEnumJsTest.js'
// import FieldNodeTest from './FieldNodeJsTest.js'
// import kvStoreBackupCallbackJsunittest from './KvStoreBackupCallbackJsTest.js'
// import kvStoreBackupPromiseJsunittest from './KvStoreBackupPromiseJsTest.js'
// import schemaTest from './SchemaJsTest.js'
// import singleKvStoreEnumTest from './SingleKvStoreEnumJsTest.js'
export default function testsuite() {
SingleKvStorePromiseTest()
deviceKvStoreCallbackTest()
deviceKvStorePromiseTest()
kvManagerCallbackTest()
KVManagerPromiseTest()
KvStoreResultSetTest()
// deviceKvStoreCallbackTest()
// deviceKvStorePromiseTest()
// kvManagerCallbackTest()
// KVManagerPromiseTest()
// KvStoreResultSetTest()
queryTest()
SingleKvStoreCallbackTest()
FieldNodeTest()
kvStoreBackupCallbackJsunittest()
kvStoreBackupPromiseJsunittest()
schemaTest()
singleKvStoreEnumTest()
// FieldNodeTest()
// kvStoreBackupCallbackJsunittest()
// kvStoreBackupPromiseJsunittest()
// schemaTest()
// singleKvStoreEnumTest()
}
......@@ -1932,12 +1932,12 @@ describe('queryTest', function() {
})
/**
* @tc.number: SUB_DDM_DKV_QUERY_PREFIXKEY_PROMISE_0200
* @tc.number: SUB_DDM_DKV_QUERY_SETSUGGESTINDEX_PROMISE_0200
* @tc.desc: Test Js Api Query.SetSuggestIndex() testcase 002
* @tc.type: FUNC
* @tc.name Test Js Api Query.SetSuggestIndex() testcase 002
*/
it('SUB_DDM_DKV_QUERY_PREFIXKEY_PROMISE_0200', 0, async function(done) {
it('SUB_DDM_DKV_QUERY_SETSUGGESTINDEX_PROMISE_0200', 0, async function(done) {
var query = null;
try {
query = new ddm.Query();
......@@ -1953,12 +1953,12 @@ describe('queryTest', function() {
})
/**
* @tc.number: SUB_DDM_DKV_QUERY_PREFIXKEY_PROMISE_0300
* @tc.number: SUB_DDM_DKV_QUERY_SETSUGGESTINDEX_PROMISE_0300
* @tc.desc: Test Js Api Query.SetSuggestIndex() testcase 003
* @tc.type: FUNC
* @tc.name Test Js Api Query.SetSuggestIndex() testcase 003
*/
it('SUB_DDM_DKV_QUERY_PREFIXKEY_PROMISE_0300', 0, async function(done) {
it('SUB_DDM_DKV_QUERY_SETSUGGESTINDEX_PROMISE_0300', 0, async function(done) {
var query = null;
try {
query = new ddm.Query();
......
......@@ -2337,14 +2337,24 @@ describe('SingleKvStoreCallbackTest', function () {
*/
it('SUB_DDM_DKV_SINGLEKVSTORE_CLOSERESULT_CALLBACK_8200', 0, async function (done) {
console.info('SingleKvStoreCloseResultSetCallbackTest004');
try {
console.info('SingleKvStoreCloseResultSetCallbackTest004 success');
}catch(e) {
console.error('SingleKvStoreCloseResultSetCallbackTest004 e ' + `, error code is ${e.code}, message is ${e.message}`);
expect(null).assertFail();
let resultSet = null;
await kvStore.getResultSet('batch_test_string_key').then((result) => {
console.info('SingleKvStoreCloseResultSetCallbackTest004 getResultSet success');
resultSet = result;
})
try{
kvStore.closeResultSet("",(err, data) => {
console.info('SingleKvStoreCloseResultSetCallbackTest004 close result finish')
expect(null).assertFail();
})
}catch(err){
expect(err.code).assertEqual("401")
}
done();
})
});
/**
* @tc.number SUB_DDM_DKV_SINGLEKVSTORE_GETENTRIES_CALLBACK_8300
......
......@@ -2420,47 +2420,47 @@ describe('SingleKvStorePromiseTest', function () {
})
/**
* @tc.number SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0100
* @tc.number SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0700
* @tc.desc Test Js Api SingleKvStoreGetSecurityLevel testcase 001
* @tc.type: FUNC
* @tc.name Test Js Api SingleKvStoreGetSecurityLevel testcase 001
*/
it('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0100', 0, async function (done) {
console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0100');
it('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0700', 0, async function (done) {
console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0700');
try {
await kvStore.getSecurityLevel().then((data) => {
console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0100 getSecurityLevel success');
console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0100 getSecurityLevel success: ' + data);
console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0100 getSecurityLevel success: ' + factory.SecurityLevel.S2);
console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0700 getSecurityLevel success');
console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0700 getSecurityLevel success: ' + data);
console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0700 getSecurityLevel success: ' + factory.SecurityLevel.S2);
expect(data == factory.SecurityLevel.S2).assertTrue();
}).catch((err) => {
console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0100 getSecurityLevel fail ' + `, error code is ${err.code}, message is ${err.message}`);
console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0700 getSecurityLevel fail ' + `, error code is ${err.code}, message is ${err.message}`);
expect(null).assertFail();
});
}catch(e) {
console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0100 e ' + `, error code is ${e.code}, message is ${e.message}`);
console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0700 e ' + `, error code is ${e.code}, message is ${e.message}`);
expect(null).assertFail();
}
done();
})
/**
* @tc.number SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0200
* @tc.number SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0800
* @tc.desc Test Js Api SingleKvStoreGetSecurityLevel testcase 002
* @tc.type: FUNC
* @tc.name Test Js Api SingleKvStoreGetSecurityLevel testcase 002
*/
it('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0200', 0, async function (done) {
console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0200');
it('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0800', 0, async function (done) {
console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0800');
try {
await kvStore.getSecurityLevel(1).then((data) => {
console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0200 getSecurityLevel success');
console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0800 getSecurityLevel success');
expect(null).assertFail();
}).catch((err) => {
console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0200 getSecurityLevel fail ' + `, error code is ${err.code}, message is ${err.message}`);
console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0800 getSecurityLevel fail ' + `, error code is ${err.code}, message is ${err.message}`);
});
}catch(e) {
console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0200 e ' + `, error code is ${e.code}, message is ${e.message}`);
console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0800 e ' + `, error code is ${e.code}, message is ${e.message}`);
}
done();
})
......@@ -2508,13 +2508,13 @@ describe('SingleKvStorePromiseTest', function () {
})
/**
* @tc.number SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0100
* @tc.desc Test Js Api SingleKvStoreGetResultSet testcase 001
* @tc.number SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0700
* @tc.desc Test Js Api SingleKvStoreGetResultSet testcase 007
* @tc.type: FUNC
* @tc.name Test Js Api SingleKvStoreGetResultSet testcase 001
* @tc.name Test Js Api SingleKvStoreGetResultSet testcase 007
*/
it('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0100', 0, async function (done) {
console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0100');
it('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0700', 0, async function (done) {
console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0700');
try {
let resultSet;
let entries = [];
......@@ -2530,61 +2530,61 @@ describe('SingleKvStorePromiseTest', function () {
entries.push(entry);
}
await kvStore.putBatch(entries).then(async (err) => {
console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0100 putBatch success');
console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0700 putBatch success');
expect(err == undefined).assertTrue();
}).catch((err) => {
console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0100 putBatch fail ' + `, error code is ${err.code}, message is ${err.message}`);
console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0700 putBatch fail ' + `, error code is ${err.code}, message is ${err.message}`);
expect(null).assertFail();
});
await kvStore.getResultSet('batch_test_string_key').then((result) => {
console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0100 getResultSet success');
console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0700 getResultSet success');
resultSet = result;
expect(resultSet.getCount() == 10).assertTrue();
}).catch((err) => {
console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0100 getResultSet fail ' + `, error code is ${err.code}, message is ${err.message}`);
console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0700 getResultSet fail ' + `, error code is ${err.code}, message is ${err.message}`);
expect(null).assertFail();
});
await kvStore.closeResultSet(resultSet).then((err) => {
console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0100 closeResultSet success');
console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0700 closeResultSet success');
expect(err == undefined).assertTrue();
}).catch((err) => {
console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0100 closeResultSet fail ' + `, error code is ${err.code}, message is ${err.message}`);
console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0700 closeResultSet fail ' + `, error code is ${err.code}, message is ${err.message}`);
expect(null).assertFail();
});
}catch(e) {
console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0100 e ' + `, error code is ${e.code}, message is ${e.message}`);
console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0700 e ' + `, error code is ${e.code}, message is ${e.message}`);
expect(null).assertFail();
}
done();
})
/**
* @tc.number SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0200
* @tc.desc Test Js Api SingleKvStoreGetResultSet testcase 002
* @tc.number SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0800
* @tc.desc Test Js Api SingleKvStoreGetResultSet testcase 008
* @tc.type: FUNC
* @tc.name Test Js Api SingleKvStoreGetResultSet testcase 002
* @tc.name Test Js Api SingleKvStoreGetResultSet testcase 008
*/
it('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0200', 0, async function (done) {
console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0200');
it('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0800', 0, async function (done) {
console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0800');
try {
let resultSet;
await kvStore.getResultSet('batch_test_string_key').then((result) => {
console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0200 getResultSet success');
console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0800 getResultSet success');
resultSet = result;
expect(resultSet.getCount() == 0).assertTrue();
}).catch((err) => {
console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0200 getResultSet fail ' + `, error code is ${err.code}, message is ${err.message}`);
console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0800 getResultSet fail ' + `, error code is ${err.code}, message is ${err.message}`);
expect(null).assertFail();
});
await kvStore.closeResultSet(resultSet).then((err) => {
console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0200 closeResultSet success');
console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0800 closeResultSet success');
expect(err == undefined).assertTrue();
}).catch((err) => {
console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0200 closeResultSet fail ' + `, error code is ${err.code}, message is ${err.message}`);
console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0800 closeResultSet fail ' + `, error code is ${err.code}, message is ${err.message}`);
expect(null).assertFail();
});
}catch(e) {
console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0200 e ' + `, error code is ${e.code}, message is ${e.message}`);
console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0800 e ' + `, error code is ${e.code}, message is ${e.message}`);
expect(null).assertFail();
}
done();
......@@ -2661,7 +2661,7 @@ describe('SingleKvStorePromiseTest', function () {
console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0500 putBatch success');
expect(err == undefined).assertTrue();
}).catch((err) => {
console.error('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0100 putBatch fail ' + `, error code is ${err.code}, message is ${err.message}`);
console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0500 putBatch fail ' + `, error code is ${err.code}, message is ${err.message}`);
expect(null).assertFail();
});
var query = new factory.Query();
......@@ -2714,7 +2714,7 @@ describe('SingleKvStorePromiseTest', function () {
console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0600 putBatch success');
expect(err == undefined).assertTrue();
}).catch((err) => {
console.error('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0100 putBatch fail ' + `, error code is ${err.code}, message is ${err.message}`);
console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0600 putBatch fail ' + `, error code is ${err.code}, message is ${err.message}`);
expect(null).assertFail();
});
var query = new factory.Query();
......@@ -2850,8 +2850,7 @@ describe('SingleKvStorePromiseTest', function () {
it('SUB_DDM_DKV_SINGLEKVSTORE_CLOSERESULTSET_PROMISE_0200', 0, async function (done) {
console.info('SUB_DDM_DKV_SINGLEKVSTORE_CLOSERESULTSET_PROMISE_0200');
try {
console.info('SUB_DDM_DKV_SINGLEKVSTORE_CLOSERESULTSET_PROMISE_0200 success');
let resultSet = null;
let resultSet = undefined;
await kvStore.getResultSet('batch_test_string_key').then((result) => {
console.info('SUB_DDM_DKV_SINGLEKVSTORE_CLOSERESULTSET_PROMISE_0200 getResultSet success');
resultSet = result;
......@@ -2904,13 +2903,24 @@ describe('SingleKvStorePromiseTest', function () {
* @tc.name Test Js Api SingleKvStoreCloseResultSet testcase 004
*/
it('SUB_DDM_DKV_SINGLEKVSTORE_CLOSERESULTSET_PROMISE_0400', 0, async function (done) {
console.info('SUB_DDM_DKV_SINGLEKVSTORE_CLOSERESULTSET_PROMISE_0400');
let resultSet = undefined;
let errorInfo = undefined;
await kvStore.getResultSet('batch_test_string_key').then((result) => {
console.info('SUB_DDM_DKV_SINGLEKVSTORE_CLOSERESULTSET_PROMISE_0400 getResultSet success');
resultSet = result;
}).catch((err) => {
console.error('SUB_DDM_DKV_SINGLEKVSTORE_CLOSERESULTSET_PROMISE_0400 getResultSet fail ' + `, error code is ${err.code}, message is ${err.message}`);
expect(null).assertFail();
});
try {
kvStore.closeResultSet("")
console.info('SUB_DDM_DKV_SINGLEKVSTORE_CLOSERESULTSET_PROMISE_0400 success');
}catch(e) {
console.error('SUB_DDM_DKV_SINGLEKVSTORE_CLOSERESULTSET_PROMISE_0400 e ' + `, error code is ${e.code}, message is ${e.message}`);
expect(null).assertFail();
}catch(err) {
console.error('SUB_DDM_DKV_SINGLEKVSTORE_CLOSERESULTSET_PROMISE_0400 e ' + `, error code is ${err.code}, message is ${err.message}`);
errorInfo = err
}
expect(errorInfo.code).assertEqual("401");
done();
})
......
......@@ -16,6 +16,7 @@
"package": "ohos.acts.relationalStorejstest",
"name": ".entry",
"deviceType": [
"tablet",
"default",
"phone"
],
......
......@@ -12,35 +12,35 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import rdbStoreBackupRestoreCallbackTest from './RdbstoreBackupRestoreCallbackJsunit.test.js'
import rdbStoreBackupRestoreWithFAContextTest from './RdbstoreBackupRestoreWithFAContextJsunit.test.js'
import rdbStoreDeleteTest from './RdbstoreDeleteJsunit.test.js'
// import rdbStoreBackupRestoreCallbackTest from './RdbstoreBackupRestoreCallbackJsunit.test.js'
// import rdbStoreBackupRestoreWithFAContextTest from './RdbstoreBackupRestoreWithFAContextJsunit.test.js'
// import rdbStoreDeleteTest from './RdbstoreDeleteJsunit.test.js'
import rdbStoreDistributedTest from './RdbStoreDistributedJsunit.test.js'
import rdbstoreInsertTest from './RdbstoreInsertJsunit.test.js'
import rdbStorePredicatesJoinTest from './RdbstorePredicatesJoinJsunit.test.js'
import rdbPredicatesTest from './RdbstorePredicatesJsunit.test.js'
import rdbStoreTest from './RdbstoreRdbstoreJsunit.test.js'
// import rdbstoreInsertTest from './RdbstoreInsertJsunit.test.js'
// import rdbStorePredicatesJoinTest from './RdbstorePredicatesJoinJsunit.test.js'
// import rdbPredicatesTest from './RdbstorePredicatesJsunit.test.js'
// import rdbStoreTest from './RdbstoreRdbstoreJsunit.test.js'
import rdbResultSetTest from './RdbStoreResultSetJsunit.test.js'
import rdbstoreStoreExcuteSqlTest from './RdbstoreStoreExcuteSqlJsunit.test.js'
import rdbstoreTransactionTest from './RdbstoreTransactionJsunit.test.js'
import rdbStoreUpdateTest from './RdbstoreUpdateJsunit.test.js'
import rdbstoreQueryTest from './RdbstoreQuery.test.js'
import rdbStoreEncryptionTest from './RdbstoreEncryptionJsunit.test.js'
import rdbStorePredicatesComplexFiledTest from './RdbstorePredicatesComplexFiledJsunit.test.js'
// import rdbstoreStoreExcuteSqlTest from './RdbstoreStoreExcuteSqlJsunit.test.js'
// import rdbstoreTransactionTest from './RdbstoreTransactionJsunit.test.js'
// import rdbStoreUpdateTest from './RdbstoreUpdateJsunit.test.js'
// import rdbstoreQueryTest from './RdbstoreQuery.test.js'
// import rdbStoreEncryptionTest from './RdbstoreEncryptionJsunit.test.js'
// import rdbStorePredicatesComplexFiledTest from './RdbstorePredicatesComplexFiledJsunit.test.js'
export default function testsuite() {
rdbStoreBackupRestoreCallbackTest()
rdbStoreBackupRestoreWithFAContextTest()
rdbStoreDeleteTest()
// rdbStoreBackupRestoreCallbackTest()
// rdbStoreBackupRestoreWithFAContextTest()
// rdbStoreDeleteTest()
rdbStoreDistributedTest()
rdbstoreInsertTest()
rdbStorePredicatesJoinTest()
rdbPredicatesTest()
rdbStoreTest()
// rdbstoreInsertTest()
// rdbStorePredicatesJoinTest()
// rdbPredicatesTest()
// rdbStoreTest()
rdbResultSetTest()
rdbstoreStoreExcuteSqlTest()
rdbstoreTransactionTest()
rdbStoreUpdateTest()
rdbstoreQueryTest()
rdbStoreEncryptionTest()
rdbStorePredicatesComplexFiledTest()
// rdbstoreStoreExcuteSqlTest()
// rdbstoreTransactionTest()
// rdbStoreUpdateTest()
// rdbstoreQueryTest()
// rdbStoreEncryptionTest()
// rdbStorePredicatesComplexFiledTest()
}
......@@ -15,7 +15,9 @@
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium'
import dataRdb from '@ohos.data.rdb';
import abilityFeatureAbility from '@ohos.ability.featureAbility';
let context = abilityFeatureAbility.getContext();
const TAG = "[RDB_JSKITS_TEST_Distributed]"
const STORE_NAME = "distributed_rdb.db"
var rdbStore = undefined;
......@@ -310,6 +312,34 @@ describe('rdbStoreDistributedTest', function () {
done();
console.info(TAG + "************* testRdbStoreDistributed0011 end *************");
})
/**
* @tc.name sync test
* @tc.number SUB_DDM_AppDataFWK_JSRDB_Distributed_syncV9_0100
* @tc.desc sync test
*/
it('SUB_DDM_AppDataFWK_JSRDB_Distributed_syncV9_0100', 0, async function (done) {
console.info(TAG + "************* SUB_DDM_AppDataFWK_JSRDB_Distributed_syncV9_0100 start *************");
let config = {
name: "secure.db",
securityLevel: dataRdb.SecurityLevel.S1
}
await dataRdb.getRdbStoreV9(context, config, 1).then(async (store) => {
let predicates = new dataRdb.RdbPredicatesV9("employee")
predicates = predicates.inDevices("12345678abcd");
try {
store.sync(dataRdb.SyncMode.SYNC_MODE_PUSH, predicates);
} catch (err) {
expect(null).assertFail();
}
}).catch((err) => {
expect(null).assertFail();
})
await dataRdb.deleteRdbStore(context,"secure.db");
done();
console.info(TAG + "************* SUB_DDM_AppDataFWK_JSRDB_Distributed_syncV9_0100 end *************");
})
/**
* @tc.name sync Callback test
......@@ -369,7 +399,7 @@ describe('rdbStoreDistributedTest', function () {
console.info(TAG + "************* testRdbStoreDistributed0013 end *************");
})
/**
/**
* @tc.name obtainDistributedTableName Callback interface test
* @tc.number SUB_DDM_AppDataFWK_JSRDB_Distributed_014
* @tc.desc obtainDistributedTableName test
......
......@@ -1559,16 +1559,10 @@ describe('rdbResultSetTest', function () {
it('testIsColumnNull0003', 0, async function (done) {
console.info(TAG + '************* testIsColumnNull0003 start *************');
{
let errInfo = undefined;
let predicates = await new dataRdb.RdbPredicates('test')
let resultSet = await rdbStore.query(predicates)
try{
resultSet.goToRow(5)
expect(false).assertEqual(resultSet.isColumnNull(2))
}catch(err){
errInfo = err
}
expect(errInfo.code).assertEqual("14800012")
resultSet.goToRow(5)
expect(false).assertEqual(resultSet.isColumnNull(2))
resultSet = null;
done();
console.info(TAG + '************* testIsColumnNull0003 end *************');
......
......@@ -13,6 +13,10 @@
* limitations under the License.
*/
import rdbStoreV9Test from './RdbstoreRdbstoreV9.test.ets'
import rdbStoreDistributedTest from './RdbstoreDistributedEtsunit.test.ets'
import rdbResultSetTest from './RdbstoreResultsetV9Etsunit.test.ets'
export default function testsuite() {
rdbStoreDistributedTest(globalThis.abilityContext)
rdbStoreV9Test(globalThis.abilityContext);
}
\ No newline at end of file
rdbResultSetTest(globalThis.abilityContext)
}
/*
* Copyright (C) 2021 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 dataRdb from '@ohos.data.rdb';
const TAG = "[RDB_JSKITS_TEST_Distributed]"
const STORE_NAME = "distributed_rdb.db"
var rdbStore = undefined;
const config = {
"name": STORE_NAME,
securityLevel: dataRdb.SecurityLevel.S1
}
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)"
export default function rdbStoreDistributedTest(context) {
describe('rdbStoreDistributedTest', function () {
beforeAll(async function () {
console.info(TAG + 'beforeAll')
})
beforeEach(async function () {
rdbStore = await dataRdb.getRdbStoreV9(context, config, 1);
await rdbStore.executeSql(CREATE_TABLE_TEST, null)
console.info(TAG + 'beforeEach')
})
afterEach(async function () {
await dataRdb.deleteRdbStoreV9(context, STORE_NAME);
console.info(TAG + 'afterEach')
})
afterAll(async function () {
console.info(TAG + 'afterAll')
})
console.info(TAG + "*************Unit Test Begin*************");
/**
* @tc.name obtainDistributedTableName Callback interface test
* @tc.number SUB_DDM_AppDataFWK_ETSRDB_Distributed_obtainDistributedTableName_0100
* @tc.desc obtainDistributedTableName test
*/
it('SUB_DDM_AppDataFWK_ETSRDB_Distributed_obtainDistributedTableName_0100', 0, async function (done){
let errInfo = undefined;
function obtainDistributedTableName(deviceId, tableName, Callback){
rdbStore.obtainDistributedTableName(deviceId, tableName, Callback)
}
try{
obtainDistributedTableName(["deviceId"], "EMPLOYEE", function (err, tableName) {
expect(err != null).assertTrue();
console.info('ObtainDistributedTableName failed, Unauthorized.' + err)
})
}catch(err){
errInfo = err
}
expect(errInfo.code).assertEqual("401")
done();
})
/**
* @tc.name obtainDistributedTableName Promise interface test
* @tc.number SUB_DDM_AppDataFWK_ETSRDB_Distributed_obtainDistributedTableName_0200
* @tc.desc obtainDistributedTableName test
*/
it('SUB_DDM_AppDataFWK_ETSRDB_Distributed_obtainDistributedTableName_0200',0,async function (done){
let errInfo = undefined
function obtainDistributedTableName(deviceId, tableName){
rdbStore.obtainDistributedTableName(deviceId, tableName)
}
try{
obtainDistributedTableName(["deviceId"], "EMPLOYEE")
}catch(err){
errInfo = err
}
expect(errInfo.code).assertEqual("401")
done();
})
console.info(TAG + "*************Unit Test End*************");
})
}
......@@ -257,7 +257,7 @@ describe('rdbStoreV9Test', function () {
console.info(TAG + "get rdb store error")
expect(null).assertFail();
}else{
console.info(TAG + "create table success")
console.info(TAG + "get rdb store success")
}
done();
});
......@@ -266,6 +266,60 @@ describe('rdbStoreV9Test', function () {
done();
console.log(TAG + "************* SUB_DDM_RELATIONALETS_GETRDBSTOREV9_CALLBACK_0400 end *************");
})
/**
* @tc.name rdb store deleteRdbStoreV9
* @tc.number SUB_DDM_RELATIONALETS_DELETERDBSTOREV9_PROMISE_0100
* @tc.desc rdb store deleteRdbStoreV9
* @tc.require: I5PIL6
*/
it('SUB_DDM_RELATIONALETS_DELETERDBSTOREV9_PROMISE_0100', 0, async function (done) {
console.log(TAG + "************* SUB_DDM_RELATIONALETS_DELETERDBSTOREV9_PROMISE_0100 start *************");
let config = {
name: "secure.db",
securityLevel: dataRdb.SecurityLevel.S4
}
let deleteResult = false
await dataRdb.getRdbStoreV9(context, config, 1).then(async (store) => {
console.info(TAG + "create table success")
})
await dataRdb.deleteRdbStoreV9(context,"secure.db").then(() => {
deleteResult = true
console.info(`${TAG} delete rdb store success,result is ${deleteResult}`)
});
expect(deleteResult).assertTrue();
done();
console.log(TAG + "************* SUB_DDM_RELATIONALETS_DELETERDBSTOREV9_PROMISE_0100 end *************");
})
/**
* @tc.name rdb store deleteRdbStoreV9
* @tc.number SUB_DDM_RELATIONALETS_DELETERDBSTOREV9_CALLBACK_0100
* @tc.desc rdb store deleteRdbStoreV9
* @tc.require: I5PIL6
*/
it('SUB_DDM_RELATIONALETS_DELETERDBSTOREV9_CALLBACK_0100', 0, async function (done) {
console.log(TAG + "************* SUB_DDM_RELATIONALETS_DELETERDBSTOREV9_CALLBACK_0100 start *************");
let config = {
name: "secure.db",
securityLevel: dataRdb.SecurityLevel.S1
}
let deleteResult = false
await dataRdb.getRdbStoreV9(context, config, 1).then(async (store) => {
console.info(TAG + "create rdb store success")
})
dataRdb.deleteRdbStoreV9(context,"secure.db", (err, data) => {
if(err == undefined){
deleteResult = true
console.info(`${TAG} delete rdb store success,result is ${deleteResult}`)
}
done();
})
await sleep(1000)
expect(deleteResult).assertTrue();
done();
console.log(TAG + "************* SUB_DDM_RELATIONALETS_DELETERDBSTOREV9_CALLBACK_0100 end *************");
})
console.log(TAG + "*************Unit Test End*************");
})
}
\ No newline at end of file
/*
* Copyright (C) 2021 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 dataRdb from '@ohos.data.rdb'
const TAG = '[RDB_JSKITS_TEST]'
const CREATE_TABLE_TEST = 'CREATE TABLE IF NOT EXISTS test (' + 'id INTEGER PRIMARY KEY AUTOINCREMENT, ' + 'data1 text,' + 'data2 long, ' + 'data3 double,' + 'data4 blob)';
const STORE_CONFIG = {
name: 'Resultset.db',
securityLevel: dataRdb.SecurityLevel.S1
}
const COLOUNM_NAMES = ["id","data1","data2","data3","data4"];
var rdbStore = undefined;
export default function rdbResultSetTest(context) {
describe('rdbResultSetTest', function () {
beforeAll(async function () {
console.info(TAG + 'beforeAll')
rdbStore = await dataRdb.getRdbStoreV9(context, STORE_CONFIG, 1);
await rdbStore.executeSql(CREATE_TABLE_TEST, null);
await createTest();
})
beforeEach(async function () {
console.info(TAG + 'beforeEach')
})
afterEach(function () {
console.info(TAG + 'afterEach')
})
afterAll(async function () {
console.info(TAG + 'afterAll')
rdbStore = null
await dataRdb.deleteRdbStoreV9(context, 'Resultset.db');
})
//插入数据
async function createTest() {
console.info(TAG + 'createTest data start');
{
var u8 = new Uint8Array([1, 2, 3])
const valueBucket = {
'data1': 'hello',
'data2': 10,
'data3': 1.0,
'data4': u8,
}
await rdbStore.insert('test', valueBucket)
}
{
var u8 = new Uint8Array([3, 4, 5])
const valueBucket = {
'data1': '2',
'data2': -5,
'data3': 2.5,
'data4': u8,
}
await rdbStore.insert('test', valueBucket)
}
{
var u8 = new Uint8Array(0)
const valueBucket = {
'data1': 'hello world',
'data2': 3,
'data3': 1.8,
'data4': u8,
}
await rdbStore.insert('test', valueBucket)
}
console.info(TAG + 'createTest data end');
}
/**
* @tc.name resultSet getBlob normal test
* @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0010
* @tc.desc resultSet getBlob normal test
*/
it('testGetBlob0001', 0, async function (done) {
console.info(TAG + '************* testGetBlob0001 start *************');
let predicates = await new dataRdb.RdbPredicatesV9('test')
let resultSetV9 = await rdbStore.query(predicates)
try {
{
expect(true).assertEqual(resultSetV9.goToFirstRow())
const id = resultSetV9.getLong(resultSetV9.getColumnIndex('id'))
const data4 = resultSetV9.getBlob(resultSetV9.getColumnIndex('data4'))
console.info(TAG + 'id=' + id + ', data4=' + data4);
expect(1).assertEqual(data4[0]);
expect(2).assertEqual(data4[1]);
expect(3).assertEqual(data4[2]);
}
resultSetV9.close();
expect(true).assertEqual(resultSetV9.isClosed)
} catch (e) {
expect(null).assertFail();
}
resultSetV9 = null
done();
console.info(TAG + '************* testGetBlob0001 end *************');
})
console.info(TAG + '*************Unit Test End*************');
})
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册