OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/synchronization/waitable_event.h" | 6 #include "base/synchronization/waitable_event.h" |
7 #include "base/threading/platform_thread.h" | 7 #include "base/threading/platform_thread.h" |
8 #include "content/browser/device_sensors/data_fetcher_shared_memory.h" | 8 #include "content/browser/device_sensors/data_fetcher_shared_memory.h" |
9 #include "content/browser/device_sensors/device_inertial_sensor_service.h" | 9 #include "content/browser/device_sensors/device_inertial_sensor_service.h" |
10 #include "content/common/device_sensors/device_light_hardware_buffer.h" | 10 #include "content/common/device_sensors/device_light_hardware_buffer.h" |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 shell()->LoadURL(test_url); | 284 shell()->LoadURL(test_url); |
285 | 285 |
286 WaitForAlertDialogAndQuitAfterDelay(base::TimeDelta::FromMilliseconds(1000)); | 286 WaitForAlertDialogAndQuitAfterDelay(base::TimeDelta::FromMilliseconds(1000)); |
287 | 287 |
288 fetcher_->started_light_.Wait(); | 288 fetcher_->started_light_.Wait(); |
289 fetcher_->stopped_light_.Wait(); | 289 fetcher_->stopped_light_.Wait(); |
290 same_tab_observer.Wait(); | 290 same_tab_observer.Wait(); |
291 EXPECT_EQ("pass", shell()->web_contents()->GetLastCommittedURL().ref()); | 291 EXPECT_EQ("pass", shell()->web_contents()->GetLastCommittedURL().ref()); |
292 } | 292 } |
293 | 293 |
294 // Flaky. See http://crbug.com/360578. | 294 IN_PROC_BROWSER_TEST_F(DeviceInertialSensorBrowserTest, OrientationNullTest) { |
295 #if defined(OS_ANDROID) || defined(OS_WIN) || defined(OS_LINUX) | 295 // The test page registers an event handler for orientation events and |
296 #define MAYBE_OrientationNullTestWithAlert DISABLED_OrientationNullTestWithAlert | 296 // expects to get an event with null values, because no sensor data can be |
297 #else | 297 // provided. |
298 #define MAYBE_OrientationNullTestWithAlert OrientationNullTestWithAlert | 298 fetcher_->SetSensorDataAvailable(false); |
299 #endif | 299 GURL test_url = GetTestUrl("device_sensors", |
300 IN_PROC_BROWSER_TEST_F(DeviceInertialSensorBrowserTest, | 300 "device_orientation_null_test.html"); |
301 MAYBE_OrientationNullTestWithAlert) { | 301 NavigateToURLBlockUntilNavigationsComplete(shell(), test_url, 2); |
302 // The test page will register an event handler for orientation events, | 302 EXPECT_EQ("pass", shell()->web_contents()->GetLastCommittedURL().ref()); |
303 // expects to get an event with null values. The test raises a modal alert | 303 fetcher_->started_orientation_.Wait(); |
304 // dialog with a delay to test that the one-off null-event still propagates | 304 fetcher_->stopped_orientation_.Wait(); |
305 // to window after the alert is dismissed and the callback is invoked which | 305 } |
306 // navigates to #pass. | 306 |
| 307 IN_PROC_BROWSER_TEST_F(DeviceInertialSensorBrowserTest, MotionNullTest) { |
| 308 // The test page registers an event handler for motion events and |
| 309 // expects to get an event with null values, because no sensor data can be |
| 310 // provided. |
| 311 fetcher_->SetSensorDataAvailable(false); |
| 312 GURL test_url = GetTestUrl("device_sensors", |
| 313 "device_motion_null_test.html"); |
| 314 NavigateToURLBlockUntilNavigationsComplete(shell(), test_url, 2); |
| 315 |
| 316 EXPECT_EQ("pass", shell()->web_contents()->GetLastCommittedURL().ref()); |
| 317 fetcher_->started_motion_.Wait(); |
| 318 fetcher_->stopped_motion_.Wait(); |
| 319 } |
| 320 |
| 321 IN_PROC_BROWSER_TEST_F(DeviceInertialSensorBrowserTest, NullTestWithAlert) { |
| 322 // The test page registers an event handlers for motion/orientation events |
| 323 // and expects to get events with null values. The test raises a modal alert |
| 324 // dialog with a delay to test that the one-off null-events still propagate |
| 325 // to window after the alert is dismissed and the callbacks are invoked which |
| 326 // eventually navigate to #pass. |
307 fetcher_->SetSensorDataAvailable(false); | 327 fetcher_->SetSensorDataAvailable(false); |
308 TestNavigationObserver same_tab_observer(shell()->web_contents(), 2); | 328 TestNavigationObserver same_tab_observer(shell()->web_contents(), 2); |
309 | 329 |
310 GURL test_url = GetTestUrl("device_sensors", | 330 GURL test_url = GetTestUrl("device_sensors", |
311 "device_orientation_null_test_with_alert.html"); | 331 "device_sensors_null_test_with_alert.html"); |
312 shell()->LoadURL(test_url); | 332 shell()->LoadURL(test_url); |
313 | 333 |
314 // TODO(timvolodine): investigate if it is possible to test this without | 334 // TODO(timvolodine): investigate if it is possible to test this without |
315 // delay, crbug.com/360044. | 335 // delay, crbug.com/360044. |
316 WaitForAlertDialogAndQuitAfterDelay(base::TimeDelta::FromMilliseconds(1000)); | 336 WaitForAlertDialogAndQuitAfterDelay(base::TimeDelta::FromMilliseconds(500)); |
317 | 337 |
| 338 fetcher_->started_motion_.Wait(); |
| 339 fetcher_->stopped_motion_.Wait(); |
318 fetcher_->started_orientation_.Wait(); | 340 fetcher_->started_orientation_.Wait(); |
319 fetcher_->stopped_orientation_.Wait(); | 341 fetcher_->stopped_orientation_.Wait(); |
320 same_tab_observer.Wait(); | 342 same_tab_observer.Wait(); |
321 EXPECT_EQ("pass", shell()->web_contents()->GetLastCommittedURL().ref()); | 343 EXPECT_EQ("pass", shell()->web_contents()->GetLastCommittedURL().ref()); |
322 } | 344 } |
323 | |
324 // Flaky. See http://crbug.com/360578. | |
325 #if defined(OS_ANDROID) || defined(OS_WIN) || defined(OS_LINUX) | |
326 #define MAYBE_MotionNullTestWithAlert DISABLED_MotionNullTestWithAlert | |
327 #else | |
328 #define MAYBE_MotionNullTestWithAlert MotionNullTestWithAlert | |
329 #endif | |
330 IN_PROC_BROWSER_TEST_F(DeviceInertialSensorBrowserTest, | |
331 MAYBE_MotionNullTestWithAlert) { | |
332 // The test page will register an event handler for motion events, | |
333 // expects to get an event with null values. The test raises a modal alert | |
334 // dialog with a delay to test that the one-off null-event still propagates | |
335 // to window after the alert is dismissed and the callback is invoked which | |
336 // navigates to #pass. | |
337 fetcher_->SetSensorDataAvailable(false); | |
338 TestNavigationObserver same_tab_observer(shell()->web_contents(), 2); | |
339 | |
340 GURL test_url = | |
341 GetTestUrl("device_sensors", "device_motion_null_test_with_alert.html"); | |
342 shell()->LoadURL(test_url); | |
343 | |
344 // TODO(timvolodine): investigate if it is possible to test this without | |
345 // delay, crbug.com/360044. | |
346 WaitForAlertDialogAndQuitAfterDelay(base::TimeDelta::FromMilliseconds(1000)); | |
347 | |
348 fetcher_->started_motion_.Wait(); | |
349 fetcher_->stopped_motion_.Wait(); | |
350 same_tab_observer.Wait(); | |
351 EXPECT_EQ("pass", shell()->web_contents()->GetLastCommittedURL().ref()); | |
352 } | |
353 | 345 |
354 } // namespace | 346 } // namespace |
355 | 347 |
356 } // namespace content | 348 } // namespace content |
OLD | NEW |