forked from mozilla-b2g/gaia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbrowser_dialer_keypad_and_dial.js
50 lines (38 loc) · 1.59 KB
/
browser_dialer_keypad_and_dial.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
function generatorTest() {
waitForExplicitFinish();
yield testApp('http://dialer.gaiamobile.org/', testDialerKeypad);
finish();
}
function testDialerKeypad(window, document, nextStep) {
function pressKey(button) {
var selector = '.keyboard-key[data-value="' + button + '"]';
var key = document.querySelector(selector);
EventUtils.sendMouseEvent({type: 'mousedown'}, key);
}
//declare each of the keys
function dialNumeric(sequence) {
for (var i = 0; i < sequence.length; i++) {
pressKey(sequence[i]);
}
}
var keyCall = document.querySelector('.keyboard-key[data-value="call"]');
var keyEnd = document.getElementById('end-call');
// Having declared the keys, enter the number "15555215556"
dialNumeric('15555215556');
// Verify the phone number view contains the correct number
ok(document.getElementById('phone-number-view').textContent == '15555215556',
'Phone number view updated');
//dial the number
EventUtils.sendMouseEvent({type: 'click'}, keyCall);
var callScreen = window.CallHandler.callScreen;
// Wait until the call screen appears
yield until(function() callScreen.classList.contains('oncall'), nextStep);
ok(callScreen.classList.contains('oncall'), 'CallScreen displayed');
//hit 'end-call' button to end the call
EventUtils.sendMouseEvent({type: 'click'}, keyEnd);
// simulating the end of the call
window.CallHandler.disconnected();
// Wait for the call screen to be hidden
yield until(function() !callScreen.classList.contains('oncall'), nextStep);
ok(!callScreen.classList.contains('oncall'), 'CallScreen hidden');
}