Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
a55f350e
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
1 年多 前同步成功
通知
9
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
Xts Acts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
a55f350e
编写于
6月 26, 2023
作者:
O
openharmony_ci
提交者:
Gitee
6月 26, 2023
浏览文件
操作
浏览文件
下载
差异文件
!9023 【Distributeddatamgr】【Master】UDMF用例新增
Merge pull request !9023 from yanglifeng/master
上级
c9ebd504
318371fa
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
1916 addition
and
2 deletion
+1916
-2
distributeddatamgr/UDMFtest/UDMFtest/entry/src/main/ets/test/List.test.ets
...r/UDMFtest/UDMFtest/entry/src/main/ets/test/List.test.ets
+5
-2
distributeddatamgr/UDMFtest/UDMFtest/entry/src/main/ets/test/UDMF.test.ets
...r/UDMFtest/UDMFtest/entry/src/main/ets/test/UDMF.test.ets
+33
-0
distributeddatamgr/UDMFtest/UDMFtest/entry/src/main/ets/test/UDMFApiCallback.test.ets
...UDMFtest/entry/src/main/ets/test/UDMFApiCallback.test.ets
+959
-0
distributeddatamgr/UDMFtest/UDMFtest/entry/src/main/ets/test/UDMFApiPromise.test.ets
.../UDMFtest/entry/src/main/ets/test/UDMFApiPromise.test.ets
+919
-0
未找到文件。
distributeddatamgr/UDMFtest/UDMFtest/entry/src/main/ets/test/List.test.ets
浏览文件 @
a55f350e
...
@@ -13,8 +13,11 @@
...
@@ -13,8 +13,11 @@
* limitations under the License.
* limitations under the License.
*/
*/
import UDMFApiCallback from './UDMFApiCallback.test'
import UDMFApiTest from './UDMF.test.ets'
import UDMFApiPromise from './UDMFApiPromise.test'
import UDMFApiTest from './UDMF.test'
export default function testsuite() {
export default function testsuite() {
UDMFApiCallback()
UDMFApiPromise()
UDMFApiTest()
UDMFApiTest()
}
}
distributeddatamgr/UDMFtest/UDMFtest/entry/src/main/ets/test/UDMF.test.ets
浏览文件 @
a55f350e
...
@@ -78,6 +78,13 @@ export default function UDMFApiTest() {
...
@@ -78,6 +78,13 @@ export default function UDMFApiTest() {
};
};
video.videoUri = "videoUri";
video.videoUri = "videoUri";
let Audio = new UDMF.Audio();
Audio.details = {
title:"标题",
content:"内容"
};
Audio.audioUri = "audioUri";
let arrayBuf = new ArrayBuffer(2 * 3 * 4);
let arrayBuf = new ArrayBuffer(2 * 3 * 4);
let u8Array = new Uint8Array(arrayBuf);
let u8Array = new Uint8Array(arrayBuf);
...
@@ -125,6 +132,11 @@ export default function UDMFApiTest() {
...
@@ -125,6 +132,11 @@ export default function UDMFApiTest() {
applicationDefinedRecord.applicationDefinedType = 'applicationDefinedType';
applicationDefinedRecord.applicationDefinedType = 'applicationDefinedType';
applicationDefinedRecord.rawData = u8Array;
applicationDefinedRecord.rawData = u8Array;
let summary = new UDMF.Summary;
let records1 = summary.summary;
console.info("ttt " + records1);
let records2 = summary.totalSize;
/**
/**
* @tc.number SUB_DistributedData_Udmf_API001
* @tc.number SUB_DistributedData_Udmf_API001
* @tc.name CreateData
* @tc.name CreateData
...
@@ -473,5 +485,26 @@ export default function UDMFApiTest() {
...
@@ -473,5 +485,26 @@ export default function UDMFApiTest() {
console.info("SUB_DistributedData_Udmf_API014 end");
console.info("SUB_DistributedData_Udmf_API014 end");
done();
done();
})
})
/**
* @tc.number SUB_DistributedData_Udmf_API015
* @tc.name CreateData
* @tc.desc Test UDMF creating a unifieddata with a Audio record.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it('SUB_DistributedData_Udmf_API015',0, function (done) {
console.info('SUB_DistributedData_Udmf_API008 start');
let unifiedData = new UDMF.UnifiedData(Audio);
let records = unifiedData.getRecords();
let record = <UDMF.Audio>(records[0]);
expect(records.length).assertEqual(1);
expect(record.details.title).assertEqual('标题');
expect(record.details.content).assertEqual('内容');
console.info("SUB_DistributedData_Udmf_API008 end");
done();
})
})
})
}
}
\ No newline at end of file
distributeddatamgr/UDMFtest/UDMFtest/entry/src/main/ets/test/UDMFApiCallback.test.ets
0 → 100644
浏览文件 @
a55f350e
/*
* Copyright (C) 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* 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 UDMF from '@ohos.data.UDMF';
const TAG = '[ttt]'
export default function UDMFApiCallback() {
describe('UDMFApiCallback', function () {
beforeEach(async function () {
console.info(TAG + "beforeEach")
let options = {
intention: UDMF.Intention.DATA_HUB
};
await UDMF.deleteData(options).then((data) => {
let size = data.length;
console.info(TAG, ` [beforeEach] success to deleteData data.size = ${size}`);
}).catch((err) => {
console.info(TAG, ` [beforeEach] Failed to deleteData. code is ${err.code},message is ${err.message} `);
});
})
console.info(TAG + "*************Unit Test Begin*************")
/**
* @tc.number SUB_DDM_UDMF_InsertData_Callback_0100
* @tc.name UDMF insertData callback interface test
* @tc.desc UDMF insertData callback interface test.
*/
it('SUB_DDM_UDMF_InsertData_Callback_0100', 0, function (done) {
let Options = {}
let plainText = new UDMF.PlainText();
plainText.textContent = 'this is textContent';
let unifiedData = new UDMF.UnifiedData(plainText);
try {
UDMF.insertData(Options, unifiedData, function (err, data) {
if (err === undefined) {
console.info(TAG + `data = ${data}, options = ${Options}`);
expect(err === undefined).assertFail();
done();
} else {
console.error(TAG, `Failed, code is ${err.code},message is ${err.message} `);
expect(err !== null).assertFail();
done();
}
})
}
catch (error) {
console.error(TAG, `Failed to insertData0100 code is ${error.code},message is ${error.message} `);
expect(error.code).assertEqual('401');
done();
}
})
/**
* @tc.number SUB_DDM_UDMF_InsertData_Callback_0200
* @tc.name UDMF insertData callback interface test
* @tc.desc UDMF insertData callback interface test.
*/
it('SUB_DDM_UDMF_InsertData_Callback_0200', 0, function (done) {
let Options = {
intention: undefined
}
let plainText = new UDMF.PlainText();
plainText.textContent = 'this is textContent';
let unifiedData = new UDMF.UnifiedData(plainText);
try {
UDMF.insertData(Options, unifiedData, function (err, data) {
if (err === undefined) {
console.info(TAG + `data = ${data}, options = ${Options}`);
expect(err === undefined).assertFail();
done();
} else {
console.error(TAG, `Failed, code is ${err.code},message is ${err.message} `);
expect(err !== null).assertFail();
done();
}
})
}
catch (error) {
console.error(TAG, `Failed to insertData0200 code is ${error.code},message is ${error.message} `);
expect(error.code).assertEqual('401');
done();
}
})
/**
* @tc.number SUB_DDM_UDMF_InsertData_Callback_0300
* @tc.name UDMF insertData callback interface test
* @tc.desc UDMF insertData callback interface test.
*/
it('SUB_DDM_UDMF_InsertData_Callback_0300', 0, function (done) {
let Options = {
intention:null
}
let plainText = new UDMF.PlainText();
plainText.textContent = 'this is textContent';
let unifiedData = new UDMF.UnifiedData(plainText);
try {
UDMF.insertData(Options, unifiedData, function (err, data) {
if (err === undefined) {
console.info(TAG + `data = ${data}, options = ${Options}`);
expect(err === undefined).assertFail();
done();
} else {
console.error(TAG, `Failed, code is ${err.code},message is ${err.message} `);
expect(err !== null).assertFail();
done();
}
})
}
catch (error) {
console.error(TAG, `Failed to insertData0300 code is ${error.code},message is ${error.message} `);
expect(error.code).assertEqual('401');
done();
}
})
/**
* @tc.number SUB_DDM_UDMF_InsertData_Callback_0400
* @tc.name UDMF insertData callback interface test
* @tc.desc UDMF insertData callback interface test.
*/
it('SUB_DDM_UDMF_InsertData_Callback_0400', 0, function (done) {
let Options = {
intention: undefined,
key: undefined
}
let plainText = new UDMF.PlainText();
plainText.textContent = 'this is textContent';
let unifiedData = new UDMF.UnifiedData(plainText);
try {
UDMF.insertData(Options, unifiedData, function (err, data) {
if (err === undefined) {
console.info(TAG + `data = ${data}, options = ${Options}`);
expect(err === undefined).assertFail();
done();
} else {
console.error(TAG, `Failed, code is ${err.code},message is ${err.message} `);
expect(err !== null).assertFail();
done();
}
})
}
catch (error) {
console.error(TAG, `Failed to insertData0400 code is ${error.code},message is ${error.message} `);
expect(error.code).assertEqual('401');
done();
}
})
/**
* @tc.number SUB_DDM_UDMF_InsertData_Callback_0500
* @tc.name UDMF insertData callback interface test
* @tc.desc UDMF insertData callback interface test.
*/
it('SUB_DDM_UDMF_InsertData_Callback_0500', 0, function (done) {
let Options = {
key: null
}
let plainText = new UDMF.PlainText();
plainText.textContent = 'this is textContent';
let unifiedData = new UDMF.UnifiedData(plainText);
try {
UDMF.insertData(Options, unifiedData, function (err, data) {
if (err === undefined) {
console.info(TAG + `data = ${data}, options = ${Options}`);
expect(err === undefined).assertFail();
done();
} else {
console.error(TAG, `Failed, code is ${err.code},message is ${err.message} `);
expect(err !== null).assertFail();
done();
}
})
}
catch (error) {
console.error(TAG, `Failed to insertData0500 code is ${error.code},message is ${error.message} `);
expect(error.code).assertEqual('401');
done();
}
})
/**
* @tc.number SUB_DDM_UDMF_InsertData_Callback_0600
* @tc.name UDMF insertData callback interface test
* @tc.desc UDMF insertData callback interface test.
*/
it('SUB_DDM_UDMF_InsertData_Callback_0600', 0, function (done) {
let options = {
intention: UDMF.Intention.DATA_HUB
}
let plainText = new UDMF.PlainText();
plainText.textContent = "hello world!";
let unifiedData = new UDMF.UnifiedData(plainText);
try{
UDMF.insertData(options, unifiedData, function (err, data) {
if (err === undefined) {
console.info(TAG + `data = ${data}, options = ${options}`);
expect(err === undefined).assertTrue()
done();
} else {
console.error(TAG, `Failed to insertData0600 code is ${err.code},message is ${err.message} `);
expect(err !== null).assertFail();
done();
}
});
}catch(error){
console.error(TAG, `Failed, code is ${error.code},message is ${error.message} `);
expect(error !== null).assertFail();
}
})
/**
* @tc.number SUB_DDM_UDMF_UpdateData_Callback_0100
* @tc.name UDMF updateData callback interface test
* @tc.desc UDMF updateData callback interface test.
*/
it('SUB_DDM_UDMF_UpdateData_Callback_0100', 0, function (done) {
let options = {
intention: UDMF.Intention.DATA_HUB
}
let plainText = new UDMF.PlainText();
plainText.textContent = "hello world!";
let unifiedData = new UDMF.UnifiedData(plainText);
try{
UDMF.insertData(options, unifiedData, function (e, data) {
if (e !== undefined) {
console.info(TAG, ` Failed to insertData. code is ${e.code},message is ${e.message} `);
return;
}
console.info(TAG + `insertData0100 success; data = ${data}, options = ${options}`);
UDMF.updateData({key: data}, unifiedData, function (err, ret) {
if (err === undefined) {
console.info(TAG + `updateData success; data = ${ret}, options = ${options}`);
expect(err === undefined).assertTrue()
done();
} else {
console.info(`UpdateData failed. code is ${err.code},message is ${err.message} `);
expect(err !== null).assertFail();
done();
}
});
});
}catch(error){
console.error(TAG, `Failed, code is ${error.code},message is ${error.message} `);
expect(error !== null).assertFail();
done();
}
})
/**
* @tc.number SUB_DDM_UDMF_UpdateData_Callback_0200
* @tc.name UDMF insertData callback interface test
* @tc.desc UDMF insertData callback interface test.
*/
it('SUB_DDM_UDMF_UpdateData_Callback_0200', 0, function (done) {
let options = {
intention: UDMF.Intention.DATA_HUB
}
let plainText = new UDMF.PlainText();
plainText.textContent = "hello world!";
let unifiedData = new UDMF.UnifiedData(plainText);
try {
UDMF.insertData(options, unifiedData, function (e, data) {
if (e !== undefined) {
console.info(TAG, ` Failed to insertData. code is ${e.code},message is ${e.message} `);
return;
}
console.info(TAG + `insertData0200 success; data = ${data}, options = ${options}`);
try{
UDMF.updateData({key: undefined}, unifiedData, function (err, ret) {
if (err === undefined) {
console.info(TAG + `updateData success; data = ${ret}, options = ${options}`);
expect(err !== null).assertFail()
done();
} else {
console.error(TAG, `Failed, code is ${err.code},message is ${err.message} `);
expect(err !== null).assertFail();
done();
}
});
}catch(errInfo){
console.info(`UpdateData failed. code is ${errInfo.code},message is ${errInfo.message} `);
expect(errInfo.code).assertEqual('401');
done();
}
});
} catch (error) {
console.info(`UpdateData1 failed. code is ${error.code},message is ${error.message} `);
expect(error !== null).assertFail();
done();
}
})
/**
* @tc.number SUB_DDM_UDMF_UpdateData_Callback_0300
* @tc.name UDMF insertData callback interface test
* @tc.desc UDMF insertData callback interface test.
*/
it('SUB_DDM_UDMF_UpdateData_Callback_0300', 0, function (done) {
let options = {
intention: UDMF.Intention.DATA_HUB
}
let plainText = new UDMF.PlainText();
plainText.textContent = "hello world!";
let unifiedData = new UDMF.UnifiedData(plainText);
try {
UDMF.insertData(options, unifiedData, function (e, data) {
if (e !== undefined) {
console.info(TAG, ` Failed to insertData. code is ${e.code},message is ${e.message} `);
return;
}
console.info(TAG + `insertData0300 success; data = ${data}, options = ${options}`);
try{
UDMF.updateData({key: null}, unifiedData, function (err, ret) {
if (err === undefined) {
console.info(TAG + `updateData success; data = ${ret}, options = ${options}`);
expect(err !== null).assertFail()
done();
} else {
console.info(`UpdateData failed. code is ${err.code},message is ${err.message} `);
expect(err !== null).assertFail()
done();
}
});
}catch(errInfo){
console.info(`UpdateData failed. code is ${errInfo.code},message is ${errInfo.message} `);
expect(errInfo.code).assertEqual('401');
done();
}
});
} catch (error) {
console.error(TAG, `Failed, code is ${error.code},message is ${error.message} `);
expect(error !== null).assertFail();
done();
}
})
/**
* @tc.number SUB_DDM_UDMF_UpdateData_Callback_0400
* @tc.name UDMF insertData callback interface test
* @tc.desc UDMF insertData callback interface test.
*/
it('SUB_DDM_UDMF_UpdateData_Callback_0400', 0, function (done) {
let options = {
intention: UDMF.Intention.DATA_HUB,
key: undefined
}
let plainText = new UDMF.PlainText();
plainText.textContent = "hello world!";
let unifiedData = new UDMF.UnifiedData(plainText);
try{
UDMF.insertData(options, unifiedData, function (e, data) {
if (e !== undefined) {
console.info(TAG, ` Failed to insertData. code is ${e.code},message is ${e.message} `);
return;
}
console.info(TAG + `insertData0500 success; data = ${data}, options = ${options}`);
UDMF.updateData({key: data}, unifiedData, function (err, ret) {
if (err === undefined) {
console.info(TAG + `updateData success; data = ${ret}, options = ${options}`);
expect(err === undefined).assertTrue()
done();
} else {
console.info(`UpdateData failed. code is ${err.code},message is ${err.message} `);
expect(err !== null).assertFail();
done();
}
});
});
}catch(error){
console.error(TAG, `Failed, code is ${error.code},message is ${error.message} `);
expect(error !== null).assertFail();
done();
}
})
/**
* @tc.number SUB_DDM_UDMF_QueryData_Callback_0100
* @tc.name UDMF queryData callback interface test
* @tc.desc UDMF queryData callback interface test.
*/
it('SUB_DDM_UDMF_QueryData_Callback_0100', 0, function (done) {
let options = {
intention: UDMF.Intention.DATA_HUB
};
let plainText = new UDMF.PlainText();
plainText.textContent = "hello world!";
let unifiedData = new UDMF.UnifiedData(plainText);
try {
UDMF.insertData(options, unifiedData, function (e, data) {
if (e !== undefined) {
console.info(`Failed to insertData. code is ${e.code},message is ${e.message} `);
return;
}
console.info(TAG + `insertData0100 success; data = ${data}, options = ${options}`);
UDMF.queryData(options, function (err, ret) {
if (err === undefined) {
let size = ret.length;
console.info(TAG, ` data.size = ${size}`);
for (var i = 0; i < size; i++) {
let records = ret[i].getRecords();
let size = records.length;
for (var j = 0; j < size; j++) {
if (records[j].getType() == UDMF.UnifiedDataType.PLAIN_TEXT) {
let text = <UDMF.PlainText> (records[j]);
console.info(TAG, ` queryData.result = ${i + 1}.${text.textContent}`);
}
}
}
expect(size).assertEqual(1);
done();
} else {
console.info(`Failed to queryData. code is ${err.code},message is ${err.message} `);
expect(err !== null).assertFail();
done();
}
});
});
} catch (error) {
console.error(TAG, `Failed, code is ${error.code},message is ${error.message} `);
expect(error !== null).assertFail();
done();
}
})
/**
* @tc.number SUB_DDM_UDMF_QueryData_Callback_0200
* @tc.name UDMF queryData callback interface test
* @tc.desc UDMF queryData callback interface test.
*/
it('SUB_DDM_UDMF_QueryData_Callback_0200', 0, function (done) {
let options = {
intention: UDMF.Intention.DATA_HUB
};
let plainText = new UDMF.PlainText();
plainText.textContent = "hello world!";
let unifiedData = new UDMF.UnifiedData(plainText);
try {
UDMF.insertData(options, unifiedData, function (e, data) {
if (e !== undefined) {
console.info(`Failed to insertData. code is ${e.code},message is ${e.message} `);
return;
}
console.info(TAG + `insertData0100 success; data = ${data}, options = ${options}`);
UDMF.queryData({key: data}, function (err, ret) {
if (err === undefined) {
let size = ret.length;
console.info(TAG, ` data.size = ${size}`);
for (var i = 0; i < size; i++) {
let records = ret[i].getRecords();
let size = records.length;
for (var j = 0; j < size; j++) {
if (records[j].getType() == UDMF.UnifiedDataType.PLAIN_TEXT) {
let text = <UDMF.PlainText> (records[j]);
console.info(TAG, ` queryData.result = ${i + 1}.${text.textContent}`);
}
}
}
expect(size).assertEqual(1);
done();
} else {
console.info(`Failed to queryData. code is ${err.code},message is ${err.message} `);
expect(err !== null).assertFail();
done();
}
});
});
} catch (error) {
console.error(TAG, `Failed, code is ${error.code},message is ${error.message} `);
expect(error !== null).assertFail();
done();
}
})
/**
* @tc.number SUB_DDM_UDMF_QueryData_Callback_0300
* @tc.name UDMF queryData callback interface test
* @tc.desc UDMF queryData callback interface test.
*/
it('SUB_DDM_UDMF_QueryData_Callback_0300', 0, function (done) {
let options1 = {
intention: UDMF.Intention.DATA_HUB
};
let plainText = new UDMF.PlainText();
plainText.textContent = "hello world!";
let unifiedData = new UDMF.UnifiedData(plainText);
try {
UDMF.insertData(options1, unifiedData, function (e, data) {
if (e !== undefined) {
console.info(`Failed to insertData. code is ${e.code},message is ${e.message} `);
return;
}
console.info(TAG + `insertData0100 success; data = ${data}, options = ${options1}`);
let options2 = {
intention: UDMF.Intention.DATA_HUB,
key: data
};
UDMF.queryData(options2, function (err, ret) {
if (err === undefined) {
let size = ret.length;
console.info(TAG, ` data.size = ${size}`);
for (var i = 0; i < size; i++) {
let records = ret[i].getRecords();
let size = records.length;
for (var j = 0; j < size; j++) {
if (records[j].getType() == UDMF.UnifiedDataType.PLAIN_TEXT) {
let text = <UDMF.PlainText> (records[j]);
console.info(TAG, ` queryData.result = ${i + 1}.${text.textContent}`);
}
}
}
expect(size).assertEqual(1);
done();
} else {
console.info(`Failed to queryData. code is ${err.code},message is ${err.message} `);
expect(err !== null).assertFail();
done();
}
});
});
} catch (error) {
console.error(TAG, `Failed, code is ${error.code},message is ${error.message} `);
expect(error !== null).assertFail();
done();
}
})
/**
* @tc.number SUB_DDM_UDMF_QueryData_Callback_0400
* @tc.name UDMF queryData callback interface test
* @tc.desc UDMF queryData callback interface test.
*/
it('SUB_DDM_UDMF_QueryData_Callback_0400', 0, function (done) {
let options1 = {
intention: UDMF.Intention.DATA_HUB
};
let plainText = new UDMF.PlainText();
plainText.textContent = "hello world!";
let unifiedData = new UDMF.UnifiedData(plainText);
try {
UDMF.insertData(options1, unifiedData, function (e, data) {
if (e !== undefined) {
console.info(`Failed to insertData. code is ${e.code},message is ${e.message} `);
return;
}
console.info(TAG + `insertData0400 success; data = ${data}, options = ${options1}`);
let options2 = {
intention: UDMF.Intention.DATA_HUB,
key: 'data'
};
try{
UDMF.queryData(options2, function (err, ret) {
if (err === undefined) {
let size = ret.length;
console.info(TAG, ` data.size = ${size}`);
for (var i = 0; i < size; i++) {
let records = ret[i].getRecords();
let size = records.length;
for (var j = 0; j < size; j++) {
if (records[j].getType() == UDMF.UnifiedDataType.PLAIN_TEXT) {
let text = <UDMF.PlainText> (records[j]);
console.info(TAG, ` queryData.result = ${i + 1}.${text.textContent}`);
}
}
}
expect(err === undefined).assertFail();
done();
} else {
console.info(`Failed to queryData code is ${err.code},message is ${err.message} `);
expect(err.code === 401).assertFail();
done();
}
});
}catch(errorInfo){
console.info(`Failed to queryData. code is ${errorInfo.code},message is ${errorInfo.message} `);
expect(errorInfo.code).assertEqual('401');
done();
}
});
} catch (error) {
console.error(TAG, `Failed, code is ${error.code},message is ${error.message} `);
expect(error !== null).assertFail();
done();
}
})
/**
* @tc.number SUB_DDM_UDMF_QueryData_Callback_0500
* @tc.name UDMF queryData callback interface test
* @tc.desc UDMF queryData callback interface test.
*/
it('SUB_DDM_UDMF_QueryData_Callback_0500', 0, function (done) {
let options1 = {
intention: UDMF.Intention.DATA_HUB
};
let plainText = new UDMF.PlainText();
plainText.textContent = "hello world!";
let unifiedData = new UDMF.UnifiedData(plainText);
try {
UDMF.insertData(options1, unifiedData, function (e, data) {
if (e !== undefined) {
console.info(`Failed to insertData. code is ${e.code},message is ${e.message} `);
return;
}
console.info(TAG + `insertData0500 success; data = ${data}, options = ${options1}`);
let options2 = {
intention: UDMF.Intention.DATA_HUB,
key: undefined
};
UDMF.queryData(options2, function (err, ret) {
if (err === undefined) {
let size = ret.length;
console.info(TAG, ` data.size = ${size}`);
for (var i = 0; i < size; i++) {
let records = ret[i].getRecords();
let size = records.length;
for (var j = 0; j < size; j++) {
if (records[j].getType() == UDMF.UnifiedDataType.PLAIN_TEXT) {
let text = <UDMF.PlainText> (records[j]);
console.info(TAG, ` queryData.result = ${i + 1}.${text.textContent}`);
}
}
}
expect(size).assertEqual(1);
done();
} else {
console.info(`Failed to queryData. code is ${err.code},message is ${err.message} `);
expect(err.code).assertEqual('401');
done();
}
});
});
} catch (error) {
console.error(TAG, `Failed, code is ${error.code},message is ${error.message} `);
expect(error !== null).assertFail();
done();
}
})
/**
* @tc.number SUB_DDM_UDMF_DeleteData_Callback_0100
* @tc.name UDMF deleteData callback interface test
* @tc.desc UDMF deleteData callback interface test.
*/
it('SUB_DDM_UDMF_DeleteData_Callback_0100', 0, function (done) {
let options = {
intention: UDMF.Intention.DATA_HUB
};
let plainText = new UDMF.PlainText();
plainText.textContent = "hello world!";
let unifiedData = new UDMF.UnifiedData(plainText);
try {
UDMF.insertData(options, unifiedData, function (e, data) {
if (e !== undefined) {
console.info(`Failed to insertData. code is ${e.code},message is ${e.message} `);
return;
}
console.info(TAG + `insertData0100 success; data = ${data}, options = ${options}`);
UDMF.queryData(options, function (errInfo, ret) {
if (errInfo !== undefined) {
console.info(`Failed to queryData. code is ${errInfo.code},message is ${errInfo.message} `);
return;
}
console.info(TAG, ` queryData size = ${ret.length}`);
UDMF.deleteData(options, function (err, row) {
if (err == undefined) {
let size = row.length;
console.info(TAG, ` deleteData size = ${size}`);
for (var i = 0; i < size; i++) {
let records = row[i].getRecords();
let size = records.length;
for (var j = 0; j < size; j++) {
if (records[j].getType() == UDMF.UnifiedDataType.PLAIN_TEXT) {
let text = <UDMF.PlainText> (records[j]);
console.info(TAG, ` deleteData.result = ${i + 1}.${text.textContent}`);
}
}
}
expect(size).assertEqual(1);
done();
} else {
console.info(`Failed to deleteData. code is ${err.code},message is ${err.message} `);
expect(err !== null).assertFail();
done();
}
});
});
});
} catch (error) {
console.error(TAG, `Failed, code is ${error.code},message is ${error.message} `);
expect(error !== null).assertFail();
done();
}
})
/**
* @tc.number SUB_DDM_UDMF_DeleteData_Callback_0200
* @tc.name UDMF deleteData callback interface test
* @tc.desc UDMF deleteData callback interface test.
*/
it('SUB_DDM_UDMF_DeleteData_Callback_0200', 0, function (done) {
let options = {
intention: UDMF.Intention.DATA_HUB
};
let plainText = new UDMF.PlainText();
plainText.textContent = "hello world!";
let unifiedData = new UDMF.UnifiedData(plainText);
try {
UDMF.insertData(options, unifiedData, function (e, data) {
if (e !== undefined) {
console.info(`Failed to insertData. code is ${e.code},message is ${e.message} `);
return;
}
console.info(TAG + `insertData0200 success; data = ${data}, options = ${options}`);
UDMF.queryData(options, function (errInfo, ret) {
if (errInfo !== undefined) {
console.info(`Failed to queryData. code is ${errInfo.code},message is ${errInfo.message} `);
return;
}
console.info(TAG, ` queryData size = ${ret.length}`);
UDMF.deleteData({key: data}, function (err, row) {
if (err == undefined) {
let size = row.length;
console.info(TAG, ` deleteData size = ${size}`);
for (var i = 0; i < size; i++) {
let records = row[i].getRecords();
let size = records.length;
for (var j = 0; j < size; j++) {
if (records[j].getType() == UDMF.UnifiedDataType.PLAIN_TEXT) {
let text = <UDMF.PlainText> (records[j]);
console.info(TAG, ` deleteData.result = ${i + 1}.${text.textContent}`);
}
}
}
expect(size).assertEqual(1);
done();
} else {
console.info(`Failed to deleteData. code is ${err.code},message is ${err.message} `);
expect(err !== null).assertFail();
done();
}
});
});
});
} catch (error) {
console.error(TAG, `Failed, code is ${error.code},message is ${error.message} `);
expect(error !== null).assertFail();
done();
}
})
/**
* @tc.number SUB_DDM_UDMF_DeleteData_Callback_0300
* @tc.name UDMF deleteData callback interface test
* @tc.desc UDMF deleteData callback interface test.
*/
it('SUB_DDM_UDMF_DeleteData_Callback_0300', 0, function (done) {
let options1 = {
intention: UDMF.Intention.DATA_HUB
};
let plainText = new UDMF.PlainText();
plainText.textContent = "hello world!";
let unifiedData = new UDMF.UnifiedData(plainText);
try {
UDMF.insertData(options1, unifiedData, function (e, data) {
if (e !== undefined) {
console.info(`Failed to insertData. code is ${e.code},message is ${e.message} `);
return;
}
console.info(TAG + `insertData0100 success; data = ${data}, options = ${options1}`);
UDMF.queryData(options1, function (errInfo, ret) {
if (errInfo !== undefined) {
console.info(`Failed to queryData. code is ${errInfo.code},message is ${errInfo.message} `);
return;
}
console.info(TAG, ` queryData size = ${ret.length}`);
let options2 = {
intention: UDMF.Intention.DATA_HUB,
key: data
};
UDMF.deleteData(options2, function (err, row) {
if (err == undefined) {
let size = row.length;
console.info(TAG, ` deleteData size = ${size}`);
for (var i = 0; i < size; i++) {
let records = row[i].getRecords();
let size = records.length;
for (var j = 0; j < size; j++) {
if (records[j].getType() == UDMF.UnifiedDataType.PLAIN_TEXT) {
let text = <UDMF.PlainText> (records[j]);
console.info(TAG, ` deleteData.result = ${i + 1}.${text.textContent}`);
}
}
}
expect(size).assertEqual(1);
done();
} else {
console.info(`Failed to deleteData. code is ${err.code},message is ${err.message} `);
expect(err !== null).assertFail();
done();
}
});
});
});
} catch (error) {
console.error(TAG, `Failed, code is ${error.code},message is ${error.message} `);
expect(error !== null).assertFail();
done();
}
})
/**
* @tc.number SUB_DDM_UDMF_DeleteData_Callback_0400
* @tc.name UDMF deleteData callback interface test
* @tc.desc UDMF deleteData callback interface test.
*/
it('SUB_DDM_UDMF_DeleteData_Callback_0400', 0, function (done) {
let options1 = {
intention: UDMF.Intention.DATA_HUB
};
let plainText = new UDMF.PlainText();
plainText.textContent = "hello world!";
let unifiedData = new UDMF.UnifiedData(plainText);
try {
UDMF.insertData(options1, unifiedData, function (e, data) {
if (e !== undefined) {
console.info(`Failed to insertData. code is ${e.code},message is ${e.message} `);
return;
}
console.info(TAG + `insertData0100 success; data = ${data}, options = ${options1}`);
UDMF.queryData(options1, function (errInfo, ret) {
if (errInfo !== undefined) {
console.info(`Failed to queryData. code is ${errInfo.code},message is ${errInfo.message} `);
return;
}
console.info(TAG, ` queryData size = ${ret.length}`);
let options2 = {
intention: UDMF.Intention.DATA_HUB,
key: 'data'
};
try{
UDMF.deleteData(options2, function (err, row) {
if (err == undefined) {
let size = row.length;
console.info(TAG, ` deleteData size = ${size}`);
for (var i = 0; i < size; i++) {
let records = row[i].getRecords();
let size = records.length;
for (var j = 0; j < size; j++) {
if (records[j].getType() == UDMF.UnifiedDataType.PLAIN_TEXT) {
let text = <UDMF.PlainText> (records[j]);
console.info(TAG, ` deleteData.result = ${i + 1}.${text.textContent}`);
}
}
}
expect(err !== null).assertFail();
done();
} else {
console.info(`Failed to deleteData. code is ${err.code},message is ${err.message} `);
expect(err.code === 401).assertFail();
done();
}
});
}catch(error){
console.info(`Failed to deleteData. code is ${error.code},message is ${error.message} `);
expect(error.code).assertEqual('401');
done();
}
});
});
} catch (error) {
console.error(TAG, `Failed, code is ${error.code},message is ${error.message} `);
expect(error !== null).assertFail();
done();
}
})
/**
* @tc.number SUB_DDM_UDMF_DeleteData_Callback_0500
* @tc.name UDMF deleteData callback interface test
* @tc.desc UDMF deleteData callback interface test.
*/
it('SUB_DDM_UDMF_DeleteData_Callback_0300', 0, function (done) {
let options1 = {
intention: UDMF.Intention.DATA_HUB
};
let plainText = new UDMF.PlainText();
plainText.textContent = "hello world!";
let unifiedData = new UDMF.UnifiedData(plainText);
try {
UDMF.insertData(options1, unifiedData, function (e, data) {
if (e !== undefined) {
console.info(`Failed to insertData. code is ${e.code},message is ${e.message} `);
return;
}
console.info(TAG + `insertData0100 success; data = ${data}, options = ${options1}`);
UDMF.queryData(options1, function (errInfo, ret) {
if (errInfo !== undefined) {
console.info(`Failed to queryData. code is ${errInfo.code},message is ${errInfo.message} `);
return;
}
console.info(TAG, ` queryData size = ${ret.length}`);
let options2 = {
intention: UDMF.Intention.DATA_HUB,
key: undefined
};
UDMF.deleteData(options2, function (err, row) {
if (err == undefined) {
let size = row.length;
console.info(TAG, ` deleteData size = ${size}`);
for (var i = 0; i < size; i++) {
let records = row[i].getRecords();
let size = records.length;
for (var j = 0; j < size; j++) {
if (records[j].getType() == UDMF.UnifiedDataType.PLAIN_TEXT) {
let text = <UDMF.PlainText> (records[j]);
console.info(TAG, ` deleteData.result = ${i + 1}.${text.textContent}`);
}
}
}
expect(size).assertEqual(1);
done();
} else {
console.info(`Failed to deleteData. code is ${err.code},message is ${err.message} `);
expect(err !== null).assertFail();
done();
}
});
});
});
} catch (error) {
console.error(TAG, `Failed, code is ${error.code},message is ${error.message} `);
expect(error !== null).assertFail();
done();
}
})
console.info(TAG + "*************Unit Test End*************")
})
}
\ No newline at end of file
distributeddatamgr/UDMFtest/UDMFtest/entry/src/main/ets/test/UDMFApiPromise.test.ets
0 → 100644
浏览文件 @
a55f350e
/*
* Copyright (C) 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* 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 UDMF from '@ohos.data.UDMF';
const TAG = '[ttt]'
export default function UDMFApiPromise() {
describe('UDMFApiPromise', function () {
beforeEach(async function () {
console.info(TAG + "beforeEach")
let options = {
intention: UDMF.Intention.DATA_HUB
};
await UDMF.deleteData(options).then((data) => {
let size = data.length;
console.info(TAG, ` [beforeEach] success to deleteData data.size = ${size}`);
}).catch((err) => {
console.info(TAG, ` [beforeEach] Failed to deleteData. code is ${err.code},message is ${err.message} `);
});
})
console.info(TAG + "*************Unit Test Begin*************")
/**
* @tc.number SUB_DDM_UDMF_InsertData_Promise_0100
* @tc.name UDMF insertData promise interface test
* @tc.desc UDMF insertData promise interface test.
*/
it('SUB_DDM_UDMF_InsertData_Promise_0100', 0, function (done) {
let Options = {}
let plainText = new UDMF.PlainText();
plainText.textContent = 'this is textContent';
let unifiedData = new UDMF.UnifiedData(plainText);
try {
UDMF.insertData(Options, unifiedData).then((data) => {
console.info(TAG + `data = ${data}, options = ${Options}`);
expect().assertFail();
done();
}).catch((err) => {
console.error(TAG, `Failed, code is ${err.code},message is ${err.message} `);
expect(err !== null).assertFail();
done();
})
}
catch (error) {
console.error(TAG, `Failed to insertData0100 code is ${error.code},message is ${error.message} `);
expect(error.code).assertEqual('401');
done();
}
})
/**
* @tc.number SUB_DDM_UDMF_InsertData_Promise_0200
* @tc.name UDMF insertData promise interface test
* @tc.desc UDMF insertData promise interface test.
*/
it('SUB_DDM_UDMF_InsertData_Promise_0200', 0, function (done) {
let Options = {
intention: undefined
}
let plainText = new UDMF.PlainText();
plainText.textContent = 'this is textContent';
let unifiedData = new UDMF.UnifiedData(plainText);
try {
UDMF.insertData(Options, unifiedData).then((data) => {
console.info(TAG + `data = ${data}, options = ${Options}`);
expect().assertFail();
done();
}).catch((err) => {
console.error(TAG, `Failed, code is ${err.code},message is ${err.message} `);
expect(err !== null).assertFail();
done();
})
}
catch (error) {
console.error(TAG, `Failed to insertData0200 code is ${error.code},message is ${error.message} `);
expect(error.code).assertEqual('401');
done();
}
})
/**
* @tc.number SUB_DDM_UDMF_InsertData_Promise_0300
* @tc.name UDMF insertData promise interface test
* @tc.desc UDMF insertData promise interface test.
*/
it('SUB_DDM_UDMF_InsertData_Promise_0300', 0, function (done) {
let Options = {
intention:null
}
let plainText = new UDMF.PlainText();
plainText.textContent = 'this is textContent';
let unifiedData = new UDMF.UnifiedData(plainText);
try {
UDMF.insertData(Options, unifiedData).then((data) => {
console.info(TAG + `data = ${data}, options = ${Options}`);
expect().assertFail();
done();
}).catch((err) => {
console.error(TAG, `Failed, code is ${err.code},message is ${err.message} `);
expect(err !== null).assertFail();
done();
})
}
catch (error) {
console.error(TAG, `Failed to insertData0300 code is ${error.code},message is ${error.message} `);
expect(error.code).assertEqual('401');
done();
}
})
/**
* @tc.number SUB_DDM_UDMF_InsertData_Promise_0400
* @tc.name UDMF insertData promise interface test
* @tc.desc UDMF insertData promise interface test.
*/
it('SUB_DDM_UDMF_InsertData_Promise_0400', 0, function (done) {
let Options = {
intention: undefined,
key: undefined
}
let plainText = new UDMF.PlainText();
plainText.textContent = 'this is textContent';
let unifiedData = new UDMF.UnifiedData(plainText);
try {
UDMF.insertData(Options, unifiedData).then((data) => {
console.info(TAG + `data = ${data}, options = ${Options}`);
expect().assertFail();
done();
}).catch((err) => {
console.error(TAG, `Failed, code is ${err.code},message is ${err.message} `);
expect(err !== null).assertFail();
done();
})
}
catch (error) {
console.error(TAG, `Failed to insertData0400 code is ${error.code},message is ${error.message} `);
expect(error.code).assertEqual('401');
done();
}
})
/**
* @tc.number SUB_DDM_UDMF_InsertData_Promise_0500
* @tc.name UDMF insertData promise interface test
* @tc.desc UDMF insertData promise interface test.
*/
it('SUB_DDM_UDMF_InsertData_Promise_0500', 0, function (done) {
let Options = {
key: null
}
let plainText = new UDMF.PlainText();
plainText.textContent = 'this is textContent';
let unifiedData = new UDMF.UnifiedData(plainText);
try {
UDMF.insertData(Options, unifiedData).then((data) => {
console.info(TAG + `data = ${data}, options = ${Options}`);
expect().assertFail();
done();
}).catch((err) => {
console.error(TAG, `Failed, code is ${err.code},message is ${err.message} `);
expect(err !== null).assertFail();
done();
})
}
catch (error) {
console.error(TAG, `Failed to insertData0500 code is ${error.code},message is ${error.message} `);
expect(error.code).assertEqual('401');
done();
}
})
/**
* @tc.number SUB_DDM_UDMF_InsertData_Promise_0600
* @tc.name UDMF insertData promise interface test
* @tc.desc UDMF insertData promise interface test.
*/
it('SUB_DDM_UDMF_InsertData_Promise_0600', 0, function (done) {
let options = {
intention: UDMF.Intention.DATA_HUB
}
let plainText = new UDMF.PlainText();
plainText.textContent = "hello world!";
let unifiedData = new UDMF.UnifiedData(plainText);
try{
UDMF.insertData(options, unifiedData).then((data) => {
console.info(TAG + `data = ${data}, options = ${options}`);
expect(data !== null).assertTrue();
done()
}).catch((err) => {
console.error(TAG, `Failed to insertData0600 code is ${err.code},message is ${err.message} `);
expect(err !== null).assertFail();
done();
});
}catch(error){
console.error(TAG, `Failed, code is ${error.code},message is ${error.message} `);
expect(error !== null).assertFail();
}
})
/**
* @tc.number SUB_DDM_UDMF_UpdateData_Promise_0100
* @tc.name UDMF updateData promise interface test
* @tc.desc UDMF updateData promise interface test.
*/
it('SUB_DDM_UDMF_UpdateData_Promise_0100', 0, function (done) {
let options = {
intention: UDMF.Intention.DATA_HUB
}
let plainText = new UDMF.PlainText();
plainText.textContent = "hello world!";
let unifiedData = new UDMF.UnifiedData(plainText);
try{
UDMF.insertData(options, unifiedData, function (e, data) {
if (e !== undefined) {
console.info(TAG, ` Failed to insertData. code is ${e.code},message is ${e.message} `);
return;
}
console.info(TAG + `insertData0100 success; data = ${data}, options = ${options}`);
UDMF.updateData({key: data}, unifiedData).then((ret) => {
console.info(TAG + `updateData success; data = ${ret}, options = ${options}`);
expect(ret !== null).assertTrue();
done();
}).catch((err) => {
console.info(`UpdateData failed. code is ${err.code},message is ${err.message} `);
expect(err !== null).assertFail();
done();
});
});
}catch(error){
console.error(TAG, `Failed, code is ${error.code},message is ${error.message} `);
expect(error !== null).assertFail();
done();
}
})
/**
* @tc.number SUB_DDM_UDMF_UpdateData_Promise_0200
* @tc.name UDMF insertData promise interface test
* @tc.desc UDMF insertData promise interface test.
*/
it('SUB_DDM_UDMF_UpdateData_Promise_0200', 0, function (done) {
let options = {
intention: UDMF.Intention.DATA_HUB
}
let plainText = new UDMF.PlainText();
plainText.textContent = "hello world!";
let unifiedData = new UDMF.UnifiedData(plainText);
try {
UDMF.insertData(options, unifiedData, function (e, data) {
if (e !== undefined) {
console.info(TAG, ` Failed to insertData. code is ${e.code},message is ${e.message} `);
return;
}
console.info(TAG + `insertData0200 success; data = ${data}, options = ${options}`);
try{
UDMF.updateData({key: undefined}, unifiedData).then((ret) => {
console.info(TAG + `updateData success; data = ${ret}, options = ${options}`);
expect().assertFail()
done();
}).catch((err) => {
console.info(`UpdateData1111 failed. code is ${err.code},message is ${err.message} `);
expect(err !== null).assertFail();
done();
});
}catch(errInfo){
console.info(`UpdateData2222 failed. code is ${errInfo.code},message is ${errInfo.message} `);
expect(errInfo.code).assertEqual('401');
done();
}
});
} catch (error) {
console.error(TAG, `Failed, code is ${error.code},message is ${error.message} `);
expect(error !== null).assertFail();
done();
}
})
/**
* @tc.number SUB_DDM_UDMF_UpdateData_Promise_0300
* @tc.name UDMF insertData promise interface test
* @tc.desc UDMF insertData promise interface test.
*/
it('SUB_DDM_UDMF_UpdateData_Promise_0300', 0, function (done) {
let options = {
intention: UDMF.Intention.DATA_HUB
}
let plainText = new UDMF.PlainText();
plainText.textContent = "hello world!";
let unifiedData = new UDMF.UnifiedData(plainText);
try {
UDMF.insertData(options, unifiedData, function (e, data) {
if (e !== undefined) {
console.info(TAG, ` Failed to insertData. code is ${e.code},message is ${e.message} `);
return;
}
console.info(TAG + `insertData0300 success; data = ${data}, options = ${options}`);
try{
UDMF.updateData({key: null}, unifiedData).then((ret) => {
console.info(TAG + `updateData success; data = ${ret}, options = ${options}`);
expect().assertFail()
done();
}).catch((err) => {
console.info(`UpdateData failed. code is ${err.code},message is ${err.message} `);
expect(err !== null).assertFail();
done();
});
}catch(errInfo){
console.info(`UpdateData failed. code is ${errInfo.code},message is ${errInfo.message} `);
expect(errInfo.code).assertEqual('401');
done();
}
});
} catch (error) {
console.error(TAG, `Failed, code is ${error.code},message is ${error.message} `);
expect(error !== null).assertFail();
done();
}
})
/**
* @tc.number SUB_DDM_UDMF_UpdateData_Promise_0400
* @tc.name UDMF insertData promise interface test
* @tc.desc UDMF insertData promise interface test.
*/
it('SUB_DDM_UDMF_UpdateData_Promise_0400', 0, function (done) {
let options = {
intention: UDMF.Intention.DATA_HUB,
key: undefined
}
let plainText = new UDMF.PlainText();
plainText.textContent = "hello world!";
let unifiedData = new UDMF.UnifiedData(plainText);
try{
UDMF.insertData(options, unifiedData, function (e, data) {
if (e !== undefined) {
console.info(TAG, ` Failed to insertData. code is ${e.code},message is ${e.message} `);
return;
}
console.info(TAG + `insertData0100 success; data = ${data}, options = ${options}`);
UDMF.updateData({key: data}, unifiedData).then((ret) => {
console.info(TAG + `updateData success; data = ${ret}, options = ${options}`);
expect(ret !== null).assertTrue();
done();
}).catch((err) => {
console.info(`UpdateData failed. code is ${err.code},message is ${err.message} `);
expect(err !== null).assertFail();
done();
});
});
}catch(error){
console.error(TAG, `Failed, code is ${error.code},message is ${error.message} `);
expect(error !== null).assertFail();
done();
}
})
/**
* @tc.number SUB_DDM_UDMF_QueryData_Promise_0100
* @tc.name UDMF queryData promise interface test
* @tc.desc UDMF queryData promise interface test.
*/
it('SUB_DDM_UDMF_QueryData_Promise_0100', 0, function (done) {
let options = {
intention: UDMF.Intention.DATA_HUB
};
let plainText = new UDMF.PlainText();
plainText.textContent = "hello world!";
let unifiedData = new UDMF.UnifiedData(plainText);
try {
UDMF.insertData(options, unifiedData, function (e, data) {
if (e !== undefined) {
console.info(`Failed to insertData. code is ${e.code},message is ${e.message} `);
return;
}
console.info(TAG + `insertData0100 success; data = ${data}, options = ${options}`);
UDMF.queryData(options).then((ret) => {
let size = ret.length;
console.info(TAG, ` data.size = ${size}`);
for (var i = 0; i < size; i++) {
let records = ret[i].getRecords();
let size = records.length;
for (var j = 0; j < size; j++) {
if (records[j].getType() == UDMF.UnifiedDataType.PLAIN_TEXT) {
let text = <UDMF.PlainText> (records[j]);
console.info(TAG, ` queryData.result = ${i + 1}.${text.textContent}`);
}
}
}
expect(size).assertEqual(1);
done();
}).catch((err) => {
console.info(`Failed to queryData. code is ${err.code},message is ${err.message} `);
expect(err !== null).assertFail();
done();
});
});
} catch (error) {
console.error(TAG, `Failed, code is ${error.code},message is ${error.message} `);
expect(error !== null).assertFail();
done();
}
})
/**
* @tc.number SUB_DDM_UDMF_QueryData_Promise_0200
* @tc.name UDMF queryData promise interface test
* @tc.desc UDMF queryData promise interface test.
*/
it('SUB_DDM_UDMF_QueryData_Promise_0200', 0, function (done) {
let options = {
intention: UDMF.Intention.DATA_HUB
};
let plainText = new UDMF.PlainText();
plainText.textContent = "hello world!";
let unifiedData = new UDMF.UnifiedData(plainText);
try {
UDMF.insertData(options, unifiedData, function (e, data) {
if (e !== undefined) {
console.info(`Failed to insertData. code is ${e.code},message is ${e.message} `);
return;
}
console.info(TAG + `insertData0100 success; data = ${data}, options = ${options}`);
UDMF.queryData({key: data}).then((ret) => {
let size = ret.length;
console.info(TAG, ` data.size = ${size}`);
for (var i = 0; i < size; i++) {
let records = ret[i].getRecords();
let size = records.length;
for (var j = 0; j < size; j++) {
if (records[j].getType() == UDMF.UnifiedDataType.PLAIN_TEXT) {
let text = <UDMF.PlainText> (records[j]);
console.info(TAG, ` queryData.result = ${i + 1}.${text.textContent}`);
}
}
}
expect(size).assertEqual(1);
done();
}).catch((err) => {
console.info(`Failed to queryData. code is ${err.code},message is ${err.message} `);
expect(err !== null).assertFail();
done();
});
});
} catch (error) {
console.error(TAG, `Failed, code is ${error.code},message is ${error.message} `);
expect(error !== null).assertFail();
done();
}
})
/**
* @tc.number SUB_DDM_UDMF_QueryData_Promise_0300
* @tc.name UDMF queryData promise interface test
* @tc.desc UDMF queryData promise interface test.
*/
it('SUB_DDM_UDMF_QueryData_Promise_0300', 0, function (done) {
let options1 = {
intention: UDMF.Intention.DATA_HUB
};
let plainText = new UDMF.PlainText();
plainText.textContent = "hello world!";
let unifiedData = new UDMF.UnifiedData(plainText);
try {
UDMF.insertData(options1, unifiedData, function (e, data) {
if (e !== undefined) {
console.info(`Failed to insertData. code is ${e.code},message is ${e.message} `);
return;
}
console.info(TAG + `insertData0100 success; data = ${data}, options = ${options1}`);
let options2 = {
intention: UDMF.Intention.DATA_HUB,
key: data
};
UDMF.queryData(options2).then((ret) => {
let size = ret.length;
console.info(TAG, ` data.size = ${size}`);
for (var i = 0; i < size; i++) {
let records = ret[i].getRecords();
let size = records.length;
for (var j = 0; j < size; j++) {
if (records[j].getType() == UDMF.UnifiedDataType.PLAIN_TEXT) {
let text = <UDMF.PlainText> (records[j]);
console.info(TAG, ` queryData.result = ${i + 1}.${text.textContent}`);
}
}
}
expect(size).assertEqual(1);
done();
}).catch((err) => {
console.info(`Failed to queryData. code is ${err.code},message is ${err.message} `);
expect(err !== null).assertFail();
done();
});
});
} catch (error) {
console.error(TAG, `Failed, code is ${error.code},message is ${error.message} `);
expect(error !== null).assertFail();
done();
}
})
/**
* @tc.number SUB_DDM_UDMF_QueryData_Promise_0400
* @tc.name UDMF queryData promise interface test
* @tc.desc UDMF queryData promise interface test.
*/
it('SUB_DDM_UDMF_QueryData_Promise_0400', 0, function (done) {
let options1 = {
intention: UDMF.Intention.DATA_HUB
};
let plainText = new UDMF.PlainText();
plainText.textContent = "hello world!";
let unifiedData = new UDMF.UnifiedData(plainText);
try {
UDMF.insertData(options1, unifiedData, function (e, data) {
if (e !== undefined) {
console.info(`Failed to insertData. code is ${e.code},message is ${e.message} `);
return;
}
console.info(TAG + `insertData0400 success; data = ${data}, options = ${options1}`);
let options2 = {
intention: UDMF.Intention.DATA_HUB,
key: 'data'
};
try{
UDMF.queryData(options2).then((ret) => {
let size = ret.length;
console.info(TAG, ` data.size = ${size}`);
for (var i = 0; i < size; i++) {
let records = ret[i].getRecords();
let size = records.length;
for (var j = 0; j < size; j++) {
if (records[j].getType() == UDMF.UnifiedDataType.PLAIN_TEXT) {
let text = <UDMF.PlainText> (records[j]);
console.info(TAG, ` queryData.result = ${i + 1}.${text.textContent}`);
}
}
}
expect().assertFail();
done();
}).catch((err) => {
console.info(`Failed. code is ${err.code},message is ${err.message} `);
expect(err !== null).assertFail();
done();
});
}catch(errInfo){
console.info(`Failed to queryData. code is ${errInfo.code},message is ${errInfo.message} `);
expect(errInfo.code).assertEqual('401');
done();
}
});
} catch (error) {
console.error(TAG, `Failed, code is ${error.code},message is ${error.message} `);
expect(error !== null).assertFail();
done();
}
})
/**
* @tc.number SUB_DDM_UDMF_QueryData_Promise_0500
* @tc.name UDMF queryData promise interface test
* @tc.desc UDMF queryData promise interface test.
*/
it('SUB_DDM_UDMF_QueryData_Promise_0500', 0, function (done) {
let options1 = {
intention: UDMF.Intention.DATA_HUB
};
let plainText = new UDMF.PlainText();
plainText.textContent = "hello world!";
let unifiedData = new UDMF.UnifiedData(plainText);
try {
UDMF.insertData(options1, unifiedData, function (e, data) {
if (e !== undefined) {
console.info(`Failed to insertData. code is ${e.code},message is ${e.message} `);
return;
}
console.info(TAG + `insertData0500 success; data = ${data}, options = ${options1}`);
let options2 = {
intention: UDMF.Intention.DATA_HUB,
key: undefined
};
UDMF.queryData(options2).then((ret) => {
let size = ret.length;
console.info(TAG, ` data.size = ${size}`);
for (var i = 0; i < size; i++) {
let records = ret[i].getRecords();
let size = records.length;
for (var j = 0; j < size; j++) {
if (records[j].getType() == UDMF.UnifiedDataType.PLAIN_TEXT) {
let text = <UDMF.PlainText> (records[j]);
console.info(TAG, ` queryData.result = ${i + 1}.${text.textContent}`);
}
}
}
expect(size).assertEqual(1);
done();
}).catch((err) => {
console.info(`Failed to queryData. code is ${err.code},message is ${err.message} `);
expect(err !== null).assertFail();
done();
});
});
} catch (error) {
console.error(TAG, `Failed, code is ${error.code},message is ${error.message} `);
expect(error !== null).assertFail();
done();
}
})
/**
* @tc.number SUB_DDM_UDMF_DeleteData_Promise_0100
* @tc.name UDMF deleteData promise interface test
* @tc.desc UDMF deleteData promise interface test.
*/
it('SUB_DDM_UDMF_DeleteData_Promise_0100', 0, function (done) {
let options = {
intention: UDMF.Intention.DATA_HUB
};
let plainText = new UDMF.PlainText();
plainText.textContent = "hello world!";
let unifiedData = new UDMF.UnifiedData(plainText);
try {
UDMF.insertData(options, unifiedData, function (e, data) {
if (e !== undefined) {
console.info(`Failed to insertData. code is ${e.code},message is ${e.message} `);
return;
}
console.info(TAG + `insertData0100 success; data = ${data}, options = ${options}`);
UDMF.queryData(options, function (errInfo, ret) {
if (errInfo !== undefined) {
console.info(`Failed to queryData. code is ${errInfo.code},message is ${errInfo.message} `);
return;
}
console.info(TAG, ` queryData size = ${ret.length}`);
UDMF.deleteData(options).then((row) => {
let size = row.length;
console.info(TAG, ` deleteData size = ${size}`);
for (var i = 0; i < size; i++) {
let records = row[i].getRecords();
let size = records.length;
for (var j = 0; j < size; j++) {
if (records[j].getType() == UDMF.UnifiedDataType.PLAIN_TEXT) {
let text = <UDMF.PlainText> (records[j]);
console.info(TAG, ` deleteData.result = ${i + 1}.${text.textContent}`);
}
}
}
expect(size).assertEqual(1);
done();
}).catch((err) => {
console.info(`Failed to deleteData. code is ${err.code},message is ${err.message} `);
expect(err !== null).assertFail();
done();
});
});
});
} catch (error) {
console.error(TAG, `Failed, code is ${error.code},message is ${error.message} `);
expect(error !== null).assertFail();
done();
}
})
/**
* @tc.number SUB_DDM_UDMF_DeleteData_Promise_0200
* @tc.name UDMF deleteData promise interface test
* @tc.desc UDMF deleteData promise interface test.
*/
it('SUB_DDM_UDMF_DeleteData_Promise_0200', 0, function (done) {
let options = {
intention: UDMF.Intention.DATA_HUB
};
let plainText = new UDMF.PlainText();
plainText.textContent = "hello world!";
let unifiedData = new UDMF.UnifiedData(plainText);
try {
UDMF.insertData(options, unifiedData, function (e, data) {
if (e !== undefined) {
console.info(`Failed to insertData. code is ${e.code},message is ${e.message} `);
return;
}
console.info(TAG + `insertData0200 success; data = ${data}, options = ${options}`);
UDMF.queryData(options, function (errInfo, ret) {
if (errInfo !== undefined) {
console.info(`Failed to queryData. code is ${errInfo.code},message is ${errInfo.message} `);
return;
}
console.info(TAG, ` queryData size = ${ret.length}`);
UDMF.deleteData({key: data}).then((row) => {
let size = row.length;
console.info(TAG, ` deleteData size = ${size}`);
for (var i = 0; i < size; i++) {
let records = row[i].getRecords();
let size = records.length;
for (var j = 0; j < size; j++) {
if (records[j].getType() == UDMF.UnifiedDataType.PLAIN_TEXT) {
let text = <UDMF.PlainText> (records[j]);
console.info(TAG, ` deleteData.result = ${i + 1}.${text.textContent}`);
}
}
}
expect(size).assertEqual(1);
done();
}).catch((err) => {
console.info(`Failed to deleteData. code is ${err.code},message is ${err.message} `);
expect(err !== null).assertFail();
done();
});
});
});
} catch (error) {
console.error(TAG, `Failed, code is ${error.code},message is ${error.message} `);
expect(error !== null).assertFail();
done();
}
})
/**
* @tc.number SUB_DDM_UDMF_DeleteData_Promise_0300
* @tc.name UDMF deleteData promise interface test
* @tc.desc UDMF deleteData promise interface test.
*/
it('SUB_DDM_UDMF_DeleteData_Promise_0300', 0, function (done) {
let options1 = {
intention: UDMF.Intention.DATA_HUB
};
let plainText = new UDMF.PlainText();
plainText.textContent = "hello world!";
let unifiedData = new UDMF.UnifiedData(plainText);
try {
UDMF.insertData(options1, unifiedData, function (e, data) {
if (e !== undefined) {
console.info(`Failed to insertData. code is ${e.code},message is ${e.message} `);
return;
}
console.info(TAG + `insertData0100 success; data = ${data}, options = ${options1}`);
UDMF.queryData(options1, function (errInfo, ret) {
if (errInfo !== undefined) {
console.info(`Failed to queryData. code is ${errInfo.code},message is ${errInfo.message} `);
return;
}
console.info(TAG, ` queryData size = ${ret.length}`);
let options2 = {
intention: UDMF.Intention.DATA_HUB,
key: data
};
UDMF.deleteData(options2).then((row) => {
let size = row.length;
console.info(TAG, ` deleteData size = ${size}`);
for (var i = 0; i < size; i++) {
let records = row[i].getRecords();
let size = records.length;
for (var j = 0; j < size; j++) {
if (records[j].getType() == UDMF.UnifiedDataType.PLAIN_TEXT) {
let text = <UDMF.PlainText> (records[j]);
console.info(TAG, ` deleteData.result = ${i + 1}.${text.textContent}`);
}
}
}
expect(size).assertEqual(1);
done();
}).catch((err) => {
console.info(`Failed to deleteData. code is ${err.code},message is ${err.message} `);
expect(err !== null).assertFail();
done();
});
});
});
} catch (error) {
console.error(TAG, `Failed, code is ${error.code},message is ${error.message} `);
expect(error !== null).assertFail();
done();
}
})
/**
* @tc.number SUB_DDM_UDMF_DeleteData_Promise_0400
* @tc.name UDMF deleteData promise interface test
* @tc.desc UDMF deleteData promise interface test.
*/
it('SUB_DDM_UDMF_DeleteData_Promise_0400', 0, function (done) {
let options1 = {
intention: UDMF.Intention.DATA_HUB
};
let plainText = new UDMF.PlainText();
plainText.textContent = "hello world!";
let unifiedData = new UDMF.UnifiedData(plainText);
try {
UDMF.insertData(options1, unifiedData, function (e, data) {
if (e !== undefined) {
console.info(`Failed to insertData. code is ${e.code},message is ${e.message} `);
return;
}
console.info(TAG + `insertData0100 success; data = ${data}, options = ${options1}`);
UDMF.queryData(options1, function (errInfo, ret) {
if (errInfo !== undefined) {
console.info(`Failed to queryData. code is ${errInfo.code},message is ${errInfo.message} `);
return;
}
console.info(TAG, ` queryData size = ${ret.length}`);
let options2 = {
intention: UDMF.Intention.DATA_HUB,
key: 'data'
};
try{
UDMF.deleteData(options2).then((row) => {
let size = row.length;
console.info(TAG, ` deleteData size = ${size}`);
for (var i = 0; i < size; i++) {
let records = row[i].getRecords();
let size = records.length;
for (var j = 0; j < size; j++) {
if (records[j].getType() == UDMF.UnifiedDataType.PLAIN_TEXT) {
let text = <UDMF.PlainText> (records[j]);
console.info(TAG, ` deleteData.result = ${i + 1}.${text.textContent}`);
}
}
}
expect().assertFail();
done();
}).catch((err) => {
console.info(`Failed to deleteData. code is ${err.code},message is ${err.message} `);
expect(err !== null).assertFail();
done();
});
}catch(errInfo){
console.info(`Failed to deleteData. code is ${errInfo.code},message is ${errInfo.message} `);
expect(errInfo.code).assertEqual('401');
done();
}
});
});
} catch (error) {
console.error(TAG, `Failed, code is ${error.code},message is ${error.message} `);
expect(error !== null).assertFail();
done();
}
})
/**
* @tc.number SUB_DDM_UDMF_DeleteData_Promise_0500
* @tc.name UDMF deleteData promise interface test
* @tc.desc UDMF deleteData promise interface test.
*/
it('SUB_DDM_UDMF_DeleteData_Promise_0500', 0, function (done) {
let options1 = {
intention: UDMF.Intention.DATA_HUB
};
let plainText = new UDMF.PlainText();
plainText.textContent = "hello world!";
let unifiedData = new UDMF.UnifiedData(plainText);
try {
UDMF.insertData(options1, unifiedData, function (e, data) {
if (e !== undefined) {
console.info(`Failed to insertData. code is ${e.code},message is ${e.message} `);
return;
}
console.info(TAG + `insertData0100 success; data = ${data}, options = ${options1}`);
UDMF.queryData(options1, function (errInfo, ret) {
if (errInfo !== undefined) {
console.info(`Failed to queryData. code is ${errInfo.code},message is ${errInfo.message} `);
return;
}
console.info(TAG, ` queryData size = ${ret.length}`);
let options2 = {
intention: UDMF.Intention.DATA_HUB,
key: undefined
};
UDMF.deleteData(options2).then((row) => {
let size = row.length;
console.info(TAG, ` deleteData size = ${size}`);
for (var i = 0; i < size; i++) {
let records = row[i].getRecords();
let size = records.length;
for (var j = 0; j < size; j++) {
if (records[j].getType() == UDMF.UnifiedDataType.PLAIN_TEXT) {
let text = <UDMF.PlainText> (records[j]);
console.info(TAG, ` deleteData.result = ${i + 1}.${text.textContent}`);
}
}
}
expect(size).assertEqual(1);
done();
}).catch((err) => {
console.info(`Failed to deleteData. code is ${err.code},message is ${err.message} `);
expect(err !== null).assertFail();
done();
});
});
});
} catch (error) {
console.error(TAG, `Failed, code is ${error.code},message is ${error.message} `);
expect(error !== null).assertFail();
done();
}
})
console.info(TAG + "*************Unit Test End*************")
})
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录