Commit 843eb85a authored by Robbie McElrath's avatar Robbie McElrath Committed by Commit Bot

Migrate devtools deviceorientation layout test to use mojo mocks.

Bug: 802815
Change-Id: Ib69ad4d375648cdd8026b457f274c9a54894c54f
Reviewed-on: https://chromium-review.googlesource.com/1075860
Commit-Queue: Robbie McElrath <rmcelrath@chromium.org>
Reviewed-by: default avatarReilly Grant <reillyg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#562604}
parent 8afe7b3a
...@@ -10,10 +10,9 @@ Running: setUpOrientationSensor ...@@ -10,10 +10,9 @@ Running: setUpOrientationSensor
Running: secondOrientationOverride Running: secondOrientationOverride
Running: clearOverride Running: clearOverride
device-orientation-success.js:22 alpha: 1.1 beta: 2.2 gamma: 3.3 device-orientation-success.js:32 alpha: 1.1 beta: 2.2 gamma: 3.3
device-orientation-success.js:22 alpha: 20 beta: 30 gamma: 40 device-orientation-success.js:32 alpha: 20 beta: 30 gamma: 40
inspected-page.html:1 A reload is required so that the existing AbsoluteOrientationSensor and RelativeOrientationSensor objects on this page use the overridden values that have been provided. Close the inspector and reload again to return to the normal behavior. inspected-page.html:1 A reload is required so that the existing AbsoluteOrientationSensor and RelativeOrientationSensor objects on this page use the overridden values that have been provided. Close the inspector and reload again to return to the normal behavior.
device-orientation-success.js:22 alpha: 90 beta: 0 gamma: 0 device-orientation-success.js:32 alpha: 90 beta: 0 gamma: 0
device-orientation-success.js:29 quaternion: 0.000000,0.000000,0.707107,0.707107 device-orientation-success.js:39 quaternion: 0.000000,0.000000,0.707107,0.707107
device-orientation-success.js:22 alpha: 1.1 beta: 2.2 gamma: 3.3 device-orientation-success.js:32 alpha: 1.1 beta: 2.2 gamma: 3.3
...@@ -5,16 +5,26 @@ ...@@ -5,16 +5,26 @@
(async function() { (async function() {
TestRunner.addResult(`Test device orientation\n`); TestRunner.addResult(`Test device orientation\n`);
await TestRunner.loadModule('console_test_runner'); await TestRunner.loadModule('console_test_runner');
await TestRunner.addScriptTag('/resources/testharness.js');
await TestRunner.addScriptTag('/resources/sensor-helpers.js');
await TestRunner.addScriptTag('/gen/layout_test_data/mojo/public/js/mojo_bindings.js');
await TestRunner.addScriptTag('/gen/services/device/public/mojom/sensor.mojom.js');
await TestRunner.addScriptTag('/gen/services/device/public/mojom/sensor_provider.mojom.js');
await TestRunner.evaluateInPagePromise(` await TestRunner.evaluateInPagePromise(`
var sensor = null;
var mockAlpha = 1.1; var mockAlpha = 1.1;
var mockBeta = 2.2; var mockBeta = 2.2;
var mockGamma = 3.3; var mockGamma = 3.3;
var absolute = true;
function setUpDeviceOrientation() function setUpDeviceOrientation()
{ {
testRunner.setMockDeviceOrientation(true, mockAlpha, true, mockBeta, true, mockGamma, absolute); sensor = sensorMocks();
window.addEventListener("deviceorientation", handler, false); let mockDataPromise = setMockSensorDataForType(
sensor,
device.mojom.SensorType.RELATIVE_ORIENTATION_EULER_ANGLES,
[mockBeta, mockGamma, mockAlpha]);
window.addEventListener("deviceorientation", handler);
return mockDataPromise;
} }
function handler(evt) function handler(evt)
...@@ -33,11 +43,19 @@ ...@@ -33,11 +43,19 @@
+ orientationSensor.quaternion[3].toFixed(6)); + orientationSensor.quaternion[3].toFixed(6));
orientationSensor.start(); orientationSensor.start();
} }
function cleanUpDeviceOrientation()
{
window.removeEventListener("deviceorientation", handler);
sensor.mockSensorProvider.reset();
return new Promise(done => setTimeout(done, 0));
}
`); `);
TestRunner.runTestSuite([ TestRunner.runTestSuite([
function setUpDeviceOrientation(next) { async function setUpDeviceOrientation(next) {
TestRunner.evaluateInPage('setUpDeviceOrientation()', next); await TestRunner.evaluateInPageAsync('setUpDeviceOrientation()');
ConsoleTestRunner.addConsoleSniffer(next);
}, },
function firstOrientationOverride(next) { function firstOrientationOverride(next) {
...@@ -56,6 +74,7 @@ ...@@ -56,6 +74,7 @@
async function clearOverride(next) { async function clearOverride(next) {
await TestRunner.DeviceOrientationAgent.clearDeviceOrientationOverride(); await TestRunner.DeviceOrientationAgent.clearDeviceOrientationOverride();
await TestRunner.evaluateInPageAsync('cleanUpDeviceOrientation()');
ConsoleTestRunner.dumpConsoleMessages(); ConsoleTestRunner.dumpConsoleMessages();
next(); next();
}, },
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment