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

Unified Diff: chrome/browser/chromeos/display/display_preferences_unittest.cc

Issue 22703004: Creates notifications for display resolution change. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 7 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/display/display_preferences_unittest.cc
diff --git a/chrome/browser/chromeos/display/display_preferences_unittest.cc b/chrome/browser/chromeos/display/display_preferences_unittest.cc
index a319c5b307d5f3a378b2c985cb966837523c44a1..3d8c17745bcaf2da098a4041ab231a6a2fd63619 100644
--- a/chrome/browser/chromeos/display/display_preferences_unittest.cc
+++ b/chrome/browser/chromeos/display/display_preferences_unittest.cc
@@ -7,6 +7,7 @@
#include "ash/display/display_controller.h"
#include "ash/display/display_layout_store.h"
#include "ash/display/display_manager.h"
+#include "ash/display/resolution_confirmation_dialog.h"
#include "ash/screen_ash.h"
#include "ash/shell.h"
#include "ash/test/ash_test_base.h"
@@ -40,6 +41,7 @@ class DisplayPreferencesTest : public ash::test::AshTestBase {
virtual void SetUp() OVERRIDE {
EXPECT_CALL(*mock_user_manager_, IsUserLoggedIn())
.WillRepeatedly(testing::Return(false));
+ EXPECT_CALL(*mock_user_manager_, Shutdown());
ash::test::AshTestBase::SetUp();
RegisterDisplayLocalStatePrefs(local_state_.registry());
TestingBrowserProcess::GetGlobal()->SetLocalState(&local_state_);
@@ -352,6 +354,46 @@ TEST_F(DisplayPreferencesTest, BasicStores) {
EXPECT_EQ(400, height);
}
+TEST_F(DisplayPreferencesTest, PreventStore) {
+ LoggedInAsUser();
+ UpdateDisplay("200x200*2,400x300");
+ int64 id2 = ash::ScreenAsh::GetSecondaryDisplay().id();
+ ash::internal::ResolutionConfirmationDialog::SetDisplayResolutionAndConfirm(
+ id2, gfx::Size(400, 300), gfx::Size(500, 400), base::Closure());
+ UpdateDisplay("200x200*2,500x400");
+
+ // SetDisplayResolutionAndConfirm invokes DisplayManager::SetDisplayResolution
+ // implicitly but doesn't store the preferences.
+
+ const base::DictionaryValue* properties =
+ local_state()->GetDictionary(prefs::kDisplayProperties);
+ const base::DictionaryValue* property = NULL;
+ EXPECT_TRUE(properties->GetDictionary(base::Int64ToString(id2), &property));
+ int width = 0, height = 0;
+ EXPECT_FALSE(property->GetInteger("width", &width));
+ EXPECT_FALSE(property->GetInteger("height", &height));
+
+ // Close the dialog.
+ ash::internal::ResolutionConfirmationDialog* dialog =
+ ash::internal::ResolutionConfirmationDialog::GetCurrentDialog();
+ dialog->GetWidget()->Close();
+ RunAllPendingInMessageLoop();
+ EXPECT_FALSE(ash::internal::ResolutionConfirmationDialog::GetCurrentDialog());
+
+ // Once the dialog is closed, the specified resolution will be stored by
+ // SetDisplayResolution.
+ ash::Shell::GetInstance()->display_manager()->SetDisplayResolution(
+ id2, gfx::Size(300, 200));
+ UpdateDisplay("200x200*2,300x300");
+
+ property = NULL;
+ EXPECT_TRUE(properties->GetDictionary(base::Int64ToString(id2), &property));
+ EXPECT_TRUE(property->GetInteger("width", &width));
+ EXPECT_TRUE(property->GetInteger("height", &height));
+ EXPECT_EQ(300, width);
+ EXPECT_EQ(200, height);
+}
+
TEST_F(DisplayPreferencesTest, StoreForSwappedDisplay) {
UpdateDisplay("100x100,200x200");
int64 id1 = gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().id();

Powered by Google App Engine
This is Rietveld 408576698