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 "athena/wm/public/window_manager.h" | 5 #include "athena/wm/public/window_manager.h" |
6 | 6 |
7 #include "athena/screen/public/screen_manager.h" | 7 #include "athena/screen/public/screen_manager.h" |
8 #include "athena/test/athena_test_base.h" | 8 #include "athena/test/athena_test_base.h" |
9 #include "athena/wm/public/window_list_provider.h" | 9 #include "athena/wm/public/window_list_provider.h" |
10 #include "athena/wm/split_view_controller.h" | 10 #include "athena/wm/split_view_controller.h" |
11 #include "athena/wm/test/window_manager_impl_test_api.h" | 11 #include "athena/wm/test/window_manager_impl_test_api.h" |
12 #include "athena/wm/window_manager_impl.h" | 12 #include "athena/wm/window_manager_impl.h" |
13 #include "ui/aura/client/window_tree_client.h" | 13 #include "ui/aura/client/window_tree_client.h" |
14 #include "ui/aura/test/test_window_delegate.h" | 14 #include "ui/aura/test/test_window_delegate.h" |
15 #include "ui/aura/window.h" | 15 #include "ui/aura/window.h" |
16 #include "ui/base/hit_test.h" | 16 #include "ui/base/hit_test.h" |
17 #include "ui/events/test/event_generator.h" | 17 #include "ui/events/test/event_generator.h" |
18 #include "ui/gfx/display.h" | 18 #include "ui/gfx/display.h" |
19 #include "ui/gfx/screen.h" | 19 #include "ui/gfx/screen.h" |
20 #include "ui/wm/core/window_util.h" | 20 #include "ui/wm/core/window_util.h" |
21 | 21 |
22 namespace athena { | 22 namespace athena { |
23 | 23 |
24 class WindowManagerTest : public test::AthenaTestBase { | 24 class WindowManagerTest : public test::AthenaTestBase { |
25 public: | 25 public: |
26 WindowManagerTest() {} | 26 WindowManagerTest() {} |
27 virtual ~WindowManagerTest() {} | 27 virtual ~WindowManagerTest() {} |
28 | 28 |
29 scoped_ptr<aura::Window> CreateAndShowWindow(aura::WindowDelegate* delegate) { | 29 scoped_ptr<aura::Window> CreateAndActivateWindow( |
30 aura::WindowDelegate* delegate) { | |
30 scoped_ptr<aura::Window> window(CreateTestWindow(delegate, gfx::Rect())); | 31 scoped_ptr<aura::Window> window(CreateTestWindow(delegate, gfx::Rect())); |
31 window->Show(); | 32 window->Show(); |
33 wm::ActivateWindow(window.get()); | |
32 return window.Pass(); | 34 return window.Pass(); |
33 } | 35 } |
34 | 36 |
35 private: | 37 private: |
36 DISALLOW_COPY_AND_ASSIGN(WindowManagerTest); | 38 DISALLOW_COPY_AND_ASSIGN(WindowManagerTest); |
37 }; | 39 }; |
38 | 40 |
39 TEST_F(WindowManagerTest, OverviewModeBasics) { | 41 TEST_F(WindowManagerTest, OverviewModeBasics) { |
40 aura::test::TestWindowDelegate delegate; | 42 aura::test::TestWindowDelegate delegate; |
41 scoped_ptr<aura::Window> first(CreateAndShowWindow(&delegate)); | 43 scoped_ptr<aura::Window> first(CreateAndActivateWindow(&delegate)); |
42 scoped_ptr<aura::Window> second(CreateAndShowWindow(&delegate)); | 44 scoped_ptr<aura::Window> second(CreateAndActivateWindow(&delegate)); |
43 | 45 |
44 test::WindowManagerImplTestApi wm_api; | 46 test::WindowManagerImplTestApi wm_api; |
45 wm::ActivateWindow(second.get()); | 47 wm::ActivateWindow(second.get()); |
46 | 48 |
47 ASSERT_FALSE(WindowManager::GetInstance()->IsOverviewModeActive()); | 49 ASSERT_FALSE(WindowManager::GetInstance()->IsOverviewModeActive()); |
48 EXPECT_EQ(first->bounds().ToString(), second->bounds().ToString()); | 50 EXPECT_EQ(first->bounds().ToString(), second->bounds().ToString()); |
49 EXPECT_EQ(gfx::Screen::GetNativeScreen() | 51 EXPECT_EQ(gfx::Screen::GetNativeScreen() |
50 ->GetPrimaryDisplay() | 52 ->GetPrimaryDisplay() |
51 .work_area() | 53 .work_area() |
52 .size() | 54 .size() |
(...skipping 19 matching lines...) Expand all Loading... | |
72 WindowManager::GetInstance()->ToggleOverview(); | 74 WindowManager::GetInstance()->ToggleOverview(); |
73 ASSERT_FALSE(WindowManager::GetInstance()->IsOverviewModeActive()); | 75 ASSERT_FALSE(WindowManager::GetInstance()->IsOverviewModeActive()); |
74 EXPECT_FALSE(first->IsVisible()); | 76 EXPECT_FALSE(first->IsVisible()); |
75 EXPECT_TRUE(second->IsVisible()); | 77 EXPECT_TRUE(second->IsVisible()); |
76 } | 78 } |
77 | 79 |
78 TEST_F(WindowManagerTest, OverviewToSplitViewMode) { | 80 TEST_F(WindowManagerTest, OverviewToSplitViewMode) { |
79 test::WindowManagerImplTestApi wm_api; | 81 test::WindowManagerImplTestApi wm_api; |
80 | 82 |
81 aura::test::TestWindowDelegate delegate; | 83 aura::test::TestWindowDelegate delegate; |
82 scoped_ptr<aura::Window> w1(CreateAndShowWindow(&delegate)); | 84 scoped_ptr<aura::Window> w1(CreateAndActivateWindow(&delegate)); |
83 scoped_ptr<aura::Window> w2(CreateAndShowWindow(&delegate)); | 85 scoped_ptr<aura::Window> w2(CreateAndActivateWindow(&delegate)); |
84 scoped_ptr<aura::Window> w3(CreateAndShowWindow(&delegate)); | 86 scoped_ptr<aura::Window> w3(CreateAndActivateWindow(&delegate)); |
85 wm::ActivateWindow(w3.get()); | 87 wm::ActivateWindow(w3.get()); |
86 | 88 |
87 WindowManager::GetInstance()->ToggleOverview(); | 89 WindowManager::GetInstance()->ToggleOverview(); |
88 EXPECT_TRUE(w1->IsVisible()); | 90 EXPECT_TRUE(w1->IsVisible()); |
89 EXPECT_TRUE(w2->IsVisible()); | 91 EXPECT_TRUE(w2->IsVisible()); |
90 EXPECT_TRUE(w3->IsVisible()); | 92 EXPECT_TRUE(w3->IsVisible()); |
91 | 93 |
92 // Go into split-view mode. | 94 // Go into split-view mode. |
93 WindowOverviewModeDelegate* overview_delegate = wm_api.wm(); | 95 WindowOverviewModeDelegate* overview_delegate = wm_api.wm(); |
94 overview_delegate->OnSelectSplitViewWindow(w3.get(), NULL, w3.get()); | 96 overview_delegate->OnSelectSplitViewWindow(w3.get(), NULL, w3.get()); |
95 EXPECT_TRUE(w3->IsVisible()); | 97 EXPECT_TRUE(w3->IsVisible()); |
96 EXPECT_TRUE(w2->IsVisible()); | 98 EXPECT_TRUE(w2->IsVisible()); |
97 EXPECT_FALSE(w1->IsVisible()); | 99 EXPECT_FALSE(w1->IsVisible()); |
98 } | 100 } |
99 | 101 |
100 TEST_F(WindowManagerTest, NewWindowFromOverview) { | 102 TEST_F(WindowManagerTest, NewWindowFromOverview) { |
101 aura::test::TestWindowDelegate delegate; | 103 aura::test::TestWindowDelegate delegate; |
102 scoped_ptr<aura::Window> w1(CreateAndShowWindow(&delegate)); | 104 scoped_ptr<aura::Window> w1(CreateAndActivateWindow(&delegate)); |
103 scoped_ptr<aura::Window> w2(CreateAndShowWindow(&delegate)); | 105 scoped_ptr<aura::Window> w2(CreateAndActivateWindow(&delegate)); |
104 | 106 |
105 WindowManager::GetInstance()->ToggleOverview(); | 107 WindowManager::GetInstance()->ToggleOverview(); |
106 EXPECT_TRUE(w1->IsVisible()); | 108 EXPECT_TRUE(w1->IsVisible()); |
107 EXPECT_TRUE(w2->IsVisible()); | 109 EXPECT_TRUE(w2->IsVisible()); |
108 | 110 |
109 // Test that opening a new window exits overview mode. The new window could | 111 // Test that opening a new window exits overview mode. The new window could |
110 // have been opened by JavaScript or by the home card. | 112 // have been opened by JavaScript or by the home card. |
111 scoped_ptr<aura::Window> w3(CreateAndShowWindow(&delegate)); | 113 scoped_ptr<aura::Window> w3(CreateAndActivateWindow(&delegate)); |
112 | 114 |
113 ASSERT_FALSE(WindowManager::GetInstance()->IsOverviewModeActive()); | 115 ASSERT_FALSE(WindowManager::GetInstance()->IsOverviewModeActive()); |
114 EXPECT_TRUE(w3->IsVisible()); | 116 EXPECT_TRUE(w3->IsVisible()); |
115 EXPECT_TRUE(wm::IsActiveWindow(w3.get())); | 117 EXPECT_TRUE(wm::IsActiveWindow(w3.get())); |
116 EXPECT_FALSE(w1->IsVisible()); | 118 EXPECT_FALSE(w1->IsVisible()); |
117 EXPECT_FALSE(w2->IsVisible()); | 119 EXPECT_FALSE(w2->IsVisible()); |
118 } | 120 } |
119 | 121 |
120 TEST_F(WindowManagerTest, BezelGestureToSplitViewMode) { | 122 TEST_F(WindowManagerTest, BezelGestureToSplitViewMode) { |
121 aura::test::TestWindowDelegate delegate; | 123 aura::test::TestWindowDelegate delegate; |
122 scoped_ptr<aura::Window> first(CreateAndShowWindow(&delegate)); | 124 scoped_ptr<aura::Window> first(CreateAndActivateWindow(&delegate)); |
123 scoped_ptr<aura::Window> second(CreateAndShowWindow(&delegate)); | 125 scoped_ptr<aura::Window> second(CreateAndActivateWindow(&delegate)); |
124 scoped_ptr<aura::Window> third(CreateAndShowWindow(&delegate)); | 126 scoped_ptr<aura::Window> third(CreateAndActivateWindow(&delegate)); |
125 | 127 |
126 test::WindowManagerImplTestApi wm_api; | 128 test::WindowManagerImplTestApi wm_api; |
127 | 129 |
128 // Test that going into split-view mode with two-finger gesture selects the | 130 // Test that going into split-view mode with two-finger gesture selects the |
129 // correct windows on left and right splits. | 131 // correct windows on left and right splits. |
130 ui::test::EventGenerator generator(root_window()); | 132 ui::test::EventGenerator generator(root_window()); |
131 const gfx::Point start_points[2] = { | 133 const gfx::Point start_points[2] = { |
132 gfx::Point(2, 10), gfx::Point(4, 20), | 134 gfx::Point(2, 10), gfx::Point(4, 20), |
133 }; | 135 }; |
134 const int kEventTimeSepration = 16; | 136 const int kEventTimeSepration = 16; |
135 int x_middle = root_window()->bounds().width() / 2; | 137 int x_middle = root_window()->bounds().width() / 2; |
136 generator.GestureMultiFingerScroll( | 138 generator.GestureMultiFingerScroll( |
137 2, start_points, kEventTimeSepration, 1, x_middle, 0); | 139 2, start_points, kEventTimeSepration, 1, x_middle, 0); |
138 ASSERT_TRUE(wm_api.GetSplitViewController()->IsSplitViewModeActive()); | 140 ASSERT_TRUE(wm_api.GetSplitViewController()->IsSplitViewModeActive()); |
139 EXPECT_EQ(second.get(), wm_api.GetSplitViewController()->left_window()); | 141 EXPECT_EQ(second.get(), wm_api.GetSplitViewController()->left_window()); |
140 EXPECT_EQ(third.get(), wm_api.GetSplitViewController()->right_window()); | 142 EXPECT_EQ(third.get(), wm_api.GetSplitViewController()->right_window()); |
141 EXPECT_EQ(second->bounds().size().ToString(), | 143 EXPECT_EQ(second->bounds().size().ToString(), |
142 third->bounds().size().ToString()); | 144 third->bounds().size().ToString()); |
143 } | 145 } |
144 | 146 |
145 TEST_F(WindowManagerTest, BezelGestureToSwitchBetweenWindows) { | 147 TEST_F(WindowManagerTest, BezelGestureToSwitchBetweenWindows) { |
146 aura::test::TestWindowDelegate delegate; | 148 aura::test::TestWindowDelegate delegate; |
147 scoped_ptr<aura::Window> first(CreateAndShowWindow(&delegate)); | 149 scoped_ptr<aura::Window> first(CreateAndActivateWindow(&delegate)); |
148 scoped_ptr<aura::Window> second(CreateAndShowWindow(&delegate)); | 150 scoped_ptr<aura::Window> second(CreateAndActivateWindow(&delegate)); |
149 scoped_ptr<aura::Window> third(CreateAndShowWindow(&delegate)); | 151 scoped_ptr<aura::Window> third(CreateAndActivateWindow(&delegate)); |
150 first->Hide(); | 152 first->Hide(); |
151 second->Hide(); | 153 second->Hide(); |
152 | 154 |
153 test::WindowManagerImplTestApi wm_api; | 155 test::WindowManagerImplTestApi wm_api; |
154 | 156 |
155 EXPECT_EQ(third.get(), | 157 EXPECT_EQ(third.get(), |
156 wm_api.GetWindowListProvider()->GetWindowList().back()); | 158 wm_api.GetWindowListProvider()->GetWindowList().back()); |
157 | 159 |
158 // Do a two-finger swipe from the left bezel. | 160 // Do a two-finger swipe from the left bezel. |
159 ui::test::EventGenerator generator(root_window()); | 161 ui::test::EventGenerator generator(root_window()); |
160 const gfx::Point left_bezel_points[2] = { | 162 const gfx::Point left_bezel_points[2] = { |
161 gfx::Point(2, 10), gfx::Point(4, 20), | 163 gfx::Point(2, 10), gfx::Point(4, 20), |
162 }; | 164 }; |
163 const int kEventTimeSepration = 16; | 165 const int kEventTimeSeparation = 16; |
164 int width = root_window()->bounds().width(); | 166 int width = root_window()->bounds().width(); |
165 generator.GestureMultiFingerScroll( | 167 generator.GestureMultiFingerScroll( |
166 2, left_bezel_points, kEventTimeSepration, 1, width, 0); | 168 2, left_bezel_points, kEventTimeSeparation, 1, width, 0); |
167 EXPECT_TRUE(wm::IsActiveWindow(second.get())); | 169 EXPECT_TRUE(wm::IsActiveWindow(second.get())); |
168 EXPECT_EQ(second.get(), | 170 EXPECT_EQ(second.get(), |
169 wm_api.GetWindowListProvider()->GetWindowList().back()); | 171 wm_api.GetWindowListProvider()->GetWindowList().back()); |
172 | |
173 // Do a two-finger swipe from the right bezel. | |
174 const gfx::Point right_bezel_points[2] = { | |
175 gfx::Point(width - 5, 10), | |
176 gfx::Point(width - 10, 20) | |
177 }; | |
178 generator.GestureMultiFingerScroll( | |
179 2, right_bezel_points, kEventTimeSeparation, 1, -width, 0); | |
180 EXPECT_TRUE(wm::IsActiveWindow(third.get())); | |
181 EXPECT_EQ(third.get(), | |
182 wm_api.GetWindowListProvider()->GetWindowList().back()); | |
170 } | 183 } |
171 | 184 |
172 TEST_F(WindowManagerTest, TitleDragSwitchBetweenWindows) { | 185 TEST_F(WindowManagerTest, TitleDragSwitchBetweenWindows) { |
173 aura::test::TestWindowDelegate delegate; | 186 aura::test::TestWindowDelegate delegate; |
174 delegate.set_window_component(HTCAPTION); | 187 delegate.set_window_component(HTCAPTION); |
175 scoped_ptr<aura::Window> first(CreateAndShowWindow(&delegate)); | 188 scoped_ptr<aura::Window> first(CreateAndActivateWindow(&delegate)); |
176 scoped_ptr<aura::Window> second(CreateAndShowWindow(&delegate)); | 189 scoped_ptr<aura::Window> second(CreateAndActivateWindow(&delegate)); |
177 scoped_ptr<aura::Window> third(CreateAndShowWindow(&delegate)); | 190 scoped_ptr<aura::Window> third(CreateAndActivateWindow(&delegate)); |
178 | 191 |
179 test::WindowManagerImplTestApi wm_api; | 192 test::WindowManagerImplTestApi wm_api; |
180 | 193 |
181 EXPECT_EQ(third.get(), | 194 EXPECT_EQ(third.get(), |
182 wm_api.GetWindowListProvider()->GetWindowList().back()); | 195 wm_api.GetWindowListProvider()->GetWindowList().back()); |
183 | 196 |
184 // Do a title-swipe from the top to switch to the previous window. | 197 // Do a title-swipe from the top to switch to the previous window. |
185 ui::test::EventGenerator generator(root_window()); | 198 ui::test::EventGenerator generator(root_window()); |
186 generator.GestureScrollSequence(gfx::Point(20, 10), | 199 generator.GestureScrollSequence(gfx::Point(20, 10), |
187 gfx::Point(20, 400), | 200 gfx::Point(20, 400), |
(...skipping 24 matching lines...) Expand all Loading... | |
212 EXPECT_TRUE(wm::IsActiveWindow(third.get())); | 225 EXPECT_TRUE(wm::IsActiveWindow(third.get())); |
213 EXPECT_EQ(third.get(), | 226 EXPECT_EQ(third.get(), |
214 wm_api.GetWindowListProvider()->GetWindowList().back()); | 227 wm_api.GetWindowListProvider()->GetWindowList().back()); |
215 EXPECT_FALSE(second->IsVisible()); | 228 EXPECT_FALSE(second->IsVisible()); |
216 EXPECT_TRUE(third->IsVisible()); | 229 EXPECT_TRUE(third->IsVisible()); |
217 } | 230 } |
218 | 231 |
219 TEST_F(WindowManagerTest, TitleDragSwitchBetweenWindowsInSplitViewMode) { | 232 TEST_F(WindowManagerTest, TitleDragSwitchBetweenWindowsInSplitViewMode) { |
220 aura::test::TestWindowDelegate delegate; | 233 aura::test::TestWindowDelegate delegate; |
221 delegate.set_window_component(HTCAPTION); | 234 delegate.set_window_component(HTCAPTION); |
222 scoped_ptr<aura::Window> first(CreateAndShowWindow(&delegate)); | 235 scoped_ptr<aura::Window> first(CreateAndActivateWindow(&delegate)); |
223 scoped_ptr<aura::Window> second(CreateAndShowWindow(&delegate)); | 236 scoped_ptr<aura::Window> second(CreateAndActivateWindow(&delegate)); |
224 scoped_ptr<aura::Window> third(CreateAndShowWindow(&delegate)); | 237 scoped_ptr<aura::Window> third(CreateAndActivateWindow(&delegate)); |
225 scoped_ptr<aura::Window> fourth(CreateAndShowWindow(&delegate)); | 238 scoped_ptr<aura::Window> fourth(CreateAndActivateWindow(&delegate)); |
226 | 239 |
227 test::WindowManagerImplTestApi wm_api; | 240 test::WindowManagerImplTestApi wm_api; |
228 | 241 |
229 // Test that going into split-view mode with two-finger gesture selects the | 242 // Test that going into split-view mode with two-finger gesture selects the |
230 // correct windows on left and right splits. | 243 // correct windows on left and right splits. |
231 ui::test::EventGenerator generator(root_window()); | 244 ui::test::EventGenerator generator(root_window()); |
232 const gfx::Point start_points[2] = { | 245 const gfx::Point start_points[2] = { |
233 gfx::Point(2, 10), gfx::Point(4, 20), | 246 gfx::Point(2, 10), gfx::Point(4, 20), |
234 }; | 247 }; |
235 const int kEventTimeSepration = 16; | 248 const int kEventTimeSepration = 16; |
(...skipping 19 matching lines...) Expand all Loading... | |
255 | 268 |
256 // Swipe the title of the right window now. It should switch to |third|. | 269 // Swipe the title of the right window now. It should switch to |third|. |
257 generator.GestureScrollSequence(gfx::Point(x_middle + 20, 10), | 270 generator.GestureScrollSequence(gfx::Point(x_middle + 20, 10), |
258 gfx::Point(x_middle + 20, 400), | 271 gfx::Point(x_middle + 20, 400), |
259 base::TimeDelta::FromMilliseconds(20), | 272 base::TimeDelta::FromMilliseconds(20), |
260 5); | 273 5); |
261 EXPECT_EQ(second.get(), wm_api.GetSplitViewController()->left_window()); | 274 EXPECT_EQ(second.get(), wm_api.GetSplitViewController()->left_window()); |
262 EXPECT_EQ(third.get(), wm_api.GetSplitViewController()->right_window()); | 275 EXPECT_EQ(third.get(), wm_api.GetSplitViewController()->right_window()); |
263 windows = wm_api.GetWindowListProvider()->GetWindowList(); | 276 windows = wm_api.GetWindowListProvider()->GetWindowList(); |
264 ASSERT_EQ(4u, windows.size()); | 277 ASSERT_EQ(4u, windows.size()); |
265 EXPECT_EQ(second.get(), windows[3]); | 278 EXPECT_EQ(third.get(), windows[3]); |
266 EXPECT_EQ(third.get(), windows[2]); | 279 EXPECT_EQ(second.get(), windows[2]); |
267 } | 280 } |
268 | 281 |
269 TEST_F(WindowManagerTest, NewWindowBounds) { | 282 TEST_F(WindowManagerTest, NewWindowBounds) { |
270 aura::test::TestWindowDelegate delegate; | 283 aura::test::TestWindowDelegate delegate; |
271 scoped_ptr<aura::Window> first(CreateAndShowWindow(&delegate)); | 284 scoped_ptr<aura::Window> first(CreateAndActivateWindow(&delegate)); |
272 | 285 |
273 test::WindowManagerImplTestApi wm_api; | 286 test::WindowManagerImplTestApi wm_api; |
274 // The window should have the same size as the container. | 287 // The window should have the same size as the container. |
275 const gfx::Size work_area = | 288 const gfx::Size work_area = |
276 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().work_area().size(); | 289 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().work_area().size(); |
277 EXPECT_EQ(work_area.ToString(), | 290 EXPECT_EQ(work_area.ToString(), |
278 first->bounds().size().ToString()); | 291 first->bounds().size().ToString()); |
279 EXPECT_TRUE(first->bounds().origin().IsOrigin()); | 292 EXPECT_TRUE(first->bounds().origin().IsOrigin()); |
280 | 293 |
281 // A second window should have the same bounds as the first one. | 294 // A second window should have the same bounds as the first one. |
282 scoped_ptr<aura::Window> second(CreateAndShowWindow(&delegate)); | 295 scoped_ptr<aura::Window> second(CreateAndActivateWindow(&delegate)); |
283 EXPECT_EQ(first->bounds().ToString(), second->bounds().ToString()); | 296 EXPECT_EQ(first->bounds().ToString(), second->bounds().ToString()); |
284 | 297 |
285 // Get into split view. | 298 // Get into split view. |
286 wm_api.GetSplitViewController()->ActivateSplitMode(NULL, NULL); | 299 wm_api.GetSplitViewController()->ActivateSplitMode(NULL, NULL, NULL); |
287 const gfx::Rect left_bounds = | 300 const gfx::Rect left_bounds = |
288 wm_api.GetSplitViewController()->left_window()->bounds(); | 301 wm_api.GetSplitViewController()->left_window()->bounds(); |
289 EXPECT_NE(work_area.ToString(), | 302 EXPECT_NE(work_area.ToString(), |
290 left_bounds.size().ToString()); | 303 left_bounds.size().ToString()); |
291 | 304 |
292 // A new window should replace the left window when in split view. | 305 // A new window should replace the left window when in split view. |
293 scoped_ptr<aura::Window> third(CreateAndShowWindow(&delegate)); | 306 scoped_ptr<aura::Window> third(CreateAndActivateWindow(&delegate)); |
294 EXPECT_EQ(wm_api.GetSplitViewController()->left_window(), third.get()); | 307 EXPECT_EQ(wm_api.GetSplitViewController()->left_window(), third.get()); |
295 EXPECT_EQ(left_bounds.ToString(), third->bounds().ToString()); | 308 EXPECT_EQ(left_bounds.ToString(), third->bounds().ToString()); |
296 } | 309 } |
297 | 310 |
298 TEST_F(WindowManagerTest, SplitModeActivationByShortcut) { | 311 TEST_F(WindowManagerTest, SplitModeActivationByShortcut) { |
299 test::WindowManagerImplTestApi wm_api; | 312 test::WindowManagerImplTestApi wm_api; |
300 | 313 |
301 aura::test::TestWindowDelegate delegate; | 314 aura::test::TestWindowDelegate delegate; |
302 scoped_ptr<aura::Window> w1(CreateTestWindow(&delegate, gfx::Rect())); | 315 scoped_ptr<aura::Window> w1(CreateAndActivateWindow(&delegate)); |
303 w1->Show(); | |
304 | |
305 ui::test::EventGenerator generator(root_window()); | |
306 | 316 |
307 // Splitview mode needs at least two windows. | 317 // Splitview mode needs at least two windows. |
308 generator.PressKey(ui::VKEY_F6, ui::EF_CONTROL_DOWN); | 318 wm_api.wm()->ToggleSplitView(); |
pkotwicz
2014/09/19 21:58:00
The accelerator does not work anymore because the
| |
309 generator.ReleaseKey(ui::VKEY_F6, ui::EF_CONTROL_DOWN); | |
310 EXPECT_FALSE(wm_api.GetSplitViewController()->IsSplitViewModeActive()); | 319 EXPECT_FALSE(wm_api.GetSplitViewController()->IsSplitViewModeActive()); |
311 | 320 |
312 scoped_ptr<aura::Window> w2(CreateAndShowWindow(&delegate)); | 321 scoped_ptr<aura::Window> w2(CreateAndActivateWindow(&delegate)); |
313 w2->Show(); | 322 w2->Show(); |
314 | 323 |
315 generator.PressKey(ui::VKEY_F6, ui::EF_CONTROL_DOWN); | 324 wm_api.wm()->ToggleSplitView(); |
316 generator.ReleaseKey(ui::VKEY_F6, ui::EF_CONTROL_DOWN); | |
317 EXPECT_TRUE(wm_api.GetSplitViewController()->IsSplitViewModeActive()); | 325 EXPECT_TRUE(wm_api.GetSplitViewController()->IsSplitViewModeActive()); |
318 int width = | 326 int width = |
319 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().work_area().width(); | 327 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().work_area().width(); |
320 | 328 |
321 EXPECT_EQ(width / 2, w1->bounds().width()); | 329 EXPECT_EQ(width / 2, w1->bounds().width()); |
322 EXPECT_EQ(width / 2, w2->bounds().width()); | 330 EXPECT_EQ(width / 2, w2->bounds().width()); |
323 | 331 |
324 // Toggle back to normal mode. | 332 // Toggle back to normal mode. |
325 generator.PressKey(ui::VKEY_F6, ui::EF_CONTROL_DOWN); | 333 wm_api.wm()->ToggleSplitView(); |
326 generator.ReleaseKey(ui::VKEY_F6, ui::EF_CONTROL_DOWN); | |
327 EXPECT_FALSE(wm_api.GetSplitViewController()->IsSplitViewModeActive()); | 334 EXPECT_FALSE(wm_api.GetSplitViewController()->IsSplitViewModeActive()); |
328 | 335 |
329 EXPECT_EQ(width, w1->bounds().width()); | 336 EXPECT_EQ(width, w1->bounds().width()); |
330 EXPECT_EQ(width, w2->bounds().width()); | 337 EXPECT_EQ(width, w2->bounds().width()); |
331 } | 338 } |
332 | 339 |
333 TEST_F(WindowManagerTest, OverviewModeFromSplitMode) { | 340 TEST_F(WindowManagerTest, OverviewModeFromSplitMode) { |
334 test::WindowManagerImplTestApi wm_api; | 341 test::WindowManagerImplTestApi wm_api; |
335 | 342 |
336 aura::test::TestWindowDelegate delegate; | 343 aura::test::TestWindowDelegate delegate; |
337 scoped_ptr<aura::Window> w1(CreateAndShowWindow(&delegate)); | 344 scoped_ptr<aura::Window> w1(CreateAndActivateWindow(&delegate)); |
338 scoped_ptr<aura::Window> w2(CreateAndShowWindow(&delegate)); | 345 scoped_ptr<aura::Window> w2(CreateAndActivateWindow(&delegate)); |
339 scoped_ptr<aura::Window> w3(CreateAndShowWindow(&delegate)); | 346 scoped_ptr<aura::Window> w3(CreateAndActivateWindow(&delegate)); |
340 | 347 |
341 // Get into split-view mode, and then turn on overview mode. | 348 // Get into split-view mode, and then turn on overview mode. |
342 wm_api.GetSplitViewController()->ActivateSplitMode(NULL, NULL); | 349 wm_api.GetSplitViewController()->ActivateSplitMode(NULL, NULL, NULL); |
343 WindowManager::GetInstance()->ToggleOverview(); | 350 WindowManager::GetInstance()->ToggleOverview(); |
344 EXPECT_TRUE(wm_api.GetSplitViewController()->IsSplitViewModeActive()); | 351 EXPECT_TRUE(wm_api.GetSplitViewController()->IsSplitViewModeActive()); |
345 EXPECT_EQ(w3.get(), wm_api.GetSplitViewController()->left_window()); | 352 EXPECT_EQ(w3.get(), wm_api.GetSplitViewController()->left_window()); |
346 EXPECT_EQ(w2.get(), wm_api.GetSplitViewController()->right_window()); | 353 EXPECT_EQ(w2.get(), wm_api.GetSplitViewController()->right_window()); |
347 | 354 |
348 WindowOverviewModeDelegate* overview_delegate = wm_api.wm(); | 355 WindowOverviewModeDelegate* overview_delegate = wm_api.wm(); |
349 overview_delegate->OnSelectWindow(w1.get()); | 356 overview_delegate->OnSelectWindow(w1.get()); |
350 EXPECT_FALSE(wm_api.GetSplitViewController()->IsSplitViewModeActive()); | 357 EXPECT_FALSE(wm_api.GetSplitViewController()->IsSplitViewModeActive()); |
351 EXPECT_TRUE(w1->IsVisible()); | 358 EXPECT_TRUE(w1->IsVisible()); |
352 // Make sure the windows that were in split-view mode are hidden. | 359 // Make sure the windows that were in split-view mode are hidden. |
353 EXPECT_FALSE(w2->IsVisible()); | 360 EXPECT_FALSE(w2->IsVisible()); |
354 EXPECT_FALSE(w3->IsVisible()); | 361 EXPECT_FALSE(w3->IsVisible()); |
355 } | 362 } |
356 | 363 |
357 } // namespace athena | 364 } // namespace athena |
OLD | NEW |