提交 a797f653 编写于 作者: O openharmony_ci 提交者: Gitee

!1026 remove JS context

Merge pull request !1026 from lichenlong1/master
......@@ -14,8 +14,7 @@
*/
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
import dataRdb from '@ohos.data.rdb';
import dataAbility from '@ohos.data.dataability';
import featureAbility from '@ohos.ability.featureAbility';
import dataAbility from '@ohos.data.dataAbility';
const TAG = "[RDB_JSKITS _TEST]"
const CREATE_TABLE_ALL_DATA_TYPE_SQL = "CREATE TABLE IF NOT EXISTS AllDataType "
......@@ -31,14 +30,12 @@ const STORE_CONFIG = {
name: "Predicates.db",
}
var rdbStore = undefined;
var context = undefined;
var DOUBLE_MAX = 9223372036854775807;
describe('dataAbilityPredicatesTest', function () {
beforeAll(async function () {
console.info(TAG + 'beforeAll')
context = await featureAbility.getContext();
rdbStore = await dataRdb.getRdbStore(context, STORE_CONFIG, 1);
rdbStore = await dataRdb.getRdbStore(STORE_CONFIG, 1);
await rdbStore.executeSql(CREATE_TABLE_ALL_DATA_TYPE_SQL, null);
await buildAllDataType1();
await buildAllDataType2();
......@@ -56,7 +53,7 @@ describe('dataAbilityPredicatesTest', function () {
afterAll(async function () {
console.info(TAG + 'afterAll')
rdbStore = null
await dataRdb.deleteRdbStore(context, "Predicates.db");
await dataRdb.deleteRdbStore("Predicates.db");
})
function resultSize(resultSet) {
......
......@@ -13,8 +13,7 @@
* limitations under the License.
*/
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
import ohos_data_rdb from '@ohos.data.rdb';
import ability_featureAbility from '@ohos.ability.featureAbility';
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, " + "name TEXT NOT NULL, " + "age INTEGER, " + "salary REAL, " + "blobType BLOB)";
......@@ -23,7 +22,6 @@ const STORE_CONFIG = {
name: "Delete.db",
}
var rdbStore = undefined;
var context = undefined;
describe('rdbStoreDeleteTest', function () {
beforeAll(function () {
......@@ -32,8 +30,7 @@ describe('rdbStoreDeleteTest', function () {
beforeEach(async function () {
console.info(TAG + 'beforeEach')
context = await ability_featureAbility.getContext();
rdbStore = await ohos_data_rdb.getRdbStore(context, STORE_CONFIG, 1);
rdbStore = await dataRdb.getRdbStore(STORE_CONFIG, 1);
await rdbStore.executeSql(CREATE_TABLE_TEST, null);
})
......@@ -41,7 +38,7 @@ describe('rdbStoreDeleteTest', function () {
console.info(TAG + 'afterEach')
await rdbStore.executeSql("DELETE FROM test");
rdbStore = null
await ohos_data_rdb.deleteRdbStore(context, "Delete.db");
await dataRdb.deleteRdbStore("Delete.db");
})
afterAll(async function () {
......@@ -86,7 +83,7 @@ describe('rdbStoreDeleteTest', function () {
}
//删除
{
let predicates = await new ohos_data_rdb.RdbPredicates("test")
let predicates = await new dataRdb.RdbPredicates("test")
let deletePromise = rdbStore.delete(predicates)
deletePromise.then(async (ret) => {
expect(3).assertEqual(ret)
......@@ -137,7 +134,7 @@ describe('rdbStoreDeleteTest', function () {
}
//删除
{
let predicates = await new ohos_data_rdb.RdbPredicates("test")
let predicates = await new dataRdb.RdbPredicates("test")
predicates.equalTo("name", "zhangsan")
let deletePromise = rdbStore.delete(predicates)
deletePromise.then(async (ret) => {
......@@ -180,14 +177,14 @@ describe('rdbStoreDeleteTest', function () {
}
//删除前查询
{
let predicates = await new ohos_data_rdb.RdbPredicates("test")
let predicates = await new dataRdb.RdbPredicates("test")
predicates.equalTo("age", 28)
let resultSet = await rdbStore.query(predicates)
expect(1).assertEqual(resultSet.rowCount)
}
//删除
{
let predicates = await new ohos_data_rdb.RdbPredicates("test")
let predicates = await new dataRdb.RdbPredicates("test")
predicates.equalTo("age", 28)
let deletePromise = rdbStore.delete(predicates)
deletePromise.then(async (ret) => {
......@@ -200,7 +197,7 @@ describe('rdbStoreDeleteTest', function () {
}
//删除后查询
{
let predicates = await new ohos_data_rdb.RdbPredicates("test")
let predicates = await new dataRdb.RdbPredicates("test")
predicates.equalTo("age", 28)
let resultSet = await rdbStore.query(predicates)
expect(0).assertEqual(resultSet.rowCount)
......@@ -246,7 +243,7 @@ describe('rdbStoreDeleteTest', function () {
}
//删除
{
let predicates = await new ohos_data_rdb.RdbPredicates("test")
let predicates = await new dataRdb.RdbPredicates("test")
predicates.equalTo("aaa id", 1)
let deletePromise = rdbStore.delete(predicates)
deletePromise.then(async (ret) => {
......@@ -297,7 +294,7 @@ describe('rdbStoreDeleteTest', function () {
}
//删除
{
let predicates = await new ohos_data_rdb.RdbPredicates("test")
let predicates = await new dataRdb.RdbPredicates("test")
predicates.equalTo("name", "lisi")
let deletePromise = rdbStore.delete(predicates)
deletePromise.then(async (ret) => {
......@@ -349,7 +346,7 @@ describe('rdbStoreDeleteTest', function () {
}
//删除
{
let predicates = await new ohos_data_rdb.RdbPredicates("")
let predicates = await new dataRdb.RdbPredicates("")
let deletePromise = rdbStore.delete(predicates)
deletePromise.then(async (ret) => {
console.log(TAG + "delete done: " + ret)
......
......@@ -14,8 +14,7 @@
*/
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
import ohos_data_rdb from '@ohos.data.rdb';
import ability_featureAbility from '@ohos.ability.featureAbility';
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, " + "name TEXT NOT NULL, " + "age INTEGER, " + "salary REAL, " + "blobType BLOB)";
......@@ -25,13 +24,11 @@ const STORE_CONFIG = {
}
var rdbStore = undefined;
var context = undefined;
describe('rdbStoreInsertTest', function () {
beforeAll(async function () {
console.info(TAG + 'beforeAll')
context = await ability_featureAbility.getContext();
rdbStore = await ohos_data_rdb.getRdbStore(context, STORE_CONFIG, 1);
rdbStore = await dataRdb.getRdbStore(STORE_CONFIG, 1);
await rdbStore.executeSql(CREATE_TABLE_TEST, null);
})
......@@ -47,7 +44,7 @@ describe('rdbStoreInsertTest', function () {
afterAll(async function () {
console.info(TAG + 'afterAll')
rdbStore = null
await ohos_data_rdb.deleteRdbStore(context, "InsertTest.db");
await dataRdb.deleteRdbStore("InsertTest.db");
})
console.log(TAG + "*************Unit Test Begin*************");
......@@ -88,7 +85,7 @@ describe('rdbStoreInsertTest', function () {
await rdbStore.insert("test", valueBucket)
}
let predicates = new ohos_data_rdb.RdbPredicates("test");
let predicates = new dataRdb.RdbPredicates("test");
predicates.equalTo("name", "zhangsan")
let resultSet = await rdbStore.query(predicates)
try {
......
......@@ -14,8 +14,7 @@
*/
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
import ohos_data_rdb from '@ohos.data.rdb';
import ability_featureAbility from '@ohos.ability.featureAbility';
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, " + "name TEXT NOT NULL, " + "age INTEGER, " + "salary REAL, " + "blobType BLOB)";
......@@ -23,11 +22,9 @@ const CREATE_TABLE_TEST = "CREATE TABLE IF NOT EXISTS test (" + "id INTEGER PRIM
const STORE_CONFIG = {
name: "rdbstore.db",
}
var context = undefined;
describe('rdbStoreTest', function () {
beforeAll(async function () {
console.info(TAG + 'beforeAll')
context = await ability_featureAbility.getContext();
})
beforeEach(function () {
......@@ -51,7 +48,7 @@ describe('rdbStoreTest', function () {
*/
it('testRdbStore0001', 0, async function (done) {
console.log(TAG + "************* testRdbStore0001 start *************");
let storePromise = ohos_data_rdb.getRdbStore(context, STORE_CONFIG, 1);
let storePromise = dataRdb.getRdbStore(STORE_CONFIG, 1);
storePromise.then(async (store) => {
try {
await console.log(TAG + "getRdbStore done: " + store);
......@@ -63,7 +60,7 @@ describe('rdbStoreTest', function () {
})
await storePromise
storePromise = null
await ohos_data_rdb.deleteRdbStore(context, "rdbstore.db");
await dataRdb.deleteRdbStore("rdbstore.db");
done();
console.log(TAG + "************* testRdbStore0001 end *************");
})
......@@ -75,7 +72,7 @@ describe('rdbStoreTest', function () {
*/
it('testRdbStore0002', 0, async function (done) {
console.log(TAG + "************* testRdbStore0002 start *************");
let storePromise = ohos_data_rdb.getRdbStore(context, STORE_CONFIG, 2);
let storePromise = dataRdb.getRdbStore(STORE_CONFIG, 2);
storePromise.then(async (store) => {
try {
await console.log(TAG + "getRdbStore done: " + store);
......@@ -88,7 +85,7 @@ describe('rdbStoreTest', function () {
})
await storePromise
storePromise = null
await ohos_data_rdb.deleteRdbStore(context, "rdbstore.db");
await dataRdb.deleteRdbStore("rdbstore.db");
done();
console.log(TAG + "************* testRdbStore0002 end *************");
})
......@@ -104,7 +101,7 @@ describe('rdbStoreTest', function () {
let storeConfig = {
name: "/wrong/rdbstore.db",
}
let storePromise = ohos_data_rdb.getRdbStore(context, storeConfig, 4);
let storePromise = dataRdb.getRdbStore(storeConfig, 4);
storePromise.then(async (ret) => {
await console.log(TAG + "getRdbStore done" + ret);
expect(null).assertFail();
......@@ -124,7 +121,7 @@ describe('rdbStoreTest', function () {
it('testRdbStore0004', 0, async function (done) {
console.log(TAG + "************* testRdbStore0004 start *************");
let storePromise = ohos_data_rdb.getRdbStore(context, STORE_CONFIG, 6);
let storePromise = dataRdb.getRdbStore(STORE_CONFIG, 6);
storePromise.then(async (store) => {
try {
await store.executeSql(CREATE_TABLE_TEST);
......@@ -136,7 +133,7 @@ describe('rdbStoreTest', function () {
})
await storePromise
storePromise = null
await ohos_data_rdb.deleteRdbStore(context, "rdbstore.db");
await dataRdb.deleteRdbStore("rdbstore.db");
done();
console.log(TAG + "************* testRdbStore0004 end *************");
})
......
......@@ -13,8 +13,7 @@
* limitations under the License.
*/
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
import ohos_data_rdb from '@ohos.data.rdb';
import ability_featureAbility from '@ohos.ability.featureAbility';
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, " + "name NOT NULL, " + "age INTEGER, " + "salary REAL, " + "blobType BLOB)";
......@@ -23,13 +22,11 @@ const STORE_CONFIG = {
name: "ExcuteSqlTest.db",
}
var rdbStore = undefined;
var context = undefined;
describe('rdbStoreInsertTest', function () {
beforeAll(async function () {
console.info(TAG + 'beforeAll')
context = await ability_featureAbility.getContext();
rdbStore = await ohos_data_rdb.getRdbStore(context, STORE_CONFIG, 1);
rdbStore = await dataRdb.getRdbStore(STORE_CONFIG, 1);
await rdbStore.executeSql(CREATE_TABLE_TEST, null);
})
......@@ -45,7 +42,7 @@ describe('rdbStoreInsertTest', function () {
afterAll(async function () {
console.info(TAG + 'afterAll')
rdbStore = null
await ohos_data_rdb.deleteRdbStore(context, "ExcuteSqlTest.db");
await dataRdb.deleteRdbStore("ExcuteSqlTest.db");
})
/**
......
......@@ -13,8 +13,7 @@
* limitations under the License.
*/
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
import ohos_data_rdb from '@ohos.data.rdb';
import ability_featureAbility from '@ohos.ability.featureAbility';
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, " + "name TEXT UNIQUE, " + "age INTEGER, " + "salary REAL, " + "blobType BLOB)";
......@@ -22,13 +21,11 @@ const STORE_CONFIG = {
name: "UpdataTest.db",
}
var rdbStore = undefined;
var context = undefined;
describe('rdbStoreUpdateTest', function () {
beforeAll(async function () {
console.info(TAG + 'beforeAll')
context = await ability_featureAbility.getContext();
rdbStore = await ohos_data_rdb.getRdbStore(context, STORE_CONFIG, 1);
rdbStore = await dataRdb.getRdbStore(STORE_CONFIG, 1);
await rdbStore.executeSql(CREATE_TABLE_TEST, null);
})
......@@ -44,7 +41,7 @@ describe('rdbStoreUpdateTest', function () {
afterAll(async function () {
console.info(TAG + 'afterAll')
rdbStore = null
await ohos_data_rdb.deleteRdbStore(context, "UpdataTest.db");
await dataRdb.deleteRdbStore("UpdataTest.db");
})
/**
......@@ -81,7 +78,7 @@ describe('rdbStoreUpdateTest', function () {
"salary": 200.5,
"blobType": u8,
}
let predicates = await new ohos_data_rdb.RdbPredicates("test")
let predicates = await new dataRdb.RdbPredicates("test")
await predicates.equalTo("id", "1")
let updatePromise = rdbStore.update(valueBucket, predicates)
updatePromise.then(async (ret) => {
......@@ -95,7 +92,7 @@ describe('rdbStoreUpdateTest', function () {
}
//查询
{
let predicates = await new ohos_data_rdb.RdbPredicates("test")
let predicates = await new dataRdb.RdbPredicates("test")
let resultSet = await rdbStore.query(predicates)
expect(true).assertEqual(resultSet.goToFirstRow())
......@@ -137,7 +134,7 @@ describe('rdbStoreUpdateTest', function () {
"blobType": u8,
}
{
let predicates = new ohos_data_rdb.RdbPredicates("")
let predicates = new dataRdb.RdbPredicates("")
let updatePromise = rdbStore.update(valueBucket, predicates)
updatePromise.then(async (ret) => {
await console.log(TAG + "update done: " + ret);
......@@ -148,7 +145,7 @@ describe('rdbStoreUpdateTest', function () {
}
{
const emptyBucket = {};
let predicates = await new ohos_data_rdb.RdbPredicates("test")
let predicates = await new dataRdb.RdbPredicates("test")
let updatePromise = rdbStore.update(emptyBucket, predicates)
updatePromise.then(async (ret) => {
await console.log(TAG + "update done: " + ret);
......@@ -158,7 +155,7 @@ describe('rdbStoreUpdateTest', function () {
})
}
{
let predicates = await new ohos_data_rdb.RdbPredicates("test")
let predicates = await new dataRdb.RdbPredicates("test")
await predicates.equalTo("aaa", "null")
let updatePromise = rdbStore.update(valueBucket, predicates)
updatePromise.then(async (ret) => {
......@@ -191,7 +188,7 @@ describe('rdbStoreUpdateTest', function () {
"wrongColumn": 100.5,
}
{
let predicates = new ohos_data_rdb.RdbPredicates("wrongTable")
let predicates = new dataRdb.RdbPredicates("wrongTable")
let updatePromise = rdbStore.update(valueBucket, predicates)
updatePromise.then(async (ret) => {
await console.log(TAG + "update done: " + ret);
......@@ -202,7 +199,7 @@ describe('rdbStoreUpdateTest', function () {
//await updatePromise
}
{
let predicates = await new ohos_data_rdb.RdbPredicates("test")
let predicates = await new dataRdb.RdbPredicates("test")
let updatePromise = rdbStore.update(valueBucket, predicates)
updatePromise.then(async (ret) => {
await console.log(TAG + "update done: " + ret);
......@@ -234,7 +231,7 @@ describe('rdbStoreUpdateTest', function () {
"blobType": u8,
}
{
let predicates = await new ohos_data_rdb.RdbPredicates("test")
let predicates = await new dataRdb.RdbPredicates("test")
await predicates.equalTo("aaa", "null")
let updatePromise = rdbStore.update(valueBucket, predicates)
updatePromise.then(async (ret) => {
......@@ -247,7 +244,7 @@ describe('rdbStoreUpdateTest', function () {
}
{
const emptyBucket = {};
let predicates = await new ohos_data_rdb.RdbPredicates("test")
let predicates = await new dataRdb.RdbPredicates("test")
await predicates.equalTo("name", "zhangsan")
await predicates.equalTo("age", 18)
await predicates.equalTo("null", 100.5)
......
......@@ -44,8 +44,8 @@ describe('storageTest', function () {
mPref.flushSync();
await mPref.clear(function (err, ret) {
expect("defaultvalue").assertEqual(mPref.getSync(KEY_TEST_STRING_ELEMENT, "defaultvalue"));
done();
});
done();
})
/**
......@@ -57,8 +57,8 @@ describe('storageTest', function () {
mPref.putSync(KEY_TEST_STRING_ELEMENT, "test");
await mPref.has(KEY_TEST_STRING_ELEMENT, function (err, ret) {
expect(true).assertEqual(ret);
done();
})
done();
})
/**
......@@ -70,8 +70,8 @@ describe('storageTest', function () {
mPref.putSync(KEY_TEST_INT_ELEMENT, 1);
await mPref.has(KEY_TEST_INT_ELEMENT, function (err, ret) {
expect(true).assertEqual(ret);
done();
})
done();
})
/**
......@@ -83,8 +83,8 @@ describe('storageTest', function () {
mPref.putSync(KEY_TEST_FLOAT_ELEMENT, 1.1);
await mPref.has(KEY_TEST_FLOAT_ELEMENT, function (err, ret) {
expect(true).assertEqual(ret);
done();
})
done();
})
/**
......@@ -96,8 +96,8 @@ describe('storageTest', function () {
mPref.putSync(KEY_TEST_LONG_ELEMENT, 0);
await mPref.has(KEY_TEST_LONG_ELEMENT, function (err, ret) {
expect(true).assertEqual(ret);
done();
})
done();
})
/**
......@@ -109,8 +109,8 @@ describe('storageTest', function () {
mPref.putSync(KEY_TEST_BOOLEAN_ELEMENT, false);
await mPref.has(KEY_TEST_BOOLEAN_ELEMENT, function (err, ret) {
expect(true).assertEqual(ret);
done();
})
done();
})
/**
......@@ -122,8 +122,8 @@ describe('storageTest', function () {
mPref.clearSync();
await mPref.get(KEY_TEST_STRING_ELEMENT, "defaultValue", function (err, ret) {
expect('defaultValue').assertEqual(ret);
done();
})
done();
})
/**
......@@ -136,8 +136,8 @@ describe('storageTest', function () {
mPref.putSync(KEY_TEST_FLOAT_ELEMENT, 3.0);
await mPref.get(KEY_TEST_FLOAT_ELEMENT, 0.0, function (err, ret) {
expect(3.0).assertEqual(ret);
done();
})
done();
})
/**
......@@ -150,8 +150,8 @@ describe('storageTest', function () {
mPref.putSync(KEY_TEST_INT_ELEMENT, 3);
await mPref.get(KEY_TEST_INT_ELEMENT, 0.0, function (err, ret) {
expect(3).assertEqual(ret);
done();
})
done();
})
/**
......@@ -165,8 +165,8 @@ describe('storageTest', function () {
expect(3).assertEqual(mPref.getSync(KEY_TEST_LONG_ELEMENT, 0));
await mPref.get(KEY_TEST_LONG_ELEMENT, 0, function (err, ret) {
expect(3).assertEqual(ret);
done();
});
done();
})
/**
......@@ -180,8 +180,8 @@ describe('storageTest', function () {
mPref.flushSync();
await mPref.get(KEY_TEST_STRING_ELEMENT, "defaultvalue", function (err, ret) {
expect('test').assertEqual(ret);
done();
});
done();
})
/**
......@@ -195,8 +195,8 @@ describe('storageTest', function () {
expect(true).assertEqual(mPref.getSync(KEY_TEST_BOOLEAN_ELEMENT, false));
mPref.flushSync();
expect(true).assertEqual(mPref.getSync(KEY_TEST_BOOLEAN_ELEMENT, false));
done();
});
done();
})
/**
......@@ -210,8 +210,8 @@ describe('storageTest', function () {
expect(4.0).assertEqual(mPref.getSync(KEY_TEST_FLOAT_ELEMENT, 0.0));
mPref.flushSync();
expect(4.0).assertEqual(mPref.getSync(KEY_TEST_FLOAT_ELEMENT, 0.0));
done();
});
done();
})
/**
......@@ -225,8 +225,8 @@ describe('storageTest', function () {
expect(4).assertEqual(mPref.getSync(KEY_TEST_INT_ELEMENT, 0));
mPref.flushSync();
expect(4).assertEqual(mPref.getSync(KEY_TEST_INT_ELEMENT, 0));
done();
});
done();
})
/**
......@@ -241,8 +241,8 @@ describe('storageTest', function () {
expect(4).assertEqual(mPref.getSync(KEY_TEST_LONG_ELEMENT, 0));
mPref.flushSync();
expect(4).assertEqual(mPref.getSync(KEY_TEST_LONG_ELEMENT, 0));
done();
});
done();
})
/**
......@@ -252,13 +252,11 @@ describe('storageTest', function () {
*/
it('testPutString0162', 0, async function (done) {
mPref.clearSync();
await mPref.put(KEY_TEST_STRING_ELEMENT, "abc", function (err, ret) {
mPref.put(KEY_TEST_STRING_ELEMENT, '', function (err, ret) {
expect('').assertEqual(mPref.getSync(KEY_TEST_STRING_ELEMENT, "defaultvalue"));
mPref.flushSync();
expect('').assertEqual(mPref.getSync(KEY_TEST_STRING_ELEMENT, "defaultvalue"));
});
await mPref.put(KEY_TEST_STRING_ELEMENT, '', function (err, ret) {
expect('').assertEqual(mPref.getSync(KEY_TEST_STRING_ELEMENT, "defaultvalue"));
mPref.flushSync();
expect('').assertEqual(mPref.getSync(KEY_TEST_STRING_ELEMENT, "defaultvalue"));
done();
});
done();
})
})
\ No newline at end of file
......@@ -110,8 +110,8 @@ describe('storageTest', function () {
}
try {
perf.putSync("int", 3);
expect(null).assertFail();
} catch (e) {
expect(null).assertFail();
}
})
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册