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

Unified Diff: ash/display/display_controller_unittest.cc

Issue 10909043: Cancel drag if display configuration changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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
« no previous file with comments | « ash/display/display_controller.cc ('k') | ash/display/multi_display_manager.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/display/display_controller_unittest.cc
diff --git a/ash/display/display_controller_unittest.cc b/ash/display/display_controller_unittest.cc
index 428d0de60270d96a19de03e86654232b067d37b0..d2be5b659da6ba004f83e84dd07b681c3a870e3c 100644
--- a/ash/display/display_controller_unittest.cc
+++ b/ash/display/display_controller_unittest.cc
@@ -16,6 +16,32 @@ namespace ash {
namespace test {
namespace {
+class TestObserver : public DisplayController::Observer {
+ public:
+ TestObserver() : count_(0) {
+ Shell::GetInstance()->display_controller()->AddObserver(this);
+ }
+
+ virtual ~TestObserver() {
+ Shell::GetInstance()->display_controller()->RemoveObserver(this);
+ }
+
+ virtual void OnDisplayConfigurationChanging() OVERRIDE {
+ ++count_;
+ }
+
+ int CountAndReset() {
+ int c = count_;
+ count_ = 0;
+ return c;
+ }
+
+ private:
+ int count_;
+
+ DISALLOW_COPY_AND_ASSIGN(TestObserver);
+};
+
gfx::Display GetPrimaryDisplay() {
return gfx::Screen::GetDisplayNearestWindow(
Shell::GetAllRootWindows()[0]);
@@ -49,7 +75,9 @@ typedef test::AshTestBase DisplayControllerTest;
#endif
TEST_F(DisplayControllerTest, MAYBE_SecondaryDisplayLayout) {
+ TestObserver observer;
UpdateDisplay("500x500,400x400");
+ EXPECT_EQ(2, observer.CountAndReset()); // resize and add
gfx::Display* secondary_display =
aura::Env::GetInstance()->display_manager()->GetDisplayAt(1);
gfx::Insets insets(5, 5, 5, 5);
@@ -62,26 +90,32 @@ TEST_F(DisplayControllerTest, MAYBE_SecondaryDisplayLayout) {
// Layout the secondary display to the bottom of the primary.
SetSecondaryDisplayLayout(DisplayLayout::BOTTOM);
+ EXPECT_EQ(1, observer.CountAndReset());
EXPECT_EQ("0,0 500x500", GetPrimaryDisplay().bounds().ToString());
EXPECT_EQ("0,500 400x400", GetSecondaryDisplay().bounds().ToString());
EXPECT_EQ("5,505 390x390", GetSecondaryDisplay().work_area().ToString());
// Layout the secondary display to the left of the primary.
SetSecondaryDisplayLayout(DisplayLayout::LEFT);
+ EXPECT_EQ(1, observer.CountAndReset());
EXPECT_EQ("0,0 500x500", GetPrimaryDisplay().bounds().ToString());
EXPECT_EQ("-400,0 400x400", GetSecondaryDisplay().bounds().ToString());
EXPECT_EQ("-395,5 390x390", GetSecondaryDisplay().work_area().ToString());
// Layout the secondary display to the top of the primary.
SetSecondaryDisplayLayout(DisplayLayout::TOP);
+ EXPECT_EQ(1, observer.CountAndReset());
EXPECT_EQ("0,0 500x500", GetPrimaryDisplay().bounds().ToString());
EXPECT_EQ("0,-400 400x400", GetSecondaryDisplay().bounds().ToString());
EXPECT_EQ("5,-395 390x390", GetSecondaryDisplay().work_area().ToString());
}
TEST_F(DisplayControllerTest, MAYBE_BoundsUpdated) {
+ TestObserver observer;
SetSecondaryDisplayLayout(DisplayLayout::BOTTOM);
- UpdateDisplay("200x200,300x300");
+ UpdateDisplay("200x200,300x300"); // layout, resize and add.
+ EXPECT_EQ(3, observer.CountAndReset());
+
gfx::Display* secondary_display =
aura::Env::GetInstance()->display_manager()->GetDisplayAt(1);
gfx::Insets insets(5, 5, 5, 5);
@@ -92,20 +126,24 @@ TEST_F(DisplayControllerTest, MAYBE_BoundsUpdated) {
EXPECT_EQ("5,205 290x290", GetSecondaryDisplay().work_area().ToString());
UpdateDisplay("400x400,200x200");
+ EXPECT_EQ(2, observer.CountAndReset()); // two resizes
EXPECT_EQ("0,0 400x400", GetPrimaryDisplay().bounds().ToString());
EXPECT_EQ("0,400 200x200", GetSecondaryDisplay().bounds().ToString());
EXPECT_EQ("5,405 190x190", GetSecondaryDisplay().work_area().ToString());
UpdateDisplay("400x400,300x300");
+ EXPECT_EQ(1, observer.CountAndReset());
EXPECT_EQ("0,0 400x400", GetPrimaryDisplay().bounds().ToString());
EXPECT_EQ("0,400 300x300", GetSecondaryDisplay().bounds().ToString());
EXPECT_EQ("5,405 290x290", GetSecondaryDisplay().work_area().ToString());
UpdateDisplay("400x400");
+ EXPECT_EQ(1, observer.CountAndReset());
EXPECT_EQ("0,0 400x400", GetPrimaryDisplay().bounds().ToString());
EXPECT_EQ(1, gfx::Screen::GetNumDisplays());
UpdateDisplay("500x500,700x700");
+ EXPECT_EQ(2, observer.CountAndReset());
ASSERT_EQ(2, gfx::Screen::GetNumDisplays());
EXPECT_EQ("0,0 500x500", GetPrimaryDisplay().bounds().ToString());
EXPECT_EQ("0,500 700x700", GetSecondaryDisplay().bounds().ToString());
« no previous file with comments | « ash/display/display_controller.cc ('k') | ash/display/multi_display_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698