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

Unified Diff: ash/wm/workspace/workspace_manager2_unittest.cc

Issue 11343028: Revert 164652 - speculative revert - this change may have caused print dialog test failures on XP. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 2 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/wm/workspace/workspace_manager2.cc ('k') | ash/wm/workspace/workspace_window_resizer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/wm/workspace/workspace_manager2_unittest.cc
===================================================================
--- ash/wm/workspace/workspace_manager2_unittest.cc (revision 164764)
+++ ash/wm/workspace/workspace_manager2_unittest.cc (working copy)
@@ -1107,290 +1107,5 @@
ASSERT_EQ("1 M1 active=1", StateString());
}
-// Test the basic auto placement of one and or two windows in a "simulated
-// session" of sequential window operations.
-TEST_F(WorkspaceManager2Test, BasicAutoPlacing) {
- // Test 1: In case there is no manageable window, no window should shift.
-
- scoped_ptr<aura::Window> window1(
- aura::test::CreateTestWindowWithId(0, NULL));
- window1->SetBounds(gfx::Rect(16, 32, 640, 320));
- gfx::Rect desktop_area = window1->parent()->bounds();
-
- scoped_ptr<aura::Window> window2(
- aura::test::CreateTestWindowWithId(1, NULL));
- // Trigger the auto window placement function by making it visible.
- // Note that the bounds are getting changed while it is invisible.
- window2->Hide();
- window2->SetBounds(gfx::Rect(32, 48, 256, 512));
- window2->Show();
-
- // Check the initial position of the windows is unchanged.
- EXPECT_EQ("16,32 640x320", window1->bounds().ToString());
- EXPECT_EQ("32,48 256x512", window2->bounds().ToString());
-
- // Remove the second window and make sure that the first window
- // does NOT get centered.
- window2.reset();
- EXPECT_EQ("16,32 640x320", window1->bounds().ToString());
-
- // Test 2: Set up two managed windows and check their auto positioning.
- ash::wm::SetWindowPositionManaged(window1.get(), true);
- scoped_ptr<aura::Window> window3(
- aura::test::CreateTestWindowWithId(2, NULL));
- ash::wm::SetWindowPositionManaged(window3.get(), true);
- // To avoid any auto window manager changes due to SetBounds, the window
- // gets first hidden and then shown again.
- window3->Hide();
- window3->SetBounds(gfx::Rect(32, 48, 256, 512));
- window3->Show();
- // |window1| should be flush right and |window3| flush left.
- EXPECT_EQ("0,32 640x320", window1->bounds().ToString());
- EXPECT_EQ(base::IntToString(
- desktop_area.width() - window3->bounds().width()) +
- ",48 256x512", window3->bounds().ToString());
-
- // After removing |window3|, |window1| should be centered again.
- window3.reset();
- EXPECT_EQ(
- base::IntToString(
- (desktop_area.width() - window1->bounds().width()) / 2) +
- ",32 640x320", window1->bounds().ToString());
-
- // Test 3: Set up a manageable and a non manageable window and check
- // positioning.
- scoped_ptr<aura::Window> window4(
- aura::test::CreateTestWindowWithId(3, NULL));
- // To avoid any auto window manager changes due to SetBounds, the window
- // gets first hidden and then shown again.
- window1->Hide();
- window1->SetBounds(gfx::Rect(16, 32, 640, 320));
- window4->SetBounds(gfx::Rect(32, 48, 256, 512));
- window1->Show();
- // |window1| should be centered and |window4| untouched.
- EXPECT_EQ(
- base::IntToString(
- (desktop_area.width() - window1->bounds().width()) / 2) +
- ",32 640x320", window1->bounds().ToString());
- EXPECT_EQ("32,48 256x512", window4->bounds().ToString());
-
- // Test4: A single manageable window should get centered.
- window4.reset();
- ash::wm::SetUserHasChangedWindowPositionOrSize(window1.get(), false);
- // Trigger the auto window placement function by showing (and hiding) it.
- window1->Hide();
- window1->Show();
- // |window1| should be centered.
- EXPECT_EQ(
- base::IntToString(
- (desktop_area.width() - window1->bounds().width()) / 2) +
- ",32 640x320", window1->bounds().ToString());
-}
-
-// Test the proper usage of user window movement interaction.
-TEST_F(WorkspaceManager2Test, TestUserMovedWindowRepositioning) {
- scoped_ptr<aura::Window> window1(
- aura::test::CreateTestWindowWithId(0, NULL));
- window1->SetBounds(gfx::Rect(16, 32, 640, 320));
- gfx::Rect desktop_area = window1->parent()->bounds();
- scoped_ptr<aura::Window> window2(
- aura::test::CreateTestWindowWithId(1, NULL));
- window2->SetBounds(gfx::Rect(32, 48, 256, 512));
- window1->Hide();
- window2->Hide();
- ash::wm::SetWindowPositionManaged(window1.get(), true);
- ash::wm::SetWindowPositionManaged(window2.get(), true);
- EXPECT_FALSE(ash::wm::HasUserChangedWindowPositionOrSize(window1.get()));
- EXPECT_FALSE(ash::wm::HasUserChangedWindowPositionOrSize(window2.get()));
-
- // Check that the current location gets preserved if the user has
- // positioned it previously.
- ash::wm::SetUserHasChangedWindowPositionOrSize(window1.get(), true);
- window1->Show();
- EXPECT_EQ("16,32 640x320", window1->bounds().ToString());
- // Flag should be still set.
- EXPECT_TRUE(ash::wm::HasUserChangedWindowPositionOrSize(window1.get()));
- EXPECT_FALSE(ash::wm::HasUserChangedWindowPositionOrSize(window2.get()));
-
- // Turn on the second window and make sure that both windows are now
- // positionable again (user movement cleared).
- window2->Show();
-
- // |window1| should be flush right and |window3| flush left.
- EXPECT_EQ(base::IntToString(
- desktop_area.width() - window1->bounds().width()) +
- ",32 640x320", window1->bounds().ToString());
- EXPECT_EQ("0,48 256x512", window2->bounds().ToString());
- // FLag should now be reset.
- EXPECT_FALSE(ash::wm::HasUserChangedWindowPositionOrSize(window1.get()));
- EXPECT_FALSE(ash::wm::HasUserChangedWindowPositionOrSize(window1.get()));
-
- // Going back to one shown window should keep the state.
- ash::wm::SetUserHasChangedWindowPositionOrSize(window1.get(), true);
- window2->Hide();
- EXPECT_EQ(base::IntToString(
- desktop_area.width() - window1->bounds().width()) +
- ",32 640x320", window1->bounds().ToString());
- EXPECT_TRUE(ash::wm::HasUserChangedWindowPositionOrSize(window1.get()));
-}
-
-// Test that a window from normal to minimize will repos the remaining.
-TEST_F(WorkspaceManager2Test, ToMinimizeRepositionsRemaining) {
- scoped_ptr<aura::Window> window1(
- aura::test::CreateTestWindowWithId(0, NULL));
- ash::wm::SetWindowPositionManaged(window1.get(), true);
- window1->SetBounds(gfx::Rect(16, 32, 640, 320));
- gfx::Rect desktop_area = window1->parent()->bounds();
-
- scoped_ptr<aura::Window> window2(
- aura::test::CreateTestWindowWithId(1, NULL));
- ash::wm::SetWindowPositionManaged(window2.get(), true);
- window2->SetBounds(gfx::Rect(32, 48, 256, 512));
-
- ash::wm::MinimizeWindow(window1.get());
-
- // |window2| should be centered now.
- EXPECT_TRUE(window2->IsVisible());
- EXPECT_TRUE(ash::wm::IsWindowNormal(window2.get()));
- EXPECT_EQ(base::IntToString(
- (desktop_area.width() - window2->bounds().width()) / 2) +
- ",48 256x512", window2->bounds().ToString());
-
- ash::wm::RestoreWindow(window1.get());
- // |window1| should be flush right and |window3| flush left.
- EXPECT_EQ(base::IntToString(
- desktop_area.width() - window1->bounds().width()) +
- ",32 640x320", window1->bounds().ToString());
- EXPECT_EQ("0,48 256x512", window2->bounds().ToString());
-}
-
-// Test that minimizing an initially maximized window will repos the remaining.
-TEST_F(WorkspaceManager2Test, MaxToMinRepositionsRemaining) {
- scoped_ptr<aura::Window> window1(
- aura::test::CreateTestWindowWithId(0, NULL));
- ash::wm::SetWindowPositionManaged(window1.get(), true);
- gfx::Rect desktop_area = window1->parent()->bounds();
-
- scoped_ptr<aura::Window> window2(
- aura::test::CreateTestWindowWithId(1, NULL));
- ash::wm::SetWindowPositionManaged(window2.get(), true);
- window2->SetBounds(gfx::Rect(32, 48, 256, 512));
-
- ash::wm::MaximizeWindow(window1.get());
- ash::wm::MinimizeWindow(window1.get());
-
- // |window2| should be centered now.
- EXPECT_TRUE(window2->IsVisible());
- EXPECT_TRUE(ash::wm::IsWindowNormal(window2.get()));
- EXPECT_EQ(base::IntToString(
- (desktop_area.width() - window2->bounds().width()) / 2) +
- ",48 256x512", window2->bounds().ToString());
-}
-
-// Test that nomral, maximize, minimizing will repos the remaining.
-TEST_F(WorkspaceManager2Test, NormToMaxToMinRepositionsRemaining) {
- scoped_ptr<aura::Window> window1(
- aura::test::CreateTestWindowWithId(0, NULL));
- window1->SetBounds(gfx::Rect(16, 32, 640, 320));
- ash::wm::SetWindowPositionManaged(window1.get(), true);
- gfx::Rect desktop_area = window1->parent()->bounds();
-
- scoped_ptr<aura::Window> window2(
- aura::test::CreateTestWindowWithId(1, NULL));
- ash::wm::SetWindowPositionManaged(window2.get(), true);
- window2->SetBounds(gfx::Rect(32, 48, 256, 512));
-
- // Trigger the auto window placement function by showing (and hiding) it.
- window1->Hide();
- window1->Show();
-
- // |window1| should be flush right and |window3| flush left.
- EXPECT_EQ(base::IntToString(
- desktop_area.width() - window1->bounds().width()) +
- ",32 640x320", window1->bounds().ToString());
- EXPECT_EQ("0,48 256x512", window2->bounds().ToString());
-
- ash::wm::MaximizeWindow(window1.get());
- ash::wm::MinimizeWindow(window1.get());
-
- // |window2| should be centered now.
- EXPECT_TRUE(window2->IsVisible());
- EXPECT_TRUE(ash::wm::IsWindowNormal(window2.get()));
- EXPECT_EQ(base::IntToString(
- (desktop_area.width() - window2->bounds().width()) / 2) +
- ",48 256x512", window2->bounds().ToString());
-}
-
-// Test that nomral, maximize, normal will repos the remaining.
-TEST_F(WorkspaceManager2Test, NormToMaxToNormRepositionsRemaining) {
- scoped_ptr<aura::Window> window1(
- aura::test::CreateTestWindowWithId(0, NULL));
- window1->SetBounds(gfx::Rect(16, 32, 640, 320));
- ash::wm::SetWindowPositionManaged(window1.get(), true);
- gfx::Rect desktop_area = window1->parent()->bounds();
-
- scoped_ptr<aura::Window> window2(
- aura::test::CreateTestWindowWithId(1, NULL));
- ash::wm::SetWindowPositionManaged(window2.get(), true);
- window2->SetBounds(gfx::Rect(32, 48, 256, 512));
-
- // Trigger the auto window placement function by showing (and hiding) it.
- window1->Hide();
- window1->Show();
-
- // |window1| should be flush right and |window3| flush left.
- EXPECT_EQ(base::IntToString(
- desktop_area.width() - window1->bounds().width()) +
- ",32 640x320", window1->bounds().ToString());
- EXPECT_EQ("0,48 256x512", window2->bounds().ToString());
-
- ash::wm::MaximizeWindow(window1.get());
- ash::wm::RestoreWindow(window1.get());
-
- // |window1| should be flush right and |window2| flush left.
- EXPECT_EQ(base::IntToString(
- desktop_area.width() - window1->bounds().width()) +
- ",32 640x320", window1->bounds().ToString());
- EXPECT_EQ("0,48 256x512", window2->bounds().ToString());
-}
-
-// Test that animations are triggered.
-TEST_F(WorkspaceManager2Test, AnimatedNormToMaxToNormRepositionsRemaining) {
- ui::LayerAnimator::set_disable_animations_for_test(false);
- scoped_ptr<aura::Window> window1(
- aura::test::CreateTestWindowWithId(0, NULL));
- window1->Hide();
- window1->SetBounds(gfx::Rect(16, 32, 640, 320));
- gfx::Rect desktop_area = window1->parent()->bounds();
- scoped_ptr<aura::Window> window2(
- aura::test::CreateTestWindowWithId(1, NULL));
- window2->Hide();
- window2->SetBounds(gfx::Rect(32, 48, 256, 512));
-
- ash::wm::SetWindowPositionManaged(window1.get(), true);
- ash::wm::SetWindowPositionManaged(window2.get(), true);
- // Make sure nothing is animating.
- window1->layer()->GetAnimator()->StopAnimating();
- window2->layer()->GetAnimator()->StopAnimating();
- window2->Show();
-
- // The second window should now animate.
- EXPECT_FALSE(window1->layer()->GetAnimator()->is_animating());
- EXPECT_TRUE(window2->layer()->GetAnimator()->is_animating());
- window2->layer()->GetAnimator()->StopAnimating();
-
- window1->Show();
- EXPECT_TRUE(window1->layer()->GetAnimator()->is_animating());
- EXPECT_TRUE(window2->layer()->GetAnimator()->is_animating());
-
- window1->layer()->GetAnimator()->StopAnimating();
- window2->layer()->GetAnimator()->StopAnimating();
- // |window1| should be flush right and |window2| flush left.
- EXPECT_EQ(base::IntToString(
- desktop_area.width() - window1->bounds().width()) +
- ",32 640x320", window1->bounds().ToString());
- EXPECT_EQ("0,48 256x512", window2->bounds().ToString());
-}
-
} // namespace internal
} // namespace ash
« no previous file with comments | « ash/wm/workspace/workspace_manager2.cc ('k') | ash/wm/workspace/workspace_window_resizer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698