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

Side by Side Diff: chrome/browser/chromeos/display/display_preferences_unittest.cc

Issue 1920263003: Rename gfx::Display/Screen to display::Display/Screen in chrome (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/chromeos/display/display_preferences.h" 5 #include "chrome/browser/chromeos/display/display_preferences.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 18 matching lines...) Expand all
29 #include "base/values.h" 29 #include "base/values.h"
30 #include "chrome/browser/chromeos/display/display_configuration_observer.h" 30 #include "chrome/browser/chromeos/display/display_configuration_observer.h"
31 #include "chrome/browser/chromeos/login/users/mock_user_manager.h" 31 #include "chrome/browser/chromeos/login/users/mock_user_manager.h"
32 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" 32 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h"
33 #include "chrome/common/pref_names.h" 33 #include "chrome/common/pref_names.h"
34 #include "chrome/test/base/testing_browser_process.h" 34 #include "chrome/test/base/testing_browser_process.h"
35 #include "components/prefs/scoped_user_pref_update.h" 35 #include "components/prefs/scoped_user_pref_update.h"
36 #include "components/prefs/testing_pref_service.h" 36 #include "components/prefs/testing_pref_service.h"
37 #include "ui/display/chromeos/display_configurator.h" 37 #include "ui/display/chromeos/display_configurator.h"
38 #include "ui/display/manager/display_layout_builder.h" 38 #include "ui/display/manager/display_layout_builder.h"
39 #include "ui/display/screen.h"
39 #include "ui/gfx/geometry/vector3d_f.h" 40 #include "ui/gfx/geometry/vector3d_f.h"
40 #include "ui/gfx/screen.h"
41 #include "ui/message_center/message_center.h" 41 #include "ui/message_center/message_center.h"
42 42
43 using ash::ResolutionNotificationController; 43 using ash::ResolutionNotificationController;
44 44
45 namespace chromeos { 45 namespace chromeos {
46 namespace { 46 namespace {
47 const char kPrimaryIdKey[] = "primary-id"; 47 const char kPrimaryIdKey[] = "primary-id";
48 const char kMirroredKey[] = "mirrored"; 48 const char kMirroredKey[] = "mirrored";
49 const char kPositionKey[] = "position"; 49 const char kPositionKey[] = "position";
50 const char kOffsetKey[] = "offset"; 50 const char kOffsetKey[] = "offset";
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 DictionaryPrefUpdate update(&local_state_, prefs::kDisplayProperties); 179 DictionaryPrefUpdate update(&local_state_, prefs::kDisplayProperties);
180 const std::string name = base::Int64ToString(id); 180 const std::string name = base::Int64ToString(id);
181 181
182 base::DictionaryValue* pref_data = update.Get(); 182 base::DictionaryValue* pref_data = update.Get();
183 base::DictionaryValue* property = new base::DictionaryValue(); 183 base::DictionaryValue* property = new base::DictionaryValue();
184 property->SetString("color_profile_name", profile); 184 property->SetString("color_profile_name", profile);
185 pref_data->Set(name, property); 185 pref_data->Set(name, property);
186 } 186 }
187 187
188 void StoreDisplayRotationPrefsForTest(bool rotation_lock, 188 void StoreDisplayRotationPrefsForTest(bool rotation_lock,
189 gfx::Display::Rotation rotation) { 189 display::Display::Rotation rotation) {
190 DictionaryPrefUpdate update(local_state(), prefs::kDisplayRotationLock); 190 DictionaryPrefUpdate update(local_state(), prefs::kDisplayRotationLock);
191 base::DictionaryValue* pref_data = update.Get(); 191 base::DictionaryValue* pref_data = update.Get();
192 pref_data->SetBoolean("lock", rotation_lock); 192 pref_data->SetBoolean("lock", rotation_lock);
193 pref_data->SetInteger("orientation", static_cast<int>(rotation)); 193 pref_data->SetInteger("orientation", static_cast<int>(rotation));
194 } 194 }
195 195
196 std::string GetRegisteredDisplayPlacementStr( 196 std::string GetRegisteredDisplayPlacementStr(
197 const display::DisplayIdList& list) { 197 const display::DisplayIdList& list) {
198 return ash::Shell::GetInstance() 198 return ash::Shell::GetInstance()
199 ->display_manager() 199 ->display_manager()
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 GetRegisteredDisplayPlacementStr(dummy_list)); 255 GetRegisteredDisplayPlacementStr(dummy_list));
256 } 256 }
257 257
258 TEST_F(DisplayPreferencesTest, BasicStores) { 258 TEST_F(DisplayPreferencesTest, BasicStores) {
259 ash::WindowTreeHostManager* window_tree_host_manager = 259 ash::WindowTreeHostManager* window_tree_host_manager =
260 ash::Shell::GetInstance()->window_tree_host_manager(); 260 ash::Shell::GetInstance()->window_tree_host_manager();
261 ash::DisplayManager* display_manager = 261 ash::DisplayManager* display_manager =
262 ash::Shell::GetInstance()->display_manager(); 262 ash::Shell::GetInstance()->display_manager();
263 263
264 UpdateDisplay("200x200*2, 400x300#400x400|300x200*1.25"); 264 UpdateDisplay("200x200*2, 400x300#400x400|300x200*1.25");
265 int64_t id1 = gfx::Screen::GetScreen()->GetPrimaryDisplay().id(); 265 int64_t id1 = display::Screen::GetScreen()->GetPrimaryDisplay().id();
266 ash::test::ScopedSetInternalDisplayId set_internal(id1); 266 ash::test::ScopedSetInternalDisplayId set_internal(id1);
267 int64_t id2 = ash::ScreenUtil::GetSecondaryDisplay().id(); 267 int64_t id2 = ash::ScreenUtil::GetSecondaryDisplay().id();
268 int64_t dummy_id = id2 + 1; 268 int64_t dummy_id = id2 + 1;
269 ASSERT_NE(id1, dummy_id); 269 ASSERT_NE(id1, dummy_id);
270 std::vector<ui::ColorCalibrationProfile> profiles; 270 std::vector<ui::ColorCalibrationProfile> profiles;
271 profiles.push_back(ui::COLOR_PROFILE_STANDARD); 271 profiles.push_back(ui::COLOR_PROFILE_STANDARD);
272 profiles.push_back(ui::COLOR_PROFILE_DYNAMIC); 272 profiles.push_back(ui::COLOR_PROFILE_DYNAMIC);
273 profiles.push_back(ui::COLOR_PROFILE_MOVIE); 273 profiles.push_back(ui::COLOR_PROFILE_MOVIE);
274 profiles.push_back(ui::COLOR_PROFILE_READING); 274 profiles.push_back(ui::COLOR_PROFILE_READING);
275 // Allows only |id1|. 275 // Allows only |id1|.
(...skipping 13 matching lines...) Expand all
289 display::DisplayLayoutBuilder dummy_layout_builder(id1); 289 display::DisplayLayoutBuilder dummy_layout_builder(id1);
290 dummy_layout_builder.SetSecondaryPlacement( 290 dummy_layout_builder.SetSecondaryPlacement(
291 dummy_id, display::DisplayPlacement::LEFT, 20); 291 dummy_id, display::DisplayPlacement::LEFT, 20);
292 std::unique_ptr<display::DisplayLayout> dummy_layout( 292 std::unique_ptr<display::DisplayLayout> dummy_layout(
293 dummy_layout_builder.Build()); 293 dummy_layout_builder.Build());
294 display::DisplayIdList list = ash::test::CreateDisplayIdList2(id1, dummy_id); 294 display::DisplayIdList list = ash::test::CreateDisplayIdList2(id1, dummy_id);
295 StoreDisplayLayoutPrefForTest(list, *dummy_layout); 295 StoreDisplayLayoutPrefForTest(list, *dummy_layout);
296 296
297 // Can't switch to a display that does not exist. 297 // Can't switch to a display that does not exist.
298 window_tree_host_manager->SetPrimaryDisplayId(dummy_id); 298 window_tree_host_manager->SetPrimaryDisplayId(dummy_id);
299 EXPECT_NE(dummy_id, gfx::Screen::GetScreen()->GetPrimaryDisplay().id()); 299 EXPECT_NE(dummy_id, display::Screen::GetScreen()->GetPrimaryDisplay().id());
300 300
301 window_tree_host_manager->SetOverscanInsets(id1, gfx::Insets(10, 11, 12, 13)); 301 window_tree_host_manager->SetOverscanInsets(id1, gfx::Insets(10, 11, 12, 13));
302 display_manager->SetDisplayRotation(id1, gfx::Display::ROTATE_90, 302 display_manager->SetDisplayRotation(id1, display::Display::ROTATE_90,
303 gfx::Display::ROTATION_SOURCE_USER); 303 display::Display::ROTATION_SOURCE_USER);
304 EXPECT_TRUE(ash::SetDisplayUIScale(id1, 1.25f)); 304 EXPECT_TRUE(ash::SetDisplayUIScale(id1, 1.25f));
305 EXPECT_FALSE(ash::SetDisplayUIScale(id2, 1.25f)); 305 EXPECT_FALSE(ash::SetDisplayUIScale(id2, 1.25f));
306 306
307 const base::DictionaryValue* displays = 307 const base::DictionaryValue* displays =
308 local_state()->GetDictionary(prefs::kSecondaryDisplays); 308 local_state()->GetDictionary(prefs::kSecondaryDisplays);
309 const base::DictionaryValue* layout_value = nullptr; 309 const base::DictionaryValue* layout_value = nullptr;
310 std::string key = base::Int64ToString(id1) + "," + base::Int64ToString(id2); 310 std::string key = base::Int64ToString(id1) + "," + base::Int64ToString(id2);
311 std::string dummy_key = 311 std::string dummy_key =
312 base::Int64ToString(id1) + "," + base::Int64ToString(dummy_id); 312 base::Int64ToString(id1) + "," + base::Int64ToString(dummy_id);
313 EXPECT_TRUE(displays->GetDictionary(dummy_key, &layout_value)); 313 EXPECT_TRUE(displays->GetDictionary(dummy_key, &layout_value));
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 height = 0; 376 height = 0;
377 EXPECT_FALSE(property->GetInteger("width", &width)); 377 EXPECT_FALSE(property->GetInteger("width", &width));
378 EXPECT_FALSE(property->GetInteger("height", &height)); 378 EXPECT_FALSE(property->GetInteger("height", &height));
379 379
380 ash::DisplayMode mode(gfx::Size(300, 200), 60.0f, false, true); 380 ash::DisplayMode mode(gfx::Size(300, 200), 60.0f, false, true);
381 mode.device_scale_factor = 1.25f; 381 mode.device_scale_factor = 1.25f;
382 display_manager->SetDisplayMode(id2, mode); 382 display_manager->SetDisplayMode(id2, mode);
383 383
384 window_tree_host_manager->SetPrimaryDisplayId(id2); 384 window_tree_host_manager->SetPrimaryDisplayId(id2);
385 385
386 EXPECT_EQ(id2, gfx::Screen::GetScreen()->GetPrimaryDisplay().id()); 386 EXPECT_EQ(id2, display::Screen::GetScreen()->GetPrimaryDisplay().id());
387 387
388 EXPECT_TRUE(properties->GetDictionary(base::Int64ToString(id1), &property)); 388 EXPECT_TRUE(properties->GetDictionary(base::Int64ToString(id1), &property));
389 width = 0; 389 width = 0;
390 height = 0; 390 height = 0;
391 // Internal display shouldn't store its resolution. 391 // Internal display shouldn't store its resolution.
392 EXPECT_FALSE(property->GetInteger("width", &width)); 392 EXPECT_FALSE(property->GetInteger("width", &width));
393 EXPECT_FALSE(property->GetInteger("height", &height)); 393 EXPECT_FALSE(property->GetInteger("height", &height));
394 394
395 // External display's resolution must be stored this time because 395 // External display's resolution must be stored this time because
396 // it's not best. 396 // it's not best.
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 457
458 // External display's selected resolution must not change 458 // External display's selected resolution must not change
459 // by mirroring. 459 // by mirroring.
460 EXPECT_TRUE(properties->GetDictionary(base::Int64ToString(id2), &property)); 460 EXPECT_TRUE(properties->GetDictionary(base::Int64ToString(id2), &property));
461 EXPECT_TRUE(property->GetInteger("width", &width)); 461 EXPECT_TRUE(property->GetInteger("width", &width));
462 EXPECT_TRUE(property->GetInteger("height", &height)); 462 EXPECT_TRUE(property->GetInteger("height", &height));
463 EXPECT_EQ(300, width); 463 EXPECT_EQ(300, width);
464 EXPECT_EQ(200, height); 464 EXPECT_EQ(200, height);
465 465
466 // Set new display's selected resolution. 466 // Set new display's selected resolution.
467 display_manager->RegisterDisplayProperty(id2 + 1, gfx::Display::ROTATE_0, 467 display_manager->RegisterDisplayProperty(id2 + 1, display::Display::ROTATE_0,
468 1.0f, nullptr, gfx::Size(500, 400), 468 1.0f, nullptr, gfx::Size(500, 400),
469 1.0f, ui::COLOR_PROFILE_STANDARD); 469 1.0f, ui::COLOR_PROFILE_STANDARD);
470 470
471 UpdateDisplay("200x200*2, 600x500#600x500|500x400"); 471 UpdateDisplay("200x200*2, 600x500#600x500|500x400");
472 472
473 // Update key as the 2nd display gets new id. 473 // Update key as the 2nd display gets new id.
474 id2 = ash::ScreenUtil::GetSecondaryDisplay().id(); 474 id2 = ash::ScreenUtil::GetSecondaryDisplay().id();
475 key = base::Int64ToString(id1) + "," + base::Int64ToString(id2); 475 key = base::Int64ToString(id1) + "," + base::Int64ToString(id2);
476 EXPECT_TRUE(displays->GetDictionary(key, &layout_value)); 476 EXPECT_TRUE(displays->GetDictionary(key, &layout_value));
477 EXPECT_TRUE(layout_value->GetString(kPositionKey, &position)); 477 EXPECT_TRUE(layout_value->GetString(kPositionKey, &position));
478 EXPECT_EQ("right", position); 478 EXPECT_EQ("right", position);
479 EXPECT_TRUE(layout_value->GetInteger(kOffsetKey, &offset)); 479 EXPECT_TRUE(layout_value->GetInteger(kOffsetKey, &offset));
480 EXPECT_EQ(0, offset); 480 EXPECT_EQ(0, offset);
481 mirrored = true; 481 mirrored = true;
482 EXPECT_TRUE(layout_value->GetBoolean(kMirroredKey, &mirrored)); 482 EXPECT_TRUE(layout_value->GetBoolean(kMirroredKey, &mirrored));
483 EXPECT_FALSE(mirrored); 483 EXPECT_FALSE(mirrored);
484 EXPECT_TRUE(layout_value->GetString(kPrimaryIdKey, &primary_id_str)); 484 EXPECT_TRUE(layout_value->GetString(kPrimaryIdKey, &primary_id_str));
485 EXPECT_EQ(base::Int64ToString(id1), primary_id_str); 485 EXPECT_EQ(base::Int64ToString(id1), primary_id_str);
486 486
487 // Best resolution should not be saved. 487 // Best resolution should not be saved.
488 EXPECT_TRUE(properties->GetDictionary(base::Int64ToString(id2), &property)); 488 EXPECT_TRUE(properties->GetDictionary(base::Int64ToString(id2), &property));
489 EXPECT_FALSE(property->GetInteger("width", &width)); 489 EXPECT_FALSE(property->GetInteger("width", &width));
490 EXPECT_FALSE(property->GetInteger("height", &height)); 490 EXPECT_FALSE(property->GetInteger("height", &height));
491 491
492 // Set yet another new display's selected resolution. 492 // Set yet another new display's selected resolution.
493 display_manager->RegisterDisplayProperty(id2 + 1, gfx::Display::ROTATE_0, 493 display_manager->RegisterDisplayProperty(id2 + 1, display::Display::ROTATE_0,
494 1.0f, nullptr, gfx::Size(500, 400), 494 1.0f, nullptr, gfx::Size(500, 400),
495 1.0f, ui::COLOR_PROFILE_STANDARD); 495 1.0f, ui::COLOR_PROFILE_STANDARD);
496 // Disconnect 2nd display first to generate new id for external display. 496 // Disconnect 2nd display first to generate new id for external display.
497 UpdateDisplay("200x200*2"); 497 UpdateDisplay("200x200*2");
498 UpdateDisplay("200x200*2, 500x400#600x500|500x400%60.0f"); 498 UpdateDisplay("200x200*2, 500x400#600x500|500x400%60.0f");
499 // Update key as the 2nd display gets new id. 499 // Update key as the 2nd display gets new id.
500 id2 = ash::ScreenUtil::GetSecondaryDisplay().id(); 500 id2 = ash::ScreenUtil::GetSecondaryDisplay().id();
501 key = base::Int64ToString(id1) + "," + base::Int64ToString(id2); 501 key = base::Int64ToString(id1) + "," + base::Int64ToString(id2);
502 EXPECT_TRUE(displays->GetDictionary(key, &layout_value)); 502 EXPECT_TRUE(displays->GetDictionary(key, &layout_value));
503 EXPECT_TRUE(layout_value->GetString(kPositionKey, &position)); 503 EXPECT_TRUE(layout_value->GetString(kPositionKey, &position));
(...skipping 11 matching lines...) Expand all
515 EXPECT_TRUE(property->GetInteger("width", &width)); 515 EXPECT_TRUE(property->GetInteger("width", &width));
516 EXPECT_TRUE(property->GetInteger("height", &height)); 516 EXPECT_TRUE(property->GetInteger("height", &height));
517 EXPECT_EQ(500, width); 517 EXPECT_EQ(500, width);
518 EXPECT_EQ(400, height); 518 EXPECT_EQ(400, height);
519 } 519 }
520 520
521 TEST_F(DisplayPreferencesTest, PreventStore) { 521 TEST_F(DisplayPreferencesTest, PreventStore) {
522 ResolutionNotificationController::SuppressTimerForTest(); 522 ResolutionNotificationController::SuppressTimerForTest();
523 LoggedInAsUser(); 523 LoggedInAsUser();
524 UpdateDisplay("400x300#500x400|400x300|300x200"); 524 UpdateDisplay("400x300#500x400|400x300|300x200");
525 int64_t id = gfx::Screen::GetScreen()->GetPrimaryDisplay().id(); 525 int64_t id = display::Screen::GetScreen()->GetPrimaryDisplay().id();
526 // Set display's resolution in single display. It creates the notification and 526 // Set display's resolution in single display. It creates the notification and
527 // display preferences should not stored meanwhile. 527 // display preferences should not stored meanwhile.
528 ash::Shell* shell = ash::Shell::GetInstance(); 528 ash::Shell* shell = ash::Shell::GetInstance();
529 ash::DisplayMode old_mode; 529 ash::DisplayMode old_mode;
530 ash::DisplayMode new_mode; 530 ash::DisplayMode new_mode;
531 old_mode.size = gfx::Size(400, 300); 531 old_mode.size = gfx::Size(400, 300);
532 new_mode.size = gfx::Size(500, 400); 532 new_mode.size = gfx::Size(500, 400);
533 if (shell->display_manager()->SetDisplayMode(id, new_mode)) { 533 if (shell->display_manager()->SetDisplayMode(id, new_mode)) {
534 shell->resolution_notification_controller()->PrepareNotification( 534 shell->resolution_notification_controller()->PrepareNotification(
535 id, old_mode, new_mode, base::Closure()); 535 id, old_mode, new_mode, base::Closure());
(...skipping 25 matching lines...) Expand all
561 property = nullptr; 561 property = nullptr;
562 EXPECT_TRUE(properties->GetDictionary(base::Int64ToString(id), &property)); 562 EXPECT_TRUE(properties->GetDictionary(base::Int64ToString(id), &property));
563 EXPECT_TRUE(property->GetInteger("width", &width)); 563 EXPECT_TRUE(property->GetInteger("width", &width));
564 EXPECT_TRUE(property->GetInteger("height", &height)); 564 EXPECT_TRUE(property->GetInteger("height", &height));
565 EXPECT_EQ(300, width); 565 EXPECT_EQ(300, width);
566 EXPECT_EQ(200, height); 566 EXPECT_EQ(200, height);
567 } 567 }
568 568
569 TEST_F(DisplayPreferencesTest, StoreForSwappedDisplay) { 569 TEST_F(DisplayPreferencesTest, StoreForSwappedDisplay) {
570 UpdateDisplay("100x100,200x200"); 570 UpdateDisplay("100x100,200x200");
571 int64_t id1 = gfx::Screen::GetScreen()->GetPrimaryDisplay().id(); 571 int64_t id1 = display::Screen::GetScreen()->GetPrimaryDisplay().id();
572 int64_t id2 = ash::ScreenUtil::GetSecondaryDisplay().id(); 572 int64_t id2 = ash::ScreenUtil::GetSecondaryDisplay().id();
573 573
574 LoggedInAsUser(); 574 LoggedInAsUser();
575 575
576 ash::test::SwapPrimaryDisplay(); 576 ash::test::SwapPrimaryDisplay();
577 ASSERT_EQ(id1, ash::ScreenUtil::GetSecondaryDisplay().id()); 577 ASSERT_EQ(id1, ash::ScreenUtil::GetSecondaryDisplay().id());
578 578
579 std::string key = base::Int64ToString(id1) + "," + base::Int64ToString(id2); 579 std::string key = base::Int64ToString(id1) + "," + base::Int64ToString(id2);
580 const base::DictionaryValue* displays = 580 const base::DictionaryValue* displays =
581 local_state()->GetDictionary(prefs::kSecondaryDisplays); 581 local_state()->GetDictionary(prefs::kSecondaryDisplays);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 EXPECT_EQ(id2, stored_placement.display_id); 630 EXPECT_EQ(id2, stored_placement.display_id);
631 EXPECT_EQ(id1, stored_placement.parent_display_id); 631 EXPECT_EQ(id1, stored_placement.parent_display_id);
632 EXPECT_EQ(id1, stored_layout.primary_id); 632 EXPECT_EQ(id1, stored_layout.primary_id);
633 } 633 }
634 } 634 }
635 635
636 TEST_F(DisplayPreferencesTest, RestoreColorProfiles) { 636 TEST_F(DisplayPreferencesTest, RestoreColorProfiles) {
637 ash::DisplayManager* display_manager = 637 ash::DisplayManager* display_manager =
638 ash::Shell::GetInstance()->display_manager(); 638 ash::Shell::GetInstance()->display_manager();
639 639
640 int64_t id1 = gfx::Screen::GetScreen()->GetPrimaryDisplay().id(); 640 int64_t id1 = display::Screen::GetScreen()->GetPrimaryDisplay().id();
641 641
642 StoreColorProfile(id1, "dynamic"); 642 StoreColorProfile(id1, "dynamic");
643 643
644 LoggedInAsUser(); 644 LoggedInAsUser();
645 LoadDisplayPreferences(false); 645 LoadDisplayPreferences(false);
646 646
647 // id1's available color profiles list is empty, means somehow the color 647 // id1's available color profiles list is empty, means somehow the color
648 // profile suport is temporary in trouble. 648 // profile suport is temporary in trouble.
649 EXPECT_NE(ui::COLOR_PROFILE_DYNAMIC, 649 EXPECT_NE(ui::COLOR_PROFILE_DYNAMIC,
650 display_manager->GetDisplayInfo(id1).color_profile()); 650 display_manager->GetDisplayInfo(id1).color_profile());
(...skipping 11 matching lines...) Expand all
662 display_manager->GetDisplayInfo(id1).color_profile()); 662 display_manager->GetDisplayInfo(id1).color_profile());
663 } 663 }
664 664
665 TEST_F(DisplayPreferencesTest, DontStoreInGuestMode) { 665 TEST_F(DisplayPreferencesTest, DontStoreInGuestMode) {
666 ash::WindowTreeHostManager* window_tree_host_manager = 666 ash::WindowTreeHostManager* window_tree_host_manager =
667 ash::Shell::GetInstance()->window_tree_host_manager(); 667 ash::Shell::GetInstance()->window_tree_host_manager();
668 668
669 UpdateDisplay("200x200*2,200x200"); 669 UpdateDisplay("200x200*2,200x200");
670 670
671 LoggedInAsGuest(); 671 LoggedInAsGuest();
672 int64_t id1 = gfx::Screen::GetScreen()->GetPrimaryDisplay().id(); 672 int64_t id1 = display::Screen::GetScreen()->GetPrimaryDisplay().id();
673 ash::test::ScopedSetInternalDisplayId set_internal(id1); 673 ash::test::ScopedSetInternalDisplayId set_internal(id1);
674 int64_t id2 = ash::ScreenUtil::GetSecondaryDisplay().id(); 674 int64_t id2 = ash::ScreenUtil::GetSecondaryDisplay().id();
675 ash::DisplayManager* display_manager = 675 ash::DisplayManager* display_manager =
676 ash::Shell::GetInstance()->display_manager(); 676 ash::Shell::GetInstance()->display_manager();
677 display_manager->SetLayoutForCurrentDisplays( 677 display_manager->SetLayoutForCurrentDisplays(
678 ash::test::CreateDisplayLayout(display::DisplayPlacement::TOP, 10)); 678 ash::test::CreateDisplayLayout(display::DisplayPlacement::TOP, 10));
679 ash::SetDisplayUIScale(id1, 1.25f); 679 ash::SetDisplayUIScale(id1, 1.25f);
680 window_tree_host_manager->SetPrimaryDisplayId(id2); 680 window_tree_host_manager->SetPrimaryDisplayId(id2);
681 int64_t new_primary = gfx::Screen::GetScreen()->GetPrimaryDisplay().id(); 681 int64_t new_primary = display::Screen::GetScreen()->GetPrimaryDisplay().id();
682 window_tree_host_manager->SetOverscanInsets(new_primary, 682 window_tree_host_manager->SetOverscanInsets(new_primary,
683 gfx::Insets(10, 11, 12, 13)); 683 gfx::Insets(10, 11, 12, 13));
684 display_manager->SetDisplayRotation(new_primary, gfx::Display::ROTATE_90, 684 display_manager->SetDisplayRotation(new_primary, display::Display::ROTATE_90,
685 gfx::Display::ROTATION_SOURCE_USER); 685 display::Display::ROTATION_SOURCE_USER);
686 686
687 // Does not store the preferences locally. 687 // Does not store the preferences locally.
688 EXPECT_FALSE(local_state()->FindPreference( 688 EXPECT_FALSE(local_state()->FindPreference(
689 prefs::kSecondaryDisplays)->HasUserSetting()); 689 prefs::kSecondaryDisplays)->HasUserSetting());
690 EXPECT_FALSE(local_state()->FindPreference( 690 EXPECT_FALSE(local_state()->FindPreference(
691 prefs::kDisplayProperties)->HasUserSetting()); 691 prefs::kDisplayProperties)->HasUserSetting());
692 692
693 // Settings are still notified to the system. 693 // Settings are still notified to the system.
694 gfx::Screen* screen = gfx::Screen::GetScreen(); 694 display::Screen* screen = display::Screen::GetScreen();
695 EXPECT_EQ(id2, screen->GetPrimaryDisplay().id()); 695 EXPECT_EQ(id2, screen->GetPrimaryDisplay().id());
696 const display::DisplayPlacement& placement = 696 const display::DisplayPlacement& placement =
697 display_manager->GetCurrentDisplayLayout().placement_list[0]; 697 display_manager->GetCurrentDisplayLayout().placement_list[0];
698 EXPECT_EQ(display::DisplayPlacement::BOTTOM, placement.position); 698 EXPECT_EQ(display::DisplayPlacement::BOTTOM, placement.position);
699 EXPECT_EQ(-10, placement.offset); 699 EXPECT_EQ(-10, placement.offset);
700 const gfx::Display& primary_display = screen->GetPrimaryDisplay(); 700 const display::Display& primary_display = screen->GetPrimaryDisplay();
701 EXPECT_EQ("178x176", primary_display.bounds().size().ToString()); 701 EXPECT_EQ("178x176", primary_display.bounds().size().ToString());
702 EXPECT_EQ(gfx::Display::ROTATE_90, primary_display.rotation()); 702 EXPECT_EQ(display::Display::ROTATE_90, primary_display.rotation());
703 703
704 const ash::DisplayInfo& info1 = display_manager->GetDisplayInfo(id1); 704 const ash::DisplayInfo& info1 = display_manager->GetDisplayInfo(id1);
705 EXPECT_EQ(1.25f, info1.configured_ui_scale()); 705 EXPECT_EQ(1.25f, info1.configured_ui_scale());
706 706
707 const ash::DisplayInfo& info_primary = 707 const ash::DisplayInfo& info_primary =
708 display_manager->GetDisplayInfo(new_primary); 708 display_manager->GetDisplayInfo(new_primary);
709 EXPECT_EQ(gfx::Display::ROTATE_90, info_primary.GetActiveRotation()); 709 EXPECT_EQ(display::Display::ROTATE_90, info_primary.GetActiveRotation());
710 EXPECT_EQ(1.0f, info_primary.configured_ui_scale()); 710 EXPECT_EQ(1.0f, info_primary.configured_ui_scale());
711 } 711 }
712 712
713 TEST_F(DisplayPreferencesTest, StorePowerStateNoLogin) { 713 TEST_F(DisplayPreferencesTest, StorePowerStateNoLogin) {
714 EXPECT_FALSE(local_state()->HasPrefPath(prefs::kDisplayPowerState)); 714 EXPECT_FALSE(local_state()->HasPrefPath(prefs::kDisplayPowerState));
715 715
716 // Stores display prefs without login, which still stores the power state. 716 // Stores display prefs without login, which still stores the power state.
717 StoreDisplayPrefs(); 717 StoreDisplayPrefs();
718 EXPECT_TRUE(local_state()->HasPrefPath(prefs::kDisplayPowerState)); 718 EXPECT_TRUE(local_state()->HasPrefPath(prefs::kDisplayPowerState));
719 } 719 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
763 local_state()->SetString(prefs::kDisplayPowerState, "all_off"); 763 local_state()->SetString(prefs::kDisplayPowerState, "all_off");
764 LoadDisplayPreferences(false); 764 LoadDisplayPreferences(false);
765 EXPECT_EQ(chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON, 765 EXPECT_EQ(chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON,
766 shell->display_configurator()->requested_power_state()); 766 shell->display_configurator()->requested_power_state());
767 } 767 }
768 768
769 // Tests that display configuration changes caused by MaximizeModeController 769 // Tests that display configuration changes caused by MaximizeModeController
770 // are not saved. 770 // are not saved.
771 TEST_F(DisplayPreferencesTest, DontSaveMaximizeModeControllerRotations) { 771 TEST_F(DisplayPreferencesTest, DontSaveMaximizeModeControllerRotations) {
772 ash::Shell* shell = ash::Shell::GetInstance(); 772 ash::Shell* shell = ash::Shell::GetInstance();
773 gfx::Display::SetInternalDisplayId( 773 display::Display::SetInternalDisplayId(
774 gfx::Screen::GetScreen()->GetPrimaryDisplay().id()); 774 display::Screen::GetScreen()->GetPrimaryDisplay().id());
775 ash::DisplayManager* display_manager = shell->display_manager(); 775 ash::DisplayManager* display_manager = shell->display_manager();
776 LoggedInAsUser(); 776 LoggedInAsUser();
777 // Populate the properties. 777 // Populate the properties.
778 display_manager->SetDisplayRotation(gfx::Display::InternalDisplayId(), 778 display_manager->SetDisplayRotation(display::Display::InternalDisplayId(),
779 gfx::Display::ROTATE_180, 779 display::Display::ROTATE_180,
780 gfx::Display::ROTATION_SOURCE_USER); 780 display::Display::ROTATION_SOURCE_USER);
781 // Reset property to avoid rotation lock 781 // Reset property to avoid rotation lock
782 display_manager->SetDisplayRotation(gfx::Display::InternalDisplayId(), 782 display_manager->SetDisplayRotation(display::Display::InternalDisplayId(),
783 gfx::Display::ROTATE_0, 783 display::Display::ROTATE_0,
784 gfx::Display::ROTATION_SOURCE_USER); 784 display::Display::ROTATION_SOURCE_USER);
785 785
786 // Open up 270 degrees to trigger maximize mode 786 // Open up 270 degrees to trigger maximize mode
787 scoped_refptr<chromeos::AccelerometerUpdate> update( 787 scoped_refptr<chromeos::AccelerometerUpdate> update(
788 new chromeos::AccelerometerUpdate()); 788 new chromeos::AccelerometerUpdate());
789 update->Set(chromeos::ACCELEROMETER_SOURCE_ATTACHED_KEYBOARD, 0.0f, 0.0f, 789 update->Set(chromeos::ACCELEROMETER_SOURCE_ATTACHED_KEYBOARD, 0.0f, 0.0f,
790 kMeanGravity); 790 kMeanGravity);
791 update->Set(chromeos::ACCELEROMETER_SOURCE_SCREEN, 0.0f, -kMeanGravity, 0.0f); 791 update->Set(chromeos::ACCELEROMETER_SOURCE_SCREEN, 0.0f, -kMeanGravity, 0.0f);
792 ash::MaximizeModeController* controller = shell->maximize_mode_controller(); 792 ash::MaximizeModeController* controller = shell->maximize_mode_controller();
793 controller->OnAccelerometerUpdated(update); 793 controller->OnAccelerometerUpdated(update);
794 EXPECT_TRUE(controller->IsMaximizeModeWindowManagerEnabled()); 794 EXPECT_TRUE(controller->IsMaximizeModeWindowManagerEnabled());
795 795
796 // Trigger 90 degree rotation 796 // Trigger 90 degree rotation
797 update->Set(chromeos::ACCELEROMETER_SOURCE_ATTACHED_KEYBOARD, -kMeanGravity, 797 update->Set(chromeos::ACCELEROMETER_SOURCE_ATTACHED_KEYBOARD, -kMeanGravity,
798 0.0f, 0.0f); 798 0.0f, 0.0f);
799 update->Set(chromeos::ACCELEROMETER_SOURCE_SCREEN, -kMeanGravity, 0.0f, 0.0f); 799 update->Set(chromeos::ACCELEROMETER_SOURCE_SCREEN, -kMeanGravity, 0.0f, 0.0f);
800 controller->OnAccelerometerUpdated(update); 800 controller->OnAccelerometerUpdated(update);
801 shell->screen_orientation_controller()->OnAccelerometerUpdated(update); 801 shell->screen_orientation_controller()->OnAccelerometerUpdated(update);
802 EXPECT_EQ(gfx::Display::ROTATE_90, GetCurrentInternalDisplayRotation()); 802 EXPECT_EQ(display::Display::ROTATE_90, GetCurrentInternalDisplayRotation());
803 803
804 const base::DictionaryValue* properties = 804 const base::DictionaryValue* properties =
805 local_state()->GetDictionary(prefs::kDisplayProperties); 805 local_state()->GetDictionary(prefs::kDisplayProperties);
806 const base::DictionaryValue* property = nullptr; 806 const base::DictionaryValue* property = nullptr;
807 EXPECT_TRUE(properties->GetDictionary( 807 EXPECT_TRUE(properties->GetDictionary(
808 base::Int64ToString(gfx::Display::InternalDisplayId()), &property)); 808 base::Int64ToString(display::Display::InternalDisplayId()), &property));
809 int rotation = -1; 809 int rotation = -1;
810 EXPECT_TRUE(property->GetInteger("rotation", &rotation)); 810 EXPECT_TRUE(property->GetInteger("rotation", &rotation));
811 EXPECT_EQ(gfx::Display::ROTATE_0, rotation); 811 EXPECT_EQ(display::Display::ROTATE_0, rotation);
812 812
813 // Trigger a save, the acceleration rotation should not be saved as the user 813 // Trigger a save, the acceleration rotation should not be saved as the user
814 // rotation. 814 // rotation.
815 StoreDisplayPrefs(); 815 StoreDisplayPrefs();
816 properties = local_state()->GetDictionary(prefs::kDisplayProperties); 816 properties = local_state()->GetDictionary(prefs::kDisplayProperties);
817 property = nullptr; 817 property = nullptr;
818 EXPECT_TRUE(properties->GetDictionary( 818 EXPECT_TRUE(properties->GetDictionary(
819 base::Int64ToString(gfx::Display::InternalDisplayId()), &property)); 819 base::Int64ToString(display::Display::InternalDisplayId()), &property));
820 rotation = -1; 820 rotation = -1;
821 EXPECT_TRUE(property->GetInteger("rotation", &rotation)); 821 EXPECT_TRUE(property->GetInteger("rotation", &rotation));
822 EXPECT_EQ(gfx::Display::ROTATE_0, rotation); 822 EXPECT_EQ(display::Display::ROTATE_0, rotation);
823 } 823 }
824 824
825 // Tests that the rotation state is saved without a user being logged in. 825 // Tests that the rotation state is saved without a user being logged in.
826 TEST_F(DisplayPreferencesTest, StoreRotationStateNoLogin) { 826 TEST_F(DisplayPreferencesTest, StoreRotationStateNoLogin) {
827 gfx::Display::SetInternalDisplayId( 827 display::Display::SetInternalDisplayId(
828 gfx::Screen::GetScreen()->GetPrimaryDisplay().id()); 828 display::Screen::GetScreen()->GetPrimaryDisplay().id());
829 EXPECT_FALSE(local_state()->HasPrefPath(prefs::kDisplayRotationLock)); 829 EXPECT_FALSE(local_state()->HasPrefPath(prefs::kDisplayRotationLock));
830 830
831 bool current_rotation_lock = IsRotationLocked(); 831 bool current_rotation_lock = IsRotationLocked();
832 StoreDisplayRotationPrefs(current_rotation_lock); 832 StoreDisplayRotationPrefs(current_rotation_lock);
833 EXPECT_TRUE(local_state()->HasPrefPath(prefs::kDisplayRotationLock)); 833 EXPECT_TRUE(local_state()->HasPrefPath(prefs::kDisplayRotationLock));
834 834
835 const base::DictionaryValue* properties = 835 const base::DictionaryValue* properties =
836 local_state()->GetDictionary(prefs::kDisplayRotationLock); 836 local_state()->GetDictionary(prefs::kDisplayRotationLock);
837 bool rotation_lock; 837 bool rotation_lock;
838 EXPECT_TRUE(properties->GetBoolean("lock", &rotation_lock)); 838 EXPECT_TRUE(properties->GetBoolean("lock", &rotation_lock));
839 EXPECT_EQ(current_rotation_lock, rotation_lock); 839 EXPECT_EQ(current_rotation_lock, rotation_lock);
840 840
841 int orientation; 841 int orientation;
842 gfx::Display::Rotation current_rotation = GetCurrentInternalDisplayRotation(); 842 display::Display::Rotation current_rotation =
843 GetCurrentInternalDisplayRotation();
843 EXPECT_TRUE(properties->GetInteger("orientation", &orientation)); 844 EXPECT_TRUE(properties->GetInteger("orientation", &orientation));
844 EXPECT_EQ(current_rotation, orientation); 845 EXPECT_EQ(current_rotation, orientation);
845 } 846 }
846 847
847 // Tests that the rotation state is saved when a guest is logged in. 848 // Tests that the rotation state is saved when a guest is logged in.
848 TEST_F(DisplayPreferencesTest, StoreRotationStateGuest) { 849 TEST_F(DisplayPreferencesTest, StoreRotationStateGuest) {
849 gfx::Display::SetInternalDisplayId( 850 display::Display::SetInternalDisplayId(
850 gfx::Screen::GetScreen()->GetPrimaryDisplay().id()); 851 display::Screen::GetScreen()->GetPrimaryDisplay().id());
851 EXPECT_FALSE(local_state()->HasPrefPath(prefs::kDisplayRotationLock)); 852 EXPECT_FALSE(local_state()->HasPrefPath(prefs::kDisplayRotationLock));
852 LoggedInAsGuest(); 853 LoggedInAsGuest();
853 854
854 bool current_rotation_lock = IsRotationLocked(); 855 bool current_rotation_lock = IsRotationLocked();
855 StoreDisplayRotationPrefs(current_rotation_lock); 856 StoreDisplayRotationPrefs(current_rotation_lock);
856 EXPECT_TRUE(local_state()->HasPrefPath(prefs::kDisplayRotationLock)); 857 EXPECT_TRUE(local_state()->HasPrefPath(prefs::kDisplayRotationLock));
857 858
858 const base::DictionaryValue* properties = 859 const base::DictionaryValue* properties =
859 local_state()->GetDictionary(prefs::kDisplayRotationLock); 860 local_state()->GetDictionary(prefs::kDisplayRotationLock);
860 bool rotation_lock; 861 bool rotation_lock;
861 EXPECT_TRUE(properties->GetBoolean("lock", &rotation_lock)); 862 EXPECT_TRUE(properties->GetBoolean("lock", &rotation_lock));
862 EXPECT_EQ(current_rotation_lock, rotation_lock); 863 EXPECT_EQ(current_rotation_lock, rotation_lock);
863 864
864 int orientation; 865 int orientation;
865 gfx::Display::Rotation current_rotation = GetCurrentInternalDisplayRotation(); 866 display::Display::Rotation current_rotation =
867 GetCurrentInternalDisplayRotation();
866 EXPECT_TRUE(properties->GetInteger("orientation", &orientation)); 868 EXPECT_TRUE(properties->GetInteger("orientation", &orientation));
867 EXPECT_EQ(current_rotation, orientation); 869 EXPECT_EQ(current_rotation, orientation);
868 } 870 }
869 871
870 // Tests that the rotation state is saved when a normal user is logged in. 872 // Tests that the rotation state is saved when a normal user is logged in.
871 TEST_F(DisplayPreferencesTest, StoreRotationStateNormalUser) { 873 TEST_F(DisplayPreferencesTest, StoreRotationStateNormalUser) {
872 gfx::Display::SetInternalDisplayId( 874 display::Display::SetInternalDisplayId(
873 gfx::Screen::GetScreen()->GetPrimaryDisplay().id()); 875 display::Screen::GetScreen()->GetPrimaryDisplay().id());
874 EXPECT_FALSE(local_state()->HasPrefPath(prefs::kDisplayRotationLock)); 876 EXPECT_FALSE(local_state()->HasPrefPath(prefs::kDisplayRotationLock));
875 LoggedInAsGuest(); 877 LoggedInAsGuest();
876 878
877 bool current_rotation_lock = IsRotationLocked(); 879 bool current_rotation_lock = IsRotationLocked();
878 StoreDisplayRotationPrefs(current_rotation_lock); 880 StoreDisplayRotationPrefs(current_rotation_lock);
879 EXPECT_TRUE(local_state()->HasPrefPath(prefs::kDisplayRotationLock)); 881 EXPECT_TRUE(local_state()->HasPrefPath(prefs::kDisplayRotationLock));
880 882
881 const base::DictionaryValue* properties = 883 const base::DictionaryValue* properties =
882 local_state()->GetDictionary(prefs::kDisplayRotationLock); 884 local_state()->GetDictionary(prefs::kDisplayRotationLock);
883 bool rotation_lock; 885 bool rotation_lock;
884 EXPECT_TRUE(properties->GetBoolean("lock", &rotation_lock)); 886 EXPECT_TRUE(properties->GetBoolean("lock", &rotation_lock));
885 EXPECT_EQ(current_rotation_lock, rotation_lock); 887 EXPECT_EQ(current_rotation_lock, rotation_lock);
886 888
887 int orientation; 889 int orientation;
888 gfx::Display::Rotation current_rotation = GetCurrentInternalDisplayRotation(); 890 display::Display::Rotation current_rotation =
891 GetCurrentInternalDisplayRotation();
889 EXPECT_TRUE(properties->GetInteger("orientation", &orientation)); 892 EXPECT_TRUE(properties->GetInteger("orientation", &orientation));
890 EXPECT_EQ(current_rotation, orientation); 893 EXPECT_EQ(current_rotation, orientation);
891 } 894 }
892 895
893 // Tests that rotation state is loaded without a user being logged in, and that 896 // Tests that rotation state is loaded without a user being logged in, and that
894 // entering maximize mode applies the state. 897 // entering maximize mode applies the state.
895 TEST_F(DisplayPreferencesTest, LoadRotationNoLogin) { 898 TEST_F(DisplayPreferencesTest, LoadRotationNoLogin) {
896 gfx::Display::SetInternalDisplayId( 899 display::Display::SetInternalDisplayId(
897 gfx::Screen::GetScreen()->GetPrimaryDisplay().id()); 900 display::Screen::GetScreen()->GetPrimaryDisplay().id());
898 ASSERT_FALSE(local_state()->HasPrefPath(prefs::kDisplayRotationLock)); 901 ASSERT_FALSE(local_state()->HasPrefPath(prefs::kDisplayRotationLock));
899 902
900 ash::Shell* shell = ash::Shell::GetInstance(); 903 ash::Shell* shell = ash::Shell::GetInstance();
901 bool initial_rotation_lock = IsRotationLocked(); 904 bool initial_rotation_lock = IsRotationLocked();
902 ASSERT_FALSE(initial_rotation_lock); 905 ASSERT_FALSE(initial_rotation_lock);
903 ash::DisplayManager* display_manager = shell->display_manager(); 906 ash::DisplayManager* display_manager = shell->display_manager();
904 gfx::Display::Rotation initial_rotation = GetCurrentInternalDisplayRotation(); 907 display::Display::Rotation initial_rotation =
905 ASSERT_EQ(gfx::Display::ROTATE_0, initial_rotation); 908 GetCurrentInternalDisplayRotation();
909 ASSERT_EQ(display::Display::ROTATE_0, initial_rotation);
906 910
907 StoreDisplayRotationPrefs(initial_rotation_lock); 911 StoreDisplayRotationPrefs(initial_rotation_lock);
908 ASSERT_TRUE(local_state()->HasPrefPath(prefs::kDisplayRotationLock)); 912 ASSERT_TRUE(local_state()->HasPrefPath(prefs::kDisplayRotationLock));
909 913
910 StoreDisplayRotationPrefsForTest(true, gfx::Display::ROTATE_90); 914 StoreDisplayRotationPrefsForTest(true, display::Display::ROTATE_90);
911 LoadDisplayPreferences(false); 915 LoadDisplayPreferences(false);
912 916
913 bool display_rotation_lock = 917 bool display_rotation_lock =
914 display_manager->registered_internal_display_rotation_lock(); 918 display_manager->registered_internal_display_rotation_lock();
915 bool display_rotation = 919 bool display_rotation =
916 display_manager->registered_internal_display_rotation(); 920 display_manager->registered_internal_display_rotation();
917 EXPECT_TRUE(display_rotation_lock); 921 EXPECT_TRUE(display_rotation_lock);
918 EXPECT_EQ(gfx::Display::ROTATE_90, display_rotation); 922 EXPECT_EQ(display::Display::ROTATE_90, display_rotation);
919 923
920 bool rotation_lock = IsRotationLocked(); 924 bool rotation_lock = IsRotationLocked();
921 gfx::Display::Rotation before_maximize_mode_rotation = 925 display::Display::Rotation before_maximize_mode_rotation =
922 GetCurrentInternalDisplayRotation(); 926 GetCurrentInternalDisplayRotation();
923 927
924 // Settings should not be applied until maximize mode activates 928 // Settings should not be applied until maximize mode activates
925 EXPECT_FALSE(rotation_lock); 929 EXPECT_FALSE(rotation_lock);
926 EXPECT_EQ(gfx::Display::ROTATE_0, before_maximize_mode_rotation); 930 EXPECT_EQ(display::Display::ROTATE_0, before_maximize_mode_rotation);
927 931
928 // Open up 270 degrees to trigger maximize mode 932 // Open up 270 degrees to trigger maximize mode
929 scoped_refptr<chromeos::AccelerometerUpdate> update( 933 scoped_refptr<chromeos::AccelerometerUpdate> update(
930 new chromeos::AccelerometerUpdate()); 934 new chromeos::AccelerometerUpdate());
931 update->Set(chromeos::ACCELEROMETER_SOURCE_ATTACHED_KEYBOARD, 0.0f, 0.0f, 935 update->Set(chromeos::ACCELEROMETER_SOURCE_ATTACHED_KEYBOARD, 0.0f, 0.0f,
932 kMeanGravity); 936 kMeanGravity);
933 update->Set(chromeos::ACCELEROMETER_SOURCE_SCREEN, 0.0f, -kMeanGravity, 0.0f); 937 update->Set(chromeos::ACCELEROMETER_SOURCE_SCREEN, 0.0f, -kMeanGravity, 0.0f);
934 ash::MaximizeModeController* maximize_mode_controller = 938 ash::MaximizeModeController* maximize_mode_controller =
935 shell->maximize_mode_controller(); 939 shell->maximize_mode_controller();
936 maximize_mode_controller->OnAccelerometerUpdated(update); 940 maximize_mode_controller->OnAccelerometerUpdated(update);
937 EXPECT_TRUE(maximize_mode_controller->IsMaximizeModeWindowManagerEnabled()); 941 EXPECT_TRUE(maximize_mode_controller->IsMaximizeModeWindowManagerEnabled());
938 bool screen_orientation_rotation_lock = IsRotationLocked(); 942 bool screen_orientation_rotation_lock = IsRotationLocked();
939 gfx::Display::Rotation maximize_mode_rotation = 943 display::Display::Rotation maximize_mode_rotation =
940 GetCurrentInternalDisplayRotation(); 944 GetCurrentInternalDisplayRotation();
941 EXPECT_TRUE(screen_orientation_rotation_lock); 945 EXPECT_TRUE(screen_orientation_rotation_lock);
942 EXPECT_EQ(gfx::Display::ROTATE_90, maximize_mode_rotation); 946 EXPECT_EQ(display::Display::ROTATE_90, maximize_mode_rotation);
943 } 947 }
944 948
945 // Tests that rotation lock being set causes the rotation state to be saved. 949 // Tests that rotation lock being set causes the rotation state to be saved.
946 TEST_F(DisplayPreferencesTest, RotationLockTriggersStore) { 950 TEST_F(DisplayPreferencesTest, RotationLockTriggersStore) {
947 gfx::Display::SetInternalDisplayId( 951 display::Display::SetInternalDisplayId(
948 gfx::Screen::GetScreen()->GetPrimaryDisplay().id()); 952 display::Screen::GetScreen()->GetPrimaryDisplay().id());
949 ASSERT_FALSE(local_state()->HasPrefPath(prefs::kDisplayRotationLock)); 953 ASSERT_FALSE(local_state()->HasPrefPath(prefs::kDisplayRotationLock));
950 954
951 ash::Shell::GetInstance()->screen_orientation_controller()->SetRotationLocked( 955 ash::Shell::GetInstance()->screen_orientation_controller()->SetRotationLocked(
952 true); 956 true);
953 957
954 EXPECT_TRUE(local_state()->HasPrefPath(prefs::kDisplayRotationLock)); 958 EXPECT_TRUE(local_state()->HasPrefPath(prefs::kDisplayRotationLock));
955 959
956 const base::DictionaryValue* properties = 960 const base::DictionaryValue* properties =
957 local_state()->GetDictionary(prefs::kDisplayRotationLock); 961 local_state()->GetDictionary(prefs::kDisplayRotationLock);
958 bool rotation_lock; 962 bool rotation_lock;
959 EXPECT_TRUE(properties->GetBoolean("lock", &rotation_lock)); 963 EXPECT_TRUE(properties->GetBoolean("lock", &rotation_lock));
960 } 964 }
961 965
962 TEST_F(DisplayPreferencesTest, SaveUnifiedMode) { 966 TEST_F(DisplayPreferencesTest, SaveUnifiedMode) {
963 967
964 LoggedInAsUser(); 968 LoggedInAsUser();
965 ash::DisplayManager* display_manager = 969 ash::DisplayManager* display_manager =
966 ash::Shell::GetInstance()->display_manager(); 970 ash::Shell::GetInstance()->display_manager();
967 display_manager->SetUnifiedDesktopEnabled(true); 971 display_manager->SetUnifiedDesktopEnabled(true);
968 972
969 UpdateDisplay("200x200,100x100"); 973 UpdateDisplay("200x200,100x100");
970 display::DisplayIdList list = display_manager->GetCurrentDisplayIdList(); 974 display::DisplayIdList list = display_manager->GetCurrentDisplayIdList();
971 EXPECT_EQ("400x200", 975 EXPECT_EQ(
972 gfx::Screen::GetScreen()->GetPrimaryDisplay().size().ToString()); 976 "400x200",
977 display::Screen::GetScreen()->GetPrimaryDisplay().size().ToString());
973 978
974 const base::DictionaryValue* secondary_displays = 979 const base::DictionaryValue* secondary_displays =
975 local_state()->GetDictionary(prefs::kSecondaryDisplays); 980 local_state()->GetDictionary(prefs::kSecondaryDisplays);
976 const base::DictionaryValue* new_value = nullptr; 981 const base::DictionaryValue* new_value = nullptr;
977 EXPECT_TRUE(secondary_displays->GetDictionary( 982 EXPECT_TRUE(secondary_displays->GetDictionary(
978 ash::DisplayIdListToString(list), &new_value)); 983 ash::DisplayIdListToString(list), &new_value));
979 984
980 display::DisplayLayout stored_layout; 985 display::DisplayLayout stored_layout;
981 EXPECT_TRUE(ash::JsonToDisplayLayout(*new_value, &stored_layout)); 986 EXPECT_TRUE(ash::JsonToDisplayLayout(*new_value, &stored_layout));
982 EXPECT_TRUE(stored_layout.default_unified); 987 EXPECT_TRUE(stored_layout.default_unified);
983 EXPECT_FALSE(stored_layout.mirrored); 988 EXPECT_FALSE(stored_layout.mirrored);
984 989
985 const base::DictionaryValue* displays = 990 const base::DictionaryValue* displays =
986 local_state()->GetDictionary(prefs::kDisplayProperties); 991 local_state()->GetDictionary(prefs::kDisplayProperties);
987 int64_t unified_id = gfx::Screen::GetScreen()->GetPrimaryDisplay().id(); 992 int64_t unified_id = display::Screen::GetScreen()->GetPrimaryDisplay().id();
988 EXPECT_FALSE( 993 EXPECT_FALSE(
989 displays->GetDictionary(base::Int64ToString(unified_id), &new_value)); 994 displays->GetDictionary(base::Int64ToString(unified_id), &new_value));
990 995
991 ash::test::SetDisplayResolution(unified_id, gfx::Size(200, 100)); 996 ash::test::SetDisplayResolution(unified_id, gfx::Size(200, 100));
992 EXPECT_EQ("200x100", 997 EXPECT_EQ(
993 gfx::Screen::GetScreen()->GetPrimaryDisplay().size().ToString()); 998 "200x100",
999 display::Screen::GetScreen()->GetPrimaryDisplay().size().ToString());
994 EXPECT_FALSE( 1000 EXPECT_FALSE(
995 displays->GetDictionary(base::Int64ToString(unified_id), &new_value)); 1001 displays->GetDictionary(base::Int64ToString(unified_id), &new_value));
996 1002
997 // Mirror mode should remember if the default mode was unified. 1003 // Mirror mode should remember if the default mode was unified.
998 display_manager->SetMirrorMode(true); 1004 display_manager->SetMirrorMode(true);
999 ASSERT_TRUE(secondary_displays->GetDictionary( 1005 ASSERT_TRUE(secondary_displays->GetDictionary(
1000 ash::DisplayIdListToString(list), &new_value)); 1006 ash::DisplayIdListToString(list), &new_value));
1001 EXPECT_TRUE(ash::JsonToDisplayLayout(*new_value, &stored_layout)); 1007 EXPECT_TRUE(ash::JsonToDisplayLayout(*new_value, &stored_layout));
1002 EXPECT_TRUE(stored_layout.default_unified); 1008 EXPECT_TRUE(stored_layout.default_unified);
1003 EXPECT_TRUE(stored_layout.mirrored); 1009 EXPECT_TRUE(stored_layout.mirrored);
1004 1010
1005 display_manager->SetMirrorMode(false); 1011 display_manager->SetMirrorMode(false);
1006 ASSERT_TRUE(secondary_displays->GetDictionary( 1012 ASSERT_TRUE(secondary_displays->GetDictionary(
1007 ash::DisplayIdListToString(list), &new_value)); 1013 ash::DisplayIdListToString(list), &new_value));
1008 EXPECT_TRUE(ash::JsonToDisplayLayout(*new_value, &stored_layout)); 1014 EXPECT_TRUE(ash::JsonToDisplayLayout(*new_value, &stored_layout));
1009 EXPECT_TRUE(stored_layout.default_unified); 1015 EXPECT_TRUE(stored_layout.default_unified);
1010 EXPECT_FALSE(stored_layout.mirrored); 1016 EXPECT_FALSE(stored_layout.mirrored);
1011 1017
1012 // Exit unified mode. 1018 // Exit unified mode.
1013 display_manager->SetDefaultMultiDisplayModeForCurrentDisplays( 1019 display_manager->SetDefaultMultiDisplayModeForCurrentDisplays(
1014 ash::DisplayManager::EXTENDED); 1020 ash::DisplayManager::EXTENDED);
1015 ASSERT_TRUE(secondary_displays->GetDictionary( 1021 ASSERT_TRUE(secondary_displays->GetDictionary(
1016 ash::DisplayIdListToString(list), &new_value)); 1022 ash::DisplayIdListToString(list), &new_value));
1017 EXPECT_TRUE(ash::JsonToDisplayLayout(*new_value, &stored_layout)); 1023 EXPECT_TRUE(ash::JsonToDisplayLayout(*new_value, &stored_layout));
1018 EXPECT_FALSE(stored_layout.default_unified); 1024 EXPECT_FALSE(stored_layout.default_unified);
1019 EXPECT_FALSE(stored_layout.mirrored); 1025 EXPECT_FALSE(stored_layout.mirrored);
1020 } 1026 }
1021 1027
1022 TEST_F(DisplayPreferencesTest, RestoreUnifiedMode) { 1028 TEST_F(DisplayPreferencesTest, RestoreUnifiedMode) {
1023 int64_t id1 = gfx::Screen::GetScreen()->GetPrimaryDisplay().id(); 1029 int64_t id1 = display::Screen::GetScreen()->GetPrimaryDisplay().id();
1024 display::DisplayIdList list = ash::test::CreateDisplayIdList2(id1, id1 + 1); 1030 display::DisplayIdList list = ash::test::CreateDisplayIdList2(id1, id1 + 1);
1025 StoreDisplayBoolPropertyForList(list, "default_unified", true); 1031 StoreDisplayBoolPropertyForList(list, "default_unified", true);
1026 StoreDisplayPropertyForList( 1032 StoreDisplayPropertyForList(
1027 list, "primary-id", 1033 list, "primary-id",
1028 base::WrapUnique(new base::StringValue(base::Int64ToString(id1)))); 1034 base::WrapUnique(new base::StringValue(base::Int64ToString(id1))));
1029 LoadDisplayPreferences(false); 1035 LoadDisplayPreferences(false);
1030 1036
1031 // Should not restore to unified unless unified desktop is enabled. 1037 // Should not restore to unified unless unified desktop is enabled.
1032 UpdateDisplay("100x100,200x200"); 1038 UpdateDisplay("100x100,200x200");
1033 ash::DisplayManager* display_manager = 1039 ash::DisplayManager* display_manager =
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1080 local_state()->GetDictionary(prefs::kSecondaryDisplays); 1086 local_state()->GetDictionary(prefs::kSecondaryDisplays);
1081 const base::DictionaryValue* new_value = nullptr; 1087 const base::DictionaryValue* new_value = nullptr;
1082 EXPECT_TRUE(secondary_displays->GetDictionary( 1088 EXPECT_TRUE(secondary_displays->GetDictionary(
1083 ash::DisplayIdListToString(list), &new_value)); 1089 ash::DisplayIdListToString(list), &new_value));
1084 } 1090 }
1085 1091
1086 TEST_F(DisplayPreferencesTest, RestoreThreeDisplays) { 1092 TEST_F(DisplayPreferencesTest, RestoreThreeDisplays) {
1087 LoggedInAsUser(); 1093 LoggedInAsUser();
1088 ash::DisplayManager* display_manager = 1094 ash::DisplayManager* display_manager =
1089 ash::Shell::GetInstance()->display_manager(); 1095 ash::Shell::GetInstance()->display_manager();
1090 int64_t id1 = gfx::Screen::GetScreen()->GetPrimaryDisplay().id(); 1096 int64_t id1 = display::Screen::GetScreen()->GetPrimaryDisplay().id();
1091 display::DisplayIdList list = 1097 display::DisplayIdList list =
1092 ash::test::CreateDisplayIdListN(3, id1, id1 + 1, id1 + 2); 1098 ash::test::CreateDisplayIdListN(3, id1, id1 + 1, id1 + 2);
1093 1099
1094 display::DisplayLayoutBuilder builder(list[0]); 1100 display::DisplayLayoutBuilder builder(list[0]);
1095 builder.AddDisplayPlacement(list[1], list[0], display::DisplayPlacement::LEFT, 1101 builder.AddDisplayPlacement(list[1], list[0], display::DisplayPlacement::LEFT,
1096 0); 1102 0);
1097 builder.AddDisplayPlacement(list[2], list[1], 1103 builder.AddDisplayPlacement(list[2], list[1],
1098 display::DisplayPlacement::BOTTOM, 100); 1104 display::DisplayPlacement::BOTTOM, 100);
1099 StoreDisplayLayoutPrefForTest(list, *builder.Build()); 1105 StoreDisplayLayoutPrefForTest(list, *builder.Build());
1100 LoadDisplayPreferences(false); 1106 LoadDisplayPreferences(false);
1101 1107
1102 UpdateDisplay("200x200,200x200,300x300"); 1108 UpdateDisplay("200x200,200x200,300x300");
1103 display::DisplayIdList new_list = display_manager->GetCurrentDisplayIdList(); 1109 display::DisplayIdList new_list = display_manager->GetCurrentDisplayIdList();
1104 ASSERT_EQ(3u, list.size()); 1110 ASSERT_EQ(3u, list.size());
1105 ASSERT_EQ(list[0], new_list[0]); 1111 ASSERT_EQ(list[0], new_list[0]);
1106 ASSERT_EQ(list[1], new_list[1]); 1112 ASSERT_EQ(list[1], new_list[1]);
1107 ASSERT_EQ(list[2], new_list[2]); 1113 ASSERT_EQ(list[2], new_list[2]);
1108 1114
1109 EXPECT_EQ(gfx::Rect(0, 0, 200, 200), 1115 EXPECT_EQ(gfx::Rect(0, 0, 200, 200),
1110 display_manager->GetDisplayForId(list[0]).bounds()); 1116 display_manager->GetDisplayForId(list[0]).bounds());
1111 EXPECT_EQ(gfx::Rect(-200, 0, 200, 200), 1117 EXPECT_EQ(gfx::Rect(-200, 0, 200, 200),
1112 display_manager->GetDisplayForId(list[1]).bounds()); 1118 display_manager->GetDisplayForId(list[1]).bounds());
1113 EXPECT_EQ(gfx::Rect(-100, 200, 300, 300), 1119 EXPECT_EQ(gfx::Rect(-100, 200, 300, 300),
1114 display_manager->GetDisplayForId(list[2]).bounds()); 1120 display_manager->GetDisplayForId(list[2]).bounds());
1115 } 1121 }
1116 1122
1117 } // namespace chromeos 1123 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/display/display_preferences.cc ('k') | chrome/browser/chromeos/display/output_protection_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698