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

!6593 observer 测试套整改

Merge pull request !6593 from zhangfuzhi/monthly_20221018
......@@ -68,49 +68,9 @@
}
],
"reqPermissions": [
{
"name": "ohos.permission.LOCATION",
"reason": "need use ohos.permission.LOCATION"
},
{
"name":"ohos.permission.SET_TELEPHONY_STATE",
"reason":"need use ohos.permission.SET_TELEPHONY_STATE"
},
{
"name":"ohos.permission.GET_TELEPHONY_STATE",
"reason":"need use ohos.permission.GET_TELEPHONY_STATE"
},
{
"name":"ohos.permission.PLACE_CALL",
"reason":"need use ohos.permission.PLACE_CALL"
},
{
"name":"ohos.permission.READ_CONTACTS",
"reason":"need use ohos.permission.READ_CONTACTS"
},
{
"name":"ohos.permission.WRITE_CONTACTS",
"reason":"need use ohos.permission.WRITE_CONTACTS"
},
{
"name":"ohos.permission.SEND_MESSAGES",
"reason":"need use ohos.permission.SEND_MESSAGES"
},
{
"name":"ohos.permission.RECEIVE_SMS",
"reason":"need use ohos.permission.RECEIVE_SMS"
},
{
"name":"ohos.permission.READ_CALL_LOG",
"reason":"need use ohos.permission.READ_CALL_LOG"
},
{
"name":"ohos.permission.GET_NETWORK_INFO",
"reason":"need use ohos.permission.GET_NETWORK_INFO"
},
{
"name":"ohos.permission.INTERNET",
"reason":"need use ohos.permission.INTERNET"
}
],
"js": [
......
......@@ -12,13 +12,13 @@
* 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() {
console.info('Application onCreate')
console.info('Application onCreate');
var abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments: any
......
/**
* 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,12 +13,8 @@
* limitations under the License.
*/
//other import
import observer from './ObserverJsunit.test.ets'
import ObserverJsunit from './ObserverJsunit.test';
export default function testsuite() {
observer();
ObserverJsunit();
}
\ 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
......@@ -13,23 +12,14 @@
* 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'
import observer from '@ohos.telephony.observer'
import cellular from '@ohos.telephony.data'
import radio from '@ohos.telephony.radio'
import call from '@ohos.telephony.call'
import utils from './Utils.ets'
import {SimStateData} from '@ohos.telephony.observer'
import {LockReason} from '@ohos.telephony.observer'
import sim from "@ohos.telephony.sim"
import { describe, expect, it } from '@ohos/hypium';
import cellular from '@ohos.telephony.data';
import observer from '@ohos.telephony.observer';
export default function observerJsunit() {
describe('ObserverTest', function () {
console.log("************* Observer Test start *************")
const SLOT_0 = 0;
const SLOT_2 = -1;
export default function ObserverJsunit() {
describe('ObserverJsunit', function () {
console.log("************* Observer Test start *************");
let envReady = false;
/*
* @tc.number : Telephony_observer_observer_DataConnectState_0100
......@@ -37,12 +27,7 @@ export default function observerJsunit() {
* @tc.desc : check the getCellularDataState callback to verify the call back data
*/
it('Telephony_observer_observer_DataConnectState_0100', 0, function (done) {
expect(observer.NetworkState == radio.NetworkState).assertTrue();
expect(observer.SignalInformation == radio.SignalInformation).assertTrue();
expect(observer.CellInformation == radio.CellInformation ).assertTrue();
expect(observer.RatType == radio.RadioTechnology).assertTrue();
expect(observer.CallState == call.CallState).assertTrue();
console.log("************* Telephony_observer_observer_DataConnectState_0100 Test start *************")
console.log("************* Telephony_observer_observer_DataConnectState_0100 Test start *************");
cellular.getCellularDataState((err, data) => {
if (!err) {
var dataConnectStateList = [cellular.DataConnectState.DATA_STATE_UNKNOWN,
......@@ -50,40 +35,14 @@ export default function observerJsunit() {
cellular.DataConnectState.DATA_STATE_CONNECTING,
cellular.DataConnectState.DATA_STATE_CONNECTED,
cellular.DataConnectState.DATA_STATE_SUSPENDED]
expect(dataConnectStateList.indexOf(data) >= 0).assertTrue()
expect(dataConnectStateList.indexOf(data) >= 0).assertTrue();
done();
return;
}
console.log("Telephony_CellularData_getCellularDataState_0100 end");
done()
})
console.log("************* Telephony_observer_observer_DataConnectState_0100 Test end *************")
})
/*
* @tc.number : Telephony_observer_observer_DataConnectState_0200
* @tc.name : DataConnectState
* @tc.desc : check the getCellularDataState callback to verify the call back data
*/
it('Telephony_observer_observer_DataConnectState_0200', 0, function (done) {
console.log("************* Telephony_observer_observer_DataConnectState_0200 Test start *************")
console.log("Telephony_observer_observer_DataConnectState_0200" + observer.DataConnectState)
expect(observer.DataConnectState == undefined).assertTrue();
console.log("************* Telephony_observer_observer_DataConnectState_0200 Test end *************")
done();
})
/*
* @tc.number : Telephony_observer_observer_RatType_0100
* @tc.name : RatType
* @tc.desc : Obtains the data connect state
*/
it('Telephony_observer_observer_RatType_0100', 0, async function (done) {
console.log("************* Telephony_observer_observer_RatType_0100 Test start *************")
console.log("Telephony_observer_observer_RatType_0100" +observer.RatType)
expect(observer.RatType == undefined).assertTrue();
console.log("************* Telephony_observer_observer_RatType_0100 Test end *************")
done()
console.log("************* Telephony_observer_observer_DataConnectState_0100 Test end *************");
})
/*
......@@ -92,14 +51,18 @@ export default function observerJsunit() {
* @tc.desc : call the on method of networkStateChange
*/
it('Telephony_observer_observer_on_networkStateChange_0100', 0, async function (done) {
console.log("************* Telephony_observer_observer_on_networkStateChange_0100 Test start *************")
observer.on('networkStateChange', (networkState) => {
expect().assertFail()
done()
return
})
console.log("************* Telephony_observer_observer_on_networkStateChange_0100 Test end *************")
done()
console.log("************* Telephony_observer_observer_on_networkStateChange_0100 Test start *************");
try {
observer.on('networkStateChange', NetworkState => {
console.log("on networkStateChange, NetworkState:" + JSON.stringify(NetworkState));
expect(typeof NetworkState === undefined).assertFalse();
});
done();
} catch (error) {
expect(false).assertTrue();
done();
}
console.log("************* Telephony_observer_observer_on_networkStateChange_0100 Test end *************");
})
/*
......@@ -108,16 +71,20 @@ export default function observerJsunit() {
* @tc.desc : call the on method of networkStateChange
*/
it('Telephony_observer_observer_on_networkStateChange_0200', 0, async function (done) {
console.log("************* Telephony_observer_observer_on_networkStateChange_0200 Test start *************")
console.log("************* Telephony_observer_observer_on_networkStateChange_0200 Test start *************");
try {
observer.on('networkStateChange', {
slotId: SLOT_0
}, (networkState) => {
expect().assertFail()
done()
return
})
console.log("************* Telephony_observer_observer_on_networkStateChange_0200 Test end *************")
done()
slotId: 0
}, NetworkState => {
console.log("on networkStateChange, NetworkState:" + JSON.stringify(NetworkState));
expect(typeof NetworkState === undefined).assertFalse();
});
done();
} catch (error) {
expect(false).assertTrue();
done();
}
console.log("************* Telephony_observer_observer_on_networkStateChange_0200 Test end *************");
})
/*
......@@ -126,14 +93,22 @@ export default function observerJsunit() {
* @tc.desc : call the off method of networkStateChange
*/
it('Telephony_observer_observer_off_networkStateChange_0100', 0, async function (done) {
console.log("************* Telephony_observer_observer_off_networkStateChange_0100 Test start *************")
observer.off('networkStateChange', (networkState) => {
expect().assertFail()
done()
return
})
console.log("************* Telephony_observer_observer_off_networkStateChange_0100 Test end *************")
done()
console.log("************* Telephony_observer_observer_off_networkStateChange_0100 Test start *************");
try {
let callback = NetworkState => {
console.log("on networkStateChange, NetworkState:" + JSON.stringify(NetworkState));
expect(typeof NetworkState === undefined).assertFalse();
}
observer.on('networkStateChange', callback);
// 可以指定传入on中的callback取消一个订阅,也可以不指定callback清空所有订阅。
observer.off('networkStateChange', callback);
observer.off('networkStateChange');
done();
} catch (error) {
expect(false).assertTrue();
done();
}
console.log("************* Telephony_observer_observer_off_networkStateChange_0100 Test end *************");
})
/*
......@@ -142,14 +117,18 @@ export default function observerJsunit() {
* @tc.desc : call the on method of signalInfoChange
*/
it('Telephony_observer_observer_on_signalInfoChange_0100', 0, async function (done) {
console.log("************* Telephony_observer_observer_on_signalInfoChange_0100 Test start *************")
observer.on('signalInfoChange', (signalInformation) => {
expect().assertFail()
done()
return
})
console.log("************* Telephony_observer_observer_on_signalInfoChange_0100 Test end *************")
done()
console.log("************* Telephony_observer_observer_on_signalInfoChange_0100 Test start *************");
try {
observer.on('signalInfoChange', SignalInformation => {
console.log("on signalInfoChange, SignalInformation:" + JSON.stringify(SignalInformation));
expect(typeof SignalInformation === undefined).assertFalse();
});
done();
} catch (error) {
expect(false).assertTrue();
done();
}
console.log("************* Telephony_observer_observer_on_signalInfoChange_0100 Test end *************");
})
/*
......@@ -158,16 +137,20 @@ export default function observerJsunit() {
* @tc.desc : call the on method of signalInfoChange
*/
it('Telephony_observer_observer_on_signalInfoChange_0200', 0, async function (done) {
console.log("************* Telephony_observer_observer_on_signalInfoChange_0200 Test start *************")
console.log("************* Telephony_observer_observer_on_signalInfoChange_0200 Test start *************");
try {
observer.on('signalInfoChange', {
slotId: SLOT_0
}, (signalInformation) => {
expect().assertFail()
done()
return
})
console.log("************* Telephony_observer_observer_on_signalInfoChange_0200 Test end *************")
done()
slotId: 0
}, SignalInformation => {
console.log("on signalInfoChange, SignalInformation:" + JSON.stringify(SignalInformation));
expect(typeof SignalInformation === undefined).assertFalse();
});
done();
} catch (error) {
expect(false).assertTrue();
done();
}
console.log("************* Telephony_observer_observer_on_signalInfoChange_0200 Test end *************");
})
/*
......@@ -176,32 +159,44 @@ export default function observerJsunit() {
* @tc.desc : call the off method of signalInfoChange
*/
it('Telephony_observer_observer_off_signalInfoChange_0100', 0, async function (done) {
console.log("************* Telephony_observer_observer_off_signalInfoChange_0100 Test start *************")
observer.off('signalInfoChange', (networkState) => {
expect().assertFail()
done()
return
})
console.log("************* Telephony_observer_observer_off_signalInfoChange_0100 Test end *************")
done()
console.log("************* Telephony_observer_observer_off_signalInfoChange_0100 Test start *************");
try {
let callback = SignalInformation => {
console.log("on signalInfoChange, SignalInformation:" + JSON.stringify(SignalInformation));
expect(typeof SignalInformation === undefined).assertFalse();
}
observer.on('signalInfoChange', callback);
// 可以指定传入on中的callback取消一个订阅,也可以不指定callback清空所有订阅。
observer.off('signalInfoChange', callback);
observer.off('signalInfoChange');
done();
} catch (error) {
expect(false).assertTrue();
done();
}
console.log("************* Telephony_observer_observer_off_signalInfoChange_0100 Test end *************");
})
/*
* @tc.number : Telephony_observer_observer_on_cellularDataConnectionStateChange_0100
* @tc.name : on_cellularDataConnectionStateChange
* @tc.desc : call the on method of cellularDataConnectionStateChange
*/
it('Telephony_observer_observer_on_cellularDataConnectionStateChange_0100', 0, async function (done) {
console.log("************* Telephony_observer_observer_on_cellularDataConnectionStateChange_0100 Test start *************")
observer.on('cellularDataConnectionStateChange', (data) => {
expect().assertFail()
done()
return
})
console.log("************* Telephony_observer_observer_on_cellularDataConnectionStateChange_0100 Test end *************")
done()
console.log("************* Telephony_observer_observer_on_cellularDataConnectionStateChange_0100 Test start *************");
try {
observer.on('cellularDataConnectionStateChange', value => {
console.log("on cellularDataConnectionStateChange, state:" + value.state + ", network:" + value.network);
expect(typeof value.state === undefined).assertFalse();
expect(typeof value.network === undefined).assertFalse();
});
done();
} catch (error) {
expect(false).assertTrue();
done();
}
console.log("************* Telephony_observer_observer_on_cellularDataConnectionStateChange_0100 Test end *************");
})
/*
......@@ -210,16 +205,21 @@ export default function observerJsunit() {
* @tc.desc : call the on method of cellularDataConnectionStateChange
*/
it('Telephony_observer_observer_on_cellularDataConnectionStateChange_0200', 0, async function (done) {
console.log("************* Telephony_observer_observer_on_cellularDataConnectionStateChange_0200 Test start *************")
console.log("************* Telephony_observer_observer_on_cellularDataConnectionStateChange_0200 Test start *************");
try {
observer.on('cellularDataConnectionStateChange', {
slotId: SLOT_0
}, (data) => {
expect().assertFail()
done()
return
})
console.log("************* Telephony_observer_observer_on_cellularDataConnectionStateChange_0200 Test end *************")
done()
slotId: 0
}, value => {
console.log("on cellularDataConnectionStateChange, state:" + value.state + ", network:" + value.network);
expect(typeof value.state === undefined).assertFalse();
expect(typeof value.network === undefined).assertFalse();
});
done();
} catch (error) {
expect(false).assertTrue();
done();
}
console.log("************* Telephony_observer_observer_on_cellularDataConnectionStateChange_0200 Test end *************");
})
/*
......@@ -228,14 +228,21 @@ export default function observerJsunit() {
* @tc.desc : call the off method of cellularDataConnectionStateChange
*/
it('Telephony_observer_observer_off_cellularDataConnectionStateChange_0100', 0, async function (done) {
console.log("************* Telephony_observer_observer_off_cellularDataConnectionStateChange_0100 Test start *************")
observer.off('cellularDataConnectionStateChange', (data) => {
expect().assertFail()
done()
return
})
console.log("************* Telephony_observer_observer_off_cellularDataConnectionStateChange_0100 Test end *************")
done()
console.log("************* Telephony_observer_observer_off_cellularDataConnectionStateChange_0100 Test start *************");
try {
let callback = value => {
console.log("on cellularDataConnectionStateChange, state:" + value.state + ", network:" + value.network);
}
observer.on('cellularDataConnectionStateChange', callback);
// 可以指定传入on中的callback取消一个订阅,也可以不指定callback清空所有订阅。
observer.off('cellularDataConnectionStateChange', callback);
observer.off('cellularDataConnectionStateChange');
done();
} catch (error) {
expect(false).assertTrue();
done();
}
console.log("************* Telephony_observer_observer_off_cellularDataConnectionStateChange_0100 Test end *************");
})
/*
......@@ -244,14 +251,18 @@ export default function observerJsunit() {
* @tc.desc : call the on method of cellularDataFlowChange
*/
it('Telephony_observer_observer_on_cellularDataFlowChange_0100', 0, async function (done) {
console.log("************* Telephony_observer_observer_on_cellularDataFlowChange_0100 Test start *************")
observer.on('cellularDataFlowChange', (data) => {
expect().assertFail()
done()
return
})
console.log("************* Telephony_observer_observer_on_cellularDataFlowChange_0100 Test end *************")
done()
console.log("************* Telephony_observer_observer_on_cellularDataFlowChange_0100 Test start *************");
try {
observer.on('cellularDataFlowChange', DataFlowType => {
console.log("on networkStateChange, DataFlowType:" + JSON.stringify(DataFlowType));
expect(typeof DataFlowType === undefined).assertFalse();
});
done();
} catch (error) {
expect(false).assertTrue();
done();
}
console.log("************* Telephony_observer_observer_on_cellularDataFlowChange_0100 Test end *************");
})
/*
......@@ -260,16 +271,20 @@ export default function observerJsunit() {
* @tc.desc : call the on method of cellularDataFlowChange
*/
it('Telephony_observer_observer_on_cellularDataFlowChange_0200', 0, async function (done) {
console.log("************* Telephony_observer_observer_on_cellularDataFlowChange_0200 Test start *************")
console.log("************* Telephony_observer_observer_on_cellularDataFlowChange_0200 Test start *************");
try {
observer.on('cellularDataFlowChange', {
slotId: SLOT_0
}, (data) => {
expect().assertFail()
done()
return
})
slotId: 0
}, DataFlowType => {
console.log("on networkStateChange, DataFlowType:" + JSON.stringify(DataFlowType));
expect(typeof DataFlowType === undefined).assertFalse();
});
done();
} catch (error) {
expect(false).assertTrue();
done();
}
console.log("************* Telephony_observer_observer_on_cellularDataFlowChange_0200 Test end *************")
done()
})
/*
......@@ -278,14 +293,21 @@ export default function observerJsunit() {
* @tc.desc : call the off method of cellularDataFlowChange
*/
it('Telephony_observer_observer_off_cellularDataFlowChange_0100', 0, async function (done) {
console.log("************* Telephony_observer_observer_off_cellularDataFlowChange_0100 Test start *************")
observer.off('cellularDataFlowChange', (data) => {
expect().assertFail()
done()
return
})
console.log("************* Telephony_observer_observer_off_cellularDataFlowChange_0100 Test start *************");
try {
let callback = data => {
console.log("on cellularDataFlowChange, data:" + JSON.stringify(data));
}
observer.on('cellularDataFlowChange', callback);
// 可以指定传入on中的callback取消一个订阅,也可以不指定callback清空所有订阅。
observer.off('cellularDataFlowChange', callback);
observer.off('cellularDataFlowChange');
done();
} catch (error) {
expect(false).assertTrue();
done();
}
console.log("************* Telephony_observer_observer_off_cellularDataFlowChange_0100 Test end *************")
done()
})
/*
......@@ -294,14 +316,18 @@ export default function observerJsunit() {
* @tc.desc : call the on method of callStateChange
*/
it('Telephony_observer_observer_on_callStateChange_0100', 0, async function (done) {
console.log("************* Telephony_observer_observer_on_callStateChange_0100 Test start *************")
observer.on('callStateChange', (data) => {
expect().assertFail()
done()
return
})
console.log("************* Telephony_observer_observer_on_callStateChange_0100 Test end *************")
done()
console.log("************* Telephony_observer_observer_on_callStateChange_0100 Test start *************");
try {
observer.on('callStateChange', value => {
console.log("on callStateChange, state:" + value.state + ", number:" + value.number);
expect(typeof value.state === undefined).assertFalse();
});
done();
} catch (error) {
expect(false).assertTrue();
done();
}
console.log("************* Telephony_observer_observer_on_callStateChange_0100 Test end *************");
})
/*
......@@ -310,16 +336,20 @@ export default function observerJsunit() {
* @tc.desc : call the on method of callStateChange
*/
it('Telephony_observer_observer_on_callStateChange_0200', 0, async function (done) {
console.log("************* Telephony_observer_observer_on_callStateChange_0200 Test start *************")
console.log("************* Telephony_observer_observer_on_callStateChange_0200 Test start *************");
try {
observer.on('callStateChange', {
slotId: SLOT_0
}, (data) => {
expect().assertFail()
done()
return
})
console.log("************* Telephony_observer_observer_on_callStateChange_0200 Test end *************")
done()
slotId: 0
}, value => {
console.log("on callStateChange, state:" + value.state + ", number:" + value.number);
expect(typeof value.state === undefined).assertFalse();
});
done();
} catch (error) {
expect(false).assertTrue();
done();
}
console.log("************* Telephony_observer_observer_on_callStateChange_0200 Test end *************");
})
/*
......@@ -328,14 +358,21 @@ export default function observerJsunit() {
* @tc.desc : call the off method of callStateChange
*/
it('Telephony_observer_observer_off_callStateChange_0100', 0, async function (done) {
console.log("************* Telephony_observer_observer_off_callStateChange_0100 Test start *************")
observer.off('callStateChange', (data) => {
expect().assertFail()
done()
return
})
console.log("************* Telephony_observer_observer_off_callStateChange_0100 Test end *************")
done()
console.log("************* Telephony_observer_observer_off_callStateChange_0100 Test start *************");
try {
let callback = value => {
console.log("on callStateChange, state:" + value.state + ", number:" + value.number);
}
observer.on('callStateChange', callback);
// 可以指定传入on中的callback取消一个订阅,也可以不指定callback清空所有订阅。
observer.off('callStateChange', callback);
observer.off('callStateChange');
done();
} catch (error) {
expect(false).assertTrue();
done();
}
console.log("************* Telephony_observer_observer_off_callStateChange_0100 Test end *************");
})
/*
......@@ -344,14 +381,18 @@ export default function observerJsunit() {
* @tc.desc : call the on method of simStateChange
*/
it('Telephony_observer_observer_on_simStateChange_0100', 0, async function (done) {
console.log("************* Telephony_observer_observer_on_simStateChange_0100 Test start *************")
observer.on('simStateChange', (data) => {
expect().assertFail()
done()
return
})
console.log("************* Telephony_observer_observer_on_simStateChange_0100 Test end *************")
done()
console.log("************* Telephony_observer_observer_on_simStateChange_0100 Test start *************");
try {
observer.on('simStateChange', SimStateData => {
console.log("on simStateChange, SimStateData:" + JSON.stringify(SimStateData));
expect(typeof SimStateData === undefined).assertFalse();
});
done();
} catch (error) {
expect(false).assertTrue();
done();
}
console.log("************* Telephony_observer_observer_on_simStateChange_0100 Test end *************");
})
/*
......@@ -360,16 +401,20 @@ export default function observerJsunit() {
* @tc.desc : call the on method of simStateChange
*/
it('Telephony_observer_observer_on_simStateChange_0200', 0, async function (done) {
console.log("************* Telephony_observer_observer_on_simStateChange_0200 Test start *************")
console.log("************* Telephony_observer_observer_on_simStateChange_0200 Test start *************");
try {
observer.on('simStateChange', {
slotId: SLOT_0
}, (data) => {
expect().assertFail()
done()
return
})
slotId: 0
}, SimStateData => {
console.log("on simStateChange, SimStateData:" + JSON.stringify(SimStateData));
expect(typeof SimStateData === undefined).assertFalse();
});
done();
} catch (error) {
expect(false).assertTrue();
done();
}
console.log("************* Telephony_observer_observer_on_simStateChange_0200 Test end *************")
done()
})
/*
......@@ -378,151 +423,21 @@ export default function observerJsunit() {
* @tc.desc : call the off method of simStateChange
*/
it('Telephony_observer_observer_off_simStateChange_0100', 0, async function (done) {
console.log("************* Telephony_observer_observer_off_simStateChange_0100 Test start *************")
observer.off('simStateChange', (data) => {
expect().assertFail()
done()
return
})
console.log("************* Telephony_observer_observer_off_simStateChange_0100 Test end *************")
done()
})
/*
* @tc.number : Telephony_observer_SimStateData_type_0100
* @tc.name : type
* @tc.desc : check the type value of SimStateData object
*/
it('Telephony_observer_SimStateData_type_0100', 0, function (done) {
console.log("************* Telephony_observer_SimStateData_type_0100 Test start *************")
const unknown: SimStateData = {
type: sim.CardType.UNKNOWN_CARD
}
expect(-1).assertEqual(unknown.type)
const singleMode: SimStateData = {
type: sim.CardType.SINGLE_MODE_SIM_CARD
}
expect(10).assertEqual(singleMode.type)
const singleModeUSim: SimStateData = {
type: sim.CardType.SINGLE_MODE_USIM_CARD
}
expect(20).assertEqual(singleModeUSim.type)
done()
console.log("************* Telephony_observer_SimStateData_type_0100 Test end *************")
})
/*
* @tc.number : Telephony_observer_SimStateData_type_0200
* @tc.name : type
* @tc.desc : check the type value of SimStateData object
*/
it('Telephony_observer_SimStateData_type_0200', 0, function (done) {
console.log("************* Telephony_observer_SimStateData_type_0200 Test start *************")
const singleModeRUim: SimStateData = {
type: sim.CardType.SINGLE_MODE_RUIM_CARD
}
expect(30).assertEqual(singleModeRUim.type)
const dualModeCG: SimStateData = {
type: sim.CardType.DUAL_MODE_CG_CARD
}
expect(40).assertEqual(dualModeCG.type)
const ctNationalRoaming: SimStateData = {
type: sim.CardType.CT_NATIONAL_ROAMING_CARD
}
expect(41).assertEqual(ctNationalRoaming.type)
done()
console.log("************* Telephony_observer_SimStateData_type_0200 Test end *************")
})
/*
* @tc.number : Telephony_observer_SimStateData_type_0300
* @tc.name : type
* @tc.desc : check the type value of SimStateData object
*/
it('Telephony_observer_SimStateData_type_0300', 0, function (done) {
console.log("************* Telephony_observer_SimStateData_type_0300 Test start *************")
const cuDualMode: SimStateData = {
type: sim.CardType.CU_DUAL_MODE_CARD
}
expect(42).assertEqual(cuDualMode.type)
const dualModeTelecomLte: SimStateData = {
type: sim.CardType.DUAL_MODE_TELECOM_LTE_CARD
}
expect(43).assertEqual(dualModeTelecomLte.type)
const dualModeUg: SimStateData = {
type: sim.CardType.DUAL_MODE_UG_CARD
}
expect(50).assertEqual(dualModeUg.type)
const singleModeIsim: SimStateData = {
type: sim.CardType.SINGLE_MODE_ISIM_CARD
}
expect(60).assertEqual(singleModeIsim.type)
done()
console.log("************* Telephony_observer_SimStateData_type_0300 Test end *************")
})
/*
* @tc.number : Telephony_observer_SimStateData_state_0100
* @tc.name : state
* @tc.desc : check the state value of SimStateData object
*/
it('Telephony_observer_SimStateData_state_0100', 0, function (done) {
console.log("************* Telephony_observer_SimStateData_state_0100 Test start *************")
const unknown: SimStateData = {
state: sim.SimState.SIM_STATE_UNKNOWN
}
expect(0).assertEqual(unknown.state)
const notPresent: SimStateData = {
state: sim.SimState.SIM_STATE_NOT_PRESENT
}
expect(1).assertEqual(notPresent.state)
done()
console.log("************* Telephony_observer_SimStateData_state_0100 Test end *************")
})
/*
* @tc.number : Telephony_observer_SimStateData_state_0200
* @tc.name : state
* @tc.desc : check the state value of SimStateData object
*/
it('Telephony_observer_SimStateData_state_0200', 0, function (done) {
console.log("************* Telephony_observer_SimStateData_state_0200 Test start *************")
const locked: SimStateData = {
state: sim.SimState.SIM_STATE_LOCKED
}
expect(2).assertEqual(locked.state)
const notReady: SimStateData = {
state: sim.SimState.SIM_STATE_NOT_READY
}
expect(3).assertEqual(notReady.state)
done()
console.log("************* Telephony_observer_SimStateData_state_0200 Test end *************")
})
/*
* @tc.number : Telephony_observer_SimStateData_state_0300
* @tc.name : state
* @tc.desc : check the state value of SimStateData object
*/
it('Telephony_observer_SimStateData_state_0300', 0, function (done) {
console.log("************* Telephony_observer_SimStateData_state_0300 Test start *************")
const ready: SimStateData = {
state: sim.SimState.SIM_STATE_READY
}
expect(4).assertEqual(ready.state)
const loaded: SimStateData = {
state: sim.SimState.SIM_STATE_LOADED
console.log("************* Telephony_observer_observer_off_simStateChange_0100 Test start *************");
try {
let callback = data => {
console.log("on simStateChange, data:" + JSON.stringify(data));
}
observer.on('simStateChange', callback);
// 可以指定传入on中的callback取消一个订阅,也可以不指定callback清空所有订阅。
observer.off('simStateChange', callback);
observer.off('simStateChange');
done();
} catch (error) {
expect(false).assertTrue();
done();
}
expect(5).assertEqual(loaded.state)
done()
console.log("************* Telephony_observer_SimStateData_state_0300 Test end *************")
console.log("************* Telephony_observer_observer_off_simStateChange_0100 Test end *************");
})
/*
......@@ -531,14 +446,15 @@ export default function observerJsunit() {
* @tc.desc : check the SIM_NONE property of LockReason
*/
it('Telephony_observer_LockReason_SIM_NONE_0100', 0, function (done) {
console.log("************* Telephony_observer_LockReason_SIM_NONE_0100 Test start *************")
if (utils.notCheck) {
expect(true).assertTrue()
done()
if (!envReady) {
console.info("The environment was not ready");
done();
return;
}
expect(0).assertEqual(LockReason.SIM_NONE)
done()
console.log("************* Telephony_observer_LockReason_SIM_NONE_0100 Test end *************")
console.log("************* Telephony_observer_LockReason_SIM_NONE_0100 Test start *************")
expect(0).assertEqual(observer.LockReason.SIM_NONE);
done();
console.log("************* Telephony_observer_LockReason_SIM_NONE_0100 Test end *************");
})
/*
......@@ -547,14 +463,15 @@ export default function observerJsunit() {
* @tc.desc : check the SIM_PIN property of LockReason
*/
it('Telephony_observer_LockReason_SIM_PIN_0100', 0, function (done) {
console.log("************* Telephony_observer_LockReason_SIM_PIN_0100 Test start *************")
if (utils.notCheck) {
expect(true).assertTrue()
done()
if (!envReady) {
console.info("The environment was not ready");
done();
return;
}
expect(1).assertEqual(LockReason.SIM_PIN)
done()
console.log("************* Telephony_observer_LockReason_SIM_PIN_0100 Test end *************")
console.log("************* Telephony_observer_LockReason_SIM_PIN_0100 Test start *************");
expect(1).assertEqual(observer.LockReason.SIM_PIN);
done();
console.log("************* Telephony_observer_LockReason_SIM_PIN_0100 Test end *************");
})
/*
......@@ -563,14 +480,15 @@ export default function observerJsunit() {
* @tc.desc : check the SIM_PUK property of LockReason
*/
it('Telephony_observer_LockReason_SIM_PUK_0100', 0, function (done) {
console.log("************* Telephony_observer_LockReason_SIM_PUK_0100 Test start *************")
if (utils.notCheck) {
expect(true).assertTrue()
done()
if (!envReady) {
console.info("The environment was not ready");
done();
return;
}
expect(2).assertEqual(LockReason.SIM_PUK)
done()
console.log("************* Telephony_observer_LockReason_SIM_PUK_0100 Test end *************")
console.log("************* Telephony_observer_LockReason_SIM_PUK_0100 Test start *************");
expect(2).assertEqual(observer.LockReason.SIM_PUK);
done();
console.log("************* Telephony_observer_LockReason_SIM_PUK_0100 Test end *************");
})
/*
......@@ -579,14 +497,15 @@ export default function observerJsunit() {
* @tc.desc : check the SIM_PN_PIN property of LockReason
*/
it('Telephony_observer_LockReason_SIM_PN_PIN_0100', 0, function (done) {
console.log("************* Telephony_observer_LockReason_SIM_PN_PIN_0100 Test start *************")
if (utils.notCheck) {
expect(true).assertTrue()
done()
if (!envReady) {
console.info("The environment was not ready");
done();
return;
}
expect(3).assertEqual(LockReason.SIM_PN_PIN)
done()
console.log("************* Telephony_observer_LockReason_SIM_PN_PIN_0100 Test end *************")
console.log("************* Telephony_observer_LockReason_SIM_PN_PIN_0100 Test start *************");
expect(3).assertEqual(observer.LockReason.SIM_PN_PIN);
done();
console.log("************* Telephony_observer_LockReason_SIM_PN_PIN_0100 Test end *************");
})
/*
* @tc.number : Telephony_observer_LockReason_SIM_PN_PUK_0100
......@@ -594,14 +513,15 @@ export default function observerJsunit() {
* @tc.desc : check the SIM_PN_PUK property of LockReason
*/
it('Telephony_observer_LockReason_SIM_PN_PUK_0100', 0, function (done) {
console.log("************* Telephony_observer_LockReason_SIM_PN_PUK_0100 Test start *************")
if (utils.notCheck) {
expect(true).assertTrue()
done()
if (!envReady) {
console.info("The environment was not ready");
done();
return;
}
expect(4).assertEqual(LockReason.SIM_PN_PUK)
done()
console.log("************* Telephony_observer_LockReason_SIM_PN_PUK_0100 Test end *************")
console.log("************* Telephony_observer_LockReason_SIM_PN_PUK_0100 Test start *************");
expect(4).assertEqual(observer.LockReason.SIM_PN_PUK);
done();
console.log("************* Telephony_observer_LockReason_SIM_PN_PUK_0100 Test end *************");
})
/*
......@@ -610,14 +530,15 @@ export default function observerJsunit() {
* @tc.desc : check the SIM_PU_PIN property of LockReason
*/
it('Telephony_observer_LockReason_SIM_PU_PIN_0100', 0, function (done) {
console.log("************* Telephony_observer_LockReason_SIM_PU_PIN_0100 Test start *************")
if (utils.notCheck) {
expect(true).assertTrue()
done()
if (!envReady) {
console.info("The environment was not ready");
done();
return;
}
expect(5).assertEqual(LockReason.SIM_PU_PIN)
done()
console.log("************* Telephony_observer_LockReason_SIM_PU_PIN_0100 Test end *************")
console.log("************* Telephony_observer_LockReason_SIM_PU_PIN_0100 Test start *************");
expect(5).assertEqual(observer.LockReason.SIM_PU_PIN);
done();
console.log("************* Telephony_observer_LockReason_SIM_PU_PIN_0100 Test end *************");
})
/*
......@@ -626,14 +547,15 @@ export default function observerJsunit() {
* @tc.desc : check the SIM_PU_PUK property of LockReason
*/
it('Telephony_observer_LockReason_SIM_PU_PUK_0100', 0, function (done) {
console.log("************* Telephony_observer_LockReason_SIM_PU_PUK_0100 Test start *************")
if (utils.notCheck) {
expect(true).assertTrue()
done()
if (!envReady) {
console.info("The environment was not ready");
done();
return;
}
expect(6).assertEqual(LockReason.SIM_PU_PUK)
done()
console.log("************* Telephony_observer_LockReason_SIM_PU_PUK_0100 Test end *************")
console.log("************* Telephony_observer_LockReason_SIM_PU_PUK_0100 Test start *************");
expect(6).assertEqual(observer.LockReason.SIM_PU_PUK);
done();
console.log("************* Telephony_observer_LockReason_SIM_PU_PUK_0100 Test end *************");
})
/*
......@@ -642,14 +564,15 @@ export default function observerJsunit() {
* @tc.desc : check the SIM_PP_PIN property of LockReason
*/
it('Telephony_observer_LockReason_SIM_PP_PIN_0100', 0, function (done) {
console.log("************* Telephony_observer_LockReason_SIM_PP_PIN_0100 Test start *************")
if (utils.notCheck) {
expect(true).assertTrue()
done()
if (!envReady) {
console.info("The environment was not ready");
done();
return;
}
expect(7).assertEqual(LockReason.SIM_PP_PIN)
done()
console.log("************* Telephony_observer_LockReason_SIM_PP_PIN_0100 Test end *************")
console.log("************* Telephony_observer_LockReason_SIM_PP_PIN_0100 Test start *************");
expect(7).assertEqual(observer.LockReason.SIM_PP_PIN);
done();
console.log("************* Telephony_observer_LockReason_SIM_PP_PIN_0100 Test end *************");
})
/*
......@@ -658,14 +581,15 @@ export default function observerJsunit() {
* @tc.desc : check the SIM_PP_PUK property of LockReason
*/
it('Telephony_observer_LockReason_SIM_PP_PUK_0100', 0, function (done) {
console.log("************* Telephony_observer_LockReason_SIM_PP_PUK_0100 Test start *************")
if (utils.notCheck) {
expect(true).assertTrue()
done()
if (!envReady) {
console.info("The environment was not ready");
done();
return;
}
expect(8).assertEqual(LockReason.SIM_PP_PUK)
done()
console.log("************* Telephony_observer_LockReason_SIM_PP_PUK_0100 Test end *************")
console.log("************* Telephony_observer_LockReason_SIM_PP_PUK_0100 Test start *************");
expect(8).assertEqual(observer.LockReason.SIM_PP_PUK);
done();
console.log("************* Telephony_observer_LockReason_SIM_PP_PUK_0100 Test end *************");
})
/*
......@@ -674,14 +598,15 @@ export default function observerJsunit() {
* @tc.desc : check the SIM_PC_PIN property of LockReason
*/
it('Telephony_observer_LockReason_SIM_PC_PIN_0100', 0, function (done) {
console.log("************* Telephony_observer_LockReason_SIM_PC_PIN_0100 Test start *************")
if (utils.notCheck) {
expect(true).assertTrue()
done()
if (!envReady) {
console.info("The environment was not ready");
done();
return;
}
expect(9).assertEqual(LockReason.SIM_PC_PIN)
done()
console.log("************* Telephony_observer_LockReason_SIM_PC_PIN_0100 Test end *************")
console.log("************* Telephony_observer_LockReason_SIM_PC_PIN_0100 Test start *************");
expect(9).assertEqual(observer.LockReason.SIM_PC_PIN);
done();
console.log("************* Telephony_observer_LockReason_SIM_PC_PIN_0100 Test end *************");
})
/*
......@@ -690,14 +615,15 @@ export default function observerJsunit() {
* @tc.desc : check the SIM_PC_PUK property of LockReason
*/
it('Telephony_observer_LockReason_SIM_PC_PUK_0100', 0, function (done) {
console.log("************* Telephony_observer_LockReason_SIM_PC_PUK_0100 Test start *************")
if (utils.notCheck) {
expect(true).assertTrue()
done()
if (!envReady) {
console.info("The environment was not ready");
done();
return;
}
expect(10).assertEqual(LockReason.SIM_PC_PUK)
done()
console.log("************* Telephony_observer_LockReason_SIM_PC_PUK_0100 Test end *************")
console.log("************* Telephony_observer_LockReason_SIM_PC_PUK_0100 Test start *************");
expect(10).assertEqual(observer.LockReason.SIM_PC_PUK);
done();
console.log("************* Telephony_observer_LockReason_SIM_PC_PUK_0100 Test end *************");
})
/*
......@@ -706,14 +632,15 @@ export default function observerJsunit() {
* @tc.desc : check the SIM_SIM_PIN property of LockReason
*/
it('Telephony_observer_LockReason_SIM_SIM_PIN_0100', 0, function (done) {
console.log("************* Telephony_observer_LockReason_SIM_SIM_PIN_0100 Test start *************")
if (utils.notCheck) {
expect(true).assertTrue()
done()
if (!envReady) {
console.info("The environment was not ready");
done();
return;
}
expect(11).assertEqual(LockReason.SIM_SIM_PIN)
done()
console.log("************* Telephony_observer_LockReason_SIM_SIM_PIN_0100 Test end *************")
console.log("************* Telephony_observer_LockReason_SIM_SIM_PIN_0100 Test start *************");
expect(11).assertEqual(observer.LockReason.SIM_SIM_PIN);
done();
console.log("************* Telephony_observer_LockReason_SIM_SIM_PIN_0100 Test end *************");
})
/*
......@@ -722,44 +649,39 @@ export default function observerJsunit() {
* @tc.desc : check the SIM_SIM_PUK property of LockReason
*/
it('Telephony_observer_LockReason_SIM_SIM_PUK_0100', 0, function (done) {
console.log("************* Telephony_observer_LockReason_SIM_SIM_PUK_0100 Test start *************")
if (utils.notCheck) {
expect(true).assertTrue()
done()
if (!envReady) {
console.info("The environment was not ready");
done();
return;
}
expect(12).assertEqual(LockReason.SIM_SIM_PUK)
done()
console.log("************* Telephony_observer_LockReason_SIM_SIM_PUK_0100 Test end *************")
console.log("************* Telephony_observer_LockReason_SIM_SIM_PUK_0100 Test start *************");
expect(12).assertEqual(observer.LockReason.SIM_SIM_PUK);
done();
console.log("************* Telephony_observer_LockReason_SIM_SIM_PUK_0100 Test end *************");
})
function timeout(done) {
expect(true).assertTrue()
console.debug('Observer Test=========timeout========');
done()
}
/*
* @tc.number : Telephony_Observer_SimStateData_Reason
* @tc.name : on_simStateChange
* @tc.desc : call the on method of simStateChange
*/
it('Telephony_Observer_SimStateData_Reason', 0, async function (done) {
console.log("************* Telephony_Observer_SimStateData_Reason Test start *************")
observer.on('simStateChange', (data:SimStateData) => {
if((data === null || data === undefined)
|| (data.reason == null || data.reason === undefined)){
expect(true).assertTrue()
done()
console.log("************* Telephony_Observer_SimStateData_Reason Test start *************");
try {
observer.on('simStateChange', SimStateData => {
console.log("on simStateChange, SimStateData:" + JSON.stringify(SimStateData));
expect(typeof SimStateData.reason === undefined).assertFalse();
expect(typeof SimStateData.state === undefined).assertFalse();
expect(typeof SimStateData.type === undefined).assertFalse();
});
done();
} catch (error) {
expect(false).assertTrue();
done();
}
return
})
console.log("************* Telephony_Observer_SimStateData_Reason Test end *************")
done()
console.log("************* Telephony_Observer_SimStateData_Reason Test end *************");
})
console.log("************* Observer Test end *************")
console.log("************* Observer Test end *************");
})
}
\ No newline at end of file
// @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.
先完成此消息的编辑!
想要评论请 注册