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

Unified Diff: third_party/WebKit/LayoutTests/media/mediasession/mediasession-integration-test.html

Issue 2401013002: Make MediaSession per frame as an attribute of Navigator (Closed)
Patch Set: fixed tests Created 4 years, 2 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
Index: third_party/WebKit/LayoutTests/media/mediasession/mediasession-integration-test.html
diff --git a/third_party/WebKit/LayoutTests/media/mediasession/mediasession-integration-test.html b/third_party/WebKit/LayoutTests/media/mediasession/mediasession-integration-test.html
new file mode 100644
index 0000000000000000000000000000000000000000..db1409b09506bb94de14727d212170c9b47aba55
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/media/mediasession/mediasession-integration-test.html
@@ -0,0 +1,120 @@
+<!DOCTYPE html>
+<title>MediaSession Integration Test</title>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<script src="../../resources/mojo-helpers.js"></script>
+<script src="resources/mediasessionservice-mock.js"></script>
+<script src="resources/utils.js"></script>
+<script>
+
+var mock;
+// Each entry contains a test object and a test function.
+var pendingTests = [];
+
+// All the tests steps are wrapped into a function, and each test should invoke
+// runPendingTests() on finish.
+
+function runPendingTests() {
+ if (pendingTests.length < 1) {
+ return;
+ }
+ var tmp = pendingTests.pop();
+ var testObj = tmp[0];
+ var testFunc = tmp[1];
+ testFunc(testObj);
+}
+
+promise_test(t => {
+ return mediaSessionServiceMock.then(m => {
whywhat 2016/10/10 20:45:09 can't we just setup the mock up for each test like
Zhiqiang Zhang (Slow) 2016/10/10 21:21:18 Our test here is slightly different. It's because
whywhat 2016/10/11 14:58:33 the budget service tests seem to just create a new
Zhiqiang Zhang (Slow) 2016/10/11 16:59:05 I think in our case, all these tests are used for
whywhat 2016/10/11 18:59:45 First, I don't think there's that much boilerplate
Zhiqiang Zhang (Slow) 2016/10/11 19:39:05 OK. I didn't found any other tests running async_t
+ mock = m;
+ runPendingTests();
+ });
+}, "setting up mock MediaSession service");
+
+function testMetadataPropagated(t) {
+ var metadata = new MediaMetadata({
+ title: "title1",
+ artist: "artist1",
+ album: "album1",
+ artwork: [
+ { src: "http://foo.com/bar.png", type: "image/png", sizes: "128x128" }
+ ]});
+
+ mock.setMetadataStub = function(mojoMetadata) {
whywhat 2016/10/11 18:59:45 I believe you can replace it with step_func(functi
Zhiqiang Zhang (Slow) 2016/10/11 19:39:05 Done.
+ t.step(() => {
+ assert_metadata_equals(metadata, mojoMetadataToJS(mojoMetadata));
mlamouri (slow - plz ping) 2016/10/10 20:30:34 I don't think you should call `mojoMetadataToJS` i
Zhiqiang Zhang (Slow) 2016/10/11 10:56:03 Done.
+ });
+ t.done();
+ runPendingTests();
+ };
+ window.navigator.mediaSession.metadata = metadata;
+}
+
+async_test(t => {
+ pendingTests.push([t, testMetadataPropagated]);
+}, "test that MediaMetadata is correctly propagated");
+
+function testMetadataPropagatedTwice(t) {
+ var dontCareMetadata = new MediaMetadata({});
+
+ mock.setMetadataStub = function() {
+ var metadata = new MediaMetadata({
+ title: "title2",
+ artist: "artist2",
+ album: "album2",
+ artwork: [
+ { src: "http://foo.com/bar.jpg", type: "image/jpeg", sizes: "256x256"}
+ ]});
+
+ mock.setMetadataStub = function(mojoMetadata) {
+ t.step(() => {
+ assert_metadata_equals(metadata, mojoMetadataToJS(mojoMetadata));
+ });
+ t.done();
+ runPendingTests();
+ }
+ window.navigator.mediaSession.metadata = metadata;
+ }
+ window.navigator.mediaSession.metadata = dontCareMetadata;
+}
+
+async_test(t => {
+ pendingTests.push([t, testMetadataPropagatedTwice]);
+}, "test that MediaMetadata is correctly propagated twice");
+
+function testSetNullMetadata(t) {
+ mock.setMetadataStub = function(mojoMetadata) {
+ t.step(() => {
+ assert_false(!!mojoMetadata);
+ });
+ t.done();
+ runPendingTests();
+ };
+ window.navigator.mediaSession.metadata = null;
+}
+
+async_test(t => {
+ pendingTests.push([t, testSetNullMetadata]);
+}, "test that setting null MediaMetadata");
+
+function testFileImageRemoved(t) {
+ var metadata = new MediaMetadata({
+ artwork: [
+ { src: "file:///foo/bar.jpg", type: "image/jpeg"}
+ ]});
+ var expectedMetadata = new MediaMetadata({});
+ mock.setMetadataStub = function(mojoMetadata) {
+ t.step(() => {
+ assert_metadata_equals(expectedMetadata, mojoMetadataToJS(mojoMetadata));
+ });
+ t.done();
+ runPendingTests();
+ }
+ window.navigator.mediaSession.metadata = metadata;
+}
+
+async_test(t => {
+ pendingTests.push([t, testFileImageRemoved]);
+}, "test that file MediaImage is removed");
+
+</script>

Powered by Google App Engine
This is Rietveld 408576698