Publish Vulpes Preview 15 sources for desktop, Android and Tundra
Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
This commit is contained in:
parent
93e3a48004
commit
b38dea0597
25901 changed files with 9982925 additions and 369 deletions
71
gaia/apps/clock/test/marionette/lib/stopwatch_actions.js
Executable file
71
gaia/apps/clock/test/marionette/lib/stopwatch_actions.js
Executable file
|
|
@ -0,0 +1,71 @@
|
|||
'use strict';
|
||||
|
||||
var utils = require('./utils');
|
||||
var $ = require('./mquery');
|
||||
|
||||
function StopwatchActions(client) {
|
||||
this._client = client;
|
||||
}
|
||||
|
||||
module.exports = StopwatchActions;
|
||||
|
||||
StopwatchActions.prototype = {
|
||||
get duration() {
|
||||
return utils.extractDuration($('.stopwatch-time').text());
|
||||
},
|
||||
|
||||
get laps() {
|
||||
return this._client.executeScript(function() {
|
||||
var domItems = document.querySelectorAll('.lap-cell');
|
||||
var laps = [];
|
||||
for (var i = 0; i < domItems.length; i++) {
|
||||
var item = domItems[i];
|
||||
laps.push({
|
||||
name: item.querySelector('.lap-name').textContent,
|
||||
durationString: item.querySelector('.lap-duration').textContent
|
||||
});
|
||||
}
|
||||
return laps;
|
||||
}).map(function(lap) {
|
||||
lap.duration = utils.extractDuration(lap.durationString);
|
||||
return lap;
|
||||
});
|
||||
},
|
||||
|
||||
start: function() {
|
||||
$('.stopwatch-start').tap();
|
||||
this.advanceTime();
|
||||
return this;
|
||||
},
|
||||
|
||||
lap: function() {
|
||||
$('.stopwatch-lap').tap();
|
||||
this.advanceTime();
|
||||
return this;
|
||||
},
|
||||
|
||||
pause: function() {
|
||||
$('.stopwatch-pause').tap();
|
||||
return this;
|
||||
},
|
||||
|
||||
reset: function() {
|
||||
$('.stopwatch-reset').tap();
|
||||
return this;
|
||||
},
|
||||
|
||||
setMaxLaps: function(num) {
|
||||
$('[data-panel-id="stopwatch"]').data('maxLaps', num);
|
||||
return this;
|
||||
},
|
||||
|
||||
advanceTime: function(milliseconds) {
|
||||
milliseconds = milliseconds || 1;
|
||||
var expectedDuration = this.duration + milliseconds;
|
||||
this._client.waitFor(function() {
|
||||
return this.duration >= expectedDuration;
|
||||
}.bind(this));
|
||||
return this;
|
||||
}
|
||||
|
||||
};
|
||||
Loading…
Reference in a new issue