Separate Simple Backend creation from initialization.
[chromium-blink-merge.git] / ash / wm / activation_controller_unittest.cc
blob33f6a078e00d5a85707fa350a2b423edf6a1fc5d
1 // Copyright (c) 2012 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 "ash/wm/activation_controller.h"
7 #include "ash/shell.h"
8 #include "ash/shell_window_ids.h"
9 #include "ash/test/ash_test_base.h"
10 #include "ash/test/test_activation_delegate.h"
11 #include "ash/wm/window_util.h"
12 #include "ui/aura/client/aura_constants.h"
13 #include "ui/aura/root_window.h"
14 #include "ui/aura/test/event_generator.h"
15 #include "ui/aura/test/test_window_delegate.h"
16 #include "ui/aura/test/test_windows.h"
17 #include "ui/compositor/layer.h"
18 #include "ui/views/corewm/corewm_switches.h"
20 #if defined(OS_WIN)
21 // Windows headers define macros for these function names which screw with us.
22 #if defined(CreateWindow)
23 #undef CreateWindow
24 #endif
25 #endif
27 namespace {
29 // Containers used for the tests.
30 const int kDefaultContainerID = -1; // Used to identify the default container.
31 const int c2 = ash::internal::kShellWindowId_AlwaysOnTopContainer;
32 const int c3 = ash::internal::kShellWindowId_LockScreenContainer;
34 } // namespace
36 namespace ash {
37 namespace test {
39 typedef test::AshTestBase ActivationControllerTest;
41 // Utilities for a set of tests that test
42 // ActivationController::GetTopmostWindowToActivate().
43 class GetTopmostWindowToActivateTest : public ActivationControllerTest {
44 public:
45 GetTopmostWindowToActivateTest() : ad_1_(false), ad_3_(false) {}
46 virtual ~GetTopmostWindowToActivateTest() {}
48 // Overridden from ActivationControllerTest:
49 virtual void SetUp() OVERRIDE {
50 ActivationControllerTest::SetUp();
51 CreateWindows();
53 virtual void TearDown() OVERRIDE {
54 DestroyWindows();
55 ActivationControllerTest::TearDown();
58 protected:
59 aura::Window* w1() { return w1_.get(); }
60 aura::Window* w2() { return w2_.get(); }
61 aura::Window* w3() { return w3_.get(); }
62 aura::Window* w4() { return w4_.get(); }
63 aura::Window* w5() { return w5_.get(); }
64 aura::Window* w6() { return w6_.get(); }
65 aura::Window* w7() { return w7_.get(); }
67 void DestroyWindow2() {
68 w2_.reset();
71 private:
72 void CreateWindows() {
73 // Create four windows, the first and third are not activatable, the second
74 // and fourth are.
75 w1_.reset(CreateWindowInShell(1, &ad_1_));
76 w2_.reset(CreateWindowInShell(2, &ad_2_));
77 w3_.reset(CreateWindowInShell(3, &ad_3_));
78 w4_.reset(CreateWindowInShell(4, &ad_4_));
79 w5_.reset(CreateWindowWithID(5, &ad_5_, c2));
80 w6_.reset(CreateWindowWithID(6, &ad_6_, c2));
81 w7_.reset(CreateWindowWithID(7, &ad_7_, c3));
84 aura::Window* CreateWindowInShell(int id,
85 TestActivationDelegate* delegate) {
86 aura::Window* window = CreateTestWindowInShellWithDelegate(
87 &delegate_,
88 id,
89 gfx::Rect());
90 delegate->SetWindow(window);
91 return window;
94 aura::Window* CreateWindowWithID(int id,
95 TestActivationDelegate* delegate,
96 int container_id) {
97 aura::Window* parent =
98 Shell::GetContainer(Shell::GetPrimaryRootWindow(), container_id);
99 aura::Window* window = aura::test::CreateTestWindowWithDelegate(
100 &delegate_,
102 gfx::Rect(),
103 parent);
104 delegate->SetWindow(window);
105 return window;
108 void DestroyWindows() {
109 w1_.reset();
110 w2_.reset();
111 w3_.reset();
112 w4_.reset();
113 w5_.reset();
114 w6_.reset();
115 w7_.reset();
118 aura::test::TestWindowDelegate delegate_;
119 TestActivationDelegate ad_1_;
120 TestActivationDelegate ad_2_;
121 TestActivationDelegate ad_3_;
122 TestActivationDelegate ad_4_;
123 TestActivationDelegate ad_5_;
124 TestActivationDelegate ad_6_;
125 TestActivationDelegate ad_7_;
126 scoped_ptr<aura::Window> w1_; // Non-activatable.
127 scoped_ptr<aura::Window> w2_; // Activatable.
128 scoped_ptr<aura::Window> w3_; // Non-activatable.
129 scoped_ptr<aura::Window> w4_; // Activatable.
130 scoped_ptr<aura::Window> w5_; // Activatable - Always on top.
131 scoped_ptr<aura::Window> w6_; // Activatable - Always on top.
132 scoped_ptr<aura::Window> w7_; // Activatable - Lock screen window.
134 DISALLOW_COPY_AND_ASSIGN(GetTopmostWindowToActivateTest);
137 // Hiding the active window should activate the next valid activatable window.
138 TEST_F(GetTopmostWindowToActivateTest, HideActivatesNext) {
139 wm::ActivateWindow(w2());
140 EXPECT_TRUE(wm::IsActiveWindow(w2()));
142 w2()->Hide();
143 EXPECT_TRUE(wm::IsActiveWindow(w4()));
146 // Destroying the active window should activate the next valid activatable
147 // window.
148 TEST_F(GetTopmostWindowToActivateTest, DestroyActivatesNext) {
149 wm::ActivateWindow(w2());
150 EXPECT_TRUE(wm::IsActiveWindow(w2()));
152 DestroyWindow2();
153 EXPECT_EQ(NULL, w2());
154 EXPECT_TRUE(wm::IsActiveWindow(w4()));
157 // Deactivating the active window should activate the next valid activatable
158 // window.
159 TEST_F(GetTopmostWindowToActivateTest, DeactivateActivatesNext) {
160 wm::ActivateWindow(w2());
161 EXPECT_TRUE(wm::IsActiveWindow(w2()));
163 wm::DeactivateWindow(w2());
164 EXPECT_TRUE(wm::IsActiveWindow(w4()));
167 // Test that hiding a window in a higher container will activate another window
168 // in that container.
169 TEST_F(GetTopmostWindowToActivateTest, HideActivatesSameContainer) {
170 wm::ActivateWindow(w6());
171 EXPECT_TRUE(wm::IsActiveWindow(w6()));
173 w6()->Hide();
174 EXPECT_TRUE(wm::IsActiveWindow(w5()));
177 // Test that hiding the lock window will activate a window from the next highest
178 // container.
179 TEST_F(GetTopmostWindowToActivateTest, UnlockActivatesNextHighestContainer) {
180 wm::ActivateWindow(w7());
181 EXPECT_TRUE(wm::IsActiveWindow(w7()));
183 w7()->Hide();
184 EXPECT_TRUE(wm::IsActiveWindow(w6()));
187 // Test that hiding a window in a higher container with no other windows will
188 // activate a window in a lower container.
189 TEST_F(GetTopmostWindowToActivateTest, HideActivatesNextHighestContainer) {
190 w5()->Hide();
191 wm::ActivateWindow(w6());
192 EXPECT_TRUE(wm::IsActiveWindow(w6()));
194 w6()->Hide();
195 EXPECT_TRUE(wm::IsActiveWindow(w4()));
198 // Test if the clicking on a menu picks the transient parent as activatable
199 // window.
200 TEST_F(ActivationControllerTest, ClickOnMenu) {
201 aura::test::TestWindowDelegate wd;
202 TestActivationDelegate ad1;
203 TestActivationDelegate ad2(false);
205 scoped_ptr<aura::Window> w1(CreateTestWindowInShellWithDelegate(
206 &wd, 1, gfx::Rect(100, 100)));
207 ad1.SetWindow(w1.get());
208 EXPECT_EQ(NULL, wm::GetActiveWindow());
210 // Clicking on an activatable window activates the window.
211 aura::test::EventGenerator& generator(GetEventGenerator());
212 generator.MoveMouseToCenterOf(w1.get());
213 generator.ClickLeftButton();
214 EXPECT_TRUE(wm::IsActiveWindow(w1.get()));
216 // Creates a menu that covers the transient parent.
217 scoped_ptr<aura::Window> menu(CreateTestWindowInShellWithDelegateAndType(
218 &wd, aura::client::WINDOW_TYPE_MENU, 2, gfx::Rect(100, 100)));
219 ad2.SetWindow(menu.get());
220 w1->AddTransientChild(menu.get());
222 // Clicking on a menu whose transient parent is active window shouldn't
223 // change the active window.
224 generator.ClickLeftButton();
225 EXPECT_TRUE(wm::IsActiveWindow(w1.get()));
228 // Various assertions for activating/deactivating.
229 TEST_F(ActivationControllerTest, Deactivate) {
230 aura::test::TestWindowDelegate d1;
231 aura::test::TestWindowDelegate d2;
232 scoped_ptr<aura::Window> w1(CreateTestWindowInShellWithDelegate(
233 &d1, 1, gfx::Rect()));
234 scoped_ptr<aura::Window> w2(CreateTestWindowInShellWithDelegate(
235 &d2, 2, gfx::Rect()));
236 aura::Window* parent = w1->parent();
237 parent->Show();
238 ASSERT_TRUE(parent);
239 ASSERT_EQ(2u, parent->children().size());
240 // Activate w2 and make sure it's active and frontmost.
241 wm::ActivateWindow(w2.get());
242 EXPECT_TRUE(wm::IsActiveWindow(w2.get()));
243 EXPECT_FALSE(wm::IsActiveWindow(w1.get()));
244 EXPECT_EQ(w2.get(), parent->children()[1]);
246 // Activate w1 and make sure it's active and frontmost.
247 wm::ActivateWindow(w1.get());
248 EXPECT_TRUE(wm::IsActiveWindow(w1.get()));
249 EXPECT_FALSE(wm::IsActiveWindow(w2.get()));
250 EXPECT_EQ(w1.get(), parent->children()[1]);
252 // Deactivate w1 and make sure w2 becomes active and frontmost.
253 wm::DeactivateWindow(w1.get());
254 EXPECT_FALSE(wm::IsActiveWindow(w1.get()));
255 EXPECT_TRUE(wm::IsActiveWindow(w2.get()));
256 EXPECT_EQ(w2.get(), parent->children()[1]);
259 // Verifies that when WindowDelegate::OnLostActive is invoked the window is not
260 // active.
261 TEST_F(ActivationControllerTest, NotActiveInLostActive) {
262 // TODO(beng): remove this test once the new focus controller is on.
263 if (views::corewm::UseFocusController())
264 return;
266 TestActivationDelegate ad1;
267 aura::test::TestWindowDelegate wd;
268 scoped_ptr<aura::Window> w1(CreateTestWindowInShellWithDelegate(
269 &wd, 1, gfx::Rect(10, 10, 50, 50)));
270 ad1.SetWindow(w1.get());
271 scoped_ptr<aura::Window> w2(CreateTestWindowInShellWithDelegate(
272 NULL, 1, gfx::Rect(10, 10, 50, 50)));
274 // Activate w1.
275 wm::ActivateWindow(w1.get());
276 EXPECT_TRUE(wm::IsActiveWindow(w1.get()));
277 EXPECT_EQ(1, ad1.activated_count());
278 // Should not have gotten a OnLostActive yet.
279 EXPECT_EQ(0, ad1.lost_active_count());
281 // Deactivate the active window.
282 wm::DeactivateWindow(w1.get());
283 EXPECT_FALSE(wm::IsActiveWindow(w1.get()));
284 EXPECT_EQ(1, ad1.lost_active_count());
285 EXPECT_FALSE(ad1.window_was_active());
287 // Activate w1 again. w1 should have gotten OnActivated.
288 wm::ActivateWindow(w1.get());
289 EXPECT_EQ(2, ad1.activated_count());
290 EXPECT_EQ(1, ad1.lost_active_count());
292 // Reset the delegate.
293 ad1.Clear();
295 // Now activate another window.
296 wm::ActivateWindow(w2.get());
298 // Should have gotten OnLostActive and w1 shoouldn't have been
299 // active window in OnLostActive.
300 EXPECT_EQ(0, ad1.activated_count());
301 EXPECT_EQ(1, ad1.lost_active_count());
302 EXPECT_FALSE(ad1.window_was_active());
305 // Verifies that focusing another window or its children causes it to become
306 // active.
307 TEST_F(ActivationControllerTest, FocusTriggersActivation) {
308 aura::test::TestWindowDelegate wd;
309 scoped_ptr<aura::Window> w1(CreateTestWindowInShellWithDelegate(
310 &wd, -1, gfx::Rect(50, 50)));
311 scoped_ptr<aura::Window> w2(CreateTestWindowInShellWithDelegate(
312 &wd, -2, gfx::Rect(50, 50)));
313 scoped_ptr<aura::Window> w21(aura::test::CreateTestWindowWithDelegate(
314 &wd, -21, gfx::Rect(50, 50), w2.get()));
316 wm::ActivateWindow(w1.get());
317 EXPECT_TRUE(wm::IsActiveWindow(w1.get()));
318 EXPECT_TRUE(w1->HasFocus());
320 w2->Focus();
321 EXPECT_TRUE(wm::IsActiveWindow(w2.get()));
322 EXPECT_TRUE(w2->HasFocus());
324 wm::ActivateWindow(w1.get());
325 EXPECT_TRUE(wm::IsActiveWindow(w1.get()));
326 EXPECT_TRUE(w1->HasFocus());
328 w21->Focus();
329 EXPECT_TRUE(wm::IsActiveWindow(w2.get()));
330 EXPECT_TRUE(w21->HasFocus());
333 // Verifies that we prevent all attempts to focus a child of a non-activatable
334 // window from claiming focus to that window.
335 TEST_F(ActivationControllerTest, PreventFocusToNonActivatableWindow) {
336 aura::test::TestWindowDelegate wd;
337 scoped_ptr<aura::Window> w1(CreateTestWindowInShellWithDelegate(
338 &wd, -1, gfx::Rect(50, 50)));
339 // The RootWindow is a non-activatable parent.
340 scoped_ptr<aura::Window> w2(aura::test::CreateTestWindowWithDelegate(
341 &wd, -2, gfx::Rect(50, 50), Shell::GetPrimaryRootWindow()));
342 scoped_ptr<aura::Window> w21(aura::test::CreateTestWindowWithDelegate(
343 &wd, -21, gfx::Rect(50, 50), w2.get()));
345 wm::ActivateWindow(w1.get());
346 EXPECT_TRUE(wm::IsActiveWindow(w1.get()));
347 EXPECT_TRUE(w1->HasFocus());
349 // Try activating |w2|. It's not a child of an activatable container, so it
350 // should neither be activated nor get focus.
351 wm::ActivateWindow(w2.get());
352 EXPECT_FALSE(wm::IsActiveWindow(w2.get()));
353 EXPECT_FALSE(w2->HasFocus());
354 EXPECT_TRUE(wm::IsActiveWindow(w1.get()));
355 EXPECT_TRUE(w1->HasFocus());
357 // Try focusing |w2|. Same rules apply.
358 w2->Focus();
359 EXPECT_FALSE(wm::IsActiveWindow(w2.get()));
360 EXPECT_FALSE(w2->HasFocus());
361 EXPECT_TRUE(wm::IsActiveWindow(w1.get()));
362 EXPECT_TRUE(w1->HasFocus());
364 // Try focusing |w21|. Same rules apply.
365 EXPECT_FALSE(wm::IsActiveWindow(w2.get()));
366 EXPECT_FALSE(w21->HasFocus());
367 EXPECT_TRUE(wm::IsActiveWindow(w1.get()));
368 EXPECT_TRUE(w1->HasFocus());
371 TEST_F(ActivationControllerTest, CanActivateWindowIteselfTest)
373 aura::test::TestWindowDelegate wd;
375 // Normal Window
376 scoped_ptr<aura::Window> w1(CreateTestWindowInShellWithDelegate(
377 &wd, -1, gfx::Rect(50, 50)));
378 EXPECT_TRUE(wm::CanActivateWindow(w1.get()));
380 // The RootWindow is a non-activatable parent.
381 scoped_ptr<aura::Window> w2(aura::test::CreateTestWindowWithDelegate(
382 &wd, -2, gfx::Rect(50, 50), Shell::GetPrimaryRootWindow()));
383 scoped_ptr<aura::Window> w21(aura::test::CreateTestWindowWithDelegate(
384 &wd, -21, gfx::Rect(50, 50), w2.get()));
385 EXPECT_FALSE(wm::CanActivateWindow(w2.get()));
386 EXPECT_FALSE(wm::CanActivateWindow(w21.get()));
388 // The window has a transient child.
389 scoped_ptr<aura::Window> w3(CreateTestWindowInShellWithDelegate(
390 &wd, -3, gfx::Rect(50, 50)));
391 scoped_ptr<aura::Window> w31(CreateTestWindowInShellWithDelegate(
392 &wd, -31, gfx::Rect(50, 50)));
393 w3->AddTransientChild(w31.get());
394 EXPECT_TRUE(wm::CanActivateWindow(w3.get()));
395 EXPECT_TRUE(wm::CanActivateWindow(w31.get()));
397 // The window has a transient window-modal child.
398 scoped_ptr<aura::Window> w4(CreateTestWindowInShellWithDelegate(
399 &wd, -4, gfx::Rect(50, 50)));
400 scoped_ptr<aura::Window> w41(CreateTestWindowInShellWithDelegate(
401 &wd, -41, gfx::Rect(50, 50)));
402 w4->AddTransientChild(w41.get());
403 w41->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_WINDOW);
404 EXPECT_FALSE(wm::CanActivateWindow(w4.get()));
405 EXPECT_TRUE(wm::CanActivateWindow(w41.get()));
407 // The window has a transient system-modal child.
408 scoped_ptr<aura::Window> w5(CreateTestWindowInShellWithDelegate(
409 &wd, -5, gfx::Rect(50, 50)));
410 scoped_ptr<aura::Window> w51(CreateTestWindowInShellWithDelegate(
411 &wd, -51, gfx::Rect(50, 50)));
412 w5->AddTransientChild(w51.get());
413 w51->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_SYSTEM);
414 EXPECT_FALSE(wm::CanActivateWindow(w5.get()));
415 EXPECT_TRUE(wm::CanActivateWindow(w51.get()));
418 // Verifies code in ActivationController::OnWindowVisibilityChanged() that keeps
419 // hiding windows layers stacked above the newly active window while they
420 // animate away.
421 // TODO(beng): This test now duplicates a test in:
422 // ui/views/corewm/focus_controller_unittest.cc
423 // ...and can be removed once the new focus controller is enabled.
424 TEST_F(ActivationControllerTest, AnimateHideMaintainsStacking) {
425 aura::test::TestWindowDelegate wd;
426 scoped_ptr<aura::Window> w1(CreateTestWindowInShellWithDelegate(
427 &wd, -1, gfx::Rect(50, 50, 50, 50)));
428 scoped_ptr<aura::Window> w2(CreateTestWindowInShellWithDelegate(
429 &wd, -2, gfx::Rect(75, 75, 50, 50)));
430 wm::ActivateWindow(w2.get());
431 EXPECT_TRUE(wm::IsActiveWindow(w2.get()));
432 w2->Hide();
433 typedef std::vector<ui::Layer*> Layers;
434 const Layers& children = w1->parent()->layer()->children();
435 Layers::const_iterator w1_iter =
436 std::find(children.begin(), children.end(), w1->layer());
437 Layers::const_iterator w2_iter =
438 std::find(children.begin(), children.end(), w2->layer());
439 EXPECT_TRUE(w2_iter > w1_iter);
442 // Verifies that activating a minimized window would restore it.
443 TEST_F(ActivationControllerTest, ActivateMinimizedWindow) {
444 aura::test::TestWindowDelegate wd;
445 scoped_ptr<aura::Window> w1(CreateTestWindowInShellWithDelegate(
446 &wd, -1, gfx::Rect(50, 50)));
448 wm::MinimizeWindow(w1.get());
449 EXPECT_TRUE(wm::IsWindowMinimized(w1.get()));
451 wm::ActivateWindow(w1.get());
452 EXPECT_TRUE(wm::IsActiveWindow(w1.get()));
453 EXPECT_FALSE(wm::IsWindowMinimized(w1.get()));
456 // Verifies that a minimized window would not be automatically activated as
457 // a replacement active window.
458 TEST_F(ActivationControllerTest, NoAutoActivateMinimizedWindow) {
459 aura::test::TestWindowDelegate wd;
460 scoped_ptr<aura::Window> w1(CreateTestWindowInShellWithDelegate(
461 &wd, -1, gfx::Rect(50, 50, 50, 50)));
462 scoped_ptr<aura::Window> w2(CreateTestWindowInShellWithDelegate(
463 &wd, -2, gfx::Rect(75, 75, 50, 50)));
465 wm::MinimizeWindow(w1.get());
466 EXPECT_TRUE(wm::IsWindowMinimized(w1.get()));
468 wm::ActivateWindow(w2.get());
469 EXPECT_TRUE(wm::IsActiveWindow(w2.get()));
471 w2->Hide();
473 EXPECT_FALSE(wm::IsActiveWindow(w1.get()));
474 EXPECT_TRUE(wm::IsWindowMinimized(w1.get()));
477 // Verifies that a window with a hidden layer can be activated.
478 TEST_F(ActivationControllerTest, ActivateWithHiddenLayer) {
479 aura::test::TestWindowDelegate wd;
480 scoped_ptr<aura::Window> w1(CreateTestWindowInShellWithDelegate(
481 &wd, -1, gfx::Rect(50, 50, 50, 50)));
483 EXPECT_TRUE(wm::CanActivateWindow(w1.get()));
484 w1->layer()->SetVisible(false);
485 EXPECT_TRUE(wm::CanActivateWindow(w1.get()));
488 // Verifies that a unrelated window cannot be activated when in a system modal
489 // dialog.
490 TEST_F(ActivationControllerTest, DontActivateWindowWhenInSystemModalDialog) {
491 scoped_ptr<aura::Window> normal_window(CreateTestWindowInShellWithId(-1));
492 EXPECT_FALSE(wm::IsActiveWindow(normal_window.get()));
493 wm::ActivateWindow(normal_window.get());
494 EXPECT_TRUE(wm::IsActiveWindow(normal_window.get()));
496 // Create and activate a system modal window.
497 aura::Window* modal_container =
498 ash::Shell::GetContainer(
499 Shell::GetPrimaryRootWindow(),
500 ash::internal::kShellWindowId_SystemModalContainer);
501 scoped_ptr<aura::Window> modal_window(
502 aura::test::CreateTestWindowWithId(-2, modal_container));
503 modal_window->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_SYSTEM);
504 wm::ActivateWindow(modal_window.get());
505 EXPECT_TRUE(ash::Shell::GetInstance()->IsSystemModalWindowOpen());
506 EXPECT_FALSE(wm::IsActiveWindow(normal_window.get()));
507 EXPECT_TRUE(wm::IsActiveWindow(modal_window.get()));
509 // We try to but cannot activate the normal window while we
510 // have the system modal window.
511 wm::ActivateWindow(normal_window.get());
512 EXPECT_TRUE(ash::Shell::GetInstance()->IsSystemModalWindowOpen());
513 EXPECT_FALSE(wm::IsActiveWindow(normal_window.get()));
514 EXPECT_TRUE(wm::IsActiveWindow(modal_window.get()));
516 modal_window->Hide();
517 modal_window.reset();
518 EXPECT_FALSE(ash::Shell::GetInstance()->IsSystemModalWindowOpen());
519 EXPECT_TRUE(wm::IsActiveWindow(normal_window.get()));
522 // Verifies that a lock window can get focus even if lock
523 // container is not visible (e.g. before animating it).
524 TEST_F(ActivationControllerTest, ActivateLockScreen) {
525 aura::Window* lock_container =
526 Shell::GetContainer(Shell::GetPrimaryRootWindow(), c3);
527 aura::test::TestWindowDelegate wd;
528 scoped_ptr<aura::Window> w1(aura::test::CreateTestWindowWithDelegate(
529 &wd, -1, gfx::Rect(50, 50, 50, 50), lock_container));
531 lock_container->layer()->SetVisible(false);
532 w1->Focus();
533 EXPECT_TRUE(w1->HasFocus());
536 #if defined(OS_WIN)
537 // Multiple displays are not supported on Windows Ash. http://crbug.com/165962
538 #define MAYBE_NextActiveWindowOnMultipleDisplays \
539 DISABLED_NextActiveWindowOnMultipleDisplays
540 #else
541 #define MAYBE_NextActiveWindowOnMultipleDisplays \
542 NextActiveWindowOnMultipleDisplays
543 #endif
545 // Verifies that a next active window is chosen from current
546 // active display.
547 TEST_F(ActivationControllerTest, MAYBE_NextActiveWindowOnMultipleDisplays) {
548 UpdateDisplay("300x300,300x300");
549 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
551 scoped_ptr<aura::Window> w1_d1(CreateTestWindowInShellWithBounds(
552 gfx::Rect(10, 10, 100, 100)));
553 scoped_ptr<aura::Window> w2_d1(CreateTestWindowInShellWithBounds(
554 gfx::Rect(20, 20, 100, 100)));
556 EXPECT_EQ(root_windows[0], w1_d1->GetRootWindow());
557 EXPECT_EQ(root_windows[0], w2_d1->GetRootWindow());
559 scoped_ptr<aura::Window> w3_d2(CreateTestWindowInShellWithBounds(
560 gfx::Rect(310, 10, 100, 100)));
561 scoped_ptr<aura::Window> w4_d2(CreateTestWindowInShellWithBounds(
562 gfx::Rect(320, 20, 100, 100)));
563 EXPECT_EQ(root_windows[1], w3_d2->GetRootWindow());
564 EXPECT_EQ(root_windows[1], w4_d2->GetRootWindow());
566 aura::client::ActivationClient* client =
567 aura::client::GetActivationClient(root_windows[0]);
568 client->ActivateWindow(w1_d1.get());
569 EXPECT_EQ(w1_d1.get(), client->GetActiveWindow());
571 w1_d1.reset();
572 EXPECT_EQ(w2_d1.get(), client->GetActiveWindow());
574 client->ActivateWindow(w3_d2.get());
575 EXPECT_EQ(w3_d2.get(), client->GetActiveWindow());
576 w3_d2.reset();
577 EXPECT_EQ(w4_d2.get(), client->GetActiveWindow());
580 } // namespace test
581 } // namespace ash