Cleanup: Remove vim comment settings, tab width and expansion variables from gyp...
[chromium-blink-merge.git] / athena / wm / window_manager_unittest.cc
blobb11d306d1b904ae8d3bdd240ca73cfce4c9a9d4a
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
3 // found in the LICENSE file.
5 #include "athena/wm/public/window_manager.h"
7 #include "athena/screen/public/screen_manager.h"
8 #include "athena/test/base/athena_test_base.h"
9 #include "athena/test/base/test_windows.h"
10 #include "athena/wm/public/window_list_provider.h"
11 #include "athena/wm/split_view_controller.h"
12 #include "athena/wm/test/window_manager_impl_test_api.h"
13 #include "athena/wm/window_manager_impl.h"
14 #include "ui/aura/client/aura_constants.h"
15 #include "ui/aura/client/window_tree_client.h"
16 #include "ui/aura/test/test_window_delegate.h"
17 #include "ui/aura/window.h"
18 #include "ui/base/hit_test.h"
19 #include "ui/events/test/event_generator.h"
20 #include "ui/gfx/display.h"
21 #include "ui/gfx/screen.h"
22 #include "ui/wm/core/window_util.h"
24 namespace athena {
26 class WindowManagerTest : public test::AthenaTestBase {
27 public:
28 WindowManagerTest() {}
29 ~WindowManagerTest() override {}
31 scoped_ptr<aura::Window> CreateAndActivateWindow(
32 aura::WindowDelegate* delegate) {
33 scoped_ptr<aura::Window> window(
34 test::CreateNormalWindow(delegate, nullptr));
35 window->Show();
36 wm::ActivateWindow(window.get());
37 window->SetProperty(aura::client::kCanMaximizeKey, true);
38 return window.Pass();
41 private:
42 DISALLOW_COPY_AND_ASSIGN(WindowManagerTest);
45 TEST_F(WindowManagerTest, OverviewModeBasics) {
46 aura::test::TestWindowDelegate delegate;
47 scoped_ptr<aura::Window> first(CreateAndActivateWindow(&delegate));
48 scoped_ptr<aura::Window> second(CreateAndActivateWindow(&delegate));
50 test::WindowManagerImplTestApi wm_api;
51 wm::ActivateWindow(second.get());
53 ASSERT_FALSE(WindowManager::Get()->IsOverviewModeActive());
54 EXPECT_EQ(first->bounds().ToString(), second->bounds().ToString());
55 EXPECT_EQ(gfx::Screen::GetNativeScreen()
56 ->GetPrimaryDisplay()
57 .work_area()
58 .size()
59 .ToString(),
60 first->bounds().size().ToString());
61 EXPECT_FALSE(WindowManager::Get()->IsOverviewModeActive());
63 // Tests that going into overview mode does not change the window bounds.
64 WindowManager::Get()->EnterOverview();
65 ASSERT_TRUE(WindowManager::Get()->IsOverviewModeActive());
66 EXPECT_EQ(first->bounds().ToString(), second->bounds().ToString());
67 EXPECT_EQ(gfx::Screen::GetNativeScreen()
68 ->GetPrimaryDisplay()
69 .work_area()
70 .size()
71 .ToString(),
72 first->bounds().size().ToString());
73 EXPECT_TRUE(first->IsVisible());
74 EXPECT_TRUE(second->IsVisible());
76 // Terminate overview mode. |first| should be hidden, since it's not visible
77 // to the user anymore.
78 WindowManager::Get()->ExitOverview();
79 ASSERT_FALSE(WindowManager::Get()->IsOverviewModeActive());
80 EXPECT_FALSE(first->IsVisible());
81 EXPECT_TRUE(second->IsVisible());
84 TEST_F(WindowManagerTest, OverviewToSplitViewMode) {
85 test::WindowManagerImplTestApi wm_api;
87 aura::test::TestWindowDelegate delegate;
88 scoped_ptr<aura::Window> w1(CreateAndActivateWindow(&delegate));
89 scoped_ptr<aura::Window> w2(CreateAndActivateWindow(&delegate));
90 scoped_ptr<aura::Window> w3(CreateAndActivateWindow(&delegate));
91 wm::ActivateWindow(w3.get());
93 WindowManager::Get()->EnterOverview();
94 EXPECT_TRUE(w1->IsVisible());
95 EXPECT_TRUE(w2->IsVisible());
96 EXPECT_TRUE(w3->IsVisible());
98 // Go into split-view mode.
99 WindowOverviewModeDelegate* overview_delegate = wm_api.wm();
100 overview_delegate->OnSelectSplitViewWindow(w3.get(), nullptr, w3.get());
101 EXPECT_TRUE(w3->IsVisible());
102 EXPECT_TRUE(w2->IsVisible());
103 EXPECT_FALSE(w1->IsVisible());
106 TEST_F(WindowManagerTest, OnSelectWindow) {
107 test::WindowManagerImplTestApi wm_api;
108 aura::test::TestWindowDelegate delegate1;
109 aura::test::TestWindowDelegate delegate2;
110 aura::test::TestWindowDelegate delegate3;
112 // (w1): A window that sets a maximum size
113 delegate1.set_maximum_size(gfx::Size(300, 200));
114 scoped_ptr<aura::Window> w1(CreateAndActivateWindow(&delegate1));
115 w1->SetBounds(gfx::Rect(0, 0, 300, 200));
117 // (w2): A window that doesn't set a max size and is maximizable
118 scoped_ptr<aura::Window> w2(CreateAndActivateWindow(&delegate2));
119 w2->SetBounds(gfx::Rect(0, 0, 300, 200));
120 w2->SetProperty(aura::client::kCanMaximizeKey, true);
122 // (w3): A window that doesn't set a max size but is NOT maximizable
123 scoped_ptr<aura::Window> w3(CreateAndActivateWindow(&delegate3));
124 w3->SetBounds(gfx::Rect(0, 0, 300, 200));
125 w3->SetProperty(aura::client::kCanMaximizeKey, false);
127 const gfx::Size old_bounds1 = w1->GetTargetBounds().size();
128 const gfx::Size old_bounds2 = w2->GetTargetBounds().size();
129 const gfx::Size old_bounds3 = w3->GetTargetBounds().size();
130 const gfx::Size work_area =
131 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().work_area().size();
133 // Select w1, which has a max size, in the overview mode and make sure it's
134 // not maximized.
135 WindowManager::Get()->EnterOverview();
136 WindowOverviewModeDelegate* overview_delegate = wm_api.wm();
137 overview_delegate->OnSelectWindow(w1.get());
138 const gfx::Size new_bounds1 = w1->GetTargetBounds().size();
139 EXPECT_EQ(new_bounds1.ToString(), old_bounds1.ToString());
140 EXPECT_NE(work_area.ToString(), new_bounds1.ToString());
142 // Select w2, which has no max size & can be maximized, in the overview
143 // mode and make sure it's actually maximized.
144 WindowManager::Get()->EnterOverview();
145 overview_delegate->OnSelectWindow(w2.get());
146 const gfx::Size new_bounds2 = w2->GetTargetBounds().size();
147 EXPECT_NE(new_bounds2.ToString(), old_bounds2.ToString());
148 EXPECT_EQ(work_area.ToString(), new_bounds2.ToString());
150 // Select w3, which has no max size & cannot be maximized, in the overview
151 // mode and make sure it's not maximized.
152 WindowManager::Get()->EnterOverview();
153 overview_delegate->OnSelectWindow(w3.get());
154 const gfx::Size new_bounds3 = w3->GetTargetBounds().size();
155 EXPECT_EQ(new_bounds3.ToString(), old_bounds3.ToString());
156 EXPECT_NE(work_area.ToString(), new_bounds3.ToString());
159 TEST_F(WindowManagerTest, NewWindowFromOverview) {
160 aura::test::TestWindowDelegate delegate;
161 scoped_ptr<aura::Window> w1(CreateAndActivateWindow(&delegate));
162 scoped_ptr<aura::Window> w2(CreateAndActivateWindow(&delegate));
164 WindowManager::Get()->EnterOverview();
165 EXPECT_TRUE(w1->IsVisible());
166 EXPECT_TRUE(w2->IsVisible());
168 // Test that opening a new window exits overview mode. The new window could
169 // have been opened by JavaScript or by the home card.
170 scoped_ptr<aura::Window> w3(CreateAndActivateWindow(&delegate));
172 ASSERT_FALSE(WindowManager::Get()->IsOverviewModeActive());
173 EXPECT_TRUE(w3->IsVisible());
174 EXPECT_TRUE(wm::IsActiveWindow(w3.get()));
175 EXPECT_FALSE(w1->IsVisible());
176 EXPECT_FALSE(w2->IsVisible());
179 TEST_F(WindowManagerTest, TitleDragSwitchBetweenWindows) {
180 aura::test::TestWindowDelegate delegate;
181 delegate.set_window_component(HTCAPTION);
182 scoped_ptr<aura::Window> first(CreateAndActivateWindow(&delegate));
183 scoped_ptr<aura::Window> second(CreateAndActivateWindow(&delegate));
184 scoped_ptr<aura::Window> third(CreateAndActivateWindow(&delegate));
186 test::WindowManagerImplTestApi wm_api;
188 EXPECT_EQ(third.get(),
189 wm_api.GetWindowListProvider()->GetWindowList().back());
191 // Do a title-swipe from the top to switch to the previous window.
192 ui::test::EventGenerator generator(root_window());
193 generator.GestureScrollSequence(gfx::Point(20, 10),
194 gfx::Point(20, 400),
195 base::TimeDelta::FromMilliseconds(20),
197 EXPECT_TRUE(wm::IsActiveWindow(second.get()));
198 EXPECT_EQ(second.get(),
199 wm_api.GetWindowListProvider()->GetWindowList().back());
200 EXPECT_TRUE(second->IsVisible());
201 EXPECT_FALSE(third->IsVisible());
203 // Performing the same gesture again will switch back to |third|.
204 generator.GestureScrollSequence(gfx::Point(20, 10),
205 gfx::Point(20, 400),
206 base::TimeDelta::FromMilliseconds(20),
208 EXPECT_TRUE(wm::IsActiveWindow(third.get()));
209 EXPECT_EQ(third.get(),
210 wm_api.GetWindowListProvider()->GetWindowList().back());
211 EXPECT_FALSE(second->IsVisible());
212 EXPECT_TRUE(third->IsVisible());
214 // Perform a swipe that doesn't go enough to perform the window switch.
215 generator.GestureScrollSequence(gfx::Point(20, 10),
216 gfx::Point(20, 90),
217 base::TimeDelta::FromMilliseconds(20),
219 EXPECT_TRUE(wm::IsActiveWindow(third.get()));
220 EXPECT_EQ(third.get(),
221 wm_api.GetWindowListProvider()->GetWindowList().back());
222 EXPECT_FALSE(second->IsVisible());
223 EXPECT_TRUE(third->IsVisible());
226 // Verifies that the correct windows are replaced and the ordering of
227 // the window list changes correctly when the window titlebars are dragged
228 // in split view mode.
229 TEST_F(WindowManagerTest, ReplaceWindowsInSplitViewMode) {
230 aura::test::TestWindowDelegate delegate;
231 delegate.set_window_component(HTCAPTION);
232 scoped_ptr<aura::Window> first(CreateAndActivateWindow(&delegate));
233 scoped_ptr<aura::Window> second(CreateAndActivateWindow(&delegate));
234 scoped_ptr<aura::Window> third(CreateAndActivateWindow(&delegate));
235 scoped_ptr<aura::Window> fourth(CreateAndActivateWindow(&delegate));
237 test::WindowManagerImplTestApi wm_api;
238 wm_api.wm()->ToggleSplitView();
239 ASSERT_TRUE(wm_api.GetSplitViewController()->IsSplitViewModeActive());
241 // Verify that the left and right windows have been set to the
242 // two windows at the top of the window list.
243 aura::Window::Windows windows =
244 wm_api.GetWindowListProvider()->GetWindowList();
245 ASSERT_EQ(4u, windows.size());
246 EXPECT_EQ(first.get(), windows[0]);
247 EXPECT_EQ(second.get(), windows[1]);
248 EXPECT_EQ(third.get(), windows[2]);
249 EXPECT_EQ(fourth.get(), windows[3]);
250 EXPECT_EQ(fourth.get(), wm_api.GetSplitViewController()->left_window());
251 EXPECT_EQ(third.get(), wm_api.GetSplitViewController()->right_window());
253 // Swiping the title of the left window should change it from |fourth|
254 // to |second|. The right window should not change.
255 ui::test::EventGenerator generator(root_window());
256 generator.GestureScrollSequence(gfx::Point(20, 10),
257 gfx::Point(20, 400),
258 base::TimeDelta::FromMilliseconds(20),
260 EXPECT_EQ(second.get(), wm_api.GetSplitViewController()->left_window());
261 EXPECT_EQ(third.get(), wm_api.GetSplitViewController()->right_window());
263 // |second| should be placed at the front of the list. The replaced
264 // window (|fourth|) should be stacked behind the non-replaced window
265 // (|third|).
266 windows = wm_api.GetWindowListProvider()->GetWindowList();
267 ASSERT_EQ(4u, windows.size());
268 EXPECT_EQ(first.get(), windows[0]);
269 EXPECT_EQ(fourth.get(), windows[1]);
270 EXPECT_EQ(third.get(), windows[2]);
271 EXPECT_EQ(second.get(), windows[3]);
273 // Swiping the title of the right window should change it from |third|
274 // to |fourth|. The left window should not change.
275 int x_middle = root_window()->bounds().width() / 2;
276 generator.GestureScrollSequence(gfx::Point(x_middle + 20, 10),
277 gfx::Point(x_middle + 20, 400),
278 base::TimeDelta::FromMilliseconds(20),
280 EXPECT_EQ(second.get(), wm_api.GetSplitViewController()->left_window());
281 EXPECT_EQ(fourth.get(), wm_api.GetSplitViewController()->right_window());
283 // |fourth| should be placed at the front of the list. The replaced
284 // window (|third|) should be stacked behind the non-replaced window
285 // (|second|).
286 windows = wm_api.GetWindowListProvider()->GetWindowList();
287 ASSERT_EQ(4u, windows.size());
288 EXPECT_EQ(first.get(), windows[0]);
289 EXPECT_EQ(third.get(), windows[1]);
290 EXPECT_EQ(second.get(), windows[2]);
291 EXPECT_EQ(fourth.get(), windows[3]);
294 TEST_F(WindowManagerTest, NewWindowBounds) {
295 aura::test::TestWindowDelegate delegate;
296 scoped_ptr<aura::Window> first(CreateAndActivateWindow(&delegate));
298 test::WindowManagerImplTestApi wm_api;
299 // The window should have the same size as the container.
300 const gfx::Size work_area =
301 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().work_area().size();
302 EXPECT_EQ(work_area.ToString(),
303 first->bounds().size().ToString());
304 EXPECT_TRUE(first->bounds().origin().IsOrigin());
306 // A second window should have the same bounds as the first one.
307 scoped_ptr<aura::Window> second(CreateAndActivateWindow(&delegate));
308 EXPECT_EQ(first->bounds().ToString(), second->bounds().ToString());
310 // Get into split view.
311 wm_api.GetSplitViewController()->ActivateSplitMode(nullptr, nullptr, nullptr);
312 const gfx::Rect left_bounds =
313 wm_api.GetSplitViewController()->left_window()->bounds();
314 EXPECT_NE(work_area.ToString(),
315 left_bounds.size().ToString());
317 // A new window should replace the left window when in split view.
318 scoped_ptr<aura::Window> third(CreateAndActivateWindow(&delegate));
319 EXPECT_EQ(wm_api.GetSplitViewController()->left_window(), third.get());
320 EXPECT_EQ(left_bounds.ToString(), third->bounds().ToString());
323 TEST_F(WindowManagerTest, OverviewModeAccelerators) {
324 ui::test::EventGenerator generator(root_window());
326 // F6 toggles overview mode
327 ASSERT_FALSE(WindowManager::Get()->IsOverviewModeActive());
328 generator.PressKey(ui::VKEY_F6, ui::EF_NONE);
329 EXPECT_TRUE(WindowManager::Get()->IsOverviewModeActive());
330 generator.PressKey(ui::VKEY_F6, ui::EF_NONE);
331 EXPECT_FALSE(WindowManager::Get()->IsOverviewModeActive());
333 // ESC exits overview mode
334 generator.PressKey(ui::VKEY_F6, ui::EF_NONE);
335 EXPECT_TRUE(WindowManager::Get()->IsOverviewModeActive());
336 generator.PressKey(ui::VKEY_ESCAPE, ui::EF_NONE);
337 EXPECT_FALSE(WindowManager::Get()->IsOverviewModeActive());
340 TEST_F(WindowManagerTest, SplitModeActivationByShortcut) {
341 test::WindowManagerImplTestApi wm_api;
343 aura::test::TestWindowDelegate delegate;
344 scoped_ptr<aura::Window> w1(CreateAndActivateWindow(&delegate));
346 // Splitview mode needs at least two windows.
347 wm_api.wm()->ToggleSplitView();
348 EXPECT_FALSE(wm_api.GetSplitViewController()->IsSplitViewModeActive());
350 scoped_ptr<aura::Window> w2(CreateAndActivateWindow(&delegate));
351 w2->Show();
353 wm_api.wm()->ToggleSplitView();
354 EXPECT_TRUE(wm_api.GetSplitViewController()->IsSplitViewModeActive());
355 int width =
356 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().work_area().width();
358 EXPECT_EQ(w1->bounds().width(), w2->bounds().width());
359 EXPECT_GE(width / 2, w1->bounds().width());
361 // Toggle back to normal mode.
362 wm_api.wm()->ToggleSplitView();
363 EXPECT_FALSE(wm_api.GetSplitViewController()->IsSplitViewModeActive());
365 // w2 is the top window, it should be resized to max width and must be visible
366 // w1 should be hidden.
367 EXPECT_EQ(width, w2->bounds().width());
368 EXPECT_TRUE(w2->IsVisible());
369 EXPECT_FALSE(w1->IsVisible());
371 // Expect w1 to be visible and maximized when activated.
372 // TODO(oshima): To change to wm::ActivateWindow once the correct window state
373 // is implemented.
374 w1->Show();
375 EXPECT_EQ(width, w1->bounds().width());
376 EXPECT_TRUE(w1->IsVisible());
379 TEST_F(WindowManagerTest, OverviewModeFromSplitMode) {
380 test::WindowManagerImplTestApi wm_api;
382 aura::test::TestWindowDelegate delegate;
383 scoped_ptr<aura::Window> w1(CreateAndActivateWindow(&delegate));
384 scoped_ptr<aura::Window> w2(CreateAndActivateWindow(&delegate));
385 scoped_ptr<aura::Window> w3(CreateAndActivateWindow(&delegate));
387 // Get into split-view mode, and then turn on overview mode.
388 wm_api.GetSplitViewController()->ActivateSplitMode(nullptr, nullptr, nullptr);
389 WindowManager::Get()->EnterOverview();
390 EXPECT_TRUE(wm_api.GetSplitViewController()->IsSplitViewModeActive());
391 EXPECT_EQ(w3.get(), wm_api.GetSplitViewController()->left_window());
392 EXPECT_EQ(w2.get(), wm_api.GetSplitViewController()->right_window());
394 WindowOverviewModeDelegate* overview_delegate = wm_api.wm();
395 overview_delegate->OnSelectWindow(w1.get());
396 EXPECT_FALSE(wm_api.GetSplitViewController()->IsSplitViewModeActive());
397 EXPECT_TRUE(w1->IsVisible());
398 // Make sure the windows that were in split-view mode are hidden.
399 EXPECT_FALSE(w2->IsVisible());
400 EXPECT_FALSE(w3->IsVisible());
403 // Clicking a background in overview should not crash.
404 TEST_F(WindowManagerTest, ClickBackgroundInOverview) {
405 test::WindowManagerImplTestApi wm_api;
407 aura::test::TestWindowDelegate delegate;
408 scoped_ptr<aura::Window> w1(CreateAndActivateWindow(&delegate));
409 WindowManager::Get()->EnterOverview();
411 ui::test::EventGenerator generator(root_window());
412 generator.MoveMouseTo(1, 1);
413 generator.ClickLeftButton();
416 TEST_F(WindowManagerTest, CloseWindow) {
417 test::WindowManagerImplTestApi wm_api;
419 aura::test::TestWindowDelegate delegate;
420 scoped_ptr<aura::Window> w1(CreateAndActivateWindow(&delegate));
421 scoped_ptr<aura::Window> w2(CreateAndActivateWindow(&delegate));
422 scoped_ptr<aura::Window> w3(CreateAndActivateWindow(&delegate));
424 EXPECT_EQ(w3.get(),
425 wm_api.GetWindowListProvider()->GetWindowList().back());
426 EXPECT_TRUE(w3->IsVisible());
427 EXPECT_TRUE(wm::IsActiveWindow(w3.get()));
429 // Closes the front window (w3).
430 w3.reset();
431 EXPECT_EQ(w2.get(),
432 wm_api.GetWindowListProvider()->GetWindowList().back());
433 EXPECT_TRUE(w2->IsVisible());
434 EXPECT_TRUE(wm::IsActiveWindow(w2.get()));
436 // Closes a non-front window (w1).
437 w1.reset();
438 EXPECT_EQ(w2.get(),
439 wm_api.GetWindowListProvider()->GetWindowList().back());
440 EXPECT_TRUE(w2->IsVisible());
441 EXPECT_TRUE(wm::IsActiveWindow(w2.get()));
443 // Closes w2.
444 w2.reset();
445 EXPECT_TRUE(wm_api.GetWindowListProvider()->GetWindowList().empty());
448 TEST_F(WindowManagerTest, CloseWindowInSplitMode) {
449 test::WindowManagerImplTestApi wm_api;
451 aura::test::TestWindowDelegate delegate;
452 scoped_ptr<aura::Window> w1(CreateAndActivateWindow(&delegate));
453 scoped_ptr<aura::Window> w2(CreateAndActivateWindow(&delegate));
454 scoped_ptr<aura::Window> w3(CreateAndActivateWindow(&delegate));
455 scoped_ptr<aura::Window> w4(CreateAndActivateWindow(&delegate));
456 scoped_ptr<aura::Window> w5(CreateAndActivateWindow(&delegate));
458 // Get into split-view mode.
459 wm_api.GetSplitViewController()->ActivateSplitMode(NULL, NULL, NULL);
460 EXPECT_TRUE(wm_api.GetSplitViewController()->IsSplitViewModeActive());
461 EXPECT_EQ(w5.get(), wm_api.GetSplitViewController()->left_window());
462 EXPECT_EQ(w4.get(), wm_api.GetSplitViewController()->right_window());
463 EXPECT_TRUE(w5->IsVisible());
464 EXPECT_TRUE(w4->IsVisible());
465 EXPECT_TRUE(wm::IsActiveWindow(w5.get()));
467 // Closes the left window (w5).
468 w5.reset();
470 EXPECT_TRUE(wm_api.GetSplitViewController()->IsSplitViewModeActive());
471 EXPECT_EQ(w3.get(), wm_api.GetSplitViewController()->left_window());
472 EXPECT_EQ(w4.get(), wm_api.GetSplitViewController()->right_window());
473 EXPECT_TRUE(w4->IsVisible());
474 EXPECT_TRUE(w3->IsVisible());
475 EXPECT_TRUE(wm::IsActiveWindow(w4.get()));
477 // Closes the right window (w4).
478 w4.reset();
480 EXPECT_TRUE(wm_api.GetSplitViewController()->IsSplitViewModeActive());
481 EXPECT_EQ(w3.get(), wm_api.GetSplitViewController()->left_window());
482 EXPECT_EQ(w2.get(), wm_api.GetSplitViewController()->right_window());
483 EXPECT_TRUE(w3->IsVisible());
484 EXPECT_TRUE(w2->IsVisible());
485 EXPECT_TRUE(wm::IsActiveWindow(w3.get()));
487 // Closes a non-visible window (w1).
488 w1.reset();
490 EXPECT_TRUE(wm_api.GetSplitViewController()->IsSplitViewModeActive());
491 EXPECT_EQ(w3.get(), wm_api.GetSplitViewController()->left_window());
492 EXPECT_EQ(w2.get(), wm_api.GetSplitViewController()->right_window());
493 EXPECT_TRUE(w3->IsVisible());
494 EXPECT_TRUE(w2->IsVisible());
495 EXPECT_TRUE(wm::IsActiveWindow(w3.get()));
497 // Closes a non-visible window (w1).
498 w3.reset();
500 EXPECT_FALSE(wm_api.GetSplitViewController()->IsSplitViewModeActive());
501 EXPECT_TRUE(w2->IsVisible());
502 EXPECT_TRUE(wm::IsActiveWindow(w2.get()));
505 TEST_F(WindowManagerTest, CloseWindowFromOverview) {
506 aura::test::TestWindowDelegate delegate;
507 scoped_ptr<aura::Window> w1(CreateAndActivateWindow(&delegate));
508 scoped_ptr<aura::Window> w2(CreateAndActivateWindow(&delegate));
509 scoped_ptr<aura::Window> w3(CreateAndActivateWindow(&delegate));
510 EXPECT_FALSE(wm::IsActiveWindow(w1.get()));
511 EXPECT_FALSE(wm::IsActiveWindow(w2.get()));
512 EXPECT_TRUE(wm::IsActiveWindow(w3.get()));
514 WindowManager::Get()->EnterOverview();
516 ASSERT_TRUE(WindowManager::Get()->IsOverviewModeActive());
517 EXPECT_TRUE(w1->IsVisible());
518 EXPECT_TRUE(w2->IsVisible());
519 EXPECT_TRUE(w3->IsVisible());
520 EXPECT_FALSE(wm::IsActiveWindow(w1.get()));
521 EXPECT_FALSE(wm::IsActiveWindow(w2.get()));
522 EXPECT_FALSE(wm::IsActiveWindow(w3.get()));
524 w3.reset();
526 ASSERT_TRUE(WindowManager::Get()->IsOverviewModeActive());
527 EXPECT_FALSE(wm::IsActiveWindow(w1.get()));
528 EXPECT_FALSE(wm::IsActiveWindow(w2.get()));
529 EXPECT_TRUE(w1->IsVisible());
530 EXPECT_TRUE(w2->IsVisible());
532 w1.reset();
534 ASSERT_TRUE(WindowManager::Get()->IsOverviewModeActive());
535 EXPECT_FALSE(wm::IsActiveWindow(w2.get()));
536 EXPECT_TRUE(w2->IsVisible());
539 TEST_F(WindowManagerTest, CloseWindowInSplitModeFromOverview) {
540 test::WindowManagerImplTestApi wm_api;
542 aura::test::TestWindowDelegate delegate;
543 scoped_ptr<aura::Window> w1(CreateAndActivateWindow(&delegate));
544 scoped_ptr<aura::Window> w2(CreateAndActivateWindow(&delegate));
545 scoped_ptr<aura::Window> w3(CreateAndActivateWindow(&delegate));
546 scoped_ptr<aura::Window> w4(CreateAndActivateWindow(&delegate));
547 scoped_ptr<aura::Window> w5(CreateAndActivateWindow(&delegate));
549 // Get into split-view mode.
550 wm_api.GetSplitViewController()->ActivateSplitMode(NULL, NULL, NULL);
551 WindowManager::Get()->EnterOverview();
553 ASSERT_TRUE(WindowManager::Get()->IsOverviewModeActive());
554 EXPECT_TRUE(wm_api.GetSplitViewController()->IsSplitViewModeActive());
555 EXPECT_EQ(w5.get(), wm_api.GetSplitViewController()->left_window());
556 EXPECT_EQ(w4.get(), wm_api.GetSplitViewController()->right_window());
557 EXPECT_TRUE(w5->IsVisible());
558 EXPECT_TRUE(w4->IsVisible());
560 // Closes the left window (w5).
561 w5.reset();
563 ASSERT_TRUE(WindowManager::Get()->IsOverviewModeActive());
564 EXPECT_TRUE(wm_api.GetSplitViewController()->IsSplitViewModeActive());
565 EXPECT_EQ(w3.get(), wm_api.GetSplitViewController()->left_window());
566 EXPECT_EQ(w4.get(), wm_api.GetSplitViewController()->right_window());
567 EXPECT_TRUE(w4->IsVisible());
568 EXPECT_TRUE(w3->IsVisible());
570 // Closes the right window (w4).
571 w4.reset();
573 ASSERT_TRUE(WindowManager::Get()->IsOverviewModeActive());
574 EXPECT_TRUE(wm_api.GetSplitViewController()->IsSplitViewModeActive());
575 EXPECT_EQ(w3.get(), wm_api.GetSplitViewController()->left_window());
576 EXPECT_EQ(w2.get(), wm_api.GetSplitViewController()->right_window());
577 EXPECT_TRUE(w3->IsVisible());
578 EXPECT_TRUE(w2->IsVisible());
580 // Closes a non-visible window (w1).
581 w1.reset();
583 ASSERT_TRUE(WindowManager::Get()->IsOverviewModeActive());
584 EXPECT_TRUE(wm_api.GetSplitViewController()->IsSplitViewModeActive());
585 EXPECT_EQ(w3.get(), wm_api.GetSplitViewController()->left_window());
586 EXPECT_EQ(w2.get(), wm_api.GetSplitViewController()->right_window());
587 EXPECT_TRUE(w3->IsVisible());
588 EXPECT_TRUE(w2->IsVisible());
590 // Closes a non-visible window (w1).
591 w3.reset();
593 ASSERT_TRUE(WindowManager::Get()->IsOverviewModeActive());
594 EXPECT_FALSE(wm_api.GetSplitViewController()->IsSplitViewModeActive());
595 EXPECT_TRUE(w2->IsVisible());
598 } // namespace athena