提交 c051220a 编写于 作者: Y yanglei1217

<yanglifeng5@huawei.com>

Signed-off-by: Nyanglei1217 <yanglifeng5@huawei.com>
上级 a37ccecb
...@@ -27,5 +27,5 @@ require('./DataAbilityPredicatesJsunit.test.js') ...@@ -27,5 +27,5 @@ require('./DataAbilityPredicatesJsunit.test.js')
require('./RdbstoreTransactionJsunit.test.js') require('./RdbstoreTransactionJsunit.test.js')
require('./RdbstorePredicatesJoinJsunit.test.js') require('./RdbstorePredicatesJoinJsunit.test.js')
require('./RdbStoreDistributedJsunit.test.js') require('./RdbStoreDistributedJsunit.test.js')
require('./DataShareJsunit.test.js')
...@@ -76,8 +76,7 @@ describe('objectStoreTest', function () { ...@@ -76,8 +76,7 @@ describe('objectStoreTest', function () {
/** /**
* @tc.name: testOn001 * @tc.name: testOn001
* @tc.desc: object join session and on,object can receive callback when data has been changed * @tc.desc: object join session and on,object can receive callback when data has been changed
* @tc.type: FUNC * @tc.number: SUB_DDM_AppDataFWK_Object_Api_On_001
* @tc.require: I4H3LS
*/ */
it('testOn001', 0, function (done) { it('testOn001', 0, function (done) {
console.log(TAG + "************* testOn001 start *************"); console.log(TAG + "************* testOn001 start *************");
...@@ -108,8 +107,7 @@ describe('objectStoreTest', function () { ...@@ -108,8 +107,7 @@ describe('objectStoreTest', function () {
/** /**
* @tc.name: testOn002 * @tc.name: testOn002
* @tc.desc object join session and no on,obejct can not receive callback when data has been changed * @tc.desc object join session and no on,obejct can not receive callback when data has been changed
* @tc.type: FUNC * @tc.number: SUB_DDM_AppDataFWK_Object_Api_On_002
* @tc.require: I4H3LS
*/ */
it('testOn002', 0, function (done) { it('testOn002', 0, function (done) {
console.log(TAG + "************* testOn002 start *************"); console.log(TAG + "************* testOn002 start *************");
...@@ -139,8 +137,7 @@ describe('objectStoreTest', function () { ...@@ -139,8 +137,7 @@ describe('objectStoreTest', function () {
* @tc.name: testOn003 * @tc.name: testOn003
* @tc.desc: object join session and on,then object change data twice, * @tc.desc: object join session and on,then object change data twice,
* object can receive two callbacks when data has been changed * object can receive two callbacks when data has been changed
* @tc.type: FUNC * @tc.number: SUB_DDM_AppDataFWK_Object_Api_On_003
* @tc.require: I4H3LS
*/ */
it('testOn003', 0, function (done) { it('testOn003', 0, function (done) {
console.log(TAG + "************* testOn003 start *************"); console.log(TAG + "************* testOn003 start *************");
...@@ -176,8 +173,7 @@ describe('objectStoreTest', function () { ...@@ -176,8 +173,7 @@ describe('objectStoreTest', function () {
/** /**
* @tc.name: testOn004 * @tc.name: testOn004
* @tc.desc object join session and on,then object do not change data,object can not receive callbacks * @tc.desc object join session and on,then object do not change data,object can not receive callbacks
* @tc.type: FUNC * @tc.number: SUB_DDM_AppDataFWK_Object_Api_On_004
* @tc.require: I4H3LS
*/ */
it('testOn004', 0, function (done) { it('testOn004', 0, function (done) {
console.log(TAG + "************* testOn004 start *************"); console.log(TAG + "************* testOn004 start *************");
...@@ -199,8 +195,7 @@ describe('objectStoreTest', function () { ...@@ -199,8 +195,7 @@ describe('objectStoreTest', function () {
/** /**
* @tc.name testOff001 * @tc.name testOff001
* @tc.desc object join session and on&off,object can not receive callback after off * @tc.desc object join session and on&off,object can not receive callback after off
* @tc.type: FUNC * @tc.number: SUB_DDM_AppDataFWK_Object_Api_Off_001
* @tc.require: I4H3LS
*/ */
it('testOff001', 0, function (done) { it('testOff001', 0, function (done) {
console.log(TAG + "************* testOff001 start *************"); console.log(TAG + "************* testOff001 start *************");
...@@ -243,8 +238,7 @@ describe('objectStoreTest', function () { ...@@ -243,8 +238,7 @@ describe('objectStoreTest', function () {
/** /**
* @tc.name:testOff002 * @tc.name:testOff002
* @tc.desc object join session and off,object can not receive callback * @tc.desc object join session and off,object can not receive callback
* @tc.type: FUNC * @tc.number: SUB_DDM_AppDataFWK_Object_Api_Off_002
* @tc.require: I4H3LS
*/ */
it('testOff002', 0, function (done) { it('testOff002', 0, function (done) {
console.log(TAG + "************* testOff002 start *************"); console.log(TAG + "************* testOff002 start *************");
...@@ -275,8 +269,7 @@ describe('objectStoreTest', function () { ...@@ -275,8 +269,7 @@ describe('objectStoreTest', function () {
/** /**
* @tc.name: testMultiObjectOn001 * @tc.name: testMultiObjectOn001
* @tc.desc: two objects join session and on,then object change data,user can receive two callbacks from two objects * @tc.desc: two objects join session and on,then object change data,user can receive two callbacks from two objects
* @tc.type: FUNC * @tc.number: SUB_DDM_AppDataFWK_Object_Api_Multi_001
* @tc.require: I4H3LS
*/ */
it('testMultiObjectOn001', 0, function (done) { it('testMultiObjectOn001', 0, function (done) {
console.log(TAG + "************* testMultiObjectOn001 start *************"); console.log(TAG + "************* testMultiObjectOn001 start *************");
...@@ -317,11 +310,108 @@ describe('objectStoreTest', function () { ...@@ -317,11 +310,108 @@ describe('objectStoreTest', function () {
console.log(TAG + "************* testMultiObjectOn001 end *************"); console.log(TAG + "************* testMultiObjectOn001 end *************");
}) })
/**
* @tc.name: testMultiObjectOff001
* @tc.desc: two objects join session and on&off,then two objects can not receive callbacks
* @tc.number: SUB_DDM_AppDataFWK_Object_Api_Multi_Off_001
*/
it('testMultiObjectOff001', 0, function (done) {
console.log(TAG + "************* testMultiObjectOff001 start *************");
var objectTest = distributedObject.createDistributedObject({ name: "Amy", age: 18, isVis: false });
objectTest.setSessionId("session8");
if (objectTest != undefined && objectTest != null) {
expect("session8" == objectTest.__sessionId);
} else {
console.log(TAG + "testMultiObjectOn002 joinSession failed");
}
var testObject = distributedObject.createDistributedObject({ name: "Eric", age: 81, isVis: true });
testObject.setSessionId("testSession2");
if (testObject != undefined && testObject != null) {
expect("testSession2" == testObject.__sessionId);
} else {
console.log(TAG + "testMultiObjectOn002 joinSession failed");
}
console.log(TAG + " start call watch change")
objectTest.on("change", changeCallback);
testObject.on("change", changeCallback2);
console.info(TAG + " watch success");
if (objectTest != undefined && objectTest != null) {
objectTest.name = "jack1";
objectTest.age = 19;
objectTest.isVis = true;
expect(objectTest.name == "jack1");
expect(objectTest.age == 19);
console.info(TAG + " set data success!");
} else {
console.info(TAG + " object is null,set name fail");
}
if (testObject != undefined && testObject != null) {
testObject.name = "jack2";
testObject.age = 20;
testObject.isVis = false;
expect(testObject.name == "jack2");
expect(testObject.age == 20);
console.info(TAG + " set data success!");
} else {
console.info(TAG + " object is null,set name fail");
}
objectTest.off("change");
if (objectTest != undefined && objectTest != null) {
objectTest.name = "jack3";
objectTest.age = 21;
objectTest.isVis = false;
expect(objectTest.name == "jack3");
expect(objectTest.age == 21);
console.info(TAG + " set data success!");
} else {
console.info(TAG + " object is null,set name fail");
}
testObject.off("change");
if (testObject != undefined && testObject != null) {
testObject.name = "jack4";
testObject.age = 22;
testObject.isVis = true;
expect(testObject.name == "jack4");
expect(testObject.age == 22);
console.info(TAG + " set data success!");
} else {
console.info(TAG + " object is null,set name fail");
}
done()
console.log(TAG + "************* testMultiObjectOff001 end *************");
})
/**
* @tc.name: testChangeSession001
* @tc.desc: objects join session,then change sessionId
* @tc.number: SUB_DDM_AppDataFWK_Object_Api_Session_001
*/
it('testChangeSession001', 0, function (done) {
console.log(TAG + "************* testChangeSession001 start *************");
var objectTest = distributedObject.createDistributedObject({ name: "Amy", age: 18, isVis: false });
objectTest.setSessionId("session9");
if (objectTest != undefined && objectTest != null) {
expect("session9" == objectTest.__sessionId);
} else {
console.log(TAG + "testChangeSession001 joinSession failed");
}
console.log(TAG+"start change sessionId");
setTimeout(() => objectTest.setSessionId("session9"), 1000);
if (objectTest != undefined && objectTest != null) {
expect("session9" == objectTest.__sessionId);
} else {
console.log(TAG + "testChangeSession001 joinSession again failed");
}
done()
console.log(TAG + "************* testChangeSession001 end *************");
})
/** /**
* @tc.name: testUndefinedType001 * @tc.name: testUndefinedType001
* @tc.desc: object use undefined type,can not join session * @tc.desc: object use undefined type,can not join session
* @tc.type: FUNC * @tc.number: SUB_DDM_AppDataFWK_Object_Api_Type_001
* @tc.require: I4H3LS
*/ */
it('testUndefinedType001', 0, function (done) { it('testUndefinedType001', 0, function (done) {
console.log(TAG + "************* testUndefinedType001 start *************"); console.log(TAG + "************* testUndefinedType001 start *************");
...@@ -331,7 +421,7 @@ describe('objectStoreTest', function () { ...@@ -331,7 +421,7 @@ describe('objectStoreTest', function () {
if (object1 != undefined && object1 != null) { if (object1 != undefined && object1 != null) {
expect("session11" == object1.__sessionId); expect("session11" == object1.__sessionId);
} else { } else {
console.log(TAG + "testChangeSession001 joinSession session11 failed"); console.log(TAG + "testUndefinedType001 joinSession session11 failed");
} }
} catch (error) { } catch (error) {
console.error(TAG + error); console.error(TAG + error);
...@@ -344,8 +434,7 @@ describe('objectStoreTest', function () { ...@@ -344,8 +434,7 @@ describe('objectStoreTest', function () {
/** /**
* @tc.name: testGenSessionId001 * @tc.name: testGenSessionId001
* @tc.desc: object generate random sessionId * @tc.desc: object generate random sessionId
* @tc.type: FUNC * @tc.number: SUB_DDM_AppDataFWK_Object_Api_GetSessionId_001
* @tc.require: I4H3LS
*/ */
it('testGenSessionId001', 0, function (done) { it('testGenSessionId001', 0, function (done) {
console.log(TAG + "************* testGenSessionId001 start *************"); console.log(TAG + "************* testGenSessionId001 start *************");
...@@ -359,11 +448,10 @@ describe('objectStoreTest', function () { ...@@ -359,11 +448,10 @@ describe('objectStoreTest', function () {
/** /**
* @tc.name: testGenSessionId002 * @tc.name: testGenSessionId002
* @tc.desc: object generate 2 random sessionId and not equal * @tc.desc: object generate 2 random sessionId and not equal
* @tc.type: FUNC * @tc.number: SUB_DDM_AppDataFWK_Object_Api_GetSessionId_002
* @tc.require: I4H3LS
*/ */
it('testGenSessionId002', 0, function (done) { it('testGenSessionId002', 0, function (done) {
console.log(TAG + "************* testGenSessionId001 start *************"); console.log(TAG + "************* testGenSessionId002 start *************");
var sessionId1 = distributedObject.genSessionId(); var sessionId1 = distributedObject.genSessionId();
var sessionId2 = distributedObject.genSessionId(); var sessionId2 = distributedObject.genSessionId();
expect(sessionId1 != sessionId2); expect(sessionId1 != sessionId2);
...@@ -375,8 +463,7 @@ describe('objectStoreTest', function () { ...@@ -375,8 +463,7 @@ describe('objectStoreTest', function () {
/** /**
* @tc.name: testOnStatus001 * @tc.name: testOnStatus001
* @tc.desc: object set a listener to watch another object online/offline * @tc.desc: object set a listener to watch another object online/offline
* @tc.type: FUNC * @tc.number: SUB_DDM_AppDataFWK_Object_Api_OnStatus_001
* @tc.require: I4H3M8
*/ */
it('testOnStatus001', 0, function (done) { it('testOnStatus001', 0, function (done) {
console.log(TAG + "************* testOnStatus001 start *************"); console.log(TAG + "************* testOnStatus001 start *************");
...@@ -392,11 +479,10 @@ describe('objectStoreTest', function () { ...@@ -392,11 +479,10 @@ describe('objectStoreTest', function () {
/** /**
* @tc.name: testOnStatus002 * @tc.name: testOnStatus002
* @tc.desc: object set several listener and can unset specified listener * @tc.desc: object set several listener and can unset specified listener
* @tc.type: FUNC * @tc.number: SUB_DDM_AppDataFWK_Object_Api_OnStatus_002
* @tc.require: I4H3M8
*/ */
it('testOnStatus002', 0, function (done) { it('testOnStatus002', 0, function (done) {
console.log(TAG + "************* testOnStatus001 start *************"); console.log(TAG + "************* testOnStatus002 start *************");
console.log(TAG + "start watch status"); console.log(TAG + "start watch status");
var objectTest = distributedObject.createDistributedObject({ name: "Amy", age: 18, isVis: false }); var objectTest = distributedObject.createDistributedObject({ name: "Amy", age: 18, isVis: false });
objectTest.on("status", statusCallback1); objectTest.on("status", statusCallback1);
...@@ -414,11 +500,10 @@ describe('objectStoreTest', function () { ...@@ -414,11 +500,10 @@ describe('objectStoreTest', function () {
/** /**
* @tc.name: testOnStatus003 * @tc.name: testOnStatus003
* @tc.desc: object set several listener and can unWatch all watcher * @tc.desc: object set several listener and can unWatch all watcher
* @tc.type: FUNC * @tc.number: SUB_DDM_AppDataFWK_Object_Api_OnStatus_003
* @tc.require: I4H3M8
*/ */
it('testOnStatus002', 0, function (done) { it('testOnStatus003', 0, function (done) {
console.log(TAG + "************* testOnStatus001 start *************"); console.log(TAG + "************* testOnStatus003 start *************");
console.log(TAG + "start watch status"); console.log(TAG + "start watch status");
var objectTest = distributedObject.createDistributedObject({ name: "Amy", age: 18, isVis: false }); var objectTest = distributedObject.createDistributedObject({ name: "Amy", age: 18, isVis: false });
objectTest.on("status", statusCallback1); objectTest.on("status", statusCallback1);
...@@ -436,8 +521,7 @@ describe('objectStoreTest', function () { ...@@ -436,8 +521,7 @@ describe('objectStoreTest', function () {
/** /**
* @tc.name: testComplex001 * @tc.name: testComplex001
* @tc.desc: object can get/set complex data * @tc.desc: object can get/set complex data
* @tc.type: FUNC * @tc.number: SUB_DDM_AppDataFWK_Object_Api_Complex_001
* @tc.require: I4H3M8
*/ */
it('testComplex001', 0, function (done) { it('testComplex001', 0, function (done) {
console.log(TAG + "************* testComplex001 start *************"); console.log(TAG + "************* testComplex001 start *************");
...@@ -470,8 +554,7 @@ describe('objectStoreTest', function () { ...@@ -470,8 +554,7 @@ describe('objectStoreTest', function () {
/** /**
* @tc.name: testMaxSize001 * @tc.name: testMaxSize001
* @tc.desc: object can get/set data under 4MB size * @tc.desc: object can get/set data under 4MB size
* @tc.type: FUNC * @tc.number: SUB_DDM_AppDataFWK_Object_Api_MaxSize_001
* @tc.require: I4H3M8
*/ */
it('testMaxSize001', 0, function (done) { it('testMaxSize001', 0, function (done) {
console.log(TAG + "************* testMaxSize001 start *************"); console.log(TAG + "************* testMaxSize001 start *************");
...@@ -501,8 +584,7 @@ describe('objectStoreTest', function () { ...@@ -501,8 +584,7 @@ describe('objectStoreTest', function () {
/** /**
* @tc.name: testPerformance001 * @tc.name: testPerformance001
* @tc.desc: performanceTest for set/get data * @tc.desc: performanceTest for set/get data
* @tc.type: FUNC * @tc.number: SUB_DDM_AppDataFWK_Object_Api_Performance_001
* @tc.require: I4H3M8
*/ */
it('testPerformance001', 0, function (done) { it('testPerformance001', 0, function (done) {
console.log(TAG + "************* testPerformance001 start *************"); console.log(TAG + "************* testPerformance001 start *************");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册