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

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_base_unittest.cc

Issue 2317563004: Change blink::WebScreenInfo to content::ScreenInfo (Closed)
Patch Set: Fix Windows compile Created 4 years, 3 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 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 "content/browser/renderer_host/render_widget_host_view_base.h" 5 #include "content/browser/renderer_host/render_widget_host_view_base.h"
6 6
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 #include "third_party/WebKit/public/platform/modules/screen_orientation/WebScree nOrientationType.h" 8 #include "third_party/WebKit/public/platform/modules/screen_orientation/WebScree nOrientationType.h"
9 #include "ui/display/display.h" 9 #include "ui/display/display.h"
10 10
11 namespace content { 11 namespace content {
12 12
13 namespace { 13 namespace {
14 14
15 display::Display CreateDisplay(int width, int height, int angle) { 15 display::Display CreateDisplay(int width, int height, int angle) {
16 display::Display display; 16 display::Display display;
17 display.SetRotationAsDegree(angle); 17 display.SetRotationAsDegree(angle);
18 display.set_bounds(gfx::Rect(width, height)); 18 display.set_bounds(gfx::Rect(width, height));
19 19
20 return display; 20 return display;
21 } 21 }
22 22
23 } // anonymous namespace 23 } // anonymous namespace
24 24
25 TEST(RenderWidgetHostViewBaseTest, OrientationTypeForMobile) { 25 TEST(RenderWidgetHostViewBaseTest, OrientationTypeForMobile) {
26 // Square display (width == height). 26 // Square display (width == height).
27 { 27 {
28 display::Display display = CreateDisplay(100, 100, 0); 28 display::Display display = CreateDisplay(100, 100, 0);
29 EXPECT_EQ(blink::WebScreenOrientationPortraitPrimary, 29 EXPECT_EQ(SCREEN_ORIENTATION_VALUES_PORTRAIT_PRIMARY,
30 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display)); 30 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display));
31 31
32 display = CreateDisplay(200, 200, 90); 32 display = CreateDisplay(200, 200, 90);
33 EXPECT_EQ(blink::WebScreenOrientationLandscapePrimary, 33 EXPECT_EQ(SCREEN_ORIENTATION_VALUES_LANDSCAPE_PRIMARY,
34 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display)); 34 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display));
35 35
36 display = CreateDisplay(0, 0, 180); 36 display = CreateDisplay(0, 0, 180);
37 EXPECT_EQ(blink::WebScreenOrientationPortraitSecondary, 37 EXPECT_EQ(SCREEN_ORIENTATION_VALUES_PORTRAIT_SECONDARY,
38 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display)); 38 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display));
39 39
40 display = CreateDisplay(10000, 10000, 270); 40 display = CreateDisplay(10000, 10000, 270);
41 EXPECT_EQ(blink::WebScreenOrientationLandscapeSecondary, 41 EXPECT_EQ(SCREEN_ORIENTATION_VALUES_LANDSCAPE_SECONDARY,
42 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display)); 42 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display));
43 } 43 }
44 44
45 // natural width > natural height. 45 // natural width > natural height.
46 { 46 {
47 display::Display display = CreateDisplay(1, 0, 0); 47 display::Display display = CreateDisplay(1, 0, 0);
48 EXPECT_EQ(blink::WebScreenOrientationLandscapePrimary, 48 EXPECT_EQ(SCREEN_ORIENTATION_VALUES_LANDSCAPE_PRIMARY,
49 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display)); 49 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display));
50 50
51 display = CreateDisplay(19999, 20000, 90); 51 display = CreateDisplay(19999, 20000, 90);
52 EXPECT_EQ(blink::WebScreenOrientationPortraitSecondary, 52 EXPECT_EQ(SCREEN_ORIENTATION_VALUES_PORTRAIT_SECONDARY,
53 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display)); 53 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display));
54 54
55 display = CreateDisplay(200, 100, 180); 55 display = CreateDisplay(200, 100, 180);
56 EXPECT_EQ(blink::WebScreenOrientationLandscapeSecondary, 56 EXPECT_EQ(SCREEN_ORIENTATION_VALUES_LANDSCAPE_SECONDARY,
57 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display)); 57 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display));
58 58
59 display = CreateDisplay(1, 10000, 270); 59 display = CreateDisplay(1, 10000, 270);
60 EXPECT_EQ(blink::WebScreenOrientationPortraitPrimary, 60 EXPECT_EQ(SCREEN_ORIENTATION_VALUES_PORTRAIT_PRIMARY,
61 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display)); 61 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display));
62 } 62 }
63 63
64 // natural width < natural height. 64 // natural width < natural height.
65 { 65 {
66 display::Display display = CreateDisplay(0, 1, 0); 66 display::Display display = CreateDisplay(0, 1, 0);
67 EXPECT_EQ(blink::WebScreenOrientationPortraitPrimary, 67 EXPECT_EQ(SCREEN_ORIENTATION_VALUES_PORTRAIT_PRIMARY,
68 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display)); 68 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display));
69 69
70 display = CreateDisplay(20000, 19999, 90); 70 display = CreateDisplay(20000, 19999, 90);
71 EXPECT_EQ(blink::WebScreenOrientationLandscapePrimary, 71 EXPECT_EQ(SCREEN_ORIENTATION_VALUES_LANDSCAPE_PRIMARY,
72 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display)); 72 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display));
73 73
74 display = CreateDisplay(100, 200, 180); 74 display = CreateDisplay(100, 200, 180);
75 EXPECT_EQ(blink::WebScreenOrientationPortraitSecondary, 75 EXPECT_EQ(SCREEN_ORIENTATION_VALUES_PORTRAIT_SECONDARY,
76 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display)); 76 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display));
77 77
78 display = CreateDisplay(10000, 1, 270); 78 display = CreateDisplay(10000, 1, 270);
79 EXPECT_EQ(blink::WebScreenOrientationLandscapeSecondary, 79 EXPECT_EQ(SCREEN_ORIENTATION_VALUES_LANDSCAPE_SECONDARY,
80 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display)); 80 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display));
81 } 81 }
82 } 82 }
83 83
84 TEST(RenderWidgetHostViewBaseTest, OrientationTypeForDesktop) { 84 TEST(RenderWidgetHostViewBaseTest, OrientationTypeForDesktop) {
85 // On Desktop, the primary orientation is the first computed one so a test 85 // On Desktop, the primary orientation is the first computed one so a test
86 // similar to OrientationTypeForMobile is not possible. 86 // similar to OrientationTypeForMobile is not possible.
87 // Instead this test will only check one configuration and verify that the 87 // Instead this test will only check one configuration and verify that the
88 // method reports two landscape and two portrait orientations with one primary 88 // method reports two landscape and two portrait orientations with one primary
89 // and one secondary for each. 89 // and one secondary for each.
90 90
91 // natural width > natural height. 91 // natural width > natural height.
92 { 92 {
93 display::Display display = CreateDisplay(1, 0, 0); 93 display::Display display = CreateDisplay(1, 0, 0);
94 blink::WebScreenOrientationType landscape_1 = 94 ScreenOrientationValues landscape_1 =
95 RenderWidgetHostViewBase::GetOrientationTypeForDesktop(display); 95 RenderWidgetHostViewBase::GetOrientationTypeForDesktop(display);
96 EXPECT_TRUE(landscape_1 == blink::WebScreenOrientationLandscapePrimary || 96 EXPECT_TRUE(landscape_1 == SCREEN_ORIENTATION_VALUES_LANDSCAPE_PRIMARY ||
97 landscape_1 == blink::WebScreenOrientationLandscapeSecondary); 97 landscape_1 == SCREEN_ORIENTATION_VALUES_LANDSCAPE_SECONDARY);
98 98
99 display = CreateDisplay(200, 100, 180); 99 display = CreateDisplay(200, 100, 180);
100 blink::WebScreenOrientationType landscape_2 = 100 ScreenOrientationValues landscape_2 =
101 RenderWidgetHostViewBase::GetOrientationTypeForDesktop(display); 101 RenderWidgetHostViewBase::GetOrientationTypeForDesktop(display);
102 EXPECT_TRUE(landscape_2 == blink::WebScreenOrientationLandscapePrimary || 102 EXPECT_TRUE(landscape_2 == SCREEN_ORIENTATION_VALUES_LANDSCAPE_PRIMARY ||
103 landscape_2 == blink::WebScreenOrientationLandscapeSecondary); 103 landscape_2 == SCREEN_ORIENTATION_VALUES_LANDSCAPE_SECONDARY);
104 104
105 EXPECT_NE(landscape_1, landscape_2); 105 EXPECT_NE(landscape_1, landscape_2);
106 106
107 display = CreateDisplay(19999, 20000, 90); 107 display = CreateDisplay(19999, 20000, 90);
108 blink::WebScreenOrientationType portrait_1 = 108 ScreenOrientationValues portrait_1 =
109 RenderWidgetHostViewBase::GetOrientationTypeForDesktop(display); 109 RenderWidgetHostViewBase::GetOrientationTypeForDesktop(display);
110 EXPECT_TRUE(portrait_1 == blink::WebScreenOrientationPortraitPrimary || 110 EXPECT_TRUE(portrait_1 == SCREEN_ORIENTATION_VALUES_PORTRAIT_PRIMARY ||
111 portrait_1 == blink::WebScreenOrientationPortraitSecondary); 111 portrait_1 == SCREEN_ORIENTATION_VALUES_PORTRAIT_SECONDARY);
112 112
113 display = CreateDisplay(1, 10000, 270); 113 display = CreateDisplay(1, 10000, 270);
114 blink::WebScreenOrientationType portrait_2 = 114 ScreenOrientationValues portrait_2 =
115 RenderWidgetHostViewBase::GetOrientationTypeForDesktop(display); 115 RenderWidgetHostViewBase::GetOrientationTypeForDesktop(display);
116 EXPECT_TRUE(portrait_2 == blink::WebScreenOrientationPortraitPrimary || 116 EXPECT_TRUE(portrait_2 == SCREEN_ORIENTATION_VALUES_PORTRAIT_PRIMARY ||
117 portrait_2 == blink::WebScreenOrientationPortraitSecondary); 117 portrait_2 == SCREEN_ORIENTATION_VALUES_PORTRAIT_SECONDARY);
118 118
119 EXPECT_NE(portrait_1, portrait_2); 119 EXPECT_NE(portrait_1, portrait_2);
120 120
121 } 121 }
122 } 122 }
123 123
124 } // namespace content 124 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698