diff --git a/distributeddatamgr/appdatamgrjstest/hap/src/main/js/default/test/DataAbilityPredicatesJsunit.test.js b/distributeddatamgr/appdatamgrjstest/hap/src/main/js/default/test/DataAbilityPredicatesJsunit.test.js index d28997db231b8d3a33bd6af90a7d33a4c951011d..a03626373d806cc4f5c36a5fc0aab10536e52401 100644 --- a/distributeddatamgr/appdatamgrjstest/hap/src/main/js/default/test/DataAbilityPredicatesJsunit.test.js +++ b/distributeddatamgr/appdatamgrjstest/hap/src/main/js/default/test/DataAbilityPredicatesJsunit.test.js @@ -15,6 +15,7 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' import ohos_data_rdb from '@ohos.data.rdb'; import data_dataability from '@ohos.data.dataability'; +import ability_featureAbility from '@ohos.ability.featureAbility'; const TAG = "[RDB_JSKITS _TEST]" const CREATE_TABLE_ALL_DATA_TYPE_SQL = "CREATE TABLE IF NOT EXISTS AllDataType " @@ -30,11 +31,13 @@ const STORE_CONFIG = { name: "Predicates.db", } var rdbStore = undefined; +var context = undefined; describe('dataAbilityPredicatesTest', function () { beforeAll(async function () { console.info(TAG + 'beforeAll') - rdbStore = await ohos_data_rdb.getRdbStore(STORE_CONFIG, 1); + context = await ability_featureAbility.getContext(); + rdbStore = await ohos_data_rdb.getRdbStore(context, STORE_CONFIG, 1); await rdbStore.executeSql(CREATE_TABLE_ALL_DATA_TYPE_SQL, null); await buildAllDataType1(); await buildAllDataType2(); @@ -52,7 +55,7 @@ describe('dataAbilityPredicatesTest', function () { afterAll(async function () { console.info(TAG + 'afterAll') rdbStore = null - await ohos_data_rdb.deleteRdbStore("Predicates.db"); + await ohos_data_rdb.deleteRdbStore(context, "Predicates.db"); }) function resultSize(resultSet) { diff --git a/distributeddatamgr/appdatamgrjstest/hap/src/main/js/default/test/RdbStoreResultSetJsunit.test.js b/distributeddatamgr/appdatamgrjstest/hap/src/main/js/default/test/RdbStoreResultSetJsunit.test.js index 9513f07b4d4357e73c0a72b01c1069ffddb8390f..fb2053192c96de06d288aafaf23af29034555ea4 100644 --- a/distributeddatamgr/appdatamgrjstest/hap/src/main/js/default/test/RdbStoreResultSetJsunit.test.js +++ b/distributeddatamgr/appdatamgrjstest/hap/src/main/js/default/test/RdbStoreResultSetJsunit.test.js @@ -14,6 +14,7 @@ */ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' import data_rdb from '@ohos.data.rdb' +import ability_featureAbility from '@ohos.ability.featureAbility'; 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)"; @@ -22,11 +23,13 @@ const STORE_CONFIG = { name: "Resultset.db", } var rdbStore = undefined; +var context = undefined; describe('rdbResultSetTest', function () { beforeAll(async function () { console.info(TAG + 'beforeAll') - rdbStore = await data_rdb.getRdbStore(STORE_CONFIG, 1); + context = await ability_featureAbility.getContext(); + rdbStore = await data_rdb.getRdbStore(context, STORE_CONFIG, 1); await rdbStore.executeSql(CREATE_TABLE_TEST, null); await createTest(); }) @@ -42,7 +45,7 @@ describe('rdbResultSetTest', function () { afterAll(async function () { console.info(TAG + 'afterAll') rdbStore = null - await data_rdb.deleteRdbStore("Resultset.db"); + await data_rdb.deleteRdbStore(context, "Resultset.db"); }) //插入数据 async function createTest() { diff --git a/distributeddatamgr/appdatamgrjstest/hap/src/main/js/default/test/RdbstoreDeleteJsunit.test.js b/distributeddatamgr/appdatamgrjstest/hap/src/main/js/default/test/RdbstoreDeleteJsunit.test.js index 7fc82f4fa691ff18cd99ff51dd070484f325f133..240b7843113b5609840cdc1773547f1f5ea18c3f 100644 --- a/distributeddatamgr/appdatamgrjstest/hap/src/main/js/default/test/RdbstoreDeleteJsunit.test.js +++ b/distributeddatamgr/appdatamgrjstest/hap/src/main/js/default/test/RdbstoreDeleteJsunit.test.js @@ -14,6 +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'; 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)"; @@ -22,6 +23,7 @@ const STORE_CONFIG = { name: "Delete.db", } var rdbStore = undefined; +var context = undefined; describe('rdbStoreDeleteTest', function () { beforeAll(function () { @@ -30,7 +32,8 @@ describe('rdbStoreDeleteTest', function () { beforeEach(async function () { console.info(TAG + 'beforeEach') - rdbStore = await ohos_data_rdb.getRdbStore(STORE_CONFIG, 1); + context = await ability_featureAbility.getContext(); + rdbStore = await ohos_data_rdb.getRdbStore(context, STORE_CONFIG, 1); await rdbStore.executeSql(CREATE_TABLE_TEST, null); }) @@ -38,7 +41,7 @@ describe('rdbStoreDeleteTest', function () { console.info(TAG + 'afterEach') await rdbStore.executeSql("DELETE FROM test"); rdbStore = null - await ohos_data_rdb.deleteRdbStore("Delete.db"); + await ohos_data_rdb.deleteRdbStore(context, "Delete.db"); }) afterAll(async function () { diff --git a/distributeddatamgr/appdatamgrjstest/hap/src/main/js/default/test/RdbstoreInsertJsunit.test.js b/distributeddatamgr/appdatamgrjstest/hap/src/main/js/default/test/RdbstoreInsertJsunit.test.js index 257b6a7593018bd3dc6b1cbeb4ce3b3a56b38c3a..28f3ee41d9ecb9e2368d72ccf5f334be245d211f 100644 --- a/distributeddatamgr/appdatamgrjstest/hap/src/main/js/default/test/RdbstoreInsertJsunit.test.js +++ b/distributeddatamgr/appdatamgrjstest/hap/src/main/js/default/test/RdbstoreInsertJsunit.test.js @@ -15,6 +15,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'; 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)"; @@ -24,11 +25,13 @@ const STORE_CONFIG = { } var rdbStore = undefined; +var context = undefined; describe('rdbStoreInsertTest', function () { beforeAll(async function () { console.info(TAG + 'beforeAll') - rdbStore = await ohos_data_rdb.getRdbStore(STORE_CONFIG, 1); + context = await ability_featureAbility.getContext(); + rdbStore = await ohos_data_rdb.getRdbStore(context, STORE_CONFIG, 1); await rdbStore.executeSql(CREATE_TABLE_TEST, null); }) @@ -44,7 +47,7 @@ describe('rdbStoreInsertTest', function () { afterAll(async function () { console.info(TAG + 'afterAll') rdbStore = null - await ohos_data_rdb.deleteRdbStore("InsertTest.db"); + await ohos_data_rdb.deleteRdbStore(context, "InsertTest.db"); }) console.log(TAG + "*************Unit Test Begin*************"); diff --git a/distributeddatamgr/appdatamgrjstest/hap/src/main/js/default/test/RdbstorePredicatesJsunit.test.js b/distributeddatamgr/appdatamgrjstest/hap/src/main/js/default/test/RdbstorePredicatesJsunit.test.js index 53d70da499e933071e2fed6fbf2a26074f4d3cd7..bae6c4bbe8ad40f970d1c4a2dfab9f5199a0376e 100644 --- a/distributeddatamgr/appdatamgrjstest/hap/src/main/js/default/test/RdbstorePredicatesJsunit.test.js +++ b/distributeddatamgr/appdatamgrjstest/hap/src/main/js/default/test/RdbstorePredicatesJsunit.test.js @@ -14,6 +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'; const TAG = "[RDB_JSKITS _TEST]" const CREATE_TABLE_ALL_DATA_TYPE_SQL = "CREATE TABLE IF NOT EXISTS AllDataType " @@ -29,11 +30,13 @@ const STORE_CONFIG = { name: "Predicates.db", } var rdbStore = undefined; +var context = undefined; describe('rdbPredicatesTest', function () { beforeAll(async function () { console.info(TAG + 'beforeAll') - rdbStore = await ohos_data_rdb.getRdbStore(STORE_CONFIG, 1); + context = await ability_featureAbility.getContext(); + rdbStore = await ohos_data_rdb.getRdbStore(context, STORE_CONFIG, 1); await rdbStore.executeSql(CREATE_TABLE_ALL_DATA_TYPE_SQL, null); await buildAllDataType1(); await buildAllDataType2(); @@ -51,7 +54,7 @@ describe('rdbPredicatesTest', function () { afterAll(async function () { console.info(TAG + 'afterAll') rdbStore = null - await ohos_data_rdb.deleteRdbStore("Predicates.db"); + await ohos_data_rdb.deleteRdbStore(context, "Predicates.db"); }) function resultSize(resultSet) { diff --git a/distributeddatamgr/appdatamgrjstest/hap/src/main/js/default/test/RdbstoreRdbstoreJsunit.test.js b/distributeddatamgr/appdatamgrjstest/hap/src/main/js/default/test/RdbstoreRdbstoreJsunit.test.js index f1816b99966b034ef3876acbb112241ab9acb89a..81c7ef7162d7b445434c0e7739e0cc9ca3c69052 100644 --- a/distributeddatamgr/appdatamgrjstest/hap/src/main/js/default/test/RdbstoreRdbstoreJsunit.test.js +++ b/distributeddatamgr/appdatamgrjstest/hap/src/main/js/default/test/RdbstoreRdbstoreJsunit.test.js @@ -15,6 +15,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'; 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)"; @@ -22,10 +23,11 @@ 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 () { @@ -49,7 +51,7 @@ describe('rdbStoreTest', function () { */ it('testRdbStore0001', 0, async function (done) { console.log(TAG + "************* testRdbStore0001 start *************"); - let storePromise = ohos_data_rdb.getRdbStore(STORE_CONFIG, 1); + let storePromise = ohos_data_rdb.getRdbStore(context, STORE_CONFIG, 1); storePromise.then(async (store) => { try { await console.log(TAG + "getRdbStore done: " + store); @@ -61,7 +63,7 @@ describe('rdbStoreTest', function () { }) await storePromise storePromise = null - await ohos_data_rdb.deleteRdbStore("rdbstore.db"); + await ohos_data_rdb.deleteRdbStore(context, "rdbstore.db"); done(); console.log(TAG + "************* testRdbStore0001 end *************"); }) @@ -73,7 +75,7 @@ describe('rdbStoreTest', function () { */ it('testRdbStore0002', 0, async function (done) { console.log(TAG + "************* testRdbStore0002 start *************"); - let storePromise = ohos_data_rdb.getRdbStore(STORE_CONFIG, 2); + let storePromise = ohos_data_rdb.getRdbStore(context, STORE_CONFIG, 2); storePromise.then(async (store) => { try { await console.log(TAG + "getRdbStore done: " + store); @@ -86,7 +88,7 @@ describe('rdbStoreTest', function () { }) await storePromise storePromise = null - await ohos_data_rdb.deleteRdbStore("rdbstore.db"); + await ohos_data_rdb.deleteRdbStore(context, "rdbstore.db"); done(); console.log(TAG + "************* testRdbStore0002 end *************"); }) @@ -102,7 +104,7 @@ describe('rdbStoreTest', function () { let storeConfig = { name: "/wrong/rdbstore.db", } - let storePromise = ohos_data_rdb.getRdbStore(storeConfig, 4); + let storePromise = ohos_data_rdb.getRdbStore(context, storeConfig, 4); storePromise.then(async (ret) => { await console.log(TAG + "getRdbStore done" + ret); expect(null).assertFail(); @@ -122,7 +124,7 @@ describe('rdbStoreTest', function () { it('testRdbStore0004', 0, async function (done) { console.log(TAG + "************* testRdbStore0004 start *************"); - let storePromise = ohos_data_rdb.getRdbStore(STORE_CONFIG, 6); + let storePromise = ohos_data_rdb.getRdbStore(context, STORE_CONFIG, 6); storePromise.then(async (store) => { try { await store.executeSql(CREATE_TABLE_TEST); @@ -134,7 +136,7 @@ describe('rdbStoreTest', function () { }) await storePromise storePromise = null - await ohos_data_rdb.deleteRdbStore("rdbstore.db"); + await ohos_data_rdb.deleteRdbStore(context, "rdbstore.db"); done(); console.log(TAG + "************* testRdbStore0004 end *************"); }) diff --git a/distributeddatamgr/appdatamgrjstest/hap/src/main/js/default/test/RdbstoreStoreExcuteSqlJsunit.test.js b/distributeddatamgr/appdatamgrjstest/hap/src/main/js/default/test/RdbstoreStoreExcuteSqlJsunit.test.js index e00b8c3315ae8ced3fe89c001689d5823e1ad0ee..63640620549d7daf88eab9caa88d18ea4e2da138 100644 --- a/distributeddatamgr/appdatamgrjstest/hap/src/main/js/default/test/RdbstoreStoreExcuteSqlJsunit.test.js +++ b/distributeddatamgr/appdatamgrjstest/hap/src/main/js/default/test/RdbstoreStoreExcuteSqlJsunit.test.js @@ -14,6 +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'; 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)"; @@ -22,11 +23,13 @@ const STORE_CONFIG = { name: "ExcuteSqlTest.db", } var rdbStore = undefined; +var context = undefined; describe('rdbStoreInsertTest', function () { beforeAll(async function () { console.info(TAG + 'beforeAll') - rdbStore = await ohos_data_rdb.getRdbStore(STORE_CONFIG, 1); + context = await ability_featureAbility.getContext(); + rdbStore = await ohos_data_rdb.getRdbStore(context, STORE_CONFIG, 1); await rdbStore.executeSql(CREATE_TABLE_TEST, null); }) @@ -42,7 +45,7 @@ describe('rdbStoreInsertTest', function () { afterAll(async function () { console.info(TAG + 'afterAll') rdbStore = null - await ohos_data_rdb.deleteRdbStore("ExcuteSqlTest.db"); + await ohos_data_rdb.deleteRdbStore(context, "ExcuteSqlTest.db"); }) /** diff --git a/distributeddatamgr/appdatamgrjstest/hap/src/main/js/default/test/RdbstoreUpdateJsunit.test.js b/distributeddatamgr/appdatamgrjstest/hap/src/main/js/default/test/RdbstoreUpdateJsunit.test.js index 7337d9db8efb609e9f18982bb1201d4fed46b718..7d99f360fa6397f97266360300871b6e2f9ff0fb 100644 --- a/distributeddatamgr/appdatamgrjstest/hap/src/main/js/default/test/RdbstoreUpdateJsunit.test.js +++ b/distributeddatamgr/appdatamgrjstest/hap/src/main/js/default/test/RdbstoreUpdateJsunit.test.js @@ -14,6 +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'; 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)"; @@ -21,11 +22,13 @@ const STORE_CONFIG = { name: "UpdataTest.db", } var rdbStore = undefined; +var context = undefined; describe('rdbStoreUpdateTest', function () { beforeAll(async function () { console.info(TAG + 'beforeAll') - rdbStore = await ohos_data_rdb.getRdbStore(STORE_CONFIG, 1); + context = await ability_featureAbility.getContext(); + rdbStore = await ohos_data_rdb.getRdbStore(context, STORE_CONFIG, 1); await rdbStore.executeSql(CREATE_TABLE_TEST, null); }) @@ -41,7 +44,7 @@ describe('rdbStoreUpdateTest', function () { afterAll(async function () { console.info(TAG + 'afterAll') rdbStore = null - await ohos_data_rdb.deleteRdbStore("UpdataTest.db"); + await ohos_data_rdb.deleteRdbStore(context, "UpdataTest.db"); }) /**