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

Side by Side Diff: content/browser/device_orientation/device_orientation_browsertest.cc

Issue 10698046: Implements part of Device Motion in the Renderer (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Resets last_motion_ 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/file_path.h" 6 #include "base/file_path.h"
7 #include "base/memory/ref_counted.h" 7 #include "base/memory/ref_counted.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "content/browser/device_orientation/device_data.h" 9 #include "content/browser/device_orientation/device_data.h"
10 #include "content/browser/device_orientation/motion.h"
10 #include "content/browser/device_orientation/orientation.h" 11 #include "content/browser/device_orientation/orientation.h"
11 #include "content/browser/device_orientation/provider.h" 12 #include "content/browser/device_orientation/provider.h"
12 #include "content/public/browser/web_contents.h" 13 #include "content/public/browser/web_contents.h"
13 #include "content/public/common/content_switches.h" 14 #include "content/public/common/content_switches.h"
14 #include "content/shell/shell.h" 15 #include "content/shell/shell.h"
15 #include "content/test/content_browser_test.h" 16 #include "content/test/content_browser_test.h"
16 #include "content/test/content_browser_test_utils.h" 17 #include "content/test/content_browser_test_utils.h"
17 18
18 namespace content { 19 namespace content {
19 20
(...skipping 24 matching lines...) Expand all
44 }; 45 };
45 46
46 class DeviceOrientationBrowserTest : public content::ContentBrowserTest { 47 class DeviceOrientationBrowserTest : public content::ContentBrowserTest {
47 public: 48 public:
48 // From ContentBrowserTest. 49 // From ContentBrowserTest.
49 virtual void SetUpCommandLine(CommandLine* command_line) { 50 virtual void SetUpCommandLine(CommandLine* command_line) {
50 EXPECT_TRUE(!command_line->HasSwitch(switches::kDisableDeviceOrientation)); 51 EXPECT_TRUE(!command_line->HasSwitch(switches::kDisableDeviceOrientation));
51 } 52 }
52 }; 53 };
53 54
54 // crbug.com/113952 55 IN_PROC_BROWSER_TEST_F(DeviceOrientationBrowserTest, BasicMotionTest) {
55 IN_PROC_BROWSER_TEST_F(DeviceOrientationBrowserTest, BasicTest) { 56 scoped_refptr<Motion> test_motion(new Motion());
57 test_motion->set_acceleration_x(1);
58 test_motion->set_acceleration_y(2);
59 test_motion->set_acceleration_z(3);
60 test_motion->set_acceleration_including_gravity_x(4);
61 test_motion->set_acceleration_including_gravity_y(5);
62 test_motion->set_acceleration_including_gravity_z(6);
63 test_motion->set_rotation_rate_alpha(7);
64 test_motion->set_rotation_rate_beta(8);
65 test_motion->set_rotation_rate_gamma(9);
66 test_motion->set_interval(10);
67 scoped_refptr<MockProvider> provider(new MockProvider(
68 test_motion, DeviceData::kTypeMotion));
69 Provider::SetInstanceForTests(provider.get());
70
71 // The test page will register an event handler for motion events,
72 // expects to get an event with kTypeMotion device_data,
73 // then removes the event handler and navigates to #pass.
74 GURL test_url = content::GetTestUrl(
75 "device_orientation", "device_motion_test.html");
76 content::NavigateToURLBlockUntilNavigationsComplete(shell(), test_url, 2);
77
78 // Check that the page got the event it expected and that the provider
79 // saw requests for adding and removing an observer.
80 EXPECT_EQ("pass", shell()->web_contents()->GetURL().ref());
81 EXPECT_TRUE(provider->added_observer_);
82 EXPECT_TRUE(provider->removed_observer_);
83 }
84
85 IN_PROC_BROWSER_TEST_F(DeviceOrientationBrowserTest, BasicOrientationTest) {
56 scoped_refptr<Orientation> test_orientation(new Orientation()); 86 scoped_refptr<Orientation> test_orientation(new Orientation());
57 test_orientation->set_alpha(1); 87 test_orientation->set_alpha(1);
58 test_orientation->set_beta(2); 88 test_orientation->set_beta(2);
59 test_orientation->set_gamma(3); 89 test_orientation->set_gamma(3);
60 test_orientation->set_absolute(true); 90 test_orientation->set_absolute(true);
61 scoped_refptr<MockProvider> provider(new MockProvider( 91 scoped_refptr<MockProvider> provider(new MockProvider(
62 test_orientation, DeviceData::kTypeOrientation)); 92 test_orientation, DeviceData::kTypeOrientation));
63 Provider::SetInstanceForTests(provider.get()); 93 Provider::SetInstanceForTests(provider.get());
64 94
65 // The test page will register an event handler for orientation events, 95 // The test page will register an event handler for orientation events,
66 // expects to get an event with kTestOrientation orientation, 96 // expects to get an event with kTypeOrientation device_data,
67 // then removes the event handler and navigates to #pass. 97 // then removes the event handler and navigates to #pass.
68 GURL test_url = content::GetTestUrl( 98 GURL test_url = content::GetTestUrl(
69 "device_orientation", "device_orientation_test.html"); 99 "device_orientation", "device_orientation_test.html");
70 content::NavigateToURLBlockUntilNavigationsComplete(shell(), test_url, 2); 100 content::NavigateToURLBlockUntilNavigationsComplete(shell(), test_url, 2);
71 101
72 // Check that the page got the event it expected and that the provider 102 // Check that the page got the event it expected and that the provider
73 // saw requests for adding and removing an observer. 103 // saw requests for adding and removing an observer.
74 EXPECT_EQ("pass", shell()->web_contents()->GetURL().ref()); 104 EXPECT_EQ("pass", shell()->web_contents()->GetURL().ref());
75 EXPECT_TRUE(provider->added_observer_); 105 EXPECT_TRUE(provider->added_observer_);
76 EXPECT_TRUE(provider->removed_observer_); 106 EXPECT_TRUE(provider->removed_observer_);
77 } 107 }
78 108
79 } // namespace content 109 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/device_orientation/device_data.h ('k') | content/browser/device_orientation/motion.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698