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

Side by Side Diff: ash/display/display_change_observer_chromeos_unittest.cc

Issue 635403002: Preserve the native mode when parsing external display modes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@fix-hotplug-in-mirror-mode
Patch Set: . Created 6 years, 2 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 "ash/display/display_change_observer_chromeos.h" 5 #include "ash/display/display_change_observer_chromeos.h"
6 6
7 #include "ash/display/display_info.h" 7 #include "ash/display/display_info.h"
8 #include "base/memory/scoped_vector.h" 8 #include "base/memory/scoped_vector.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "ui/display/chromeos/display_configurator.h" 10 #include "ui/display/chromeos/display_configurator.h"
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 EXPECT_EQ(display_modes[7].device_scale_factor, 1.25); 306 EXPECT_EQ(display_modes[7].device_scale_factor, 1.25);
307 307
308 EXPECT_EQ("3840x2160", display_modes[8].size.ToString()); 308 EXPECT_EQ("3840x2160", display_modes[8].size.ToString());
309 EXPECT_FALSE(display_modes[8].interlaced); 309 EXPECT_FALSE(display_modes[8].interlaced);
310 EXPECT_TRUE(display_modes[8].native); 310 EXPECT_TRUE(display_modes[8].native);
311 EXPECT_EQ(display_modes[8].refresh_rate, 30); 311 EXPECT_EQ(display_modes[8].refresh_rate, 30);
312 312
313 // Outputs without any modes shouldn't cause a crash. 313 // Outputs without any modes shouldn't cause a crash.
314 modes.clear(); 314 modes.clear();
315 display_snapshot.set_modes(modes.get()); 315 display_snapshot.set_modes(modes.get());
316 display_snapshot.set_native_mode(NULL);
316 317
317 display_modes = DisplayChangeObserver::GetExternalDisplayModeList(output); 318 display_modes = DisplayChangeObserver::GetExternalDisplayModeList(output);
318 EXPECT_EQ(0u, display_modes.size()); 319 EXPECT_EQ(0u, display_modes.size());
319 } 320 }
320 321
321 TEST_F(DisplayChangeObserverTest, FindDeviceScaleFactor) { 322 TEST_F(DisplayChangeObserverTest, FindDeviceScaleFactor) {
322 // 19.5" 1600x900 323 // 19.5" 1600x900
323 EXPECT_EQ(1.0f, DisplayChangeObserver::FindDeviceScaleFactor(94.14f)); 324 EXPECT_EQ(1.0f, DisplayChangeObserver::FindDeviceScaleFactor(94.14f));
324 325
325 // 21.5" 1920x1080 326 // 21.5" 1920x1080
(...skipping 10 matching lines...) Expand all
336 337
337 // 12.85" 2560x1700 338 // 12.85" 2560x1700
338 EXPECT_EQ(2.0f, DisplayChangeObserver::FindDeviceScaleFactor(239.15f)); 339 EXPECT_EQ(2.0f, DisplayChangeObserver::FindDeviceScaleFactor(239.15f));
339 340
340 // Erroneous values should still work. 341 // Erroneous values should still work.
341 EXPECT_EQ(1.0f, DisplayChangeObserver::FindDeviceScaleFactor(-100.0f)); 342 EXPECT_EQ(1.0f, DisplayChangeObserver::FindDeviceScaleFactor(-100.0f));
342 EXPECT_EQ(1.0f, DisplayChangeObserver::FindDeviceScaleFactor(0.0f)); 343 EXPECT_EQ(1.0f, DisplayChangeObserver::FindDeviceScaleFactor(0.0f));
343 EXPECT_EQ(2.0f, DisplayChangeObserver::FindDeviceScaleFactor(10000.0f)); 344 EXPECT_EQ(2.0f, DisplayChangeObserver::FindDeviceScaleFactor(10000.0f));
344 } 345 }
345 346
347 TEST_F(DisplayChangeObserverTest,
348 FindExternalDisplayNativeModeWhenOverwritten) {
349 ScopedVector<const ui::DisplayMode> modes;
350 modes.push_back(new ui::DisplayMode(gfx::Size(1920, 1080), true, 60));
351 modes.push_back(new ui::DisplayMode(gfx::Size(1920, 1080), false, 60));
352
353 ui::TestDisplaySnapshot display_snapshot;
354 display_snapshot.set_modes(modes.get());
355 display_snapshot.set_native_mode(modes[0]);
356 DisplayConfigurator::DisplayState output;
357 output.display = &display_snapshot;
358
359 std::vector<DisplayMode> display_modes =
360 DisplayChangeObserver::GetExternalDisplayModeList(output);
361 ASSERT_EQ(2u, display_modes.size());
362 EXPECT_EQ("1920x1080", display_modes[0].size.ToString());
363 EXPECT_FALSE(display_modes[0].interlaced);
364 EXPECT_FALSE(display_modes[0].native);
365 EXPECT_EQ(display_modes[0].refresh_rate, 60);
366
367 EXPECT_EQ("1920x1080", display_modes[1].size.ToString());
368 EXPECT_TRUE(display_modes[1].interlaced);
369 EXPECT_TRUE(display_modes[1].native);
370 EXPECT_EQ(display_modes[1].refresh_rate, 60);
371 }
372
346 } // namespace ash 373 } // namespace ash
OLDNEW
« no previous file with comments | « ash/display/display_change_observer_chromeos.cc ('k') | ash/touch/touch_transformer_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698