未验证 提交 2ec2820d 编写于 作者: O openharmony_ci 提交者: Gitee

!8591 【distributeddatamgr】【master】【acts】distributedObject 的promise接口前加await

Merge pull request !8591 from wuxiaodan/master
...@@ -726,7 +726,7 @@ export default function objectStoreTest() { ...@@ -726,7 +726,7 @@ export default function objectStoreTest() {
g_object.setSessionId("testSession001"); g_object.setSessionId("testSession001");
expect("testSession001" == g_object.__sessionId).assertEqual(true); expect("testSession001" == g_object.__sessionId).assertEqual(true);
g_object.save("local").then((ret) => { await g_object.save("local").then((ret) => {
expect(ret.sessionId == "testSession001").assertEqual(true); expect(ret.sessionId == "testSession001").assertEqual(true);
expect(ret.version == g_object.__version).assertEqual(true); expect(ret.version == g_object.__version).assertEqual(true);
expect(ret.deviceId == "local").assertEqual(true); expect(ret.deviceId == "local").assertEqual(true);
......
...@@ -84,7 +84,7 @@ describe('objectStoreTestV9', function () { ...@@ -84,7 +84,7 @@ describe('objectStoreTestV9', function () {
* @tc.number: SUB_DDM_AppDataFWK_Object_Api9_SetSessionId_001 * @tc.number: SUB_DDM_AppDataFWK_Object_Api9_SetSessionId_001
* @tc.type: FUNC * @tc.type: FUNC
*/ */
it('SUB_DDM_AppDataFWK_Object_Api9_SetSessionId_001', 0, function (done) { it('SUB_DDM_AppDataFWK_Object_Api9_SetSessionId_001', 0, async function (done) {
console.info(TAG + "************* SUB_DDM_AppDataFWK_Object_Api9_SetSessionId_001 start *************"); console.info(TAG + "************* SUB_DDM_AppDataFWK_Object_Api9_SetSessionId_001 start *************");
var g_object; var g_object;
try { try {
...@@ -103,15 +103,16 @@ describe('objectStoreTestV9', function () { ...@@ -103,15 +103,16 @@ describe('objectStoreTestV9', function () {
} }
g_object = distributedObject.create(context, {name: "Amy", age: 18, isVis: false}); g_object = distributedObject.create(context, {name: "Amy", age: 18, isVis: false});
expect(g_object == undefined).assertEqual(false); expect(g_object == undefined).assertEqual(false);
g_object.setSessionId("123456").then((data) => { await g_object.setSessionId("123456").then((data) => {
console.info(TAG + "SUB_DDM_AppDataFWK_Object_Api9_SetSessionId_001"); console.info(TAG + "SUB_DDM_AppDataFWK_Object_Api9_SetSessionId_001 setSessionId 123456");
console.info(TAG + data); console.info(TAG + data);
}).catch((error) => { }).catch((error) => {
console.info(TAG + error); console.info(TAG + error);
}); });
console.info(TAG + "************* SUB_DDM_AppDataFWK_Object_Api9_SetSessionId_001 end *************"); console.info(TAG + "************* SUB_DDM_AppDataFWK_Object_Api9_SetSessionId_001 end *************");
g_object.setSessionId((error, data) => { g_object.setSessionId((error, data) => {
console.info(TAG + error + "," + data); console.info(TAG + error + ", data=" + data);
}); });
done(); done();
}) })
...@@ -122,12 +123,12 @@ describe('objectStoreTestV9', function () { ...@@ -122,12 +123,12 @@ describe('objectStoreTestV9', function () {
* @tc.type: FUNC * @tc.type: FUNC
* @tc.number: SUB_DDM_AppDataFWK_Object_Api9_SetSessionId_002 * @tc.number: SUB_DDM_AppDataFWK_Object_Api9_SetSessionId_002
*/ */
it('SUB_DDM_AppDataFWK_Object_Api9_SetSessionId_002', 0, function (done) { it('SUB_DDM_AppDataFWK_Object_Api9_SetSessionId_002', 0, async function (done) {
console.info(TAG + "************* SUB_DDM_AppDataFWK_Object_Api9_SetSessionId_002 start *************"); console.info(TAG + "************* SUB_DDM_AppDataFWK_Object_Api9_SetSessionId_002 start *************");
var g_object = distributedObject.create(context, {name: "Amy", age: 18, isVis: false}); var g_object = distributedObject.create(context, {name: "Amy", age: 18, isVis: false});
expect(g_object == undefined).assertEqual(false); expect(g_object == undefined).assertEqual(false);
try { try {
g_object.setSessionId(123).then((data) => { await g_object.setSessionId(123).then((data) => {
console.info(TAG + "setSessionId test"); console.info(TAG + "setSessionId test");
console.info(TAG + data); console.info(TAG + data);
}).catch((err) => { }).catch((err) => {
...@@ -150,13 +151,13 @@ describe('objectStoreTestV9', function () { ...@@ -150,13 +151,13 @@ describe('objectStoreTestV9', function () {
* @tc.type: FUNC * @tc.type: FUNC
* @tc.number: SUB_DDM_AppDataFWK_Object_Api9_SetSessionId_003 * @tc.number: SUB_DDM_AppDataFWK_Object_Api9_SetSessionId_003
*/ */
it('SUB_DDM_AppDataFWK_Object_Api9_SetSessionId_003', 0, function (done) { it('SUB_DDM_AppDataFWK_Object_Api9_SetSessionId_003', 0, async function (done) {
console.info(TAG + "************* SUB_DDM_AppDataFWK_Object_Api9_SetSessionId_003 start *************"); console.info(TAG + "************* SUB_DDM_AppDataFWK_Object_Api9_SetSessionId_003 start *************");
var g_object = distributedObject.create(context, {name: "Amy", age: 18, isVis: false}); var g_object = distributedObject.create(context, {name: "Amy", age: 18, isVis: false});
expect(g_object == undefined).assertEqual(false); expect(g_object == undefined).assertEqual(false);
g_object.setSessionId("session1"); g_object.setSessionId("session1");
expect("session1" == g_object.__sessionId).assertEqual(true); expect("session1" == g_object.__sessionId).assertEqual(true);
g_object.setSessionId("session1").then(() => { await g_object.setSessionId("session1").then(() => {
console.info(TAG + "setSessionId test"); console.info(TAG + "setSessionId test");
}).catch((error) => { }).catch((error) => {
expect(error.code == 15400001).assertEqual(true); expect(error.code == 15400001).assertEqual(true);
...@@ -175,11 +176,11 @@ describe('objectStoreTestV9', function () { ...@@ -175,11 +176,11 @@ describe('objectStoreTestV9', function () {
* @tc.type: FUNC * @tc.type: FUNC
* @tc.number: SUB_DDM_AppDataFWK_Object_Api9_SetSessionId_004 * @tc.number: SUB_DDM_AppDataFWK_Object_Api9_SetSessionId_004
*/ */
it('SUB_DDM_AppDataFWK_Object_Api9_SetSessionId_004', 0, function (done) { it('SUB_DDM_AppDataFWK_Object_Api9_SetSessionId_004', 0, async function (done) {
console.info(TAG + "************* SUB_DDM_AppDataFWK_Object_Api9_SetSessionId_004 start *************"); console.info(TAG + "************* SUB_DDM_AppDataFWK_Object_Api9_SetSessionId_004 start *************");
var g_object = distributedObject.create(context, {name: "Amy", age: 18, isVis: false}); var g_object = distributedObject.create(context, {name: "Amy", age: 18, isVis: false});
expect(g_object == undefined).assertEqual(false); expect(g_object == undefined).assertEqual(false);
g_object.setSessionId("123456").then((data) => { await g_object.setSessionId("123456").then((data) => {
console.info(TAG + "setSessionId test"); console.info(TAG + "setSessionId test");
console.info(TAG + data); console.info(TAG + data);
}).catch((err) => { }).catch((err) => {
...@@ -233,11 +234,11 @@ describe('objectStoreTestV9', function () { ...@@ -233,11 +234,11 @@ describe('objectStoreTestV9', function () {
* @tc.type: FUNC * @tc.type: FUNC
* @tc.number: SUB_DDM_AppDataFWK_Object_Api9_On_001 * @tc.number: SUB_DDM_AppDataFWK_Object_Api9_On_001
*/ */
it('SUB_DDM_AppDataFWK_Object_Api9_On_001', 0, function (done) { it('SUB_DDM_AppDataFWK_Object_Api9_On_001', 0, async function (done) {
console.info(TAG + "************* SUB_DDM_AppDataFWK_Object_Api9_On_001 start *************"); console.info(TAG + "************* SUB_DDM_AppDataFWK_Object_Api9_On_001 start *************");
var g_object = distributedObject.create(context, {name: "Amy", age: 18, isVis: false}); var g_object = distributedObject.create(context, {name: "Amy", age: 18, isVis: false});
expect(g_object == undefined).assertEqual(false); expect(g_object == undefined).assertEqual(false);
g_object.setSessionId("session1").then(() => { await g_object.setSessionId("session1").then(() => {
console.info("join session"); console.info("join session");
}).catch((error) => { }).catch((error) => {
console.info(TAG + error.code + error.message); console.info(TAG + error.code + error.message);
...@@ -315,11 +316,11 @@ describe('objectStoreTestV9', function () { ...@@ -315,11 +316,11 @@ describe('objectStoreTestV9', function () {
* @tc.type: FUNC * @tc.type: FUNC
* @tc.number: SUB_DDM_AppDataFWK_Object_Api9_On_003 * @tc.number: SUB_DDM_AppDataFWK_Object_Api9_On_003
*/ */
it('SUB_DDM_AppDataFWK_Object_Api9_On_003', 0, function (done) { it('SUB_DDM_AppDataFWK_Object_Api9_On_003', 0, async function (done) {
console.info(TAG + "************* SUB_DDM_AppDataFWK_Object_Api9_On_003 start *************"); console.info(TAG + "************* SUB_DDM_AppDataFWK_Object_Api9_On_003 start *************");
var g_object = distributedObject.create(context, {name: "Amy", age: 18, isVis: false}); var g_object = distributedObject.create(context, {name: "Amy", age: 18, isVis: false});
expect(g_object == undefined).assertEqual(false); expect(g_object == undefined).assertEqual(false);
g_object.setSessionId("session1").then(() => { await g_object.setSessionId("session1").then(() => {
console.info("join session"); console.info("join session");
}).catch((error) => { }).catch((error) => {
console.info(TAG + error.code + error.message); console.info(TAG + error.code + error.message);
...@@ -353,11 +354,11 @@ describe('objectStoreTestV9', function () { ...@@ -353,11 +354,11 @@ describe('objectStoreTestV9', function () {
* @tc.type: FUNC * @tc.type: FUNC
* @tc.number: SUB_DDM_AppDataFWK_Object_Api9_Off_001 * @tc.number: SUB_DDM_AppDataFWK_Object_Api9_Off_001
*/ */
it('SUB_DDM_AppDataFWK_Object_Api9_Off_001', 0, function (done) { it('SUB_DDM_AppDataFWK_Object_Api9_Off_001', 0, async function (done) {
console.info(TAG + "************* SUB_DDM_AppDataFWK_Object_Api9_Off_001 start *************"); console.info(TAG + "************* SUB_DDM_AppDataFWK_Object_Api9_Off_001 start *************");
var g_object = distributedObject.create(context, {name: "Amy", age: 18, isVis: false}); var g_object = distributedObject.create(context, {name: "Amy", age: 18, isVis: false});
expect(g_object == undefined).assertEqual(false); expect(g_object == undefined).assertEqual(false);
g_object.setSessionId("session5").then(() => { await g_object.setSessionId("session5").then(() => {
console.info("join session"); console.info("join session");
}).catch((error) => { }).catch((error) => {
console.info(TAG + error.code + error.message); console.info(TAG + error.code + error.message);
...@@ -401,11 +402,11 @@ describe('objectStoreTestV9', function () { ...@@ -401,11 +402,11 @@ describe('objectStoreTestV9', function () {
* @tc.type: FUNC * @tc.type: FUNC
* @tc.number: SUB_DDM_AppDataFWK_Object_Api9_Off_002 * @tc.number: SUB_DDM_AppDataFWK_Object_Api9_Off_002
*/ */
it('SUB_DDM_AppDataFWK_Object_Api9_Off_002', 0, function (done) { it('SUB_DDM_AppDataFWK_Object_Api9_Off_002', 0, async function (done) {
console.info(TAG + "************* SUB_DDM_AppDataFWK_Object_Api9_Off_002 start *************"); console.info(TAG + "************* SUB_DDM_AppDataFWK_Object_Api9_Off_002 start *************");
var g_object = distributedObject.create(context, {name: "Amy", age: 18, isVis: false}); var g_object = distributedObject.create(context, {name: "Amy", age: 18, isVis: false});
expect(g_object == undefined).assertEqual(false); expect(g_object == undefined).assertEqual(false);
g_object.setSessionId("session6").then(() => { await g_object.setSessionId("session6").then(() => {
console.info("join session"); console.info("join session");
}).catch((error) => { }).catch((error) => {
console.info(TAG + error.code + error.message); console.info(TAG + error.code + error.message);
...@@ -419,7 +420,7 @@ describe('objectStoreTestV9', function () { ...@@ -419,7 +420,7 @@ describe('objectStoreTestV9', function () {
} }
console.info(TAG + " end call watch change"); console.info(TAG + " end call watch change");
console.info(TAG + "************* SUB_DDM_AppDataFWK_Object_Api9_Off_002 end *************"); console.info(TAG + "************* SUB_DDM_AppDataFWK_Object_Api9_Off_002 end *************");
g_object.setSessionId().then((data) => { await g_object.setSessionId().then((data) => {
console.info(TAG + data); console.info(TAG + data);
console.info(TAG + "setSessionId test"); console.info(TAG + "setSessionId test");
}).catch((error) => { }).catch((error) => {
...@@ -434,7 +435,7 @@ describe('objectStoreTestV9', function () { ...@@ -434,7 +435,7 @@ describe('objectStoreTestV9', function () {
* @tc.type: FUNC * @tc.type: FUNC
* @tc.number: SUB_DDM_AppDataFWK_Object_Api9_OnStatus_001 * @tc.number: SUB_DDM_AppDataFWK_Object_Api9_OnStatus_001
*/ */
it('SUB_DDM_AppDataFWK_Object_Api9_OnStatus_001', 0, function (done) { it('SUB_DDM_AppDataFWK_Object_Api9_OnStatus_001', 0, async function (done) {
console.info(TAG + "************* SUB_DDM_AppDataFWK_Object_Api9_OnStatus_001 start *************"); console.info(TAG + "************* SUB_DDM_AppDataFWK_Object_Api9_OnStatus_001 start *************");
console.info(TAG + "start watch status"); console.info(TAG + "start watch status");
var g_object = distributedObject.create(context, {name: "Amy", age: 18, isVis: false}); var g_object = distributedObject.create(context, {name: "Amy", age: 18, isVis: false});
...@@ -447,7 +448,7 @@ describe('objectStoreTestV9', function () { ...@@ -447,7 +448,7 @@ describe('objectStoreTestV9', function () {
} }
console.info(TAG + "watch success"); console.info(TAG + "watch success");
console.info(TAG + "************* SUB_DDM_AppDataFWK_Object_Api9_OnStatus_001 end *************"); console.info(TAG + "************* SUB_DDM_AppDataFWK_Object_Api9_OnStatus_001 end *************");
g_object.setSessionId("").then((data) => { await g_object.setSessionId("").then((data) => {
console.info(TAG + data); console.info(TAG + data);
console.info(TAG + "setSessionId test"); console.info(TAG + "setSessionId test");
}).catch((error) => { }).catch((error) => {
...@@ -462,7 +463,7 @@ describe('objectStoreTestV9', function () { ...@@ -462,7 +463,7 @@ describe('objectStoreTestV9', function () {
* @tc.type: FUNC * @tc.type: FUNC
* @tc.number: SUB_DDM_AppDataFWK_Object_Api9_OnStatus_002 * @tc.number: SUB_DDM_AppDataFWK_Object_Api9_OnStatus_002
*/ */
it('SUB_DDM_AppDataFWK_Object_Api9_OnStatus_002', 0, function (done) { it('SUB_DDM_AppDataFWK_Object_Api9_OnStatus_002', 0, async function (done) {
console.info(TAG + "************* SUB_DDM_AppDataFWK_Object_Api9_OnStatus_002 start *************"); console.info(TAG + "************* SUB_DDM_AppDataFWK_Object_Api9_OnStatus_002 start *************");
console.info(TAG + "start watch status"); console.info(TAG + "start watch status");
var g_object = distributedObject.create(context, {name: "Amy", age: 18, isVis: false}); var g_object = distributedObject.create(context, {name: "Amy", age: 18, isVis: false});
...@@ -474,7 +475,7 @@ describe('objectStoreTestV9', function () { ...@@ -474,7 +475,7 @@ describe('objectStoreTestV9', function () {
g_object.off("status"); g_object.off("status");
console.info(TAG + "unwatch success"); console.info(TAG + "unwatch success");
console.info(TAG + "************* SUB_DDM_AppDataFWK_Object_Api9_OnStatus_002 end *************"); console.info(TAG + "************* SUB_DDM_AppDataFWK_Object_Api9_OnStatus_002 end *************");
g_object.setSessionId().then(() => { await g_object.setSessionId().then(() => {
console.info("leave session"); console.info("leave session");
}).catch((error) => { }).catch((error) => {
console.info(TAG + error.code + error.message); console.info(TAG + error.code + error.message);
...@@ -494,14 +495,14 @@ describe('objectStoreTestV9', function () { ...@@ -494,14 +495,14 @@ describe('objectStoreTestV9', function () {
var g_object = distributedObject.create(context, {name: "Amy", age: 18, isVis: false}); var g_object = distributedObject.create(context, {name: "Amy", age: 18, isVis: false});
expect(g_object == undefined).assertEqual(false); expect(g_object == undefined).assertEqual(false);
g_object.setSessionId("mySession1").then(() => { await g_object.setSessionId("mySession1").then(() => {
console.info("join session"); console.info("join session");
}).catch((error) => { }).catch((error) => {
console.info(TAG + error.code + error.message); console.info(TAG + error.code + error.message);
}); });
expect("mySession1" == g_object.__sessionId).assertEqual(true); expect("mySession1" == g_object.__sessionId).assertEqual(true);
g_object.save("local").then((ret) => { await g_object.save("local").then((ret) => {
expect(ret.sessionId == "mySession1").assertEqual(true); expect(ret.sessionId == "mySession1").assertEqual(true);
expect(ret.version == g_object.__version).assertEqual(true); expect(ret.version == g_object.__version).assertEqual(true);
expect(ret.deviceId == "local").assertEqual(true); expect(ret.deviceId == "local").assertEqual(true);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册