Chromium Code Reviews| Index: content/browser/device_orientation/device_orientation_browsertest.cc |
| diff --git a/content/browser/device_orientation/device_orientation_browsertest.cc b/content/browser/device_orientation/device_orientation_browsertest.cc |
| index f30346ff4160285b796e2f131ad407da3844b697..2d64b81a46329473073849d9799a0fac3fc290e3 100644 |
| --- a/content/browser/device_orientation/device_orientation_browsertest.cc |
| +++ b/content/browser/device_orientation/device_orientation_browsertest.cc |
| @@ -7,6 +7,7 @@ |
| #include "base/memory/ref_counted.h" |
| #include "base/memory/scoped_ptr.h" |
| #include "content/browser/device_orientation/device_data.h" |
| +#include "content/browser/device_orientation/motion.h" |
| #include "content/browser/device_orientation/orientation.h" |
| #include "content/browser/device_orientation/provider.h" |
| #include "content/public/browser/web_contents.h" |
| @@ -51,19 +52,49 @@ class DeviceOrientationBrowserTest : public content::ContentBrowserTest { |
| } |
| }; |
| +IN_PROC_BROWSER_TEST_F(DeviceOrientationBrowserTest, BasicMotionTest) { |
| + scoped_refptr<Motion> test_motion(new Motion()); |
| + test_motion->set_acceleration_x(1); |
| + test_motion->set_acceleration_y(2); |
| + test_motion->set_acceleration_z(3); |
| + test_motion->set_acceleration_including_gravity_x(4); |
| + test_motion->set_acceleration_including_gravity_y(5); |
| + test_motion->set_acceleration_including_gravity_z(6); |
| + test_motion->set_rotation_rate_alpha(7); |
| + test_motion->set_rotation_rate_beta(8); |
| + test_motion->set_rotation_rate_gamma(9); |
| + test_motion->set_interval(10); |
| + scoped_refptr<MockProvider> provider(new MockProvider( |
| + test_motion, DeviceData::kTypeMotion)); |
| + Provider::SetInstanceForTests(provider.get()); |
| + |
| + // The test page will register an event handler for motion events, |
| + // expects to get an event with kTypeMotion device_data, |
| + // then removes the event handler and navigates to #pass. |
| + GURL test_url = content::GetTestUrl( |
| + "device_orientation", "device_motion_test.html"); |
| + content::NavigateToURLBlockUntilNavigationsComplete(shell(), test_url, 2); |
| + |
| + // Check that the page got the event it expected and that the provider |
| + // saw requests for adding and removing an observer. |
| + EXPECT_EQ("pass", shell()->web_contents()->GetURL().ref()); |
| + EXPECT_TRUE(provider->added_observer_); |
| + EXPECT_TRUE(provider->removed_observer_); |
| +} |
| + |
| // crbug.com/113952 |
|
hans
2012/08/13 13:35:19
this crbug.com comment is obsolete; feel free to r
aousterh
2012/08/16 15:23:49
Done.
|
| -IN_PROC_BROWSER_TEST_F(DeviceOrientationBrowserTest, BasicTest) { |
| +IN_PROC_BROWSER_TEST_F(DeviceOrientationBrowserTest, BasicOrientationTest) { |
| scoped_refptr<Orientation> test_orientation(new Orientation()); |
| test_orientation->set_alpha(1); |
| test_orientation->set_beta(2); |
| test_orientation->set_gamma(3); |
| test_orientation->set_absolute(true); |
| scoped_refptr<MockProvider> provider(new MockProvider( |
| - test_orientation, DeviceData::kTypeOrientation)); |
| + test_orientation, DeviceData::kTypeOrientation)); |
| Provider::SetInstanceForTests(provider.get()); |
| // The test page will register an event handler for orientation events, |
| - // expects to get an event with kTestOrientation orientation, |
| + // expects to get an event with kTypeOrientation device_data, |
| // then removes the event handler and navigates to #pass. |
| GURL test_url = content::GetTestUrl( |
| "device_orientation", "device_orientation_test.html"); |