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

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

Issue 1867223004: Convert //ash from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 4 years, 8 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
« no previous file with comments | « ash/wm/window_manager_unittest.cc ('k') | ash/wm/window_resizer.h » ('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/test/child_modal_window.h" 9 #include "ash/test/child_modal_window.h"
10 #include "ash/wm/window_util.h" 10 #include "ash/wm/window_util.h"
(...skipping 26 matching lines...) Expand all
37 } // namespace 37 } // namespace
38 38
39 // Creates three windows, w1, w11, and w12. w11 is a non-modal transient, w12 is 39 // Creates three windows, w1, w11, and w12. w11 is a non-modal transient, w12 is
40 // a modal transient. 40 // a modal transient.
41 // Validates: 41 // Validates:
42 // - it should be possible to activate w12 even when w11 is open. 42 // - it should be possible to activate w12 even when w11 is open.
43 // - activating w1 activates w12 and updates stacking order appropriately. 43 // - activating w1 activates w12 and updates stacking order appropriately.
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 std::unique_ptr<aura::Window> w1(
48 CreateTestWindowInShellWithDelegate(&d, -1, gfx::Rect())); 48 CreateTestWindowInShellWithDelegate(&d, -1, gfx::Rect()));
49 scoped_ptr<aura::Window> w11( 49 std::unique_ptr<aura::Window> w11(
50 CreateTestWindowInShellWithDelegate(&d, -11, gfx::Rect())); 50 CreateTestWindowInShellWithDelegate(&d, -11, gfx::Rect()));
51 scoped_ptr<aura::Window> w12( 51 std::unique_ptr<aura::Window> w12(
52 CreateTestWindowInShellWithDelegate(&d, -12, gfx::Rect())); 52 CreateTestWindowInShellWithDelegate(&d, -12, gfx::Rect()));
53 53
54 ::wm::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 ::wm::AddTransientChild(w1.get(), w12.get()); 61 ::wm::AddTransientChild(w1.get(), w12.get());
(...skipping 20 matching lines...) Expand all
82 } 82 }
83 83
84 // Create two toplevel windows w1 and w2, and nest two modals w11 and w111 below 84 // Create two toplevel windows w1 and w2, and nest two modals w11 and w111 below
85 // w1. 85 // w1.
86 // Validates: 86 // Validates:
87 // - activating w1 while w11/w111 is showing always activates most deeply nested 87 // - activating w1 while w11/w111 is showing always activates most deeply nested
88 // descendant. 88 // descendant.
89 // - closing a window passes focus up the stack. 89 // - closing a window passes focus up the stack.
90 TEST_F(WindowModalityControllerTest, NestedModals) { 90 TEST_F(WindowModalityControllerTest, NestedModals) {
91 aura::test::TestWindowDelegate d; 91 aura::test::TestWindowDelegate d;
92 scoped_ptr<aura::Window> w1( 92 std::unique_ptr<aura::Window> w1(
93 CreateTestWindowInShellWithDelegate(&d, -1, gfx::Rect())); 93 CreateTestWindowInShellWithDelegate(&d, -1, gfx::Rect()));
94 scoped_ptr<aura::Window> w11( 94 std::unique_ptr<aura::Window> w11(
95 CreateTestWindowInShellWithDelegate(&d, -11, gfx::Rect())); 95 CreateTestWindowInShellWithDelegate(&d, -11, gfx::Rect()));
96 scoped_ptr<aura::Window> w111( 96 std::unique_ptr<aura::Window> w111(
97 CreateTestWindowInShellWithDelegate(&d, -111, gfx::Rect())); 97 CreateTestWindowInShellWithDelegate(&d, -111, gfx::Rect()));
98 scoped_ptr<aura::Window> w2( 98 std::unique_ptr<aura::Window> w2(
99 CreateTestWindowInShellWithDelegate(&d, -2, gfx::Rect())); 99 CreateTestWindowInShellWithDelegate(&d, -2, gfx::Rect()));
100 100
101 ::wm::AddTransientChild(w1.get(), w11.get()); 101 ::wm::AddTransientChild(w1.get(), w11.get());
102 ::wm::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
(...skipping 26 matching lines...) Expand all
135 w11.reset(); 135 w11.reset();
136 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); 136 EXPECT_TRUE(wm::IsActiveWindow(w1.get()));
137 } 137 }
138 138
139 // Create two toplevel windows w1 and w2, and nest two modals w11 and w111 below 139 // Create two toplevel windows w1 and w2, and nest two modals w11 and w111 below
140 // w1. 140 // w1.
141 // Validates: 141 // Validates:
142 // - destroying w11 while w111 is focused activates w1. 142 // - destroying w11 while w111 is focused activates w1.
143 TEST_F(WindowModalityControllerTest, NestedModalsOuterClosed) { 143 TEST_F(WindowModalityControllerTest, NestedModalsOuterClosed) {
144 aura::test::TestWindowDelegate d; 144 aura::test::TestWindowDelegate d;
145 scoped_ptr<aura::Window> w1( 145 std::unique_ptr<aura::Window> w1(
146 CreateTestWindowInShellWithDelegate(&d, -1, gfx::Rect())); 146 CreateTestWindowInShellWithDelegate(&d, -1, gfx::Rect()));
147 scoped_ptr<aura::Window> w11( 147 std::unique_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 std::unique_ptr<aura::Window> w2(
153 CreateTestWindowInShellWithDelegate(&d, -2, gfx::Rect())); 153 CreateTestWindowInShellWithDelegate(&d, -2, gfx::Rect()));
154 154
155 ::wm::AddTransientChild(w1.get(), w11.get()); 155 ::wm::AddTransientChild(w1.get(), w11.get());
156 ::wm::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
(...skipping 11 matching lines...) Expand all
174 // modal window. There is no such use case right now, but it 174 // modal window. There is no such use case right now, but it
175 // probably should. 175 // probably should.
176 176
177 w11.reset(); 177 w11.reset();
178 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); 178 EXPECT_TRUE(wm::IsActiveWindow(w1.get()));
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 std::unique_ptr<aura::Window> w1(
185 gfx::Rect(0, 0, 100, 100))); 185 CreateTestWindowInShellWithDelegate(&d, -1, gfx::Rect(0, 0, 100, 100)));
186 scoped_ptr<aura::Window> w11(CreateTestWindowInShellWithDelegate(&d, -11, 186 std::unique_ptr<aura::Window> w11(
187 gfx::Rect(20, 20, 50, 50))); 187 CreateTestWindowInShellWithDelegate(&d, -11, gfx::Rect(20, 20, 50, 50)));
188 scoped_ptr<aura::Window> w111( 188 std::unique_ptr<aura::Window> w111(
189 CreateTestWindowInShellWithDelegate(&d, -111, gfx::Rect(20, 20, 50, 50))); 189 CreateTestWindowInShellWithDelegate(&d, -111, gfx::Rect(20, 20, 50, 50)));
190 190
191 ::wm::AddTransientChild(w1.get(), w11.get()); 191 ::wm::AddTransientChild(w1.get(), w11.get());
192 192
193 // Add a non-modal child to the modal window in order to ensure modality still 193 // Add a non-modal child to the modal window in order to ensure modality still
194 // works in this case. This is a regression test for https://crbug.com/456697. 194 // works in this case. This is a regression test for https://crbug.com/456697.
195 ::wm::AddTransientChild(w11.get(), w111.get()); 195 ::wm::AddTransientChild(w11.get(), w111.get());
196 196
197 { 197 {
198 // Clicking a point within w1 should activate that window. 198 // Clicking a point within w1 should activate that window.
(...skipping 10 matching lines...) Expand all
209 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), 209 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
210 gfx::Point(10, 10)); 210 gfx::Point(10, 10));
211 generator.ClickLeftButton(); 211 generator.ClickLeftButton();
212 EXPECT_TRUE(wm::IsActiveWindow(w11.get())); 212 EXPECT_TRUE(wm::IsActiveWindow(w11.get()));
213 } 213 }
214 } 214 }
215 215
216 // Events on modal parent activate. 216 // Events on modal parent activate.
217 TEST_F(WindowModalityControllerTest, EventsForEclipsedWindows) { 217 TEST_F(WindowModalityControllerTest, EventsForEclipsedWindows) {
218 aura::test::TestWindowDelegate d; 218 aura::test::TestWindowDelegate d;
219 scoped_ptr<aura::Window> w1(CreateTestWindowInShellWithDelegate(&d, -1, 219 std::unique_ptr<aura::Window> w1(
220 gfx::Rect(0, 0, 100, 100))); 220 CreateTestWindowInShellWithDelegate(&d, -1, gfx::Rect(0, 0, 100, 100)));
221 scoped_ptr<aura::Window> w11(CreateTestWindowInShellWithDelegate(&d, -11, 221 std::unique_ptr<aura::Window> w11(
222 gfx::Rect(20, 20, 50, 50))); 222 CreateTestWindowInShellWithDelegate(&d, -11, gfx::Rect(20, 20, 50, 50)));
223 ::wm::AddTransientChild(w1.get(), w11.get()); 223 ::wm::AddTransientChild(w1.get(), w11.get());
224 scoped_ptr<aura::Window> w2(CreateTestWindowInShellWithDelegate(&d, -2, 224 std::unique_ptr<aura::Window> w2(
225 gfx::Rect(0, 0, 50, 50))); 225 CreateTestWindowInShellWithDelegate(&d, -2, gfx::Rect(0, 0, 50, 50)));
226 226
227 w11->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_WINDOW); 227 w11->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_WINDOW);
228 228
229 // Partially eclipse w1 with w2. 229 // Partially eclipse w1 with w2.
230 wm::ActivateWindow(w2.get()); 230 wm::ActivateWindow(w2.get());
231 { 231 {
232 // Clicking a point on w1 that is not eclipsed by w2. 232 // Clicking a point on w1 that is not eclipsed by w2.
233 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), 233 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
234 gfx::Point(90, 90)); 234 gfx::Point(90, 90));
235 generator.ClickLeftButton(); 235 generator.ClickLeftButton();
236 EXPECT_TRUE(wm::IsActiveWindow(w11.get())); 236 EXPECT_TRUE(wm::IsActiveWindow(w11.get()));
237 } 237 }
238 } 238 }
239 239
240 // Creates windows w1 and non activatiable child w11. Creates transient window 240 // Creates windows w1 and non activatiable child w11. Creates transient window
241 // w2 and adds it as a transeint child of w1. Ensures that w2 is parented to 241 // w2 and adds it as a transeint child of w1. Ensures that w2 is parented to
242 // the parent of w1, and that GetModalTransient(w11) returns w2. 242 // the parent of w1, and that GetModalTransient(w11) returns w2.
243 TEST_F(WindowModalityControllerTest, GetModalTransient) { 243 TEST_F(WindowModalityControllerTest, GetModalTransient) {
244 aura::test::TestWindowDelegate d; 244 aura::test::TestWindowDelegate d;
245 scoped_ptr<aura::Window> w1( 245 std::unique_ptr<aura::Window> w1(
246 CreateTestWindowInShellWithDelegate(&d, -1, gfx::Rect())); 246 CreateTestWindowInShellWithDelegate(&d, -1, gfx::Rect()));
247 scoped_ptr<aura::Window> w11( 247 std::unique_ptr<aura::Window> w11(
248 aura::test::CreateTestWindowWithDelegate(&d, -11, gfx::Rect(), w1.get())); 248 aura::test::CreateTestWindowWithDelegate(&d, -11, gfx::Rect(), w1.get()));
249 scoped_ptr<aura::Window> w2( 249 std::unique_ptr<aura::Window> w2(
250 CreateTestWindowInShellWithDelegate(&d, -2, gfx::Rect())); 250 CreateTestWindowInShellWithDelegate(&d, -2, gfx::Rect()));
251 w2->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_WINDOW); 251 w2->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_WINDOW);
252 252
253 aura::Window* wt; 253 aura::Window* wt;
254 wt = ::wm::GetModalTransient(w1.get()); 254 wt = ::wm::GetModalTransient(w1.get());
255 ASSERT_EQ(static_cast<aura::Window*>(NULL), wt); 255 ASSERT_EQ(static_cast<aura::Window*>(NULL), wt);
256 256
257 // Parent w2 to w1. It should get parented to the parent of w1. 257 // Parent w2 to w1. It should get parented to the parent of w1.
258 ::wm::AddTransientChild(w1.get(), w2.get()); 258 ::wm::AddTransientChild(w1.get(), w2.get());
259 ASSERT_EQ(2U, w1->parent()->children().size()); 259 ASSERT_EQ(2U, w1->parent()->children().size());
260 EXPECT_EQ(-2, w1->parent()->children().at(1)->id()); 260 EXPECT_EQ(-2, w1->parent()->children().at(1)->id());
261 261
262 // Request the modal transient window for w1, it should be w2. 262 // Request the modal transient window for w1, it should be w2.
263 wt = ::wm::GetModalTransient(w1.get()); 263 wt = ::wm::GetModalTransient(w1.get());
264 ASSERT_NE(static_cast<aura::Window*>(NULL), wt); 264 ASSERT_NE(static_cast<aura::Window*>(NULL), wt);
265 EXPECT_EQ(-2, wt->id()); 265 EXPECT_EQ(-2, wt->id());
266 266
267 // Request the modal transient window for w11, it should also be w2. 267 // Request the modal transient window for w11, it should also be w2.
268 wt = ::wm::GetModalTransient(w11.get()); 268 wt = ::wm::GetModalTransient(w11.get());
269 ASSERT_NE(static_cast<aura::Window*>(NULL), wt); 269 ASSERT_NE(static_cast<aura::Window*>(NULL), wt);
270 EXPECT_EQ(-2, wt->id()); 270 EXPECT_EQ(-2, wt->id());
271 } 271 }
272 272
273 // Verifies we generate a capture lost when showing a modal window. 273 // Verifies we generate a capture lost when showing a modal window.
274 TEST_F(WindowModalityControllerTest, ChangeCapture) { 274 TEST_F(WindowModalityControllerTest, ChangeCapture) {
275 views::Widget* widget = views::Widget::CreateWindowWithContext( 275 views::Widget* widget = views::Widget::CreateWindowWithContext(
276 NULL, Shell::GetPrimaryRootWindow()); 276 NULL, Shell::GetPrimaryRootWindow());
277 scoped_ptr<aura::Window> widget_window(widget->GetNativeView()); 277 std::unique_ptr<aura::Window> widget_window(widget->GetNativeView());
278 views::test::CaptureTrackingView* view = new views::test::CaptureTrackingView; 278 views::test::CaptureTrackingView* view = new views::test::CaptureTrackingView;
279 widget->client_view()->AddChildView(view); 279 widget->client_view()->AddChildView(view);
280 widget->SetBounds(gfx::Rect(0, 0, 200, 200)); 280 widget->SetBounds(gfx::Rect(0, 0, 200, 200));
281 view->SetBoundsRect(widget->client_view()->GetLocalBounds()); 281 view->SetBoundsRect(widget->client_view()->GetLocalBounds());
282 widget->Show(); 282 widget->Show();
283 283
284 gfx::Point center(view->width() / 2, view->height() / 2); 284 gfx::Point center(view->width() / 2, view->height() / 2);
285 views::View::ConvertPointToScreen(view, &center); 285 views::View::ConvertPointToScreen(view, &center);
286 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), center); 286 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), center);
287 generator.PressLeftButton(); 287 generator.PressLeftButton();
288 EXPECT_TRUE(view->got_press()); 288 EXPECT_TRUE(view->got_press());
289 289
290 views::Widget* modal_widget = 290 views::Widget* modal_widget =
291 views::Widget::CreateWindowWithParent(NULL, widget->GetNativeView()); 291 views::Widget::CreateWindowWithParent(NULL, widget->GetNativeView());
292 scoped_ptr<aura::Window> modal_window(modal_widget->GetNativeView()); 292 std::unique_ptr<aura::Window> modal_window(modal_widget->GetNativeView());
293 modal_window->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_WINDOW); 293 modal_window->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_WINDOW);
294 views::test::CaptureTrackingView* modal_view = 294 views::test::CaptureTrackingView* modal_view =
295 new views::test::CaptureTrackingView; 295 new views::test::CaptureTrackingView;
296 modal_widget->client_view()->AddChildView(modal_view); 296 modal_widget->client_view()->AddChildView(modal_view);
297 modal_widget->SetBounds(gfx::Rect(50, 50, 200, 200)); 297 modal_widget->SetBounds(gfx::Rect(50, 50, 200, 200));
298 modal_view->SetBoundsRect(modal_widget->client_view()->GetLocalBounds()); 298 modal_view->SetBoundsRect(modal_widget->client_view()->GetLocalBounds());
299 modal_widget->Show(); 299 modal_widget->Show();
300 300
301 EXPECT_TRUE(view->got_capture_lost()); 301 EXPECT_TRUE(view->got_capture_lost());
302 generator.ReleaseLeftButton(); 302 generator.ReleaseLeftButton();
(...skipping 18 matching lines...) Expand all
321 // modal window's modal parent window. 321 // modal window's modal parent window.
322 TEST_F(WindowModalityControllerTest, ReleaseCapture) { 322 TEST_F(WindowModalityControllerTest, ReleaseCapture) {
323 // Create a window hierachy like this: 323 // Create a window hierachy like this:
324 // w0 324 // w0
325 // / | \ 325 // / | \
326 // w1 <------ w3 w2 326 // w1 <------ w3 w2
327 // | (modal to) 327 // | (modal to)
328 // w11 328 // w11
329 329
330 aura::test::TestWindowDelegate d; 330 aura::test::TestWindowDelegate d;
331 scoped_ptr<aura::Window> w1( 331 std::unique_ptr<aura::Window> w1(
332 CreateTestWindowInShellWithDelegate(&d, -1, gfx::Rect())); 332 CreateTestWindowInShellWithDelegate(&d, -1, gfx::Rect()));
333 scoped_ptr<aura::Window> w11( 333 std::unique_ptr<aura::Window> w11(
334 aura::test::CreateTestWindowWithDelegate(&d, -11, gfx::Rect(), w1.get())); 334 aura::test::CreateTestWindowWithDelegate(&d, -11, gfx::Rect(), w1.get()));
335 scoped_ptr<aura::Window> w2( 335 std::unique_ptr<aura::Window> w2(
336 CreateTestWindowInShellWithDelegate(&d, -2, gfx::Rect())); 336 CreateTestWindowInShellWithDelegate(&d, -2, gfx::Rect()));
337 scoped_ptr<aura::Window> w3( 337 std::unique_ptr<aura::Window> w3(
338 CreateTestWindowInShellWithDelegate(&d, -2, gfx::Rect())); 338 CreateTestWindowInShellWithDelegate(&d, -2, gfx::Rect()));
339 w3->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_CHILD); 339 w3->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_CHILD);
340 ::wm::SetModalParent(w3.get(), w1.get()); 340 ::wm::SetModalParent(w3.get(), w1.get());
341 341
342 // w1's capture should be released when w3 becomes visible. 342 // w1's capture should be released when w3 becomes visible.
343 w3->Hide(); 343 w3->Hide();
344 aura::client::GetCaptureClient(Shell::GetPrimaryRootWindow()) 344 aura::client::GetCaptureClient(Shell::GetPrimaryRootWindow())
345 ->SetCapture(w1.get()); 345 ->SetCapture(w1.get());
346 EXPECT_EQ(w1.get(), 346 EXPECT_EQ(w1.get(),
347 aura::client::GetCaptureClient(Shell::GetPrimaryRootWindow()) 347 aura::client::GetCaptureClient(Shell::GetPrimaryRootWindow())
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 402
403 bool received_touch_; 403 bool received_touch_;
404 ui::EventType last_event_type_; 404 ui::EventType last_event_type_;
405 405
406 DISALLOW_COPY_AND_ASSIGN(TouchTrackerWindowDelegate); 406 DISALLOW_COPY_AND_ASSIGN(TouchTrackerWindowDelegate);
407 }; 407 };
408 408
409 // Modality should prevent events from being passed to the transient parent. 409 // Modality should prevent events from being passed to the transient parent.
410 TEST_F(WindowModalityControllerTest, TouchEvent) { 410 TEST_F(WindowModalityControllerTest, TouchEvent) {
411 TouchTrackerWindowDelegate d1; 411 TouchTrackerWindowDelegate d1;
412 scoped_ptr<aura::Window> w1(CreateTestWindowInShellWithDelegate(&d1, 412 std::unique_ptr<aura::Window> w1(
413 -1, gfx::Rect(0, 0, 100, 100))); 413 CreateTestWindowInShellWithDelegate(&d1, -1, gfx::Rect(0, 0, 100, 100)));
414 TouchTrackerWindowDelegate d11; 414 TouchTrackerWindowDelegate d11;
415 scoped_ptr<aura::Window> w11(CreateTestWindowInShellWithDelegate(&d11, 415 std::unique_ptr<aura::Window> w11(CreateTestWindowInShellWithDelegate(
416 -11, gfx::Rect(20, 20, 50, 50))); 416 &d11, -11, gfx::Rect(20, 20, 50, 50)));
417 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), 417 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
418 gfx::Point(10, 10)); 418 gfx::Point(10, 10));
419 419
420 ::wm::AddTransientChild(w1.get(), w11.get()); 420 ::wm::AddTransientChild(w1.get(), w11.get());
421 d1.reset(); 421 d1.reset();
422 d11.reset(); 422 d11.reset();
423 423
424 { 424 {
425 // Clicking a point within w1 should activate that window. 425 // Clicking a point within w1 should activate that window.
426 generator.PressMoveAndReleaseTouchTo(gfx::Point(10, 10)); 426 generator.PressMoveAndReleaseTouchTo(gfx::Point(10, 10));
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 EXPECT_TRUE(child->HasFocus()); 590 EXPECT_TRUE(child->HasFocus());
591 EXPECT_FALSE(modal_parent->HasFocus()); 591 EXPECT_FALSE(modal_parent->HasFocus());
592 EXPECT_FALSE(parent->HasFocus()); 592 EXPECT_FALSE(parent->HasFocus());
593 } 593 }
594 } 594 }
595 595
596 // Window-modal test for the case when the originally clicked window is an 596 // Window-modal test for the case when the originally clicked window is an
597 // ancestor of the modal parent. 597 // ancestor of the modal parent.
598 TEST_F(WindowModalityControllerTest, WindowModalAncestor) { 598 TEST_F(WindowModalityControllerTest, WindowModalAncestor) {
599 aura::test::TestWindowDelegate d; 599 aura::test::TestWindowDelegate d;
600 scoped_ptr<aura::Window> w1( 600 std::unique_ptr<aura::Window> w1(
601 CreateTestWindowInShellWithDelegate(&d, -1, gfx::Rect())); 601 CreateTestWindowInShellWithDelegate(&d, -1, gfx::Rect()));
602 scoped_ptr<aura::Window> w2( 602 std::unique_ptr<aura::Window> w2(
603 aura::test::CreateTestWindowWithDelegate(&d, -11, gfx::Rect(), w1.get())); 603 aura::test::CreateTestWindowWithDelegate(&d, -11, gfx::Rect(), w1.get()));
604 scoped_ptr<aura::Window> w3( 604 std::unique_ptr<aura::Window> w3(
605 aura::test::CreateTestWindowWithDelegate(&d, -11, gfx::Rect(), w2.get())); 605 aura::test::CreateTestWindowWithDelegate(&d, -11, gfx::Rect(), w2.get()));
606 scoped_ptr<aura::Window> w4( 606 std::unique_ptr<aura::Window> w4(
607 CreateTestWindowInShellWithDelegate(&d, -2, gfx::Rect())); 607 CreateTestWindowInShellWithDelegate(&d, -2, gfx::Rect()));
608 w4->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_WINDOW); 608 w4->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_WINDOW);
609 ::wm::AddTransientChild(w1.get(), w4.get()); 609 ::wm::AddTransientChild(w1.get(), w4.get());
610 610
611 wm::ActivateWindow(w1.get()); 611 wm::ActivateWindow(w1.get());
612 EXPECT_TRUE(wm::IsActiveWindow(w4.get())); 612 EXPECT_TRUE(wm::IsActiveWindow(w4.get()));
613 613
614 wm::ActivateWindow(w2.get()); 614 wm::ActivateWindow(w2.get());
615 EXPECT_TRUE(wm::IsActiveWindow(w4.get())); 615 EXPECT_TRUE(wm::IsActiveWindow(w4.get()));
616 616
617 wm::ActivateWindow(w3.get()); 617 wm::ActivateWindow(w3.get());
618 EXPECT_TRUE(wm::IsActiveWindow(w4.get())); 618 EXPECT_TRUE(wm::IsActiveWindow(w4.get()));
619 619
620 wm::ActivateWindow(w4.get()); 620 wm::ActivateWindow(w4.get());
621 EXPECT_TRUE(wm::IsActiveWindow(w4.get())); 621 EXPECT_TRUE(wm::IsActiveWindow(w4.get()));
622 } 622 }
623 623
624 // Child-modal test for the case when the originally clicked window is an 624 // Child-modal test for the case when the originally clicked window is an
625 // ancestor of the modal parent. 625 // ancestor of the modal parent.
626 TEST_F(WindowModalityControllerTest, ChildModalAncestor) { 626 TEST_F(WindowModalityControllerTest, ChildModalAncestor) {
627 aura::test::TestWindowDelegate d; 627 aura::test::TestWindowDelegate d;
628 scoped_ptr<aura::Window> w1( 628 std::unique_ptr<aura::Window> w1(
629 CreateTestWindowInShellWithDelegate(&d, -1, gfx::Rect())); 629 CreateTestWindowInShellWithDelegate(&d, -1, gfx::Rect()));
630 scoped_ptr<aura::Window> w2( 630 std::unique_ptr<aura::Window> w2(
631 aura::test::CreateTestWindowWithDelegate(&d, -11, gfx::Rect(), w1.get())); 631 aura::test::CreateTestWindowWithDelegate(&d, -11, gfx::Rect(), w1.get()));
632 scoped_ptr<aura::Window> w3( 632 std::unique_ptr<aura::Window> w3(
633 aura::test::CreateTestWindowWithDelegate(&d, -11, gfx::Rect(), w2.get())); 633 aura::test::CreateTestWindowWithDelegate(&d, -11, gfx::Rect(), w2.get()));
634 scoped_ptr<aura::Window> w4( 634 std::unique_ptr<aura::Window> w4(
635 CreateTestWindowInShellWithDelegate(&d, -2, gfx::Rect())); 635 CreateTestWindowInShellWithDelegate(&d, -2, gfx::Rect()));
636 w4->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_CHILD); 636 w4->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_CHILD);
637 ::wm::SetModalParent(w4.get(), w2.get()); 637 ::wm::SetModalParent(w4.get(), w2.get());
638 ::wm::AddTransientChild(w1.get(), w4.get()); 638 ::wm::AddTransientChild(w1.get(), w4.get());
639 639
640 wm::ActivateWindow(w1.get()); 640 wm::ActivateWindow(w1.get());
641 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); 641 EXPECT_TRUE(wm::IsActiveWindow(w1.get()));
642 642
643 wm::ActivateWindow(w2.get()); 643 wm::ActivateWindow(w2.get());
644 EXPECT_TRUE(wm::IsActiveWindow(w4.get())); 644 EXPECT_TRUE(wm::IsActiveWindow(w4.get()));
645 645
646 wm::ActivateWindow(w3.get()); 646 wm::ActivateWindow(w3.get());
647 EXPECT_TRUE(wm::IsActiveWindow(w4.get())); 647 EXPECT_TRUE(wm::IsActiveWindow(w4.get()));
648 648
649 wm::ActivateWindow(w4.get()); 649 wm::ActivateWindow(w4.get());
650 EXPECT_TRUE(wm::IsActiveWindow(w4.get())); 650 EXPECT_TRUE(wm::IsActiveWindow(w4.get()));
651 } 651 }
652 652
653 } // namespace ash 653 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/window_manager_unittest.cc ('k') | ash/wm/window_resizer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698