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

Side by Side Diff: third_party/WebKit/LayoutTests/vibration/mock-vibration.html

Issue 2731953003: [DeviceService] Replace vibration_browsertest.cc with layout tests. (Closed)
Patch Set: Created 3 years, 9 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 unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE html>
timvolodine 2017/03/08 19:38:31 does it make sense to call this file mock-vibratio
leonhsl(Using Gerrit) 2017/03/09 08:34:10 Done.
2 <script src="../resources/testharness.js"></script>
3 <script src="../resources/testharnessreport.js"></script>
4 <script src="../resources/testharness-helpers.js"></script>
timvolodine 2017/03/08 19:38:31 is this needed?
leonhsl(Using Gerrit) 2017/03/09 08:34:10 Yeah not necessary, removed.
5 <script src="../resources/mojo-helpers.js"></script>
6 <script src="resources/vibration-helpers.js"></script>
7 <script>
8
9 'use strict';
10
timvolodine 2017/03/08 19:38:31 nit: maybe add if (!window.testRunner) debug('
leonhsl(Using Gerrit) 2017/03/09 08:34:10 Done.
11 vibration_test(vibration => {
12 assert_true(vibration instanceof Object);
13 assert_true(vibration.mockVibrationManager instanceof Object);
14 }, 'VibrationManager Mojo bindings and mock interfaces are available.');
timvolodine 2017/03/08 19:38:31 nit: '.. are available to tests.' (for consistency
leonhsl(Using Gerrit) 2017/03/09 08:34:10 Done.
15
16 // Cover test case in vibration_browsertest.cc: Vibrate
leonhsl(Using Gerrit) 2017/03/08 09:14:34 This comment is to make review easier, will delete
17 vibration_test(vibration => {
18 let promise = new Promise(resolve => {
19 let listener = msg => {
20 window.removeEventListener('message', listener);
21 resolve(msg.data);
22 };
23 window.addEventListener('message', listener);
24
25 navigator.vibrate(1234);
26 });
27
28 return promise.then(msgData => {
29 assert_equals(msgData, 'Vibrate');
30 assert_equals(vibration.mockVibrationManager.getDuration(), 1234);
31 assert_false(vibration.mockVibrationManager.isCancelled());
32 });
33 }, 'navigator.vibrate(1234) can trigger MockVibrationManager vibrate(1234) corre ctly.');
34
35 // Cover test case in vibration_browsertest.cc: Cancel
36 vibration_test(vibration => {
37 let promise = new Promise(resolve => {
38 let listener = msg => {
39 window.removeEventListener('message', listener);
40 resolve(msg.data);
41 };
42 window.addEventListener('message', listener);
43
44 navigator.vibrate(0);
45 });
46
47 return promise.then(msgData => {
48 assert_equals(msgData, 'Cancel');
49 assert_true(vibration.mockVibrationManager.isCancelled());
50 });
51 }, 'navigator.vibrate(0) can trigger MockVibrationManager cancel() correctly.');
52
53 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698