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

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

Issue 2668443002: Fix sensors layout tests flakiness (Closed)
Patch Set: Created 3 years, 10 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
« no previous file with comments | « third_party/WebKit/LayoutTests/TestExpectations ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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})),
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 fastSensor.start(); 303 fastSensor.start();
304 readingUpdatesCounter = mockSensor.reading_updates_count(); 304 readingUpdatesCounter = mockSensor.reading_updates_count();
305 } else if (slowSensorNotifiedCounter == 2) { 305 } else if (slowSensorNotifiedCounter == 2) {
306 // By the moment slow sensor (9 Hz) is notified for the 306 // By the moment slow sensor (9 Hz) is notified for the
307 // next time, the fast sensor (30 Hz) has been notified 307 // next time, the fast sensor (30 Hz) has been notified
308 // for int(30/9) = 3 times. 308 // for int(30/9) = 3 times.
309 // In actual implementation updates are bound to rAF, 309 // In actual implementation updates are bound to rAF,
310 // (not to a timer) so fluctuations are possible, so we 310 // (not to a timer) so fluctuations are possible, so we
311 // reference to the actual elapsed updates count. 311 // reference to the actual elapsed updates count.
312 let elapsedUpdates = mockSensor.reading_updates_count() - readin gUpdatesCounter; 312 let elapsedUpdates = mockSensor.reading_updates_count() - readin gUpdatesCounter;
313 assert_equals(fastSensorNotifiedCounter, elapsedUpdates); 313 assert_approx_equals(fastSensorNotifiedCounter, elapsedUpdates, 1);
314 fastSensor.stop(); 314 fastSensor.stop();
315 slowSensor.stop(); 315 slowSensor.stop();
316 resolve(mockSensor); 316 resolve(mockSensor);
317 } 317 }
318 }, reject); 318 }, reject);
319 319
320 fastSensor.onchange = fastSensorWrapper.callback; 320 fastSensor.onchange = fastSensorWrapper.callback;
321 slowSensor.onchange = slowSensorWrapper.callback; 321 slowSensor.onchange = slowSensorWrapper.callback;
322 fastSensor.onerror = reject; 322 fastSensor.onerror = reject;
323 slowSensor.onerror = reject; 323 slowSensor.onerror = reject;
324 }); 324 });
325 }) 325 })
326 .then(mockSensor => { return mockSensor.removeConfigurationCalled(); }); 326 .then(mockSensor => { return mockSensor.removeConfigurationCalled(); });
327 327
328 return testPromise; 328 return testPromise;
329 } 329 }
330 330
331 sensor_test(sensor => { 331 sensor_test(sensor => {
332 return checkFrequencyHintWorks(sensor); 332 return checkFrequencyHintWorks(sensor);
333 }, 'Test that frequency hint works (onchange reporting).'); 333 }, 'Test that frequency hint works (onchange reporting).');
334 334
335 sensor_test(sensor => { 335 sensor_test(sensor => {
336 sensor.mockSensorProvider.setContinuousReportingMode(); 336 sensor.mockSensorProvider.setContinuousReportingMode();
337 return checkFrequencyHintWorks(sensor); 337 return checkFrequencyHintWorks(sensor);
338 }, 'Test that frequency hint works (continuous reporting).'); 338 }, 'Test that frequency hint works (continuous reporting).');
339 } 339 }
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/TestExpectations ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698