OLD | NEW |
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/orientation.h" | 10 #include "content/browser/device_orientation/orientation.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 | 36 |
37 scoped_refptr<const DeviceData> device_data_; | 37 scoped_refptr<const DeviceData> device_data_; |
38 DeviceData::Type device_data_type_; | 38 DeviceData::Type device_data_type_; |
39 bool added_observer_; | 39 bool added_observer_; |
40 bool removed_observer_; | 40 bool removed_observer_; |
41 | 41 |
42 private: | 42 private: |
43 virtual ~MockProvider() {} | 43 virtual ~MockProvider() {} |
44 }; | 44 }; |
45 | 45 |
46 class DeviceOrientationBrowserTest : public content::ContentBrowserTest { | 46 class DeviceOrientationBrowserTest : public ContentBrowserTest { |
47 public: | 47 public: |
48 // From ContentBrowserTest. | 48 // From ContentBrowserTest. |
49 virtual void SetUpCommandLine(CommandLine* command_line) { | 49 virtual void SetUpCommandLine(CommandLine* command_line) { |
50 EXPECT_TRUE(!command_line->HasSwitch(switches::kDisableDeviceOrientation)); | 50 EXPECT_TRUE(!command_line->HasSwitch(switches::kDisableDeviceOrientation)); |
51 } | 51 } |
52 }; | 52 }; |
53 | 53 |
54 // crbug.com/113952 | 54 // crbug.com/113952 |
55 IN_PROC_BROWSER_TEST_F(DeviceOrientationBrowserTest, BasicTest) { | 55 IN_PROC_BROWSER_TEST_F(DeviceOrientationBrowserTest, BasicTest) { |
56 scoped_refptr<Orientation> test_orientation(new Orientation()); | 56 scoped_refptr<Orientation> test_orientation(new Orientation()); |
57 test_orientation->set_alpha(1); | 57 test_orientation->set_alpha(1); |
58 test_orientation->set_beta(2); | 58 test_orientation->set_beta(2); |
59 test_orientation->set_gamma(3); | 59 test_orientation->set_gamma(3); |
60 test_orientation->set_absolute(true); | 60 test_orientation->set_absolute(true); |
61 scoped_refptr<MockProvider> provider(new MockProvider( | 61 scoped_refptr<MockProvider> provider(new MockProvider( |
62 test_orientation, DeviceData::kTypeOrientation)); | 62 test_orientation, DeviceData::kTypeOrientation)); |
63 Provider::SetInstanceForTests(provider.get()); | 63 Provider::SetInstanceForTests(provider.get()); |
64 | 64 |
65 // The test page will register an event handler for orientation events, | 65 // The test page will register an event handler for orientation events, |
66 // expects to get an event with kTestOrientation orientation, | 66 // expects to get an event with kTestOrientation orientation, |
67 // then removes the event handler and navigates to #pass. | 67 // then removes the event handler and navigates to #pass. |
68 GURL test_url = content::GetTestUrl( | 68 GURL test_url = GetTestUrl( |
69 "device_orientation", "device_orientation_test.html"); | 69 "device_orientation", "device_orientation_test.html"); |
70 content::NavigateToURLBlockUntilNavigationsComplete(shell(), test_url, 2); | 70 NavigateToURLBlockUntilNavigationsComplete(shell(), test_url, 2); |
71 | 71 |
72 // Check that the page got the event it expected and that the provider | 72 // Check that the page got the event it expected and that the provider |
73 // saw requests for adding and removing an observer. | 73 // saw requests for adding and removing an observer. |
74 EXPECT_EQ("pass", shell()->web_contents()->GetURL().ref()); | 74 EXPECT_EQ("pass", shell()->web_contents()->GetURL().ref()); |
75 EXPECT_TRUE(provider->added_observer_); | 75 EXPECT_TRUE(provider->added_observer_); |
76 EXPECT_TRUE(provider->removed_observer_); | 76 EXPECT_TRUE(provider->removed_observer_); |
77 } | 77 } |
78 | 78 |
79 } // namespace content | 79 } // namespace content |
OLD | NEW |