Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(30)

Side by Side Diff: ash/wm/window_modality_controller_unittest.cc

Issue 196063002: Move wm/core to wm namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ash/wm/window_manager_unittest.cc ('k') | ash/wm/window_positioner.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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 "ui/wm/core/window_modality_controller.h" 5 #include "ui/wm/core/window_modality_controller.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/test/ash_test_base.h" 8 #include "ash/test/ash_test_base.h"
9 #include "ash/wm/window_util.h" 9 #include "ash/wm/window_util.h"
10 #include "ui/aura/client/aura_constants.h" 10 #include "ui/aura/client/aura_constants.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 // - closing a window passes focus up the stack. 44 // - closing a window passes focus up the stack.
45 TEST_F(WindowModalityControllerTest, BasicActivation) { 45 TEST_F(WindowModalityControllerTest, BasicActivation) {
46 aura::test::TestWindowDelegate d; 46 aura::test::TestWindowDelegate d;
47 scoped_ptr<aura::Window> w1( 47 scoped_ptr<aura::Window> w1(
48 CreateTestWindowInShellWithDelegate(&d, -1, gfx::Rect())); 48 CreateTestWindowInShellWithDelegate(&d, -1, gfx::Rect()));
49 scoped_ptr<aura::Window> w11( 49 scoped_ptr<aura::Window> w11(
50 CreateTestWindowInShellWithDelegate(&d, -11, gfx::Rect())); 50 CreateTestWindowInShellWithDelegate(&d, -11, gfx::Rect()));
51 scoped_ptr<aura::Window> w12( 51 scoped_ptr<aura::Window> w12(
52 CreateTestWindowInShellWithDelegate(&d, -12, gfx::Rect())); 52 CreateTestWindowInShellWithDelegate(&d, -12, gfx::Rect()));
53 53
54 views::corewm::AddTransientChild(w1.get(), w11.get()); 54 ::wm::AddTransientChild(w1.get(), w11.get());
55 wm::ActivateWindow(w1.get()); 55 wm::ActivateWindow(w1.get());
56 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); 56 EXPECT_TRUE(wm::IsActiveWindow(w1.get()));
57 wm::ActivateWindow(w11.get()); 57 wm::ActivateWindow(w11.get());
58 EXPECT_TRUE(wm::IsActiveWindow(w11.get())); 58 EXPECT_TRUE(wm::IsActiveWindow(w11.get()));
59 59
60 w12->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_WINDOW); 60 w12->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_WINDOW);
61 views::corewm::AddTransientChild(w1.get(), w12.get()); 61 ::wm::AddTransientChild(w1.get(), w12.get());
62 wm::ActivateWindow(w12.get()); 62 wm::ActivateWindow(w12.get());
63 EXPECT_TRUE(wm::IsActiveWindow(w12.get())); 63 EXPECT_TRUE(wm::IsActiveWindow(w12.get()));
64 64
65 wm::ActivateWindow(w11.get()); 65 wm::ActivateWindow(w11.get());
66 EXPECT_TRUE(wm::IsActiveWindow(w11.get())); 66 EXPECT_TRUE(wm::IsActiveWindow(w11.get()));
67 67
68 int check1[] = { -1, -12, -11 }; 68 int check1[] = { -1, -12, -11 };
69 EXPECT_TRUE(ValidateStacking(w1->parent(), check1, arraysize(check1))); 69 EXPECT_TRUE(ValidateStacking(w1->parent(), check1, arraysize(check1)));
70 70
71 wm::ActivateWindow(w1.get()); 71 wm::ActivateWindow(w1.get());
(...skipping 19 matching lines...) Expand all
91 aura::test::TestWindowDelegate d; 91 aura::test::TestWindowDelegate d;
92 scoped_ptr<aura::Window> w1( 92 scoped_ptr<aura::Window> w1(
93 CreateTestWindowInShellWithDelegate(&d, -1, gfx::Rect())); 93 CreateTestWindowInShellWithDelegate(&d, -1, gfx::Rect()));
94 scoped_ptr<aura::Window> w11( 94 scoped_ptr<aura::Window> w11(
95 CreateTestWindowInShellWithDelegate(&d, -11, gfx::Rect())); 95 CreateTestWindowInShellWithDelegate(&d, -11, gfx::Rect()));
96 scoped_ptr<aura::Window> w111( 96 scoped_ptr<aura::Window> w111(
97 CreateTestWindowInShellWithDelegate(&d, -111, gfx::Rect())); 97 CreateTestWindowInShellWithDelegate(&d, -111, gfx::Rect()));
98 scoped_ptr<aura::Window> w2( 98 scoped_ptr<aura::Window> w2(
99 CreateTestWindowInShellWithDelegate(&d, -2, gfx::Rect())); 99 CreateTestWindowInShellWithDelegate(&d, -2, gfx::Rect()));
100 100
101 views::corewm::AddTransientChild(w1.get(), w11.get()); 101 ::wm::AddTransientChild(w1.get(), w11.get());
102 views::corewm::AddTransientChild(w11.get(), w111.get()); 102 ::wm::AddTransientChild(w11.get(), w111.get());
103 103
104 wm::ActivateWindow(w1.get()); 104 wm::ActivateWindow(w1.get());
105 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); 105 EXPECT_TRUE(wm::IsActiveWindow(w1.get()));
106 wm::ActivateWindow(w2.get()); 106 wm::ActivateWindow(w2.get());
107 EXPECT_TRUE(wm::IsActiveWindow(w2.get())); 107 EXPECT_TRUE(wm::IsActiveWindow(w2.get()));
108 108
109 // Set up modality. 109 // Set up modality.
110 w11->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_WINDOW); 110 w11->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_WINDOW);
111 w111->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_WINDOW); 111 w111->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_WINDOW);
112 112
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 scoped_ptr<aura::Window> w1( 145 scoped_ptr<aura::Window> w1(
146 CreateTestWindowInShellWithDelegate(&d, -1, gfx::Rect())); 146 CreateTestWindowInShellWithDelegate(&d, -1, gfx::Rect()));
147 scoped_ptr<aura::Window> w11( 147 scoped_ptr<aura::Window> w11(
148 CreateTestWindowInShellWithDelegate(&d, -11, gfx::Rect())); 148 CreateTestWindowInShellWithDelegate(&d, -11, gfx::Rect()));
149 // |w111| will be owned and deleted by |w11|. 149 // |w111| will be owned and deleted by |w11|.
150 aura::Window* w111 = 150 aura::Window* w111 =
151 CreateTestWindowInShellWithDelegate(&d, -111, gfx::Rect()); 151 CreateTestWindowInShellWithDelegate(&d, -111, gfx::Rect());
152 scoped_ptr<aura::Window> w2( 152 scoped_ptr<aura::Window> w2(
153 CreateTestWindowInShellWithDelegate(&d, -2, gfx::Rect())); 153 CreateTestWindowInShellWithDelegate(&d, -2, gfx::Rect()));
154 154
155 views::corewm::AddTransientChild(w1.get(), w11.get()); 155 ::wm::AddTransientChild(w1.get(), w11.get());
156 views::corewm::AddTransientChild(w11.get(), w111); 156 ::wm::AddTransientChild(w11.get(), w111);
157 157
158 wm::ActivateWindow(w1.get()); 158 wm::ActivateWindow(w1.get());
159 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); 159 EXPECT_TRUE(wm::IsActiveWindow(w1.get()));
160 wm::ActivateWindow(w2.get()); 160 wm::ActivateWindow(w2.get());
161 EXPECT_TRUE(wm::IsActiveWindow(w2.get())); 161 EXPECT_TRUE(wm::IsActiveWindow(w2.get()));
162 162
163 // Set up modality. 163 // Set up modality.
164 w11->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_WINDOW); 164 w11->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_WINDOW);
165 w111->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_WINDOW); 165 w111->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_WINDOW);
166 166
(...skipping 12 matching lines...) Expand all
179 } 179 }
180 180
181 // Modality also prevents events from being passed to the transient parent. 181 // Modality also prevents events from being passed to the transient parent.
182 TEST_F(WindowModalityControllerTest, Events) { 182 TEST_F(WindowModalityControllerTest, Events) {
183 aura::test::TestWindowDelegate d; 183 aura::test::TestWindowDelegate d;
184 scoped_ptr<aura::Window> w1(CreateTestWindowInShellWithDelegate(&d, -1, 184 scoped_ptr<aura::Window> w1(CreateTestWindowInShellWithDelegate(&d, -1,
185 gfx::Rect(0, 0, 100, 100))); 185 gfx::Rect(0, 0, 100, 100)));
186 scoped_ptr<aura::Window> w11(CreateTestWindowInShellWithDelegate(&d, -11, 186 scoped_ptr<aura::Window> w11(CreateTestWindowInShellWithDelegate(&d, -11,
187 gfx::Rect(20, 20, 50, 50))); 187 gfx::Rect(20, 20, 50, 50)));
188 188
189 views::corewm::AddTransientChild(w1.get(), w11.get()); 189 ::wm::AddTransientChild(w1.get(), w11.get());
190 190
191 { 191 {
192 // Clicking a point within w1 should activate that window. 192 // Clicking a point within w1 should activate that window.
193 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), 193 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
194 gfx::Point(10, 10)); 194 gfx::Point(10, 10));
195 generator.ClickLeftButton(); 195 generator.ClickLeftButton();
196 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); 196 EXPECT_TRUE(wm::IsActiveWindow(w1.get()));
197 } 197 }
198 198
199 w11->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_WINDOW); 199 w11->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_WINDOW);
(...skipping 14 matching lines...) Expand all
214 aura::test::TestWindowDelegate d; 214 aura::test::TestWindowDelegate d;
215 scoped_ptr<aura::Window> w1( 215 scoped_ptr<aura::Window> w1(
216 CreateTestWindowInShellWithDelegate(&d, -1, gfx::Rect())); 216 CreateTestWindowInShellWithDelegate(&d, -1, gfx::Rect()));
217 scoped_ptr<aura::Window> w11( 217 scoped_ptr<aura::Window> w11(
218 aura::test::CreateTestWindowWithDelegate(&d, -11, gfx::Rect(), w1.get())); 218 aura::test::CreateTestWindowWithDelegate(&d, -11, gfx::Rect(), w1.get()));
219 scoped_ptr<aura::Window> w2( 219 scoped_ptr<aura::Window> w2(
220 CreateTestWindowInShellWithDelegate(&d, -2, gfx::Rect())); 220 CreateTestWindowInShellWithDelegate(&d, -2, gfx::Rect()));
221 w2->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_WINDOW); 221 w2->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_WINDOW);
222 222
223 aura::Window* wt; 223 aura::Window* wt;
224 wt = views::corewm::GetModalTransient(w1.get()); 224 wt = ::wm::GetModalTransient(w1.get());
225 ASSERT_EQ(static_cast<aura::Window*>(NULL), wt); 225 ASSERT_EQ(static_cast<aura::Window*>(NULL), wt);
226 226
227 // Parent w2 to w1. It should get parented to the parent of w1. 227 // Parent w2 to w1. It should get parented to the parent of w1.
228 views::corewm::AddTransientChild(w1.get(), w2.get()); 228 ::wm::AddTransientChild(w1.get(), w2.get());
229 ASSERT_EQ(2U, w1->parent()->children().size()); 229 ASSERT_EQ(2U, w1->parent()->children().size());
230 EXPECT_EQ(-2, w1->parent()->children().at(1)->id()); 230 EXPECT_EQ(-2, w1->parent()->children().at(1)->id());
231 231
232 // Request the modal transient window for w1, it should be w2. 232 // Request the modal transient window for w1, it should be w2.
233 wt = views::corewm::GetModalTransient(w1.get()); 233 wt = ::wm::GetModalTransient(w1.get());
234 ASSERT_NE(static_cast<aura::Window*>(NULL), wt); 234 ASSERT_NE(static_cast<aura::Window*>(NULL), wt);
235 EXPECT_EQ(-2, wt->id()); 235 EXPECT_EQ(-2, wt->id());
236 236
237 // Request the modal transient window for w11, it should also be w2. 237 // Request the modal transient window for w11, it should also be w2.
238 wt = views::corewm::GetModalTransient(w11.get()); 238 wt = ::wm::GetModalTransient(w11.get());
239 ASSERT_NE(static_cast<aura::Window*>(NULL), wt); 239 ASSERT_NE(static_cast<aura::Window*>(NULL), wt);
240 EXPECT_EQ(-2, wt->id()); 240 EXPECT_EQ(-2, wt->id());
241 } 241 }
242 242
243 // Verifies we generate a capture lost when showing a modal window. 243 // Verifies we generate a capture lost when showing a modal window.
244 TEST_F(WindowModalityControllerTest, ChangeCapture) { 244 TEST_F(WindowModalityControllerTest, ChangeCapture) {
245 views::Widget* widget = views::Widget::CreateWindowWithContext( 245 views::Widget* widget = views::Widget::CreateWindowWithContext(
246 NULL, Shell::GetPrimaryRootWindow()); 246 NULL, Shell::GetPrimaryRootWindow());
247 scoped_ptr<aura::Window> widget_window(widget->GetNativeView()); 247 scoped_ptr<aura::Window> widget_window(widget->GetNativeView());
248 views::test::CaptureTrackingView* view = new views::test::CaptureTrackingView; 248 views::test::CaptureTrackingView* view = new views::test::CaptureTrackingView;
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 TEST_F(WindowModalityControllerTest, TouchEvent) { 320 TEST_F(WindowModalityControllerTest, TouchEvent) {
321 TouchTrackerWindowDelegate d1; 321 TouchTrackerWindowDelegate d1;
322 scoped_ptr<aura::Window> w1(CreateTestWindowInShellWithDelegate(&d1, 322 scoped_ptr<aura::Window> w1(CreateTestWindowInShellWithDelegate(&d1,
323 -1, gfx::Rect(0, 0, 100, 100))); 323 -1, gfx::Rect(0, 0, 100, 100)));
324 TouchTrackerWindowDelegate d11; 324 TouchTrackerWindowDelegate d11;
325 scoped_ptr<aura::Window> w11(CreateTestWindowInShellWithDelegate(&d11, 325 scoped_ptr<aura::Window> w11(CreateTestWindowInShellWithDelegate(&d11,
326 -11, gfx::Rect(20, 20, 50, 50))); 326 -11, gfx::Rect(20, 20, 50, 50)));
327 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), 327 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
328 gfx::Point(10, 10)); 328 gfx::Point(10, 10));
329 329
330 views::corewm::AddTransientChild(w1.get(), w11.get()); 330 ::wm::AddTransientChild(w1.get(), w11.get());
331 d1.reset(); 331 d1.reset();
332 d11.reset(); 332 d11.reset();
333 333
334 { 334 {
335 // Clicking a point within w1 should activate that window. 335 // Clicking a point within w1 should activate that window.
336 generator.PressMoveAndReleaseTouchTo(gfx::Point(10, 10)); 336 generator.PressMoveAndReleaseTouchTo(gfx::Point(10, 10));
337 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); 337 EXPECT_TRUE(wm::IsActiveWindow(w1.get()));
338 EXPECT_TRUE(d1.received_touch()); 338 EXPECT_TRUE(d1.received_touch());
339 EXPECT_FALSE(d11.received_touch()); 339 EXPECT_FALSE(d11.received_touch());
340 } 340 }
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 aura::test::TestWindowDelegate d; 509 aura::test::TestWindowDelegate d;
510 scoped_ptr<aura::Window> w1( 510 scoped_ptr<aura::Window> w1(
511 CreateTestWindowInShellWithDelegate(&d, -1, gfx::Rect())); 511 CreateTestWindowInShellWithDelegate(&d, -1, gfx::Rect()));
512 scoped_ptr<aura::Window> w2( 512 scoped_ptr<aura::Window> w2(
513 aura::test::CreateTestWindowWithDelegate(&d, -11, gfx::Rect(), w1.get())); 513 aura::test::CreateTestWindowWithDelegate(&d, -11, gfx::Rect(), w1.get()));
514 scoped_ptr<aura::Window> w3( 514 scoped_ptr<aura::Window> w3(
515 aura::test::CreateTestWindowWithDelegate(&d, -11, gfx::Rect(), w2.get())); 515 aura::test::CreateTestWindowWithDelegate(&d, -11, gfx::Rect(), w2.get()));
516 scoped_ptr<aura::Window> w4( 516 scoped_ptr<aura::Window> w4(
517 CreateTestWindowInShellWithDelegate(&d, -2, gfx::Rect())); 517 CreateTestWindowInShellWithDelegate(&d, -2, gfx::Rect()));
518 w4->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_WINDOW); 518 w4->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_WINDOW);
519 views::corewm::AddTransientChild(w1.get(), w4.get()); 519 ::wm::AddTransientChild(w1.get(), w4.get());
520 520
521 wm::ActivateWindow(w1.get()); 521 wm::ActivateWindow(w1.get());
522 EXPECT_TRUE(wm::IsActiveWindow(w4.get())); 522 EXPECT_TRUE(wm::IsActiveWindow(w4.get()));
523 523
524 wm::ActivateWindow(w2.get()); 524 wm::ActivateWindow(w2.get());
525 EXPECT_TRUE(wm::IsActiveWindow(w4.get())); 525 EXPECT_TRUE(wm::IsActiveWindow(w4.get()));
526 526
527 wm::ActivateWindow(w3.get()); 527 wm::ActivateWindow(w3.get());
528 EXPECT_TRUE(wm::IsActiveWindow(w4.get())); 528 EXPECT_TRUE(wm::IsActiveWindow(w4.get()));
529 529
530 wm::ActivateWindow(w4.get()); 530 wm::ActivateWindow(w4.get());
531 EXPECT_TRUE(wm::IsActiveWindow(w4.get())); 531 EXPECT_TRUE(wm::IsActiveWindow(w4.get()));
532 } 532 }
533 533
534 // Child-modal test for the case when the originally clicked window is an 534 // Child-modal test for the case when the originally clicked window is an
535 // ancestor of the modal parent. 535 // ancestor of the modal parent.
536 TEST_F(WindowModalityControllerTest, ChildModalAncestor) { 536 TEST_F(WindowModalityControllerTest, ChildModalAncestor) {
537 aura::test::TestWindowDelegate d; 537 aura::test::TestWindowDelegate d;
538 scoped_ptr<aura::Window> w1( 538 scoped_ptr<aura::Window> w1(
539 CreateTestWindowInShellWithDelegate(&d, -1, gfx::Rect())); 539 CreateTestWindowInShellWithDelegate(&d, -1, gfx::Rect()));
540 scoped_ptr<aura::Window> w2( 540 scoped_ptr<aura::Window> w2(
541 aura::test::CreateTestWindowWithDelegate(&d, -11, gfx::Rect(), w1.get())); 541 aura::test::CreateTestWindowWithDelegate(&d, -11, gfx::Rect(), w1.get()));
542 scoped_ptr<aura::Window> w3( 542 scoped_ptr<aura::Window> w3(
543 aura::test::CreateTestWindowWithDelegate(&d, -11, gfx::Rect(), w2.get())); 543 aura::test::CreateTestWindowWithDelegate(&d, -11, gfx::Rect(), w2.get()));
544 scoped_ptr<aura::Window> w4( 544 scoped_ptr<aura::Window> w4(
545 CreateTestWindowInShellWithDelegate(&d, -2, gfx::Rect())); 545 CreateTestWindowInShellWithDelegate(&d, -2, gfx::Rect()));
546 w4->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_CHILD); 546 w4->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_CHILD);
547 views::corewm::SetModalParent(w4.get(), w2.get()); 547 ::wm::SetModalParent(w4.get(), w2.get());
548 views::corewm::AddTransientChild(w1.get(), w4.get()); 548 ::wm::AddTransientChild(w1.get(), w4.get());
549 549
550 wm::ActivateWindow(w1.get()); 550 wm::ActivateWindow(w1.get());
551 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); 551 EXPECT_TRUE(wm::IsActiveWindow(w1.get()));
552 552
553 wm::ActivateWindow(w2.get()); 553 wm::ActivateWindow(w2.get());
554 EXPECT_TRUE(wm::IsActiveWindow(w4.get())); 554 EXPECT_TRUE(wm::IsActiveWindow(w4.get()));
555 555
556 wm::ActivateWindow(w3.get()); 556 wm::ActivateWindow(w3.get());
557 EXPECT_TRUE(wm::IsActiveWindow(w4.get())); 557 EXPECT_TRUE(wm::IsActiveWindow(w4.get()));
558 558
559 wm::ActivateWindow(w4.get()); 559 wm::ActivateWindow(w4.get());
560 EXPECT_TRUE(wm::IsActiveWindow(w4.get())); 560 EXPECT_TRUE(wm::IsActiveWindow(w4.get()));
561 } 561 }
562 562
563 } // namespace internal 563 } // namespace internal
564 } // namespace ash 564 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/window_manager_unittest.cc ('k') | ash/wm/window_positioner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698