Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(765)

Unified Diff: LayoutTests/http/tests/media/media-source/mediasource-util.js

Issue 20114005: Layout Test for basic MSE seek scenario. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add notes describing functionality of waitForTimeUpdate. Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « LayoutTests/http/tests/media/media-source/mediasource-play-then-seek-back-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/http/tests/media/media-source/mediasource-util.js
diff --git a/LayoutTests/http/tests/media/media-source/mediasource-util.js b/LayoutTests/http/tests/media/media-source/mediasource-util.js
index 456f012f4d99dc613dbdf3ac07f224d518097e76..181a35a55ee8e485b8034261f2de7eb2b03cbc35 100644
--- a/LayoutTests/http/tests/media/media-source/mediasource-util.js
+++ b/LayoutTests/http/tests/media/media-source/mediasource-util.js
@@ -4,6 +4,7 @@
this.test_ = test;
this.eventTargetList_ = [];
this.waitCallbacks_ = [];
+ this.timeoutIDs_ = {};
wolenetz 2013/08/06 23:06:48 This still needs removal :)
};
EventExpectationsManager.prototype.expectEvent = function(object, eventName, description)
@@ -35,6 +36,21 @@
setTimeout(this.handleWaitCallback_.bind(this), 0);
};
+ EventExpectationsManager.prototype.waitForTimeUpdate = function(mediaElement, callback)
+ {
+ var initialTime = mediaElement.currentTime;
+
+ var onTimeUpdate = this.test_.step_func(function()
+ {
+ if (mediaElement.currentTime != initialTime) {
+ mediaElement.removeEventListener('timeupdate', onTimeUpdate);
+ callback();
+ }
+ });
+
+ mediaElement.addEventListener('timeupdate', onTimeUpdate);
+ };
+
EventExpectationsManager.prototype.expectingEvents = function()
{
for (var i = 0; i < this.eventTargetList_.length; ++i) {
@@ -176,6 +192,14 @@
test.eventExpectations_.expectEvent(object, eventName, description);
};
+ test.waitForTimeUpdate = function(mediaElement, callback)
+ // This function waits for a timeupdate event to be fired accompanied by
+ // a change in currentTime of the mediaElement. Only when both have
+ // occurred does it eventually invoke callback.
+ {
+ test.eventExpectations_.waitForTimeUpdate(mediaElement, callback);
+ }
+
test.waitForExpectedEvents = function(callback)
{
test.eventExpectations_.waitForExpectedEvents(callback);
@@ -184,8 +208,14 @@
var oldTestDone = test.done.bind(test);
test.done = function()
{
- if (test.status == test.PASS)
+ // loop through and clear timeoutIDs
wolenetz 2013/08/06 23:06:48 And clearing timeoutIDs needs removal too.
+ for (var i in test.eventExpectations_.timeoutIDs_) {
+ clearTimeout(test.eventExpectations_.timeoutIDs_[i]);
+ }
+ if (test.status == test.PASS) {
assert_false(test.eventExpectations_.expectingEvents(), "No pending event expectations.");
+ assert_equals(Object.keys(test.eventExpectations_.timeoutIDs_).length, 0);
wolenetz 2013/08/06 23:06:48 And this line also needs removal.
+ }
oldTestDone();
};
};
« no previous file with comments | « LayoutTests/http/tests/media/media-source/mediasource-play-then-seek-back-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698