OLD | NEW |
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 "ash/shell.h" | 5 #include "ash/shell.h" |
6 #include "ash/shell_window_ids.h" | 6 #include "ash/shell_window_ids.h" |
7 #include "ash/test/ash_test_base.h" | 7 #include "ash/test/ash_test_base.h" |
8 #include "ash/test/test_activation_delegate.h" | 8 #include "ash/test/test_activation_delegate.h" |
9 #include "ash/wm/window_util.h" | 9 #include "ash/wm/window_util.h" |
10 #include "ui/aura/client/cursor_client_observer.h" | 10 #include "ui/aura/client/cursor_client_observer.h" |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 // The IME event filter interferes with the basic key event propagation we | 135 // The IME event filter interferes with the basic key event propagation we |
136 // attempt to do here, so we disable it. | 136 // attempt to do here, so we disable it. |
137 // | 137 // |
138 DisableIME(); | 138 DisableIME(); |
139 aura::Window* root_window = Shell::GetPrimaryRootWindow(); | 139 aura::Window* root_window = Shell::GetPrimaryRootWindow(); |
140 root_window->SetBounds(gfx::Rect(0, 0, 510, 510)); | 140 root_window->SetBounds(gfx::Rect(0, 0, 510, 510)); |
141 | 141 |
142 // Supplied ids are negative so as not to collide with shell ids. | 142 // Supplied ids are negative so as not to collide with shell ids. |
143 // TODO(beng): maybe introduce a MAKE_SHELL_ID() macro that generates a safe | 143 // TODO(beng): maybe introduce a MAKE_SHELL_ID() macro that generates a safe |
144 // id beyond shell id max? | 144 // id beyond shell id max? |
145 scoped_ptr<aura::Window> w1(CreateTestWindowInShell( | 145 std::unique_ptr<aura::Window> w1( |
146 SK_ColorWHITE, -1, gfx::Rect(10, 10, 500, 500))); | 146 CreateTestWindowInShell(SK_ColorWHITE, -1, gfx::Rect(10, 10, 500, 500))); |
147 scoped_ptr<aura::Window> w11(aura::test::CreateTestWindow( | 147 std::unique_ptr<aura::Window> w11(aura::test::CreateTestWindow( |
148 SK_ColorGREEN, -11, gfx::Rect(5, 5, 100, 100), w1.get())); | 148 SK_ColorGREEN, -11, gfx::Rect(5, 5, 100, 100), w1.get())); |
149 scoped_ptr<aura::Window> w111(aura::test::CreateTestWindow( | 149 std::unique_ptr<aura::Window> w111(aura::test::CreateTestWindow( |
150 SK_ColorCYAN, -111, gfx::Rect(5, 5, 75, 75), w11.get())); | 150 SK_ColorCYAN, -111, gfx::Rect(5, 5, 75, 75), w11.get())); |
151 scoped_ptr<aura::Window> w1111(aura::test::CreateTestWindow( | 151 std::unique_ptr<aura::Window> w1111(aura::test::CreateTestWindow( |
152 SK_ColorRED, -1111, gfx::Rect(5, 5, 50, 50), w111.get())); | 152 SK_ColorRED, -1111, gfx::Rect(5, 5, 50, 50), w111.get())); |
153 scoped_ptr<aura::Window> w12(aura::test::CreateTestWindow( | 153 std::unique_ptr<aura::Window> w12(aura::test::CreateTestWindow( |
154 SK_ColorMAGENTA, -12, gfx::Rect(10, 420, 25, 25), w1.get())); | 154 SK_ColorMAGENTA, -12, gfx::Rect(10, 420, 25, 25), w1.get())); |
155 aura::test::ColorTestWindowDelegate* w121delegate = | 155 aura::test::ColorTestWindowDelegate* w121delegate = |
156 new aura::test::ColorTestWindowDelegate(SK_ColorYELLOW); | 156 new aura::test::ColorTestWindowDelegate(SK_ColorYELLOW); |
157 scoped_ptr<aura::Window> w121(aura::test::CreateTestWindowWithDelegate( | 157 std::unique_ptr<aura::Window> w121(aura::test::CreateTestWindowWithDelegate( |
158 w121delegate, -121, gfx::Rect(5, 5, 5, 5), w12.get())); | 158 w121delegate, -121, gfx::Rect(5, 5, 5, 5), w12.get())); |
159 aura::test::ColorTestWindowDelegate* w122delegate = | 159 aura::test::ColorTestWindowDelegate* w122delegate = |
160 new aura::test::ColorTestWindowDelegate(SK_ColorRED); | 160 new aura::test::ColorTestWindowDelegate(SK_ColorRED); |
161 scoped_ptr<aura::Window> w122(aura::test::CreateTestWindowWithDelegate( | 161 std::unique_ptr<aura::Window> w122(aura::test::CreateTestWindowWithDelegate( |
162 w122delegate, -122, gfx::Rect(10, 5, 5, 5), w12.get())); | 162 w122delegate, -122, gfx::Rect(10, 5, 5, 5), w12.get())); |
163 aura::test::ColorTestWindowDelegate* w123delegate = | 163 aura::test::ColorTestWindowDelegate* w123delegate = |
164 new aura::test::ColorTestWindowDelegate(SK_ColorRED); | 164 new aura::test::ColorTestWindowDelegate(SK_ColorRED); |
165 scoped_ptr<aura::Window> w123(aura::test::CreateTestWindowWithDelegate( | 165 std::unique_ptr<aura::Window> w123(aura::test::CreateTestWindowWithDelegate( |
166 w123delegate, -123, gfx::Rect(15, 5, 5, 5), w12.get())); | 166 w123delegate, -123, gfx::Rect(15, 5, 5, 5), w12.get())); |
167 scoped_ptr<aura::Window> w13(aura::test::CreateTestWindow( | 167 std::unique_ptr<aura::Window> w13(aura::test::CreateTestWindow( |
168 SK_ColorGRAY, -13, gfx::Rect(5, 470, 50, 50), w1.get())); | 168 SK_ColorGRAY, -13, gfx::Rect(5, 470, 50, 50), w1.get())); |
169 | 169 |
170 // Click on a sub-window (w121) to focus it. | 170 // Click on a sub-window (w121) to focus it. |
171 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), w121.get()); | 171 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), w121.get()); |
172 generator.ClickLeftButton(); | 172 generator.ClickLeftButton(); |
173 | 173 |
174 aura::client::FocusClient* focus_client = | 174 aura::client::FocusClient* focus_client = |
175 aura::client::GetFocusClient(w121.get()); | 175 aura::client::GetFocusClient(w121.get()); |
176 EXPECT_EQ(w121.get(), focus_client->GetFocusedWindow()); | 176 EXPECT_EQ(w121.get(), focus_client->GetFocusedWindow()); |
177 | 177 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 // the windows. | 256 // the windows. |
257 aura::client::SetActivationDelegate(w1.get(), NULL); | 257 aura::client::SetActivationDelegate(w1.get(), NULL); |
258 } | 258 } |
259 | 259 |
260 // Various assertion testing for activating windows. | 260 // Various assertion testing for activating windows. |
261 TEST_F(WindowManagerTest, ActivateOnMouse) { | 261 TEST_F(WindowManagerTest, ActivateOnMouse) { |
262 aura::Window* root_window = Shell::GetPrimaryRootWindow(); | 262 aura::Window* root_window = Shell::GetPrimaryRootWindow(); |
263 | 263 |
264 test::TestActivationDelegate d1; | 264 test::TestActivationDelegate d1; |
265 aura::test::TestWindowDelegate wd; | 265 aura::test::TestWindowDelegate wd; |
266 scoped_ptr<aura::Window> w1(CreateTestWindowInShellWithDelegate( | 266 std::unique_ptr<aura::Window> w1( |
267 &wd, -1, gfx::Rect(10, 10, 50, 50))); | 267 CreateTestWindowInShellWithDelegate(&wd, -1, gfx::Rect(10, 10, 50, 50))); |
268 d1.SetWindow(w1.get()); | 268 d1.SetWindow(w1.get()); |
269 test::TestActivationDelegate d2; | 269 test::TestActivationDelegate d2; |
270 scoped_ptr<aura::Window> w2(CreateTestWindowInShellWithDelegate( | 270 std::unique_ptr<aura::Window> w2( |
271 &wd, -2, gfx::Rect(70, 70, 50, 50))); | 271 CreateTestWindowInShellWithDelegate(&wd, -2, gfx::Rect(70, 70, 50, 50))); |
272 d2.SetWindow(w2.get()); | 272 d2.SetWindow(w2.get()); |
273 | 273 |
274 aura::client::FocusClient* focus_client = | 274 aura::client::FocusClient* focus_client = |
275 aura::client::GetFocusClient(w1.get()); | 275 aura::client::GetFocusClient(w1.get()); |
276 | 276 |
277 d1.Clear(); | 277 d1.Clear(); |
278 d2.Clear(); | 278 d2.Clear(); |
279 | 279 |
280 // Activate window1. | 280 // Activate window1. |
281 wm::ActivateWindow(w1.get()); | 281 wm::ActivateWindow(w1.get()); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 EXPECT_EQ(0, d2.activated_count()); | 324 EXPECT_EQ(0, d2.activated_count()); |
325 EXPECT_EQ(1, d2.lost_active_count()); | 325 EXPECT_EQ(1, d2.lost_active_count()); |
326 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); | 326 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); |
327 EXPECT_EQ(w1.get(), focus_client->GetFocusedWindow()); | 327 EXPECT_EQ(w1.get(), focus_client->GetFocusedWindow()); |
328 EXPECT_EQ(1, d1.activated_count()); | 328 EXPECT_EQ(1, d1.activated_count()); |
329 EXPECT_EQ(0, d1.lost_active_count()); | 329 EXPECT_EQ(0, d1.lost_active_count()); |
330 | 330 |
331 // Clicking an active window with a child shouldn't steal the | 331 // Clicking an active window with a child shouldn't steal the |
332 // focus from the child. | 332 // focus from the child. |
333 { | 333 { |
334 scoped_ptr<aura::Window> w11(CreateTestWindowWithDelegate( | 334 std::unique_ptr<aura::Window> w11(CreateTestWindowWithDelegate( |
335 &wd, -11, gfx::Rect(10, 10, 10, 10), w1.get())); | 335 &wd, -11, gfx::Rect(10, 10, 10, 10), w1.get())); |
336 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), | 336 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), |
337 w11.get()); | 337 w11.get()); |
338 // First set the focus to the child |w11|. | 338 // First set the focus to the child |w11|. |
339 generator.ClickLeftButton(); | 339 generator.ClickLeftButton(); |
340 EXPECT_EQ(w11.get(), focus_client->GetFocusedWindow()); | 340 EXPECT_EQ(w11.get(), focus_client->GetFocusedWindow()); |
341 EXPECT_EQ(w1.get(), wm::GetActiveWindow()); | 341 EXPECT_EQ(w1.get(), wm::GetActiveWindow()); |
342 | 342 |
343 // Then click the parent active window. The focus shouldn't move. | 343 // Then click the parent active window. The focus shouldn't move. |
344 gfx::Point left_top = w1->bounds().origin(); | 344 gfx::Point left_top = w1->bounds().origin(); |
345 aura::Window::ConvertPointToTarget(w1->parent(), root_window, &left_top); | 345 aura::Window::ConvertPointToTarget(w1->parent(), root_window, &left_top); |
346 left_top.Offset(1, 1); | 346 left_top.Offset(1, 1); |
347 generator.MoveMouseTo(left_top); | 347 generator.MoveMouseTo(left_top); |
348 generator.ClickLeftButton(); | 348 generator.ClickLeftButton(); |
349 EXPECT_EQ(w11.get(), focus_client->GetFocusedWindow()); | 349 EXPECT_EQ(w11.get(), focus_client->GetFocusedWindow()); |
350 EXPECT_EQ(w1.get(), wm::GetActiveWindow()); | 350 EXPECT_EQ(w1.get(), wm::GetActiveWindow()); |
351 } | 351 } |
352 | 352 |
353 // Clicking on a non-focusable window inside a background window should still | 353 // Clicking on a non-focusable window inside a background window should still |
354 // give focus to the background window. | 354 // give focus to the background window. |
355 { | 355 { |
356 NonFocusableDelegate nfd; | 356 NonFocusableDelegate nfd; |
357 scoped_ptr<aura::Window> w11(CreateTestWindowWithDelegate( | 357 std::unique_ptr<aura::Window> w11(CreateTestWindowWithDelegate( |
358 &nfd, -1, gfx::Rect(10, 10, 10, 10), w1.get())); | 358 &nfd, -1, gfx::Rect(10, 10, 10, 10), w1.get())); |
359 // Move focus to |w2| first. | 359 // Move focus to |w2| first. |
360 scoped_ptr<aura::Window> w2(CreateTestWindowInShellWithDelegate( | 360 std::unique_ptr<aura::Window> w2(CreateTestWindowInShellWithDelegate( |
361 &wd, -1, gfx::Rect(70, 70, 50, 50))); | 361 &wd, -1, gfx::Rect(70, 70, 50, 50))); |
362 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), w2.get()); | 362 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), w2.get()); |
363 generator.ClickLeftButton(); | 363 generator.ClickLeftButton(); |
364 EXPECT_EQ(w2.get(), focus_client->GetFocusedWindow()); | 364 EXPECT_EQ(w2.get(), focus_client->GetFocusedWindow()); |
365 EXPECT_FALSE(w11->CanFocus()); | 365 EXPECT_FALSE(w11->CanFocus()); |
366 | 366 |
367 // Click on |w11|. This should focus w1. | 367 // Click on |w11|. This should focus w1. |
368 generator.MoveMouseToCenterOf(w11.get()); | 368 generator.MoveMouseToCenterOf(w11.get()); |
369 generator.ClickLeftButton(); | 369 generator.ClickLeftButton(); |
370 EXPECT_EQ(w1.get(), focus_client->GetFocusedWindow()); | 370 EXPECT_EQ(w1.get(), focus_client->GetFocusedWindow()); |
371 } | 371 } |
372 } | 372 } |
373 | 373 |
374 TEST_F(WindowManagerTest, PanelActivation) { | 374 TEST_F(WindowManagerTest, PanelActivation) { |
375 aura::test::TestWindowDelegate wd; | 375 aura::test::TestWindowDelegate wd; |
376 scoped_ptr<aura::Window> w1(CreateTestWindowInShellWithDelegate( | 376 std::unique_ptr<aura::Window> w1( |
377 &wd, -1, gfx::Rect(10, 10, 50, 50))); | 377 CreateTestWindowInShellWithDelegate(&wd, -1, gfx::Rect(10, 10, 50, 50))); |
378 aura::test::TestWindowDelegate pd; | 378 aura::test::TestWindowDelegate pd; |
379 scoped_ptr<aura::Window> p1(CreateTestWindowInShellWithDelegateAndType( | 379 std::unique_ptr<aura::Window> p1(CreateTestWindowInShellWithDelegateAndType( |
380 &pd, ui::wm::WINDOW_TYPE_PANEL, -1, gfx::Rect(10, 10, 50, 50))); | 380 &pd, ui::wm::WINDOW_TYPE_PANEL, -1, gfx::Rect(10, 10, 50, 50))); |
381 aura::client::FocusClient* focus_client = | 381 aura::client::FocusClient* focus_client = |
382 aura::client::GetFocusClient(w1.get()); | 382 aura::client::GetFocusClient(w1.get()); |
383 | 383 |
384 // Activate w1. | 384 // Activate w1. |
385 wm::ActivateWindow(w1.get()); | 385 wm::ActivateWindow(w1.get()); |
386 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); | 386 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); |
387 | 387 |
388 // Activate p1. | 388 // Activate p1. |
389 wm::ActivateWindow(p1.get()); | 389 wm::ActivateWindow(p1.get()); |
390 EXPECT_TRUE(wm::IsActiveWindow(p1.get())); | 390 EXPECT_TRUE(wm::IsActiveWindow(p1.get())); |
391 EXPECT_EQ(p1.get(), focus_client->GetFocusedWindow()); | 391 EXPECT_EQ(p1.get(), focus_client->GetFocusedWindow()); |
392 | 392 |
393 // Activate w1. | 393 // Activate w1. |
394 wm::ActivateWindow(w1.get()); | 394 wm::ActivateWindow(w1.get()); |
395 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); | 395 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); |
396 EXPECT_EQ(w1.get(), focus_client->GetFocusedWindow()); | 396 EXPECT_EQ(w1.get(), focus_client->GetFocusedWindow()); |
397 | 397 |
398 // Clicking on a non-activatable window should not change the active window. | 398 // Clicking on a non-activatable window should not change the active window. |
399 { | 399 { |
400 NonFocusableDelegate nfd; | 400 NonFocusableDelegate nfd; |
401 scoped_ptr<aura::Window> w3(CreateTestWindowInShellWithDelegate( | 401 std::unique_ptr<aura::Window> w3(CreateTestWindowInShellWithDelegate( |
402 &nfd, -1, gfx::Rect(70, 70, 50, 50))); | 402 &nfd, -1, gfx::Rect(70, 70, 50, 50))); |
403 ui::test::EventGenerator generator3(Shell::GetPrimaryRootWindow(), | 403 ui::test::EventGenerator generator3(Shell::GetPrimaryRootWindow(), |
404 w3.get()); | 404 w3.get()); |
405 wm::ActivateWindow(p1.get()); | 405 wm::ActivateWindow(p1.get()); |
406 EXPECT_TRUE(wm::IsActiveWindow(p1.get())); | 406 EXPECT_TRUE(wm::IsActiveWindow(p1.get())); |
407 generator3.ClickLeftButton(); | 407 generator3.ClickLeftButton(); |
408 EXPECT_TRUE(wm::IsActiveWindow(p1.get())); | 408 EXPECT_TRUE(wm::IsActiveWindow(p1.get())); |
409 } | 409 } |
410 } | 410 } |
411 | 411 |
412 // Essentially the same as ActivateOnMouse, but for touch events. | 412 // Essentially the same as ActivateOnMouse, but for touch events. |
413 TEST_F(WindowManagerTest, ActivateOnTouch) { | 413 TEST_F(WindowManagerTest, ActivateOnTouch) { |
414 aura::Window* root_window = Shell::GetPrimaryRootWindow(); | 414 aura::Window* root_window = Shell::GetPrimaryRootWindow(); |
415 | 415 |
416 test::TestActivationDelegate d1; | 416 test::TestActivationDelegate d1; |
417 aura::test::TestWindowDelegate wd; | 417 aura::test::TestWindowDelegate wd; |
418 scoped_ptr<aura::Window> w1(CreateTestWindowInShellWithDelegate( | 418 std::unique_ptr<aura::Window> w1( |
419 &wd, -1, gfx::Rect(10, 10, 50, 50))); | 419 CreateTestWindowInShellWithDelegate(&wd, -1, gfx::Rect(10, 10, 50, 50))); |
420 d1.SetWindow(w1.get()); | 420 d1.SetWindow(w1.get()); |
421 test::TestActivationDelegate d2; | 421 test::TestActivationDelegate d2; |
422 scoped_ptr<aura::Window> w2(CreateTestWindowInShellWithDelegate( | 422 std::unique_ptr<aura::Window> w2( |
423 &wd, -2, gfx::Rect(70, 70, 50, 50))); | 423 CreateTestWindowInShellWithDelegate(&wd, -2, gfx::Rect(70, 70, 50, 50))); |
424 d2.SetWindow(w2.get()); | 424 d2.SetWindow(w2.get()); |
425 | 425 |
426 aura::client::FocusClient* focus_client = | 426 aura::client::FocusClient* focus_client = |
427 aura::client::GetFocusClient(w1.get()); | 427 aura::client::GetFocusClient(w1.get()); |
428 | 428 |
429 d1.Clear(); | 429 d1.Clear(); |
430 d2.Clear(); | 430 d2.Clear(); |
431 | 431 |
432 // Activate window1. | 432 // Activate window1. |
433 wm::ActivateWindow(w1.get()); | 433 wm::ActivateWindow(w1.get()); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 EXPECT_EQ(0, d1.lost_active_count()); | 485 EXPECT_EQ(0, d1.lost_active_count()); |
486 } | 486 } |
487 | 487 |
488 TEST_F(WindowManagerTest, MouseEventCursors) { | 488 TEST_F(WindowManagerTest, MouseEventCursors) { |
489 aura::Window* root_window = Shell::GetPrimaryRootWindow(); | 489 aura::Window* root_window = Shell::GetPrimaryRootWindow(); |
490 | 490 |
491 // Create a window. | 491 // Create a window. |
492 const int kWindowLeft = 123; | 492 const int kWindowLeft = 123; |
493 const int kWindowTop = 45; | 493 const int kWindowTop = 45; |
494 HitTestWindowDelegate window_delegate; | 494 HitTestWindowDelegate window_delegate; |
495 scoped_ptr<aura::Window> window(CreateTestWindowInShellWithDelegate( | 495 std::unique_ptr<aura::Window> window(CreateTestWindowInShellWithDelegate( |
496 &window_delegate, | 496 &window_delegate, -1, gfx::Rect(kWindowLeft, kWindowTop, 640, 480))); |
497 -1, | |
498 gfx::Rect(kWindowLeft, kWindowTop, 640, 480))); | |
499 | 497 |
500 // Create two mouse movement events we can switch between. | 498 // Create two mouse movement events we can switch between. |
501 gfx::Point point1(kWindowLeft, kWindowTop); | 499 gfx::Point point1(kWindowLeft, kWindowTop); |
502 aura::Window::ConvertPointToTarget(window->parent(), root_window, &point1); | 500 aura::Window::ConvertPointToTarget(window->parent(), root_window, &point1); |
503 | 501 |
504 gfx::Point point2(kWindowLeft + 1, kWindowTop + 1); | 502 gfx::Point point2(kWindowLeft + 1, kWindowTop + 1); |
505 aura::Window::ConvertPointToTarget(window->parent(), root_window, &point2); | 503 aura::Window::ConvertPointToTarget(window->parent(), root_window, &point2); |
506 | 504 |
507 aura::WindowTreeHost* host = root_window->GetHost(); | 505 aura::WindowTreeHost* host = root_window->GetHost(); |
508 ui::EventProcessor* dispatcher = host->event_processor(); | 506 ui::EventProcessor* dispatcher = host->event_processor(); |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
609 .ToString()); | 607 .ToString()); |
610 | 608 |
611 // Rotate it clock-wise 90 degrees. | 609 // Rotate it clock-wise 90 degrees. |
612 gfx::Transform transform; | 610 gfx::Transform transform; |
613 transform.Translate(size.width(), 0); | 611 transform.Translate(size.width(), 0); |
614 transform.Rotate(90.0f); | 612 transform.Rotate(90.0f); |
615 root_window->GetHost()->SetRootTransform(transform); | 613 root_window->GetHost()->SetRootTransform(transform); |
616 | 614 |
617 test::TestActivationDelegate d1; | 615 test::TestActivationDelegate d1; |
618 aura::test::TestWindowDelegate wd; | 616 aura::test::TestWindowDelegate wd; |
619 scoped_ptr<aura::Window> w1( | 617 std::unique_ptr<aura::Window> w1( |
620 CreateTestWindowInShellWithDelegate(&wd, 1, gfx::Rect(0, 15, 50, 50))); | 618 CreateTestWindowInShellWithDelegate(&wd, 1, gfx::Rect(0, 15, 50, 50))); |
621 d1.SetWindow(w1.get()); | 619 d1.SetWindow(w1.get()); |
622 w1->Show(); | 620 w1->Show(); |
623 | 621 |
624 gfx::Point miss_point(5, 5); | 622 gfx::Point miss_point(5, 5); |
625 transform.TransformPoint(&miss_point); | 623 transform.TransformPoint(&miss_point); |
626 ui::MouseEvent mouseev1(ui::ET_MOUSE_PRESSED, miss_point, miss_point, | 624 ui::MouseEvent mouseev1(ui::ET_MOUSE_PRESSED, miss_point, miss_point, |
627 ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, | 625 ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, |
628 ui::EF_LEFT_MOUSE_BUTTON); | 626 ui::EF_LEFT_MOUSE_BUTTON); |
629 ui::EventProcessor* dispatcher = root_window->GetHost()->event_processor(); | 627 ui::EventProcessor* dispatcher = root_window->GetHost()->event_processor(); |
(...skipping 18 matching lines...) Expand all Loading... |
648 aura::client::GetFocusClient(w1.get())->GetFocusedWindow()); | 646 aura::client::GetFocusClient(w1.get())->GetFocusedWindow()); |
649 } | 647 } |
650 | 648 |
651 TEST_F(WindowManagerTest, AdditionalFilters) { | 649 TEST_F(WindowManagerTest, AdditionalFilters) { |
652 // The IME event filter interferes with the basic key event propagation we | 650 // The IME event filter interferes with the basic key event propagation we |
653 // attempt to do here, so we disable it. | 651 // attempt to do here, so we disable it. |
654 DisableIME(); | 652 DisableIME(); |
655 aura::Window* root_window = Shell::GetPrimaryRootWindow(); | 653 aura::Window* root_window = Shell::GetPrimaryRootWindow(); |
656 | 654 |
657 // Creates a window and make it active | 655 // Creates a window and make it active |
658 scoped_ptr<aura::Window> w1(CreateTestWindowInShell( | 656 std::unique_ptr<aura::Window> w1( |
659 SK_ColorWHITE, -1, gfx::Rect(0, 0, 100, 100))); | 657 CreateTestWindowInShell(SK_ColorWHITE, -1, gfx::Rect(0, 0, 100, 100))); |
660 wm::ActivateWindow(w1.get()); | 658 wm::ActivateWindow(w1.get()); |
661 | 659 |
662 // Creates two addition filters | 660 // Creates two addition filters |
663 scoped_ptr<CustomEventHandler> f1(new CustomEventHandler); | 661 std::unique_ptr<CustomEventHandler> f1(new CustomEventHandler); |
664 scoped_ptr<CustomEventHandler> f2(new CustomEventHandler); | 662 std::unique_ptr<CustomEventHandler> f2(new CustomEventHandler); |
665 | 663 |
666 // Adds them to root window event filter. | 664 // Adds them to root window event filter. |
667 ::wm::CompoundEventFilter* env_filter = | 665 ::wm::CompoundEventFilter* env_filter = |
668 Shell::GetInstance()->env_filter(); | 666 Shell::GetInstance()->env_filter(); |
669 env_filter->AddHandler(f1.get()); | 667 env_filter->AddHandler(f1.get()); |
670 env_filter->AddHandler(f2.get()); | 668 env_filter->AddHandler(f2.get()); |
671 | 669 |
672 // Dispatches mouse and keyboard events. | 670 // Dispatches mouse and keyboard events. |
673 ui::KeyEvent key_event(ui::ET_KEY_PRESSED, ui::VKEY_A, ui::EF_NONE); | 671 ui::KeyEvent key_event(ui::ET_KEY_PRESSED, ui::VKEY_A, ui::EF_NONE); |
674 ui::EventProcessor* dispatcher = root_window->GetHost()->event_processor(); | 672 ui::EventProcessor* dispatcher = root_window->GetHost()->event_processor(); |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
792 generator.ReleaseKey(ui::VKEY_CONTROL, ui::EF_NONE); | 790 generator.ReleaseKey(ui::VKEY_CONTROL, ui::EF_NONE); |
793 generator.ReleaseKey(ui::VKEY_A, ui::EF_NONE); | 791 generator.ReleaseKey(ui::VKEY_A, ui::EF_NONE); |
794 EXPECT_TRUE(cursor_manager->IsCursorVisible()); | 792 EXPECT_TRUE(cursor_manager->IsCursorVisible()); |
795 } | 793 } |
796 | 794 |
797 TEST_F(WindowManagerTest, TestCursorClientObserver) { | 795 TEST_F(WindowManagerTest, TestCursorClientObserver) { |
798 ui::test::EventGenerator& generator = GetEventGenerator(); | 796 ui::test::EventGenerator& generator = GetEventGenerator(); |
799 ::wm::CursorManager* cursor_manager = | 797 ::wm::CursorManager* cursor_manager = |
800 ash::Shell::GetInstance()->cursor_manager(); | 798 ash::Shell::GetInstance()->cursor_manager(); |
801 | 799 |
802 scoped_ptr<aura::Window> w1(CreateTestWindowInShell( | 800 std::unique_ptr<aura::Window> w1( |
803 SK_ColorWHITE, -1, gfx::Rect(0, 0, 100, 100))); | 801 CreateTestWindowInShell(SK_ColorWHITE, -1, gfx::Rect(0, 0, 100, 100))); |
804 wm::ActivateWindow(w1.get()); | 802 wm::ActivateWindow(w1.get()); |
805 | 803 |
806 // Add two observers. Both should have OnCursorVisibilityChanged() | 804 // Add two observers. Both should have OnCursorVisibilityChanged() |
807 // invoked when an event changes the visibility of the cursor. | 805 // invoked when an event changes the visibility of the cursor. |
808 TestingCursorClientObserver observer_a; | 806 TestingCursorClientObserver observer_a; |
809 TestingCursorClientObserver observer_b; | 807 TestingCursorClientObserver observer_b; |
810 cursor_manager->AddObserver(&observer_a); | 808 cursor_manager->AddObserver(&observer_a); |
811 cursor_manager->AddObserver(&observer_b); | 809 cursor_manager->AddObserver(&observer_b); |
812 | 810 |
813 // Initial state before any events have been sent. | 811 // Initial state before any events have been sent. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
852 generator.MoveMouseTo(50, 50); | 850 generator.MoveMouseTo(50, 50); |
853 EXPECT_TRUE(observer_a.did_visibility_change()); | 851 EXPECT_TRUE(observer_a.did_visibility_change()); |
854 EXPECT_FALSE(observer_b.did_visibility_change()); | 852 EXPECT_FALSE(observer_b.did_visibility_change()); |
855 EXPECT_TRUE(observer_a.is_cursor_visible()); | 853 EXPECT_TRUE(observer_a.is_cursor_visible()); |
856 | 854 |
857 cursor_manager->RemoveObserver(&observer_a); | 855 cursor_manager->RemoveObserver(&observer_a); |
858 } | 856 } |
859 #endif // defined(OS_CHROMEOS) | 857 #endif // defined(OS_CHROMEOS) |
860 | 858 |
861 } // namespace ash | 859 } // namespace ash |
OLD | NEW |