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

Side by Side Diff: content/browser/screen_orientation/screen_orientation_browsertest.cc

Issue 456623003: Disable Screen Orientation API on Win8. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix compilation Created 6 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
« no previous file with comments | « no previous file | content/child/runtime_features.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "content/public/browser/render_widget_host_view.h" 11 #include "content/public/browser/render_widget_host_view.h"
12 #include "content/public/browser/web_contents.h" 12 #include "content/public/browser/web_contents.h"
13 #include "content/public/common/content_switches.h" 13 #include "content/public/common/content_switches.h"
14 #include "content/public/test/browser_test_utils.h" 14 #include "content/public/test/browser_test_utils.h"
15 #include "content/public/test/content_browser_test.h" 15 #include "content/public/test/content_browser_test.h"
16 #include "content/public/test/content_browser_test_utils.h" 16 #include "content/public/test/content_browser_test_utils.h"
17 #include "content/public/test/test_navigation_observer.h" 17 #include "content/public/test/test_navigation_observer.h"
18 #include "content/public/test/test_utils.h" 18 #include "content/public/test/test_utils.h"
19 #include "content/shell/browser/shell.h" 19 #include "content/shell/browser/shell.h"
20 #include "content/shell/common/shell_switches.h" 20 #include "content/shell/common/shell_switches.h"
21 #include "third_party/WebKit/public/platform/WebScreenInfo.h" 21 #include "third_party/WebKit/public/platform/WebScreenInfo.h"
22 #include "ui/compositor/compositor_switches.h" 22 #include "ui/compositor/compositor_switches.h"
23 23
24 #if defined(OS_WIN)
25 #include "base/win/windows_version.h"
26 #endif // OS_WIN
27
24 namespace content { 28 namespace content {
25 29
26 class ScreenOrientationBrowserTest : public ContentBrowserTest { 30 class ScreenOrientationBrowserTest : public ContentBrowserTest {
27 public: 31 public:
28 ScreenOrientationBrowserTest() { 32 ScreenOrientationBrowserTest() {
29 } 33 }
30 34
31 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 35 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
32 command_line->AppendSwitch( 36 command_line->AppendSwitch(
33 switches::kEnableExperimentalWebPlatformFeatures); 37 switches::kEnableExperimentalWebPlatformFeatures);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 return angle; 83 return angle;
80 } 84 }
81 85
82 std::string GetOrientationType() { 86 std::string GetOrientationType() {
83 std::string type; 87 std::string type;
84 ExecuteScriptAndGetValue(shell()->web_contents()->GetMainFrame(), 88 ExecuteScriptAndGetValue(shell()->web_contents()->GetMainFrame(),
85 "screen.orientation.type")->GetAsString(&type); 89 "screen.orientation.type")->GetAsString(&type);
86 return type; 90 return type;
87 } 91 }
88 92
93 bool ScreenOrientationSupported() {
94 bool support;
95 ExecuteScriptAndGetValue(shell()->web_contents()->GetMainFrame(),
96 "'orientation' in screen")->GetAsBoolean(&support);
97 return support;
98 }
99
89 bool WindowOrientationSupported() { 100 bool WindowOrientationSupported() {
90 bool support; 101 bool support;
91 ExecuteScriptAndGetValue(shell()->web_contents()->GetMainFrame(), 102 ExecuteScriptAndGetValue(shell()->web_contents()->GetMainFrame(),
92 "'orientation' in window")->GetAsBoolean(&support); 103 "'orientation' in window")->GetAsBoolean(&support);
93 return support; 104 return support;
94 } 105 }
95 106
96 int GetWindowOrientationAngle() { 107 int GetWindowOrientationAngle() {
97 int angle; 108 int angle;
98 ExecuteScriptAndGetValue(shell()->web_contents()->GetMainFrame(), 109 ExecuteScriptAndGetValue(shell()->web_contents()->GetMainFrame(),
(...skipping 17 matching lines...) Expand all
116 GURL test_url = GetTestUrl("screen_orientation", 127 GURL test_url = GetTestUrl("screen_orientation",
117 "screen_orientation_screenorientationchange.html"); 128 "screen_orientation_screenorientationchange.html");
118 129
119 TestNavigationObserver navigation_observer(shell()->web_contents(), 1); 130 TestNavigationObserver navigation_observer(shell()->web_contents(), 1);
120 shell()->LoadURL(test_url); 131 shell()->LoadURL(test_url);
121 navigation_observer.Wait(); 132 navigation_observer.Wait();
122 #if USE_AURA 133 #if USE_AURA
123 WaitForResizeComplete(shell()->web_contents()); 134 WaitForResizeComplete(shell()->web_contents());
124 #endif // USE_AURA 135 #endif // USE_AURA
125 136
137 #if defined(OS_WIN)
138 // Screen Orientation is currently disabled on Windows 8.
139 // This test will break, requiring an update when the API will be enabled.
140 if (base::win::OSInfo::GetInstance()->version() >= base::win::VERSION_WIN8) {
141 EXPECT_EQ(false, ScreenOrientationSupported());
142 return;
143 }
144 #endif // defined(OS_WIN)
145
126 int angle = GetOrientationAngle(); 146 int angle = GetOrientationAngle();
127 147
128 for (int i = 0; i < 4; ++i) { 148 for (int i = 0; i < 4; ++i) {
129 angle = (angle + 90) % 360; 149 angle = (angle + 90) % 360;
130 SendFakeScreenOrientation(angle, types[i]); 150 SendFakeScreenOrientation(angle, types[i]);
131 151
132 TestNavigationObserver navigation_observer(shell()->web_contents()); 152 TestNavigationObserver navigation_observer(shell()->web_contents());
133 navigation_observer.Wait(); 153 navigation_observer.Wait();
134 EXPECT_EQ(angle, GetOrientationAngle()); 154 EXPECT_EQ(angle, GetOrientationAngle());
135 EXPECT_EQ(types[i], GetOrientationType()); 155 EXPECT_EQ(types[i], GetOrientationType());
(...skipping 27 matching lines...) Expand all
163 } 183 }
164 } 184 }
165 185
166 // Chromium Android does not support fullscreen 186 // Chromium Android does not support fullscreen
167 IN_PROC_BROWSER_TEST_F(ScreenOrientationBrowserTest, LockSmoke) { 187 IN_PROC_BROWSER_TEST_F(ScreenOrientationBrowserTest, LockSmoke) {
168 GURL test_url = GetTestUrl("screen_orientation", 188 GURL test_url = GetTestUrl("screen_orientation",
169 "screen_orientation_lock_smoke.html"); 189 "screen_orientation_lock_smoke.html");
170 190
171 TestNavigationObserver navigation_observer(shell()->web_contents(), 2); 191 TestNavigationObserver navigation_observer(shell()->web_contents(), 2);
172 shell()->LoadURL(test_url); 192 shell()->LoadURL(test_url);
193
194 #if defined(OS_WIN)
195 // Screen Orientation is currently disabled on Windows 8.
196 // This test will break, requiring an update when the API will be enabled.
197 if (base::win::OSInfo::GetInstance()->version() >= base::win::VERSION_WIN8) {
198 EXPECT_EQ(false, ScreenOrientationSupported());
199 return;
200 }
201 #endif // defined(OS_WIN)
202
173 navigation_observer.Wait(); 203 navigation_observer.Wait();
174 #if USE_AURA 204 #if USE_AURA
175 WaitForResizeComplete(shell()->web_contents()); 205 WaitForResizeComplete(shell()->web_contents());
176 #endif // USE_AURA 206 #endif // USE_AURA
177 207
178 std::string expected = 208 std::string expected =
179 #if defined(OS_ANDROID) 209 #if defined(OS_ANDROID)
180 "SecurityError"; // WebContents need to be fullscreen. 210 "SecurityError"; // WebContents need to be fullscreen.
181 #else 211 #else
182 "NotSupportedError"; // Locking isn't supported. 212 "NotSupportedError"; // Locking isn't supported.
183 #endif 213 #endif
184 214
185 EXPECT_EQ(expected, shell()->web_contents()->GetLastCommittedURL().ref()); 215 EXPECT_EQ(expected, shell()->web_contents()->GetLastCommittedURL().ref());
186 } 216 }
187 217
188 } // namespace content 218 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/child/runtime_features.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698