forked from mozilla-b2g/gaia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
browser_clock_stopwatch.js
36 lines (30 loc) · 1.36 KB
/
browser_clock_stopwatch.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
function generatorTest() {
waitForExplicitFinish();
yield testApp('http://clock.gaiamobile.org/', testStopwatch);
finish();
}
function testStopwatch(window, document, nextStep) {
var stopWatch = window.StopWatch;
var actionButton = document.getElementById('stopwatch-action-button');
var tickerView = document.getElementById('stopwatch-ticker-view');
// start the stopwatch
EventUtils.sendMouseEvent({type: 'click'}, actionButton);
yield setTimeout(nextStep, 100);
ok(actionButton.dataset.action == 'stop', 'Stop button present');
ok(tickerView.classList.contains('running'), 'Animation running');
isnot(stopWatch._startTime, undefined, 'Start time set');
isnot(stopWatch._ticker, undefined, 'Ticker running');
// stop the stopwatch
EventUtils.sendMouseEvent({type: 'click'}, actionButton);
yield setTimeout(nextStep, 100);
ok(actionButton.dataset.action == 'start', 'Start button present');
ok(!tickerView.classList.contains('running'), 'Animation stoped');
isnot(stopWatch._elasped, 0, 'Elapsed time kept');
is(stopWatch._ticker, undefined, 'Ticker cleared');
is(stopWatch._startTime, undefined, 'Start time deleted');
// reset the stopwatch
EventUtils.sendMouseEvent({type: 'click'},
document.getElementById('reset-button'));
yield setTimeout(nextStep, 100);
is(stopWatch._elapsed, 0, 'Elapsed time reset');
}