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 <stdlib.h> | 5 #include <stdlib.h> |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "content/browser/renderer_host/render_widget_host_impl.h" | 8 #include "content/browser/renderer_host/render_widget_host_impl.h" |
9 #include "content/common/view_messages.h" | 9 #include "content/common/view_messages.h" |
10 #include "content/public/browser/render_widget_host.h" | 10 #include "content/public/browser/render_widget_host.h" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 std::string type; | 82 std::string type; |
83 ExecuteScriptAndGetValue(shell()->web_contents()->GetMainFrame(), | 83 ExecuteScriptAndGetValue(shell()->web_contents()->GetMainFrame(), |
84 "screen.orientation.type")->GetAsString(&type); | 84 "screen.orientation.type")->GetAsString(&type); |
85 return type; | 85 return type; |
86 } | 86 } |
87 | 87 |
88 private: | 88 private: |
89 DISALLOW_COPY_AND_ASSIGN(ScreenOrientationBrowserTest); | 89 DISALLOW_COPY_AND_ASSIGN(ScreenOrientationBrowserTest); |
90 }; | 90 }; |
91 | 91 |
92 #if !defined(OS_ANDROID) && !defined(OS_MACOSX) && !defined(OS_CHROMEOS) | 92 // This test doesn't work on MacOS X but the reason is mostly because it is not |
93 IN_PROC_BROWSER_TEST_F(ScreenOrientationBrowserTest, OrientationChange) { | 93 // used Aura. It could be set as !defined(OS_MACOSX) but the rule below will |
| 94 // actually support MacOS X if and when it switches to Aura. |
| 95 #if defined(USE_AURA) || defined(OS_ANDROID) |
| 96 IN_PROC_BROWSER_TEST_F(ScreenOrientationBrowserTest, ScreenOrientationChange) { |
94 std::string types[] = { "portrait-primary", | 97 std::string types[] = { "portrait-primary", |
95 "portrait-secondary", | 98 "portrait-secondary", |
96 "landscape-primary", | 99 "landscape-primary", |
97 "landscape-secondary" }; | 100 "landscape-secondary" }; |
98 GURL test_url = GetTestUrl("screen_orientation", | 101 GURL test_url = GetTestUrl("screen_orientation", |
99 "screen_orientation_orientationchange.html"); | 102 "screen_orientation_orientationchange.html"); |
100 | 103 |
101 TestNavigationObserver navigation_observer(shell()->web_contents(), 1); | 104 TestNavigationObserver navigation_observer( |
| 105 shell()->web_contents(), 1 |
| 106 // Android doesn't paint (ie. UseSoftwareCompositing() has no effect) so we |
| 107 // shouldn't wait for the first paint. |
| 108 #if !defined(OS_ANDROID) |
| 109 , TestNavigationObserver::FirstPaintRequired |
| 110 #endif |
| 111 ); |
102 shell()->LoadURL(test_url); | 112 shell()->LoadURL(test_url); |
103 navigation_observer.Wait(); | 113 navigation_observer.Wait(); |
104 | 114 |
105 int angle = GetOrientationAngle(); | 115 int angle = GetOrientationAngle(); |
106 | 116 |
107 for (int i = 0; i < 4; ++i) { | 117 for (int i = 0; i < 4; ++i) { |
108 angle = (angle + 90) % 360; | 118 angle = (angle + 90) % 360; |
109 SendFakeScreenOrientation(angle, types[i]); | 119 SendFakeScreenOrientation(angle, types[i]); |
110 | 120 |
111 TestNavigationObserver navigation_observer(shell()->web_contents(), 1); | 121 TestNavigationObserver navigation_observer(shell()->web_contents()); |
112 navigation_observer.Wait(); | 122 navigation_observer.Wait(); |
113 EXPECT_EQ(angle, GetOrientationAngle()); | 123 EXPECT_EQ(angle, GetOrientationAngle()); |
114 EXPECT_EQ(types[i], GetOrientationType()); | 124 EXPECT_EQ(types[i], GetOrientationType()); |
115 } | 125 } |
116 } | 126 } |
117 #endif // !defined(OS_ANDROID) && !defined(OS_MACOSX) && !defined(OS_CHROMEOS) | 127 #endif // defined(USE_AURA) || defined(OS_ANDROID) |
118 | 128 |
119 } // namespace content | 129 } // namespace content |
OLD | NEW |