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