OLD | NEW |
---|---|
(Empty) | |
1 <!DOCTYPE html> | |
2 <title>MediaSession Integration Test</title> | |
3 <script src="../../resources/testharness.js"></script> | |
4 <script src="../../resources/testharnessreport.js"></script> | |
5 <script src="../../resources/mojo-helpers.js"></script> | |
6 <script src="resources/mediasessionservice-mock.js"></script> | |
7 <script src="resources/utils.js"></script> | |
8 <script> | |
9 | |
10 var mock; | |
11 // Each entry contains a test object and a test function. | |
12 var pendingTests = []; | |
13 | |
14 // All the tests steps are wrapped into a function, and each test should invoke | |
15 // runPendingTests() on finish. | |
16 | |
17 function runPendingTests() { | |
18 if (pendingTests.length < 1) { | |
19 return; | |
20 } | |
21 var tmp = pendingTests.pop(); | |
22 var testObj = tmp[0]; | |
23 var testFunc = tmp[1]; | |
24 testFunc(testObj); | |
25 } | |
26 | |
27 promise_test(t => { | |
28 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
| |
29 mock = m; | |
30 runPendingTests(); | |
31 }); | |
32 }, "setting up mock MediaSession service"); | |
33 | |
34 function testMetadataPropagated(t) { | |
35 var metadata = new MediaMetadata({ | |
36 title: "title1", | |
37 artist: "artist1", | |
38 album: "album1", | |
39 artwork: [ | |
40 { src: "http://foo.com/bar.png", type: "image/png", sizes: "128x128" } | |
41 ]}); | |
42 | |
43 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.
| |
44 t.step(() => { | |
45 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.
| |
46 }); | |
47 t.done(); | |
48 runPendingTests(); | |
49 }; | |
50 window.navigator.mediaSession.metadata = metadata; | |
51 } | |
52 | |
53 async_test(t => { | |
54 pendingTests.push([t, testMetadataPropagated]); | |
55 }, "test that MediaMetadata is correctly propagated"); | |
56 | |
57 function testMetadataPropagatedTwice(t) { | |
58 var dontCareMetadata = new MediaMetadata({}); | |
59 | |
60 mock.setMetadataStub = function() { | |
61 var metadata = new MediaMetadata({ | |
62 title: "title2", | |
63 artist: "artist2", | |
64 album: "album2", | |
65 artwork: [ | |
66 { src: "http://foo.com/bar.jpg", type: "image/jpeg", sizes: "256x256"} | |
67 ]}); | |
68 | |
69 mock.setMetadataStub = function(mojoMetadata) { | |
70 t.step(() => { | |
71 assert_metadata_equals(metadata, mojoMetadataToJS(mojoMetadata)); | |
72 }); | |
73 t.done(); | |
74 runPendingTests(); | |
75 } | |
76 window.navigator.mediaSession.metadata = metadata; | |
77 } | |
78 window.navigator.mediaSession.metadata = dontCareMetadata; | |
79 } | |
80 | |
81 async_test(t => { | |
82 pendingTests.push([t, testMetadataPropagatedTwice]); | |
83 }, "test that MediaMetadata is correctly propagated twice"); | |
84 | |
85 function testSetNullMetadata(t) { | |
86 mock.setMetadataStub = function(mojoMetadata) { | |
87 t.step(() => { | |
88 assert_false(!!mojoMetadata); | |
89 }); | |
90 t.done(); | |
91 runPendingTests(); | |
92 }; | |
93 window.navigator.mediaSession.metadata = null; | |
94 } | |
95 | |
96 async_test(t => { | |
97 pendingTests.push([t, testSetNullMetadata]); | |
98 }, "test that setting null MediaMetadata"); | |
99 | |
100 function testFileImageRemoved(t) { | |
101 var metadata = new MediaMetadata({ | |
102 artwork: [ | |
103 { src: "file:///foo/bar.jpg", type: "image/jpeg"} | |
104 ]}); | |
105 var expectedMetadata = new MediaMetadata({}); | |
106 mock.setMetadataStub = function(mojoMetadata) { | |
107 t.step(() => { | |
108 assert_metadata_equals(expectedMetadata, mojoMetadataToJS(mojoMetadata)); | |
109 }); | |
110 t.done(); | |
111 runPendingTests(); | |
112 } | |
113 window.navigator.mediaSession.metadata = metadata; | |
114 } | |
115 | |
116 async_test(t => { | |
117 pendingTests.push([t, testFileImageRemoved]); | |
118 }, "test that file MediaImage is removed"); | |
119 | |
120 </script> | |
OLD | NEW |