OLD | NEW |
---|---|
(Empty) | |
1 <!DOCTYPE html> | |
2 <title>MediaSession Mojo 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 | |
12 function runTests() { | |
13 async_test(function(t) { | |
14 window.navigator.mediaSession.onplay = t.step_func_done(); | |
15 mock.getClient().didReceivedAction(0); | |
16 }, "test that onplay handler is notified correctly"); | |
17 | |
18 async_test(function(t) { | |
19 window.navigator.mediaSession.onpause = t.step_func_done(); | |
20 mock.getClient().didReceivedAction(1); | |
21 }, "test that onpause handler is notified correctly"); | |
22 | |
23 async_test(function(t) { | |
24 window.navigator.mediaSession.onplaypause = t.step_func_done(); | |
25 mock.getClient().didReceivedAction(2); | |
26 }, "test that onplaypause handler is notified correctly"); | |
27 | |
28 async_test(function(t) { | |
29 window.navigator.mediaSession.onprevioustrack = t.step_func_done(); | |
30 mock.getClient().didReceivedAction(3); | |
31 }, "test that onprevioustrack handler is notified correctly"); | |
32 | |
33 async_test(function(t) { | |
34 window.navigator.mediaSession.onnexttrack = t.step_func_done(); | |
35 mock.getClient().didReceivedAction(4); | |
36 }, "test that onnexttrack handler is notified correctly"); | |
37 | |
38 async_test(function(t) { | |
39 window.navigator.mediaSession.onseekforward = t.step_func_done(); | |
40 mock.getClient().didReceivedAction(5); | |
41 }, "test that onseekforward handler is notified correctly"); | |
42 | |
43 async_test(function(t) { | |
44 window.navigator.mediaSession.onseekbackward = t.step_func_done(); | |
45 mock.getClient().didReceivedAction(6); | |
46 }, "test that onseekbackward handler is notified correctly"); | |
47 | |
48 } | |
49 | |
50 // Use async_test to do asynchronous setup since setup() only works for | |
51 // synchronous setup. | |
52 async_test(function(t) { | |
53 mediaSessionServiceMock.then(m => { | |
54 mock = m; | |
55 m.setClientCallback(t.step_func_done(_ => { | |
whywhat
2016/10/18 21:02:57
it seems like you could just use t.step_func() her
Zhiqiang Zhang (Slow)
2016/10/19 12:52:06
I'm doing similar as the "set-handler-notifies-ser
| |
56 runTests(); | |
57 })); | |
58 // Touch window.navigator.mediaSession to start the service. | |
59 window.navigator.mediaSession.metadata = null; | |
60 }); | |
61 }, "test that the mock service is setup"); | |
62 | |
63 </script> | |
OLD | NEW |