OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/maximize_mode/maximize_mode_window_manager.h" | 5 #include "ash/wm/maximize_mode/maximize_mode_window_manager.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "ash/root_window_controller.h" | 9 #include "ash/root_window_controller.h" |
10 #include "ash/screen_util.h" | 10 #include "ash/screen_util.h" |
11 #include "ash/shelf/shelf_layout_manager.h" | 11 #include "ash/shelf/shelf_layout_manager.h" |
12 #include "ash/shell.h" | 12 #include "ash/shell.h" |
13 #include "ash/switchable_windows.h" | 13 #include "ash/switchable_windows.h" |
14 #include "ash/test/ash_test_base.h" | 14 #include "ash/test/ash_test_base.h" |
15 #include "ash/test/shell_test_api.h" | 15 #include "ash/test/shell_test_api.h" |
16 #include "ash/wm/maximize_mode/maximize_mode_controller.h" | 16 #include "ash/wm/maximize_mode/maximize_mode_controller.h" |
17 #include "ash/wm/mru_window_tracker.h" | 17 #include "ash/wm/mru_window_tracker.h" |
18 #include "ash/wm/overview/window_selector_controller.h" | 18 #include "ash/wm/overview/window_selector_controller.h" |
19 #include "ash/wm/window_properties.h" | 19 #include "ash/wm/window_properties.h" |
20 #include "ash/wm/window_state.h" | 20 #include "ash/wm/window_state.h" |
21 #include "ash/wm/window_util.h" | 21 #include "ash/wm/window_util.h" |
22 #include "ash/wm/wm_event.h" | 22 #include "ash/wm/wm_event.h" |
23 #include "base/strings/stringprintf.h" | 23 #include "base/strings/stringprintf.h" |
24 #include "base/strings/utf_string_conversions.h" | 24 #include "base/strings/utf_string_conversions.h" |
25 #include "base/values.h" | 25 #include "base/values.h" |
26 #include "ui/aura/client/aura_constants.h" | 26 #include "ui/aura/client/aura_constants.h" |
27 #include "ui/aura/test/event_generator.h" | |
28 #include "ui/aura/test/test_window_delegate.h" | 27 #include "ui/aura/test/test_window_delegate.h" |
29 #include "ui/aura/test/test_windows.h" | 28 #include "ui/aura/test/test_windows.h" |
30 #include "ui/aura/window.h" | 29 #include "ui/aura/window.h" |
31 #include "ui/base/hit_test.h" | 30 #include "ui/base/hit_test.h" |
| 31 #include "ui/events/test/event_generator.h" |
32 | 32 |
33 namespace ash { | 33 namespace ash { |
34 | 34 |
35 // TODO(skuhne): These tests are failing on Widows because maximized is there | 35 // TODO(skuhne): These tests are failing on Widows because maximized is there |
36 // differently handled. Fix this! | 36 // differently handled. Fix this! |
37 #if !defined(OS_WIN) | 37 #if !defined(OS_WIN) |
38 | 38 |
39 class MaximizeModeWindowManagerTest : public test::AshTestBase { | 39 class MaximizeModeWindowManagerTest : public test::AshTestBase { |
40 public: | 40 public: |
41 MaximizeModeWindowManagerTest() {} | 41 MaximizeModeWindowManagerTest() {} |
(...skipping 896 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
938 | 938 |
939 // Check that non maximizable windows cannot be dragged by the user. | 939 // Check that non maximizable windows cannot be dragged by the user. |
940 TEST_F(MaximizeModeWindowManagerTest, TryToDesktopSizeDragUnmaximizable) { | 940 TEST_F(MaximizeModeWindowManagerTest, TryToDesktopSizeDragUnmaximizable) { |
941 gfx::Rect rect(10, 10, 100, 100); | 941 gfx::Rect rect(10, 10, 100, 100); |
942 scoped_ptr<aura::Window> window( | 942 scoped_ptr<aura::Window> window( |
943 CreateFixedSizeNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); | 943 CreateFixedSizeNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); |
944 EXPECT_EQ(rect.ToString(), window->bounds().ToString()); | 944 EXPECT_EQ(rect.ToString(), window->bounds().ToString()); |
945 | 945 |
946 // 1. Move the mouse over the caption and check that dragging the window does | 946 // 1. Move the mouse over the caption and check that dragging the window does |
947 // change the location. | 947 // change the location. |
948 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); | 948 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
949 generator.MoveMouseTo(gfx::Point(rect.x() + 2, rect.y() + 2)); | 949 generator.MoveMouseTo(gfx::Point(rect.x() + 2, rect.y() + 2)); |
950 generator.PressLeftButton(); | 950 generator.PressLeftButton(); |
951 generator.MoveMouseBy(10, 5); | 951 generator.MoveMouseBy(10, 5); |
952 RunAllPendingInMessageLoop(); | 952 RunAllPendingInMessageLoop(); |
953 generator.ReleaseLeftButton(); | 953 generator.ReleaseLeftButton(); |
954 gfx::Point first_dragged_origin = window->bounds().origin(); | 954 gfx::Point first_dragged_origin = window->bounds().origin(); |
955 EXPECT_EQ(rect.x() + 10, first_dragged_origin.x()); | 955 EXPECT_EQ(rect.x() + 10, first_dragged_origin.x()); |
956 EXPECT_EQ(rect.y() + 5, first_dragged_origin.y()); | 956 EXPECT_EQ(rect.y() + 5, first_dragged_origin.y()); |
957 | 957 |
958 // 2. Check that turning on the manager will stop allowing the window from | 958 // 2. Check that turning on the manager will stop allowing the window from |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1026 | 1026 |
1027 // Fullscreen both windows. | 1027 // Fullscreen both windows. |
1028 wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN); | 1028 wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN); |
1029 background_window_state->OnWMEvent(&event); | 1029 background_window_state->OnWMEvent(&event); |
1030 foreground_window_state->OnWMEvent(&event); | 1030 foreground_window_state->OnWMEvent(&event); |
1031 EXPECT_TRUE(background_window_state->IsFullscreen()); | 1031 EXPECT_TRUE(background_window_state->IsFullscreen()); |
1032 EXPECT_TRUE(foreground_window_state->IsFullscreen()); | 1032 EXPECT_TRUE(foreground_window_state->IsFullscreen()); |
1033 EXPECT_EQ(foreground_window.get(), wm::GetActiveWindow()); | 1033 EXPECT_EQ(foreground_window.get(), wm::GetActiveWindow()); |
1034 | 1034 |
1035 // Do an edge swipe top into screen. | 1035 // Do an edge swipe top into screen. |
1036 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); | 1036 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
1037 generator.GestureScrollSequence(gfx::Point(50, 0), | 1037 generator.GestureScrollSequence(gfx::Point(50, 0), |
1038 gfx::Point(50, 100), | 1038 gfx::Point(50, 100), |
1039 base::TimeDelta::FromMilliseconds(20), | 1039 base::TimeDelta::FromMilliseconds(20), |
1040 10); | 1040 10); |
1041 | 1041 |
1042 EXPECT_FALSE(foreground_window_state->IsFullscreen()); | 1042 EXPECT_FALSE(foreground_window_state->IsFullscreen()); |
1043 EXPECT_TRUE(background_window_state->IsFullscreen()); | 1043 EXPECT_TRUE(background_window_state->IsFullscreen()); |
1044 | 1044 |
1045 // Do a second edge swipe top into screen. | 1045 // Do a second edge swipe top into screen. |
1046 generator.GestureScrollSequence(gfx::Point(50, 0), | 1046 generator.GestureScrollSequence(gfx::Point(50, 0), |
(...skipping 23 matching lines...) Expand all Loading... |
1070 | 1070 |
1071 // Fullscreen both windows. | 1071 // Fullscreen both windows. |
1072 wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN); | 1072 wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN); |
1073 background_window_state->OnWMEvent(&event); | 1073 background_window_state->OnWMEvent(&event); |
1074 foreground_window_state->OnWMEvent(&event); | 1074 foreground_window_state->OnWMEvent(&event); |
1075 EXPECT_TRUE(background_window_state->IsFullscreen()); | 1075 EXPECT_TRUE(background_window_state->IsFullscreen()); |
1076 EXPECT_TRUE(foreground_window_state->IsFullscreen()); | 1076 EXPECT_TRUE(foreground_window_state->IsFullscreen()); |
1077 EXPECT_EQ(foreground_window.get(), wm::GetActiveWindow()); | 1077 EXPECT_EQ(foreground_window.get(), wm::GetActiveWindow()); |
1078 | 1078 |
1079 // Do an edge swipe bottom into screen. | 1079 // Do an edge swipe bottom into screen. |
1080 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); | 1080 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
1081 int y = Shell::GetPrimaryRootWindow()->bounds().bottom(); | 1081 int y = Shell::GetPrimaryRootWindow()->bounds().bottom(); |
1082 generator.GestureScrollSequence(gfx::Point(50, y), | 1082 generator.GestureScrollSequence(gfx::Point(50, y), |
1083 gfx::Point(50, y - 100), | 1083 gfx::Point(50, y - 100), |
1084 base::TimeDelta::FromMilliseconds(20), | 1084 base::TimeDelta::FromMilliseconds(20), |
1085 10); | 1085 10); |
1086 | 1086 |
1087 EXPECT_FALSE(foreground_window_state->IsFullscreen()); | 1087 EXPECT_FALSE(foreground_window_state->IsFullscreen()); |
1088 EXPECT_TRUE(background_window_state->IsFullscreen()); | 1088 EXPECT_TRUE(background_window_state->IsFullscreen()); |
1089 | 1089 |
1090 DestroyMaximizeModeWindowManager(); | 1090 DestroyMaximizeModeWindowManager(); |
(...skipping 15 matching lines...) Expand all Loading... |
1106 | 1106 |
1107 // Fullscreen both windows. | 1107 // Fullscreen both windows. |
1108 wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN); | 1108 wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN); |
1109 background_window_state->OnWMEvent(&event); | 1109 background_window_state->OnWMEvent(&event); |
1110 foreground_window_state->OnWMEvent(&event); | 1110 foreground_window_state->OnWMEvent(&event); |
1111 EXPECT_TRUE(background_window_state->IsFullscreen()); | 1111 EXPECT_TRUE(background_window_state->IsFullscreen()); |
1112 EXPECT_TRUE(foreground_window_state->IsFullscreen()); | 1112 EXPECT_TRUE(foreground_window_state->IsFullscreen()); |
1113 EXPECT_EQ(foreground_window.get(), wm::GetActiveWindow()); | 1113 EXPECT_EQ(foreground_window.get(), wm::GetActiveWindow()); |
1114 | 1114 |
1115 // Touch tap on the top edge. | 1115 // Touch tap on the top edge. |
1116 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); | 1116 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
1117 generator.GestureTapAt(gfx::Point(100, 0)); | 1117 generator.GestureTapAt(gfx::Point(100, 0)); |
1118 EXPECT_FALSE(foreground_window_state->IsFullscreen()); | 1118 EXPECT_FALSE(foreground_window_state->IsFullscreen()); |
1119 EXPECT_TRUE(background_window_state->IsFullscreen()); | 1119 EXPECT_TRUE(background_window_state->IsFullscreen()); |
1120 | 1120 |
1121 // Try the same again and see that nothing changes. | 1121 // Try the same again and see that nothing changes. |
1122 generator.GestureTapAt(gfx::Point(100, 0)); | 1122 generator.GestureTapAt(gfx::Point(100, 0)); |
1123 EXPECT_FALSE(foreground_window_state->IsFullscreen()); | 1123 EXPECT_FALSE(foreground_window_state->IsFullscreen()); |
1124 EXPECT_TRUE(background_window_state->IsFullscreen()); | 1124 EXPECT_TRUE(background_window_state->IsFullscreen()); |
1125 | 1125 |
1126 DestroyMaximizeModeWindowManager(); | 1126 DestroyMaximizeModeWindowManager(); |
(...skipping 15 matching lines...) Expand all Loading... |
1142 | 1142 |
1143 // Fullscreen both windows. | 1143 // Fullscreen both windows. |
1144 wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN); | 1144 wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN); |
1145 background_window_state->OnWMEvent(&event); | 1145 background_window_state->OnWMEvent(&event); |
1146 foreground_window_state->OnWMEvent(&event); | 1146 foreground_window_state->OnWMEvent(&event); |
1147 EXPECT_TRUE(background_window_state->IsFullscreen()); | 1147 EXPECT_TRUE(background_window_state->IsFullscreen()); |
1148 EXPECT_TRUE(foreground_window_state->IsFullscreen()); | 1148 EXPECT_TRUE(foreground_window_state->IsFullscreen()); |
1149 EXPECT_EQ(foreground_window.get(), wm::GetActiveWindow()); | 1149 EXPECT_EQ(foreground_window.get(), wm::GetActiveWindow()); |
1150 | 1150 |
1151 // Touch tap on the bottom edge. | 1151 // Touch tap on the bottom edge. |
1152 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); | 1152 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
1153 generator.GestureTapAt( | 1153 generator.GestureTapAt( |
1154 gfx::Point(100, Shell::GetPrimaryRootWindow()->bounds().bottom() - 1)); | 1154 gfx::Point(100, Shell::GetPrimaryRootWindow()->bounds().bottom() - 1)); |
1155 EXPECT_FALSE(foreground_window_state->IsFullscreen()); | 1155 EXPECT_FALSE(foreground_window_state->IsFullscreen()); |
1156 EXPECT_TRUE(background_window_state->IsFullscreen()); | 1156 EXPECT_TRUE(background_window_state->IsFullscreen()); |
1157 | 1157 |
1158 // Try the same again and see that nothing changes. | 1158 // Try the same again and see that nothing changes. |
1159 generator.GestureTapAt( | 1159 generator.GestureTapAt( |
1160 gfx::Point(100, Shell::GetPrimaryRootWindow()->bounds().bottom() - 1)); | 1160 gfx::Point(100, Shell::GetPrimaryRootWindow()->bounds().bottom() - 1)); |
1161 EXPECT_FALSE(foreground_window_state->IsFullscreen()); | 1161 EXPECT_FALSE(foreground_window_state->IsFullscreen()); |
1162 EXPECT_TRUE(background_window_state->IsFullscreen()); | 1162 EXPECT_TRUE(background_window_state->IsFullscreen()); |
(...skipping 13 matching lines...) Expand all Loading... |
1176 // Fullscreen the window. | 1176 // Fullscreen the window. |
1177 wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN); | 1177 wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN); |
1178 window_state->OnWMEvent(&event); | 1178 window_state->OnWMEvent(&event); |
1179 EXPECT_TRUE(window_state->IsFullscreen()); | 1179 EXPECT_TRUE(window_state->IsFullscreen()); |
1180 EXPECT_FALSE(window_state->in_immersive_fullscreen()); | 1180 EXPECT_FALSE(window_state->in_immersive_fullscreen()); |
1181 EXPECT_EQ(window.get(), wm::GetActiveWindow()); | 1181 EXPECT_EQ(window.get(), wm::GetActiveWindow()); |
1182 | 1182 |
1183 window_state->set_in_immersive_fullscreen(true); | 1183 window_state->set_in_immersive_fullscreen(true); |
1184 | 1184 |
1185 // Do an edge swipe top into screen. | 1185 // Do an edge swipe top into screen. |
1186 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); | 1186 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
1187 generator.GestureScrollSequence(gfx::Point(50, 0), | 1187 generator.GestureScrollSequence(gfx::Point(50, 0), |
1188 gfx::Point(50, 100), | 1188 gfx::Point(50, 100), |
1189 base::TimeDelta::FromMilliseconds(20), | 1189 base::TimeDelta::FromMilliseconds(20), |
1190 10); | 1190 10); |
1191 | 1191 |
1192 // It should have not exited full screen or immersive mode. | 1192 // It should have not exited full screen or immersive mode. |
1193 EXPECT_TRUE(window_state->IsFullscreen()); | 1193 EXPECT_TRUE(window_state->IsFullscreen()); |
1194 EXPECT_TRUE(window_state->in_immersive_fullscreen()); | 1194 EXPECT_TRUE(window_state->in_immersive_fullscreen()); |
1195 | 1195 |
1196 DestroyMaximizeModeWindowManager(); | 1196 DestroyMaximizeModeWindowManager(); |
(...skipping 11 matching lines...) Expand all Loading... |
1208 // Fullscreen the window. | 1208 // Fullscreen the window. |
1209 wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN); | 1209 wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN); |
1210 window_state->OnWMEvent(&event); | 1210 window_state->OnWMEvent(&event); |
1211 EXPECT_TRUE(window_state->IsFullscreen()); | 1211 EXPECT_TRUE(window_state->IsFullscreen()); |
1212 EXPECT_FALSE(window_state->in_immersive_fullscreen()); | 1212 EXPECT_FALSE(window_state->in_immersive_fullscreen()); |
1213 EXPECT_EQ(window.get(), wm::GetActiveWindow()); | 1213 EXPECT_EQ(window.get(), wm::GetActiveWindow()); |
1214 window_state->set_in_immersive_fullscreen(true); | 1214 window_state->set_in_immersive_fullscreen(true); |
1215 EXPECT_TRUE(window_state->in_immersive_fullscreen()); | 1215 EXPECT_TRUE(window_state->in_immersive_fullscreen()); |
1216 | 1216 |
1217 // Do an edge swipe bottom into screen. | 1217 // Do an edge swipe bottom into screen. |
1218 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); | 1218 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
1219 int y = Shell::GetPrimaryRootWindow()->bounds().bottom(); | 1219 int y = Shell::GetPrimaryRootWindow()->bounds().bottom(); |
1220 generator.GestureScrollSequence(gfx::Point(50, y), | 1220 generator.GestureScrollSequence(gfx::Point(50, y), |
1221 gfx::Point(50, y - 100), | 1221 gfx::Point(50, y - 100), |
1222 base::TimeDelta::FromMilliseconds(20), | 1222 base::TimeDelta::FromMilliseconds(20), |
1223 10); | 1223 10); |
1224 | 1224 |
1225 // The window should still be full screen and immersive. | 1225 // The window should still be full screen and immersive. |
1226 EXPECT_TRUE(window_state->IsFullscreen()); | 1226 EXPECT_TRUE(window_state->IsFullscreen()); |
1227 EXPECT_TRUE(window_state->in_immersive_fullscreen()); | 1227 EXPECT_TRUE(window_state->in_immersive_fullscreen()); |
1228 | 1228 |
1229 DestroyMaximizeModeWindowManager(); | 1229 DestroyMaximizeModeWindowManager(); |
1230 } | 1230 } |
1231 | 1231 |
1232 #endif // OS_WIN | 1232 #endif // OS_WIN |
1233 | 1233 |
1234 } // namespace ash | 1234 } // namespace ash |
OLD | NEW |