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

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

Issue 226183004: Renamed OutputConfigurator to DisplayConfigurator (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 6 years, 8 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 | Annotate | Revision Log
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 "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"
11 #include "ash/screen_util.h" 11 #include "ash/screen_util.h"
12 #include "ash/shell.h" 12 #include "ash/shell.h"
13 #include "ash/test/ash_test_base.h" 13 #include "ash/test/ash_test_base.h"
14 #include "ash/test/display_manager_test_api.h" 14 #include "ash/test/display_manager_test_api.h"
15 #include "base/prefs/scoped_user_pref_update.h" 15 #include "base/prefs/scoped_user_pref_update.h"
16 #include "base/prefs/testing_pref_service.h" 16 #include "base/prefs/testing_pref_service.h"
17 #include "base/strings/string_number_conversions.h" 17 #include "base/strings/string_number_conversions.h"
18 #include "base/values.h" 18 #include "base/values.h"
19 #include "chrome/browser/chromeos/display/display_configuration_observer.h" 19 #include "chrome/browser/chromeos/display/display_configuration_observer.h"
20 #include "chrome/browser/chromeos/login/mock_user_manager.h" 20 #include "chrome/browser/chromeos/login/mock_user_manager.h"
21 #include "chrome/browser/chromeos/login/user_manager.h" 21 #include "chrome/browser/chromeos/login/user_manager.h"
22 #include "chrome/common/pref_names.h" 22 #include "chrome/common/pref_names.h"
23 #include "chrome/test/base/testing_browser_process.h" 23 #include "chrome/test/base/testing_browser_process.h"
24 #include "ui/display/chromeos/output_configurator.h" 24 #include "ui/display/chromeos/display_configurator.h"
25 #include "ui/message_center/message_center.h" 25 #include "ui/message_center/message_center.h"
26 26
27 using ash::ResolutionNotificationController; 27 using ash::ResolutionNotificationController;
28 28
29 namespace chromeos { 29 namespace chromeos {
30 namespace { 30 namespace {
31 const char kPrimaryIdKey[] = "primary-id"; 31 const char kPrimaryIdKey[] = "primary-id";
32 const char kMirroredKey[] = "mirrored"; 32 const char kMirroredKey[] = "mirrored";
33 const char kPositionKey[] = "position"; 33 const char kPositionKey[] = "position";
34 const char kOffsetKey[] = "offset"; 34 const char kOffsetKey[] = "offset";
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 StoreDisplayLayoutPrefForPair(id1, id2, ash::DisplayLayout::TOP, 20); 168 StoreDisplayLayoutPrefForPair(id1, id2, ash::DisplayLayout::TOP, 20);
169 StoreDisplayLayoutPrefForPair(id1, dummy_id, ash::DisplayLayout::LEFT, 30); 169 StoreDisplayLayoutPrefForPair(id1, dummy_id, ash::DisplayLayout::LEFT, 30);
170 StoreDisplayPowerStateForTest( 170 StoreDisplayPowerStateForTest(
171 chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON); 171 chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON);
172 172
173 ash::Shell* shell = ash::Shell::GetInstance(); 173 ash::Shell* shell = ash::Shell::GetInstance();
174 174
175 LoadDisplayPreferences(true); 175 LoadDisplayPreferences(true);
176 // DisplayPowerState should be ignored at boot. 176 // DisplayPowerState should be ignored at boot.
177 EXPECT_EQ(chromeos::DISPLAY_POWER_ALL_ON, 177 EXPECT_EQ(chromeos::DISPLAY_POWER_ALL_ON,
178 shell->output_configurator()->power_state()); 178 shell->display_configurator()->power_state());
179 179
180 shell->display_manager()->UpdateDisplays(); 180 shell->display_manager()->UpdateDisplays();
181 // Check if the layout settings are notified to the system properly. 181 // Check if the layout settings are notified to the system properly.
182 // The paired layout overrides old layout. 182 // The paired layout overrides old layout.
183 // Inverted one of for specified pair (id1, id2). Not used for the pair 183 // Inverted one of for specified pair (id1, id2). Not used for the pair
184 // (id1, dummy_id) since dummy_id is not connected right now. 184 // (id1, dummy_id) since dummy_id is not connected right now.
185 EXPECT_EQ("top, 20", 185 EXPECT_EQ("top, 20",
186 shell->display_manager()->GetCurrentDisplayLayout().ToString()); 186 shell->display_manager()->GetCurrentDisplayLayout().ToString());
187 EXPECT_EQ("top, 20", GetRegisteredDisplayLayoutStr(id1, id2)); 187 EXPECT_EQ("top, 20", GetRegisteredDisplayLayoutStr(id1, id2));
188 EXPECT_EQ("left, 30", GetRegisteredDisplayLayoutStr(id1, dummy_id)); 188 EXPECT_EQ("left, 30", GetRegisteredDisplayLayoutStr(id1, dummy_id));
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 586
587 LoggedInAsUser(); 587 LoggedInAsUser();
588 StoreDisplayPrefs(); 588 StoreDisplayPrefs();
589 EXPECT_TRUE(local_state()->HasPrefPath(prefs::kDisplayPowerState)); 589 EXPECT_TRUE(local_state()->HasPrefPath(prefs::kDisplayPowerState));
590 } 590 }
591 591
592 TEST_F(DisplayPreferencesTest, DisplayPowerStateAfterRestart) { 592 TEST_F(DisplayPreferencesTest, DisplayPowerStateAfterRestart) {
593 StoreDisplayPowerStateForTest( 593 StoreDisplayPowerStateForTest(
594 chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON); 594 chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON);
595 LoadDisplayPreferences(false); 595 LoadDisplayPreferences(false);
596 EXPECT_EQ( 596 EXPECT_EQ(chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON,
597 chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON, 597 ash::Shell::GetInstance()->display_configurator()->power_state());
598 ash::Shell::GetInstance()->output_configurator()->power_state());
599 } 598 }
600 599
601 TEST_F(DisplayPreferencesTest, DontSaveAndRestoreAllOff) { 600 TEST_F(DisplayPreferencesTest, DontSaveAndRestoreAllOff) {
602 ash::Shell* shell = ash::Shell::GetInstance(); 601 ash::Shell* shell = ash::Shell::GetInstance();
603 StoreDisplayPowerStateForTest( 602 StoreDisplayPowerStateForTest(
604 chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON); 603 chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON);
605 LoadDisplayPreferences(false); 604 LoadDisplayPreferences(false);
606 // DisplayPowerState should be ignored at boot. 605 // DisplayPowerState should be ignored at boot.
607 EXPECT_EQ(chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON, 606 EXPECT_EQ(chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON,
608 shell->output_configurator()->power_state()); 607 shell->display_configurator()->power_state());
609 608
610 StoreDisplayPowerStateForTest( 609 StoreDisplayPowerStateForTest(
611 chromeos::DISPLAY_POWER_ALL_OFF); 610 chromeos::DISPLAY_POWER_ALL_OFF);
612 EXPECT_EQ(chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON, 611 EXPECT_EQ(chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON,
613 shell->output_configurator()->power_state()); 612 shell->display_configurator()->power_state());
614 EXPECT_EQ("internal_off_external_on", 613 EXPECT_EQ("internal_off_external_on",
615 local_state()->GetString(prefs::kDisplayPowerState)); 614 local_state()->GetString(prefs::kDisplayPowerState));
616 615
617 // Don't try to load 616 // Don't try to load
618 local_state()->SetString(prefs::kDisplayPowerState, "all_off"); 617 local_state()->SetString(prefs::kDisplayPowerState, "all_off");
619 LoadDisplayPreferences(false); 618 LoadDisplayPreferences(false);
620 EXPECT_EQ(chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON, 619 EXPECT_EQ(chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON,
621 shell->output_configurator()->power_state()); 620 shell->display_configurator()->power_state());
622 } 621 }
623 622
624 } // namespace chromeos 623 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698