diff options
author | varkha@chromium.org <varkha@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-14 08:12:55 +0000 |
---|---|---|
committer | varkha@chromium.org <varkha@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-14 08:12:55 +0000 |
commit | f68204f7a6e61f278250fb62f3e1138d6b6167c3 (patch) | |
tree | 9bdfe19638e886439e0c4e2d44f131af996567b9 /ash/wm/workspace_controller_unittest.cc | |
parent | d9ba0d15ca7a1f572f6db627af54b4e2625fe7e5 (diff) | |
download | chromium_src-f68204f7a6e61f278250fb62f3e1138d6b6167c3.zip chromium_src-f68204f7a6e61f278250fb62f3e1138d6b6167c3.tar.gz chromium_src-f68204f7a6e61f278250fb62f3e1138d6b6167c3.tar.bz2 |
Moves transient parent together with its children when auto-positioning
BUG=362197
TEST=ash_unittests --gtest_filter=WorkspaceControllerTest.AutoPlacingMovesTransientChild
TEST=Repeat the repro steps in the bug
Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=263507
Review URL: https://codereview.chromium.org/233853002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@263600 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/wm/workspace_controller_unittest.cc')
-rw-r--r-- | ash/wm/workspace_controller_unittest.cc | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/ash/wm/workspace_controller_unittest.cc b/ash/wm/workspace_controller_unittest.cc index 09d1c94..6056a2f 100644 --- a/ash/wm/workspace_controller_unittest.cc +++ b/ash/wm/workspace_controller_unittest.cc @@ -772,6 +772,54 @@ TEST_F(WorkspaceControllerTest, BasicAutoPlacingOnCreate) { } } +// Test that adding a second window shifts both the first window and its +// transient child. +TEST_F(WorkspaceControllerTest, AutoPlacingMovesTransientChild) { + // Create an auto-positioned window. + scoped_ptr<aura::Window> window1(CreateTestWindowInShellWithId(0)); + gfx::Rect desktop_area = window1->parent()->bounds(); + wm::GetWindowState(window1.get())->set_window_position_managed(true); + // Hide and then show |window1| to trigger auto-positioning logic. + window1->Hide(); + window1->SetBounds(gfx::Rect(16, 32, 300, 300)); + window1->Show(); + + // |window1| should be horizontally centered. + int x_window1 = (desktop_area.width() - 300) / 2; + EXPECT_EQ(base::IntToString(x_window1) + ",32 300x300", + window1->bounds().ToString()); + + // Create a |child| window and make it a transient child of |window1|. + scoped_ptr<Window> child(CreateTestWindowUnparented()); + ::wm::AddTransientChild(window1.get(), child.get()); + const int x_child = x_window1 + 50; + child->SetBounds(gfx::Rect(x_child, 20, 200, 200)); + ParentWindowInPrimaryRootWindow(child.get()); + child->Show(); + wm::ActivateWindow(child.get()); + + // The |child| should be where it was created. + EXPECT_EQ(base::IntToString(x_child) + ",20 200x200", + child->bounds().ToString()); + + // Create and show a second window forcing the first window and its child to + // move. + scoped_ptr<aura::Window> window2(CreateTestWindowInShellWithId(1)); + wm::GetWindowState(window2.get())->set_window_position_managed(true); + // Hide and then show |window2| to trigger auto-positioning logic. + window2->Hide(); + window2->SetBounds(gfx::Rect(32, 48, 250, 250)); + window2->Show(); + + // Check that both |window1| and |child| have moved left. + EXPECT_EQ("0,32 300x300", window1->bounds().ToString()); + int x = x_child - x_window1; + EXPECT_EQ(base::IntToString(x) + ",20 200x200", child->bounds().ToString()); + // Check that |window2| has moved right. + x = desktop_area.width() - window2->bounds().width(); + EXPECT_EQ(base::IntToString(x) + ",48 250x250", window2->bounds().ToString()); +} + // Test the basic auto placement of one and or two windows in a "simulated // session" of sequential window operations. TEST_F(WorkspaceControllerTest, BasicAutoPlacingOnShowHide) { |