Skip to content

Commit

Permalink
Fix Flash currentTime test
Browse files Browse the repository at this point in the history
Add a trigger() to the mock Flash implementation and verify that "seeking" is fired the appropriate number of times.
  • Loading branch information
dmlap committed Jul 21, 2015
1 parent 7cc13cf commit 9983434
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions test/unit/tech/flash.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ test('Flash.canPlaySource', function() {
test('currentTime', function() {
let getCurrentTime = Flash.prototype.currentTime;
let setCurrentTime = Flash.prototype.setCurrentTime;
let seekingCount = 0;
let seeking = false;
let setPropVal;
let getPropVal;
Expand All @@ -41,6 +42,11 @@ test('currentTime', function() {
seekable(){
return createTimeRange(5, 1000);
},
trigger(event){
if (event === 'seeking') {
seekingCount++;
}
},
seeking(){
return seeking;
}
Expand All @@ -54,22 +60,26 @@ test('currentTime', function() {
// Test the currentTime setter
setCurrentTime.call(mockFlash, 10);
equal(setPropVal, 10, 'currentTime is set on the swf element');
equal(seekingCount, 1, 'triggered seeking');

// Test current time while seeking
setCurrentTime.call(mockFlash, 20);
seeking = true;
result = getCurrentTime.call(mockFlash);
equal(result, 20, 'currentTime is retrieved from the lastSeekTarget while seeking');
notEqual(result, getPropVal, 'currentTime is not retrieved from the element while seeking');
equal(seekingCount, 2, 'triggered seeking');

// clamp seeks to seekable
setCurrentTime.call(mockFlash, 1001);
result = getCurrentTime.call(mockFlash);
equal(result, mockFlash.seekable().end(0), 'clamped to the seekable end');
equal(seekingCount, 3, 'triggered seeking');

setCurrentTime.call(mockFlash, 1);
result = getCurrentTime.call(mockFlash);
equal(result, mockFlash.seekable().start(0), 'clamped to the seekable start');
equal(seekingCount, 4, 'triggered seeking');
});

test('dispose removes the object element even before ready fires', function() {
Expand Down

0 comments on commit 9983434

Please sign in to comment.