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 "ash/display/display_controller.h" | 7 #include "ash/display/display_controller.h" |
8 #include "ash/display/display_layout_store.h" | 8 #include "ash/display/display_layout_store.h" |
9 #include "ash/display/display_manager.h" | 9 #include "ash/display/display_manager.h" |
10 #include "ash/display/resolution_notification_controller.h" | 10 #include "ash/display/resolution_notification_controller.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 | 27 |
28 namespace chromeos { | 28 namespace chromeos { |
29 namespace { | 29 namespace { |
30 const char kPrimaryIdKey[] = "primary-id"; | 30 const char kPrimaryIdKey[] = "primary-id"; |
31 const char kMirroredKey[] = "mirrored"; | 31 const char kMirroredKey[] = "mirrored"; |
32 const char kPositionKey[] = "position"; | 32 const char kPositionKey[] = "position"; |
33 const char kOffsetKey[] = "offset"; | 33 const char kOffsetKey[] = "offset"; |
34 | 34 |
35 class DisplayPreferencesTest : public ash::test::AshTestBase { | 35 class DisplayPreferencesTest : public ash::test::AshTestBase { |
36 protected: | 36 protected: |
37 DisplayPreferencesTest() : ash::test::AshTestBase(), | 37 DisplayPreferencesTest() |
38 mock_user_manager_(new MockUserManager), | 38 : mock_user_manager_(new MockUserManager), |
39 user_manager_enabler_(mock_user_manager_) { | 39 user_manager_enabler_(mock_user_manager_) { |
40 } | 40 } |
41 | 41 |
42 virtual ~DisplayPreferencesTest() {} | 42 virtual ~DisplayPreferencesTest() {} |
43 | 43 |
44 virtual void SetUp() OVERRIDE { | 44 virtual void SetUp() OVERRIDE { |
45 EXPECT_CALL(*mock_user_manager_, IsUserLoggedIn()) | 45 EXPECT_CALL(*mock_user_manager_, IsUserLoggedIn()) |
46 .WillRepeatedly(testing::Return(false)); | 46 .WillRepeatedly(testing::Return(false)); |
47 EXPECT_CALL(*mock_user_manager_, Shutdown()); | 47 EXPECT_CALL(*mock_user_manager_, Shutdown()); |
48 ash::test::AshTestBase::SetUp(); | 48 ash::test::AshTestBase::SetUp(); |
49 RegisterDisplayLocalStatePrefs(local_state_.registry()); | 49 RegisterDisplayLocalStatePrefs(local_state_.registry()); |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 EXPECT_TRUE(layout_value->GetString(kPositionKey, &position)); | 344 EXPECT_TRUE(layout_value->GetString(kPositionKey, &position)); |
345 EXPECT_EQ("right", position); | 345 EXPECT_EQ("right", position); |
346 EXPECT_TRUE(layout_value->GetInteger(kOffsetKey, &offset)); | 346 EXPECT_TRUE(layout_value->GetInteger(kOffsetKey, &offset)); |
347 EXPECT_EQ(0, offset); | 347 EXPECT_EQ(0, offset); |
348 mirrored = true; | 348 mirrored = true; |
349 EXPECT_TRUE(layout_value->GetBoolean(kMirroredKey, &mirrored)); | 349 EXPECT_TRUE(layout_value->GetBoolean(kMirroredKey, &mirrored)); |
350 EXPECT_FALSE(mirrored); | 350 EXPECT_FALSE(mirrored); |
351 EXPECT_TRUE(layout_value->GetString(kPrimaryIdKey, &primary_id_str)); | 351 EXPECT_TRUE(layout_value->GetString(kPrimaryIdKey, &primary_id_str)); |
352 EXPECT_EQ(base::Int64ToString(id1), primary_id_str); | 352 EXPECT_EQ(base::Int64ToString(id1), primary_id_str); |
353 | 353 |
| 354 // Best resolution should not be saved. |
| 355 EXPECT_TRUE(properties->GetDictionary(base::Int64ToString(id2), &property)); |
| 356 EXPECT_FALSE(property->GetInteger("width", &width)); |
| 357 EXPECT_FALSE(property->GetInteger("height", &height)); |
| 358 |
| 359 // Set yet another new display's selected resolution. |
| 360 display_manager->RegisterDisplayProperty(id2 + 1, |
| 361 gfx::Display::ROTATE_0, |
| 362 1.0f, |
| 363 NULL, |
| 364 gfx::Size(500, 400)); |
| 365 // Disconnect 2nd display first to generate new id for external display. |
| 366 UpdateDisplay("200x200*2"); |
| 367 UpdateDisplay("200x200*2, 500x400#600x500|500x400"); |
| 368 // Update key as the 2nd display gets new id. |
| 369 id2 = ash::ScreenAsh::GetSecondaryDisplay().id(); |
| 370 key = base::Int64ToString(id1) + "," + base::Int64ToString(id2); |
| 371 EXPECT_TRUE(displays->GetDictionary(key, &layout_value)); |
| 372 EXPECT_TRUE(layout_value->GetString(kPositionKey, &position)); |
| 373 EXPECT_EQ("right", position); |
| 374 EXPECT_TRUE(layout_value->GetInteger(kOffsetKey, &offset)); |
| 375 EXPECT_EQ(0, offset); |
| 376 mirrored = true; |
| 377 EXPECT_TRUE(layout_value->GetBoolean(kMirroredKey, &mirrored)); |
| 378 EXPECT_FALSE(mirrored); |
| 379 EXPECT_TRUE(layout_value->GetString(kPrimaryIdKey, &primary_id_str)); |
| 380 EXPECT_EQ(base::Int64ToString(id1), primary_id_str); |
| 381 |
354 // External dispaly's selected resolution must be updated. | 382 // External dispaly's selected resolution must be updated. |
355 EXPECT_TRUE(properties->GetDictionary(base::Int64ToString(id2), &property)); | 383 EXPECT_TRUE(properties->GetDictionary(base::Int64ToString(id2), &property)); |
356 EXPECT_TRUE(property->GetInteger("width", &width)); | 384 EXPECT_TRUE(property->GetInteger("width", &width)); |
357 EXPECT_TRUE(property->GetInteger("height", &height)); | 385 EXPECT_TRUE(property->GetInteger("height", &height)); |
358 EXPECT_EQ(500, width); | 386 EXPECT_EQ(500, width); |
359 EXPECT_EQ(400, height); | 387 EXPECT_EQ(400, height); |
360 } | 388 } |
361 | 389 |
362 TEST_F(DisplayPreferencesTest, PreventStore) { | 390 TEST_F(DisplayPreferencesTest, PreventStore) { |
363 ResolutionNotificationController::SuppressTimerForTest(); | 391 ResolutionNotificationController::SuppressTimerForTest(); |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
534 local_state()->GetString(prefs::kDisplayPowerState)); | 562 local_state()->GetString(prefs::kDisplayPowerState)); |
535 | 563 |
536 // Don't try to load | 564 // Don't try to load |
537 local_state()->SetString(prefs::kDisplayPowerState, "all_off"); | 565 local_state()->SetString(prefs::kDisplayPowerState, "all_off"); |
538 LoadDisplayPreferences(false); | 566 LoadDisplayPreferences(false); |
539 EXPECT_EQ(chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON, | 567 EXPECT_EQ(chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON, |
540 shell->output_configurator()->power_state()); | 568 shell->output_configurator()->power_state()); |
541 } | 569 } |
542 | 570 |
543 } // namespace chromeos | 571 } // namespace chromeos |
OLD | NEW |