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

Unified Diff: third_party/WebKit/LayoutTests/sensor/orientation-sensor.html

Issue 2908393002: [Sensors] Bindings for RelativeOrientationSensor (Closed)
Patch Set: Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/sensor/orientation-sensor.html
diff --git a/third_party/WebKit/LayoutTests/sensor/absolute-orientation-sensor.html b/third_party/WebKit/LayoutTests/sensor/orientation-sensor.html
similarity index 52%
rename from third_party/WebKit/LayoutTests/sensor/absolute-orientation-sensor.html
rename to third_party/WebKit/LayoutTests/sensor/orientation-sensor.html
index 74555b8bf73a78c00113b1cea3d9ade8deada5cc..b7abc8bc357d76b7f12ac0134c0df532b727e89f 100644
--- a/third_party/WebKit/LayoutTests/sensor/absolute-orientation-sensor.html
+++ b/third_party/WebKit/LayoutTests/sensor/orientation-sensor.html
@@ -36,10 +36,8 @@ function verify_sensor_reading(sensor, should_be_null) {
return true;
}
-runGenericSensorTests(AbsoluteOrientationSensor, update_sensor_reading, verify_sensor_reading);
-
-sensor_test(sensor => {
- let sensorObject = new AbsoluteOrientationSensor();
+function checkPopulateMatrix(sensor, sensorType) {
+ let sensorObject = new sensorType();
// Throws with insufficient buffer space.
assert_throws({ name: 'TypeError' }, () => sensorObject.populateMatrix(new Float32Array(15)));
@@ -55,39 +53,52 @@ sensor_test(sensor => {
sensorObject.start();
return sensor.mockSensorProvider.getCreatedSensor()
- .then(mockSensor => {
- return mockSensor.setUpdateSensorReadingFunction(update_sensor_reading);
- })
- .then(mockSensor => {
- return new Promise((resolve, reject) => {
- let wrapper = new CallbackWrapper(() => {
- // Works for all supported types.
- let rotationMatrix32 = new Float32Array(16);
- sensorObject.populateMatrix(rotationMatrix32);
- assert_array_equals(rotationMatrix32, kRotationMatrix);
-
- let rotationMatrix64 = new Float64Array(16);
- sensorObject.populateMatrix(rotationMatrix64);
- assert_array_equals(rotationMatrix64, kRotationMatrix);
-
- let rotationDOMMatrix = new DOMMatrix();
- sensorObject.populateMatrix(rotationDOMMatrix);
- assert_array_equals(rotationDOMMatrix, kRotationDOMMatrix);
-
- // Sets every matrix element.
- rotationMatrix64.fill(123);
- sensorObject.populateMatrix(rotationMatrix64);
- assert_array_equals(rotationMatrix64, kRotationMatrix);
-
- sensorObject.stop();
- resolve(mockSensor);
- }, reject);
-
- sensorObject.onchange = wrapper.callback;
- sensorObject.onerror = reject;
- });
- })
- .then(mockSensor => { return mockSensor.removeConfigurationCalled(); });
+ .then(mockSensor => {
+ return mockSensor.setUpdateSensorReadingFunction(update_sensor_reading);
+ })
+ .then(mockSensor => {
+ return new Promise((resolve, reject) => {
+ let wrapper = new CallbackWrapper(() => {
+ // Works for all supported types.
+ let rotationMatrix32 = new Float32Array(16);
+ sensorObject.populateMatrix(rotationMatrix32);
+ assert_array_equals(rotationMatrix32, kRotationMatrix);
+
+ let rotationMatrix64 = new Float64Array(16);
+ sensorObject.populateMatrix(rotationMatrix64);
+ assert_array_equals(rotationMatrix64, kRotationMatrix);
+
+ let rotationDOMMatrix = new DOMMatrix();
+ sensorObject.populateMatrix(rotationDOMMatrix);
+ assert_array_equals(rotationDOMMatrix, kRotationDOMMatrix);
+
+ // Sets every matrix element.
+ rotationMatrix64.fill(123);
+ sensorObject.populateMatrix(rotationMatrix64);
+ assert_array_equals(rotationMatrix64, kRotationMatrix);
+
+ sensorObject.stop();
+ resolve(mockSensor);
+ }, reject);
+
+ sensorObject.onchange = wrapper.callback;
+ sensorObject.onerror = reject;
+ });
+ })
+ .then(mockSensor => { return mockSensor.removeConfigurationCalled(); });
Reilly Grant (use Gerrit) 2017/05/30 18:41:48 .then(mockSensor => mockSensor.removeConfiguration
+}
+
+
+runGenericSensorTests(AbsoluteOrientationSensor, update_sensor_reading, verify_sensor_reading);
+
+sensor_test(sensor => {
+ return checkPopulateMatrix(sensor, AbsoluteOrientationSensor);
}, 'Test AbsoluteOrientationSensor.populateMatrix() method works correctly.');
+runGenericSensorTests(RelativeOrientationSensor, update_sensor_reading, verify_sensor_reading);
+
+sensor_test(sensor => {
+ return checkPopulateMatrix(sensor, RelativeOrientationSensor);
+}, 'Test RelativeOrientationSensor.populateMatrix() method works correctly.');
+
</script>

Powered by Google App Engine
This is Rietveld 408576698