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

Unified Diff: content/browser/device_orientation/device_orientation_browsertest.cc

Issue 10827415: Chromium-side implementation of DeviceMotion. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Test should set the kEnableDeviceMotion flag Created 8 years, 4 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
« no previous file with comments | « no previous file | content/browser/renderer_host/render_process_host_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 d002a10dfccd72a3ab177033a2fc2b241e0177a6..38212a31291969492049f12ab0cff179e5432337 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"
@@ -48,22 +49,52 @@ class DeviceOrientationBrowserTest : public ContentBrowserTest {
// From ContentBrowserTest.
virtual void SetUpCommandLine(CommandLine* command_line) {
EXPECT_TRUE(!command_line->HasSwitch(switches::kDisableDeviceOrientation));
+ command_line->AppendSwitch(switches::kEnableDeviceMotion);
}
};
-// crbug.com/113952
-IN_PROC_BROWSER_TEST_F(DeviceOrientationBrowserTest, BasicTest) {
+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_);
+}
+
+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 = GetTestUrl(
"device_orientation", "device_orientation_test.html");
« no previous file with comments | « no previous file | content/browser/renderer_host/render_process_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698