OLD | NEW |
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 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 // its available list. | 371 // its available list. |
372 EXPECT_FALSE(property->GetString("color_profile_name", &color_profile)); | 372 EXPECT_FALSE(property->GetString("color_profile_name", &color_profile)); |
373 | 373 |
374 // Resolution is saved only when the resolution is set | 374 // Resolution is saved only when the resolution is set |
375 // by DisplayManager::SetDisplayMode | 375 // by DisplayManager::SetDisplayMode |
376 width = 0; | 376 width = 0; |
377 height = 0; | 377 height = 0; |
378 EXPECT_FALSE(property->GetInteger("width", &width)); | 378 EXPECT_FALSE(property->GetInteger("width", &width)); |
379 EXPECT_FALSE(property->GetInteger("height", &height)); | 379 EXPECT_FALSE(property->GetInteger("height", &height)); |
380 | 380 |
381 scoped_refptr<ash::ManagedDisplayMode> mode(new ash::ManagedDisplayMode( | 381 scoped_refptr<display::ManagedDisplayMode> mode( |
382 gfx::Size(300, 200), 60.0f, false, true, 1.0 /* ui_scale */, | 382 new display::ManagedDisplayMode(gfx::Size(300, 200), 60.0f, false, true, |
383 1.25f /* device_scale_factor */)); | 383 1.0 /* ui_scale */, |
| 384 1.25f /* device_scale_factor */)); |
384 display_manager->SetDisplayMode(id2, mode); | 385 display_manager->SetDisplayMode(id2, mode); |
385 | 386 |
386 window_tree_host_manager->SetPrimaryDisplayId(id2); | 387 window_tree_host_manager->SetPrimaryDisplayId(id2); |
387 | 388 |
388 EXPECT_EQ(id2, display::Screen::GetScreen()->GetPrimaryDisplay().id()); | 389 EXPECT_EQ(id2, display::Screen::GetScreen()->GetPrimaryDisplay().id()); |
389 | 390 |
390 EXPECT_TRUE(properties->GetDictionary(base::Int64ToString(id1), &property)); | 391 EXPECT_TRUE(properties->GetDictionary(base::Int64ToString(id1), &property)); |
391 width = 0; | 392 width = 0; |
392 height = 0; | 393 height = 0; |
393 // Internal display shouldn't store its resolution. | 394 // Internal display shouldn't store its resolution. |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 | 523 |
523 TEST_F(DisplayPreferencesTest, PreventStore) { | 524 TEST_F(DisplayPreferencesTest, PreventStore) { |
524 ResolutionNotificationController::SuppressTimerForTest(); | 525 ResolutionNotificationController::SuppressTimerForTest(); |
525 LoggedInAsUser(); | 526 LoggedInAsUser(); |
526 UpdateDisplay("400x300#500x400|400x300|300x200"); | 527 UpdateDisplay("400x300#500x400|400x300|300x200"); |
527 int64_t id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); | 528 int64_t id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); |
528 // Set display's resolution in single display. It creates the notification and | 529 // Set display's resolution in single display. It creates the notification and |
529 // display preferences should not stored meanwhile. | 530 // display preferences should not stored meanwhile. |
530 ash::Shell* shell = ash::Shell::GetInstance(); | 531 ash::Shell* shell = ash::Shell::GetInstance(); |
531 | 532 |
532 scoped_refptr<ash::ManagedDisplayMode> old_mode( | 533 scoped_refptr<display::ManagedDisplayMode> old_mode( |
533 new ash::ManagedDisplayMode(gfx::Size(400, 300))); | 534 new display::ManagedDisplayMode(gfx::Size(400, 300))); |
534 scoped_refptr<ash::ManagedDisplayMode> new_mode( | 535 scoped_refptr<display::ManagedDisplayMode> new_mode( |
535 new ash::ManagedDisplayMode(gfx::Size(500, 400))); | 536 new display::ManagedDisplayMode(gfx::Size(500, 400))); |
536 if (shell->display_manager()->SetDisplayMode(id, new_mode)) { | 537 if (shell->display_manager()->SetDisplayMode(id, new_mode)) { |
537 shell->resolution_notification_controller()->PrepareNotification( | 538 shell->resolution_notification_controller()->PrepareNotification( |
538 id, old_mode, new_mode, base::Closure()); | 539 id, old_mode, new_mode, base::Closure()); |
539 } | 540 } |
540 UpdateDisplay("500x400#500x400|400x300|300x200"); | 541 UpdateDisplay("500x400#500x400|400x300|300x200"); |
541 | 542 |
542 const base::DictionaryValue* properties = | 543 const base::DictionaryValue* properties = |
543 local_state()->GetDictionary(prefs::kDisplayProperties); | 544 local_state()->GetDictionary(prefs::kDisplayProperties); |
544 const base::DictionaryValue* property = nullptr; | 545 const base::DictionaryValue* property = nullptr; |
545 EXPECT_TRUE(properties->GetDictionary(base::Int64ToString(id), &property)); | 546 EXPECT_TRUE(properties->GetDictionary(base::Int64ToString(id), &property)); |
546 int width = 0, height = 0; | 547 int width = 0, height = 0; |
547 EXPECT_FALSE(property->GetInteger("width", &width)); | 548 EXPECT_FALSE(property->GetInteger("width", &width)); |
548 EXPECT_FALSE(property->GetInteger("height", &height)); | 549 EXPECT_FALSE(property->GetInteger("height", &height)); |
549 | 550 |
550 // Revert the change. When timeout, 2nd button is revert. | 551 // Revert the change. When timeout, 2nd button is revert. |
551 message_center::MessageCenter::Get()->ClickOnNotificationButton( | 552 message_center::MessageCenter::Get()->ClickOnNotificationButton( |
552 ResolutionNotificationController::kNotificationId, 1); | 553 ResolutionNotificationController::kNotificationId, 1); |
553 RunAllPendingInMessageLoop(); | 554 RunAllPendingInMessageLoop(); |
554 EXPECT_FALSE( | 555 EXPECT_FALSE( |
555 message_center::MessageCenter::Get()->FindVisibleNotificationById( | 556 message_center::MessageCenter::Get()->FindVisibleNotificationById( |
556 ResolutionNotificationController::kNotificationId)); | 557 ResolutionNotificationController::kNotificationId)); |
557 | 558 |
558 // Once the notification is removed, the specified resolution will be stored | 559 // Once the notification is removed, the specified resolution will be stored |
559 // by SetDisplayMode. | 560 // by SetDisplayMode. |
560 ash::Shell::GetInstance()->display_manager()->SetDisplayMode( | 561 ash::Shell::GetInstance()->display_manager()->SetDisplayMode( |
561 id, make_scoped_refptr(new ash::ManagedDisplayMode(gfx::Size(300, 200), | 562 id, make_scoped_refptr(new display::ManagedDisplayMode( |
562 60.0f, false, true))); | 563 gfx::Size(300, 200), 60.0f, false, true))); |
563 UpdateDisplay("300x200#500x400|400x300|300x200"); | 564 UpdateDisplay("300x200#500x400|400x300|300x200"); |
564 | 565 |
565 property = nullptr; | 566 property = nullptr; |
566 EXPECT_TRUE(properties->GetDictionary(base::Int64ToString(id), &property)); | 567 EXPECT_TRUE(properties->GetDictionary(base::Int64ToString(id), &property)); |
567 EXPECT_TRUE(property->GetInteger("width", &width)); | 568 EXPECT_TRUE(property->GetInteger("width", &width)); |
568 EXPECT_TRUE(property->GetInteger("height", &height)); | 569 EXPECT_TRUE(property->GetInteger("height", &height)); |
569 EXPECT_EQ(300, width); | 570 EXPECT_EQ(300, width); |
570 EXPECT_EQ(200, height); | 571 EXPECT_EQ(200, height); |
571 } | 572 } |
572 | 573 |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
698 display::Screen* screen = display::Screen::GetScreen(); | 699 display::Screen* screen = display::Screen::GetScreen(); |
699 EXPECT_EQ(id2, screen->GetPrimaryDisplay().id()); | 700 EXPECT_EQ(id2, screen->GetPrimaryDisplay().id()); |
700 const display::DisplayPlacement& placement = | 701 const display::DisplayPlacement& placement = |
701 display_manager->GetCurrentDisplayLayout().placement_list[0]; | 702 display_manager->GetCurrentDisplayLayout().placement_list[0]; |
702 EXPECT_EQ(display::DisplayPlacement::BOTTOM, placement.position); | 703 EXPECT_EQ(display::DisplayPlacement::BOTTOM, placement.position); |
703 EXPECT_EQ(-10, placement.offset); | 704 EXPECT_EQ(-10, placement.offset); |
704 const display::Display& primary_display = screen->GetPrimaryDisplay(); | 705 const display::Display& primary_display = screen->GetPrimaryDisplay(); |
705 EXPECT_EQ("178x176", primary_display.bounds().size().ToString()); | 706 EXPECT_EQ("178x176", primary_display.bounds().size().ToString()); |
706 EXPECT_EQ(display::Display::ROTATE_90, primary_display.rotation()); | 707 EXPECT_EQ(display::Display::ROTATE_90, primary_display.rotation()); |
707 | 708 |
708 const ash::DisplayInfo& info1 = display_manager->GetDisplayInfo(id1); | 709 const display::ManagedDisplayInfo& info1 = |
| 710 display_manager->GetDisplayInfo(id1); |
709 EXPECT_EQ(1.25f, info1.configured_ui_scale()); | 711 EXPECT_EQ(1.25f, info1.configured_ui_scale()); |
710 | 712 |
711 const ash::DisplayInfo& info_primary = | 713 const display::ManagedDisplayInfo& info_primary = |
712 display_manager->GetDisplayInfo(new_primary); | 714 display_manager->GetDisplayInfo(new_primary); |
713 EXPECT_EQ(display::Display::ROTATE_90, info_primary.GetActiveRotation()); | 715 EXPECT_EQ(display::Display::ROTATE_90, info_primary.GetActiveRotation()); |
714 EXPECT_EQ(1.0f, info_primary.configured_ui_scale()); | 716 EXPECT_EQ(1.0f, info_primary.configured_ui_scale()); |
715 } | 717 } |
716 | 718 |
717 TEST_F(DisplayPreferencesTest, StorePowerStateNoLogin) { | 719 TEST_F(DisplayPreferencesTest, StorePowerStateNoLogin) { |
718 EXPECT_FALSE(local_state()->HasPrefPath(prefs::kDisplayPowerState)); | 720 EXPECT_FALSE(local_state()->HasPrefPath(prefs::kDisplayPowerState)); |
719 | 721 |
720 // Stores display prefs without login, which still stores the power state. | 722 // Stores display prefs without login, which still stores the power state. |
721 StoreDisplayPrefs(); | 723 StoreDisplayPrefs(); |
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1119 | 1121 |
1120 EXPECT_EQ(gfx::Rect(0, 0, 200, 200), | 1122 EXPECT_EQ(gfx::Rect(0, 0, 200, 200), |
1121 display_manager->GetDisplayForId(list[0]).bounds()); | 1123 display_manager->GetDisplayForId(list[0]).bounds()); |
1122 EXPECT_EQ(gfx::Rect(-200, 0, 200, 200), | 1124 EXPECT_EQ(gfx::Rect(-200, 0, 200, 200), |
1123 display_manager->GetDisplayForId(list[1]).bounds()); | 1125 display_manager->GetDisplayForId(list[1]).bounds()); |
1124 EXPECT_EQ(gfx::Rect(-100, 200, 300, 300), | 1126 EXPECT_EQ(gfx::Rect(-100, 200, 300, 300), |
1125 display_manager->GetDisplayForId(list[2]).bounds()); | 1127 display_manager->GetDisplayForId(list[2]).bounds()); |
1126 } | 1128 } |
1127 | 1129 |
1128 } // namespace chromeos | 1130 } // namespace chromeos |
OLD | NEW |