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 "ui/views/corewm/window_modality_controller.h"
8 #include "ash/test/ash_test_base.h"
9 #include "ash/wm/window_util.h"
10 #include "ui/aura/client/aura_constants.h"
11 #include "ui/aura/test/event_generator.h"
12 #include "ui/aura/test/test_window_delegate.h"
13 #include "ui/aura/test/test_windows.h"
14 #include "ui/aura/window.h"
15 #include "ui/aura/window_event_dispatcher.h"
16 #include "ui/base/ui_base_types.h"
17 #include "ui/views/corewm/window_util.h"
18 #include "ui/views/test/capture_tracking_view.h"
19 #include "ui/views/test/child_modal_window.h"
20 #include "ui/views/widget/widget.h"
25 typedef test::AshTestBase WindowModalityControllerTest
;
29 bool ValidateStacking(aura::Window
* parent
, int ids
[], int count
) {
30 for (int i
= 0; i
< count
; ++i
) {
31 if (parent
->children().at(i
)->id() != ids
[i
])
39 // Creates three windows, w1, w11, and w12. w11 is a non-modal transient, w12 is
42 // - it should be possible to activate w12 even when w11 is open.
43 // - activating w1 activates w12 and updates stacking order appropriately.
44 // - closing a window passes focus up the stack.
45 TEST_F(WindowModalityControllerTest
, BasicActivation
) {
46 aura::test::TestWindowDelegate d
;
47 scoped_ptr
<aura::Window
> w1(
48 CreateTestWindowInShellWithDelegate(&d
, -1, gfx::Rect()));
49 scoped_ptr
<aura::Window
> w11(
50 CreateTestWindowInShellWithDelegate(&d
, -11, gfx::Rect()));
51 scoped_ptr
<aura::Window
> w12(
52 CreateTestWindowInShellWithDelegate(&d
, -12, gfx::Rect()));
54 views::corewm::AddTransientChild(w1
.get(), w11
.get());
55 wm::ActivateWindow(w1
.get());
56 EXPECT_TRUE(wm::IsActiveWindow(w1
.get()));
57 wm::ActivateWindow(w11
.get());
58 EXPECT_TRUE(wm::IsActiveWindow(w11
.get()));
60 w12
->SetProperty(aura::client::kModalKey
, ui::MODAL_TYPE_WINDOW
);
61 views::corewm::AddTransientChild(w1
.get(), w12
.get());
62 wm::ActivateWindow(w12
.get());
63 EXPECT_TRUE(wm::IsActiveWindow(w12
.get()));
65 wm::ActivateWindow(w11
.get());
66 EXPECT_TRUE(wm::IsActiveWindow(w11
.get()));
68 int check1
[] = { -1, -12, -11 };
69 EXPECT_TRUE(ValidateStacking(w1
->parent(), check1
, arraysize(check1
)));
71 wm::ActivateWindow(w1
.get());
72 EXPECT_TRUE(wm::IsActiveWindow(w12
.get()));
73 // Transient children are always stacked above their transient parent, which
74 // is why this order is not -11, -1, -12.
75 int check2
[] = { -1, -11, -12 };
76 EXPECT_TRUE(ValidateStacking(w1
->parent(), check2
, arraysize(check2
)));
79 EXPECT_TRUE(wm::IsActiveWindow(w11
.get()));
81 EXPECT_TRUE(wm::IsActiveWindow(w1
.get()));
84 // Create two toplevel windows w1 and w2, and nest two modals w11 and w111 below
87 // - activating w1 while w11/w111 is showing always activates most deeply nested
89 // - closing a window passes focus up the stack.
90 TEST_F(WindowModalityControllerTest
, NestedModals
) {
91 aura::test::TestWindowDelegate d
;
92 scoped_ptr
<aura::Window
> w1(
93 CreateTestWindowInShellWithDelegate(&d
, -1, gfx::Rect()));
94 scoped_ptr
<aura::Window
> w11(
95 CreateTestWindowInShellWithDelegate(&d
, -11, gfx::Rect()));
96 scoped_ptr
<aura::Window
> w111(
97 CreateTestWindowInShellWithDelegate(&d
, -111, gfx::Rect()));
98 scoped_ptr
<aura::Window
> w2(
99 CreateTestWindowInShellWithDelegate(&d
, -2, gfx::Rect()));
101 views::corewm::AddTransientChild(w1
.get(), w11
.get());
102 views::corewm::AddTransientChild(w11
.get(), w111
.get());
104 wm::ActivateWindow(w1
.get());
105 EXPECT_TRUE(wm::IsActiveWindow(w1
.get()));
106 wm::ActivateWindow(w2
.get());
107 EXPECT_TRUE(wm::IsActiveWindow(w2
.get()));
110 w11
->SetProperty(aura::client::kModalKey
, ui::MODAL_TYPE_WINDOW
);
111 w111
->SetProperty(aura::client::kModalKey
, ui::MODAL_TYPE_WINDOW
);
113 wm::ActivateWindow(w1
.get());
114 EXPECT_TRUE(wm::IsActiveWindow(w111
.get()));
115 int check1
[] = { -2, -1, -11, -111 };
116 EXPECT_TRUE(ValidateStacking(w1
->parent(), check1
, arraysize(check1
)));
118 wm::ActivateWindow(w11
.get());
119 EXPECT_TRUE(wm::IsActiveWindow(w111
.get()));
120 EXPECT_TRUE(ValidateStacking(w1
->parent(), check1
, arraysize(check1
)));
122 wm::ActivateWindow(w111
.get());
123 EXPECT_TRUE(wm::IsActiveWindow(w111
.get()));
124 EXPECT_TRUE(ValidateStacking(w1
->parent(), check1
, arraysize(check1
)));
126 wm::ActivateWindow(w2
.get());
127 EXPECT_TRUE(wm::IsActiveWindow(w2
.get()));
128 int check2
[] = { -1, -11, -111, -2 };
129 EXPECT_TRUE(ValidateStacking(w1
->parent(), check2
, arraysize(check2
)));
132 EXPECT_TRUE(wm::IsActiveWindow(w111
.get()));
134 EXPECT_TRUE(wm::IsActiveWindow(w11
.get()));
136 EXPECT_TRUE(wm::IsActiveWindow(w1
.get()));
139 // Create two toplevel windows w1 and w2, and nest two modals w11 and w111 below
142 // - destroying w11 while w111 is focused activates w1.
143 TEST_F(WindowModalityControllerTest
, NestedModalsOuterClosed
) {
144 aura::test::TestWindowDelegate d
;
145 scoped_ptr
<aura::Window
> w1(
146 CreateTestWindowInShellWithDelegate(&d
, -1, gfx::Rect()));
147 scoped_ptr
<aura::Window
> w11(
148 CreateTestWindowInShellWithDelegate(&d
, -11, gfx::Rect()));
149 // |w111| will be owned and deleted by |w11|.
151 CreateTestWindowInShellWithDelegate(&d
, -111, gfx::Rect());
152 scoped_ptr
<aura::Window
> w2(
153 CreateTestWindowInShellWithDelegate(&d
, -2, gfx::Rect()));
155 views::corewm::AddTransientChild(w1
.get(), w11
.get());
156 views::corewm::AddTransientChild(w11
.get(), w111
);
158 wm::ActivateWindow(w1
.get());
159 EXPECT_TRUE(wm::IsActiveWindow(w1
.get()));
160 wm::ActivateWindow(w2
.get());
161 EXPECT_TRUE(wm::IsActiveWindow(w2
.get()));
164 w11
->SetProperty(aura::client::kModalKey
, ui::MODAL_TYPE_WINDOW
);
165 w111
->SetProperty(aura::client::kModalKey
, ui::MODAL_TYPE_WINDOW
);
167 wm::ActivateWindow(w1
.get());
168 EXPECT_TRUE(wm::IsActiveWindow(w111
));
171 EXPECT_TRUE(wm::IsActiveWindow(w11
.get()));
173 // TODO(oshima): Re-showing doesn't set the focus back to
174 // modal window. There is no such use case right now, but it
178 EXPECT_TRUE(wm::IsActiveWindow(w1
.get()));
181 // Modality also prevents events from being passed to the transient parent.
182 TEST_F(WindowModalityControllerTest
, Events
) {
183 aura::test::TestWindowDelegate d
;
184 scoped_ptr
<aura::Window
> w1(CreateTestWindowInShellWithDelegate(&d
, -1,
185 gfx::Rect(0, 0, 100, 100)));
186 scoped_ptr
<aura::Window
> w11(CreateTestWindowInShellWithDelegate(&d
, -11,
187 gfx::Rect(20, 20, 50, 50)));
189 views::corewm::AddTransientChild(w1
.get(), w11
.get());
192 // Clicking a point within w1 should activate that window.
193 aura::test::EventGenerator
generator(Shell::GetPrimaryRootWindow(),
195 generator
.ClickLeftButton();
196 EXPECT_TRUE(wm::IsActiveWindow(w1
.get()));
199 w11
->SetProperty(aura::client::kModalKey
, ui::MODAL_TYPE_WINDOW
);
202 // Clicking a point within w1 should activate w11.
203 aura::test::EventGenerator
generator(Shell::GetPrimaryRootWindow(),
205 generator
.ClickLeftButton();
206 EXPECT_TRUE(wm::IsActiveWindow(w11
.get()));
210 // Creates windows w1 and non activatiable child w11. Creates transient window
211 // w2 and adds it as a transeint child of w1. Ensures that w2 is parented to
212 // the parent of w1, and that GetModalTransient(w11) returns w2.
213 TEST_F(WindowModalityControllerTest
, GetModalTransient
) {
214 aura::test::TestWindowDelegate d
;
215 scoped_ptr
<aura::Window
> w1(
216 CreateTestWindowInShellWithDelegate(&d
, -1, gfx::Rect()));
217 scoped_ptr
<aura::Window
> w11(
218 aura::test::CreateTestWindowWithDelegate(&d
, -11, gfx::Rect(), w1
.get()));
219 scoped_ptr
<aura::Window
> w2(
220 CreateTestWindowInShellWithDelegate(&d
, -2, gfx::Rect()));
221 w2
->SetProperty(aura::client::kModalKey
, ui::MODAL_TYPE_WINDOW
);
224 wt
= views::corewm::GetModalTransient(w1
.get());
225 ASSERT_EQ(static_cast<aura::Window
*>(NULL
), wt
);
227 // Parent w2 to w1. It should get parented to the parent of w1.
228 views::corewm::AddTransientChild(w1
.get(), w2
.get());
229 ASSERT_EQ(2U, w1
->parent()->children().size());
230 EXPECT_EQ(-2, w1
->parent()->children().at(1)->id());
232 // Request the modal transient window for w1, it should be w2.
233 wt
= views::corewm::GetModalTransient(w1
.get());
234 ASSERT_NE(static_cast<aura::Window
*>(NULL
), wt
);
235 EXPECT_EQ(-2, wt
->id());
237 // Request the modal transient window for w11, it should also be w2.
238 wt
= views::corewm::GetModalTransient(w11
.get());
239 ASSERT_NE(static_cast<aura::Window
*>(NULL
), wt
);
240 EXPECT_EQ(-2, wt
->id());
243 // Verifies we generate a capture lost when showing a modal window.
244 TEST_F(WindowModalityControllerTest
, ChangeCapture
) {
245 views::Widget
* widget
= views::Widget::CreateWindowWithContext(
246 NULL
, Shell::GetPrimaryRootWindow());
247 scoped_ptr
<aura::Window
> widget_window(widget
->GetNativeView());
248 views::test::CaptureTrackingView
* view
= new views::test::CaptureTrackingView
;
249 widget
->client_view()->AddChildView(view
);
250 widget
->SetBounds(gfx::Rect(0, 0, 200, 200));
251 view
->SetBoundsRect(widget
->client_view()->GetLocalBounds());
254 gfx::Point
center(view
->width() / 2, view
->height() / 2);
255 views::View::ConvertPointToScreen(view
, ¢er
);
256 aura::test::EventGenerator
generator(Shell::GetPrimaryRootWindow(), center
);
257 generator
.PressLeftButton();
258 EXPECT_TRUE(view
->got_press());
260 views::Widget
* modal_widget
=
261 views::Widget::CreateWindowWithParent(NULL
, widget
->GetNativeView());
262 scoped_ptr
<aura::Window
> modal_window(modal_widget
->GetNativeView());
263 modal_window
->SetProperty(aura::client::kModalKey
, ui::MODAL_TYPE_WINDOW
);
264 views::test::CaptureTrackingView
* modal_view
=
265 new views::test::CaptureTrackingView
;
266 modal_widget
->client_view()->AddChildView(modal_view
);
267 modal_widget
->SetBounds(gfx::Rect(50, 50, 200, 200));
268 modal_view
->SetBoundsRect(modal_widget
->client_view()->GetLocalBounds());
269 modal_widget
->Show();
271 EXPECT_TRUE(view
->got_capture_lost());
272 generator
.ReleaseLeftButton();
276 EXPECT_FALSE(modal_view
->got_capture_lost());
277 EXPECT_FALSE(modal_view
->got_press());
279 gfx::Point
modal_center(modal_view
->width() / 2, modal_view
->height() / 2);
280 views::View::ConvertPointToScreen(modal_view
, &modal_center
);
281 generator
.MoveMouseTo(modal_center
, 1);
282 generator
.PressLeftButton();
283 EXPECT_TRUE(modal_view
->got_press());
284 EXPECT_FALSE(modal_view
->got_capture_lost());
285 EXPECT_FALSE(view
->got_capture_lost());
286 EXPECT_FALSE(view
->got_press());
289 class TouchTrackerWindowDelegate
: public aura::test::TestWindowDelegate
{
291 TouchTrackerWindowDelegate()
292 : received_touch_(false),
293 last_event_type_(ui::ET_UNKNOWN
) {
295 virtual ~TouchTrackerWindowDelegate() {}
298 received_touch_
= false;
299 last_event_type_
= ui::ET_UNKNOWN
;
302 bool received_touch() const { return received_touch_
; }
303 ui::EventType
last_event_type() const { return last_event_type_
; }
306 // Overridden from aura::test::TestWindowDelegate.
307 virtual void OnTouchEvent(ui::TouchEvent
* event
) OVERRIDE
{
308 received_touch_
= true;
309 last_event_type_
= event
->type();
310 aura::test::TestWindowDelegate::OnTouchEvent(event
);
313 bool received_touch_
;
314 ui::EventType last_event_type_
;
316 DISALLOW_COPY_AND_ASSIGN(TouchTrackerWindowDelegate
);
319 // Modality should prevent events from being passed to the transient parent.
320 TEST_F(WindowModalityControllerTest
, TouchEvent
) {
321 TouchTrackerWindowDelegate d1
;
322 scoped_ptr
<aura::Window
> w1(CreateTestWindowInShellWithDelegate(&d1
,
323 -1, gfx::Rect(0, 0, 100, 100)));
324 TouchTrackerWindowDelegate d11
;
325 scoped_ptr
<aura::Window
> w11(CreateTestWindowInShellWithDelegate(&d11
,
326 -11, gfx::Rect(20, 20, 50, 50)));
327 aura::test::EventGenerator
generator(Shell::GetPrimaryRootWindow(),
330 views::corewm::AddTransientChild(w1
.get(), w11
.get());
335 // Clicking a point within w1 should activate that window.
336 generator
.PressMoveAndReleaseTouchTo(gfx::Point(10, 10));
337 EXPECT_TRUE(wm::IsActiveWindow(w1
.get()));
338 EXPECT_TRUE(d1
.received_touch());
339 EXPECT_FALSE(d11
.received_touch());
343 // Adding a modal window while a touch is down should fire a touch cancel.
344 generator
.PressTouch();
345 generator
.MoveTouch(gfx::Point(10, 10));
349 w11
->SetProperty(aura::client::kModalKey
, ui::MODAL_TYPE_WINDOW
);
350 EXPECT_TRUE(d1
.received_touch());
351 EXPECT_EQ(ui::ET_TOUCH_CANCELLED
, d1
.last_event_type());
352 EXPECT_FALSE(d11
.received_touch());
358 // - A |parent| window that hosts a |modal_parent| window within itself. The
359 // |parent| and |modal_parent| windows are not the same window. The
360 // |modal_parent| window is not activatable, because it's contained within the
362 // - A |child| window with parent window |parent|, but is modal to
363 // |modal_parent| window.
365 // - Clicking on the |modal_parent| should activate the |child| window.
366 // - Clicking on the |parent| window outside of the |modal_parent| bounds should
367 // activate the |parent| window.
368 // - Clicking on the |child| while |parent| is active should activate the
370 // - Focus should follow the active window.
371 TEST_F(WindowModalityControllerTest
, ChildModal
) {
372 views::test::ChildModalParent
* delegate
=
373 new views::test::ChildModalParent(CurrentContext());
374 views::Widget
* widget
= views::Widget::CreateWindowWithContextAndBounds(
375 delegate
, CurrentContext(), gfx::Rect(0, 0, 400, 400));
378 aura::Window
* parent
= widget
->GetNativeView();
379 EXPECT_TRUE(wm::IsActiveWindow(parent
));
381 aura::Window
* modal_parent
= delegate
->GetModalParent();
382 EXPECT_NE(static_cast<aura::Window
*>(NULL
), modal_parent
);
383 EXPECT_NE(parent
, modal_parent
);
384 EXPECT_FALSE(wm::IsActiveWindow(modal_parent
));
386 delegate
->ShowChild();
387 aura::Window
* child
= delegate
->GetChild();
388 EXPECT_NE(static_cast<aura::Window
*>(NULL
), child
);
390 EXPECT_TRUE(wm::IsActiveWindow(child
));
391 EXPECT_FALSE(wm::IsActiveWindow(modal_parent
));
392 EXPECT_FALSE(wm::IsActiveWindow(parent
));
394 EXPECT_TRUE(child
->HasFocus());
395 EXPECT_FALSE(modal_parent
->HasFocus());
396 EXPECT_FALSE(parent
->HasFocus());
398 wm::ActivateWindow(modal_parent
);
400 EXPECT_TRUE(wm::IsActiveWindow(child
));
401 EXPECT_FALSE(wm::IsActiveWindow(modal_parent
));
402 EXPECT_FALSE(wm::IsActiveWindow(parent
));
404 EXPECT_TRUE(child
->HasFocus());
405 EXPECT_FALSE(modal_parent
->HasFocus());
406 EXPECT_FALSE(parent
->HasFocus());
408 wm::ActivateWindow(parent
);
410 EXPECT_FALSE(wm::IsActiveWindow(child
));
411 EXPECT_FALSE(wm::IsActiveWindow(modal_parent
));
412 EXPECT_TRUE(wm::IsActiveWindow(parent
));
414 EXPECT_FALSE(child
->HasFocus());
415 EXPECT_FALSE(modal_parent
->HasFocus());
416 EXPECT_TRUE(parent
->HasFocus());
418 wm::ActivateWindow(child
);
420 EXPECT_TRUE(wm::IsActiveWindow(child
));
421 EXPECT_FALSE(wm::IsActiveWindow(modal_parent
));
422 EXPECT_FALSE(wm::IsActiveWindow(parent
));
424 EXPECT_TRUE(child
->HasFocus());
425 EXPECT_FALSE(modal_parent
->HasFocus());
426 EXPECT_FALSE(parent
->HasFocus());
429 // Same as |ChildModal| test, but using |EventGenerator| rather than bypassing
430 // it by calling |ActivateWindow|.
431 TEST_F(WindowModalityControllerTest
, ChildModalEventGenerator
) {
432 views::test::ChildModalParent
* delegate
=
433 new views::test::ChildModalParent(CurrentContext());
434 views::Widget
* widget
= views::Widget::CreateWindowWithContextAndBounds(
435 delegate
, CurrentContext(), gfx::Rect(0, 0, 400, 400));
438 aura::Window
* parent
= widget
->GetNativeView();
439 EXPECT_TRUE(wm::IsActiveWindow(parent
));
441 aura::Window
* modal_parent
= delegate
->GetModalParent();
442 EXPECT_NE(static_cast<aura::Window
*>(NULL
), modal_parent
);
443 EXPECT_NE(parent
, modal_parent
);
444 EXPECT_FALSE(wm::IsActiveWindow(modal_parent
));
446 delegate
->ShowChild();
447 aura::Window
* child
= delegate
->GetChild();
448 EXPECT_NE(static_cast<aura::Window
*>(NULL
), child
);
450 EXPECT_TRUE(wm::IsActiveWindow(child
));
451 EXPECT_FALSE(wm::IsActiveWindow(modal_parent
));
452 EXPECT_FALSE(wm::IsActiveWindow(parent
));
454 EXPECT_TRUE(child
->HasFocus());
455 EXPECT_FALSE(modal_parent
->HasFocus());
456 EXPECT_FALSE(parent
->HasFocus());
459 aura::test::EventGenerator
generator(
460 Shell::GetPrimaryRootWindow(),
461 parent
->bounds().origin() +
462 gfx::Vector2d(10, parent
->bounds().height() - 10));
463 generator
.ClickLeftButton();
464 generator
.ClickLeftButton();
466 EXPECT_TRUE(wm::IsActiveWindow(child
));
467 EXPECT_FALSE(wm::IsActiveWindow(modal_parent
));
468 EXPECT_FALSE(wm::IsActiveWindow(parent
));
470 EXPECT_TRUE(child
->HasFocus());
471 EXPECT_FALSE(modal_parent
->HasFocus());
472 EXPECT_FALSE(parent
->HasFocus());
476 aura::test::EventGenerator
generator(
477 Shell::GetPrimaryRootWindow(),
478 parent
->bounds().origin() + gfx::Vector2d(10, 10));
479 generator
.ClickLeftButton();
481 EXPECT_FALSE(wm::IsActiveWindow(child
));
482 EXPECT_FALSE(wm::IsActiveWindow(modal_parent
));
483 EXPECT_TRUE(wm::IsActiveWindow(parent
));
485 EXPECT_FALSE(child
->HasFocus());
486 EXPECT_FALSE(modal_parent
->HasFocus());
487 EXPECT_TRUE(parent
->HasFocus());
491 aura::test::EventGenerator
generator(
492 Shell::GetPrimaryRootWindow(),
493 child
->bounds().origin() + gfx::Vector2d(10, 10));
494 generator
.ClickLeftButton();
496 EXPECT_TRUE(wm::IsActiveWindow(child
));
497 EXPECT_FALSE(wm::IsActiveWindow(modal_parent
));
498 EXPECT_FALSE(wm::IsActiveWindow(parent
));
500 EXPECT_TRUE(child
->HasFocus());
501 EXPECT_FALSE(modal_parent
->HasFocus());
502 EXPECT_FALSE(parent
->HasFocus());
506 // Window-modal test for the case when the originally clicked window is an
507 // ancestor of the modal parent.
508 TEST_F(WindowModalityControllerTest
, WindowModalAncestor
) {
509 aura::test::TestWindowDelegate d
;
510 scoped_ptr
<aura::Window
> w1(
511 CreateTestWindowInShellWithDelegate(&d
, -1, gfx::Rect()));
512 scoped_ptr
<aura::Window
> w2(
513 aura::test::CreateTestWindowWithDelegate(&d
, -11, gfx::Rect(), w1
.get()));
514 scoped_ptr
<aura::Window
> w3(
515 aura::test::CreateTestWindowWithDelegate(&d
, -11, gfx::Rect(), w2
.get()));
516 scoped_ptr
<aura::Window
> w4(
517 CreateTestWindowInShellWithDelegate(&d
, -2, gfx::Rect()));
518 w4
->SetProperty(aura::client::kModalKey
, ui::MODAL_TYPE_WINDOW
);
519 views::corewm::AddTransientChild(w1
.get(), w4
.get());
521 wm::ActivateWindow(w1
.get());
522 EXPECT_TRUE(wm::IsActiveWindow(w4
.get()));
524 wm::ActivateWindow(w2
.get());
525 EXPECT_TRUE(wm::IsActiveWindow(w4
.get()));
527 wm::ActivateWindow(w3
.get());
528 EXPECT_TRUE(wm::IsActiveWindow(w4
.get()));
530 wm::ActivateWindow(w4
.get());
531 EXPECT_TRUE(wm::IsActiveWindow(w4
.get()));
534 // Child-modal test for the case when the originally clicked window is an
535 // ancestor of the modal parent.
536 TEST_F(WindowModalityControllerTest
, ChildModalAncestor
) {
537 aura::test::TestWindowDelegate d
;
538 scoped_ptr
<aura::Window
> w1(
539 CreateTestWindowInShellWithDelegate(&d
, -1, gfx::Rect()));
540 scoped_ptr
<aura::Window
> w2(
541 aura::test::CreateTestWindowWithDelegate(&d
, -11, gfx::Rect(), w1
.get()));
542 scoped_ptr
<aura::Window
> w3(
543 aura::test::CreateTestWindowWithDelegate(&d
, -11, gfx::Rect(), w2
.get()));
544 scoped_ptr
<aura::Window
> w4(
545 CreateTestWindowInShellWithDelegate(&d
, -2, gfx::Rect()));
546 w4
->SetProperty(aura::client::kModalKey
, ui::MODAL_TYPE_CHILD
);
547 views::corewm::SetModalParent(w4
.get(), w2
.get());
548 views::corewm::AddTransientChild(w1
.get(), w4
.get());
550 wm::ActivateWindow(w1
.get());
551 EXPECT_TRUE(wm::IsActiveWindow(w1
.get()));
553 wm::ActivateWindow(w2
.get());
554 EXPECT_TRUE(wm::IsActiveWindow(w4
.get()));
556 wm::ActivateWindow(w3
.get());
557 EXPECT_TRUE(wm::IsActiveWindow(w4
.get()));
559 wm::ActivateWindow(w4
.get());
560 EXPECT_TRUE(wm::IsActiveWindow(w4
.get()));
563 } // namespace internal