OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "ash/wm/workspace_controller.h" | 5 #include "ash/wm/workspace_controller.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 | 8 |
9 #include "ash/ash_switches.h" | 9 #include "ash/ash_switches.h" |
10 #include "ash/root_window_controller.h" | 10 #include "ash/root_window_controller.h" |
(...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
844 window1->Show(); | 844 window1->Show(); |
845 // |window1| should be centered and |window4| untouched. | 845 // |window1| should be centered and |window4| untouched. |
846 EXPECT_EQ( | 846 EXPECT_EQ( |
847 base::IntToString( | 847 base::IntToString( |
848 (desktop_area.width() - window1->bounds().width()) / 2) + | 848 (desktop_area.width() - window1->bounds().width()) / 2) + |
849 ",32 640x320", window1->bounds().ToString()); | 849 ",32 640x320", window1->bounds().ToString()); |
850 EXPECT_EQ("32,48 256x512", window4->bounds().ToString()); | 850 EXPECT_EQ("32,48 256x512", window4->bounds().ToString()); |
851 | 851 |
852 // Test4: A single manageable window should get centered. | 852 // Test4: A single manageable window should get centered. |
853 window4.reset(); | 853 window4.reset(); |
854 window1_state->set_bounds_changed_by_user(false); | 854 window1_state->SetBoundsChangedByUser(false); |
855 // Trigger the auto window placement function by showing (and hiding) it. | 855 // Trigger the auto window placement function by showing (and hiding) it. |
856 window1->Hide(); | 856 window1->Hide(); |
857 window1->Show(); | 857 window1->Show(); |
858 // |window1| should be centered. | 858 // |window1| should be centered. |
859 EXPECT_EQ( | 859 EXPECT_EQ( |
860 base::IntToString( | 860 base::IntToString( |
861 (desktop_area.width() - window1->bounds().width()) / 2) + | 861 (desktop_area.width() - window1->bounds().width()) / 2) + |
862 ",32 640x320", window1->bounds().ToString()); | 862 ",32 640x320", window1->bounds().ToString()); |
863 } | 863 } |
864 | 864 |
865 // Test the proper usage of user window movement interaction. | 865 // Test the proper usage of user window movement interaction. |
866 TEST_F(WorkspaceControllerTest, TestUserMovedWindowRepositioning) { | 866 TEST_F(WorkspaceControllerTest, TestUserMovedWindowRepositioning) { |
867 scoped_ptr<aura::Window> window1(CreateTestWindowInShellWithId(0)); | 867 scoped_ptr<aura::Window> window1(CreateTestWindowInShellWithId(0)); |
868 window1->SetBounds(gfx::Rect(16, 32, 640, 320)); | 868 window1->SetBounds(gfx::Rect(16, 32, 640, 320)); |
869 gfx::Rect desktop_area = window1->parent()->bounds(); | 869 gfx::Rect desktop_area = window1->parent()->bounds(); |
870 scoped_ptr<aura::Window> window2(CreateTestWindowInShellWithId(1)); | 870 scoped_ptr<aura::Window> window2(CreateTestWindowInShellWithId(1)); |
871 window2->SetBounds(gfx::Rect(32, 48, 256, 512)); | 871 window2->SetBounds(gfx::Rect(32, 48, 256, 512)); |
872 window1->Hide(); | 872 window1->Hide(); |
873 window2->Hide(); | 873 window2->Hide(); |
874 wm::WindowState* window1_state = wm::GetWindowState(window1.get()); | 874 wm::WindowState* window1_state = wm::GetWindowState(window1.get()); |
875 wm::WindowState* window2_state = wm::GetWindowState(window2.get()); | 875 wm::WindowState* window2_state = wm::GetWindowState(window2.get()); |
876 | 876 |
877 window1_state->set_window_position_managed(true); | 877 window1_state->set_window_position_managed(true); |
878 window2_state->set_window_position_managed(true); | 878 window2_state->set_window_position_managed(true); |
879 EXPECT_FALSE(window1_state->bounds_changed_by_user()); | 879 EXPECT_FALSE(window1_state->bounds_changed_by_user()); |
880 EXPECT_FALSE(window2_state->bounds_changed_by_user()); | 880 EXPECT_FALSE(window2_state->bounds_changed_by_user()); |
881 | 881 |
882 // Check that the current location gets preserved if the user has | 882 // Check that the current location gets preserved if the user has |
883 // positioned it previously. | 883 // positioned it previously. |
884 window1_state->set_bounds_changed_by_user(true); | 884 window1_state->SetBoundsChangedByUser(true); |
885 window1->Show(); | 885 window1->Show(); |
886 EXPECT_EQ("16,32 640x320", window1->bounds().ToString()); | 886 EXPECT_EQ("16,32 640x320", window1->bounds().ToString()); |
887 // Flag should be still set. | 887 // Flag should be still set. |
888 EXPECT_TRUE(window1_state->bounds_changed_by_user()); | 888 EXPECT_TRUE(window1_state->bounds_changed_by_user()); |
889 EXPECT_FALSE(window2_state->bounds_changed_by_user()); | 889 EXPECT_FALSE(window2_state->bounds_changed_by_user()); |
890 | 890 |
891 // Turn on the second window and make sure that both windows are now | 891 // Turn on the second window and make sure that both windows are now |
892 // positionable again (user movement cleared). | 892 // positionable again (user movement cleared). |
893 window2->Show(); | 893 window2->Show(); |
894 | 894 |
895 // |window1| should be flush left and |window2| flush right. | 895 // |window1| should be flush left and |window2| flush right. |
896 EXPECT_EQ("0,32 640x320", window1->bounds().ToString()); | 896 EXPECT_EQ("0,32 640x320", window1->bounds().ToString()); |
897 EXPECT_EQ( | 897 EXPECT_EQ( |
898 base::IntToString(desktop_area.width() - window2->bounds().width()) + | 898 base::IntToString(desktop_area.width() - window2->bounds().width()) + |
899 ",48 256x512", window2->bounds().ToString()); | 899 ",48 256x512", window2->bounds().ToString()); |
900 // FLag should now be reset. | 900 // FLag should now be reset. |
901 EXPECT_FALSE(window1_state->bounds_changed_by_user()); | 901 EXPECT_FALSE(window1_state->bounds_changed_by_user()); |
902 EXPECT_FALSE(window2_state->bounds_changed_by_user()); | 902 EXPECT_FALSE(window2_state->bounds_changed_by_user()); |
903 | 903 |
904 // Going back to one shown window should keep the state. | 904 // Going back to one shown window should keep the state. |
905 window1_state->set_bounds_changed_by_user(true); | 905 window1_state->SetBoundsChangedByUser(true); |
906 window2->Hide(); | 906 window2->Hide(); |
907 EXPECT_EQ("0,32 640x320", window1->bounds().ToString()); | 907 EXPECT_EQ("0,32 640x320", window1->bounds().ToString()); |
908 EXPECT_TRUE(window1_state->bounds_changed_by_user()); | 908 EXPECT_TRUE(window1_state->bounds_changed_by_user()); |
909 } | 909 } |
910 | 910 |
911 // Test if the single window will be restored at original position. | 911 // Test if the single window will be restored at original position. |
912 TEST_F(WorkspaceControllerTest, TestSingleWindowsRestoredBounds) { | 912 TEST_F(WorkspaceControllerTest, TestSingleWindowsRestoredBounds) { |
913 scoped_ptr<aura::Window> window1( | 913 scoped_ptr<aura::Window> window1( |
914 CreateTestWindowInShellWithBounds(gfx::Rect(100, 100, 100, 100))); | 914 CreateTestWindowInShellWithBounds(gfx::Rect(100, 100, 100, 100))); |
915 scoped_ptr<aura::Window> window2( | 915 scoped_ptr<aura::Window> window2( |
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1384 scoped_ptr<Window> maximized_window(CreateTestWindow()); | 1384 scoped_ptr<Window> maximized_window(CreateTestWindow()); |
1385 maximized_window->SetProperty( | 1385 maximized_window->SetProperty( |
1386 aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 1386 aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
1387 maximized_window->Show(); | 1387 maximized_window->Show(); |
1388 wm::ActivateWindow(maximized_window.get()); | 1388 wm::ActivateWindow(maximized_window.get()); |
1389 EXPECT_TRUE(maximized_window->IsVisible()); | 1389 EXPECT_TRUE(maximized_window->IsVisible()); |
1390 } | 1390 } |
1391 | 1391 |
1392 } // namespace internal | 1392 } // namespace internal |
1393 } // namespace ash | 1393 } // namespace ash |
OLD | NEW |