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

Side by Side Diff: third_party/WebKit/LayoutTests/sensor/resources/generic-sensor-tests.js

Issue 2529343002: [sensors] Fix flakiness in generic sensors tests (Closed)
Patch Set: Created 4 years 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
1 'use strict'; 1 'use strict';
2 2
3 // Run a set of tests for a given |sensorType|. |updateReading| is 3 // Run a set of tests for a given |sensorType|. |updateReading| is
4 // a called by the test to provide the mock values for sensor. |verifyReading| 4 // a called by the test to provide the mock values for sensor. |verifyReading|
5 // is called so that the value read in JavaScript are the values expected (the o nes 5 // is called so that the value read in JavaScript are the values expected (the o nes
6 // sent by |updateReading|). 6 // sent by |updateReading|).
7 function runGenericSensorTests(sensorType, updateReading, verifyReading) { 7 function runGenericSensorTests(sensorType, updateReading, verifyReading) {
8 test(() => assert_throws( 8 test(() => assert_throws(
9 new RangeError(), 9 new RangeError(),
10 () => new sensorType({frequency: -60})), 10 () => new sensorType({frequency: -60})),
11 'Test that negative frequency causes exception from constructor.'); 11 'Test that negative frequency causes exception from constructor.');
12 12
13 sensor_test(sensor => { 13 sensor_test(sensor => {
14 sensor.mockSensorProvider.setGetSensorShouldFail(true); 14 sensor.mockSensorProvider.setGetSensorShouldFail(true);
15 let sensorObject = new sensorType; 15 let sensorObject = new sensorType;
16 sensorObject.start(); 16 sensorObject.start();
17 return new Promise((resolve, reject) => { 17 return new Promise((resolve, reject) => {
18 let wrapper = new CallbackWrapper(event => { 18 let wrapper = new CallbackWrapper(event => {
19 assert_equals(sensorObject.state, 'errored'); 19 assert_equals(sensorObject.state, 'errored');
20 console.log(event.error.message);
21 assert_equals(event.error.name, 'NotFoundError'); 20 assert_equals(event.error.name, 'NotFoundError');
22 sensorObject.onerror = null; 21 sensorObject.onerror = null;
23 resolve(); 22 resolve();
24 }, reject); 23 }, reject);
25 24
26 sensorObject.onerror = wrapper.callback; 25 sensorObject.onerror = wrapper.callback;
27 }); 26 });
28 }, 'Test that "onerror" is send when sensor is not supported.'); 27 }, 'Test that "onerror" is send when sensor is not supported.');
29 28
30 sensor_test(sensor => { 29 sensor_test(sensor => {
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 sensor1.onchange = wrapper.callback; 260 sensor1.onchange = wrapper.callback;
262 sensor1.onerror = reject; 261 sensor1.onerror = reject;
263 sensor2.onerror = reject; 262 sensor2.onerror = reject;
264 }); 263 });
265 }) 264 })
266 .then(mockSensor => { return mockSensor.removeConfigurationCalled(); }); 265 .then(mockSensor => { return mockSensor.removeConfigurationCalled(); });
267 266
268 return testPromise; 267 return testPromise;
269 }, 'Test that sensor reading is correct.'); 268 }, 'Test that sensor reading is correct.');
270 } 269 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698