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 12 matching lines...) Expand all Loading... |
23 namespace content { | 23 namespace content { |
24 | 24 |
25 class ScreenOrientationBrowserTest : public ContentBrowserTest { | 25 class ScreenOrientationBrowserTest : public ContentBrowserTest { |
26 public: | 26 public: |
27 ScreenOrientationBrowserTest() { | 27 ScreenOrientationBrowserTest() { |
28 } | 28 } |
29 | 29 |
30 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 30 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
31 command_line->AppendSwitch( | 31 command_line->AppendSwitch( |
32 switches::kEnableExperimentalWebPlatformFeatures); | 32 switches::kEnableExperimentalWebPlatformFeatures); |
33 command_line->AppendSwitch(switches::kEnablePixelOutputInTests); | |
34 } | 33 } |
35 | 34 |
36 virtual void SetUp() OVERRIDE { | 35 virtual void SetUp() OVERRIDE { |
37 // Painting has to happen otherwise the Resize messages will be added on top | 36 // Painting has to happen otherwise the Resize messages will be added on top |
38 // of each other without properly ack-painting which will fail and crash. | 37 // of each other without properly ack-painting which will fail and crash. |
39 UseSoftwareCompositing(); | 38 UseSoftwareCompositing(); |
40 EnablePixelOutput(); | |
41 | |
42 // The browser process should not ack check, otherwise it will break. | |
43 RenderWidgetHostImpl::DisableResizeAckCheckForTesting(); | |
44 | 39 |
45 ContentBrowserTest::SetUp(); | 40 ContentBrowserTest::SetUp(); |
46 } | 41 } |
47 | 42 |
48 protected: | 43 protected: |
49 void SendFakeScreenOrientation(unsigned angle, const std::string& strType) { | 44 void SendFakeScreenOrientation(unsigned angle, const std::string& strType) { |
50 RenderWidgetHost* rwh = shell()->web_contents()->GetRenderWidgetHostView() | 45 RenderWidgetHost* rwh = shell()->web_contents()->GetRenderWidgetHostView() |
51 ->GetRenderWidgetHost(); | 46 ->GetRenderWidgetHost(); |
52 blink::WebScreenInfo screen_info; | 47 blink::WebScreenInfo screen_info; |
53 rwh->GetWebScreenInfo(&screen_info); | 48 rwh->GetWebScreenInfo(&screen_info); |
54 screen_info.orientationAngle = angle; | 49 screen_info.orientationAngle = angle; |
55 | 50 |
56 blink::WebScreenOrientationType type = blink::WebScreenOrientationUndefined; | 51 blink::WebScreenOrientationType type = blink::WebScreenOrientationUndefined; |
57 if (strType == "portrait-primary") { | 52 if (strType == "portrait-primary") { |
58 type = blink::WebScreenOrientationPortraitPrimary; | 53 type = blink::WebScreenOrientationPortraitPrimary; |
59 } else if (strType == "portrait-secondary") { | 54 } else if (strType == "portrait-secondary") { |
60 type = blink::WebScreenOrientationPortraitSecondary; | 55 type = blink::WebScreenOrientationPortraitSecondary; |
61 } else if (strType == "landscape-primary") { | 56 } else if (strType == "landscape-primary") { |
62 type = blink::WebScreenOrientationLandscapePrimary; | 57 type = blink::WebScreenOrientationLandscapePrimary; |
63 } else if (strType == "landscape-secondary") { | 58 } else if (strType == "landscape-secondary") { |
64 type = blink::WebScreenOrientationLandscapeSecondary; | 59 type = blink::WebScreenOrientationLandscapeSecondary; |
65 } | 60 } |
66 ASSERT_NE(blink::WebScreenOrientationUndefined, type); | 61 ASSERT_NE(blink::WebScreenOrientationUndefined, type); |
67 screen_info.orientationType = type; | 62 screen_info.orientationType = type; |
68 | 63 |
69 ViewMsg_Resize_Params params; | 64 ViewMsg_Resize_Params params; |
70 params.screen_info = screen_info; | 65 params.screen_info = screen_info; |
71 params.new_size = gfx::Size(300, 300); | 66 params.new_size = gfx::Size(0, 0); |
72 params.physical_backing_size = gfx::Size(300, 300); | 67 params.physical_backing_size = gfx::Size(300, 300); |
73 params.overdraw_bottom_height = 0.f; | 68 params.overdraw_bottom_height = 0.f; |
74 params.resizer_rect = gfx::Rect(); | 69 params.resizer_rect = gfx::Rect(); |
75 params.is_fullscreen = false; | 70 params.is_fullscreen = false; |
76 rwh->Send(new ViewMsg_Resize(rwh->GetRoutingID(), params)); | 71 rwh->Send(new ViewMsg_Resize(rwh->GetRoutingID(), params)); |
77 } | 72 } |
78 | 73 |
79 int GetOrientationAngle() { | 74 int GetOrientationAngle() { |
80 int angle; | 75 int angle; |
81 ExecuteScriptAndGetValue(shell()->web_contents()->GetMainFrame(), | 76 ExecuteScriptAndGetValue(shell()->web_contents()->GetMainFrame(), |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 | 110 |
116 TestNavigationObserver navigation_observer(shell()->web_contents(), 1); | 111 TestNavigationObserver navigation_observer(shell()->web_contents(), 1); |
117 navigation_observer.Wait(); | 112 navigation_observer.Wait(); |
118 EXPECT_EQ(angle, GetOrientationAngle()); | 113 EXPECT_EQ(angle, GetOrientationAngle()); |
119 EXPECT_EQ(types[i], GetOrientationType()); | 114 EXPECT_EQ(types[i], GetOrientationType()); |
120 } | 115 } |
121 } | 116 } |
122 #endif // !defined(OS_ANDROID) && !defined(OS_MACOSX) && !defined(OS_CHROMEOS) | 117 #endif // !defined(OS_ANDROID) && !defined(OS_MACOSX) && !defined(OS_CHROMEOS) |
123 | 118 |
124 } // namespace content | 119 } // namespace content |
OLD | NEW |