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

Side by Side Diff: chromeos/display/output_util_unittest.cc

Issue 24081004: chromeos: Fix display failures when going to mirrored mode. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: uploading yet again Created 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "chromeos/display/output_util.h" 5 #include "chromeos/display/output_util.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 #include <X11/extensions/Xrandr.h> 10 #include <X11/extensions/Xrandr.h>
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 kInternalDisplay, charsize(kInternalDisplay), 0, &id)); 239 kInternalDisplay, charsize(kInternalDisplay), 0, &id));
240 EXPECT_NE(-1, id); 240 EXPECT_NE(-1, id);
241 } 241 }
242 242
243 TEST(OutputUtilTest, GetDisplayIdFailure) { 243 TEST(OutputUtilTest, GetDisplayIdFailure) {
244 int64 id = -1; 244 int64 id = -1;
245 EXPECT_FALSE(GetDisplayIdFromEDID(NULL, 0, 0, &id)); 245 EXPECT_FALSE(GetDisplayIdFromEDID(NULL, 0, 0, &id));
246 EXPECT_EQ(-1, id); 246 EXPECT_EQ(-1, id);
247 } 247 }
248 248
249 TEST(OutputUtilTest, FindOutputModeMatchingSize) {
250 XRRScreenResources resources = {0};
251 RROutput outputs[] = {1};
252 resources.noutput = arraysize(outputs);
253 resources.outputs = outputs;
254 XRRModeInfo modes[] = {
255 // id, width, height, interlaced, refresh rate
256 test::CreateModeInfo(11, 1920, 1200, false, 60.0f),
257
258 // different rates
259 test::CreateModeInfo(12, 1920, 1080, false, 30.0f),
260 test::CreateModeInfo(13, 1920, 1080, false, 50.0f),
261 test::CreateModeInfo(14, 1920, 1080, false, 40.0f),
262 test::CreateModeInfo(15, 1920, 1080, false, 0.0f),
263
264 // interlace vs non interlace
265 test::CreateModeInfo(16, 1280, 720, true, 60.0f),
266 test::CreateModeInfo(17, 1280, 720, false, 40.0f),
267
268 // interlace only
269 test::CreateModeInfo(18, 1024, 768, true, 0.0f),
270 test::CreateModeInfo(19, 1024, 768, true, 40.0f),
271 test::CreateModeInfo(20, 1024, 768, true, 60.0f),
272
273 // mixed
274 test::CreateModeInfo(21, 1024, 600, true, 60.0f),
275 test::CreateModeInfo(22, 1024, 600, false, 40.0f),
276 test::CreateModeInfo(23, 1024, 600, false, 50.0f),
277
278 // just one interlaced mode
279 test::CreateModeInfo(24, 640, 480, true, 60.0f),
280
281 // refresh rate not available.
282 test::CreateModeInfo(25, 320, 200, false, 0.0f),
283 };
284 resources.nmode = arraysize(modes);
285 resources.modes = modes;
286
287 XRROutputInfo output_info = {0};
288 RRMode output_modes[] = {
289 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25
290 };
291 output_info.nmode = arraysize(output_modes);
292 output_info.modes = output_modes;
293
294 EXPECT_EQ(11u, FindOutputModeMatchingSize(&resources,
295 &output_info,
296 1920, 1200));
297
298 // Should pick highest refresh rate.
299 EXPECT_EQ(13u, FindOutputModeMatchingSize(&resources,
300 &output_info,
301 1920, 1080));
302
303 // Should pick non interlaced mode.
304 EXPECT_EQ(17u, FindOutputModeMatchingSize(&resources,
305 &output_info,
306 1280, 720));
307
308 // Interlaced only. Should pick one with the highest refresh rate in
309 // interlaced mode.
310 EXPECT_EQ(20u, FindOutputModeMatchingSize(&resources,
311 &output_info,
312 1024, 768));
313
314 // Mixed: Should pick one with the highest refresh rate in
315 // interlaced mode.
316 EXPECT_EQ(23u, FindOutputModeMatchingSize(&resources,
317 &output_info,
318 1024, 600));
319
320 // Just one interlaced mode.
321 EXPECT_EQ(24u, FindOutputModeMatchingSize(&resources,
322 &output_info,
323 640, 480));
324
325 // Refresh rate not available.
326 EXPECT_EQ(25u, FindOutputModeMatchingSize(&resources,
327 &output_info,
328 320, 200));
329
330 // No mode found.
331 EXPECT_EQ(static_cast<XID>(None),
332 FindOutputModeMatchingSize(&resources,
333 &output_info,
334 1440, 900));
335 }
336
337 } // namespace chromeos 249 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698