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/shell_test_api.h" | 8 #include "ash/test/shell_test_api.h" |
9 #include "ash/test/test_activation_delegate.h" | 9 #include "ash/test/test_activation_delegate.h" |
10 #include "ash/wm/window_util.h" | 10 #include "ash/wm/window_util.h" |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 generator.ClickLeftButton(); | 180 generator.ClickLeftButton(); |
181 | 181 |
182 aura::client::FocusClient* focus_client = | 182 aura::client::FocusClient* focus_client = |
183 aura::client::GetFocusClient(w121.get()); | 183 aura::client::GetFocusClient(w121.get()); |
184 EXPECT_EQ(w121.get(), focus_client->GetFocusedWindow()); | 184 EXPECT_EQ(w121.get(), focus_client->GetFocusedWindow()); |
185 | 185 |
186 aura::WindowEventDispatcher* dispatcher = root_window->GetDispatcher(); | 186 aura::WindowEventDispatcher* dispatcher = root_window->GetDispatcher(); |
187 | 187 |
188 // The key press should be sent to the focused sub-window. | 188 // The key press should be sent to the focused sub-window. |
189 ui::KeyEvent keyev(ui::ET_KEY_PRESSED, ui::VKEY_E, 0, false); | 189 ui::KeyEvent keyev(ui::ET_KEY_PRESSED, ui::VKEY_E, 0, false); |
190 dispatcher->AsRootWindowHostDelegate()->OnHostKeyEvent(&keyev); | 190 dispatcher->AsWindowTreeHostDelegate()->OnHostKeyEvent(&keyev); |
191 EXPECT_EQ(ui::VKEY_E, w121delegate->last_key_code()); | 191 EXPECT_EQ(ui::VKEY_E, w121delegate->last_key_code()); |
192 | 192 |
193 // Touch on a sub-window (w122) to focus it. | 193 // Touch on a sub-window (w122) to focus it. |
194 gfx::Point click_point = w122->bounds().CenterPoint(); | 194 gfx::Point click_point = w122->bounds().CenterPoint(); |
195 aura::Window::ConvertPointToTarget(w122->parent(), root_window, &click_point); | 195 aura::Window::ConvertPointToTarget(w122->parent(), root_window, &click_point); |
196 ui::TouchEvent touchev(ui::ET_TOUCH_PRESSED, click_point, 0, getTime()); | 196 ui::TouchEvent touchev(ui::ET_TOUCH_PRESSED, click_point, 0, getTime()); |
197 dispatcher->AsRootWindowHostDelegate()->OnHostTouchEvent(&touchev); | 197 dispatcher->AsWindowTreeHostDelegate()->OnHostTouchEvent(&touchev); |
198 focus_client = aura::client::GetFocusClient(w122.get()); | 198 focus_client = aura::client::GetFocusClient(w122.get()); |
199 EXPECT_EQ(w122.get(), focus_client->GetFocusedWindow()); | 199 EXPECT_EQ(w122.get(), focus_client->GetFocusedWindow()); |
200 | 200 |
201 // The key press should be sent to the focused sub-window. | 201 // The key press should be sent to the focused sub-window. |
202 dispatcher->AsRootWindowHostDelegate()->OnHostKeyEvent(&keyev); | 202 dispatcher->AsWindowTreeHostDelegate()->OnHostKeyEvent(&keyev); |
203 EXPECT_EQ(ui::VKEY_E, w122delegate->last_key_code()); | 203 EXPECT_EQ(ui::VKEY_E, w122delegate->last_key_code()); |
204 | 204 |
205 // Hiding the focused window will set the focus to its parent if | 205 // Hiding the focused window will set the focus to its parent if |
206 // it's focusable. | 206 // it's focusable. |
207 w122->Hide(); | 207 w122->Hide(); |
208 EXPECT_EQ(aura::client::GetFocusClient(w12.get()), | 208 EXPECT_EQ(aura::client::GetFocusClient(w12.get()), |
209 aura::client::GetFocusClient(w122.get())); | 209 aura::client::GetFocusClient(w122.get())); |
210 EXPECT_EQ(w12.get(), | 210 EXPECT_EQ(w12.get(), |
211 aura::client::GetFocusClient(w12.get())->GetFocusedWindow()); | 211 aura::client::GetFocusClient(w12.get())->GetFocusedWindow()); |
212 | 212 |
(...skipping 16 matching lines...) Expand all Loading... |
229 EXPECT_EQ(w123.get(), | 229 EXPECT_EQ(w123.get(), |
230 aura::client::GetFocusClient(w12.get())->GetFocusedWindow()); | 230 aura::client::GetFocusClient(w12.get())->GetFocusedWindow()); |
231 aura::client::SetActivationDelegate(w1.get(), &activation_delegate); | 231 aura::client::SetActivationDelegate(w1.get(), &activation_delegate); |
232 | 232 |
233 // Hiding the focused window will set the focus to NULL because | 233 // Hiding the focused window will set the focus to NULL because |
234 // parent window is not focusable. | 234 // parent window is not focusable. |
235 w123->Hide(); | 235 w123->Hide(); |
236 EXPECT_EQ(aura::client::GetFocusClient(w12.get()), | 236 EXPECT_EQ(aura::client::GetFocusClient(w12.get()), |
237 aura::client::GetFocusClient(w123.get())); | 237 aura::client::GetFocusClient(w123.get())); |
238 EXPECT_EQ(NULL, aura::client::GetFocusClient(w12.get())->GetFocusedWindow()); | 238 EXPECT_EQ(NULL, aura::client::GetFocusClient(w12.get())->GetFocusedWindow()); |
239 EXPECT_FALSE(dispatcher->AsRootWindowHostDelegate()->OnHostKeyEvent(&keyev)); | 239 EXPECT_FALSE(dispatcher->AsWindowTreeHostDelegate()->OnHostKeyEvent(&keyev)); |
240 | 240 |
241 // Set the focus back to w123 | 241 // Set the focus back to w123 |
242 aura::client::SetActivationDelegate(w1.get(), NULL); | 242 aura::client::SetActivationDelegate(w1.get(), NULL); |
243 w123->Show(); | 243 w123->Show(); |
244 w123->Focus(); | 244 w123->Focus(); |
245 EXPECT_EQ(w123.get(), | 245 EXPECT_EQ(w123.get(), |
246 aura::client::GetFocusClient(w12.get())->GetFocusedWindow()); | 246 aura::client::GetFocusClient(w12.get())->GetFocusedWindow()); |
247 aura::client::SetActivationDelegate(w1.get(), &activation_delegate); | 247 aura::client::SetActivationDelegate(w1.get(), &activation_delegate); |
248 | 248 |
249 // Removing the focused window will set the focus to NULL because | 249 // Removing the focused window will set the focus to NULL because |
250 // parent window is not focusable. | 250 // parent window is not focusable. |
251 w12->RemoveChild(w123.get()); | 251 w12->RemoveChild(w123.get()); |
252 EXPECT_EQ(NULL, aura::client::GetFocusClient(w123.get())); | 252 EXPECT_EQ(NULL, aura::client::GetFocusClient(w123.get())); |
253 EXPECT_FALSE(dispatcher->AsRootWindowHostDelegate()->OnHostKeyEvent(&keyev)); | 253 EXPECT_FALSE(dispatcher->AsWindowTreeHostDelegate()->OnHostKeyEvent(&keyev)); |
254 } | 254 } |
255 | 255 |
256 // Various assertion testing for activating windows. | 256 // Various assertion testing for activating windows. |
257 TEST_F(WindowManagerTest, ActivateOnMouse) { | 257 TEST_F(WindowManagerTest, ActivateOnMouse) { |
258 aura::Window* root_window = Shell::GetPrimaryRootWindow(); | 258 aura::Window* root_window = Shell::GetPrimaryRootWindow(); |
259 | 259 |
260 test::TestActivationDelegate d1; | 260 test::TestActivationDelegate d1; |
261 aura::test::TestWindowDelegate wd; | 261 aura::test::TestWindowDelegate wd; |
262 scoped_ptr<aura::Window> w1(CreateTestWindowInShellWithDelegate( | 262 scoped_ptr<aura::Window> w1(CreateTestWindowInShellWithDelegate( |
263 &wd, -1, gfx::Rect(10, 10, 50, 50))); | 263 &wd, -1, gfx::Rect(10, 10, 50, 50))); |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 EXPECT_EQ(1, d1.activated_count()); | 435 EXPECT_EQ(1, d1.activated_count()); |
436 EXPECT_EQ(0, d1.lost_active_count()); | 436 EXPECT_EQ(0, d1.lost_active_count()); |
437 d1.Clear(); | 437 d1.Clear(); |
438 | 438 |
439 // Touch window2. | 439 // Touch window2. |
440 gfx::Point press_point = w2->bounds().CenterPoint(); | 440 gfx::Point press_point = w2->bounds().CenterPoint(); |
441 aura::Window::ConvertPointToTarget(w2->parent(), root_window, &press_point); | 441 aura::Window::ConvertPointToTarget(w2->parent(), root_window, &press_point); |
442 ui::TouchEvent touchev1(ui::ET_TOUCH_PRESSED, press_point, 0, getTime()); | 442 ui::TouchEvent touchev1(ui::ET_TOUCH_PRESSED, press_point, 0, getTime()); |
443 | 443 |
444 aura::WindowEventDispatcher* dispatcher = root_window->GetDispatcher(); | 444 aura::WindowEventDispatcher* dispatcher = root_window->GetDispatcher(); |
445 dispatcher->AsRootWindowHostDelegate()->OnHostTouchEvent(&touchev1); | 445 dispatcher->AsWindowTreeHostDelegate()->OnHostTouchEvent(&touchev1); |
446 | 446 |
447 // Window2 should have become active. | 447 // Window2 should have become active. |
448 EXPECT_TRUE(wm::IsActiveWindow(w2.get())); | 448 EXPECT_TRUE(wm::IsActiveWindow(w2.get())); |
449 EXPECT_EQ(w2.get(), focus_client->GetFocusedWindow()); | 449 EXPECT_EQ(w2.get(), focus_client->GetFocusedWindow()); |
450 EXPECT_EQ(0, d1.activated_count()); | 450 EXPECT_EQ(0, d1.activated_count()); |
451 EXPECT_EQ(1, d1.lost_active_count()); | 451 EXPECT_EQ(1, d1.lost_active_count()); |
452 EXPECT_EQ(1, d2.activated_count()); | 452 EXPECT_EQ(1, d2.activated_count()); |
453 EXPECT_EQ(0, d2.lost_active_count()); | 453 EXPECT_EQ(0, d2.lost_active_count()); |
454 d1.Clear(); | 454 d1.Clear(); |
455 d2.Clear(); | 455 d2.Clear(); |
456 | 456 |
457 // Touch window1, but set it up so w1 doesn't activate on touch. | 457 // Touch window1, but set it up so w1 doesn't activate on touch. |
458 press_point = w1->bounds().CenterPoint(); | 458 press_point = w1->bounds().CenterPoint(); |
459 aura::Window::ConvertPointToTarget(w1->parent(), root_window, &press_point); | 459 aura::Window::ConvertPointToTarget(w1->parent(), root_window, &press_point); |
460 d1.set_activate(false); | 460 d1.set_activate(false); |
461 ui::TouchEvent touchev2(ui::ET_TOUCH_PRESSED, press_point, 1, getTime()); | 461 ui::TouchEvent touchev2(ui::ET_TOUCH_PRESSED, press_point, 1, getTime()); |
462 dispatcher->AsRootWindowHostDelegate()->OnHostTouchEvent(&touchev2); | 462 dispatcher->AsWindowTreeHostDelegate()->OnHostTouchEvent(&touchev2); |
463 | 463 |
464 // Window2 should still be active and focused. | 464 // Window2 should still be active and focused. |
465 EXPECT_TRUE(wm::IsActiveWindow(w2.get())); | 465 EXPECT_TRUE(wm::IsActiveWindow(w2.get())); |
466 EXPECT_EQ(w2.get(), focus_client->GetFocusedWindow()); | 466 EXPECT_EQ(w2.get(), focus_client->GetFocusedWindow()); |
467 EXPECT_EQ(0, d1.activated_count()); | 467 EXPECT_EQ(0, d1.activated_count()); |
468 EXPECT_EQ(0, d1.lost_active_count()); | 468 EXPECT_EQ(0, d1.lost_active_count()); |
469 EXPECT_EQ(0, d2.activated_count()); | 469 EXPECT_EQ(0, d2.activated_count()); |
470 EXPECT_EQ(0, d2.lost_active_count()); | 470 EXPECT_EQ(0, d2.lost_active_count()); |
471 d1.Clear(); | 471 d1.Clear(); |
472 d2.Clear(); | 472 d2.Clear(); |
(...skipping 30 matching lines...) Expand all Loading... |
503 | 503 |
504 aura::WindowEventDispatcher* dispatcher = root_window->GetDispatcher(); | 504 aura::WindowEventDispatcher* dispatcher = root_window->GetDispatcher(); |
505 | 505 |
506 // Cursor starts as a pointer (set during Shell::Init()). | 506 // Cursor starts as a pointer (set during Shell::Init()). |
507 EXPECT_EQ(ui::kCursorPointer, dispatcher->last_cursor().native_type()); | 507 EXPECT_EQ(ui::kCursorPointer, dispatcher->last_cursor().native_type()); |
508 | 508 |
509 { | 509 { |
510 // Resize edges and corners show proper cursors. | 510 // Resize edges and corners show proper cursors. |
511 window_delegate.set_hittest_code(HTBOTTOM); | 511 window_delegate.set_hittest_code(HTBOTTOM); |
512 ui::MouseEvent move1(ui::ET_MOUSE_MOVED, point1, point1, 0, 0); | 512 ui::MouseEvent move1(ui::ET_MOUSE_MOVED, point1, point1, 0, 0); |
513 dispatcher->AsRootWindowHostDelegate()->OnHostMouseEvent(&move1); | 513 dispatcher->AsWindowTreeHostDelegate()->OnHostMouseEvent(&move1); |
514 EXPECT_EQ(ui::kCursorSouthResize, dispatcher->last_cursor().native_type()); | 514 EXPECT_EQ(ui::kCursorSouthResize, dispatcher->last_cursor().native_type()); |
515 } | 515 } |
516 | 516 |
517 { | 517 { |
518 window_delegate.set_hittest_code(HTBOTTOMLEFT); | 518 window_delegate.set_hittest_code(HTBOTTOMLEFT); |
519 ui::MouseEvent move2(ui::ET_MOUSE_MOVED, point2, point2, 0, 0); | 519 ui::MouseEvent move2(ui::ET_MOUSE_MOVED, point2, point2, 0, 0); |
520 dispatcher->AsRootWindowHostDelegate()->OnHostMouseEvent(&move2); | 520 dispatcher->AsWindowTreeHostDelegate()->OnHostMouseEvent(&move2); |
521 EXPECT_EQ(ui::kCursorSouthWestResize, | 521 EXPECT_EQ(ui::kCursorSouthWestResize, |
522 dispatcher->last_cursor().native_type()); | 522 dispatcher->last_cursor().native_type()); |
523 } | 523 } |
524 | 524 |
525 { | 525 { |
526 window_delegate.set_hittest_code(HTBOTTOMRIGHT); | 526 window_delegate.set_hittest_code(HTBOTTOMRIGHT); |
527 ui::MouseEvent move1(ui::ET_MOUSE_MOVED, point1, point1, 0, 0); | 527 ui::MouseEvent move1(ui::ET_MOUSE_MOVED, point1, point1, 0, 0); |
528 dispatcher->AsRootWindowHostDelegate()->OnHostMouseEvent(&move1); | 528 dispatcher->AsWindowTreeHostDelegate()->OnHostMouseEvent(&move1); |
529 EXPECT_EQ(ui::kCursorSouthEastResize, | 529 EXPECT_EQ(ui::kCursorSouthEastResize, |
530 dispatcher->last_cursor().native_type()); | 530 dispatcher->last_cursor().native_type()); |
531 } | 531 } |
532 | 532 |
533 { | 533 { |
534 window_delegate.set_hittest_code(HTLEFT); | 534 window_delegate.set_hittest_code(HTLEFT); |
535 ui::MouseEvent move2(ui::ET_MOUSE_MOVED, point2, point2, 0, 0); | 535 ui::MouseEvent move2(ui::ET_MOUSE_MOVED, point2, point2, 0, 0); |
536 dispatcher->AsRootWindowHostDelegate()->OnHostMouseEvent(&move2); | 536 dispatcher->AsWindowTreeHostDelegate()->OnHostMouseEvent(&move2); |
537 EXPECT_EQ(ui::kCursorWestResize, dispatcher->last_cursor().native_type()); | 537 EXPECT_EQ(ui::kCursorWestResize, dispatcher->last_cursor().native_type()); |
538 } | 538 } |
539 | 539 |
540 { | 540 { |
541 window_delegate.set_hittest_code(HTRIGHT); | 541 window_delegate.set_hittest_code(HTRIGHT); |
542 ui::MouseEvent move1(ui::ET_MOUSE_MOVED, point1, point1, 0, 0); | 542 ui::MouseEvent move1(ui::ET_MOUSE_MOVED, point1, point1, 0, 0); |
543 dispatcher->AsRootWindowHostDelegate()->OnHostMouseEvent(&move1); | 543 dispatcher->AsWindowTreeHostDelegate()->OnHostMouseEvent(&move1); |
544 EXPECT_EQ(ui::kCursorEastResize, dispatcher->last_cursor().native_type()); | 544 EXPECT_EQ(ui::kCursorEastResize, dispatcher->last_cursor().native_type()); |
545 } | 545 } |
546 | 546 |
547 { | 547 { |
548 window_delegate.set_hittest_code(HTTOP); | 548 window_delegate.set_hittest_code(HTTOP); |
549 ui::MouseEvent move2(ui::ET_MOUSE_MOVED, point2, point2, 0, 0); | 549 ui::MouseEvent move2(ui::ET_MOUSE_MOVED, point2, point2, 0, 0); |
550 dispatcher->AsRootWindowHostDelegate()->OnHostMouseEvent(&move2); | 550 dispatcher->AsWindowTreeHostDelegate()->OnHostMouseEvent(&move2); |
551 EXPECT_EQ(ui::kCursorNorthResize, dispatcher->last_cursor().native_type()); | 551 EXPECT_EQ(ui::kCursorNorthResize, dispatcher->last_cursor().native_type()); |
552 } | 552 } |
553 | 553 |
554 { | 554 { |
555 window_delegate.set_hittest_code(HTTOPLEFT); | 555 window_delegate.set_hittest_code(HTTOPLEFT); |
556 ui::MouseEvent move1(ui::ET_MOUSE_MOVED, point1, point1, 0, 0); | 556 ui::MouseEvent move1(ui::ET_MOUSE_MOVED, point1, point1, 0, 0); |
557 dispatcher->AsRootWindowHostDelegate()->OnHostMouseEvent(&move1); | 557 dispatcher->AsWindowTreeHostDelegate()->OnHostMouseEvent(&move1); |
558 EXPECT_EQ(ui::kCursorNorthWestResize, | 558 EXPECT_EQ(ui::kCursorNorthWestResize, |
559 dispatcher->last_cursor().native_type()); | 559 dispatcher->last_cursor().native_type()); |
560 } | 560 } |
561 | 561 |
562 { | 562 { |
563 window_delegate.set_hittest_code(HTTOPRIGHT); | 563 window_delegate.set_hittest_code(HTTOPRIGHT); |
564 ui::MouseEvent move2(ui::ET_MOUSE_MOVED, point2, point2, 0, 0); | 564 ui::MouseEvent move2(ui::ET_MOUSE_MOVED, point2, point2, 0, 0); |
565 dispatcher->AsRootWindowHostDelegate()->OnHostMouseEvent(&move2); | 565 dispatcher->AsWindowTreeHostDelegate()->OnHostMouseEvent(&move2); |
566 EXPECT_EQ(ui::kCursorNorthEastResize, | 566 EXPECT_EQ(ui::kCursorNorthEastResize, |
567 dispatcher->last_cursor().native_type()); | 567 dispatcher->last_cursor().native_type()); |
568 } | 568 } |
569 | 569 |
570 { | 570 { |
571 // Client area uses null cursor. | 571 // Client area uses null cursor. |
572 window_delegate.set_hittest_code(HTCLIENT); | 572 window_delegate.set_hittest_code(HTCLIENT); |
573 ui::MouseEvent move1(ui::ET_MOUSE_MOVED, point1, point1, 0, 0); | 573 ui::MouseEvent move1(ui::ET_MOUSE_MOVED, point1, point1, 0, 0); |
574 dispatcher->AsRootWindowHostDelegate()->OnHostMouseEvent(&move1); | 574 dispatcher->AsWindowTreeHostDelegate()->OnHostMouseEvent(&move1); |
575 EXPECT_EQ(ui::kCursorNull, dispatcher->last_cursor().native_type()); | 575 EXPECT_EQ(ui::kCursorNull, dispatcher->last_cursor().native_type()); |
576 } | 576 } |
577 } | 577 } |
578 | 578 |
579 #if defined(OS_WIN) | 579 #if defined(OS_WIN) |
580 #define MAYBE_TransformActivate DISABLED_TransformActivate | 580 #define MAYBE_TransformActivate DISABLED_TransformActivate |
581 #else | 581 #else |
582 #define MAYBE_TransformActivate TransformActivate | 582 #define MAYBE_TransformActivate TransformActivate |
583 #endif | 583 #endif |
584 TEST_F(WindowManagerTest, MAYBE_TransformActivate) { | 584 TEST_F(WindowManagerTest, MAYBE_TransformActivate) { |
(...skipping 17 matching lines...) Expand all Loading... |
602 w1->Show(); | 602 w1->Show(); |
603 | 603 |
604 gfx::Point miss_point(5, 5); | 604 gfx::Point miss_point(5, 5); |
605 transform.TransformPoint(&miss_point); | 605 transform.TransformPoint(&miss_point); |
606 ui::MouseEvent mouseev1(ui::ET_MOUSE_PRESSED, | 606 ui::MouseEvent mouseev1(ui::ET_MOUSE_PRESSED, |
607 miss_point, | 607 miss_point, |
608 miss_point, | 608 miss_point, |
609 ui::EF_LEFT_MOUSE_BUTTON, | 609 ui::EF_LEFT_MOUSE_BUTTON, |
610 ui::EF_LEFT_MOUSE_BUTTON); | 610 ui::EF_LEFT_MOUSE_BUTTON); |
611 aura::WindowEventDispatcher* dispatcher = root_window->GetDispatcher(); | 611 aura::WindowEventDispatcher* dispatcher = root_window->GetDispatcher(); |
612 dispatcher->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouseev1); | 612 dispatcher->AsWindowTreeHostDelegate()->OnHostMouseEvent(&mouseev1); |
613 EXPECT_EQ(NULL, aura::client::GetFocusClient(w1.get())->GetFocusedWindow()); | 613 EXPECT_EQ(NULL, aura::client::GetFocusClient(w1.get())->GetFocusedWindow()); |
614 ui::MouseEvent mouseup(ui::ET_MOUSE_RELEASED, | 614 ui::MouseEvent mouseup(ui::ET_MOUSE_RELEASED, |
615 miss_point, | 615 miss_point, |
616 miss_point, | 616 miss_point, |
617 ui::EF_LEFT_MOUSE_BUTTON, | 617 ui::EF_LEFT_MOUSE_BUTTON, |
618 ui::EF_LEFT_MOUSE_BUTTON); | 618 ui::EF_LEFT_MOUSE_BUTTON); |
619 dispatcher->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouseup); | 619 dispatcher->AsWindowTreeHostDelegate()->OnHostMouseEvent(&mouseup); |
620 | 620 |
621 gfx::Point hit_point(5, 15); | 621 gfx::Point hit_point(5, 15); |
622 transform.TransformPoint(&hit_point); | 622 transform.TransformPoint(&hit_point); |
623 ui::MouseEvent mouseev2(ui::ET_MOUSE_PRESSED, | 623 ui::MouseEvent mouseev2(ui::ET_MOUSE_PRESSED, |
624 hit_point, | 624 hit_point, |
625 hit_point, | 625 hit_point, |
626 ui::EF_LEFT_MOUSE_BUTTON, | 626 ui::EF_LEFT_MOUSE_BUTTON, |
627 ui::EF_LEFT_MOUSE_BUTTON); | 627 ui::EF_LEFT_MOUSE_BUTTON); |
628 dispatcher->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouseev2); | 628 dispatcher->AsWindowTreeHostDelegate()->OnHostMouseEvent(&mouseev2); |
629 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); | 629 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); |
630 EXPECT_EQ(w1.get(), | 630 EXPECT_EQ(w1.get(), |
631 aura::client::GetFocusClient(w1.get())->GetFocusedWindow()); | 631 aura::client::GetFocusClient(w1.get())->GetFocusedWindow()); |
632 } | 632 } |
633 | 633 |
634 TEST_F(WindowManagerTest, AdditionalFilters) { | 634 TEST_F(WindowManagerTest, AdditionalFilters) { |
635 // The IME event filter interferes with the basic key event propagation we | 635 // The IME event filter interferes with the basic key event propagation we |
636 // attempt to do here, so we remove it. | 636 // attempt to do here, so we remove it. |
637 test::ShellTestApi shell_test(Shell::GetInstance()); | 637 test::ShellTestApi shell_test(Shell::GetInstance()); |
638 Shell::GetInstance()->RemovePreTargetHandler( | 638 Shell::GetInstance()->RemovePreTargetHandler( |
(...skipping 12 matching lines...) Expand all Loading... |
651 | 651 |
652 // Adds them to root window event filter. | 652 // Adds them to root window event filter. |
653 views::corewm::CompoundEventFilter* env_filter = | 653 views::corewm::CompoundEventFilter* env_filter = |
654 Shell::GetInstance()->env_filter(); | 654 Shell::GetInstance()->env_filter(); |
655 env_filter->AddHandler(f1.get()); | 655 env_filter->AddHandler(f1.get()); |
656 env_filter->AddHandler(f2.get()); | 656 env_filter->AddHandler(f2.get()); |
657 | 657 |
658 // Dispatches mouse and keyboard events. | 658 // Dispatches mouse and keyboard events. |
659 ui::KeyEvent key_event(ui::ET_KEY_PRESSED, ui::VKEY_A, 0, false); | 659 ui::KeyEvent key_event(ui::ET_KEY_PRESSED, ui::VKEY_A, 0, false); |
660 aura::WindowEventDispatcher* dispatcher = root_window->GetDispatcher(); | 660 aura::WindowEventDispatcher* dispatcher = root_window->GetDispatcher(); |
661 dispatcher->AsRootWindowHostDelegate()->OnHostKeyEvent(&key_event); | 661 dispatcher->AsWindowTreeHostDelegate()->OnHostKeyEvent(&key_event); |
662 ui::MouseEvent mouse_pressed( | 662 ui::MouseEvent mouse_pressed( |
663 ui::ET_MOUSE_PRESSED, gfx::Point(0, 0), gfx::Point(0, 0), 0, 0); | 663 ui::ET_MOUSE_PRESSED, gfx::Point(0, 0), gfx::Point(0, 0), 0, 0); |
664 dispatcher->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouse_pressed); | 664 dispatcher->AsWindowTreeHostDelegate()->OnHostMouseEvent(&mouse_pressed); |
665 | 665 |
666 // Both filters should get the events. | 666 // Both filters should get the events. |
667 EXPECT_EQ(1, f1->num_key_events()); | 667 EXPECT_EQ(1, f1->num_key_events()); |
668 EXPECT_EQ(1, f1->num_mouse_events()); | 668 EXPECT_EQ(1, f1->num_mouse_events()); |
669 EXPECT_EQ(1, f2->num_key_events()); | 669 EXPECT_EQ(1, f2->num_key_events()); |
670 EXPECT_EQ(1, f2->num_mouse_events()); | 670 EXPECT_EQ(1, f2->num_mouse_events()); |
671 | 671 |
672 f1->Reset(); | 672 f1->Reset(); |
673 f2->Reset(); | 673 f2->Reset(); |
674 | 674 |
675 // Makes f1 consume events. | 675 // Makes f1 consume events. |
676 f1->set_key_event_handling_result(ui::ER_CONSUMED); | 676 f1->set_key_event_handling_result(ui::ER_CONSUMED); |
677 f1->set_mouse_event_handling_result(ui::ER_CONSUMED); | 677 f1->set_mouse_event_handling_result(ui::ER_CONSUMED); |
678 | 678 |
679 // Dispatches events. | 679 // Dispatches events. |
680 dispatcher->AsRootWindowHostDelegate()->OnHostKeyEvent(&key_event); | 680 dispatcher->AsWindowTreeHostDelegate()->OnHostKeyEvent(&key_event); |
681 ui::MouseEvent mouse_released( | 681 ui::MouseEvent mouse_released( |
682 ui::ET_MOUSE_RELEASED, gfx::Point(0, 0), gfx::Point(0, 0), 0, 0); | 682 ui::ET_MOUSE_RELEASED, gfx::Point(0, 0), gfx::Point(0, 0), 0, 0); |
683 dispatcher->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouse_released); | 683 dispatcher->AsWindowTreeHostDelegate()->OnHostMouseEvent(&mouse_released); |
684 | 684 |
685 // f1 should still get the events but f2 no longer gets them. | 685 // f1 should still get the events but f2 no longer gets them. |
686 EXPECT_EQ(1, f1->num_key_events()); | 686 EXPECT_EQ(1, f1->num_key_events()); |
687 EXPECT_EQ(1, f1->num_mouse_events()); | 687 EXPECT_EQ(1, f1->num_mouse_events()); |
688 EXPECT_EQ(0, f2->num_key_events()); | 688 EXPECT_EQ(0, f2->num_key_events()); |
689 EXPECT_EQ(0, f2->num_mouse_events()); | 689 EXPECT_EQ(0, f2->num_mouse_events()); |
690 | 690 |
691 f1->Reset(); | 691 f1->Reset(); |
692 f2->Reset(); | 692 f2->Reset(); |
693 | 693 |
694 // Remove f1 from additonal filters list. | 694 // Remove f1 from additonal filters list. |
695 env_filter->RemoveHandler(f1.get()); | 695 env_filter->RemoveHandler(f1.get()); |
696 | 696 |
697 // Dispatches events. | 697 // Dispatches events. |
698 dispatcher->AsRootWindowHostDelegate()->OnHostKeyEvent(&key_event); | 698 dispatcher->AsWindowTreeHostDelegate()->OnHostKeyEvent(&key_event); |
699 dispatcher->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouse_pressed); | 699 dispatcher->AsWindowTreeHostDelegate()->OnHostMouseEvent(&mouse_pressed); |
700 | 700 |
701 // f1 should get no events since it's out and f2 should get them. | 701 // f1 should get no events since it's out and f2 should get them. |
702 EXPECT_EQ(0, f1->num_key_events()); | 702 EXPECT_EQ(0, f1->num_key_events()); |
703 EXPECT_EQ(0, f1->num_mouse_events()); | 703 EXPECT_EQ(0, f1->num_mouse_events()); |
704 EXPECT_EQ(1, f2->num_key_events()); | 704 EXPECT_EQ(1, f2->num_key_events()); |
705 EXPECT_EQ(1, f2->num_mouse_events()); | 705 EXPECT_EQ(1, f2->num_mouse_events()); |
706 | 706 |
707 env_filter->RemoveHandler(f2.get()); | 707 env_filter->RemoveHandler(f2.get()); |
708 } | 708 } |
709 | 709 |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
813 observer_a.reset(); | 813 observer_a.reset(); |
814 observer_b.reset(); | 814 observer_b.reset(); |
815 generator.MoveMouseTo(50, 50); | 815 generator.MoveMouseTo(50, 50); |
816 EXPECT_TRUE(observer_a.did_visibility_change()); | 816 EXPECT_TRUE(observer_a.did_visibility_change()); |
817 EXPECT_FALSE(observer_b.did_visibility_change()); | 817 EXPECT_FALSE(observer_b.did_visibility_change()); |
818 EXPECT_TRUE(observer_a.is_cursor_visible()); | 818 EXPECT_TRUE(observer_a.is_cursor_visible()); |
819 } | 819 } |
820 #endif // defined(OS_CHROMEOS) | 820 #endif // defined(OS_CHROMEOS) |
821 | 821 |
822 } // namespace ash | 822 } // namespace ash |
OLD | NEW |