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

Side by Side Diff: chrome/browser/extensions/display_info_provider_chromeos_unittest.cc

Issue 1842953002: [Extensions] Convert APIs to use movable types [13] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 "extensions/browser/api/system_display/display_info_provider.h" 5 #include "extensions/browser/api/system_display/display_info_provider.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "ash/ash_switches.h" 9 #include "ash/ash_switches.h"
10 #include "ash/display/display_manager.h" 10 #include "ash/display/display_manager.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 DISALLOW_COPY_AND_ASSIGN(DisplayInfoProviderChromeosTest); 76 DISALLOW_COPY_AND_ASSIGN(DisplayInfoProviderChromeosTest);
77 }; 77 };
78 78
79 TEST_F(DisplayInfoProviderChromeosTest, GetBasic) { 79 TEST_F(DisplayInfoProviderChromeosTest, GetBasic) {
80 UpdateDisplay("500x600,400x520"); 80 UpdateDisplay("500x600,400x520");
81 DisplayInfo result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); 81 DisplayInfo result = DisplayInfoProvider::Get()->GetAllDisplaysInfo();
82 82
83 ASSERT_EQ(2u, result.size()); 83 ASSERT_EQ(2u, result.size());
84 84
85 int64_t display_id; 85 int64_t display_id;
86 ASSERT_TRUE(base::StringToInt64(result[0]->id, &display_id)) 86 ASSERT_TRUE(base::StringToInt64(result[0].id, &display_id))
87 << "Display id must be convertable to integer: " << result[0]->id; 87 << "Display id must be convertable to integer: " << result[0].id;
88 88
89 ASSERT_TRUE(DisplayExists(display_id)) << display_id << " not found"; 89 ASSERT_TRUE(DisplayExists(display_id)) << display_id << " not found";
90 EXPECT_EQ("0,0 500x600", SystemInfoDisplayBoundsToString(result[0]->bounds)); 90 EXPECT_EQ("0,0 500x600", SystemInfoDisplayBoundsToString(result[0].bounds));
91 EXPECT_EQ("0,0,0,0", SystemInfoDisplayInsetsToString(result[0]->overscan)); 91 EXPECT_EQ("0,0,0,0", SystemInfoDisplayInsetsToString(result[0].overscan));
92 EXPECT_EQ(0, result[0]->rotation); 92 EXPECT_EQ(0, result[0].rotation);
93 EXPECT_TRUE(result[0]->is_primary); 93 EXPECT_TRUE(result[0].is_primary);
94 EXPECT_EQ(96, result[0]->dpi_x); 94 EXPECT_EQ(96, result[0].dpi_x);
95 EXPECT_EQ(96, result[0]->dpi_y); 95 EXPECT_EQ(96, result[0].dpi_y);
96 EXPECT_TRUE(result[0]->mirroring_source_id.empty()); 96 EXPECT_TRUE(result[0].mirroring_source_id.empty());
97 EXPECT_TRUE(result[0]->is_enabled); 97 EXPECT_TRUE(result[0].is_enabled);
98 98
99 ASSERT_TRUE(base::StringToInt64(result[1]->id, &display_id)) 99 ASSERT_TRUE(base::StringToInt64(result[1].id, &display_id))
100 << "Display id must be convertable to integer: " << result[0]->id; 100 << "Display id must be convertable to integer: " << result[0].id;
101 101
102 ASSERT_TRUE(DisplayExists(display_id)) << display_id << " not found"; 102 ASSERT_TRUE(DisplayExists(display_id)) << display_id << " not found";
103 EXPECT_EQ(GetDisplayManager()->GetDisplayNameForId(display_id), 103 EXPECT_EQ(GetDisplayManager()->GetDisplayNameForId(display_id),
104 result[1]->name); 104 result[1].name);
105 // The second display is positioned left of the primary display, whose width 105 // The second display is positioned left of the primary display, whose width
106 // is 500. 106 // is 500.
107 EXPECT_EQ("500,0 400x520", 107 EXPECT_EQ("500,0 400x520", SystemInfoDisplayBoundsToString(result[1].bounds));
108 SystemInfoDisplayBoundsToString(result[1]->bounds)); 108 EXPECT_EQ("0,0,0,0", SystemInfoDisplayInsetsToString(result[1].overscan));
109 EXPECT_EQ("0,0,0,0", SystemInfoDisplayInsetsToString(result[1]->overscan)); 109 EXPECT_EQ(0, result[1].rotation);
110 EXPECT_EQ(0, result[1]->rotation); 110 EXPECT_FALSE(result[1].is_primary);
111 EXPECT_FALSE(result[1]->is_primary); 111 EXPECT_EQ(96, result[1].dpi_x);
112 EXPECT_EQ(96, result[1]->dpi_x); 112 EXPECT_EQ(96, result[1].dpi_y);
113 EXPECT_EQ(96, result[1]->dpi_y); 113 EXPECT_TRUE(result[1].mirroring_source_id.empty());
114 EXPECT_TRUE(result[1]->mirroring_source_id.empty()); 114 EXPECT_TRUE(result[1].is_enabled);
115 EXPECT_TRUE(result[1]->is_enabled);
116 } 115 }
117 116
118 TEST_F(DisplayInfoProviderChromeosTest, GetWithUnifiedDesktop) { 117 TEST_F(DisplayInfoProviderChromeosTest, GetWithUnifiedDesktop) {
119 UpdateDisplay("500x600,400x520"); 118 UpdateDisplay("500x600,400x520");
120 119
121 // Check initial state. 120 // Check initial state.
122 EXPECT_FALSE(GetDisplayManager()->IsInUnifiedMode()); 121 EXPECT_FALSE(GetDisplayManager()->IsInUnifiedMode());
123 DisplayInfo result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); 122 DisplayInfo result = DisplayInfoProvider::Get()->GetAllDisplaysInfo();
124 123
125 ASSERT_EQ(2u, result.size()); 124 ASSERT_EQ(2u, result.size());
126 125
127 int64_t display_id; 126 int64_t display_id;
128 ASSERT_TRUE(base::StringToInt64(result[0]->id, &display_id)) 127 ASSERT_TRUE(base::StringToInt64(result[0].id, &display_id))
129 << "Display id must be convertable to integer: " << result[0]->id; 128 << "Display id must be convertable to integer: " << result[0].id;
130 129
131 ASSERT_TRUE(DisplayExists(display_id)) << display_id << " not found"; 130 ASSERT_TRUE(DisplayExists(display_id)) << display_id << " not found";
132 EXPECT_EQ("0,0 500x600", SystemInfoDisplayBoundsToString(result[0]->bounds)); 131 EXPECT_EQ("0,0 500x600", SystemInfoDisplayBoundsToString(result[0].bounds));
133 EXPECT_EQ("0,0,0,0", SystemInfoDisplayInsetsToString(result[0]->overscan)); 132 EXPECT_EQ("0,0,0,0", SystemInfoDisplayInsetsToString(result[0].overscan));
134 EXPECT_EQ(0, result[0]->rotation); 133 EXPECT_EQ(0, result[0].rotation);
135 EXPECT_TRUE(result[0]->is_primary); 134 EXPECT_TRUE(result[0].is_primary);
136 EXPECT_EQ(96, result[0]->dpi_x); 135 EXPECT_EQ(96, result[0].dpi_x);
137 EXPECT_EQ(96, result[0]->dpi_y); 136 EXPECT_EQ(96, result[0].dpi_y);
138 EXPECT_TRUE(result[0]->mirroring_source_id.empty()); 137 EXPECT_TRUE(result[0].mirroring_source_id.empty());
139 EXPECT_TRUE(result[0]->is_enabled); 138 EXPECT_TRUE(result[0].is_enabled);
140 139
141 ASSERT_TRUE(base::StringToInt64(result[1]->id, &display_id)) 140 ASSERT_TRUE(base::StringToInt64(result[1].id, &display_id))
142 << "Display id must be convertable to integer: " << result[0]->id; 141 << "Display id must be convertable to integer: " << result[0].id;
143 142
144 ASSERT_TRUE(DisplayExists(display_id)) << display_id << " not found"; 143 ASSERT_TRUE(DisplayExists(display_id)) << display_id << " not found";
145 EXPECT_EQ(GetDisplayManager()->GetDisplayNameForId(display_id), 144 EXPECT_EQ(GetDisplayManager()->GetDisplayNameForId(display_id),
146 result[1]->name); 145 result[1].name);
147 146
148 // Initial multipple display configuration. 147 // Initial multipple display configuration.
149 EXPECT_EQ("500,0 400x520", 148 EXPECT_EQ("500,0 400x520", SystemInfoDisplayBoundsToString(result[1].bounds));
150 SystemInfoDisplayBoundsToString(result[1]->bounds)); 149 EXPECT_EQ("0,0,0,0", SystemInfoDisplayInsetsToString(result[1].overscan));
151 EXPECT_EQ("0,0,0,0", SystemInfoDisplayInsetsToString(result[1]->overscan)); 150 EXPECT_EQ(0, result[1].rotation);
152 EXPECT_EQ(0, result[1]->rotation); 151 EXPECT_FALSE(result[1].is_primary);
153 EXPECT_FALSE(result[1]->is_primary); 152 EXPECT_EQ(96, result[1].dpi_x);
154 EXPECT_EQ(96, result[1]->dpi_x); 153 EXPECT_EQ(96, result[1].dpi_y);
155 EXPECT_EQ(96, result[1]->dpi_y); 154 EXPECT_TRUE(result[1].mirroring_source_id.empty());
156 EXPECT_TRUE(result[1]->mirroring_source_id.empty()); 155 EXPECT_TRUE(result[1].is_enabled);
157 EXPECT_TRUE(result[1]->is_enabled);
158 156
159 // Enable unified. 157 // Enable unified.
160 GetDisplayManager()->SetUnifiedDesktopEnabled(true); 158 GetDisplayManager()->SetUnifiedDesktopEnabled(true);
161 EXPECT_TRUE(GetDisplayManager()->IsInUnifiedMode()); 159 EXPECT_TRUE(GetDisplayManager()->IsInUnifiedMode());
162 160
163 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); 161 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo();
164 162
165 ASSERT_EQ(2u, result.size()); 163 ASSERT_EQ(2u, result.size());
166 164
167 ASSERT_TRUE(base::StringToInt64(result[0]->id, &display_id)) 165 ASSERT_TRUE(base::StringToInt64(result[0].id, &display_id))
168 << "Display id must be convertable to integer: " << result[0]->id; 166 << "Display id must be convertable to integer: " << result[0].id;
169 167
170 EXPECT_EQ("0,0 500x600", SystemInfoDisplayBoundsToString(result[0]->bounds)); 168 EXPECT_EQ("0,0 500x600", SystemInfoDisplayBoundsToString(result[0].bounds));
171 EXPECT_EQ("0,0,0,0", SystemInfoDisplayInsetsToString(result[0]->overscan)); 169 EXPECT_EQ("0,0,0,0", SystemInfoDisplayInsetsToString(result[0].overscan));
172 EXPECT_EQ(0, result[0]->rotation); 170 EXPECT_EQ(0, result[0].rotation);
173 EXPECT_TRUE(result[0]->is_primary); 171 EXPECT_TRUE(result[0].is_primary);
174 EXPECT_EQ(96, result[0]->dpi_x); 172 EXPECT_EQ(96, result[0].dpi_x);
175 EXPECT_EQ(96, result[0]->dpi_y); 173 EXPECT_EQ(96, result[0].dpi_y);
176 EXPECT_TRUE(result[0]->mirroring_source_id.empty()); 174 EXPECT_TRUE(result[0].mirroring_source_id.empty());
177 EXPECT_TRUE(result[0]->is_enabled); 175 EXPECT_TRUE(result[0].is_enabled);
178 176
179 ASSERT_TRUE(base::StringToInt64(result[1]->id, &display_id)) 177 ASSERT_TRUE(base::StringToInt64(result[1].id, &display_id))
180 << "Display id must be convertable to integer: " << result[0]->id; 178 << "Display id must be convertable to integer: " << result[0].id;
181 179
182 EXPECT_EQ(GetDisplayManager()->GetDisplayNameForId(display_id), 180 EXPECT_EQ(GetDisplayManager()->GetDisplayNameForId(display_id),
183 result[1]->name); 181 result[1].name);
184 182
185 // After enabling unified the second display is scaled to meet the height for 183 // After enabling unified the second display is scaled to meet the height for
186 // the first. Which also affects the DPI below. 184 // the first. Which also affects the DPI below.
187 EXPECT_EQ("500,0 461x600", 185 EXPECT_EQ("500,0 461x600", SystemInfoDisplayBoundsToString(result[1].bounds));
188 SystemInfoDisplayBoundsToString(result[1]->bounds)); 186 EXPECT_EQ("0,0,0,0", SystemInfoDisplayInsetsToString(result[1].overscan));
189 EXPECT_EQ("0,0,0,0", SystemInfoDisplayInsetsToString(result[1]->overscan)); 187 EXPECT_EQ(0, result[1].rotation);
190 EXPECT_EQ(0, result[1]->rotation); 188 EXPECT_FALSE(result[1].is_primary);
191 EXPECT_FALSE(result[1]->is_primary); 189 EXPECT_FLOAT_EQ(111, round(result[1].dpi_x));
192 EXPECT_FLOAT_EQ(111, round(result[1]->dpi_x)); 190 EXPECT_FLOAT_EQ(111, round(result[1].dpi_y));
193 EXPECT_FLOAT_EQ(111, round(result[1]->dpi_y)); 191 EXPECT_TRUE(result[1].mirroring_source_id.empty());
194 EXPECT_TRUE(result[1]->mirroring_source_id.empty()); 192 EXPECT_TRUE(result[1].is_enabled);
195 EXPECT_TRUE(result[1]->is_enabled);
196 193
197 // Disable unified and check that once again it matches initial situation. 194 // Disable unified and check that once again it matches initial situation.
198 GetDisplayManager()->SetUnifiedDesktopEnabled(false); 195 GetDisplayManager()->SetUnifiedDesktopEnabled(false);
199 EXPECT_FALSE(GetDisplayManager()->IsInUnifiedMode()); 196 EXPECT_FALSE(GetDisplayManager()->IsInUnifiedMode());
200 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); 197 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo();
201 198
202 ASSERT_EQ(2u, result.size()); 199 ASSERT_EQ(2u, result.size());
203 200
204 ASSERT_TRUE(base::StringToInt64(result[0]->id, &display_id)) 201 ASSERT_TRUE(base::StringToInt64(result[0].id, &display_id))
205 << "Display id must be convertable to integer: " << result[0]->id; 202 << "Display id must be convertable to integer: " << result[0].id;
206 203
207 ASSERT_TRUE(DisplayExists(display_id)) << display_id << " not found"; 204 ASSERT_TRUE(DisplayExists(display_id)) << display_id << " not found";
208 EXPECT_EQ("0,0 500x600", SystemInfoDisplayBoundsToString(result[0]->bounds)); 205 EXPECT_EQ("0,0 500x600", SystemInfoDisplayBoundsToString(result[0].bounds));
209 EXPECT_EQ("0,0,0,0", SystemInfoDisplayInsetsToString(result[0]->overscan)); 206 EXPECT_EQ("0,0,0,0", SystemInfoDisplayInsetsToString(result[0].overscan));
210 EXPECT_EQ(0, result[0]->rotation); 207 EXPECT_EQ(0, result[0].rotation);
211 EXPECT_TRUE(result[0]->is_primary); 208 EXPECT_TRUE(result[0].is_primary);
212 EXPECT_EQ(96, result[0]->dpi_x); 209 EXPECT_EQ(96, result[0].dpi_x);
213 EXPECT_EQ(96, result[0]->dpi_y); 210 EXPECT_EQ(96, result[0].dpi_y);
214 EXPECT_TRUE(result[0]->mirroring_source_id.empty()); 211 EXPECT_TRUE(result[0].mirroring_source_id.empty());
215 EXPECT_TRUE(result[0]->is_enabled); 212 EXPECT_TRUE(result[0].is_enabled);
216 213
217 ASSERT_TRUE(base::StringToInt64(result[1]->id, &display_id)) 214 ASSERT_TRUE(base::StringToInt64(result[1].id, &display_id))
218 << "Display id must be convertable to integer: " << result[0]->id; 215 << "Display id must be convertable to integer: " << result[0].id;
219 216
220 ASSERT_TRUE(DisplayExists(display_id)) << display_id << " not found"; 217 ASSERT_TRUE(DisplayExists(display_id)) << display_id << " not found";
221 EXPECT_EQ(GetDisplayManager()->GetDisplayNameForId(display_id), 218 EXPECT_EQ(GetDisplayManager()->GetDisplayNameForId(display_id),
222 result[1]->name); 219 result[1].name);
223 EXPECT_EQ("500,0 400x520", 220 EXPECT_EQ("500,0 400x520", SystemInfoDisplayBoundsToString(result[1].bounds));
224 SystemInfoDisplayBoundsToString(result[1]->bounds)); 221 EXPECT_EQ("0,0,0,0", SystemInfoDisplayInsetsToString(result[1].overscan));
225 EXPECT_EQ("0,0,0,0", SystemInfoDisplayInsetsToString(result[1]->overscan)); 222 EXPECT_EQ(0, result[1].rotation);
226 EXPECT_EQ(0, result[1]->rotation); 223 EXPECT_FALSE(result[1].is_primary);
227 EXPECT_FALSE(result[1]->is_primary); 224 EXPECT_EQ(96, result[1].dpi_x);
228 EXPECT_EQ(96, result[1]->dpi_x); 225 EXPECT_EQ(96, result[1].dpi_y);
229 EXPECT_EQ(96, result[1]->dpi_y); 226 EXPECT_TRUE(result[1].mirroring_source_id.empty());
230 EXPECT_TRUE(result[1]->mirroring_source_id.empty()); 227 EXPECT_TRUE(result[1].is_enabled);
231 EXPECT_TRUE(result[1]->is_enabled);
232 } 228 }
233 229
234 TEST_F(DisplayInfoProviderChromeosTest, GetRotation) { 230 TEST_F(DisplayInfoProviderChromeosTest, GetRotation) {
235 UpdateDisplay("500x600/r"); 231 UpdateDisplay("500x600/r");
236 DisplayInfo result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); 232 DisplayInfo result = DisplayInfoProvider::Get()->GetAllDisplaysInfo();
237 233
238 ASSERT_EQ(1u, result.size()); 234 ASSERT_EQ(1u, result.size());
239 235
240 int64_t display_id; 236 int64_t display_id;
241 ASSERT_TRUE(base::StringToInt64(result[0]->id, &display_id)) 237 ASSERT_TRUE(base::StringToInt64(result[0].id, &display_id))
242 << "Display id must be convertable to integer: " << result[0]->id; 238 << "Display id must be convertable to integer: " << result[0].id;
243 239
244 ASSERT_TRUE(DisplayExists(display_id)) << display_id << " not found"; 240 ASSERT_TRUE(DisplayExists(display_id)) << display_id << " not found";
245 EXPECT_EQ("0,0 600x500", SystemInfoDisplayBoundsToString(result[0]->bounds)); 241 EXPECT_EQ("0,0 600x500", SystemInfoDisplayBoundsToString(result[0].bounds));
246 EXPECT_EQ(90, result[0]->rotation); 242 EXPECT_EQ(90, result[0].rotation);
247 243
248 GetDisplayManager()->SetDisplayRotation(display_id, gfx::Display::ROTATE_270, 244 GetDisplayManager()->SetDisplayRotation(display_id, gfx::Display::ROTATE_270,
249 gfx::Display::ROTATION_SOURCE_ACTIVE); 245 gfx::Display::ROTATION_SOURCE_ACTIVE);
250 246
251 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); 247 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo();
252 248
253 ASSERT_EQ(1u, result.size()); 249 ASSERT_EQ(1u, result.size());
254 250
255 EXPECT_EQ(base::Int64ToString(display_id), result[0]->id); 251 EXPECT_EQ(base::Int64ToString(display_id), result[0].id);
256 EXPECT_EQ("0,0 600x500", SystemInfoDisplayBoundsToString(result[0]->bounds)); 252 EXPECT_EQ("0,0 600x500", SystemInfoDisplayBoundsToString(result[0].bounds));
257 EXPECT_EQ(270, result[0]->rotation); 253 EXPECT_EQ(270, result[0].rotation);
258 254
259 GetDisplayManager()->SetDisplayRotation(display_id, gfx::Display::ROTATE_180, 255 GetDisplayManager()->SetDisplayRotation(display_id, gfx::Display::ROTATE_180,
260 gfx::Display::ROTATION_SOURCE_ACTIVE); 256 gfx::Display::ROTATION_SOURCE_ACTIVE);
261 257
262 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); 258 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo();
263 259
264 ASSERT_EQ(1u, result.size()); 260 ASSERT_EQ(1u, result.size());
265 261
266 EXPECT_EQ(base::Int64ToString(display_id), result[0]->id); 262 EXPECT_EQ(base::Int64ToString(display_id), result[0].id);
267 EXPECT_EQ("0,0 500x600", SystemInfoDisplayBoundsToString(result[0]->bounds)); 263 EXPECT_EQ("0,0 500x600", SystemInfoDisplayBoundsToString(result[0].bounds));
268 EXPECT_EQ(180, result[0]->rotation); 264 EXPECT_EQ(180, result[0].rotation);
269 265
270 GetDisplayManager()->SetDisplayRotation(display_id, gfx::Display::ROTATE_0, 266 GetDisplayManager()->SetDisplayRotation(display_id, gfx::Display::ROTATE_0,
271 gfx::Display::ROTATION_SOURCE_ACTIVE); 267 gfx::Display::ROTATION_SOURCE_ACTIVE);
272 268
273 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); 269 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo();
274 270
275 ASSERT_EQ(1u, result.size()); 271 ASSERT_EQ(1u, result.size());
276 272
277 EXPECT_EQ(base::Int64ToString(display_id), result[0]->id); 273 EXPECT_EQ(base::Int64ToString(display_id), result[0].id);
278 EXPECT_EQ("0,0 500x600", SystemInfoDisplayBoundsToString(result[0]->bounds)); 274 EXPECT_EQ("0,0 500x600", SystemInfoDisplayBoundsToString(result[0].bounds));
279 EXPECT_EQ(0, result[0]->rotation); 275 EXPECT_EQ(0, result[0].rotation);
280 } 276 }
281 277
282 TEST_F(DisplayInfoProviderChromeosTest, GetDPI) { 278 TEST_F(DisplayInfoProviderChromeosTest, GetDPI) {
283 UpdateDisplay("500x600,400x520*2"); 279 UpdateDisplay("500x600,400x520*2");
284 DisplayInfo result; 280 DisplayInfo result;
285 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); 281 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo();
286 282
287 ASSERT_EQ(2u, result.size()); 283 ASSERT_EQ(2u, result.size());
288 284
289 EXPECT_EQ("0,0 500x600", SystemInfoDisplayBoundsToString(result[0]->bounds)); 285 EXPECT_EQ("0,0 500x600", SystemInfoDisplayBoundsToString(result[0].bounds));
290 EXPECT_EQ(96, result[0]->dpi_x); 286 EXPECT_EQ(96, result[0].dpi_x);
291 EXPECT_EQ(96, result[0]->dpi_y); 287 EXPECT_EQ(96, result[0].dpi_y);
292 288
293 EXPECT_EQ("500,0 200x260", 289 EXPECT_EQ("500,0 200x260", SystemInfoDisplayBoundsToString(result[1].bounds));
294 SystemInfoDisplayBoundsToString(result[1]->bounds));
295 // DPI should be 96 (native dpi) * 200 (display) / 400 (native) when ui scale 290 // DPI should be 96 (native dpi) * 200 (display) / 400 (native) when ui scale
296 // is 2. 291 // is 2.
297 EXPECT_EQ(96 / 2, result[1]->dpi_x); 292 EXPECT_EQ(96 / 2, result[1].dpi_x);
298 EXPECT_EQ(96 / 2, result[1]->dpi_y); 293 EXPECT_EQ(96 / 2, result[1].dpi_y);
299 294
300 ash::test::SwapPrimaryDisplay(); 295 ash::test::SwapPrimaryDisplay();
301 296
302 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); 297 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo();
303 298
304 ASSERT_EQ(2u, result.size()); 299 ASSERT_EQ(2u, result.size());
305 300
306 EXPECT_EQ("-500,0 500x600", 301 EXPECT_EQ("-500,0 500x600",
307 SystemInfoDisplayBoundsToString(result[0]->bounds)); 302 SystemInfoDisplayBoundsToString(result[0].bounds));
308 EXPECT_EQ(96, result[0]->dpi_x); 303 EXPECT_EQ(96, result[0].dpi_x);
309 EXPECT_EQ(96, result[0]->dpi_y); 304 EXPECT_EQ(96, result[0].dpi_y);
310 305
311 EXPECT_EQ("0,0 200x260", SystemInfoDisplayBoundsToString(result[1]->bounds)); 306 EXPECT_EQ("0,0 200x260", SystemInfoDisplayBoundsToString(result[1].bounds));
312 EXPECT_EQ(96 / 2, result[1]->dpi_x); 307 EXPECT_EQ(96 / 2, result[1].dpi_x);
313 EXPECT_EQ(96 / 2, result[1]->dpi_y); 308 EXPECT_EQ(96 / 2, result[1].dpi_y);
314 } 309 }
315 310
316 TEST_F(DisplayInfoProviderChromeosTest, GetVisibleArea) { 311 TEST_F(DisplayInfoProviderChromeosTest, GetVisibleArea) {
317 UpdateDisplay("640x720*2/o, 400x520/o"); 312 UpdateDisplay("640x720*2/o, 400x520/o");
318 DisplayInfo result; 313 DisplayInfo result;
319 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); 314 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo();
320 315
321 ASSERT_EQ(2u, result.size()); 316 ASSERT_EQ(2u, result.size());
322 317
323 int64_t display_id; 318 int64_t display_id;
324 ASSERT_TRUE(base::StringToInt64(result[1]->id, &display_id)) 319 ASSERT_TRUE(base::StringToInt64(result[1].id, &display_id))
325 << "Display id must be convertable to integer: " << result[1]->id; 320 << "Display id must be convertable to integer: " << result[1].id;
326 ASSERT_TRUE(DisplayExists(display_id)) << display_id << " not found"; 321 ASSERT_TRUE(DisplayExists(display_id)) << display_id << " not found";
327 322
328 // Default overscan is 5%. 323 // Default overscan is 5%.
329 EXPECT_EQ("304,0 380x494", 324 EXPECT_EQ("304,0 380x494", SystemInfoDisplayBoundsToString(result[1].bounds));
330 SystemInfoDisplayBoundsToString(result[1]->bounds)); 325 EXPECT_EQ("13,10,13,10", SystemInfoDisplayInsetsToString(result[1].overscan));
331 EXPECT_EQ("13,10,13,10",
332 SystemInfoDisplayInsetsToString(result[1]->overscan));
333 326
334 GetDisplayManager()->SetOverscanInsets(display_id, 327 GetDisplayManager()->SetOverscanInsets(display_id,
335 gfx::Insets(20, 30, 50, 60)); 328 gfx::Insets(20, 30, 50, 60));
336 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); 329 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo();
337 330
338 ASSERT_EQ(2u, result.size()); 331 ASSERT_EQ(2u, result.size());
339 332
340 EXPECT_EQ(base::Int64ToString(display_id), result[1]->id); 333 EXPECT_EQ(base::Int64ToString(display_id), result[1].id);
341 EXPECT_EQ("304,0 310x450", 334 EXPECT_EQ("304,0 310x450", SystemInfoDisplayBoundsToString(result[1].bounds));
342 SystemInfoDisplayBoundsToString(result[1]->bounds)); 335 EXPECT_EQ("20,30,50,60", SystemInfoDisplayInsetsToString(result[1].overscan));
343 EXPECT_EQ("20,30,50,60",
344 SystemInfoDisplayInsetsToString(result[1]->overscan));
345 336
346 // Set insets for the primary screen. Note that it has 2x scale. 337 // Set insets for the primary screen. Note that it has 2x scale.
347 ASSERT_TRUE(base::StringToInt64(result[0]->id, &display_id)) 338 ASSERT_TRUE(base::StringToInt64(result[0].id, &display_id))
348 << "Display id must be convertable to integer: " << result[0]->id; 339 << "Display id must be convertable to integer: " << result[0].id;
349 ASSERT_TRUE(DisplayExists(display_id)) << display_id << " not found"; 340 ASSERT_TRUE(DisplayExists(display_id)) << display_id << " not found";
350 341
351 EXPECT_EQ("0,0 304x342", SystemInfoDisplayBoundsToString(result[0]->bounds)); 342 EXPECT_EQ("0,0 304x342", SystemInfoDisplayBoundsToString(result[0].bounds));
352 EXPECT_EQ("9,8,9,8", SystemInfoDisplayInsetsToString(result[0]->overscan)); 343 EXPECT_EQ("9,8,9,8", SystemInfoDisplayInsetsToString(result[0].overscan));
353 344
354 GetDisplayManager()->SetOverscanInsets(display_id, 345 GetDisplayManager()->SetOverscanInsets(display_id,
355 gfx::Insets(10, 20, 30, 40)); 346 gfx::Insets(10, 20, 30, 40));
356 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); 347 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo();
357 348
358 ASSERT_EQ(2u, result.size()); 349 ASSERT_EQ(2u, result.size());
359 350
360 EXPECT_EQ(base::Int64ToString(display_id), result[0]->id); 351 EXPECT_EQ(base::Int64ToString(display_id), result[0].id);
361 EXPECT_EQ("0,0 260x320", SystemInfoDisplayBoundsToString(result[0]->bounds)); 352 EXPECT_EQ("0,0 260x320", SystemInfoDisplayBoundsToString(result[0].bounds));
362 EXPECT_EQ("10,20,30,40", 353 EXPECT_EQ("10,20,30,40", SystemInfoDisplayInsetsToString(result[0].overscan));
363 SystemInfoDisplayInsetsToString(result[0]->overscan));
364 } 354 }
365 355
366 TEST_F(DisplayInfoProviderChromeosTest, GetMirroring) { 356 TEST_F(DisplayInfoProviderChromeosTest, GetMirroring) {
367 UpdateDisplay("600x600, 400x520/o"); 357 UpdateDisplay("600x600, 400x520/o");
368 DisplayInfo result; 358 DisplayInfo result;
369 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); 359 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo();
370 360
371 ASSERT_EQ(2u, result.size()); 361 ASSERT_EQ(2u, result.size());
372 362
373 int64_t display_id_primary; 363 int64_t display_id_primary;
374 ASSERT_TRUE(base::StringToInt64(result[0]->id, &display_id_primary)) 364 ASSERT_TRUE(base::StringToInt64(result[0].id, &display_id_primary))
375 << "Display id must be convertable to integer: " << result[0]->id; 365 << "Display id must be convertable to integer: " << result[0].id;
376 ASSERT_TRUE(DisplayExists(display_id_primary)) << display_id_primary 366 ASSERT_TRUE(DisplayExists(display_id_primary)) << display_id_primary
377 << " not found"; 367 << " not found";
378 368
379 int64_t display_id_secondary; 369 int64_t display_id_secondary;
380 ASSERT_TRUE(base::StringToInt64(result[1]->id, &display_id_secondary)) 370 ASSERT_TRUE(base::StringToInt64(result[1].id, &display_id_secondary))
381 << "Display id must be convertable to integer: " << result[1]->id; 371 << "Display id must be convertable to integer: " << result[1].id;
382 ASSERT_TRUE(DisplayExists(display_id_secondary)) << display_id_secondary 372 ASSERT_TRUE(DisplayExists(display_id_secondary)) << display_id_secondary
383 << " not found"; 373 << " not found";
384 374
385 ASSERT_FALSE(GetDisplayManager()->IsInMirrorMode()); 375 ASSERT_FALSE(GetDisplayManager()->IsInMirrorMode());
386 EXPECT_TRUE(result[0]->mirroring_source_id.empty()); 376 EXPECT_TRUE(result[0].mirroring_source_id.empty());
387 EXPECT_TRUE(result[1]->mirroring_source_id.empty()); 377 EXPECT_TRUE(result[1].mirroring_source_id.empty());
388 378
389 GetDisplayManager()->SetMirrorMode(true); 379 GetDisplayManager()->SetMirrorMode(true);
390 ASSERT_TRUE(GetDisplayManager()->IsInMirrorMode()); 380 ASSERT_TRUE(GetDisplayManager()->IsInMirrorMode());
391 381
392 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); 382 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo();
393 383
394 ASSERT_EQ(1u, result.size()); 384 ASSERT_EQ(1u, result.size());
395 EXPECT_EQ(base::Int64ToString(display_id_primary), result[0]->id); 385 EXPECT_EQ(base::Int64ToString(display_id_primary), result[0].id);
396 EXPECT_EQ(base::Int64ToString(display_id_secondary), 386 EXPECT_EQ(base::Int64ToString(display_id_secondary),
397 result[0]->mirroring_source_id); 387 result[0].mirroring_source_id);
398 388
399 GetDisplayManager()->SetMirrorMode(false); 389 GetDisplayManager()->SetMirrorMode(false);
400 ASSERT_FALSE(GetDisplayManager()->IsInMirrorMode()); 390 ASSERT_FALSE(GetDisplayManager()->IsInMirrorMode());
401 391
402 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); 392 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo();
403 393
404 ASSERT_EQ(2u, result.size()); 394 ASSERT_EQ(2u, result.size());
405 EXPECT_EQ(base::Int64ToString(display_id_primary), result[0]->id); 395 EXPECT_EQ(base::Int64ToString(display_id_primary), result[0].id);
406 EXPECT_TRUE(result[0]->mirroring_source_id.empty()); 396 EXPECT_TRUE(result[0].mirroring_source_id.empty());
407 EXPECT_EQ(base::Int64ToString(display_id_secondary), result[1]->id); 397 EXPECT_EQ(base::Int64ToString(display_id_secondary), result[1].id);
408 EXPECT_TRUE(result[1]->mirroring_source_id.empty()); 398 EXPECT_TRUE(result[1].mirroring_source_id.empty());
409 } 399 }
410 400
411 TEST_F(DisplayInfoProviderChromeosTest, GetBounds) { 401 TEST_F(DisplayInfoProviderChromeosTest, GetBounds) {
412 UpdateDisplay("600x600, 400x520"); 402 UpdateDisplay("600x600, 400x520");
413 GetDisplayManager()->SetLayoutForCurrentDisplays( 403 GetDisplayManager()->SetLayoutForCurrentDisplays(
414 ash::test::CreateDisplayLayout(ash::DisplayPlacement::LEFT, -40)); 404 ash::test::CreateDisplayLayout(ash::DisplayPlacement::LEFT, -40));
415 405
416 DisplayInfo result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); 406 DisplayInfo result = DisplayInfoProvider::Get()->GetAllDisplaysInfo();
417 407
418 ASSERT_EQ(2u, result.size()); 408 ASSERT_EQ(2u, result.size());
419 EXPECT_EQ("0,0 600x600", SystemInfoDisplayBoundsToString(result[0]->bounds)); 409 EXPECT_EQ("0,0 600x600", SystemInfoDisplayBoundsToString(result[0].bounds));
420 EXPECT_EQ("-400,-40 400x520", 410 EXPECT_EQ("-400,-40 400x520",
421 SystemInfoDisplayBoundsToString(result[1]->bounds)); 411 SystemInfoDisplayBoundsToString(result[1].bounds));
422 412
423 GetDisplayManager()->SetLayoutForCurrentDisplays( 413 GetDisplayManager()->SetLayoutForCurrentDisplays(
424 ash::test::CreateDisplayLayout(ash::DisplayPlacement::TOP, 40)); 414 ash::test::CreateDisplayLayout(ash::DisplayPlacement::TOP, 40));
425 415
426 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); 416 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo();
427 417
428 ASSERT_EQ(2u, result.size()); 418 ASSERT_EQ(2u, result.size());
429 EXPECT_EQ("0,0 600x600", SystemInfoDisplayBoundsToString(result[0]->bounds)); 419 EXPECT_EQ("0,0 600x600", SystemInfoDisplayBoundsToString(result[0].bounds));
430 EXPECT_EQ("40,-520 400x520", 420 EXPECT_EQ("40,-520 400x520",
431 SystemInfoDisplayBoundsToString(result[1]->bounds)); 421 SystemInfoDisplayBoundsToString(result[1].bounds));
432 422
433 GetDisplayManager()->SetLayoutForCurrentDisplays( 423 GetDisplayManager()->SetLayoutForCurrentDisplays(
434 ash::test::CreateDisplayLayout(ash::DisplayPlacement::BOTTOM, 80)); 424 ash::test::CreateDisplayLayout(ash::DisplayPlacement::BOTTOM, 80));
435 425
436 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); 426 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo();
437 ASSERT_EQ(2u, result.size()); 427 ASSERT_EQ(2u, result.size());
438 EXPECT_EQ("0,0 600x600", SystemInfoDisplayBoundsToString(result[0]->bounds)); 428 EXPECT_EQ("0,0 600x600", SystemInfoDisplayBoundsToString(result[0].bounds));
439 EXPECT_EQ("80,600 400x520", 429 EXPECT_EQ("80,600 400x520",
440 SystemInfoDisplayBoundsToString(result[1]->bounds)); 430 SystemInfoDisplayBoundsToString(result[1].bounds));
441 } 431 }
442 432
443 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginLeftExact) { 433 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginLeftExact) {
444 UpdateDisplay("1200x600,520x400"); 434 UpdateDisplay("1200x600,520x400");
445 435
446 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); 436 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay();
447 api::system_display::DisplayProperties info; 437 api::system_display::DisplayProperties info;
448 info.bounds_origin_x.reset(new int(-520)); 438 info.bounds_origin_x.reset(new int(-520));
449 info.bounds_origin_y.reset(new int(50)); 439 info.bounds_origin_y.reset(new int(50));
450 440
(...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after
1074 std::string error; 1064 std::string error;
1075 CallSetDisplayUnitInfo( 1065 CallSetDisplayUnitInfo(
1076 base::Int64ToString(internal_display_id), info, &success, &error); 1066 base::Int64ToString(internal_display_id), info, &success, &error);
1077 1067
1078 ASSERT_FALSE(success); 1068 ASSERT_FALSE(success);
1079 EXPECT_EQ("Overscan changes not allowed for the internal monitor.", error); 1069 EXPECT_EQ("Overscan changes not allowed for the internal monitor.", error);
1080 } 1070 }
1081 1071
1082 } // namespace 1072 } // namespace
1083 } // namespace extensions 1073 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/display_info_provider_chromeos.cc ('k') | chrome/browser/extensions/display_info_provider_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698