提交 c66781ce 编写于 作者: L liangzhenyu123

用例新增

Signed-off-by: Nliangzhenyu123 <liangzhenyu6@huawei.com>
上级 aaa975d1
......@@ -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()
}
......@@ -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.getRdbStore(context, config, 1);
await rdbStore.executeSql(CREATE_TABLE_TEST, null)
console.info(TAG + 'beforeEach')
})
afterEach(async function () {
await dataRdb.deleteRdbStore(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.
先完成此消息的编辑!
想要评论请 注册