Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/vibration/mock-vibration.html |
| diff --git a/third_party/WebKit/LayoutTests/vibration/mock-vibration.html b/third_party/WebKit/LayoutTests/vibration/mock-vibration.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..5a9d4682b5dadfe4e24bd03e98c96d743bfa6651 |
| --- /dev/null |
| +++ b/third_party/WebKit/LayoutTests/vibration/mock-vibration.html |
| @@ -0,0 +1,53 @@ |
| +<!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.
|
| +<script src="../resources/testharness.js"></script> |
| +<script src="../resources/testharnessreport.js"></script> |
| +<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.
|
| +<script src="../resources/mojo-helpers.js"></script> |
| +<script src="resources/vibration-helpers.js"></script> |
| +<script> |
| + |
| +'use strict'; |
| + |
|
timvolodine
2017/03/08 19:38:31
nit: maybe add
if (!window.testRunner)
debug('
leonhsl(Using Gerrit)
2017/03/09 08:34:10
Done.
|
| +vibration_test(vibration => { |
| + assert_true(vibration instanceof Object); |
| + assert_true(vibration.mockVibrationManager instanceof Object); |
| +}, '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.
|
| + |
| +// 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
|
| +vibration_test(vibration => { |
| + let promise = new Promise(resolve => { |
| + let listener = msg => { |
| + window.removeEventListener('message', listener); |
| + resolve(msg.data); |
| + }; |
| + window.addEventListener('message', listener); |
| + |
| + navigator.vibrate(1234); |
| + }); |
| + |
| + return promise.then(msgData => { |
| + assert_equals(msgData, 'Vibrate'); |
| + assert_equals(vibration.mockVibrationManager.getDuration(), 1234); |
| + assert_false(vibration.mockVibrationManager.isCancelled()); |
| + }); |
| +}, 'navigator.vibrate(1234) can trigger MockVibrationManager vibrate(1234) correctly.'); |
| + |
| +// Cover test case in vibration_browsertest.cc: Cancel |
| +vibration_test(vibration => { |
| + let promise = new Promise(resolve => { |
| + let listener = msg => { |
| + window.removeEventListener('message', listener); |
| + resolve(msg.data); |
| + }; |
| + window.addEventListener('message', listener); |
| + |
| + navigator.vibrate(0); |
| + }); |
| + |
| + return promise.then(msgData => { |
| + assert_equals(msgData, 'Cancel'); |
| + assert_true(vibration.mockVibrationManager.isCancelled()); |
| + }); |
| +}, 'navigator.vibrate(0) can trigger MockVibrationManager cancel() correctly.'); |
| + |
| +</script> |