未验证 提交 95129dc9 编写于 作者: O openharmony_ci 提交者: Gitee

!6610 radiostatistic测试套整改

Merge pull request !6610 from zhangfuzhi/monthly_20221018
......@@ -12,9 +12,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from 'hypium/index'
import testsuite from '../test/List.test'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry';
import { Hypium } from '@ohos/hypium';
import testsuite from '../test/List.test';
export default {
onCreate() {
......
// @ts-nocheck
/**
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Copyright (C) 2021-2022 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
......@@ -13,48 +12,33 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'hypium/index'
import { describe, expect, it } from '@ohos/hypium';
import call from '@ohos.telephony.call';
import utils from './Utils.ets'
export const PHONE_NUMBER = '';
export const DEFAULT_SLOT_ID = 0;
export const MEDIA_TYPE_VOICE = 0;
export const DIAL_SCENCE_CALL_NORMAL = 0;
export const DIAL_CARRIER_TYPE = 0;
export const DIAL_SCENCE_CALL_PRIVILEGED = 1;
export const BOUNDARY_NUMBER_INT = 2147483649;
export const CALL_ID_NOT_EXIST = 999;
export function toString (data) {
export function toString(data) {
if (typeof data === 'object') {
return JSON.stringify(data);
} else {
return data;
}
}
;
class CallAttributeOptions {
constructor (callId) {
this.callId = callId;
}
}
export default function callJsunit(){
describe('callTest', function(){
export default function callJsunit() {
describe('callTest', function () {
console.log("==========> call Test start ==========>");
/**
* @tc.number Telephony_Call_HasVoiceCapability_HasVoiceCapability
* @tc.name Checks whether a device supports voice calls.
* @tc.desc Return type test
*/
it("Telephony_Call_HasVoiceCapability_HasVoiceCapability",0,async function(done){
* @tc.number Telephony_Call_HasVoiceCapability_HasVoiceCapability
* @tc.name Checks whether a device supports voice calls.
* @tc.desc Return type test
*/
it("Telephony_Call_HasVoiceCapability_HasVoiceCapability", 0, async function (done) {
let caseName = 'Telephony_Call_HasVoiceCapability_HasVoiceCapability';
console.log(`==========> ${caseName} Test start ==========>`);
let ret = false;
let voiceCapablity = call.hasVoiceCapability();
if(voiceCapablity === true || voiceCapablity === false){
if (voiceCapablity === true || voiceCapablity === false) {
ret = true;
}
expect(ret).assertTrue();
......@@ -62,440 +46,168 @@ export default function callJsunit(){
done();
});
/**
* @tc.number Telephony_Call_AudioDevice_DEVICE_MIC
* @tc.name Enum AudioDevice
* @tc.desc Enum value test
*/
it("Telephony_Call_AudioDevice_DEVICE_MIC",0,async function(done){
let caseName = 'Telephony_Call_AudioDevice_DEVICE_MIC';
console.log(`==========> ${caseName} Test start ==========>`);
if (utils.notCheck) {
expect(true).assertTrue();
done();
return;
}
expect(0).assertEqual(call.AudioDevice.DEVICE_MIC);
console.log(`==========> ${caseName} Test end ==========>`);
done();
});
/**
* @tc.number Telephony_Call_CallTransferType_TRANSFER_TYPE_BUSY
* @tc.name Enum CallTransferType
* @tc.desc Enum value test
*/
it("Telephony_Call_CallTransferType_TRANSFER_TYPE_BUSY",0,async function(done){
let caseName = 'Telephony_Call_CallTransferType_TRANSFER_TYPE_BUSY';
console.log(`==========> ${caseName} Test start ==========>`);
expect(1).assertEqual(call.CallTransferType.TRANSFER_TYPE_BUSY);
console.log(`==========> ${caseName} Test end ==========>`);
done();
});
/**
* @tc.number Telephony_Call_CallTransferSettingType_CALL_TRANSFER_REGISTRATION
* @tc.name Enum CallTransferSettingType
* @tc.desc Enum value test
*/
it("Telephony_Call_CallTransferSettingType_CALL_TRANSFER_REGISTRATION",0,async function(done){
let caseName = 'Telephony_Call_CallTransferSettingType_CALL_TRANSFER_REGISTRATION';
console.log(`==========> ${caseName} Test start ==========>`);
expect(3).assertEqual(call.CallTransferSettingType.CALL_TRANSFER_REGISTRATION);
console.log(`==========> ${caseName} Test end ==========>`);
done();
});
/**
* @tc.number Telephony_Call_CallTransferSettingType_CALL_TRANSFER_ERASURE
* @tc.name Enum CallTransferSettingType
* @tc.desc Enum value test
*/
it("Telephony_Call_CallTransferSettingType_CALL_TRANSFER_ERASURE",0, function(done){
let caseName = 'Telephony_Call_CallTransferSettingType_CALL_TRANSFER_ERASURE';
console.log(`==========> ${caseName} Test start ==========>`);
expect(4).assertEqual(call.CallTransferSettingType.CALL_TRANSFER_ERASURE);
console.log(`==========> ${caseName} Test end ==========>`);
done();
});
/**
* @tc.number Telephony_Call_CallAbilityEventId_EVENT_DIAL_NO_CARRIER
* @tc.name Enum CallAbilityEventId
* @tc.desc Enum value test
*/
it("Telephony_Call_CallAbilityEventId_EVENT_DIAL_NO_CARRIER",0, function(done){
let caseName = 'Telephony_Call_CallAbilityEventId_EVENT_DIAL_NO_CARRIER';
console.log(`==========> ${caseName} Test start ==========>`);
expect(1).assertEqual(call.CallAbilityEventId.EVENT_DIAL_NO_CARRIER);
console.log(`==========> ${caseName} Test end ==========>`);
done();
});
/**
* @tc.number Telephony_Call_CallAbilityEventId_EVENT_INVALID_FDN_NUMBER
* @tc.name Enum CallAbilityEventId
* @tc.desc Enum value test
*/
it("Telephony_Call_CallAbilityEventId_EVENT_INVALID_FDN_NUMBER",0, function(done){
let caseName = 'Telephony_Call_CallAbilityEventId_EVENT_INVALID_FDN_NUMBER';
console.log(`==========> ${caseName} Test start ==========>`);
expect(2).assertEqual(call.CallAbilityEventId.EVENT_INVALID_FDN_NUMBER);
console.log(`==========> ${caseName} Test end ==========>`);
done();
});
/**
* @tc.number Telephony_Call_CallTransferInfo_Type
* @tc.name Interface CallTransferInfo
* @tc.desc Interface value test
*/
* @tc.number Telephony_Call_CallTransferInfo_Type
* @tc.name Interface CallTransferInfo
* @tc.desc Interface value test
*/
it('Telephony_Call_CallTransferInfo_Type', 0, function (done) {
let caseName = 'Telephony_Call_CallTransferInfo_Type';
console.log(`==========> ${caseName} Test start ==========>`);
let callTransferInfo = {transferNum:'10000000001', type: 2, settingType: 1}
let callTransferInfo = {
transferNum: '10000000001', type: 2, settingType: 1
};
expect(callTransferInfo.type === 2).assertTrue();
console.log(`==========> ${caseName} Test end ==========>`);
done();
});
/**
* @tc.number Telephony_Call_CallTransferResult_Status
* @tc.name Interface CallTransferResult
* @tc.desc Interface value test
*/
* @tc.number Telephony_Call_CallTransferResult_Status
* @tc.name Interface CallTransferResult
* @tc.desc Interface value test
*/
it('Telephony_Call_CallTransferResult_Status', 0, function (done) {
let caseName = 'Telephony_Call_CallTransferResult_Status';
console.log(`==========> ${caseName} Test start ==========>`);
let callTransferResult = {status:0, number: '10000000001'}
let callTransferResult = {
status: 0, number: '10000000001'
};
expect(callTransferResult.status === 0).assertTrue();
console.log(`==========> ${caseName} Test end ==========>`);
done();
});
/**
* @tc.number Telephony_Call_CallTransferResult_Number
* @tc.name Interface CallTransferResult
* @tc.desc Interface value test
*/
* @tc.number Telephony_Call_CallTransferResult_Number
* @tc.name Interface CallTransferResult
* @tc.desc Interface value test
*/
it('Telephony_Call_CallTransferResult_Number', 0, function (done) {
let caseName = 'Telephony_Call_CallTransferResult_Number';
console.log(`==========> ${caseName} Test start ==========>`);
let callTransferResult = {status:0, number: '10000000001'}
let callTransferResult = {
status: 0, number: '10000000001'
};
expect(callTransferResult.number === '10000000001').assertTrue();
console.log(`==========> ${caseName} Test end ==========>`);
done();
});
/**
* @tc.number Telephony_Call_CallAttributeOptions_CallId
* @tc.name Interface CallAttributeOptions
* @tc.desc Interface value test
*/
* @tc.number Telephony_Call_CallAttributeOptions_CallId
* @tc.name Interface CallAttributeOptions
* @tc.desc Interface value test
*/
it('Telephony_Call_CallAttributeOptions_CallId', 0, function (done) {
let caseName = 'Telephony_Call_CallAttributeOptions_CallId';
console.log(`==========> ${caseName} Test start ==========>`);
let callAttributeOptions = {callId:1};
let callAttributeOptions = {
callId: 1
};
expect(callAttributeOptions.callId === 1).assertTrue();
console.log(`==========> ${caseName} Test end ==========>`);
done();
});
/**
* @tc.number Telephony_Call_CallRestrictionInfo_Type
* @tc.name Interface CallRestrictionInfo
* @tc.desc Interface value test
*/
* @tc.number Telephony_Call_CallRestrictionInfo_Type
* @tc.name Interface CallRestrictionInfo
* @tc.desc Interface value test
*/
it('Telephony_Call_CallRestrictionInfo_Type', 0, function (done) {
let caseName = 'Telephony_Call_CallRestrictionInfo_Type';
console.log(`==========> ${caseName} Test start ==========>`);
let callRestrictionInfo = {type:0, password: '123456', mode:1}
let callRestrictionInfo = {
type: 0, password: '123456', mode: 1
};
expect(callRestrictionInfo.type === 0).assertTrue();
console.log(`==========> ${caseName} Test end ==========>`);
done();
});
/**
* @tc.number Telephony_Call_CallRestrictionInfo_Mode
* @tc.name Interface CallRestrictionInfo
* @tc.desc Interface value test
*/
* @tc.number Telephony_Call_CallRestrictionInfo_Mode
* @tc.name Interface CallRestrictionInfo
* @tc.desc Interface value test
*/
it('Telephony_Call_CallRestrictionInfo_Mode', 0, function (done) {
let caseName = 'Telephony_Call_CallRestrictionInfo_Mode';
console.log(`==========> ${caseName} Test start ==========>`);
let callRestrictionInfo = {type:0, password: '123456', mode:1}
let callRestrictionInfo = {
type: 0, password: '123456', mode: 1
};
expect(callRestrictionInfo.mode === 1).assertTrue();
console.log(`==========> ${caseName} Test end ==========>`);
done();
});
/**
* @tc.number Telephony_Call_CallEventOptions_EventId
* @tc.name Interface CallEventOptions
* @tc.desc Interface value test
*/
* @tc.number Telephony_Call_CallEventOptions_EventId
* @tc.name Interface CallEventOptions
* @tc.desc Interface value test
*/
it('Telephony_Call_CallEventOptions_EventId', 0, function (done) {
let caseName = 'Telephony_Call_CallEventOptions_EventId';
console.log(`==========> ${caseName} Test start ==========>`);
let callEventOptions = {eventId:1}
let callEventOptions = {
eventId: 1
};
expect(callEventOptions.eventId === 1).assertTrue();
console.log(`==========> ${caseName} Test end ==========>`);
done();
});
/**
* @tc.number Telephony_Call_DisconnectedDetails_NO_ROUTE_TO_DESTINATION
* @tc.name Enum DisconnectedDetails
* @tc.desc Enum value test
*/
it("Telephony_Call_DisconnectedDetails_UNASSIGNED_NUMBER",0,async function(done){
let caseName = 'Telephony_Call_DisconnectedDetails_UNASSIGNED_NUMBER';
console.log(`==========> ${caseName} Test start ==========>`);
if (utils.notCheck) {
expect(true).assertTrue();
done();
return;
}
expect(1).assertEqual(call.DisconnectedDetails.UNASSIGNED_NUMBER);
expect(3).assertEqual(call.DisconnectedDetails.NO_ROUTE_TO_DESTINATION);
console.log(`==========> ${caseName} Test end ==========>`);
done();
});
/**
* @tc.number Telephony_Call_DisconnectedDetails_CHANNEL_UNACCEPTABLE
* @tc.name Enum DisconnectedDetails
* @tc.desc Enum value test
*/
it("Telephony_Call_DisconnectedDetails_CHANNEL_UNACCEPTABLE",0,async function(done){
let caseName = 'Telephony_Call_DisconnectedDetails_CHANNEL_UNACCEPTABLE';
console.log(`==========> ${caseName} Test start ==========>`);
if (utils.notCheck) {
expect(true).assertTrue();
done();
return;
}
expect(6).assertEqual(call.DisconnectedDetails.CHANNEL_UNACCEPTABLE);
expect(8).assertEqual(call.DisconnectedDetails.OPERATOR_DETERMINED_BARRING);
console.log(`==========> ${caseName} Test end ==========>`);
done();
});
/**
* @tc.number Telephony_Call_DisconnectedDetails_NORMAL_CALL_CLEARING
* @tc.name Enum DisconnectedDetails
* @tc.desc Enum value test
*/
it("Telephony_Call_DisconnectedDetails_NORMAL_CALL_CLEARING",0,async function(done){
let caseName = 'Telephony_Call_DisconnectedDetails_NORMAL_CALL_CLEARING';
* @tc.number Telephony_Call_Call_MakeCall_0100
* @tc.name Make a call.
* @tc.desc Function test
*/
it("Telephony_Call_Call_MakeCall_0100", 0, async function (done) {
let caseName: string = "Telephony_Call_Call_MakeCall_0100";
console.log(`==========> ${caseName} Test start ==========>`);
if (utils.notCheck) {
expect(true).assertTrue();
done();
return;
}
expect(16).assertEqual(call.DisconnectedDetails.NORMAL_CALL_CLEARING);
expect(17).assertEqual(call.DisconnectedDetails.USER_BUSY);
console.log(`==========> ${caseName} Test end ==========>`);
done();
});
/**
* @tc.number Telephony_Call_DisconnectedDetails_NO_USER_RESPONDING
* @tc.name Enum DisconnectedDetails
* @tc.desc Enum value test
*/
it("Telephony_Call_DisconnectedDetails_NO_USER_RESPONDING",0,async function(done){
let caseName = 'Telephony_Call_DisconnectedDetails_NO_USER_RESPONDING';
console.log(`==========> ${caseName} Test start ==========>`);
if (utils.notCheck) {
expect(true).assertTrue();
done();
return;
}
expect(18).assertEqual(call.DisconnectedDetails.NO_USER_RESPONDING);
expect(19).assertEqual(call.DisconnectedDetails.USER_ALERTING_NO_ANSWER);
console.log(`==========> ${caseName} Test end ==========>`);
done();
});
/**
* @tc.number Telephony_Call_DisconnectedDetails_CALL_REJECTED
* @tc.name Enum DisconnectedDetails
* @tc.desc Enum value test
*/
it("Telephony_Call_DisconnectedDetails_CALL_REJECTED",0,async function(done){
let caseName = 'Telephony_Call_DisconnectedDetails_CALL_REJECTED';
console.log(`==========> ${caseName} Test start ==========>`);
if (utils.notCheck) {
expect(true).assertTrue();
done();
return;
}
expect(21).assertEqual(call.DisconnectedDetails.CALL_REJECTED);
expect(22).assertEqual(call.DisconnectedDetails.NUMBER_CHANGED);
console.log(`==========> ${caseName} Test end ==========>`);
done();
});
/**
* @tc.number Telephony_Call_DisconnectedDetails_DESTINATION_OUT_OF_ORDER
* @tc.name Enum DisconnectedDetails
* @tc.desc Enum value test
*/
it("Telephony_Call_DisconnectedDetails_DESTINATION_OUT_OF_ORDER",0,async function(done){
let caseName = 'Telephony_Call_DisconnectedDetails_DESTINATION_OUT_OF_ORDER';
console.log(`==========> ${caseName} Test start ==========>`);
if (utils.notCheck) {
expect(true).assertTrue();
done();
return;
}
expect(27).assertEqual(call.DisconnectedDetails.DESTINATION_OUT_OF_ORDER);
expect(28).assertEqual(call.DisconnectedDetails.INVALID_NUMBER_FORMAT);
console.log(`==========> ${caseName} Test end ==========>`);
done();
});
/**
* @tc.number Telephony_Call_DisconnectedDetails_DESTINATION_NETWORK_OUT_OF_ORDER
* @tc.name Enum DisconnectedDetails
* @tc.desc Enum value test
*/
it("Telephony_Call_DisconnectedDetails_DESTINATION_NETWORK_OUT_OF_ORDER",0,async function(done){
let caseName = 'Telephony_Call_DisconnectedDetails_NETWORK_OUT_OF_ORDER';
console.log(`==========> ${caseName} Test start ==========>`);
if (utils.notCheck) {
expect(true).assertTrue();
done();
return;
}
expect(38).assertEqual(call.DisconnectedDetails.NETWORK_OUT_OF_ORDER);
expect(41).assertEqual(call.DisconnectedDetails.TEMPORARY_FAILURE);
console.log(`==========> ${caseName} Test end ==========>`);
done();
});
/**
* @tc.number Telephony_Call_DisconnectedDetails_INVALID_PARAMETER
* @tc.name Enum DisconnectedDetails
* @tc.desc Enum value test
*/
it("Telephony_Call_DisconnectedDetails_INVALID_PARAMETER",0,async function(done){
let caseName = 'Telephony_Call_DisconnectedDetails_INVALID_PARAMETER';
console.log(`==========> ${caseName} Test start ==========>`);
if (utils.notCheck) {
expect(true).assertTrue();
done();
return;
}
expect(1025).assertEqual(call.DisconnectedDetails.INVALID_PARAMETER);
expect(1026).assertEqual(call.DisconnectedDetails.SIM_NOT_EXIT);
console.log(`==========> ${caseName} Test end ==========>`);
done();
});
/**
* @tc.number Telephony_Call_DisconnectedDetails_SIM_PIN_NEED
* @tc.name Enum DisconnectedDetails
* @tc.desc Enum value test
*/
it("Telephony_Call_DisconnectedDetails_SIM_PIN_NEED",0,async function(done){
let caseName = 'Telephony_Call_DisconnectedDetails_SIM_PIN_NEED';
console.log(`==========> ${caseName} Test start ==========>`);
if (utils.notCheck) {
expect(true).assertTrue();
done();
return;
}
expect(1027).assertEqual(call.DisconnectedDetails.SIM_PIN_NEED);
expect(1029).assertEqual(call.DisconnectedDetails.CALL_NOT_ALLOW);
console.log(`==========> ${caseName} Test end ==========>`);
done();
});
/**
* @tc.number Telephony_Call_DisconnectedDetails_SIM_INVALID
* @tc.name Enum DisconnectedDetails
* @tc.desc Enum value test
*/
it("Telephony_Call_DisconnectedDetails_SIM_INVALID",0,async function(done){
let caseName = 'Telephony_Call_DisconnectedDetails_SIM_INVALID';
console.log(`==========> ${caseName} Test start ==========>`);
if (utils.notCheck) {
expect(true).assertTrue();
done();
return;
}
expect(1045).assertEqual(call.DisconnectedDetails.SIM_INVALID);
expect(1045).assertEqual(call.DisconnectedDetails.SIM_INVALID);
console.log(`==========> ${caseName} Test end ==========>`);
done();
});
/**
* @tc.number Telephony_Call_Call_MakeCall_0100
* @tc.name Make a call.
* @tc.desc Function test
*/
it("Telephony_Call_Call_MakeCall_0100",0,async function(done){
let caseName:string = "Telephony_Call_Call_MakeCall_0100";
console.log(`==========> ${caseName} Test start ==========>`);
try{
try {
let telNumber = "";
call.makeCall(telNumber,(error) => {
if(error){
console.log(`${caseName} fail,case success,error:${toString(error)}`);
expect(true).assertTrue();
call.makeCall(telNumber, (error) => {
if (error) {
console.log("makeCall callback: err->" + JSON.stringify(error));
expect(false).assertTrue();
done();
return;
}
expect().assertFail();
console.log(`${caseName} success,case fail`);
done();
});
}catch(err){
console.log(`${caseName} fail,case success,error:${toString(err)}`);
expect(true).assertTrue();
} catch (err) {
console.log("makeCall callback: err->" + JSON.stringify(err));
expect(false).assertTrue();
done();
return;
}
console.log(`==========> ${caseName} Test end ==========>`);
done();
});
/**
* @tc.number Telephony_Call_Call_MakeCall_0200
* @tc.name Makes a call.
* @tc.desc Function test
*/
it("Telephony_Call_Call_MakeCall_0200",0,async function(done){
let caseName:string = "Telephony_Call_Call_MakeCall_0200";
* @tc.number Telephony_Call_Call_MakeCall_0200
* @tc.name Makes a call.
* @tc.desc Function test
*/
it("Telephony_Call_Call_MakeCall_0200", 0, async function (done) {
let caseName: string = "Telephony_Call_Call_MakeCall_0200";
console.log(`==========> ${caseName} Test start ==========>`);
let telNumber = "";
try{
call.makeCall(telNumber).then(()=>{
console.log(`${caseName} success,case fail`);
try {
call.makeCall(telNumber).then(() => {
done();
}).catch(error =>{
console.log(`${caseName} fail,case success,error:${toString(error)}`);
expect(true).assertTrue();
}).catch(error => {
console.log("makeCall callback: err->" + JSON.stringify(error));
expect(false).assertTrue();
done();
return;
});
}catch(err){
console.log(`${caseName} fail,case success,error:${toString(err)}`);
expect(true).assertTrue();
} catch (err) {
console.log("makeCall callback: err->" + JSON.stringify(err));
expect(false).assertTrue();
done();
return;
}
console.log(`==========> ${caseName} Test end ==========>`);
done();
});
});
}
}
\ No newline at end of file
// @ts-nocheck
/**
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 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
......@@ -14,10 +13,11 @@
* limitations under the License.
*/
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'hypium/index'
import convertxml from '@ohos.convertxml'
import { describe, expect, it } from '@ohos/hypium';
import convertxml from '@ohos.convertxml';
export default function convertOptionsJsunit() {
describe('XmlTest_radio_1',function () {
describe('XmlTest_radio_1', function () {
console.log("************* settings Test start*************");
it('Telephony_convertxml_ConvertXML_0100', 0, async function (done) {
var xml =
......@@ -28,30 +28,45 @@ export default function convertOptionsJsunit() {
' <todo>Play</todo>' +
'</note>';
var conv = new convertxml.ConvertXML();
var result1 = JSON.stringify(conv.convert(xml, {compact: false,trim :true}));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",'+
'"encoding":"utf-8"}},'+
'"_elements":[{"_type":"element",'+
'"_name":"note",'+
'"_attributes":{"importance":"high",'+
'"logged":"true"},'+
'"_elements":[{"_type":"element",'+
'"_name":"title",'+
'"_elements":[{"_type":"text",'+
'"_text":"Happy"}]},'+
'{"_type":"element",'+
'"_name":"todo",'+
'"_elements":[{"_type":"text",'+
'"_text":"Work"}]},'+
'{"_type":"element",'+
'"_name":"todo",'+
'"_elements":[{"_type":"text",'+
'"_text":"Play"}]}]}]}'
let options = {
trim: true,
declarationKey: "_declaration",
instructionKey: "_instruction",
attributesKey: "_attributes",
textKey: "_text",
cdataKey: "_cdata",
doctypeKey: "_doctype",
commentKey: "_comment",
parentKey: "_parent",
typeKey: "_type",
nameKey: "_name",
elementsKey: "_elements"
};
var result1 = JSON.stringify(conv.convert(xml, options));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' +
'"encoding":"utf-8"}},' +
'"_elements":[{"_type":"element",' +
'"_name":"note",' +
'"_attributes":{"importance":"high",' +
'"logged":"true"},' +
'"_elements":[{"_type":"element",' +
'"_name":"title",' +
'"_elements":[{"_type":"text",' +
'"_text":"Happy"}]},' +
'{"_type":"element",' +
'"_name":"todo",' +
'"_elements":[{"_type":"text",' +
'"_text":"Work"}]},' +
'{"_type":"element",' +
'"_name":"todo",' +
'"_elements":[{"_type":"text",' +
'"_text":"Play"}]}]}]}';
expect(result1).assertEqual(str1);
expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1);
done();
})
it('Telephony_convertxml_ConvertXML_0200', 0, async function (done) {
it('Telephony_convertxml_ConvertXML_0200', 0, async function (done) {
var xml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
......@@ -60,28 +75,44 @@ export default function convertOptionsJsunit() {
' <todo>Play</todo>' +
'</note>';
var conv = new convertxml.ConvertXML();
var result1 = JSON.stringify(conv.convert(xml, {compact: false, ignoreDeclaration: true}));
var str1 = '{"_elements":[{"_type":"element",'+
'"_name":"note",'+
'"_attributes":{"importance":"high",'+
'"logged":"true"},'+
'"_elements":[{"_type":"element",'+
'"_name":"title",'+
'"_elements":[{"_type":"text",'+
'"_text":"Happy"}]},'+
'{"_type":"element",'+
'"_name":"todo",'+
'"_elements":[{"_type":"text",'+
'"_text":"Work"}]},'+
'{"_type":"element",'+
'"_name":"todo",'+
'"_elements":[{"_type":"text",'+
'"_text":"Play"}]}]}]}'
let options = {
trim: false,
declarationKey: "_declaration",
instructionKey: "_instruction",
attributesKey: "_attributes",
textKey: "_text",
cdataKey: "_cdata",
doctypeKey: "_doctype",
commentKey: "_comment",
parentKey: "_parent",
typeKey: "_type",
nameKey: "_name",
elementsKey: "_elements",
ignoreDeclaration: true
};
var result1 = JSON.stringify(conv.convert(xml, options));
var str1 = '{"_elements":[{"_type":"element",' +
'"_name":"note",' +
'"_attributes":{"importance":"high",' +
'"logged":"true"},' +
'"_elements":[{"_type":"element",' +
'"_name":"title",' +
'"_elements":[{"_type":"text",' +
'"_text":"Happy"}]},' +
'{"_type":"element",' +
'"_name":"todo",' +
'"_elements":[{"_type":"text",' +
'"_text":"Work"}]},' +
'{"_type":"element",' +
'"_name":"todo",' +
'"_elements":[{"_type":"text",' +
'"_text":"Play"}]}]}]}';
expect(result1).assertEqual(str1);
expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1);
done();
})
it('Telephony_convertxml_ConvertXML_0300', 0,async function (done) {
it('Telephony_convertxml_ConvertXML_0300', 0, async function (done) {
var xml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
......@@ -90,24 +121,40 @@ export default function convertOptionsJsunit() {
' <todo>Play</todo>' +
'</note>';
var conv = new convertxml.ConvertXML();
var result1 = JSON.stringify(conv.convert(xml, {compact: false, ignoreDeclaration: true}));
var str1 = '{"_elements":[{"_type":"element",'+
'"_name":"note",'+
'"_attributes":{"importance":"high",'+
'"logged":"true"},'+
'"_elements":[{"_type":"element",'+
'"_name":"title",'+
'"_elements":[{"_type":"text",'+
'"_text":"Happy"}]},'+
'{"_type":"element",'+
'"_name":"todo",'+
'"_elements":[{"_type":"text",'+
'"_text":"Work"}]},'+
'{"_type":"element",'+
'"_name":"todo",'+
'"_elements":[{"_type":"text",'+
'"_text":"Play"}]}]}]}'
let options = {
trim: false,
declarationKey: "_declaration",
instructionKey: "_instruction",
attributesKey: "_attributes",
textKey: "_text",
cdataKey: "_cdata",
doctypeKey: "_doctype",
commentKey: "_comment",
parentKey: "_parent",
typeKey: "_type",
nameKey: "_name",
elementsKey: "_elements",
ignoreDeclaration: true
};
var result1 = JSON.stringify(conv.convert(xml, options));
var str1 = '{"_elements":[{"_type":"element",' +
'"_name":"note",' +
'"_attributes":{"importance":"high",' +
'"logged":"true"},' +
'"_elements":[{"_type":"element",' +
'"_name":"title",' +
'"_elements":[{"_type":"text",' +
'"_text":"Happy"}]},' +
'{"_type":"element",' +
'"_name":"todo",' +
'"_elements":[{"_type":"text",' +
'"_text":"Work"}]},' +
'{"_type":"element",' +
'"_name":"todo",' +
'"_elements":[{"_type":"text",' +
'"_text":"Play"}]}]}]}';
expect(result1).assertEqual(str1);
expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1);
done();
})
......@@ -120,57 +167,89 @@ export default function convertOptionsJsunit() {
' <todo>Play</todo>' +
'</note>';
var conv = new convertxml.ConvertXML();
var result1 = JSON.stringify(conv.convert(xml, {compact: false, ignoreAttributes: true}));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",'+
'"encoding":"utf-8"}},'+
'"_elements":[{"_type":"element",'+
'"_name":"note",'+
'"_elements":[{"_type":"element",'+
'"_name":"title",'+
'"_elements":[{"_type":"text",'+
'"_text":"Happy"}]},'+
'{"_type":"element",'+
'"_name":"todo",'+
'"_elements":[{"_type":"text",'+
'"_text":"Work"}]},'+
'{"_type":"element",'+
'"_name":"todo",'+
'"_elements":[{"_type":"text",'+
'"_text":"Play"}]}]}]}'
let options = {
trim: false,
declarationKey: "_declaration",
instructionKey: "_instruction",
attributesKey: "_attributes",
textKey: "_text",
cdataKey: "_cdata",
doctypeKey: "_doctype",
commentKey: "_comment",
parentKey: "_parent",
typeKey: "_type",
nameKey: "_name",
elementsKey: "_elements",
ignoreAttributes: true
};
var result1 = JSON.stringify(conv.convert(xml, options));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' +
'"encoding":"utf-8"}},' +
'"_elements":[{"_type":"element",' +
'"_name":"note",' +
'"_elements":[{"_type":"element",' +
'"_name":"title",' +
'"_elements":[{"_type":"text",' +
'"_text":"Happy"}]},' +
'{"_type":"element",' +
'"_name":"todo",' +
'"_elements":[{"_type":"text",' +
'"_text":"Work"}]},' +
'{"_type":"element",' +
'"_name":"todo",' +
'"_elements":[{"_type":"text",' +
'"_text":"Play"}]}]}]}';
expect(result1).assertEqual(str1);
expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1);
done();
})
it('Telephony_convertxml_ConvertXML_0500', 0,async function (done) {
it('Telephony_convertxml_ConvertXML_0500', 0, async function (done) {
var xml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
' <!--note-->'+
' <!--note-->' +
' <title>Happy</title>' +
' <todo>Work</todo>' +
' <todo>Play</todo>' +
'</note>';
var conv = new convertxml.ConvertXML();
var result1 = JSON.stringify(conv.convert(xml, {compact: false, ignoreComment: true}));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",'+
'"encoding":"utf-8"}},'+
'"_elements":[{"_type":"element",'+
'"_name":"note",'+
'"_attributes":{"importance":"high",'+
'"logged":"true"},'+
'"_elements":[{"_type":"element",'+
'"_name":"title",'+
'"_elements":[{"_type":"text",'+
'"_text":"Happy"}]},'+
'{"_type":"element",'+
'"_name":"todo",'+
'"_elements":[{"_type":"text",'+
'"_text":"Work"}]},'+
'{"_type":"element",'+
'"_name":"todo",'+
'"_elements":[{"_type":"text",'+
'"_text":"Play"}]}]}]}'
let options = {
trim: false,
declarationKey: "_declaration",
instructionKey: "_instruction",
attributesKey: "_attributes",
textKey: "_text",
cdataKey: "_cdata",
doctypeKey: "_doctype",
commentKey: "_comment",
parentKey: "_parent",
typeKey: "_type",
nameKey: "_name",
elementsKey: "_elements",
ignoreComment: true
};
var result1 = JSON.stringify(conv.convert(xml, options));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' +
'"encoding":"utf-8"}},' +
'"_elements":[{"_type":"element",' +
'"_name":"note",' +
'"_attributes":{"importance":"high",' +
'"logged":"true"},' +
'"_elements":[{"_type":"element",' +
'"_name":"title",' +
'"_elements":[{"_type":"text",' +
'"_text":"Happy"}]},' +
'{"_type":"element",' +
'"_name":"todo",' +
'"_elements":[{"_type":"text",' +
'"_text":"Work"}]},' +
'{"_type":"element",' +
'"_name":"todo",' +
'"_elements":[{"_type":"text",' +
'"_text":"Play"}]}]}]}';
expect(result1).assertEqual(str1);
expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1);
done();
})
......@@ -178,65 +257,97 @@ export default function convertOptionsJsunit() {
var xml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
' <![CDATA[<foo></bar>]]>'+
' <![CDATA[<foo></bar>]]>' +
' <title>Happy</title>' +
' <todo>Work</todo>' +
' <todo>Play</todo>' +
'</note>';
var conv = new convertxml.ConvertXML();
var result1 = JSON.stringify(conv.convert(xml, {compact: false, ignoreCDATA: true}));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",'+
'"encoding":"utf-8"}},'+
'"_elements":[{"_type":"element",'+
'"_name":"note",'+
'"_attributes":{"importance":"high",'+
'"logged":"true"},'+
'"_elements":[{"_type":"element",'+
'"_name":"title",'+
'"_elements":[{"_type":"text",'+
'"_text":"Happy"}]},'+
'{"_type":"element",'+
'"_name":"todo",'+
'"_elements":[{"_type":"text",'+
'"_text":"Work"}]},'+
'{"_type":"element",'+
'"_name":"todo",'+
'"_elements":[{"_type":"text",'+
'"_text":"Play"}]}]}]}'
let options = {
trim: false,
declarationKey: "_declaration",
instructionKey: "_instruction",
attributesKey: "_attributes",
textKey: "_text",
cdataKey: "_cdata",
doctypeKey: "_doctype",
commentKey: "_comment",
parentKey: "_parent",
typeKey: "_type",
nameKey: "_name",
elementsKey: "_elements",
ignoreCDATA: true
};
var result1 = JSON.stringify(conv.convert(xml, options));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' +
'"encoding":"utf-8"}},' +
'"_elements":[{"_type":"element",' +
'"_name":"note",' +
'"_attributes":{"importance":"high",' +
'"logged":"true"},' +
'"_elements":[{"_type":"element",' +
'"_name":"title",' +
'"_elements":[{"_type":"text",' +
'"_text":"Happy"}]},' +
'{"_type":"element",' +
'"_name":"todo",' +
'"_elements":[{"_type":"text",' +
'"_text":"Work"}]},' +
'{"_type":"element",' +
'"_name":"todo",' +
'"_elements":[{"_type":"text",' +
'"_text":"Play"}]}]}]}';
expect(result1).assertEqual(str1);
expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1);
done();
})
it('Telephony_convertxml_ConvertXML_0700', 0, async function (done) {
var xml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<!DOCTYPE foo>'+
'<!DOCTYPE foo>' +
'<note importance="high" logged="true">' +
' <title>Happy</title>' +
' <todo>Work</todo>' +
' <todo>Play</todo>' +
'</note>';
var conv = new convertxml.ConvertXML();
var result1 = JSON.stringify(conv.convert(xml, {compact: false, ignoreDoctype: true}));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",'+
'"encoding":"utf-8"}},'+
'"_elements":[{"_type":"element",'+
'"_name":"note",'+
'"_attributes":{"importance":"high",'+
'"logged":"true"},'+
'"_elements":[{"_type":"element",'+
'"_name":"title",'+
'"_elements":[{"_type":"text",'+
'"_text":"Happy"}]},'+
'{"_type":"element",'+
'"_name":"todo",'+
'"_elements":[{"_type":"text",'+
'"_text":"Work"}]},'+
'{"_type":"element",'+
'"_name":"todo",'+
'"_elements":[{"_type":"text",'+
'"_text":"Play"}]}]}]}'
let options = {
trim: false,
declarationKey: "_declaration",
instructionKey: "_instruction",
attributesKey: "_attributes",
textKey: "_text",
cdataKey: "_cdata",
doctypeKey: "_doctype",
commentKey: "_comment",
parentKey: "_parent",
typeKey: "_type",
nameKey: "_name",
elementsKey: "_elements",
ignoreDoctype: true
};
var result1 = JSON.stringify(conv.convert(xml, options));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' +
'"encoding":"utf-8"}},' +
'"_elements":[{"_type":"element",' +
'"_name":"note",' +
'"_attributes":{"importance":"high",' +
'"logged":"true"},' +
'"_elements":[{"_type":"element",' +
'"_name":"title",' +
'"_elements":[{"_type":"text",' +
'"_text":"Happy"}]},' +
'{"_type":"element",' +
'"_name":"todo",' +
'"_elements":[{"_type":"text",' +
'"_text":"Work"}]},' +
'{"_type":"element",' +
'"_name":"todo",' +
'"_elements":[{"_type":"text",' +
'"_text":"Play"}]}]}]}';
expect(result1).assertEqual(str1);
expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1);
done();
})
......@@ -249,20 +360,36 @@ export default function convertOptionsJsunit() {
' <todo>Play</todo>' +
'</note>';
var conv = new convertxml.ConvertXML();
var result1 = JSON.stringify(conv.convert(xml, {compact: false, ignoreText: true}));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",'+
'"encoding":"utf-8"}},'+
'"_elements":[{"_type":"element",'+
'"_name":"note",'+
'"_attributes":{"importance":"high",'+
'"logged":"true"},'+
'"_elements":[{"_type":"element",'+
'"_name":"title"},'+
'{"_type":"element",'+
'"_name":"todo"},'+
'{"_type":"element",'+
'"_name":"todo"}]}]}'
let options = {
trim: false,
declarationKey: "_declaration",
instructionKey: "_instruction",
attributesKey: "_attributes",
textKey: "_text",
cdataKey: "_cdata",
doctypeKey: "_doctype",
commentKey: "_comment",
parentKey: "_parent",
typeKey: "_type",
nameKey: "_name",
elementsKey: "_elements",
ignoreText: true
};
var result1 = JSON.stringify(conv.convert(xml, options));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' +
'"encoding":"utf-8"}},' +
'"_elements":[{"_type":"element",' +
'"_name":"note",' +
'"_attributes":{"importance":"high",' +
'"logged":"true"},' +
'"_elements":[{"_type":"element",' +
'"_name":"title"},' +
'{"_type":"element",' +
'"_name":"todo"},' +
'{"_type":"element",' +
'"_name":"todo"}]}]}';
expect(result1).assertEqual(str1);
expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1);
done();
})
......@@ -275,26 +402,41 @@ export default function convertOptionsJsunit() {
' <todo>Play</todo>' +
'</note>';
var conv = new convertxml.ConvertXML();
var result1 = JSON.stringify(conv.convert(xml, {compact: false, declarationKey: "123"}));
var str1 = '{"123":{"_attributes":{"version":"1.0",'+
'"encoding":"utf-8"}},'+
'"_elements":[{"_type":"element",'+
'"_name":"note",'+
'"_attributes":{"importance":"high",'+
'"logged":"true"},'+
'"_elements":[{"_type":"element",'+
'"_name":"title",'+
'"_elements":[{"_type":"text",'+
'"_text":"Happy"}]},'+
'{"_type":"element",'+
'"_name":"todo",'+
'"_elements":[{"_type":"text",'+
'"_text":"Work"}]},'+
'{"_type":"element",'+
'"_name":"todo",'+
'"_elements":[{"_type":"text",'+
'"_text":"Play"}]}]}]}'
let options = {
trim: false,
declarationKey: "123",
instructionKey: "_instruction",
attributesKey: "_attributes",
textKey: "_text",
cdataKey: "_cdata",
doctypeKey: "_doctype",
commentKey: "_comment",
parentKey: "_parent",
typeKey: "_type",
nameKey: "_name",
elementsKey: "_elements"
};
var result1 = JSON.stringify(conv.convert(xml, options));
var str1 = '{"123":{"_attributes":{"version":"1.0",' +
'"encoding":"utf-8"}},' +
'"_elements":[{"_type":"element",' +
'"_name":"note",' +
'"_attributes":{"importance":"high",' +
'"logged":"true"},' +
'"_elements":[{"_type":"element",' +
'"_name":"title",' +
'"_elements":[{"_type":"text",' +
'"_text":"Happy"}]},' +
'{"_type":"element",' +
'"_name":"todo",' +
'"_elements":[{"_type":"text",' +
'"_text":"Work"}]},' +
'{"_type":"element",' +
'"_name":"todo",' +
'"_elements":[{"_type":"text",' +
'"_text":"Play"}]}]}]}';
expect(result1).assertEqual(str1);
expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1);
done();
})
......@@ -302,35 +444,50 @@ export default function convertOptionsJsunit() {
var xml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
' <?go there?>'+
' <?go there?>' +
' <title>Happy</title>' +
' <todo>Work</todo>' +
' <todo>Play</todo>' +
'</note>';
var conv = new convertxml.ConvertXML();
var result1 = JSON.stringify(conv.convert(xml, {compact: false, instructionKey: "123"}));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",'+
'"encoding":"utf-8"}},'+
'"_elements":[{"_type":"element",'+
'"_name":"note",'+
'"_attributes":{"importance":"high",'+
'"logged":"true"},'+
'"_elements":[{"123":"there",'+
'"_type":"instruction",'+
'"_name":"go"},'+
'{"_type":"element",'+
'"_name":"title",'+
'"_elements":[{"_type":"text",'+
'"_text":"Happy"}]},'+
'{"_type":"element",'+
'"_name":"todo",'+
'"_elements":[{"_type":"text",'+
'"_text":"Work"}]},'+
'{"_type":"element",'+
'"_name":"todo",'+
'"_elements":[{"_type":"text",'+
'"_text":"Play"}]}]}]}'
let options = {
trim: false,
declarationKey: "_declaration",
instructionKey: "123",
attributesKey: "_attributes",
textKey: "_text",
cdataKey: "_cdata",
doctypeKey: "_doctype",
commentKey: "_comment",
parentKey: "_parent",
typeKey: "_type",
nameKey: "_name",
elementsKey: "_elements"
};
var result1 = JSON.stringify(conv.convert(xml, options));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' +
'"encoding":"utf-8"}},' +
'"_elements":[{"_type":"element",' +
'"_name":"note",' +
'"_attributes":{"importance":"high",' +
'"logged":"true"},' +
'"_elements":[{"123":"there",' +
'"_type":"instruction",' +
'"_name":"go"},' +
'{"_type":"element",' +
'"_name":"title",' +
'"_elements":[{"_type":"text",' +
'"_text":"Happy"}]},' +
'{"_type":"element",' +
'"_name":"todo",' +
'"_elements":[{"_type":"text",' +
'"_text":"Work"}]},' +
'{"_type":"element",' +
'"_name":"todo",' +
'"_elements":[{"_type":"text",' +
'"_text":"Play"}]}]}]}';
expect(result1).assertEqual(str1);
expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1);
done();
})
......@@ -338,35 +495,50 @@ export default function convertOptionsJsunit() {
var xml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
' <?go there?>'+
' <?go there?>' +
' <title>Happy</title>' +
' <todo>Work</todo>' +
' <todo>Play</todo>' +
'</note>';
var conv = new convertxml.ConvertXML();
var result1 = JSON.stringify(conv.convert(xml, {compact: false, attributesKey: "123"}));
var str1 = '{"_declaration":{"123":{"version":"1.0",'+
'"encoding":"utf-8"}},'+
'"_elements":[{"123":{"importance":"high",'+
'"logged":"true"},'+
'"_type":"element",'+
'"_name":"note",'+
'"_elements":[{"_type":"instruction",'+
'"_name":"go",'+
'"_instruction":"there"},'+
'{"_type":"element",'+
'"_name":"title",'+
'"_elements":[{"_type":"text",'+
'"_text":"Happy"}]},'+
'{"_type":"element",'+
'"_name":"todo",'+
'"_elements":[{"_type":"text",'+
'"_text":"Work"}]},'+
'{"_type":"element",'+
'"_name":"todo",'+
'"_elements":[{"_type":"text",'+
'"_text":"Play"}]}]}]}'
let options = {
trim: false,
declarationKey: "_declaration",
instructionKey: "_instruction",
attributesKey: "123",
textKey: "_text",
cdataKey: "_cdata",
doctypeKey: "_doctype",
commentKey: "_comment",
parentKey: "_parent",
typeKey: "_type",
nameKey: "_name",
elementsKey: "_elements"
};
var result1 = JSON.stringify(conv.convert(xml, options));
var str1 = '{"_declaration":{"123":{"version":"1.0",' +
'"encoding":"utf-8"}},' +
'"_elements":[{"123":{"importance":"high",' +
'"logged":"true"},' +
'"_type":"element",' +
'"_name":"note",' +
'"_elements":[{"_type":"instruction",' +
'"_name":"go",' +
'"_instruction":"there"},' +
'{"_type":"element",' +
'"_name":"title",' +
'"_elements":[{"_type":"text",' +
'"_text":"Happy"}]},' +
'{"_type":"element",' +
'"_name":"todo",' +
'"_elements":[{"_type":"text",' +
'"_text":"Work"}]},' +
'{"_type":"element",' +
'"_name":"todo",' +
'"_elements":[{"_type":"text",' +
'"_text":"Play"}]}]}]}';
expect(result1).assertEqual(str1);
expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1);
done();
})
......@@ -379,26 +551,41 @@ export default function convertOptionsJsunit() {
' <todo>Play</todo>' +
'</note>';
var conv = new convertxml.ConvertXML();
var result1 = JSON.stringify(conv.convert(xml, {compact: false, textKey: "123"}));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",'+
'"encoding":"utf-8"}},'+
'"_elements":[{"_type":"element",'+
'"_name":"note",'+
'"_attributes":{"importance":"high",'+
'"logged":"true"},'+
'"_elements":[{"_type":"element",'+
'"_name":"title",'+
'"_elements":[{"123":"Happy",'+
'"_type":"text"}]},'+
'{"_type":"element",'+
'"_name":"todo",'+
'"_elements":[{"123":"Work",'+
'"_type":"text"}]},'+
'{"_type":"element",'+
'"_name":"todo",'+
'"_elements":[{"123":"Play",'+
'"_type":"text"}]}]}]}'
let options = {
trim: false,
declarationKey: "_declaration",
instructionKey: "_instruction",
attributesKey: "_attributes",
textKey: "123",
cdataKey: "_cdata",
doctypeKey: "_doctype",
commentKey: "_comment",
parentKey: "_parent",
typeKey: "_type",
nameKey: "_name",
elementsKey: "_elements"
};
var result1 = JSON.stringify(conv.convert(xml, options));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' +
'"encoding":"utf-8"}},' +
'"_elements":[{"_type":"element",' +
'"_name":"note",' +
'"_attributes":{"importance":"high",' +
'"logged":"true"},' +
'"_elements":[{"_type":"element",' +
'"_name":"title",' +
'"_elements":[{"123":"Happy",' +
'"_type":"text"}]},' +
'{"_type":"element",' +
'"_name":"todo",' +
'"_elements":[{"123":"Work",' +
'"_type":"text"}]},' +
'{"_type":"element",' +
'"_name":"todo",' +
'"_elements":[{"123":"Play",' +
'"_type":"text"}]}]}]}';
expect(result1).assertEqual(str1);
expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1);
done();
})
......@@ -406,102 +593,146 @@ export default function convertOptionsJsunit() {
var xml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
' <![CDATA[1 is < 2]]>'+
' <![CDATA[1 is < 2]]>' +
' <title>Happy</title>' +
' <todo>Work</todo>' +
' <todo>Play</todo>' +
'</note>';
var conv = new convertxml.ConvertXML();
var result1 = JSON.stringify(conv.convert(xml, {compact: false, cdataKey: "123"}));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",'+
'"encoding":"utf-8"}},'+
'"_elements":[{"_type":"element",'+
'"_name":"note",'+
'"_attributes":{"importance":"high",'+
'"logged":"true"},'+
'"_elements":[{"123":"1 is < 2",'+
'"_type":"cdata"},'+
'{"_type":"element",'+
'"_name":"title",'+
'"_elements":[{"_type":"text",'+
'"_text":"Happy"}]},'+
'{"_type":"element",'+
'"_name":"todo",'+
'"_elements":[{"_type":"text",'+
'"_text":"Work"}]},'+
'{"_type":"element",'+
'"_name":"todo",'+
'"_elements":[{"_type":"text",'+
'"_text":"Play"}]}]}]}'
let options = {
trim: false,
declarationKey: "_declaration",
instructionKey: "_instruction",
attributesKey: "_attributes",
textKey: "_text",
cdataKey: "123",
doctypeKey: "_doctype",
commentKey: "_comment",
parentKey: "_parent",
typeKey: "_type",
nameKey: "_name",
elementsKey: "_elements"
};
var result1 = JSON.stringify(conv.convert(xml, options));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' +
'"encoding":"utf-8"}},' +
'"_elements":[{"_type":"element",' +
'"_name":"note",' +
'"_attributes":{"importance":"high",' +
'"logged":"true"},' +
'"_elements":[{"123":"1 is < 2",' +
'"_type":"cdata"},' +
'{"_type":"element",' +
'"_name":"title",' +
'"_elements":[{"_type":"text",' +
'"_text":"Happy"}]},' +
'{"_type":"element",' +
'"_name":"todo",' +
'"_elements":[{"_type":"text",' +
'"_text":"Work"}]},' +
'{"_type":"element",' +
'"_name":"todo",' +
'"_elements":[{"_type":"text",' +
'"_text":"Play"}]}]}]}';
expect(result1).assertEqual(str1);
expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1);
done();
})
it('Telephony_convertxml_ConvertXML_1400', 0, async function (done) {
var xml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<!DOCTYPE foo>'+
'<!DOCTYPE foo>' +
'<note importance="high" logged="true">' +
' <title>Happy</title>' +
' <todo>Work</todo>' +
' <todo>Play</todo>' +
'</note>';
var conv = new convertxml.ConvertXML();
var result1 = JSON.stringify(conv.convert(xml, {compact: false, doctypeKey: 'doctype'}));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",'+
'"encoding":"utf-8"}},'+
'"_elements":[{"_type":"doctype","doctype":"foo"},'+
'{"_type":"element",'+
'"_name":"note",'+
'"_attributes":{"importance":"high",'+
'"logged":"true"},'+
'"_elements":[{"_type":"element",'+
'"_name":"title",'+
'"_elements":[{"_type":"text",'+
'"_text":"Happy"}]},'+
'{"_type":"element",'+
'"_name":"todo",'+
'"_elements":[{"_type":"text",'+
'"_text":"Work"}]},'+
'{"_type":"element",'+
'"_name":"todo",'+
'"_elements":[{"_type":"text",'+
'"_text":"Play"}]}]}]}'
let options = {
trim: false,
declarationKey: "_declaration",
instructionKey: "_instruction",
attributesKey: "_attributes",
textKey: "_text",
cdataKey: "_cdata",
doctypeKey: "doctype",
commentKey: "_comment",
parentKey: "_parent",
typeKey: "_type",
nameKey: "_name",
elementsKey: "_elements"
};
var result1 = JSON.stringify(conv.convert(xml, options));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' +
'"encoding":"utf-8"}},' +
'"_elements":[{"_type":"doctype","doctype":"foo"},' +
'{"_type":"element",' +
'"_name":"note",' +
'"_attributes":{"importance":"high",' +
'"logged":"true"},' +
'"_elements":[{"_type":"element",' +
'"_name":"title",' +
'"_elements":[{"_type":"text",' +
'"_text":"Happy"}]},' +
'{"_type":"element",' +
'"_name":"todo",' +
'"_elements":[{"_type":"text",' +
'"_text":"Work"}]},' +
'{"_type":"element",' +
'"_name":"todo",' +
'"_elements":[{"_type":"text",' +
'"_text":"Play"}]}]}]}';
expect(result1).assertEqual(str1);
console.info("Telephony_convertxml_ConvertXML_1400 result1 :"+result1);
done();
})
it('Telephony_convertxml_ConvertXML_1500', 0, async function (done) {
var xml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<!--note-->'+
'<!--note-->' +
'<note importance="high" logged="true">' +
' <title>Happy</title>' +
' <todo>Work</todo>' +
' <todo>Play</todo>' +
'</note>';
var conv = new convertxml.ConvertXML();
var result1 = JSON.stringify(conv.convert(xml, {compact: false, commentKey: "123"}));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",'+
'"encoding":"utf-8"}},'+
'"_elements":[{"123":"note",'+
'"_type":"comment"},'+
'{"_type":"element",'+
'"_name":"note",'+
'"_attributes":{"importance":"high",'+
'"logged":"true"},'+
'"_elements":[{"_type":"element",'+
'"_name":"title",'+
'"_elements":[{"_type":"text",'+
'"_text":"Happy"}]},'+
'{"_type":"element",'+
'"_name":"todo",'+
'"_elements":[{"_type":"text",'+
'"_text":"Work"}]},'+
'{"_type":"element",'+
'"_name":"todo",'+
'"_elements":[{"_type":"text",'+
'"_text":"Play"}]}]}]}'
let options = {
trim: false,
declarationKey: "_declaration",
instructionKey: "_instruction",
attributesKey: "_attributes",
textKey: "_text",
cdataKey: "_cdata",
doctypeKey: "_doctype",
commentKey: "123",
parentKey: "_parent",
typeKey: "_type",
nameKey: "_name",
elementsKey: "_elements"
};
var result1 = JSON.stringify(conv.convert(xml, options));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' +
'"encoding":"utf-8"}},' +
'"_elements":[{"123":"note",' +
'"_type":"comment"},' +
'{"_type":"element",' +
'"_name":"note",' +
'"_attributes":{"importance":"high",' +
'"logged":"true"},' +
'"_elements":[{"_type":"element",' +
'"_name":"title",' +
'"_elements":[{"_type":"text",' +
'"_text":"Happy"}]},' +
'{"_type":"element",' +
'"_name":"todo",' +
'"_elements":[{"_type":"text",' +
'"_text":"Work"}]},' +
'{"_type":"element",' +
'"_name":"todo",' +
'"_elements":[{"_type":"text",' +
'"_text":"Play"}]}]}]}';
expect(result1).assertEqual(str1);
done();
})
......@@ -510,36 +741,51 @@ export default function convertOptionsJsunit() {
var xml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
' <a><b/></a>'+
' <a><b/></a>' +
' <title>Happy</title>' +
' <todo>Work</todo>' +
' <todo>Play</todo>' +
'</note>';
var conv = new convertxml.ConvertXML();
var result1 = JSON.stringify(conv.convert(xml, {compact: false, parentKey: "123"}));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",'+
'"encoding":"utf-8"}},'+
'"_elements":[{"_type":"element",'+
'"_name":"note",'+
'"_attributes":{"importance":"high",'+
'"logged":"true"},'+
'"_elements":[{"_type":"element",'+
'"_name":"a",'+
'"_elements":[{"_type":"element",'+
'"_name":"b"}]},'+
'{"_type":"element",'+
'"_name":"title",'+
'"_elements":[{"_type":"text",'+
'"_text":"Happy"}]},'+
'{"_type":"element",'+
'"_name":"todo",'+
'"_elements":[{"_type":"text",'+
'"_text":"Work"}]},'+
'{"_type":"element",'+
'"_name":"todo",'+
'"_elements":[{"_type":"text",'+
'"_text":"Play"}]}]}]}'
let options = {
trim: false,
declarationKey: "_declaration",
instructionKey: "_instruction",
attributesKey: "_attributes",
textKey: "_text",
cdataKey: "_cdata",
doctypeKey: "_doctype",
commentKey: "_comment",
parentKey: "123",
typeKey: "_type",
nameKey: "_name",
elementsKey: "_elements"
};
var result1 = JSON.stringify(conv.convert(xml, options));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' +
'"encoding":"utf-8"}},' +
'"_elements":[{"_type":"element",' +
'"_name":"note",' +
'"_attributes":{"importance":"high",' +
'"logged":"true"},' +
'"_elements":[{"_type":"element",' +
'"_name":"a",' +
'"_elements":[{"_type":"element",' +
'"_name":"b"}]},' +
'{"_type":"element",' +
'"_name":"title",' +
'"_elements":[{"_type":"text",' +
'"_text":"Happy"}]},' +
'{"_type":"element",' +
'"_name":"todo",' +
'"_elements":[{"_type":"text",' +
'"_text":"Work"}]},' +
'{"_type":"element",' +
'"_name":"todo",' +
'"_elements":[{"_type":"text",' +
'"_text":"Play"}]}]}]}';
expect(result1).assertEqual(str1);
expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1);
done();
})
......@@ -552,26 +798,41 @@ export default function convertOptionsJsunit() {
' <todo>Play</todo>' +
'</note>';
var conv = new convertxml.ConvertXML();
var result1 = JSON.stringify(conv.convert(xml, {compact: false, typeKey: "123"}));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",'+
'"encoding":"utf-8"}},'+
'"_elements":[{"123":"element",'+
'"_name":"note",'+
'"_attributes":{"importance":"high",'+
'"logged":"true"},'+
'"_elements":[{"123":"element",'+
'"_name":"title",'+
'"_elements":[{"123":"text",'+
'"_text":"Happy"}]},'+
'{"123":"element",'+
'"_name":"todo",'+
'"_elements":[{"123":"text",'+
'"_text":"Work"}]},'+
'{"123":"element",'+
'"_name":"todo",'+
'"_elements":[{"123":"text",'+
'"_text":"Play"}]}]}]}'
let options = {
trim: false,
declarationKey: "_declaration",
instructionKey: "_instruction",
attributesKey: "_attributes",
textKey: "_text",
cdataKey: "_cdata",
doctypeKey: "_doctype",
commentKey: "_comment",
parentKey: "_parent",
typeKey: "123",
nameKey: "_name",
elementsKey: "_elements"
};
var result1 = JSON.stringify(conv.convert(xml, options));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' +
'"encoding":"utf-8"}},' +
'"_elements":[{"123":"element",' +
'"_name":"note",' +
'"_attributes":{"importance":"high",' +
'"logged":"true"},' +
'"_elements":[{"123":"element",' +
'"_name":"title",' +
'"_elements":[{"123":"text",' +
'"_text":"Happy"}]},' +
'{"123":"element",' +
'"_name":"todo",' +
'"_elements":[{"123":"text",' +
'"_text":"Work"}]},' +
'{"123":"element",' +
'"_name":"todo",' +
'"_elements":[{"123":"text",' +
'"_text":"Play"}]}]}]}';
expect(result1).assertEqual(str1);
expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1);
done();
})
......@@ -584,26 +845,41 @@ export default function convertOptionsJsunit() {
' <todo>Play</todo>' +
'</note>';
var conv = new convertxml.ConvertXML();
var result1 = JSON.stringify(conv.convert(xml, {compact: false, nameKey: "123"}));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",'+
'"encoding":"utf-8"}},'+
'"_elements":[{"123":"note",'+
'"_type":"element",'+
'"_attributes":{"importance":"high",'+
'"logged":"true"},'+
'"_elements":[{"123":"title",'+
'"_type":"element",'+
'"_elements":[{"_type":"text",'+
'"_text":"Happy"}]},'+
'{"123":"todo",'+
'"_type":"element",'+
'"_elements":[{"_type":"text",'+
'"_text":"Work"}]},'+
'{"123":"todo",'+
'"_type":"element",'+
'"_elements":[{"_type":"text",'+
'"_text":"Play"}]}]}]}'
let options = {
trim: false,
declarationKey: "_declaration",
instructionKey: "_instruction",
attributesKey: "_attributes",
textKey: "_text",
cdataKey: "_cdata",
doctypeKey: "_doctype",
commentKey: "_comment",
parentKey: "_parent",
typeKey: "_type",
nameKey: "123",
elementsKey: "_elements"
};
var result1 = JSON.stringify(conv.convert(xml, options));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' +
'"encoding":"utf-8"}},' +
'"_elements":[{"123":"note",' +
'"_type":"element",' +
'"_attributes":{"importance":"high",' +
'"logged":"true"},' +
'"_elements":[{"123":"title",' +
'"_type":"element",' +
'"_elements":[{"_type":"text",' +
'"_text":"Happy"}]},' +
'{"123":"todo",' +
'"_type":"element",' +
'"_elements":[{"_type":"text",' +
'"_text":"Work"}]},' +
'{"123":"todo",' +
'"_type":"element",' +
'"_elements":[{"_type":"text",' +
'"_text":"Play"}]}]}]}';
expect(result1).assertEqual(str1);
expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1);
done();
})
......@@ -616,26 +892,41 @@ export default function convertOptionsJsunit() {
' <todo>Play</todo>' +
'</note>';
var conv = new convertxml.ConvertXML();
var result1 = JSON.stringify(conv.convert(xml, {compact: false, elementsKey: "123"}));
var str1 = '{"123":[{"123":[{"123":[{"_type":"text",'+
'"_text":"Happy"}],'+
'"_type":"element",'+
'"_name":"title"},'+
'{"123":[{"_type":"text",'+
'"_text":"Work"}],'+
'"_type":"element",'+
'"_name":"todo"},'+
'{"123":[{"_type":"text",'+
'"_text":"Play"}],'+
'"_type":"element",'+
'"_name":"todo"}],'+
'"_type":"element",'+
'"_name":"note",'+
'"_attributes":{"importance":"high",'+
'"logged":"true"}}],'+
'"_declaration":{"_attributes":{"version":"1.0",'+
'"encoding":"utf-8"}}}'
let options = {
trim: false,
declarationKey: "_declaration",
instructionKey: "_instruction",
attributesKey: "_attributes",
textKey: "_text",
cdataKey: "_cdata",
doctypeKey: "_doctype",
commentKey: "_comment",
parentKey: "_parent",
typeKey: "_type",
nameKey: "_name",
elementsKey: "123"
};
var result1 = JSON.stringify(conv.convert(xml, options));
var str1 = '{"123":[{"123":[{"123":[{"_type":"text",' +
'"_text":"Happy"}],' +
'"_type":"element",' +
'"_name":"title"},' +
'{"123":[{"_type":"text",' +
'"_text":"Work"}],' +
'"_type":"element",' +
'"_name":"todo"},' +
'{"123":[{"_type":"text",' +
'"_text":"Play"}],' +
'"_type":"element",' +
'"_name":"todo"}],' +
'"_type":"element",' +
'"_name":"note",' +
'"_attributes":{"importance":"high",' +
'"logged":"true"}}],' +
'"_declaration":{"_attributes":{"version":"1.0",' +
'"encoding":"utf-8"}}}';
expect(result1).assertEqual(str1);
expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1);
done();
})
......@@ -648,30 +939,45 @@ export default function convertOptionsJsunit() {
' <todo>Play</todo>' +
'</note>';
var conv = new convertxml.ConvertXML();
var result1 = JSON.stringify(conv.convert(xml, {compact: false,trim :true}));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",'+
'"encoding":"utf-8"}},'+
'"_elements":[{"_type":"element",'+
'"_name":"note",'+
'"_attributes":{"importance":"high",'+
'"logged":"true"},'+
'"_elements":[{"_type":"element",'+
'"_name":"title",'+
'"_elements":[{"_type":"text",'+
'"_text":"Happy"}]},'+
'{"_type":"element",'+
'"_name":"todo",'+
'"_elements":[{"_type":"text",'+
'"_text":"Work"}]},'+
'{"_type":"element",'+
'"_name":"todo",'+
'"_elements":[{"_type":"text",'+
'"_text":"Play"}]}]}]}'
let options = {
trim: true,
declarationKey: "_declaration",
instructionKey: "_instruction",
attributesKey: "_attributes",
textKey: "_text",
cdataKey: "_cdata",
doctypeKey: "_doctype",
commentKey: "_comment",
parentKey: "_parent",
typeKey: "_type",
nameKey: "_name",
elementsKey: "_elements"
};
var result1 = JSON.stringify(conv.convert(xml, options));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' +
'"encoding":"utf-8"}},' +
'"_elements":[{"_type":"element",' +
'"_name":"note",' +
'"_attributes":{"importance":"high",' +
'"logged":"true"},' +
'"_elements":[{"_type":"element",' +
'"_name":"title",' +
'"_elements":[{"_type":"text",' +
'"_text":"Happy"}]},' +
'{"_type":"element",' +
'"_name":"todo",' +
'"_elements":[{"_type":"text",' +
'"_text":"Work"}]},' +
'{"_type":"element",' +
'"_name":"todo",' +
'"_elements":[{"_type":"text",' +
'"_text":"Play"}]}]}]}';
expect(result1).assertEqual(str1);
expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1);
done();
})
it('Telephony_convertxml_ConvertXML_2100', 0, async function (done) {
it('Telephony_convertxml_ConvertXML_2100', 0, async function (done) {
var xml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
......@@ -680,28 +986,44 @@ export default function convertOptionsJsunit() {
' <todo>Play</todo>' +
'</note>';
var conv = new convertxml.ConvertXML();
var result1 = JSON.stringify(conv.convert(xml, {compact: false, ignoreDeclaration: true}));
var str1 = '{"_elements":[{"_type":"element",'+
'"_name":"note",'+
'"_attributes":{"importance":"high",'+
'"logged":"true"},'+
'"_elements":[{"_type":"element",'+
'"_name":"title",'+
'"_elements":[{"_type":"text",'+
'"_text":"Happy"}]},'+
'{"_type":"element",'+
'"_name":"todo",'+
'"_elements":[{"_type":"text",'+
'"_text":"Work"}]},'+
'{"_type":"element",'+
'"_name":"todo",'+
'"_elements":[{"_type":"text",'+
'"_text":"Play"}]}]}]}'
let options = {
trim: false,
declarationKey: "_declaration",
instructionKey: "_instruction",
attributesKey: "_attributes",
textKey: "_text",
cdataKey: "_cdata",
doctypeKey: "_doctype",
commentKey: "_comment",
parentKey: "_parent",
typeKey: "_type",
nameKey: "_name",
elementsKey: "_elements",
ignoreDeclaration: true
};
var result1 = JSON.stringify(conv.convert(xml, options));
var str1 = '{"_elements":[{"_type":"element",' +
'"_name":"note",' +
'"_attributes":{"importance":"high",' +
'"logged":"true"},' +
'"_elements":[{"_type":"element",' +
'"_name":"title",' +
'"_elements":[{"_type":"text",' +
'"_text":"Happy"}]},' +
'{"_type":"element",' +
'"_name":"todo",' +
'"_elements":[{"_type":"text",' +
'"_text":"Work"}]},' +
'{"_type":"element",' +
'"_name":"todo",' +
'"_elements":[{"_type":"text",' +
'"_text":"Play"}]}]}]}';
expect(result1).assertEqual(str1);
expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1);
done();
})
it('Telephony_convertxml_ConvertXML_2200', 0,async function (done) {
it('Telephony_convertxml_ConvertXML_2200', 0, async function (done) {
var xml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
......@@ -710,24 +1032,40 @@ export default function convertOptionsJsunit() {
' <todo>Play</todo>' +
'</note>';
var conv = new convertxml.ConvertXML();
var result1 = JSON.stringify(conv.convert(xml, {compact: false, ignoreDeclaration: true}));
var str1 = '{"_elements":[{"_type":"element",'+
'"_name":"note",'+
'"_attributes":{"importance":"high",'+
'"logged":"true"},'+
'"_elements":[{"_type":"element",'+
'"_name":"title",'+
'"_elements":[{"_type":"text",'+
'"_text":"Happy"}]},'+
'{"_type":"element",'+
'"_name":"todo",'+
'"_elements":[{"_type":"text",'+
'"_text":"Work"}]},'+
'{"_type":"element",'+
'"_name":"todo",'+
'"_elements":[{"_type":"text",'+
'"_text":"Play"}]}]}]}'
let options = {
trim: false,
declarationKey: "_declaration",
instructionKey: "_instruction",
attributesKey: "_attributes",
textKey: "_text",
cdataKey: "_cdata",
doctypeKey: "_doctype",
commentKey: "_comment",
parentKey: "_parent",
typeKey: "_type",
nameKey: "_name",
elementsKey: "_elements",
ignoreDeclaration: true
};
var result1 = JSON.stringify(conv.convert(xml, options));
var str1 = '{"_elements":[{"_type":"element",' +
'"_name":"note",' +
'"_attributes":{"importance":"high",' +
'"logged":"true"},' +
'"_elements":[{"_type":"element",' +
'"_name":"title",' +
'"_elements":[{"_type":"text",' +
'"_text":"Happy"}]},' +
'{"_type":"element",' +
'"_name":"todo",' +
'"_elements":[{"_type":"text",' +
'"_text":"Work"}]},' +
'{"_type":"element",' +
'"_name":"todo",' +
'"_elements":[{"_type":"text",' +
'"_text":"Play"}]}]}]}';
expect(result1).assertEqual(str1);
expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1);
done();
})
......@@ -740,57 +1078,89 @@ export default function convertOptionsJsunit() {
' <todo>Play</todo>' +
'</note>';
var conv = new convertxml.ConvertXML();
var result1 = JSON.stringify(conv.convert(xml, {compact: false, ignoreAttributes: true}));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",'+
'"encoding":"utf-8"}},'+
'"_elements":[{"_type":"element",'+
'"_name":"note",'+
'"_elements":[{"_type":"element",'+
'"_name":"title",'+
'"_elements":[{"_type":"text",'+
'"_text":"Happy"}]},'+
'{"_type":"element",'+
'"_name":"todo",'+
'"_elements":[{"_type":"text",'+
'"_text":"Work"}]},'+
'{"_type":"element",'+
'"_name":"todo",'+
'"_elements":[{"_type":"text",'+
'"_text":"Play"}]}]}]}'
let options = {
trim: false,
declarationKey: "_declaration",
instructionKey: "_instruction",
attributesKey: "_attributes",
textKey: "_text",
cdataKey: "_cdata",
doctypeKey: "_doctype",
commentKey: "_comment",
parentKey: "_parent",
typeKey: "_type",
nameKey: "_name",
elementsKey: "_elements",
ignoreAttributes: true
};
var result1 = JSON.stringify(conv.convert(xml, options));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' +
'"encoding":"utf-8"}},' +
'"_elements":[{"_type":"element",' +
'"_name":"note",' +
'"_elements":[{"_type":"element",' +
'"_name":"title",' +
'"_elements":[{"_type":"text",' +
'"_text":"Happy"}]},' +
'{"_type":"element",' +
'"_name":"todo",' +
'"_elements":[{"_type":"text",' +
'"_text":"Work"}]},' +
'{"_type":"element",' +
'"_name":"todo",' +
'"_elements":[{"_type":"text",' +
'"_text":"Play"}]}]}]}';
expect(result1).assertEqual(str1);
expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1);
done();
})
it('Telephony_convertxml_ConvertXML_2400', 0,async function (done) {
it('Telephony_convertxml_ConvertXML_2400', 0, async function (done) {
var xml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
' <!--note-->'+
' <!--note-->' +
' <title>Happy</title>' +
' <todo>Work</todo>' +
' <todo>Play</todo>' +
'</note>';
var conv = new convertxml.ConvertXML();
var result1 = JSON.stringify(conv.convert(xml, {compact: false, ignoreComment: true}));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",'+
'"encoding":"utf-8"}},'+
'"_elements":[{"_type":"element",'+
'"_name":"note",'+
'"_attributes":{"importance":"high",'+
'"logged":"true"},'+
'"_elements":[{"_type":"element",'+
'"_name":"title",'+
'"_elements":[{"_type":"text",'+
'"_text":"Happy"}]},'+
'{"_type":"element",'+
'"_name":"todo",'+
'"_elements":[{"_type":"text",'+
'"_text":"Work"}]},'+
'{"_type":"element",'+
'"_name":"todo",'+
'"_elements":[{"_type":"text",'+
'"_text":"Play"}]}]}]}'
let options = {
trim: false,
declarationKey: "_declaration",
instructionKey: "_instruction",
attributesKey: "_attributes",
textKey: "_text",
cdataKey: "_cdata",
doctypeKey: "_doctype",
commentKey: "_comment",
parentKey: "_parent",
typeKey: "_type",
nameKey: "_name",
elementsKey: "_elements",
ignoreComment: true
};
var result1 = JSON.stringify(conv.convert(xml, options));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' +
'"encoding":"utf-8"}},' +
'"_elements":[{"_type":"element",' +
'"_name":"note",' +
'"_attributes":{"importance":"high",' +
'"logged":"true"},' +
'"_elements":[{"_type":"element",' +
'"_name":"title",' +
'"_elements":[{"_type":"text",' +
'"_text":"Happy"}]},' +
'{"_type":"element",' +
'"_name":"todo",' +
'"_elements":[{"_type":"text",' +
'"_text":"Work"}]},' +
'{"_type":"element",' +
'"_name":"todo",' +
'"_elements":[{"_type":"text",' +
'"_text":"Play"}]}]}]}';
expect(result1).assertEqual(str1);
expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1);
done();
})
......@@ -798,65 +1168,97 @@ export default function convertOptionsJsunit() {
var xml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
' <![CDATA[<foo></bar>]]>'+
' <![CDATA[<foo></bar>]]>' +
' <title>Happy</title>' +
' <todo>Work</todo>' +
' <todo>Play</todo>' +
'</note>';
var conv = new convertxml.ConvertXML();
var result1 = JSON.stringify(conv.convert(xml, {compact: false, ignoreCDATA: true}));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",'+
'"encoding":"utf-8"}},'+
'"_elements":[{"_type":"element",'+
'"_name":"note",'+
'"_attributes":{"importance":"high",'+
'"logged":"true"},'+
'"_elements":[{"_type":"element",'+
'"_name":"title",'+
'"_elements":[{"_type":"text",'+
'"_text":"Happy"}]},'+
'{"_type":"element",'+
'"_name":"todo",'+
'"_elements":[{"_type":"text",'+
'"_text":"Work"}]},'+
'{"_type":"element",'+
'"_name":"todo",'+
'"_elements":[{"_type":"text",'+
'"_text":"Play"}]}]}]}'
let options = {
trim: false,
declarationKey: "_declaration",
instructionKey: "_instruction",
attributesKey: "_attributes",
textKey: "_text",
cdataKey: "_cdata",
doctypeKey: "_doctype",
commentKey: "_comment",
parentKey: "_parent",
typeKey: "_type",
nameKey: "_name",
elementsKey: "_elements",
ignoreCDATA: true
};
var result1 = JSON.stringify(conv.convert(xml, options));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' +
'"encoding":"utf-8"}},' +
'"_elements":[{"_type":"element",' +
'"_name":"note",' +
'"_attributes":{"importance":"high",' +
'"logged":"true"},' +
'"_elements":[{"_type":"element",' +
'"_name":"title",' +
'"_elements":[{"_type":"text",' +
'"_text":"Happy"}]},' +
'{"_type":"element",' +
'"_name":"todo",' +
'"_elements":[{"_type":"text",' +
'"_text":"Work"}]},' +
'{"_type":"element",' +
'"_name":"todo",' +
'"_elements":[{"_type":"text",' +
'"_text":"Play"}]}]}]}';
expect(result1).assertEqual(str1);
expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1);
done();
})
it('Telephony_convertxml_ConvertXML_2600', 0, async function (done) {
var xml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<!DOCTYPE foo>'+
'<!DOCTYPE foo>' +
'<note importance="high" logged="true">' +
' <title>Happy</title>' +
' <todo>Work</todo>' +
' <todo>Play</todo>' +
'</note>';
var conv = new convertxml.ConvertXML();
var result1 = JSON.stringify(conv.convert(xml, {compact: false, ignoreDoctype: true}));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",'+
'"encoding":"utf-8"}},'+
'"_elements":[{"_type":"element",'+
'"_name":"note",'+
'"_attributes":{"importance":"high",'+
'"logged":"true"},'+
'"_elements":[{"_type":"element",'+
'"_name":"title",'+
'"_elements":[{"_type":"text",'+
'"_text":"Happy"}]},'+
'{"_type":"element",'+
'"_name":"todo",'+
'"_elements":[{"_type":"text",'+
'"_text":"Work"}]},'+
'{"_type":"element",'+
'"_name":"todo",'+
'"_elements":[{"_type":"text",'+
'"_text":"Play"}]}]}]}'
let options = {
trim: false,
declarationKey: "_declaration",
instructionKey: "_instruction",
attributesKey: "_attributes",
textKey: "_text",
cdataKey: "_cdata",
doctypeKey: "_doctype",
commentKey: "_comment",
parentKey: "_parent",
typeKey: "_type",
nameKey: "_name",
elementsKey: "_elements",
ignoreDoctype: true
};
var result1 = JSON.stringify(conv.convert(xml, options));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' +
'"encoding":"utf-8"}},' +
'"_elements":[{"_type":"element",' +
'"_name":"note",' +
'"_attributes":{"importance":"high",' +
'"logged":"true"},' +
'"_elements":[{"_type":"element",' +
'"_name":"title",' +
'"_elements":[{"_type":"text",' +
'"_text":"Happy"}]},' +
'{"_type":"element",' +
'"_name":"todo",' +
'"_elements":[{"_type":"text",' +
'"_text":"Work"}]},' +
'{"_type":"element",' +
'"_name":"todo",' +
'"_elements":[{"_type":"text",' +
'"_text":"Play"}]}]}]}';
expect(result1).assertEqual(str1);
expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1);
done();
})
......@@ -869,20 +1271,36 @@ export default function convertOptionsJsunit() {
' <todo>Play</todo>' +
'</note>';
var conv = new convertxml.ConvertXML();
var result1 = JSON.stringify(conv.convert(xml, {compact: false, ignoreText: true}));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",'+
'"encoding":"utf-8"}},'+
'"_elements":[{"_type":"element",'+
'"_name":"note",'+
'"_attributes":{"importance":"high",'+
'"logged":"true"},'+
'"_elements":[{"_type":"element",'+
'"_name":"title"},'+
'{"_type":"element",'+
'"_name":"todo"},'+
'{"_type":"element",'+
'"_name":"todo"}]}]}'
let options = {
trim: false,
declarationKey: "_declaration",
instructionKey: "_instruction",
attributesKey: "_attributes",
textKey: "_text",
cdataKey: "_cdata",
doctypeKey: "_doctype",
commentKey: "_comment",
parentKey: "_parent",
typeKey: "_type",
nameKey: "_name",
elementsKey: "_elements",
ignoreText: true
};
var result1 = JSON.stringify(conv.convert(xml, options));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' +
'"encoding":"utf-8"}},' +
'"_elements":[{"_type":"element",' +
'"_name":"note",' +
'"_attributes":{"importance":"high",' +
'"logged":"true"},' +
'"_elements":[{"_type":"element",' +
'"_name":"title"},' +
'{"_type":"element",' +
'"_name":"todo"},' +
'{"_type":"element",' +
'"_name":"todo"}]}]}';
expect(result1).assertEqual(str1);
expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1);
done();
})
......@@ -895,26 +1313,41 @@ export default function convertOptionsJsunit() {
' <todo>Play</todo>' +
'</note>';
var conv = new convertxml.ConvertXML();
var result1 = JSON.stringify(conv.convert(xml, {compact: false, declarationKey: "456"}));
var str1 = '{"456":{"_attributes":{"version":"1.0",'+
'"encoding":"utf-8"}},'+
'"_elements":[{"_type":"element",'+
'"_name":"note",'+
'"_attributes":{"importance":"high",'+
'"logged":"true"},'+
'"_elements":[{"_type":"element",'+
'"_name":"title",'+
'"_elements":[{"_type":"text",'+
'"_text":"Happy"}]},'+
'{"_type":"element",'+
'"_name":"todo",'+
'"_elements":[{"_type":"text",'+
'"_text":"Work"}]},'+
'{"_type":"element",'+
'"_name":"todo",'+
'"_elements":[{"_type":"text",'+
'"_text":"Play"}]}]}]}'
let options = {
trim: false,
declarationKey: "456",
instructionKey: "_instruction",
attributesKey: "_attributes",
textKey: "_text",
cdataKey: "_cdata",
doctypeKey: "_doctype",
commentKey: "_comment",
parentKey: "_parent",
typeKey: "_type",
nameKey: "_name",
elementsKey: "_elements"
};
var result1 = JSON.stringify(conv.convert(xml, options));
var str1 = '{"456":{"_attributes":{"version":"1.0",' +
'"encoding":"utf-8"}},' +
'"_elements":[{"_type":"element",' +
'"_name":"note",' +
'"_attributes":{"importance":"high",' +
'"logged":"true"},' +
'"_elements":[{"_type":"element",' +
'"_name":"title",' +
'"_elements":[{"_type":"text",' +
'"_text":"Happy"}]},' +
'{"_type":"element",' +
'"_name":"todo",' +
'"_elements":[{"_type":"text",' +
'"_text":"Work"}]},' +
'{"_type":"element",' +
'"_name":"todo",' +
'"_elements":[{"_type":"text",' +
'"_text":"Play"}]}]}]}';
expect(result1).assertEqual(str1);
expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1);
done();
})
......@@ -922,35 +1355,50 @@ export default function convertOptionsJsunit() {
var xml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
' <?go there?>'+
' <?go there?>' +
' <title>Happy</title>' +
' <todo>Work</todo>' +
' <todo>Play</todo>' +
'</note>';
var conv = new convertxml.ConvertXML();
var result1 = JSON.stringify(conv.convert(xml, {compact: false, instructionKey: "456"}));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",'+
'"encoding":"utf-8"}},'+
'"_elements":[{"_type":"element",'+
'"_name":"note",'+
'"_attributes":{"importance":"high",'+
'"logged":"true"},'+
'"_elements":[{"456":"there",'+
'"_type":"instruction",'+
'"_name":"go"},'+
'{"_type":"element",'+
'"_name":"title",'+
'"_elements":[{"_type":"text",'+
'"_text":"Happy"}]},'+
'{"_type":"element",'+
'"_name":"todo",'+
'"_elements":[{"_type":"text",'+
'"_text":"Work"}]},'+
'{"_type":"element",'+
'"_name":"todo",'+
'"_elements":[{"_type":"text",'+
'"_text":"Play"}]}]}]}'
let options = {
trim: false,
declarationKey: "_declaration",
instructionKey: "456",
attributesKey: "_attributes",
textKey: "_text",
cdataKey: "_cdata",
doctypeKey: "_doctype",
commentKey: "_comment",
parentKey: "_parent",
typeKey: "_type",
nameKey: "_name",
elementsKey: "_elements"
};
var result1 = JSON.stringify(conv.convert(xml, options));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' +
'"encoding":"utf-8"}},' +
'"_elements":[{"_type":"element",' +
'"_name":"note",' +
'"_attributes":{"importance":"high",' +
'"logged":"true"},' +
'"_elements":[{"456":"there",' +
'"_type":"instruction",' +
'"_name":"go"},' +
'{"_type":"element",' +
'"_name":"title",' +
'"_elements":[{"_type":"text",' +
'"_text":"Happy"}]},' +
'{"_type":"element",' +
'"_name":"todo",' +
'"_elements":[{"_type":"text",' +
'"_text":"Work"}]},' +
'{"_type":"element",' +
'"_name":"todo",' +
'"_elements":[{"_type":"text",' +
'"_text":"Play"}]}]}]}';
expect(result1).assertEqual(str1);
expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1);
done();
})
......@@ -958,35 +1406,50 @@ export default function convertOptionsJsunit() {
var xml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
' <?go there?>'+
' <?go there?>' +
' <title>Happy</title>' +
' <todo>Work</todo>' +
' <todo>Play</todo>' +
'</note>';
var conv = new convertxml.ConvertXML();
var result1 = JSON.stringify(conv.convert(xml, {compact: false, attributesKey: "456"}));
var str1 = '{"_declaration":{"456":{"version":"1.0",'+
'"encoding":"utf-8"}},'+
'"_elements":[{"456":{"importance":"high",'+
'"logged":"true"},'+
'"_type":"element",'+
'"_name":"note",'+
'"_elements":[{"_type":"instruction",'+
'"_name":"go",'+
'"_instruction":"there"},'+
'{"_type":"element",'+
'"_name":"title",'+
'"_elements":[{"_type":"text",'+
'"_text":"Happy"}]},'+
'{"_type":"element",'+
'"_name":"todo",'+
'"_elements":[{"_type":"text",'+
'"_text":"Work"}]},'+
'{"_type":"element",'+
'"_name":"todo",'+
'"_elements":[{"_type":"text",'+
'"_text":"Play"}]}]}]}'
let options = {
trim: false,
declarationKey: "_declaration",
instructionKey: "_instruction",
attributesKey: "456",
textKey: "_text",
cdataKey: "_cdata",
doctypeKey: "_doctype",
commentKey: "_comment",
parentKey: "_parent",
typeKey: "_type",
nameKey: "_name",
elementsKey: "_elements"
};
var result1 = JSON.stringify(conv.convert(xml, options));
var str1 = '{"_declaration":{"456":{"version":"1.0",' +
'"encoding":"utf-8"}},' +
'"_elements":[{"456":{"importance":"high",' +
'"logged":"true"},' +
'"_type":"element",' +
'"_name":"note",' +
'"_elements":[{"_type":"instruction",' +
'"_name":"go",' +
'"_instruction":"there"},' +
'{"_type":"element",' +
'"_name":"title",' +
'"_elements":[{"_type":"text",' +
'"_text":"Happy"}]},' +
'{"_type":"element",' +
'"_name":"todo",' +
'"_elements":[{"_type":"text",' +
'"_text":"Work"}]},' +
'{"_type":"element",' +
'"_name":"todo",' +
'"_elements":[{"_type":"text",' +
'"_text":"Play"}]}]}]}';
expect(result1).assertEqual(str1);
expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1);
done();
})
......@@ -999,26 +1462,41 @@ export default function convertOptionsJsunit() {
' <todo>Play</todo>' +
'</note>';
var conv = new convertxml.ConvertXML();
var result1 = JSON.stringify(conv.convert(xml, {compact: false, textKey: "456"}));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",'+
'"encoding":"utf-8"}},'+
'"_elements":[{"_type":"element",'+
'"_name":"note",'+
'"_attributes":{"importance":"high",'+
'"logged":"true"},'+
'"_elements":[{"_type":"element",'+
'"_name":"title",'+
'"_elements":[{"456":"Happy",'+
'"_type":"text"}]},'+
'{"_type":"element",'+
'"_name":"todo",'+
'"_elements":[{"456":"Work",'+
'"_type":"text"}]},'+
'{"_type":"element",'+
'"_name":"todo",'+
'"_elements":[{"456":"Play",'+
'"_type":"text"}]}]}]}'
let options = {
trim: false,
declarationKey: "_declaration",
instructionKey: "_instruction",
attributesKey: "_attributes",
textKey: "456",
cdataKey: "_cdata",
doctypeKey: "_doctype",
commentKey: "_comment",
parentKey: "_parent",
typeKey: "_type",
nameKey: "_name",
elementsKey: "_elements"
};
var result1 = JSON.stringify(conv.convert(xml, options));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' +
'"encoding":"utf-8"}},' +
'"_elements":[{"_type":"element",' +
'"_name":"note",' +
'"_attributes":{"importance":"high",' +
'"logged":"true"},' +
'"_elements":[{"_type":"element",' +
'"_name":"title",' +
'"_elements":[{"456":"Happy",' +
'"_type":"text"}]},' +
'{"_type":"element",' +
'"_name":"todo",' +
'"_elements":[{"456":"Work",' +
'"_type":"text"}]},' +
'{"_type":"element",' +
'"_name":"todo",' +
'"_elements":[{"456":"Play",' +
'"_type":"text"}]}]}]}';
expect(result1).assertEqual(str1);
expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1);
done();
})
......@@ -1026,67 +1504,96 @@ export default function convertOptionsJsunit() {
var xml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
' <![CDATA[1 is < 2]]>'+
' <![CDATA[1 is < 2]]>' +
' <title>Happy</title>' +
' <todo>Work</todo>' +
' <todo>Play</todo>' +
'</note>';
var conv = new convertxml.ConvertXML();
var result1 = JSON.stringify(conv.convert(xml, {compact: false, cdataKey: "456"}));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",'+
'"encoding":"utf-8"}},'+
'"_elements":[{"_type":"element",'+
'"_name":"note",'+
'"_attributes":{"importance":"high",'+
'"logged":"true"},'+
'"_elements":[{"456":"1 is < 2",'+
'"_type":"cdata"},'+
'{"_type":"element",'+
'"_name":"title",'+
'"_elements":[{"_type":"text",'+
'"_text":"Happy"}]},'+
'{"_type":"element",'+
'"_name":"todo",'+
'"_elements":[{"_type":"text",'+
'"_text":"Work"}]},'+
'{"_type":"element",'+
'"_name":"todo",'+
'"_elements":[{"_type":"text",'+
'"_text":"Play"}]}]}]}'
let options = {
trim: false,
declarationKey: "_declaration",
instructionKey: "_instruction",
attributesKey: "_attributes",
textKey: "_text",
cdataKey: "456",
doctypeKey: "_doctype",
commentKey: "_comment",
parentKey: "_parent",
typeKey: "_type",
nameKey: "_name",
elementsKey: "_elements"
};
var result1 = JSON.stringify(conv.convert(xml, options));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' +
'"encoding":"utf-8"}},' +
'"_elements":[{"_type":"element",' +
'"_name":"note",' +
'"_attributes":{"importance":"high",' +
'"logged":"true"},' +
'"_elements":[{"456":"1 is < 2",' +
'"_type":"cdata"},' +
'{"_type":"element",' +
'"_name":"title",' +
'"_elements":[{"_type":"text",' +
'"_text":"Happy"}]},' +
'{"_type":"element",' +
'"_name":"todo",' +
'"_elements":[{"_type":"text",' +
'"_text":"Work"}]},' +
'{"_type":"element",' +
'"_name":"todo",' +
'"_elements":[{"_type":"text",' +
'"_text":"Play"}]}]}]}';
expect(result1).assertEqual(str1);
expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1);
done();
})
it('Telephony_convertxml_ConvertXML_3300', 0, async function (done) {
var xml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<!DOCTYPE foo>'+
'<!DOCTYPE foo>' +
'<note importance="high" logged="true">' +
' <title>Happy</title>' +
' <todo>Work</todo>' +
' <todo>Play</todo>' +
'</note>';
var conv = new convertxml.ConvertXML();
var result1 = JSON.stringify(conv.convert(xml, {compact: false, doctypeKey: 'doctype_next'}));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",'+
'"encoding":"utf-8"}},'+
'"_elements":[{"_type":"doctype","doctype_next":"foo"},'+
'{"_type":"element",'+
'"_name":"note",'+
'"_attributes":{"importance":"high",'+
'"logged":"true"},'+
'"_elements":[{"_type":"element",'+
'"_name":"title",'+
'"_elements":[{"_type":"text",'+
'"_text":"Happy"}]},'+
'{"_type":"element",'+
'"_name":"todo",'+
'"_elements":[{"_type":"text",'+
'"_text":"Work"}]},'+
'{"_type":"element",'+
'"_name":"todo",'+
'"_elements":[{"_type":"text",'+
'"_text":"Play"}]}]}]}'
let options = {
trim: false,
declarationKey: "_declaration",
instructionKey: "_instruction",
attributesKey: "_attributes",
textKey: "_text",
cdataKey: "_cdata",
doctypeKey: "doctype_next",
commentKey: "_comment",
parentKey: "_parent",
typeKey: "_type",
nameKey: "_name",
elementsKey: "_elements"
};
var result1 = JSON.stringify(conv.convert(xml, options));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' +
'"encoding":"utf-8"}},' +
'"_elements":[{"_type":"doctype","doctype_next":"foo"},' +
'{"_type":"element",' +
'"_name":"note",' +
'"_attributes":{"importance":"high",' +
'"logged":"true"},' +
'"_elements":[{"_type":"element",' +
'"_name":"title",' +
'"_elements":[{"_type":"text",' +
'"_text":"Happy"}]},' +
'{"_type":"element",' +
'"_name":"todo",' +
'"_elements":[{"_type":"text",' +
'"_text":"Work"}]},' +
'{"_type":"element",' +
'"_name":"todo",' +
'"_elements":[{"_type":"text",' +
'"_text":"Play"}]}]}]}';
expect(result1).assertEqual(str1);
done();
})
......@@ -1094,34 +1601,48 @@ export default function convertOptionsJsunit() {
it('Telephony_convertxml_ConvertXML_3400', 0, async function (done) {
var xml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<!--note-->'+
'<!--note-->' +
'<note importance="high" logged="true">' +
' <title>Happy</title>' +
' <todo>Work</todo>' +
' <todo>Play</todo>' +
'</note>';
var conv = new convertxml.ConvertXML();
var result1 = JSON.stringify(conv.convert(xml, {compact: false, commentKey: "456"}));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",'+
'"encoding":"utf-8"}},'+
'"_elements":[{"456":"note",'+
'"_type":"comment"},'+
'{"_type":"element",'+
'"_name":"note",'+
'"_attributes":{"importance":"high",'+
'"logged":"true"},'+
'"_elements":[{"_type":"element",'+
'"_name":"title",'+
'"_elements":[{"_type":"text",'+
'"_text":"Happy"}]},'+
'{"_type":"element",'+
'"_name":"todo",'+
'"_elements":[{"_type":"text",'+
'"_text":"Work"}]},'+
'{"_type":"element",'+
'"_name":"todo",'+
'"_elements":[{"_type":"text",'+
'"_text":"Play"}]}]}]}'
let options = {
trim: false,
declarationKey: "_declaration",
instructionKey: "_instruction",
attributesKey: "_attributes",
textKey: "_text",
cdataKey: "_cdata",
doctypeKey: "_doctype",
commentKey: "456",
parentKey: "_parent",
typeKey: "_type",
nameKey: "_name",
elementsKey: "_elements"
};
var result1 = JSON.stringify(conv.convert(xml, options));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' +
'"encoding":"utf-8"}},' +
'"_elements":[{"456":"note",' +
'"_type":"comment"},' +
'{"_type":"element",' +
'"_name":"note",' +
'"_attributes":{"importance":"high",' +
'"logged":"true"},' +
'"_elements":[{"_type":"element",' +
'"_name":"title",' +
'"_elements":[{"_type":"text",' +
'"_text":"Happy"}]},' +
'{"_type":"element",' +
'"_name":"todo",' +
'"_elements":[{"_type":"text",' +
'"_text":"Work"}]},' +
'{"_type":"element",' +
'"_name":"todo",' +
'"_elements":[{"_type":"text",' +
'"_text":"Play"}]}]}]}';
expect(result1).assertEqual(str1);
done();
})
......@@ -1130,36 +1651,51 @@ export default function convertOptionsJsunit() {
var xml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
' <a><b/></a>'+
' <a><b/></a>' +
' <title>Happy</title>' +
' <todo>Work</todo>' +
' <todo>Play</todo>' +
'</note>';
var conv = new convertxml.ConvertXML();
var result1 = JSON.stringify(conv.convert(xml, {compact: false, parentKey: "456"}));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",'+
'"encoding":"utf-8"}},'+
'"_elements":[{"_type":"element",'+
'"_name":"note",'+
'"_attributes":{"importance":"high",'+
'"logged":"true"},'+
'"_elements":[{"_type":"element",'+
'"_name":"a",'+
'"_elements":[{"_type":"element",'+
'"_name":"b"}]},'+
'{"_type":"element",'+
'"_name":"title",'+
'"_elements":[{"_type":"text",'+
'"_text":"Happy"}]},'+
'{"_type":"element",'+
'"_name":"todo",'+
'"_elements":[{"_type":"text",'+
'"_text":"Work"}]},'+
'{"_type":"element",'+
'"_name":"todo",'+
'"_elements":[{"_type":"text",'+
'"_text":"Play"}]}]}]}'
let options = {
trim: false,
declarationKey: "_declaration",
instructionKey: "_instruction",
attributesKey: "_attributes",
textKey: "_text",
cdataKey: "_cdata",
doctypeKey: "_doctype",
commentKey: "_comment",
parentKey: "456",
typeKey: "_type",
nameKey: "_name",
elementsKey: "_elements"
};
var result1 = JSON.stringify(conv.convert(xml, options));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' +
'"encoding":"utf-8"}},' +
'"_elements":[{"_type":"element",' +
'"_name":"note",' +
'"_attributes":{"importance":"high",' +
'"logged":"true"},' +
'"_elements":[{"_type":"element",' +
'"_name":"a",' +
'"_elements":[{"_type":"element",' +
'"_name":"b"}]},' +
'{"_type":"element",' +
'"_name":"title",' +
'"_elements":[{"_type":"text",' +
'"_text":"Happy"}]},' +
'{"_type":"element",' +
'"_name":"todo",' +
'"_elements":[{"_type":"text",' +
'"_text":"Work"}]},' +
'{"_type":"element",' +
'"_name":"todo",' +
'"_elements":[{"_type":"text",' +
'"_text":"Play"}]}]}]}';
expect(result1).assertEqual(str1);
expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1);
done();
})
......@@ -1172,26 +1708,41 @@ export default function convertOptionsJsunit() {
' <todo>Play</todo>' +
'</note>';
var conv = new convertxml.ConvertXML();
var result1 = JSON.stringify(conv.convert(xml, {compact: false, typeKey: "123"}));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",'+
'"encoding":"utf-8"}},'+
'"_elements":[{"123":"element",'+
'"_name":"note",'+
'"_attributes":{"importance":"high",'+
'"logged":"true"},'+
'"_elements":[{"123":"element",'+
'"_name":"title",'+
'"_elements":[{"123":"text",'+
'"_text":"Happy"}]},'+
'{"123":"element",'+
'"_name":"todo",'+
'"_elements":[{"123":"text",'+
'"_text":"Work"}]},'+
'{"123":"element",'+
'"_name":"todo",'+
'"_elements":[{"123":"text",'+
'"_text":"Play"}]}]}]}'
let options = {
trim: false,
declarationKey: "_declaration",
instructionKey: "_instruction",
attributesKey: "_attributes",
textKey: "_text",
cdataKey: "_cdata",
doctypeKey: "_doctype",
commentKey: "_comment",
parentKey: "_parent",
typeKey: "123",
nameKey: "_name",
elementsKey: "_elements"
};
var result1 = JSON.stringify(conv.convert(xml, options));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' +
'"encoding":"utf-8"}},' +
'"_elements":[{"123":"element",' +
'"_name":"note",' +
'"_attributes":{"importance":"high",' +
'"logged":"true"},' +
'"_elements":[{"123":"element",' +
'"_name":"title",' +
'"_elements":[{"123":"text",' +
'"_text":"Happy"}]},' +
'{"123":"element",' +
'"_name":"todo",' +
'"_elements":[{"123":"text",' +
'"_text":"Work"}]},' +
'{"123":"element",' +
'"_name":"todo",' +
'"_elements":[{"123":"text",' +
'"_text":"Play"}]}]}]}';
expect(result1).assertEqual(str1);
expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1);
done();
})
......@@ -1204,26 +1755,41 @@ export default function convertOptionsJsunit() {
' <todo>Play</todo>' +
'</note>';
var conv = new convertxml.ConvertXML();
var result1 = JSON.stringify(conv.convert(xml, {compact: false, nameKey: "123"}));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",'+
'"encoding":"utf-8"}},'+
'"_elements":[{"123":"note",'+
'"_type":"element",'+
'"_attributes":{"importance":"high",'+
'"logged":"true"},'+
'"_elements":[{"123":"title",'+
'"_type":"element",'+
'"_elements":[{"_type":"text",'+
'"_text":"Happy"}]},'+
'{"123":"todo",'+
'"_type":"element",'+
'"_elements":[{"_type":"text",'+
'"_text":"Work"}]},'+
'{"123":"todo",'+
'"_type":"element",'+
'"_elements":[{"_type":"text",'+
'"_text":"Play"}]}]}]}'
let options = {
trim: false,
declarationKey: "_declaration",
instructionKey: "_instruction",
attributesKey: "_attributes",
textKey: "_text",
cdataKey: "_cdata",
doctypeKey: "_doctype",
commentKey: "_comment",
parentKey: "_parent",
typeKey: "_type",
nameKey: "123",
elementsKey: "_elements"
};
var result1 = JSON.stringify(conv.convert(xml, options));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' +
'"encoding":"utf-8"}},' +
'"_elements":[{"123":"note",' +
'"_type":"element",' +
'"_attributes":{"importance":"high",' +
'"logged":"true"},' +
'"_elements":[{"123":"title",' +
'"_type":"element",' +
'"_elements":[{"_type":"text",' +
'"_text":"Happy"}]},' +
'{"123":"todo",' +
'"_type":"element",' +
'"_elements":[{"_type":"text",' +
'"_text":"Work"}]},' +
'{"123":"todo",' +
'"_type":"element",' +
'"_elements":[{"_type":"text",' +
'"_text":"Play"}]}]}]}';
expect(result1).assertEqual(str1);
expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1);
done();
})
......@@ -1236,26 +1802,41 @@ export default function convertOptionsJsunit() {
' <todo>Play</todo>' +
'</note>';
var conv = new convertxml.ConvertXML();
var result1 = JSON.stringify(conv.convert(xml, {compact: false, elementsKey: "123"}));
var str1 = '{"123":[{"123":[{"123":[{"_type":"text",'+
'"_text":"Happy"}],'+
'"_type":"element",'+
'"_name":"title"},'+
'{"123":[{"_type":"text",'+
'"_text":"Work"}],'+
'"_type":"element",'+
'"_name":"todo"},'+
'{"123":[{"_type":"text",'+
'"_text":"Play"}],'+
'"_type":"element",'+
'"_name":"todo"}],'+
'"_type":"element",'+
'"_name":"note",'+
'"_attributes":{"importance":"high",'+
'"logged":"true"}}],'+
'"_declaration":{"_attributes":{"version":"1.0",'+
'"encoding":"utf-8"}}}'
let options = {
trim: false,
declarationKey: "_declaration",
instructionKey: "_instruction",
attributesKey: "_attributes",
textKey: "_text",
cdataKey: "_cdata",
doctypeKey: "_doctype",
commentKey: "_comment",
parentKey: "_parent",
typeKey: "_type",
nameKey: "_name",
elementsKey: "123"
};
var result1 = JSON.stringify(conv.convert(xml, options));
var str1 = '{"123":[{"123":[{"123":[{"_type":"text",' +
'"_text":"Happy"}],' +
'"_type":"element",' +
'"_name":"title"},' +
'{"123":[{"_type":"text",' +
'"_text":"Work"}],' +
'"_type":"element",' +
'"_name":"todo"},' +
'{"123":[{"_type":"text",' +
'"_text":"Play"}],' +
'"_type":"element",' +
'"_name":"todo"}],' +
'"_type":"element",' +
'"_name":"note",' +
'"_attributes":{"importance":"high",' +
'"logged":"true"}}],' +
'"_declaration":{"_attributes":{"version":"1.0",' +
'"encoding":"utf-8"}}}';
expect(result1).assertEqual(str1);
expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1);
done();
})
......@@ -1264,37 +1845,54 @@ export default function convertOptionsJsunit() {
* @tc.desc: To convert XML text to JavaScript object.
* @tc.require: AR000GFB5B
*/
it('Telephony_convertxml_ConvertXML_3900', 0, function () {
it('Telephony_convertxml_ConvertXML_3900', 0, function (done) {
var xml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
' <?go there?>'+
' <?go there?>' +
' <title>Happy</title>' +
' <todo>Work</todo>' +
' <todo>Play</todo>' +
'</note>';
var conv = new convertxml.ConvertXML();
var result1 = JSON.stringify(conv.convert(xml, {compact: false, ignoreInstruction: true}));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",'+
'"encoding":"utf-8"}},'+
'"_elements":[{"_type":"element",'+
'"_name":"note",'+
'"_attributes":{"importance":"high",'+
'"logged":"true"},'+
'"_elements":['+
'{"_type":"element",'+
'"_name":"title",'+
'"_elements":[{"_type":"text",'+
'"_text":"Happy"}]},'+
'{"_type":"element",'+
'"_name":"todo",'+
'"_elements":[{"_type":"text",'+
'"_text":"Work"}]},'+
'{"_type":"element",'+
'"_name":"todo",'+
'"_elements":[{"_type":"text",'+
'"_text":"Play"}]}]}]}'
let options = {
trim: false,
declarationKey: "_declaration",
instructionKey: "_instruction",
attributesKey: "_attributes",
textKey: "_text",
cdataKey: "_cdata",
doctypeKey: "_doctype",
commentKey: "_comment",
parentKey: "_parent",
typeKey: "_type",
nameKey: "_name",
elementsKey: "_elements",
ignoreInstruction: true
};
var result1 = JSON.stringify(conv.convert(xml, options));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' +
'"encoding":"utf-8"}},' +
'"_elements":[{"_type":"element",' +
'"_name":"note",' +
'"_attributes":{"importance":"high",' +
'"logged":"true"},' +
'"_elements":[' +
'{"_type":"element",' +
'"_name":"title",' +
'"_elements":[{"_type":"text",' +
'"_text":"Happy"}]},' +
'{"_type":"element",' +
'"_name":"todo",' +
'"_elements":[{"_type":"text",' +
'"_text":"Work"}]},' +
'{"_type":"element",' +
'"_name":"todo",' +
'"_elements":[{"_type":"text",' +
'"_text":"Play"}]}]}]}';
expect(result1).assertEqual(str1);
expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1);
done();
})
})
}
\ No newline at end of file
/**
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Copyright (C) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License")
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
......@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'hypium/index'
import {describe, it, expect} from '@ohos/hypium';
import data from '@ohos.telephony.data';
......@@ -22,7 +22,7 @@ export function toString(data) {
} else {
return data;
}
}
};
export default function dataJsunit() {
describe('dataTest', function () {
......@@ -158,8 +158,6 @@ export default function dataJsunit() {
console.log(`==========> ${caseName} Test end ==========>`);
done();
});
});
}
......
/**
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 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
......@@ -13,16 +13,14 @@
* limitations under the License.
*/
//other import
import convertOptionsJsunit from './ConvertOptionsJsunit.test.ets'
import radioJsunit from './RadioJsunit.test.ets'
import radioSecondJsunit from './RadioSecondJsunit.test.ets'
import smsUiJsunit from './SmsMmsJsunit.test.ets';
import callJsunit from './CallJsunit.test.ets';
import dataJsunit from './DataJsunit.test.ets';
import convertOptionsJsunit from './ConvertOptionsJsunit.test';
import radioJsunit from './RadioJsunit.test';
import radioSecondJsunit from './RadioSecondJsunit.test';
import smsUiJsunit from './SmsMmsJsunit.test';
import callJsunit from './CallJsunit.test';
import dataJsunit from './DataJsunit.test';
export default function testsuite() {
//other
dataJsunit();
smsUiJsunit();
convertOptionsJsunit();
......
// @ts-nocheck
/**
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 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
......@@ -14,228 +13,68 @@
* limitations under the License.
*/
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
import { describe, expect, it } from '@ohos/hypium';
import radio from '@ohos.telephony.radio';
import utils from './Utils.ets'
export default function radioJsunit() {
describe('ActsNetworkSearchTest',function () {
describe('ActsNetworkSearchTest', function () {
const SLOT_2 = -1;
const SLOT_0 = 0;
/**
* @tc.number Telephony_NetworkSearch_getPrimarySlotId_Async_0200
* @tc.name Test getPrimarySlotId(-1) to check the callback result
* @tc.desc Function test
* @tc.number Telephony_NetworkSearch_getPrimarySlotId_Async_0200
* @tc.name Test getPrimarySlotId(-1) to check the callback result
* @tc.desc Function test
*/
it('Telephony_NetworkSearch_getPrimarySlotId_Async_0200', 0, async function (done) {
if(utils.notCheck){
done();
return;
}
radio.getPrimarySlotId((err, data) => {
if (err) {
console.log(`Telephony_NetworkSearch_getPrimarySlotId_Async_0200 fail: ${err}`);
expect(data === undefined).assertTrue();
console.log("Telephony_NetworkSearch_getPrimarySlotId_Async_0200 err:" + JSON.stringify(err));
expect(false).assertTrue();
done();
return;
}
console.log(`Telephony_NetworkSearch_getPrimarySlotId_Async_0200 end data: ${data}`);
expect(data === '').assertTrue();
console.log("Telephony_NetworkSearch_getPrimarySlotId_Async_0200 data:" + JSON.stringify(data));
expect(data == 0 || data == 1).assertTrue();
done();
});
});
/**
* @tc.number Telephony_NetworkSearch_getPrimarySlotId_Async_0300
* @tc.name testGetPrimarySlotId_0300
* @tc.desc Test getPrimarySlotId api by promise.
* @tc.number Telephony_NetworkSearch_getPrimarySlotId_Async_0300
* @tc.name testGetPrimarySlotId_0300
* @tc.desc Test getPrimarySlotId api by promise.
*/
it('Telephony_NetworkSearch_getPrimarySlotId_Promise_0200', 0, async function (done) {
if(utils.notCheck){
done();
return;
}
try {
let data = await radio.getPrimarySlotId();
console.log(`Telephony_NetworkSearch_getPrimarySlotId_Promise_0200 pass data: ${data}`);
expect(true).assertTrue();
} catch (err) {
console.log(`Telephony_NetworkSearch_getPrimarySlotId_Promise_0200 fail err: ${err}`);
expect().assertFail();
done();
return;
}
done();
});
/**
* @tc.number Telephony_NetworkSearch_isNrSupported_Promise_0400
* @tc.name Test The function setPrimarySlotId(0)
* @tc.desc Function test
*/
it('Telephony_NetworkSearch_isNrSupported_Promise_0400', 0, async function (done) {
if(utils.notCheck){
done();
return;
}
try {
await radio.isNrSupported(SLOT_0);
console.log('radio.isNrSupported(SLOT_0) = ' + radio.isNrSupported(SLOT_0));
console.log('Telephony_NetworkSearch_isNrSupported_Promise_0400 success');
let data = await radio.getPrimarySlotId();
console.log("Telephony_NetworkSearch_getPrimarySlotId_Promise_0200 data:" + JSON.stringify(data));
expect(data == 0 || data == 1).assertTrue();
done();
} catch (err) {
console.log(`Telephony_NetworkSearch_isNrSupported_Promise_0400 fail ${err}`);
done();
}
});
/**
* @tc.number Telephony_radio_PreferredNetworkMode_0500
* @tc.name Test The PreferredNetworkMode enum
* @tc.desc Function test
*/
it('Telephony_radio_PreferredNetworkMode_0500', 0, async function (done) {
console.info("Telephony_radio_PreferredNetworkMode_0500 start")
if(utils.notCheck){
done();
return;
}
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_WCDMA === 2).assertTrue();
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_LTE === 3).assertTrue();
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_LTE_WCDMA === 4).assertTrue();
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_LTE_WCDMA_GSM === 5).assertTrue();
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_WCDMA_GSM === 6).assertTrue();
console.info("Telephony_radio_PreferredNetworkMode_0500 end")
done();
});
/**
* @tc.number Telephony_radio_PreferredNetworkMode_0600
* @tc.name Test The PreferredNetworkMode enum
* @tc.desc Function test
*/
it('Telephony_radio_PreferredNetworkMode_0600', 0, async function (done) {
if(utils.notCheck){
console.log("Telephony_NetworkSearch_getPrimarySlotId_Promise_0200 err:" + JSON.stringify(err));
expect(false).assertTrue();
done();
return;
}
console.info("Telephony_radio_PreferredNetworkMode_0600 start")
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_CDMA === 7).assertTrue();
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_EVDO === 8).assertTrue();
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_EVDO_CDMA === 9).assertTrue();
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_WCDMA_GSM_EVDO_CDMA === 10).assertTrue();
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_LTE_EVDO_CDMA === 11).assertTrue();
console.info("Telephony_radio_PreferredNetworkMode_0600 end")
done();
});
/**
* @tc.number Telephony_radio_PreferredNetworkMode_0700
* @tc.name Test The PreferredNetworkMode enum
* @tc.desc Function test
* @tc.number Telephony_NetworkSearch_isNrSupported_Promise_0400
* @tc.name Test The function setPrimarySlotId(0)
* @tc.desc Function test
*/
it('Telephony_radio_PreferredNetworkMode_0700', 0, async function (done) {
if(utils.notCheck){
done();
return;
}
console.info("Telephony_radio_PreferredNetworkMode_0700 start")
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_LTE_WCDMA_GSM_EVDO_CDMA === 12).assertTrue();
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_TDSCDMA === 13).assertTrue();
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_TDSCDMA_GSM === 14).assertTrue();
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_TDSCDMA_WCDMA === 15).assertTrue();
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_TDSCDMA_WCDMA_GSM === 16).assertTrue();
console.info("Telephony_radio_PreferredNetworkMode_0700 end")
done();
});
/**
* @tc.number Telephony_radio_PreferredNetworkMode_0800
* @tc.name Test The PreferredNetworkMode enum
* @tc.desc Function test
*/
it('Telephony_radio_PreferredNetworkMode_0800', 0, async function (done) {
if(utils.notCheck){
done();
return;
}
console.info("Telephony_radio_PreferredNetworkMode_0800 start")
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_LTE_TDSCDMA === 17).assertTrue();
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_LTE_TDSCDMA_GSM === 18).assertTrue();
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_LTE_TDSCDMA_WCDMA === 19).assertTrue();
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_LTE_TDSCDMA_WCDMA_GSM === 20).assertTrue();
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_TDSCDMA_WCDMA_GSM_EVDO_CDMA ===21).assertTrue();
console.info("Telephony_radio_PreferredNetworkMode_0800 end")
done();
});
/**
* @tc.number Telephony_radio_PreferredNetworkMode_0900
* @tc.name Test The PreferredNetworkMode enum
* @tc.desc Function test
*/
it('Telephony_radio_PreferredNetworkMode_0900', 0, async function (done) {
if(utils.notCheck){
done();
return;
}
console.info("Telephony_radio_PreferredNetworkMode_0900 start")
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_LTE_TDSCDMA === 17).assertTrue();
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_LTE_TDSCDMA_GSM === 18).assertTrue();
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_LTE_TDSCDMA_WCDMA === 19).assertTrue();
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_LTE_TDSCDMA_WCDMA_GSM === 20).assertTrue();
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_TDSCDMA_WCDMA_GSM_EVDO_CDMA ===21).assertTrue();
console.info("Telephony_radio_PreferredNetworkMode_0900 end")
done();
});
/**
* @tc.number Telephony_radio_PreferredNetworkMode_1000
* @tc.name Test The PreferredNetworkMode enum
* @tc.desc Function test
*/
it('Telephony_radio_PreferredNetworkMode_1000', 0, async function (done) {
if(utils.notCheck){
it('Telephony_NetworkSearch_isNrSupported_Promise_0400', 0, async function (done) {
try {
let result = radio.isNrSupported();
console.log("Result: " + result);
let result0 = radio.isNrSupported(SLOT_0);
console.log("Result0: " + result0);
done();
return;
}
console.info("Telephony_radio_PreferredNetworkMode_1000 start")
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_LTE_TDSCDMA_WCDMA_GSM_EVDO_CDMA === 22).assertTrue();
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_NR === 31).assertTrue();
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_NR_LTE === 32).assertTrue();
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_NR_LTE_WCDMA === 33).assertTrue();
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_NR_LTE_WCDMA_GSM ===34).assertTrue();
console.info("Telephony_radio_PreferredNetworkMode_1000 end")
done();
});
/**
* @tc.number Telephony_radio_PreferredNetworkMode_1100
* @tc.name Test The PreferredNetworkMode enum
* @tc.desc Function test
*/
it('Telephony_radio_PreferredNetworkMode_1100', 0, async function (done) {
if(utils.notCheck){
} catch (err) {
console.log("Telephony_NetworkSearch_isNrSupported_Promise_0400 err" + JSON.stringify(err));
expect(false).assertTrue();
done();
return;
}
console.info("Telephony_radio_PreferredNetworkMode_1100 start")
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_NR_LTE_EVDO_CDMA === 35).assertTrue();
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_NR_LTE_WCDMA_GSM_EVDO_CDMA === 36).assertTrue();
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_NR_LTE_TDSCDMA === 37).assertTrue();
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_NR_LTE_TDSCDMA_GSM === 38).assertTrue();
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_NR_LTE_TDSCDMA_WCDMA ===39).assertTrue();
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_NR_LTE_TDSCDMA_WCDMA_GSM === 40).assertTrue();
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_NR_LTE_TDSCDMA_WCDMA_GSM_EVDO_CDMA === 41).assertTrue();
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_MAX_VALUE === 99).assertTrue();
console.info("Telephony_radio_PreferredNetworkMode_1100 end")
done();
});
})
}
// @ts-nocheck
/**
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 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
......@@ -13,417 +12,344 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets";
import { describe, expect, it } from '@ohos/hypium';
import radio from '@ohos.telephony.radio';
import utils from './Utils.ets'
export default function radioSecondJsunit() {
describe('radioSecondTest', function () {
const NROPTION_MODE = [
radio.NR_OPTION_UNKNOWN,
radio.NR_OPTION_NSA_ONLY,
radio.NR_OPTION_SA_ONLY,
radio.NR_OPTION_NSA_AND_SA
];
//Network status
let garrNetworkState = [
radio.NETWORK_UNKNOWN,
radio.NETWORK_AVAILABLE,
radio.NETWORK_CURRENT,
radio.NETWORK_FORBIDDEN,
];
//NetworkRadioTech
let garrNetworkRadioTech = [
'UNKNOWN', 'GSM', '1XRTT', 'WCDMA',
'HSPA', 'HSPAP', 'TD_SCDMA', 'EVDO',
'EHRPD', 'LTE', 'LTE_CA', 'IWLAN', 'NR'];
const SLOT_0 = 0;
const SLOT_1 = 5;
const SLOT_2 = 2;
const SLOT_3 = -1;
const NETWORK_TYPES = [
radio.NETWORK_TYPE_UNKNOWN,
radio.NETWORK_TYPE_GSM,
radio.NETWORK_TYPE_CDMA,
radio.NETWORK_TYPE_WCDMA,
radio.NETWORK_TYPE_TDSCDMA,
radio.NETWORK_TYPE_LTE,
radio.NETWORK_TYPE_NR,
radio.NetworkType.NETWORK_TYPE_UNKNOWN,
radio.NetworkType.NETWORK_TYPE_GSM,
radio.NetworkType.NETWORK_TYPE_CDMA,
radio.NetworkType.NETWORK_TYPE_WCDMA,
radio.NetworkType.NETWORK_TYPE_TDSCDMA,
radio.NetworkType.NETWORK_TYPE_LTE,
radio.NetworkType.NETWORK_TYPE_NR,
];
const NETWORK_SIGNAL = [0, 1, 2, 3, 4, 5];
const CELL_LAC_TAC_MAX = 0xffff;
const CELL_CELLID_MAX = 0xfffffff;
const CELL_GSM_CELLID_MAX = 0xffff;
const CELL_ARFCN_MAX = 1023;
const CELL_EARFCN_MAX = 41589;
const CELL_BSIC_MAX = 63;
const CELL_PSC_MAX = 511;
const CELL_PCI_MAX = 503;
const CELL_MCC = 460;
const CELL_MNC_MAX = 20;
const CELL_INFO_MIN = 0;
const TIME_RADIO_TURNON = 10000;
console.log("************* radio Test start*************");
/**
* @tc.number Telephony_NetworkSearch_NetworkState_Async_0100
* @tc.name Test getNrOptionMode() to check the callback result
* @tc.desc Function test
*/
* @tc.number Telephony_NetworkSearch_NetworkState_Async_0100
* @tc.name Test getNrOptionMode() to check the callback result
* @tc.desc Function test
*/
it('Telephony_NetworkSearch_NetworkState_Async_0100', 0, async function (done) {
if (utils.notCheck) {
expect(true).assertTrue();
done();
return;
}
radio.getNetworkState((err, data) => {
if (err) {
console.log(`Telephony_NetworkSearch_NetworkState_Async_0100 get fail err: ${err}`);
expect().assertFail();
console.error("Network unavailable");
expect(false).assertTrue();
done();
return;
}
console.log(`Telephony_NetworkSearch_NetworkState_Async_0100 end data: ${JSON.stringify(data)}`);
if (true) {
console.log(`Telephony_NetworkSearch_getNrOptionMode_Async_0100 1`);
expect(true).assertTrue();
done();
return;
} else {
expect(NROPTION_MODE).assertContain(data);
expect(NROPTION_MODE).assertContain(data.cfgTech);
done();
}
console.log("Telephony_NetworkSearch_NetworkState_Async_0100 end data:" + JSON.stringify(data));
expect(data.longOperatorName === "longOperatorName").assertFalse();
expect(data.shortOperatorName === "shortOperatorName").assertFalse();
expect(data.plmnNumeric === "plmnNumeric").assertFalse();
expect(data.isRoaming === true || data.isRoaming === false).assertTrue();
expect(data.isCaActive === true || data.isCaActive === false).assertTrue();
expect(data.isEmergency === true || data.isEmergency === false).assertTrue();
expect(data.cfgTech === -1).assertFalse();
expect(data.nsaState === -1).assertFalse();
expect(data.regState === -1).assertFalse();
done();
return;
});
})
/**
* @tc.number Telephony_NetworkSearch_NetworkState_Async_0300
* @tc.name testGetNetworkState_0300
* @tc.desc Test getNetworkState api by promise.
* @tc.number Telephony_NetworkSearch_NetworkState_Async_0300
* @tc.name testGetNetworkState_0300
* @tc.desc Test getNetworkState api by promise.
*/
it('Telephony_NetworkSearch_NetworkState_Promise_0100', 0, async function (done) {
if (utils.notCheck) {
expect(true).assertTrue();
done();
return;
}
try {
const result = await radio.getNetworkState();
expect(true).assertTrue();
console.log(`Telephony_NetworkSearch_NetworkState_Promise_0100 test finish.`);
console.log("Telephony_NetworkSearch_NetworkState_Promise_0100 result:" + JSON.stringify(result));
expect(result.longOperatorName === "longOperatorName").assertFalse();
expect(result.shortOperatorName === "shortOperatorName").assertFalse();
expect(result.plmnNumeric === "plmnNumeric").assertFalse();
expect(result.isRoaming === true || result.isRoaming === false).assertTrue();
expect(result.isCaActive === true || result.isCaActive === false).assertTrue();
expect(result.isEmergency === true || result.isEmergency === false).assertTrue();
expect(result.cfgTech === -1).assertFalse();
expect(result.nsaState === -1).assertFalse();
expect(result.regState === -1).assertFalse();
done();
} catch (error) {
console.log(`Telephony_NetworkSearch_NetworkState_Promise_0100 error: ${error.message}`);
expect().assertFail();
console.error("Network unavailable");
expect(false).assertTrue();
done();
}
done();
})
/**
* @tc.number Telephony_NetworkSearch_NetworkState_Async_0200
* @tc.name testGetNetworkState_0200
* @tc.desc Test getNetworkState() api by callback, slotId is 0, to check the callback result
*/
* @tc.number Telephony_NetworkSearch_NetworkState_Async_0200
* @tc.name testGetNetworkState_0200
* @tc.desc Test getNetworkState() api by callback, slotId is 0, to check the callback result
*/
it('Telephony_NetworkSearch_NetworkState_Async_0200', 0, async function (done) {
if (utils.notCheck) {
expect(true).assertTrue();
done();
return;
}
radio.getNetworkState(0, (err, data) => {
if (err) {
console.log(`Telephony_NetworkSearch_NetworkState_Async_0200 get fail err: ${err}`);
expect().assertFail();
console.error("Network unavailable");
expect(false).assertTrue();
done();
return;
}
console.log(`Telephony_NetworkSearch_NetworkState_Async_0200 end data: ${JSON.stringify(data)}`);
expect(true).assertTrue();
console.log("Telephony_NetworkSearch_NetworkState_Async_0200 end data:" + JSON.stringify(data));
expect(data.longOperatorName === "longOperatorName").assertFalse();
expect(data.shortOperatorName === "shortOperatorName").assertFalse();
expect(data.plmnNumeric === "plmnNumeric").assertFalse();
expect(data.isRoaming === true || data.isRoaming === false).assertTrue();
expect(data.isCaActive === true || data.isCaActive === false).assertTrue();
expect(data.isEmergency === true || data.isEmergency === false).assertTrue();
expect(data.cfgTech === -1).assertFalse();
expect(data.nsaState === -1).assertFalse();
expect(data.regState === -1).assertFalse();
done();
return;
});
})
/**
* @tc.number Telephony_NetworkSearch_NetworkState_Async_0400
* @tc.name testGetNetworkState_0400
* @tc.desc Test getNetworkState() api by promise, slotId is 0, to check the callback result
* @tc.number Telephony_NetworkSearch_NetworkState_Async_0400
* @tc.name testGetNetworkState_0400
* @tc.desc Test getNetworkState() api by promise, slotId is 0, to check the callback result
*/
it('Telephony_NetworkSearch_NetworkState_Promise_0200', 0, async function (done) {
if (utils.notCheck) {
expect(true).assertTrue();
done();
return;
}
try {
const result = await radio.getNetworkState(0);
expect(true).assertTrue();
console.log(`Telephony_NetworkSearch_NetworkState_Promise_0200 test finish.`);
console.log("Telephony_NetworkSearch_NetworkState_Promise_0200 result:" + JSON.stringify(result));
expect(result.longOperatorName === "longOperatorName").assertFalse();
expect(result.shortOperatorName === "shortOperatorName").assertFalse();
expect(result.plmnNumeric === "plmnNumeric").assertFalse();
expect(result.isRoaming === true || result.isRoaming === false).assertTrue();
expect(result.isCaActive === true || result.isCaActive === false).assertTrue();
expect(result.isEmergency === true || result.isEmergency === false).assertTrue();
expect(result.cfgTech === -1).assertFalse();
expect(result.nsaState === -1).assertFalse();
expect(result.regState === -1).assertFalse();
done();
} catch (error) {
console.log(`Telephony_NetworkSearch_NetworkState_Promise_0200 error: ${error.message}`);
expect().assertFail();
console.error("Network unavailable");
expect(false).assertTrue();
done();
}
done();
})
/**
* @tc.number Telephony_Radio_CdmaCellInformation_sid_0100
* @tc.name sid
* @tc.desc sid test
* @tc.number Telephony_Radio_CdmaCellInformation_sid_0100
* @tc.name sid
* @tc.desc sid test
*/
it('Telephony_Radio_CdmaCellInformation_sid_0100', 0, async function (done) {
console.log("-----------------------Telephony_Radio_CdmaCellInformation_sid_0100 start-----------------------");
if (utils.notCheck) {
expect(true).assertTrue();
done();
return;
}
let cdmaCellInformatio = {
let cdmaCellInformation = {
baseId: 1,
latitude: 39,
longitude: 116,
nid: 101,
sid: 102
}
expect(101).assertEqual(cdmaCellInformatio.nid);
expect(102).assertEqual(cdmaCellInformatio.sid);
};
expect(101).assertEqual(cdmaCellInformation.nid);
expect(102).assertEqual(cdmaCellInformation.sid);
done();
console.log("-----------------------Telephony_Radio_CdmaCellInformation_sid_0100 end-----------------------");
})
/**
* @tc.number Telephony_NetworkSearch_getRadioTech_Async_0500
* @tc.name TestGetRadioTech_0500
* @tc.desc Test getRadioTech() api by callback .SlotId parameter input is 0
*/
it("Telephony_NetworkSearch_getRadioTech_Async_0500", 0, async function(done){
* @tc.number Telephony_NetworkSearch_getRadioTech_Async_0500
* @tc.name TestGetRadioTech_0500
* @tc.desc Test getRadioTech() api by callback .SlotId parameter input is 0
*/
it("Telephony_NetworkSearch_getRadioTech_Async_0500", 0, async function (done) {
let slotId = 0;
radio.getRadioTech(slotId, (err, data) =>{
expect(JSON.stringify(data) != null).assertTrue();
console.info(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
radio.getRadioTech(slotId, (err, data) => {
if (err) {
console.error("Telephony_NetworkSearch_getRadioTech_Async_0500 err:" + JSON.stringify(err));
expect(true).assertEqual(false);
done();
return;
}
console.error("Telephony_NetworkSearch_getRadioTech_Async_0500 data:" + JSON.stringify(data));
expect(data.psRadioTech === -1).assertFalse();
expect(data.csRadioTech === -1).assertFalse();
done();
});
done();
});
/**
* @tc.number Telephony_NetworkSearch_getRadioTech_Promise_0500
* @tc.name TestGetRadioTech_0500
* @tc.desc SlotId parameter input is 0 ,Test getRadioTech() api by promise
*/
it("Telephony_NetworkSearch_getRadioTech_Promise_0500", 0, async function(done){
* @tc.number Telephony_NetworkSearch_getRadioTech_Promise_0500
* @tc.name TestGetRadioTech_0500
* @tc.desc SlotId parameter input is 0 ,Test getRadioTech() api by promise
*/
it("Telephony_NetworkSearch_getRadioTech_Promise_0500", 0, async function (done) {
let slotId = 0;
let promise = radio.getRadioTech(slotId);
promise.then(data => {
expect(JSON.stringify(data) != null).assertTrue();
console.info(`getRadioTech success, data->${JSON.stringify(data)}`);
console.error("Telephony_NetworkSearch_getRadioTech_Async_0500 data:" + JSON.stringify(data));
expect(data.psRadioTech === -1).assertFalse();
expect(data.csRadioTech === -1).assertFalse();
done();
}).catch(err => {
console.info(`getRadioTech fail, err->${JSON.stringify(err)}`);
console.error("Telephony_NetworkSearch_getRadioTech_Async_0500 err:" + JSON.stringify(err));
expect(true).assertEqual(false);
done();
});
done();
});
/**
* @tc.number Telephony_NetworkSearch_getNetworkSelectionMode_Async_0600
* @tc.name testGetNetworkSelectionMode_0600
* @tc.desc SlotId parameter input is 0, test getNetworkSelectionMode() api by callback.
* @tc.number Telephony_NetworkSearch_getNetworkSelectionMode_Async_0600
* @tc.name testGetNetworkSelectionMode_0600
* @tc.desc SlotId parameter input is 0, test getNetworkSelectionMode() api by callback.
*/
it('Telephony_NetworkSearch_getNetworkSelectionMode_Async_0600', 0, async function (done) {
if (utils.notCheck) {
expect(true).assertTrue();
done();
return;
}
radio.getNetworkSelectionMode(0, (err, res) => {
let slotId = 0;
radio.getNetworkSelectionMode(slotId, (err, data) => {
if (err) {
console.log(`Telephony_NetworkSearch_getNetworkSelectionMode_Async_0600 err: ${err}`);
expect().assertFail();
done();
} else {
console.log('Telephony_NetworkSearch_getNetworkSelectionMode_Async_0600 pass ${res}');
expect(true).assertTrue();
console.error("Telephony_NetworkSearch_getRadioTech_Async_0500 err:" + JSON.stringify(err));
done();
return;
}
console.error("Telephony_NetworkSearch_getRadioTech_Async_0500 data:" + JSON.stringify(data));
expect(data == radio.NetworkSelectionMode.NETWORK_SELECTION_AUTOMATIC ||
data == radio.NetworkSelectionMode.NETWORK_SELECTION_MANUAL ||
data == radio.NetworkSelectionMode.NETWORK_SELECTION_UNKNOWN).assertTrue();
done();
});
done();
});
/**
* @tc.number Telephony_NetworkSearch_getNetworkSelectionMode_Async_0700
* @tc.name testGetNetworkSelectionMode_0700
* @tc.desc SlotId parameter input is 0, test getNetworkSelectionMode() api by promise.
* @tc.number Telephony_NetworkSearch_getNetworkSelectionMode_Async_0700
* @tc.name testGetNetworkSelectionMode_0700
* @tc.desc SlotId parameter input is 0, test getNetworkSelectionMode() api by promise.
*/
it('Telephony_NetworkSearch_getNetworkSelectionMode_Promise_0600', 0, async function (done) {
if (utils.notCheck) {
expect(true).assertTrue();
let slotId = 0;
let promise = radio.getNetworkSelectionMode(slotId);
promise.then(data => {
console.log("getNetworkSelectionMode success, promise: data:" + JSON.stringify(data));
expect(data == radio.NetworkSelectionMode.NETWORK_SELECTION_AUTOMATIC ||
data == radio.NetworkSelectionMode.NETWORK_SELECTION_MANUAL ||
data == radio.NetworkSelectionMode.NETWORK_SELECTION_UNKNOWN).assertTrue();
done();
return;
}
try {
await radio.getNetworkSelectionMode(0);
console.log('Telephony_NetworkSearch_getNetworkSelectionMode_Promise_0600 pass');
expect(true).assertTrue();
} catch (err) {
console.log('Telephony_NetworkSearch_getNetworkSelectionMode_Promise_0600 fail: ${err}');
expect().assertFail();
}).catch(err => {
console.log("getNetworkSelectionMode failed, promise: err:" + JSON.stringify(err));
done();
return;
}
done();
});
done();
});
/**
* @tc.number Telephony_NetworkSearch_getISOCountryCodeForNetwork_Async_0500
* @tc.name testGetISOCountryCodeForNetwork_0500
* @tc.desc SlotId parameter input is 0, test getISOCountryCodeForNetwork() api by callback.
* @tc.number Telephony_NetworkSearch_getISOCountryCodeForNetwork_Async_0500
* @tc.name testGetISOCountryCodeForNetwork_0500
* @tc.desc SlotId parameter input is 0, test getISOCountryCodeForNetwork() api by callback.
*/
it('Telephony_NetworkSearch_getISOCountryCodeForNetwork_Async_0500', 0, async function (done) {
if (utils.notCheck) {
expect(true).assertTrue();
done();
return;
}
radio.getISOCountryCodeForNetwork(0, (err, data) => {
if (err) {
console.log(`Telephony_NetworkSearch_getISOCountryCodeForNetwork_Async_0500 fail err: ${err}`);
expect().assertFail();
console.log("Telephony_NetworkSearch_getISOCountryCodeForNetwork_Async_0500 fail err:" + JSON.stringify(err));
expect(false).assertTrue();
done();
return;
}
console.log(
`Telephony_NetworkSearch_getISOCountryCodeForNetwork_Async_0500 finish data: ${JSON.stringify(data)}`);
expect(true).assertTrue();
"Telephony_NetworkSearch_getISOCountryCodeForNetwork_Async_0500 finish data:" + JSON.stringify(data));
expect(data == undefined).assertFalse();
done();
});
});
/**
* @tc.number Telephony_NetworkSearch_getISOCountryCodeForNetwork_Async_0600
* @tc.name testGetISOCountryCodeForNetwork_0600
* @tc.desc SlotId parameter input is 0, test getISOCountryCodeForNetwork() api by promise.
* @tc.number Telephony_NetworkSearch_getISOCountryCodeForNetwork_Async_0600
* @tc.name testGetISOCountryCodeForNetwork_0600
* @tc.desc SlotId parameter input is 0, test getISOCountryCodeForNetwork() api by promise.
*/
it('Telephony_NetworkSearch_getISOCountryCodeForNetwork_Promise_0500', 0, async function (done) {
if (utils.notCheck) {
expect(true).assertTrue();
done();
return;
}
try {
let data = await radio.getISOCountryCodeForNetwork(0);
console.log(
`Telephony_NetworkSearch_getISOCountryCodeForNetwork_Promise_0500 finish data:${JSON.stringify(data)}`);
expect(true).assertTrue();
"Telephony_NetworkSearch_getISOCountryCodeForNetwork_Async_0500 finish data:" + JSON.stringify(data));
expect(data == undefined).assertFalse();
done();
} catch (err) {
console.log(`Telephony_NetworkSearch_getISOCountryCodeForNetwork_Promise_0500 fail err: ${err}`);
expect().assertFail();
console.log("Telephony_NetworkSearch_getISOCountryCodeForNetwork_Async_0500 fail err:" + JSON.stringify(err));
expect(false).assertTrue();
done();
return;
}
done();
});
/**
* @tc.number Telephony_NetworkSearch_getSignalInformation_Async_0500
* @tc.name testGetSignalInformation_0500
* @tc.desc SlotId parameter input is 0, test getSignalInformation() api by callback.
* @tc.number Telephony_NetworkSearch_getSignalInformation_Async_0500
* @tc.name testGetSignalInformation_0500
* @tc.desc SlotId parameter input is 0, test getSignalInformation() api by callback.
*/
it('Telephony_NetworkSearch_getSignalInformation_Async_0500', 0, async function (done) {
if (utils.notCheck) {
expect(true).assertTrue();
done();
return;
}
radio.getSignalInformation(0, (err, data) => {
if (err) {
console.log(`Telephony_NetworkSearch_getSignalInformation_Async_0500 fail err: ${err}`);
expect().assertFail();
console.log("Telephony_NetworkSearch_getSignalInformation_Async_0500 fail err:" + JSON.stringify(err));
expect(false).assertTrue();
done();
return;
}
console.log(`Telephony_NetworkSearch_getSignalInformation_Async_0500 finish data: ${JSON.stringify(data)}`);
expect(true).assertTrue();
console.log(
"Telephony_NetworkSearch_getSignalInformation_Async_0500 finish data:" + JSON.stringify(data));
expect(data == undefined).assertFalse();
done();
});
});
/**
* @tc.number Telephony_NetworkSearch_getSignalInformation_Async_0600
* @tc.name testGetSignalInformation_0600
* @tc.desc SlotId parameter input is 0, test getSignalInformation() api by promise.
* @tc.number Telephony_NetworkSearch_getSignalInformation_Async_0600
* @tc.name testGetSignalInformation_0600
* @tc.desc SlotId parameter input is 0, test getSignalInformation() api by promise.
*/
it('Telephony_NetworkSearch_getSignalInformation_Promise_0500', 0, async function (done) {
if (utils.notCheck) {
expect(true).assertTrue();
done();
return;
}
try {
let data = await radio.getSignalInformation(0);
console.log(
`Telephony_NetworkSearch_getSignalInformation_Promise_0500 pass data: ${JSON.stringify(data)}`);
expect(true).assertTrue();
"Telephony_NetworkSearch_getSignalInformation_Promise_0500 finish data:" + JSON.stringify(data));
expect(data == undefined).assertFalse();
radio.getCellInformation(0, (err, data) => {
if (!err && data.length > 0) {
assertCellInformation(data);
}
});
done();
} catch (err) {
console.log(`Telephony_NetworkSearch_getSignalInformation_Promise_0500 fail err: ${err}`);
expect().assertFail();
console.log("Telephony_NetworkSearch_getSignalInformation_Promise_0500 fail err:" + JSON.stringify(err));
expect(false).assertTrue();
done();
return;
}
done();
});
console.log("************* radio Test end*************");
function assertCellInformation(data) {
expect(data !== '' && data != undefined && data != null).assertTrue();
expect(data.length).assertLarger(0);
for (let i = 0; i < data.length; i++) {
expect(NETWORK_TYPES).assertContain(data[i].networkType);
expect(data[i].isCamped).assertTrue();
expect(data[i].isCamped == true || data[i].isCamped == false).assertTrue();
expect(data[i].timeStamp).assertLarger(0);
expect(NETWORK_TYPES).assertContain(data[i].signalInformation.signalType);
expect(NETWORK_SIGNAL).assertContain(data[i].signalInformation.signalLevel);
expect(data[i].data != undefined && data[i].data != '' && data[i].data != null).assertTrue();
if (data[0].networkType === radio.NETWORK_TYPE_LTE) {
expect(data[i].data.tac >= CELL_INFO_MIN && data[i].data.tac <= CELL_LAC_TAC_MAX).assertTrue();
expect(data[i].data.cgi >= CELL_INFO_MIN && data[i].data.cgi <= CELL_CELLID_MAX).assertTrue();
expect(data[i].data.earfcn >= CELL_INFO_MIN && data[i].data.earfcn <= CELL_EARFCN_MAX).assertTrue();
expect(data[i].data.pci >= CELL_INFO_MIN && data[i].data.pci <= CELL_PCI_MAX).assertTrue();
expect(data[i].data.mnc >= CELL_INFO_MIN && data[i].data.mnc <= CELL_MNC_MAX).assertTrue();
expect(data[i].data.bandwidth >= CELL_INFO_MIN && data[i].data.bandwidth <= CELL_MNC_MAX).assertTrue();
expect(data[i].data.isSupportEndc >= CELL_INFO_MIN && data[i].data.isSupportEndc <= CELL_MNC_MAX).assertTrue();
expect(data[i].data.mcc).assertEqual(CELL_MCC);
} else if (data[i].networkType === radio.NETWORK_TYPE_WCDMA) {
expect(data[i].data.lac >= CELL_INFO_MIN && data[i].data.lac <= CELL_LAC_TAC_MAX).assertTrue();
expect(data[i].data.cellId >= CELL_INFO_MIN && data[i].data.cellId <= CELL_CELLID_MAX).assertTrue();
expect(data[i].data.uarfcn >= CELL_INFO_MIN && data[i].data.uarfcn <= CELL_ARFCN_MAX).assertTrue();
expect(data[i].data.psc >= CELL_INFO_MIN && data[i].data.psc <= CELL_PSC_MAX).assertTrue();
expect(data[i].data.mnc >= CELL_INFO_MIN && data[i].data.mnc <= CELL_MNC_MAX).assertTrue();
expect(data[i].data.cpid >= CELL_INFO_MIN && data[i].data.cpid <= CELL_MNC_MAX).assertTrue();
expect(data[i].data.mcc).assertEqual(CELL_MCC);
} else if (data[i].networkType === radio.NETWORK_TYPE_GSM) {
expect(data[i].data.lac >= CELL_INFO_MIN && data[i].data.lac <= CELL_LAC_TAC_MAX).assertTrue();
expect(data[i].data.cellId >= CELL_INFO_MIN && data[i].data.cellId <= CELL_GSM_CELLID_MAX).assertTrue();
expect(data[i].data.arfcn >= CELL_INFO_MIN && data[i].data.arfcn <= CELL_ARFCN_MAX).assertTrue();
expect(data[i].data.bsic >= CELL_INFO_MIN && data[i].data.bsic <= CELL_BSIC_MAX).assertTrue();
expect(data[i].data.mnc >= CELL_INFO_MIN && data[i].data.mnc <= CELL_MNC_MAX).assertTrue();
expect(data[i].data.mcc).assertEqual(CELL_MCC);
} else if (data[i].networkType === radio.NETWORK_TYPE_TDSCDMA) {
expect(data[i].data.baseId >= CELL_INFO_MIN && data[i].data.baseId <= CELL_LAC_TAC_MAX).assertTrue();
expect(data[i].data.latitude >= CELL_INFO_MIN && data[i].data.latitude <= CELL_GSM_CELLID_MAX).assertTrue();
expect(data[i].data.longitude >= CELL_INFO_MIN && data[i].data.longitude <= CELL_ARFCN_MAX).assertTrue();
expect(data[i].data.bsic >= CELL_INFO_MIN && data[i].data.bsic <= CELL_BSIC_MAX).assertTrue();
expect(data[i].data.nid >= CELL_INFO_MIN && data[i].data.nid <= CELL_MNC_MAX).assertTrue();
expect(data[i].data.mcc).assertEqual(CELL_MCC);
} else if (data[i].networkType === radio.NETWORK_TYPE_NR) {
expect(data[i].data.nrArfcn >= CELL_INFO_MIN && data[i].data.nrArfcn <= CELL_LAC_TAC_MAX).assertTrue();
expect(data[i].data.tac >= CELL_INFO_MIN && data[i].data.tac <= CELL_GSM_CELLID_MAX).assertTrue();
expect(data[i].data.nci >= CELL_INFO_MIN && data[i].data.nci <= CELL_ARFCN_MAX).assertTrue();
expect(data[i].data.mcc).assertEqual(CELL_MCC);
if (data[i].networkType === radio.NetworkType.NETWORK_TYPE_LTE) {
console.log("radio.NetworkType.NETWORK_TYPE_LTE:" + radio.NetworkType.NETWORK_TYPE_LTE);
} else if (data[i].networkType === radio.NetworkType.NETWORK_TYPE_WCDMA) {
console.log("radio.NetworkType.NETWORK_TYPE_WCDMA:" + radio.NetworkType.NETWORK_TYPE_WCDMA);
} else if (data[i].networkType === radio.NetworkType.NETWORK_TYPE_GSM) {
console.log("radio.NetworkType.NETWORK_TYPE_GSM:" + radio.NetworkType.NETWORK_TYPE_GSM);
} else if (data[i].networkType === radio.NetworkType.NETWORK_TYPE_TDSCDMA) {
console.log("radio.NetworkType.NETWORK_TYPE_TDSCDMA:" + radio.NetworkType.NETWORK_TYPE_TDSCDMA);
} else if (data[i].networkType === radio.NetworkType.NETWORK_TYPE_NR) {
console.log("radio.NetworkType.NETWORK_TYPE_NR:" + radio.NetworkType.NETWORK_TYPE_NR);
} else {
expect().assertFail();
console.log("radio.NetworkType.NETWORK_TYPE_UNKNOWN:" + radio.NetworkType.NETWORK_TYPE_UNKNOWN);
}
}
}
})
......
// @ts-nocheck
/**
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 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
......@@ -13,30 +12,18 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets";
import mms from '@ohos.telephony.sms';
import utils from './Utils.ets'
import { describe, expect, it } from '@ohos/hypium';
import sms from '@ohos.telephony.sms';
export default function smsUiJsunit() {
describe('appInfoTest', function () {
const SMS_SEND_DST_NUMBER = '';
const TRUE_SLOT_ID = 0;
const FALSE_SLOT_ID = 9;
const OTHER_SLOT_ID = 1;
const SECOND_SLOT_ID = 2;
const IDENTIFIER_MIN = 0;
const IDENTIFIER_MAX = 0xFFFF;
const RANTYPE_GSM = 1;
const RANTYPE_CDMA = 2;
const RANTYPE_ERROR = 3;
describe('smsUiJsunit', function () {
var rawArray = [
0x08, 0x91, 0x68, 0x31, 0x08, 0x20, 0x00, 0x75, 0xF4, 0x24, 0x0D, 0x91,
0x68, 0x81, 0x29, 0x56, 0x29, 0x83, 0xF6, 0x00, 0x00, 0x12, 0x40, 0x80,
0x01, 0x02, 0x14, 0x23, 0x02, 0xC1, 0x30
]
];
/*
* @tc.number Telephony_SmsMms_createMessage_Async_0100
* @tc.name Call interface CreateMessage,
......@@ -45,11 +32,6 @@ export default function smsUiJsunit() {
* @tc.desc Function test
*/
it('Telephony_SmsMms_createMessage_Async_0100', 0, async function (done) {
if (true) {
expect(true).assertTrue();
done();
return;
}
sms.createMessage(rawArray, '3gpp', (err, shortMessage) => {
if (err) {
expect().assertFail();
......@@ -57,74 +39,59 @@ export default function smsUiJsunit() {
done();
return;
}
expect(shortMessage.visibleMessageBody === MESSAGEBODY).assertTrue();
expect(shortMessage.visibleRawAddress.length === ADDR_LENGTH).assertTrue();
expect(shortMessage.messageClass === sms.FORWARD_MESSAGE).assertTrue();
expect(shortMessage.protocolId === 0).assertTrue();
expect(shortMessage.scAddress.length === ADDR_LENGTH).assertTrue();
expect(shortMessage.scTimestamp === SC_TIMESTAMP).assertTrue();
console.log("dxj fail shortMessage:" + JSON.stringify(shortMessage));
expect(shortMessage.visibleMessageBody == "Aa").assertTrue();
console.log("dxj fail visibleMessageBody:" + shortMessage.visibleMessageBody);
expect(shortMessage.visibleRawAddress.length !== 0).assertTrue();
console.log("dxj fail visibleRawAddress:" + shortMessage.visibleRawAddress);
expect(shortMessage.messageClass !== -1).assertTrue();
console.log("dxj fail messageClass:" + shortMessage.messageClass);
expect(shortMessage.protocolId !== -1).assertTrue();
console.log("dxj fail protocolId:" + shortMessage.protocolId);
expect(shortMessage.scAddress.length !== 0).assertTrue();
console.log("dxj fail scAddress:" + shortMessage.scAddress);
expect(shortMessage.scTimestamp !== 0).assertTrue();
console.log("dxj fail scTimestamp:" + shortMessage.scTimestamp);
expect(shortMessage.isReplaceMessage).assertFalse();
console.log("dxj fail isReplaceMessage:" + shortMessage.isReplaceMessage);
expect(shortMessage.hasReplyPath).assertFalse();
expect(shortMessage.pdu.length > 0).assertTrue();
expect(shortMessage.status === 0).assertTrue();
console.log("dxj fail hasReplyPath:" + shortMessage.hasReplyPath);
expect(shortMessage.pdu == undefined).assertFalse();
console.log("dxj fail pdu:" + shortMessage.pdu);
expect(shortMessage.status !== -1).assertTrue();
console.log("dxj fail status:" + shortMessage.status);
expect(shortMessage.isSmsStatusReportMessage).assertTrue();
console.log('Telephony_SmsMms_createMessage_Async_0100 finish');
console.log("dxj fail isSmsStatusReportMessage:" + shortMessage.isSmsStatusReportMessage);
done();
});
});
/*
* @tc.number Telephony_SmsMms_createMessage_Async_0300
* @tc.name testCreateMessage_0300
* @tc.desc Call interface CreateMessage,
* pass in the PDU(rawArray) in line with the coding specification, the specification is 3GPP,
* shortMessage Don't empty
*/
/*
* @tc.number Telephony_SmsMms_createMessage_Async_0300
* @tc.name testCreateMessage_0300
* @tc.desc Call interface CreateMessage,
* pass in the PDU(rawArray) in line with the coding specification, the specification is 3GPP,
* shortMessage Don't empty
*/
it('Telephony_SmsMms_createMessage_Promise_0100', 0, async function (done) {
if (true) {
expect(true).assertTrue();
done();
return;
}
sms.createMessage(rawArray, '3gpp').then(shortMessage => {
expect(shortMessage.visibleMessageBody === MESSAGEBODY).assertTrue();
expect(shortMessage.visibleRawAddress.length === ADDR_LENGTH).assertTrue();
expect(shortMessage.messageClass === sms.FORWARD_MESSAGE).assertTrue();
expect(shortMessage.protocolId === 0).assertTrue();
expect(shortMessage.scAddress.length === ADDR_LENGTH).assertTrue();
expect(shortMessage.scTimestamp === SC_TIMESTAMP).assertTrue();
expect(shortMessage.visibleMessageBody == "Aa").assertTrue();
expect(shortMessage.visibleRawAddress.length !== 0).assertTrue();
expect(shortMessage.messageClass !== -1).assertTrue();
expect(shortMessage.protocolId !== -1).assertTrue();
expect(shortMessage.scAddress.length !== 0).assertTrue();
expect(shortMessage.scTimestamp !== 0).assertTrue();
expect(shortMessage.isReplaceMessage).assertFalse();
expect(shortMessage.hasReplyPath).assertFalse();
expect(shortMessage.pdu.length > 0).assertTrue();
expect(shortMessage.status === 0).assertTrue();
expect(shortMessage.pdu == undefined).assertFalse();
expect(shortMessage.status !== -1).assertTrue();
expect(shortMessage.isSmsStatusReportMessage).assertTrue();
console.log('Telephony_SmsMms_createMessage_Promise_0100 finish');
done();
}).catch(err => {
expect().assertFail();
console.log('Telephony_SmsMms_createMessage_Promise_0100 fail');
done();
return;
});
});
/*
* @tc.number Telephony_SmsMms_getSmsEncodingScheme_Async_0100
* @tc.name
* @tc.desc Function test
*/
it('Telephony_SmsMms_getSmsEncodingScheme_Async_0100', 0, async function (done) {
if (true) {
expect(true).assertTrue();
expect().assertFail();
console.log('Telephony_SmsMms_createMessage_Promise_0100 fail' + JSON.stringify(err));
done();
return;
}
expect(sms.SMS_ENCODING_UNKNOWN == 0).assertTrue();
expect(sms.SMS_ENCODING_7BIT == 1).assertTrue();
expect(sms.SMS_ENCODING_8BIT == 2).assertTrue();
expect(sms.SMS_ENCODING_16BIT == 3).assertTrue();
done();
});
});
/*
......@@ -133,18 +100,10 @@ export default function smsUiJsunit() {
* @tc.desc Function test
*/
it('Telephony_SmsMms_getSendSmsResult_Async_0100', 0, async function (done) {
if (true) {
expect(true).assertTrue();
done();
return;
}
expect(sms.SEND_SMS_SUCCESS == 0).assertTrue();
expect(sms.SEND_SMS_FAILURE_UNKNOWN == 1).assertTrue();
expect(sms.SEND_SMS_FAILURE_RADIO_OFF == 2).assertTrue();
expect(sms.SEND_SMS_FAILURE_SERVICE_UNAVAILABLE == 3).assertTrue();
expect(sms.SIM_MESSAGE_STATUS_FREE == 0).assertTrue();
expect(sms.INSTANT_MESSAGE == 1).assertTrue();
expect(sms.OPTIONAL_MESSAGE == 2).assertTrue();
expect(sms.SendSmsResult.SEND_SMS_SUCCESS == 0).assertTrue();
expect(sms.SendSmsResult.SEND_SMS_FAILURE_UNKNOWN == 1).assertTrue();
expect(sms.SendSmsResult.SEND_SMS_FAILURE_RADIO_OFF == 2).assertTrue();
expect(sms.SendSmsResult.SEND_SMS_FAILURE_SERVICE_UNAVAILABLE == 3).assertTrue();
done();
});
......@@ -154,41 +113,11 @@ export default function smsUiJsunit() {
* @tc.desc Function test
*/
it('Telephony_SmsMms_ShortMessageClass_Async_0100', 0, async function (done) {
if (true) {
expect(true).assertTrue();
done();
return;
}
expect(sms.SIM_MESSAGE_STATUS_FREE == 0).assertTrue();
expect(sms.INSTANT_MESSAGE == 1).assertTrue();
expect(sms.OPTIONAL_MESSAGE == 2).assertTrue();
done();
});
/*
* @tc.number Telephony_SmsMms_getMmsCharSets_Async_0100
* @tc.name
* @tc.desc Function test
*/
it('Telephony_SmsMms_getMmsCharSets_Async_0100', 0, async function (done) {
if (true) {
expect(true).assertTrue();
done();
return;
}
expect(sms.BIG5 == 0X07EA).assertTrue();
expect(sms.ISO_10646_UCS_2 == 0X03E8).assertTrue();
expect(sms.ISO_8859_1 == 0X04).assertTrue();
expect(sms.ISO_8859_2 == 0X05).assertTrue();
expect(sms.ISO_8859_3 == 0X06).assertTrue();
expect(sms.ISO_8859_4 == 0X07).assertTrue();
expect(sms.ISO_8859_5 == 0X08).assertTrue();
expect(sms.ISO_8859_6 == 0X09).assertTrue();
expect(sms.ISO_8859_7 == 0X10).assertTrue();
expect(sms.ISO_8859_8 == 0X12).assertTrue();
expect(sms.ISO_8859_9 == 0X13).assertTrue();
expect(sms.SHIFT_JIS == 0X11).assertTrue();
expect(sms.US_ASCII == 0X03).assertTrue();
expect(sms.UTF_8 == 0X6A).assertTrue();
expect(sms.ShortMessageClass.UNKNOWN == 0).assertTrue();
expect(sms.ShortMessageClass.INSTANT_MESSAGE == 1).assertTrue();
expect(sms.ShortMessageClass.OPTIONAL_MESSAGE == 2).assertTrue();
expect(sms.ShortMessageClass.SIM_MESSAGE == 3).assertTrue();
expect(sms.ShortMessageClass.FORWARD_MESSAGE == 4).assertTrue();
done();
});
})
......
// @ts-nocheck
/**
* Copyright (c) 2021 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.
*/
export default class Utils {
static rect_left;
static rect_top;
static rect_right;
static rect_bottom;
static rect_value;
static notCheck = true;
static sleep(time) {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve()
}, time)
}).then(() => {
console.info(`sleep ${time} over...`)
})
}
static getComponentRect(key) {
let strJson = getInspectorByKey(key);
let obj = JSON.parse(strJson);
console.info("[getInspectorByKey] current component obj is: " + JSON.stringify(obj));
let rectInfo = JSON.parse('[' + obj.$rect + ']')
console.info("[getInspectorByKey] rectInfo is: " + rectInfo);
this.rect_left = JSON.parse('[' + rectInfo[0] + ']')[0]
this.rect_top = JSON.parse('[' + rectInfo[0] + ']')[1]
this.rect_right = JSON.parse('[' + rectInfo[1] + ']')[0]
this.rect_bottom = JSON.parse('[' + rectInfo[1] + ']')[1]
return this.rect_value = {
"left": this.rect_left, "top": this.rect_top, "right": this.rect_right, "bottom": this.rect_bottom
}
}
static async swipe(downX, downY, upX, upY, steps) {
console.info('start to swipe')
this.drags(downX, downY, upX, upY, steps, false)
}
static async drag(downX, downY, upX, upY, steps) {
console.info('start to drag')
this.drags(downX, downY, upX, upY, steps, true)
}
static async drags(downX, downY, upX, upY, steps, drag) {
var xStep;
var yStep;
var swipeSteps;
var ret;
xStep = 0;
yStep = 0;
ret = false;
swipeSteps = steps;
if (swipeSteps == 0) {
swipeSteps = 1;
}
xStep = (upX - downX) / swipeSteps;
yStep = (upY - downY) / swipeSteps;
console.info('move step is: ' + 'xStep: ' + xStep + ' yStep: ' + yStep)
var downPonit: TouchObject = {
id: 1,
x: downX,
y: downY,
type: TouchType.Down,
}
console.info('down touch started: ' + JSON.stringify(downPonit))
sendTouchEvent(downPonit);
console.info('start to move')
if (drag) {
await this.sleep(500)
}
for (var i = 1;i <= swipeSteps; i++) {
var movePoint: TouchObject = {
id: 1,
x: downX + (xStep * i),
y: downY + (yStep * i),
type: TouchType.Move
}
console.info('move touch started: ' + JSON.stringify(movePoint))
ret = sendTouchEvent(movePoint)
if (ret == false) {
break;
}
await this.sleep(5)
}
console.info('start to up')
if (drag) {
await this.sleep(100)
}
var upPoint: TouchObject = {
id: 1,
x: upX,
y: upY,
type: TouchType.Up,
}
console.info('up touch started: ' + JSON.stringify(upPoint))
sendTouchEvent(upPoint)
await this.sleep(500)
}
}
/**
* Copyright (C) 2021 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.
*/
// sim slot id
export const DEFAULT_SLOTID = 0;
export const SLOTID3 = 3;
export const SLOTID2 = 2;
export const SLOTID_MINUS1 = -1;
// sim correct password
export const CORRECT_PIN = '1234';
export const CORRECT_PIN2 = '18099014';
// sim incorrect password
export const INCORRECT_PIN = '134679';
export const INCORRECT_PIN_LEN3 = '123';
export const INCORRECT_PUK = '134679';
export const INCORRECT_PIN2 = '134679';
export const INCORRECT_PIN2_LEN3 = '123';
export const INCORRECT_PIN2_LEN9 = '123456789';
export const INCORRECT_PUK2 = '134679';
// lock status response
export const LOCK_RESULT = { SUCCESS: 0, FAILURE: -1, EXCEPTION: -2 };
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册