| 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 ash::DisplayMode mode(gfx::Size(300, 200), 60.0f, false, true); | 381 scoped_refptr<ash::DisplayMode> mode(new ash::DisplayMode( |
| 382 mode.device_scale_factor = 1.25f; | 382 gfx::Size(300, 200), 60.0f, false, true, 1.0 /* ui_scale */, |
| 383 1.25f /* device_scale_factor */)); |
| 383 display_manager->SetDisplayMode(id2, mode); | 384 display_manager->SetDisplayMode(id2, mode); |
| 384 | 385 |
| 385 window_tree_host_manager->SetPrimaryDisplayId(id2); | 386 window_tree_host_manager->SetPrimaryDisplayId(id2); |
| 386 | 387 |
| 387 EXPECT_EQ(id2, display::Screen::GetScreen()->GetPrimaryDisplay().id()); | 388 EXPECT_EQ(id2, display::Screen::GetScreen()->GetPrimaryDisplay().id()); |
| 388 | 389 |
| 389 EXPECT_TRUE(properties->GetDictionary(base::Int64ToString(id1), &property)); | 390 EXPECT_TRUE(properties->GetDictionary(base::Int64ToString(id1), &property)); |
| 390 width = 0; | 391 width = 0; |
| 391 height = 0; | 392 height = 0; |
| 392 // Internal display shouldn't store its resolution. | 393 // Internal display shouldn't store its resolution. |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 520 } | 521 } |
| 521 | 522 |
| 522 TEST_F(DisplayPreferencesTest, PreventStore) { | 523 TEST_F(DisplayPreferencesTest, PreventStore) { |
| 523 ResolutionNotificationController::SuppressTimerForTest(); | 524 ResolutionNotificationController::SuppressTimerForTest(); |
| 524 LoggedInAsUser(); | 525 LoggedInAsUser(); |
| 525 UpdateDisplay("400x300#500x400|400x300|300x200"); | 526 UpdateDisplay("400x300#500x400|400x300|300x200"); |
| 526 int64_t id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); | 527 int64_t id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); |
| 527 // 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 |
| 528 // display preferences should not stored meanwhile. | 529 // display preferences should not stored meanwhile. |
| 529 ash::Shell* shell = ash::Shell::GetInstance(); | 530 ash::Shell* shell = ash::Shell::GetInstance(); |
| 530 ash::DisplayMode old_mode; | 531 |
| 531 ash::DisplayMode new_mode; | 532 scoped_refptr<ash::DisplayMode> old_mode( |
| 532 old_mode.size = gfx::Size(400, 300); | 533 new ash::DisplayMode(gfx::Size(400, 300))); |
| 533 new_mode.size = gfx::Size(500, 400); | 534 scoped_refptr<ash::DisplayMode> new_mode( |
| 535 new ash::DisplayMode(gfx::Size(500, 400))); |
| 534 if (shell->display_manager()->SetDisplayMode(id, new_mode)) { | 536 if (shell->display_manager()->SetDisplayMode(id, new_mode)) { |
| 535 shell->resolution_notification_controller()->PrepareNotification( | 537 shell->resolution_notification_controller()->PrepareNotification( |
| 536 id, old_mode, new_mode, base::Closure()); | 538 id, old_mode, new_mode, base::Closure()); |
| 537 } | 539 } |
| 538 UpdateDisplay("500x400#500x400|400x300|300x200"); | 540 UpdateDisplay("500x400#500x400|400x300|300x200"); |
| 539 | 541 |
| 540 const base::DictionaryValue* properties = | 542 const base::DictionaryValue* properties = |
| 541 local_state()->GetDictionary(prefs::kDisplayProperties); | 543 local_state()->GetDictionary(prefs::kDisplayProperties); |
| 542 const base::DictionaryValue* property = nullptr; | 544 const base::DictionaryValue* property = nullptr; |
| 543 EXPECT_TRUE(properties->GetDictionary(base::Int64ToString(id), &property)); | 545 EXPECT_TRUE(properties->GetDictionary(base::Int64ToString(id), &property)); |
| 544 int width = 0, height = 0; | 546 int width = 0, height = 0; |
| 545 EXPECT_FALSE(property->GetInteger("width", &width)); | 547 EXPECT_FALSE(property->GetInteger("width", &width)); |
| 546 EXPECT_FALSE(property->GetInteger("height", &height)); | 548 EXPECT_FALSE(property->GetInteger("height", &height)); |
| 547 | 549 |
| 548 // Revert the change. When timeout, 2nd button is revert. | 550 // Revert the change. When timeout, 2nd button is revert. |
| 549 message_center::MessageCenter::Get()->ClickOnNotificationButton( | 551 message_center::MessageCenter::Get()->ClickOnNotificationButton( |
| 550 ResolutionNotificationController::kNotificationId, 1); | 552 ResolutionNotificationController::kNotificationId, 1); |
| 551 RunAllPendingInMessageLoop(); | 553 RunAllPendingInMessageLoop(); |
| 552 EXPECT_FALSE( | 554 EXPECT_FALSE( |
| 553 message_center::MessageCenter::Get()->FindVisibleNotificationById( | 555 message_center::MessageCenter::Get()->FindVisibleNotificationById( |
| 554 ResolutionNotificationController::kNotificationId)); | 556 ResolutionNotificationController::kNotificationId)); |
| 555 | 557 |
| 556 // Once the notification is removed, the specified resolution will be stored | 558 // Once the notification is removed, the specified resolution will be stored |
| 557 // by SetDisplayMode. | 559 // by SetDisplayMode. |
| 558 ash::Shell::GetInstance()->display_manager()->SetDisplayMode( | 560 ash::Shell::GetInstance()->display_manager()->SetDisplayMode( |
| 559 id, ash::DisplayMode(gfx::Size(300, 200), 60.0f, false, true)); | 561 id, make_scoped_refptr( |
| 562 new ash::DisplayMode(gfx::Size(300, 200), 60.0f, false, true))); |
| 560 UpdateDisplay("300x200#500x400|400x300|300x200"); | 563 UpdateDisplay("300x200#500x400|400x300|300x200"); |
| 561 | 564 |
| 562 property = nullptr; | 565 property = nullptr; |
| 563 EXPECT_TRUE(properties->GetDictionary(base::Int64ToString(id), &property)); | 566 EXPECT_TRUE(properties->GetDictionary(base::Int64ToString(id), &property)); |
| 564 EXPECT_TRUE(property->GetInteger("width", &width)); | 567 EXPECT_TRUE(property->GetInteger("width", &width)); |
| 565 EXPECT_TRUE(property->GetInteger("height", &height)); | 568 EXPECT_TRUE(property->GetInteger("height", &height)); |
| 566 EXPECT_EQ(300, width); | 569 EXPECT_EQ(300, width); |
| 567 EXPECT_EQ(200, height); | 570 EXPECT_EQ(200, height); |
| 568 } | 571 } |
| 569 | 572 |
| (...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1116 | 1119 |
| 1117 EXPECT_EQ(gfx::Rect(0, 0, 200, 200), | 1120 EXPECT_EQ(gfx::Rect(0, 0, 200, 200), |
| 1118 display_manager->GetDisplayForId(list[0]).bounds()); | 1121 display_manager->GetDisplayForId(list[0]).bounds()); |
| 1119 EXPECT_EQ(gfx::Rect(-200, 0, 200, 200), | 1122 EXPECT_EQ(gfx::Rect(-200, 0, 200, 200), |
| 1120 display_manager->GetDisplayForId(list[1]).bounds()); | 1123 display_manager->GetDisplayForId(list[1]).bounds()); |
| 1121 EXPECT_EQ(gfx::Rect(-100, 200, 300, 300), | 1124 EXPECT_EQ(gfx::Rect(-100, 200, 300, 300), |
| 1122 display_manager->GetDisplayForId(list[2]).bounds()); | 1125 display_manager->GetDisplayForId(list[2]).bounds()); |
| 1123 } | 1126 } |
| 1124 | 1127 |
| 1125 } // namespace chromeos | 1128 } // namespace chromeos |
| OLD | NEW |