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

Side by Side Diff: third_party/WebKit/LayoutTests/sensor/ambient-light-sensor.html

Issue 2465363004: [Sensors] Consider maximum supported frequency (Closed)
Patch Set: Comments from Alex Created 4 years, 1 month 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 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <script src="../resources/testharness.js"></script> 2 <script src="../resources/testharness.js"></script>
3 <script src="../resources/testharnessreport.js"></script> 3 <script src="../resources/testharnessreport.js"></script>
4 <script src="../resources/mojo-helpers.js"></script> 4 <script src="../resources/mojo-helpers.js"></script>
5 <script src="resources/sensor-helpers.js"></script> 5 <script src="resources/sensor-helpers.js"></script>
6 <script> 6 <script>
7 7
8 'use strict'; 8 'use strict';
9 9
10 if (!window.testRunner) 10 if (!window.testRunner)
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 } 91 }
92 }; 92 };
93 }); 93 });
94 }) 94 })
95 .then(mockSensor => { return mockSensor.removeConfigurationCalled(); }); 95 .then(mockSensor => { return mockSensor.removeConfigurationCalled(); });
96 96
97 return testPromise; 97 return testPromise;
98 }, 'Test that frequency is capped to 60.0 Hz.'); 98 }, 'Test that frequency is capped to 60.0 Hz.');
99 99
100 sensor_test(sensor => { 100 sensor_test(sensor => {
101 let maxSupportedFrequency = 15;
102 sensor.mockSensorProvider.setMaximumSupportedFrequency(maxSupportedFrequency);
103 let ambientLightSensor = new AmbientLightSensor({frequency: 50});
104 ambientLightSensor.start();
105
106 let testPromise = sensor.mockSensorProvider.getCreatedSensor()
107 .then(mockSensor => { return mockSensor.addConfigurationCalled(); })
108 .then(mockSensor => {
109 return new Promise((resolve, reject) => {
110 ambientLightSensor.onstatechange = event => {
111 if (ambientLightSensor.state === 'idle') {
112 resolve(mockSensor);
113 }
114
115 if (ambientLightSensor.state === 'active') {
116 let configuration = mockSensor.active_sensor_configurations_[0];
117 assert_equals(configuration.frequency, maxSupportedFrequency);
118 ambientLightSensor.stop();
119 }
120 };
121 });
122 })
123 .then(mockSensor => { return mockSensor.removeConfigurationCalled(); });
124
125 return testPromise;
126 }, 'Test that frequency is capped to the maximum supported from frequency.');
127
128 sensor_test(sensor => {
101 let ambientLightSensor = new AmbientLightSensor({frequency: 60}); 129 let ambientLightSensor = new AmbientLightSensor({frequency: 60});
102 ambientLightSensor.start(); 130 ambientLightSensor.start();
103 let testPromise = sensor.mockSensorProvider.getCreatedSensor() 131 let testPromise = sensor.mockSensorProvider.getCreatedSensor()
104 .then((mockSensor) => { 132 .then((mockSensor) => {
105 return new Promise((resolve, reject) => { 133 return new Promise((resolve, reject) => {
106 ambientLightSensor.onstatechange = event => { 134 ambientLightSensor.onstatechange = event => {
107 if (ambientLightSensor.state === 'idle') { 135 if (ambientLightSensor.state === 'idle') {
108 resolve(mockSensor); 136 resolve(mockSensor);
109 } 137 }
110 138
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 ambientLightSensor.onerror = reject; 288 ambientLightSensor.onerror = reject;
261 }); 289 });
262 }) 290 })
263 .then(mockSensor => { return mockSensor.removeConfigurationCalled(); }); 291 .then(mockSensor => { return mockSensor.removeConfigurationCalled(); });
264 292
265 return testPromise; 293 return testPromise;
266 }, 'Test that sensor receives suspend / resume notifications when page' 294 }, 'Test that sensor receives suspend / resume notifications when page'
267 +' visibility changes.'); 295 +' visibility changes.');
268 296
269 </script> 297 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698