提交 0fd11b83 编写于 作者: W wangxiaomeng1379

<wangxiaomeng9@huawei.com>

Signed-off-by: Nwangxiaomeng1379 <wangxiaomeng9@huawei.com>
上级 b5a7a2d7
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Copyright (C) 2022-2023 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
......@@ -130,9 +130,10 @@ export default function objectStoreTest() {
} else {
console.info(TAG + " object is null,set name fail");
}
objectTest.off("change");
objectTest.setSessionId("");
done();
console.info(TAG + "************* testOn001 end *************");
objectTest.setSessionId("");
})
/**
......@@ -160,9 +161,9 @@ export default function objectStoreTest() {
} else {
console.info(TAG + " object is null,set name fail");
}
objectTest.setSessionId("");
done();
console.info(TAG + "************* testOn002 end *************");
objectTest.setSessionId("");
})
/**
......@@ -198,10 +199,10 @@ export default function objectStoreTest() {
} else {
console.info(TAG + " object is null,set name fail");
}
objectTest.off("change");
objectTest.setSessionId("");
done();
console.info(TAG + "************* testOn003 end *************");
objectTest.setSessionId("");
})
/**
......@@ -221,11 +222,11 @@ export default function objectStoreTest() {
}
objectTest.on("change", changeCallback);
console.info(TAG + " start call watch change");
objectTest.off("change");
console.info(TAG + " end call watch change");
objectTest.setSessionId("");
done();
console.info(TAG + "************* testOn004 end *************");
objectTest.setSessionId("");
})
/**
......@@ -267,10 +268,9 @@ export default function objectStoreTest() {
} else {
console.info(TAG + " object is null,set name fail");
}
objectTest.setSessionId("");
done()
console.info(TAG + "************* testOff001 end *************");
objectTest.setSessionId("");
})
/**
......@@ -336,6 +336,7 @@ export default function objectStoreTest() {
objectTest.name = "jack1";
objectTest.age = 19;
objectTest.isVis = true;
expect(objectTest.name == "jack1").assertEqual(true);
expect(objectTest.age == 19).assertEqual(true);
console.info(TAG + " set data success!");
} else {
......@@ -351,10 +352,12 @@ export default function objectStoreTest() {
} else {
console.info(TAG + " testObject is null,set name fail");
}
done();
console.info(TAG + "************* testMultiObjectOn001 end *************");
objectTest.off("change");
testObject.off("change");
objectTest.setSessionId("");
testObject.setSessionId("");
done();
console.info(TAG + "************* testMultiObjectOn001 end *************");
})
/**
......@@ -427,11 +430,10 @@ export default function objectStoreTest() {
} else {
console.info(TAG + " object is null,set name fail");
}
done();
console.info(TAG + "************* testMultiObjectOff001 end *************");
objectTest.setSessionId("");
testObject.setSessionId("");
done();
console.info(TAG + "************* testMultiObjectOff001 end *************");
})
/**
......@@ -480,9 +482,10 @@ export default function objectStoreTest() {
} else {
console.info(TAG + " object is null,set name fail");
}
objectTest.off("change");
objectTest.setSessionId("");
done();
console.info(TAG + "************* testChangeSession001 end *************");
objectTest.setSessionId("");
})
/**
......@@ -501,7 +504,6 @@ export default function objectStoreTest() {
} catch (error) {
console.error(TAG + error);
}
done();
console.info(TAG + "************* testUndefinedType001 end *************");
})
......@@ -515,7 +517,6 @@ export default function objectStoreTest() {
console.info(TAG + "************* testGenSessionId001 start *************");
var sessionId = distributedObject.genSessionId();
expect(sessionId != null && sessionId.length > 0 && typeof (sessionId) == 'string').assertEqual(true);
done();
console.info(TAG + "************* testGenSessionId001 end *************");
})
......@@ -546,10 +547,10 @@ export default function objectStoreTest() {
var objectTest = distributedObject.createDistributedObject({ name: "Amy", age: 18, isVis: false });
objectTest.on("status", statusCallback1);
console.info(TAG + "watch success");
objectTest.off("status");
objectTest.setSessionId("");
done();
console.info(TAG + "************* testOnStatus001 end *************");
objectTest.setSessionId("");
})
/**
......@@ -570,10 +571,9 @@ export default function objectStoreTest() {
console.info(TAG + "start call unwatch status");
objectTest.off("status", statusCallback1);
console.info(TAG + "unwatch success");
objectTest.setSessionId("");
done();
console.info(TAG + "************* testOnStatus002 end *************");
objectTest.setSessionId("");
})
/**
......@@ -592,12 +592,11 @@ export default function objectStoreTest() {
objectTest.on("status", statusCallback3);
console.info(TAG + "watch success");
console.info(TAG + "start call unwatch status");
objectTest.off("status");
objectTest.off("status", statusCallback1);
console.info(TAG + "unwatch success");
objectTest.setSessionId("");
done();
console.info(TAG + "************* testOnStatus003 end *************");
objectTest.setSessionId("");
})
/**
......@@ -631,10 +630,9 @@ export default function objectStoreTest() {
expect(complexObject.parent.father == "jack Dad").assertEqual(true);
expect(complexObject.list[0].mother == "jack2 mom2").assertEqual(true);
expect(complexObject.list[1].father == "jack2 Dad2").assertEqual(true);
complexObject.setSessionId("");
done();
console.info(TAG + "************* testComplex001 end *************");
complexObject.setSessionId("");
})
/**
......@@ -663,10 +661,9 @@ export default function objectStoreTest() {
} else {
console.info(TAG + " object is null,set name fail");
}
objectTest.setSessionId("");
done()
console.info(TAG + "************* testMaxSize001 end *************");
objectTest.setSessionId("");
})
/**
......@@ -711,12 +708,12 @@ export default function objectStoreTest() {
console.log("testPerformance001 totalTime = " + totalTime);
console.log("testPerformance001 baseLine = " + baseLine);
expect(totalTime < baseLine).assertEqual(true);
complexObject.setSessionId("");
done();
console.log(TAG + "************* testPerformance001 end *************");
complexObject.setSessionId("");
})
/**
/**
* @tc.name: testSave001
* @tc.desc: Save object <Promise>
* @tc.number: SUB_DDM_AppDataFWK_Object_Api_Save_001
......
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Copyright (C) 2022-2023 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
......@@ -265,6 +265,7 @@ describe('objectStoreTest', function () {
}
console.log(TAG + "************* SUB_DDM_AppDataFWK_Object_Api9_On_001 end *************");
g_object.off("change");
g_object.setSessionId("", (error, data) => {
console.info(TAG + error + "," + data);
});
......@@ -338,6 +339,7 @@ describe('objectStoreTest', function () {
expect(error != undefined).assertEqual(true);
}
console.log(TAG + "************* SUB_DDM_AppDataFWK_Object_Api9_On_003 end *************");
g_object.off("error");
g_object.setSessionId("", (error, data) => {
console.info(TAG + error + "," + data);
});
......@@ -658,8 +660,87 @@ describe('objectStoreTest', function () {
console.info(TAG + error + "," + data);
});
done();
})
console.log(TAG + "*************Unit Test End*************");
})
/**
* @tc.name: testNumberMax
* @tc.desc: test NumberMax
* @tc.type: FUNC
* @tc.number: SUB_DDM_AppDataFWK_Object_Api9_NumberMax_0100
*/
it('SUB_DDM_AppDataFWK_Object_Api9_NumberMax_0100', 0, async function (done) {
console.log(TAG + "************* SUB_DDM_AppDataFWK_Object_Api9_NumberMax_0100 start *************");
try {
let g_object;
let maxValue = Number.MAX_VALUE;
g_object= distributedObject.create(context, {name: "Amy", age: maxValue, isVis: false});
console.info(TAG + "_age = "+g_object.age);
expect(g_object == undefined).assertEqual(false);
} catch (error) {
console.info(error.code + error.message);
}
console.log(TAG + "************* SUB_DDM_AppDataFWK_Object_Api9_NumberMax_0100 end *************");
done();
})
/**
* @tc.name: testNumberMin
* @tc.desc: test NumberMin
* @tc.type: FUNC
* @tc.number: SUB_DDM_AppDataFWK_Object_Api9_NumberMin_0100
*/
it('SUB_DDM_AppDataFWK_Object_Api9_NumberMin_0100', 0, async function (done) {
console.log(TAG + "************* SUB_DDM_AppDataFWK_Object_Api9_NumberMin_0100 start *************");
try {
let g_object;
let minValue = Number.MIN_VALUE;
g_object= distributedObject.create(context, {name: "Amy", age: minValue, isVis: false});
console.info(TAG + "_age = "+g_object.age);
expect(g_object == undefined).assertEqual(false);
} catch (error) {
console.info(error.code + error.message);
}
console.log(TAG + "************* SUB_DDM_AppDataFWK_Object_Api9_NumberMin_0100 end *************");
done();
})
/**
* @tc.name: testNumberAbnormal
* @tc.desc: test NumberAbnormal
* @tc.type: FUNC
* @tc.number: SUB_DDM_AppDataFWK_Object_Api9_NumberAbnormal_0100
*/
it('SUB_DDM_AppDataFWK_Object_Api9_NumberAbnormal_0100', 0, async function (done) {
console.log(TAG + "************* SUB_DDM_AppDataFWK_Object_Api9_NumberAbnormal_0100 start *************");
try {
let g_object;
let abnValue = -1;
g_object= distributedObject.create(context, {name: "Amy", age: abnValue, isVis: false});
console.info(TAG + "_age = "+g_object.age);
expect(g_object == undefined).assertEqual(false);
} catch (error) {
console.info(error.code + error.message);
}
console.log(TAG + "************* SUB_DDM_AppDataFWK_Object_Api9_NumberAbnormal_0100 end *************");
done();
})
/**
* @tc.name: testNumberAbnormal
* @tc.desc: test NumberAbnormal
* @tc.type: FUNC
* @tc.number: SUB_DDM_AppDataFWK_Object_Api9_NumberAbnormal_0200
*/
it('SUB_DDM_AppDataFWK_Object_Api9_NumberAbnormal_0100', 0, async function (done) {
console.log(TAG + "************* SUB_DDM_AppDataFWK_Object_Api9_NumberAbnormal_0100 start *************");
try {
let g_object;
let abnValue = 0.02;
g_object= distributedObject.create(context, {name: "Amy", age: abnValue, isVis: false});
console.info(TAG + "_age = "+g_object.age);
expect(g_object == undefined).assertEqual(false);
} catch (error) {
console.info(error.code + error.message);
}
console.log(TAG + "************* SUB_DDM_AppDataFWK_Object_Api9_NumberAbnormal_0100 end *************");
done();
})
console.log(TAG + "*************Unit Test End*************");
})
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Copyright (c) 2022-2023 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
......@@ -455,7 +455,7 @@ describe('preferencesCallBackTest', function () {
expect(false).assertTrue();
}else{
console.info(TAG + "Delete preferences success")
expect(true).assertTrue();
expect(data == null).assertTrue();
}
})
done()
......@@ -482,7 +482,7 @@ describe('preferencesCallBackTest', function () {
expect(false).assertTrue();
}else{
console.info(TAG + "Remove preferences from cache success")
expect(true).assertTrue();
expect(data==null).assertTrue();
}
})
done();
......
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Copyright (c) 2022-2023 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
......
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Copyright (c) 2022-2023 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
......@@ -12,7 +12,7 @@
* 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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
import dataPreferences from '@ohos.data.preferences'
import featureAbility from '@ohos.ability.featureAbility';
......
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Copyright (c) 2022-2023 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
......@@ -30,11 +30,13 @@ describe('systemStorageTest', function () {
afterEach(async function (done) {
console.info(TAG + 'afterEach')
let promise = storage.clear({
success: function () {
expect(true).assertTrue();
success: function (data) {
console.info("Succeeded in clearing.");
expect(data!=undefined).assertTrue();
done();
},
fail: function (data, errCode) {
console.info("Failed to clearr");
expect(false).assertTrue();
done();
}
......@@ -200,8 +202,9 @@ describe('systemStorageTest', function () {
let promise1 = storage.set({
key: 'storageKey',
value: 'storageVal',
success: async function () {
await expect(true).assertTrue();
success:async function (data) {
console.info("Set is success.");
await expect(data != undefined).assertTrue();
},
fail: async function (data, err) {
await expect(false).assertTrue();
......@@ -340,8 +343,9 @@ describe('systemStorageTest', function () {
let promise1 = storage.set({
key: 'storageKey',
value: 'storageVal',
success: async function () {
await expect(true).assertTrue();
success:async function (data) {
console.info("Set is success.");
await expect(data != undefined).assertTrue();
},
fail: async function (data, err) {
await expect(false).assertTrue();
......@@ -390,8 +394,9 @@ describe('systemStorageTest', function () {
let promise1 = storage.set({
key: 'storageKey',
value: 'storageVal',
success: async function () {
await expect(true).assertTrue();
success:async function (data) {
console.info("Set is success.");
await expect(data != undefined).assertTrue();
},
fail: async function (data, err) {
await expect(false).assertTrue();
......@@ -435,8 +440,9 @@ describe('systemStorageTest', function () {
let promise1 = storage.set({
key: 'storageKey',
value: 'test',
success: async function () {
await expect(true).assertTrue();
success:async function (data) {
console.info("Set is success.");
await expect(data != undefined).assertTrue();
},
fail: async function () {
await expect(false).assertTrue();
......@@ -445,8 +451,9 @@ describe('systemStorageTest', function () {
await promise1;
let promise2 = storage.delete({
key: '123',
success: async function () {
await expect(true).assertTrue();
success: async function (data) {
console.info("delete is success.");
await expect(data != undefined).assertTrue();
},
fail: async function (data, err) {
await expect(false).assertTrue();
......@@ -486,8 +493,9 @@ describe('systemStorageTest', function () {
let promise1 = storage.set({
key: 'storageKey1',
value: 'storageVal1',
success:async function () {
await expect(true).assertTrue();
success:async function (data) {
console.info("Set is success.");
await expect(data != undefined).assertTrue();
},
fail:async function () {
await expect(false).assertTrue();
......@@ -497,8 +505,9 @@ describe('systemStorageTest', function () {
let promise2 = storage.set({
key: 'storageKey2',
value: 'storageVal2',
success:async function () {
await expect(true).assertTrue();
success:async function (data) {
console.info("Set is success.")
await expect(data != undefined).assertTrue();
},
fail:async function () {
await expect(false).assertTrue();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册