未验证 提交 573ab70d 编写于 作者: O openharmony_ci 提交者: Gitee

!8846 【分布式数据】【UDMF】用例新增

Merge pull request !8846 from 刘皓男/master
# Copyright (C) 2022 Huawei Device Co., Ltd.
# 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
......@@ -16,6 +16,7 @@ group("distributeddatamgr") {
testonly = true
if (is_standard_system) {
deps = [
"UDMFtest:UDMFtest",
"dataObjectjstest/hap:dataObject_js_test",
"dataSharejstest/hap:dataShare_js_test",
"distributedKVStoretest:distributedKVStoretest",
......
# 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("//test/xts/tools/build/suite.gni")
group("UDMFtest") {
testonly = true
if (is_standard_system) {
deps = [ "UDMFtest:UDMF_ets_test" ]
}
}
{
"app": {
"bundleName": "ohos.acts.UDMF",
"vendor": "example",
"versionCode": 1000000,
"versionName": "1.0.0",
"icon": "$media:app_icon",
"label": "$string:app_name",
"debug": false,
"distributedNotificationEnabled": true,
"keepAlive": true,
"singleUser": true,
"minAPIVersion": 9,
"targetAPIVersion": 9,
"car": {
"apiCompatibleVersion": 9,
"singleUser": false
}
}
}
{
"string": [
{
"name": "app_name",
"value": "MyApplication2"
}
]
}
# 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("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("UDMF_ets_test") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":relationalStoreStage_js_assets",
":relationalStoreStage_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsUDMFTest"
subsystem_name = "distributeddatamgr"
part_name = "relational_store"
}
ohos_app_scope("relationalStoreStage_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("relationalStoreStage_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("relationalStoreStage_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":relationalStoreStage_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "180000",
"bundle-name": "ohos.acts.UDMF",
"module-name": "entry",
"shell-timeout": "600000",
"testcase-timeout": 70000
},
"kits": [{
"test-file-name": [
"ActsUDMFTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}]
}
\ No newline at end of file
/*
* 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 AbilityStage from "@ohos.app.ability.AbilityStage"
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("[Demo] MyAbilityStage onCreate")
}
}
\ No newline at end of file
/*
* 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 Ability from '@ohos.app.ability.UIAbility'
import dataShare from '@ohos.data.dataShare'
import rpc from "@ohos.rpc";
var seConnect = {
onConnect:function (elementName, proxy) {
console.log("[ttt] [DataShareTest] <<Consumer>> seConnect onConnect called.");
console.log("[ttt] [DataShareTest] <<Consumer>> seConnect onConnect elementName = " + elementName);
console.log("[ttt] [DataShareTest] <<Consumer>> seConnect onConnect proxy = " + proxy);
let data = rpc.MessageParcel.create();
let reply = rpc.MessageParcel.create();
let option = new rpc.MessageOption();
data.writeInterfaceToken("connect-test");
data.writeInt(111);
console.log("[ttt] [DataShareTest] <<Consumer>> seConnect onConnect sendRequest.");
proxy.sendRequest(1, data, reply, option)
.then(function (result) {
if (result.errCode === 0) {
let msg = result.reply.readInt();
console.log("[ttt] [DataShareTest] <<Consumer>> seConnect reply msg: " + msg);
} else {
console.log("[ttt] [DataShareTest] <<Consumer>> seConnect sendRequest failed, errCode: " + result.errCode);
}
// callback没有返回值,默认返回undefined
}).catch(function (e) {
console.log("[ttt] [DataShareTest] <<Consumer>> seConnect sendRequest got exception: " + e);
}).finally (async () => {
console.log("[ttt] [DataShareTest] <<Consumer>> seConnect sendRequest ends, reclaim parcel");
data.reclaim();
reply.reclaim();
})
},
onDisconnect:function (elementName) {
console.log("[ttt] [DataShareTest] <<Consumer>> seConnect onDisconnect");
},
onFailed:function (code) {
console.log("[ttt] [DataShareTest] <<Consumer>> seConnect onFailed");
}
};
let dseProxy = 0;
let dseUri = ("datashare:///com.samples.datasharekvtest.DataShare");
var dseConnect = {
onConnect:function (elementName, proxy) {
console.log("[ttt] [DataShareTest] <<Consumer>> dseConnect onConnect called.");
dseProxy = proxy;
},
onDisconnect:function (elementName) {
console.log("[ttt] [DataShareTest] <<Consumer>> dseConnect onDisconnect, elementName:" + elementName);
},
onFailed:function (code) {
console.log("[ttt] [DataShareTest] <<Consumer>> dseConnect onFailed, code:" + code);
}
};
let seConnectionId = -1;
let dseConnectionId = -1;
let seWant = {
"bundleName": "com.samples.datasharetest",
"abilityName": "ServiceExtAbility",
}
let dseWant = {
"bundleName": "com.samples.datasharetest",
"abilityName": "DataShareExtAbility",
}
export function onCallback() {
console.info("[ttt] [DataShareTest] <<Consumer>> **** Observer on callback ****");
}
export function offCallback() {
console.info("[ttt] [DataShareTest] <<Consumer>> **** Observer off callback ****");
}
export default class MainAbility extends Ability {
onCreate(want, launchParam) {
// Ability is creating, initialize resources for this ability
console.log("[ttt] [DataShareTest] <<Consumer>> MainAbility onCreate")
globalThis.abilityWant = want;
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("[ttt] [DataShareTest] <<Consumer>> MainAbility onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[ttt] [DataShareTest] <<Consumer>> MainAbility onWindowStageCreate")
globalThis.abilityContext = this.context;
let context = this.context;
dseConnectionId = context.connectServiceExtensionAbility(dseWant, dseConnect);
globalThis.connectDataShareExtAbility = (async () => {
console.log("[ttt] [DataShareTest] <<Consumer>> connectDataShareExtAbility begin");
await dataShare.createDataShareHelper(globalThis.abilityContext, dseUri, (err,data)=>{
globalThis.helper = data;
globalThis.testhelper = data;
console.info("[ttt] [DataShareTest] <<Consumer>> ----- 1 -----, globalThis.helper = " + globalThis.helper);
console.info("[ttt] [DataShareTest] <<Consumer>> ----- 2 -----, data = " + data);
console.info("[ttt] [DataShareTest] <<Consumer>> ----- 3 -----, err = " + err);
console.info("[ttt] [DataShareTest] <<Consumer>> ----- 4 -----, JSON.stringify(err) = " + JSON.stringify(err));
});
dseConnectionId = await context.connectServiceExtensionAbility(dseWant, dseConnect);
})
windowStage.setUIContent(this.context, "MainAbility/pages/index", null)
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("[ttt] [DataShareTest] <<Consumer>> MainAbility onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("[ttt] [DataShareTest] <<Consumer>> MainAbility onForeground")
}
onBackground() {
// Ability has back to background
console.log("[ttt] [DataShareTest] <<Consumer>> MainAbility onBackground")
}
};
/*
* 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 file from '@system.file';
import router from '@ohos.router';
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../../test/List.test'
//InstrumentLog, ReportExtend
@Entry
@Component
struct Index {
aboutToAppear(){
console.info("start run testcase!!!!")
var abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments: any
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
}
build() {
Flex({ direction:FlexDirection.Column, alignItems:ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('Hello World')
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('next page')
.fontSize(25)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.onClick(() => {
})
}
.width('100%')
.height('100%')
}
}
\ No newline at end of file
/*
* 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 Ability from '@ohos.app.ability.UIAbility'
export default class TestAbility extends Ability {
onCreate(want, launchParam) {
console.log('TestAbility onCreate')
}
onDestroy() {
console.log('TestAbility onDestroy')
}
onWindowStageCreate(windowStage) {
console.log('TestAbility onWindowStageCreate')
windowStage.loadContent("TestAbility/pages/index", (err, data) => {
if (err.code) {
console.error('Failed to load the content. Cause:' + JSON.stringify(err));
return;
}
console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data))
});
globalThis.abilityContext = this.context;
}
onWindowStageDestroy() {
console.log('TestAbility onWindowStageDestroy')
}
onForeground() {
console.log('TestAbility onForeground')
}
onBackground() {
console.log('TestAbility onBackground')
}
};
\ No newline at end of file
/*
* 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 router from '@ohos.router';
@Entry
@Component
struct Index {
aboutToAppear() {
console.info('TestAbility index aboutToAppear')
}
@State message: string = 'Hello World'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('next page')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.width('35%')
.height('5%')
.onClick(()=>{
})
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
/*
* 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 TestRunner from '@ohos.application.testRunner'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
var abilityDelegator = undefined
var abilityDelegatorArguments = undefined
function translateParamsToString(parameters) {
const keySet = new Set([
'-s class', '-s notClass', '-s suite', '-s it',
'-s level', '-s testType', '-s size', '-s timeout',
'-s dryRun'
])
let targetParams = '';
for (const key in parameters) {
if (keySet.has(key)) {
targetParams = `${targetParams} ${key} ${parameters[key]}`
}
}
return targetParams.trim()
}
async function onAbilityCreateCallback() {
console.log("onAbilityCreateCallback");
}
async function addAbilityMonitorCallback(err: any) {
console.info("addAbilityMonitorCallback : " + JSON.stringify(err))
}
export default class OpenHarmonyTestRunner implements TestRunner {
constructor() {
}
onPrepare() {
console.info("OpenHarmonyTestRunner OnPrepare ")
}
async onRun() {
console.log('OpenHarmonyTestRunner onRun run')
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var testAbilityName = abilityDelegatorArguments.bundleName + '.MainAbility'
let lMonitor = {
abilityName: testAbilityName,
onAbilityCreate: onAbilityCreateCallback,
};
abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback)
var cmd = 'aa start -d 0 -a ohos.acts.UDMF.MainAbility' + ' -b ' + abilityDelegatorArguments.bundleName
cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters)
var debug = abilityDelegatorArguments.parameters["-D"]
if (debug == 'true')
{
cmd += ' -D'
}
console.info('cmd : '+cmd)
abilityDelegator.executeShellCommand(cmd,
(err: any, d: any) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
console.info('executeShellCommand : data : ' + d.stdResult);
console.info('executeShellCommand : data : ' + d.exitCode);
})
console.info('OpenHarmonyTestRunner onRun end')
}
};
\ No newline at end of file
/*
* 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 UDMFApiTest from './UDMF.test.ets'
export default function testsuite() {
UDMFApiTest()
}
/*
* 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';
export default function UDMFApiTest() {
describe('UDMFApiTest', function () {
console.info('start################################start');
let text = new UDMF.Text();
text.details = {
title:"标题",
content:"内容"
};
let plainText = new UDMF.PlainText();
plainText.details = {
title:"标题",
content:"内容"
};
plainText.textContent = "textContent";
plainText.abstract = "abstract";
let link = new UDMF.Hyperlink();
link.details = {
title:"标题",
content:"内容"
};
link.url = "url";
link.description = "description";
let html = new UDMF.HTML();
html.details = {
title:"标题",
content:"内容"
};
html.htmlContent = "htmlContent";
html.plainContent = "plainContent";
let file = new UDMF.File();
file.details = {
title:"标题",
content:"内容"
};
file.uri = "uri";
let folder = new UDMF.Folder();
folder.details = {
title:"标题",
content:"内容"
};
folder.folderUri = "folderUri";
let image = new UDMF.Image();
image.details = {
title:"标题",
content:"内容"
};
image.imageUri = "imageUri";
let video = new UDMF.Video();
video.details = {
title:"标题",
content:"内容"
};
video.videoUri = "videoUri";
let arrayBuf = new ArrayBuffer(2 * 3 * 4);
let u8Array = new Uint8Array(arrayBuf);
let systemDefinedRecord = new UDMF.SystemDefinedRecord();
systemDefinedRecord.details = {
title:"标题",
version:1,
content:u8Array
};
let systemDefinedForm = new UDMF.SystemDefinedForm();
systemDefinedForm.details = {
title:"标题",
version:1,
content:u8Array
};
systemDefinedForm.formId = 123456;
systemDefinedForm.formName = 'formName';
systemDefinedForm.bundleName = 'bundleName';
systemDefinedForm.abilityName = 'abilityName';
systemDefinedForm.module = 'module';
let systemDefinedAppItem = new UDMF.SystemDefinedAppItem();
systemDefinedAppItem.details = {
title:"标题",
version:1,
content:u8Array
};
systemDefinedAppItem.appId = 'appId';
systemDefinedAppItem.appName = 'appName';
systemDefinedAppItem.appIconId = 'appIconId';
systemDefinedAppItem.appLabelId = 'appLabelId';
systemDefinedAppItem.bundleName = 'bundleName';
systemDefinedAppItem.abilityName = 'abilityName';
let systemDefinedPixelMap = new UDMF.SystemDefinedPixelMap();
systemDefinedPixelMap.details = {
title:"标题",
version:1,
content:u8Array
};
systemDefinedPixelMap.rawData = u8Array;
let applicationDefinedRecord = new UDMF.ApplicationDefinedRecord();
applicationDefinedRecord.applicationDefinedType = 'applicationDefinedType';
applicationDefinedRecord.rawData = u8Array;
/**
* @tc.number SUB_DistributedData_Udmf_API001
* @tc.name CreateData
* @tc.desc Test UDMF creating a unifieddata with a text record.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it('SUB_DistributedData_Udmf_API001',0, async function (done) {
console.info('SUB_DistributedData_Udmf_API001 start');
let unifiedData = new UDMF.UnifiedData(text);
let records = unifiedData.getRecords();
let record = <UDMF.Text>(records[0]);
expect(records.length).assertEqual(1);
expect(record.details.title).assertEqual('标题');
expect(record.details.content).assertEqual('内容');
console.info("SUB_DistributedData_Udmf_API001 end");
done();
})
/**
* @tc.number SUB_DistributedData_Udmf_API002
* @tc.name CreateData
* @tc.desc Test UDMF creating a unifieddata with a plaintext record.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it('SUB_DistributedData_Udmf_API002',0, async function (done) {
console.info('SUB_DistributedData_Udmf_API002 start');
let unifiedData = new UDMF.UnifiedData(plainText);
let records = unifiedData.getRecords();
let record = <UDMF.PlainText>(records[0]);
expect(records.length).assertEqual(1);
expect(record.details.title).assertEqual('标题');
expect(record.details.content).assertEqual('内容');
expect(record.textContent).assertEqual('textContent');
expect(record.abstract).assertEqual('abstract');
console.info("SUB_DistributedData_Udmf_API002 end");
done();
})
/**
* @tc.number SUB_DistributedData_Udmf_API003
* @tc.name CreateData
* @tc.desc Test UDMF creating a unifieddata with a hyperlink record.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it('SUB_DistributedData_Udmf_API003',0, async function (done) {
console.info('SUB_DistributedData_Udmf_API003 start');
let unifiedData = new UDMF.UnifiedData(link);
let records = unifiedData.getRecords();
let record = <UDMF.Hyperlink>(records[0]);
expect(records.length).assertEqual(1);
expect(record.details.title).assertEqual('标题');
expect(record.details.content).assertEqual('内容');
expect(record.url).assertEqual('url');
expect(record.description).assertEqual('description');
console.info("SUB_DistributedData_Udmf_API003 end");
done();
})
/**
* @tc.number SUB_DistributedData_Udmf_API004
* @tc.name CreateData
* @tc.desc Test UDMF creating a unifieddata with a html record.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it('SUB_DistributedData_Udmf_API004',0, async function (done) {
console.info('SUB_DistributedData_Udmf_API004 start');
let unifiedData = new UDMF.UnifiedData(html);
let records = unifiedData.getRecords();
let record = <UDMF.HTML>(records[0]);
expect(records.length).assertEqual(1);
expect(record.details.title).assertEqual('标题');
expect(record.details.content).assertEqual('内容');
expect(record.htmlContent).assertEqual('htmlContent');
expect(record.plainContent).assertEqual('plainContent');
console.info("SUB_DistributedData_Udmf_API004 end");
done();
})
/**
* @tc.number SUB_DistributedData_Udmf_API005
* @tc.name CreateData
* @tc.desc Test UDMF creating a unifieddata with a file record.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it('SUB_DistributedData_Udmf_API005',0, async function (done) {
console.info('SUB_DistributedData_Udmf_API005 start');
let unifiedData = new UDMF.UnifiedData(file);
let records = unifiedData.getRecords();
let record = <UDMF.File>(records[0]);
expect(records.length).assertEqual(1);
expect(record.details.title).assertEqual('标题');
expect(record.details.content).assertEqual('内容');
console.info("SUB_DistributedData_Udmf_API005 end");
done();
})
/**
* @tc.number SUB_DistributedData_Udmf_API006
* @tc.name CreateData
* @tc.desc Test UDMF creating a unifieddata with a folder record.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it('SUB_DistributedData_Udmf_API006',0, async function (done) {
console.info('SUB_DistributedData_Udmf_API006 start');
let unifiedData = new UDMF.UnifiedData(folder);
let records = unifiedData.getRecords();
let record = <UDMF.Folder>(records[0]);
expect(records.length).assertEqual(1);
expect(record.details.title).assertEqual('标题');
expect(record.details.content).assertEqual('内容');
console.info("SUB_DistributedData_Udmf_API006 end");
done();
})
/**
* @tc.number SUB_DistributedData_Udmf_API007
* @tc.name CreateData
* @tc.desc Test UDMF creating a unifieddata with a image record.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it('SUB_DistributedData_Udmf_API007',0, async function (done) {
console.info('SUB_DistributedData_Udmf_API007 start');
let unifiedData = new UDMF.UnifiedData(image);
let records = unifiedData.getRecords();
let record = <UDMF.Image>(records[0]);
expect(records.length).assertEqual(1);
expect(record.details.title).assertEqual('标题');
expect(record.details.content).assertEqual('内容');
console.info("SUB_DistributedData_Udmf_API007 end");
done();
})
/**
* @tc.number SUB_DistributedData_Udmf_API008
* @tc.name CreateData
* @tc.desc Test UDMF creating a unifieddata with a video record.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it('SUB_DistributedData_Udmf_API008',0, async function (done) {
console.info('SUB_DistributedData_Udmf_API008 start');
let unifiedData = new UDMF.UnifiedData(video);
let records = unifiedData.getRecords();
let record = <UDMF.Video>(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();
})
/**
* @tc.number SUB_DistributedData_Udmf_API009
* @tc.name CreateData
* @tc.desc Test UDMF creating a unifieddata with a systemdefinedrecord record.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it('SUB_DistributedData_Udmf_API009',0, async function (done) {
console.info('SUB_DistributedData_Udmf_API009 start');
let unifiedData = new UDMF.UnifiedData(systemDefinedRecord);
let records = unifiedData.getRecords();
let record = <UDMF.SystemDefinedRecord>(records[0]);
expect(records.length).assertEqual(1);
expect(record.details.title).assertEqual('标题');
expect(record.details.version).assertEqual(1);
for(var i = 0; i<u8Array.length; i++){
expect(record.details.content[i]).assertEqual(u8Array[i]);
}
console.info("SUB_DistributedData_Udmf_API009 end");
done();
})
/**
* @tc.number SUB_DistributedData_Udmf_API010
* @tc.name CreateData
* @tc.desc Test UDMF creating a unifieddata with a systemdefinedform record.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it('SUB_DistributedData_Udmf_API010',0, async function (done) {
console.info('SUB_DistributedData_Udmf_API010 start');
let unifiedData = new UDMF.UnifiedData(systemDefinedForm);
let records = unifiedData.getRecords();
let record = <UDMF.SystemDefinedForm>(records[0]);
expect(records.length).assertEqual(1);
expect(record.details.title).assertEqual('标题');
expect(record.details.version).assertEqual(1);
for(var i = 0; i<u8Array.length; i++){
expect(record.details.content[i]).assertEqual(u8Array[i]);
}
expect(record.formId).assertEqual(123456);
expect(record.formName).assertEqual('formName');
expect(record.bundleName).assertEqual('bundleName');
expect(record.abilityName).assertEqual('abilityName');
expect(record.module).assertEqual('module');
console.info("SUB_DistributedData_Udmf_API010 end");
done();
})
/**
* @tc.number SUB_DistributedData_Udmf_API011
* @tc.name CreateData
* @tc.desc Test UDMF creating a unifieddata with a systemdefinedappitem record.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it('SUB_DistributedData_Udmf_API011',0, async function (done) {
console.info('SUB_DistributedData_Udmf_API011 start');
let unifiedData = new UDMF.UnifiedData(systemDefinedAppItem);
let records = unifiedData.getRecords();
let record = <UDMF.SystemDefinedAppItem>(records[0]);
expect(records.length).assertEqual(1);
expect(record.details.title).assertEqual('标题');
expect(record.details.version).assertEqual(1);
for(var i = 0; i<u8Array.length; i++){
expect(record.details.content[i]).assertEqual(u8Array[i]);
}
expect(record.appId).assertEqual('appId');
expect(record.appName).assertEqual('appName');
expect(record.appIconId).assertEqual('appIconId');
expect(record.appLabelId).assertEqual('appLabelId');
expect(record.bundleName).assertEqual('bundleName');
expect(record.abilityName).assertEqual('abilityName');
console.info("SUB_DistributedData_Udmf_API011 end");
done();
})
/**
* @tc.number SUB_DistributedData_Udmf_API012
* @tc.name CreateData
* @tc.desc Test UDMF creating a unifieddata with a systemdefinedpixelmap record.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it('SUB_DistributedData_Udmf_API012',0, async function (done) {
console.info('SUB_DistributedData_Udmf_API012 start');
let unifiedData = new UDMF.UnifiedData(systemDefinedPixelMap);
let records = unifiedData.getRecords();
let record = <UDMF.SystemDefinedPixelMap>(records[0]);
expect(records.length).assertEqual(1);
expect(record.details.title).assertEqual('标题');
expect(record.details.version).assertEqual(1);
for(var i = 0; i<u8Array.length; i++){
expect(record.details.content[i]).assertEqual(u8Array[i]);
}
for(var i = 0; i<u8Array.length; i++){
expect(record.rawData[i]).assertEqual(u8Array[i]);
}
console.info("SUB_DistributedData_Udmf_API012 end");
done();
})
/**
* @tc.number SUB_DistributedData_Udmf_API013
* @tc.name CreateData
* @tc.desc Test UDMF creating a unifieddata with a applicationdefinedrecord record.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it('SUB_DistributedData_Udmf_API013',0, async function (done) {
console.info('SUB_DistributedData_Udmf_API013 start');
let unifiedData = new UDMF.UnifiedData(applicationDefinedRecord);
let records = unifiedData.getRecords();
let record = <UDMF.ApplicationDefinedRecord>(records[0]);
expect(records.length).assertEqual(1);
expect(record.applicationDefinedType).assertEqual('applicationDefinedType');
for(var i = 0; i<u8Array.length; i++){
expect(record.rawData[i]).assertEqual(u8Array[i]);
}
console.info("SUB_DistributedData_Udmf_API013 end");
done();
})
/**
* @tc.number SUB_DistributedData_Udmf_API014
* @tc.name CreateData
* @tc.desc Test UDMF creating a unifieddata with a recordgroup.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it('SUB_DistributedData_Udmf_API014',0, async function (done) {
console.info('SUB_DistributedData_Udmf_API014 start');
let unifiedData = new UDMF.UnifiedData(text);
unifiedData.addRecord(plainText);
unifiedData.addRecord(link);
unifiedData.addRecord(html);
unifiedData.addRecord(file);
unifiedData.addRecord(folder);
unifiedData.addRecord(image);
unifiedData.addRecord(video);
unifiedData.addRecord(systemDefinedRecord);
unifiedData.addRecord(systemDefinedForm);
unifiedData.addRecord(systemDefinedAppItem);
unifiedData.addRecord(systemDefinedPixelMap);
unifiedData.addRecord(applicationDefinedRecord);
let records = unifiedData.getRecords();
let record1 = <UDMF.Text>(records[0]);
let record2 = <UDMF.PlainText>(records[1]);
let record3 = <UDMF.Hyperlink>(records[2]);
let record4 = <UDMF.HTML>(records[3]);
let record5 = <UDMF.File>(records[4]);
let record6 = <UDMF.Folder>(records[5]);
let record7 = <UDMF.Image>(records[6]);
let record8 = <UDMF.Video>(records[7]);
let record9 = <UDMF.SystemDefinedRecord>(records[8]);
let record10 = <UDMF.SystemDefinedForm>(records[9]);
let record11 = <UDMF.SystemDefinedAppItem>(records[10]);
let record12 = <UDMF.SystemDefinedPixelMap>(records[11]);
let record13 = <UDMF.ApplicationDefinedRecord>(records[12]);
expect(records.length).assertEqual(13);
expect(record1.getType()).assertEqual(UDMF.UnifiedDataType.TEXT);
expect(record2.getType()).assertEqual(UDMF.UnifiedDataType.PLAIN_TEXT);
expect(record3.getType()).assertEqual(UDMF.UnifiedDataType.HYPERLINK);
expect(record4.getType()).assertEqual(UDMF.UnifiedDataType.HTML);
expect(record5.getType()).assertEqual(UDMF.UnifiedDataType.FILE);
expect(record6.getType()).assertEqual(UDMF.UnifiedDataType.FOLDER);
expect(record7.getType()).assertEqual(UDMF.UnifiedDataType.IMAGE);
expect(record8.getType()).assertEqual(UDMF.UnifiedDataType.VIDEO);
expect(record9.getType()).assertEqual(UDMF.UnifiedDataType.SYSTEM_DEFINED_RECORD);
expect(record10.getType()).assertEqual(UDMF.UnifiedDataType.SYSTEM_DEFINED_FORM);
expect(record11.getType()).assertEqual(UDMF.UnifiedDataType.SYSTEM_DEFINED_APP_ITEM);
expect(record12.getType()).assertEqual(UDMF.UnifiedDataType.SYSTEM_DEFINED_PIXEL_MAP);
expect(record13.getType()).assertEqual(UDMF.UnifiedDataType.APPLICATION_DEFINED_RECORD);
console.info("SUB_DistributedData_Udmf_API014 end");
done();
})
})
}
\ No newline at end of file
{
"module": {
"package": "ohos.acts.UDMF",
"name": "entry",
"mainAbility": "ohos.acts.UDMF.MainAbility",
"type": "entry",
"srcEntrance": "./ets/Application/AbilityStage.ts",
"description": "$string:entry_desc",
"mainElement": "MainAbility",
"deviceTypes": [
"default",
"tablet",
"phone"
],
"deliveryWithInstall": true,
"installationFree": false,
"pages": "$profile:main_pages",
"uiSyntax": "ets",
"abilities": [
{
"name": "ohos.acts.UDMF.MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:MainAbility_desc",
"icon": "$media:icon",
"label": "$string:MainAbility_label",
"visible": true,
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
]
}
]
}
}
{
"string": [
{
"name": "entry_desc",
"value": "description"
},
{
"name": "MainAbility_desc",
"value": "description"
},
{
"name": "MainAbility_label",
"value": "ActsUDMFTest"
}
]
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册