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->AsWindowTreeHostDelegate()->OnHostKeyEvent(&keyev); | 190 dispatcher->AsRootWindowHostDelegate()->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->AsWindowTreeHostDelegate()->OnHostTouchEvent(&touchev); | 197 dispatcher->AsRootWindowHostDelegate()->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->AsWindowTreeHostDelegate()->OnHostKeyEvent(&keyev); | 202 dispatcher->AsRootWindowHostDelegate()->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->AsWindowTreeHostDelegate()->OnHostKeyEvent(&keyev)); | 239 EXPECT_FALSE(dispatcher->AsRootWindowHostDelegate()->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->AsWindowTreeHostDelegate()->OnHostKeyEvent(&keyev)); | 253 EXPECT_FALSE(dispatcher->AsRootWindowHostDelegate()->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->AsWindowTreeHostDelegate()->OnHostTouchEvent(&touchev1); | 445 dispatcher->AsRootWindowHostDelegate()->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->AsWindowTreeHostDelegate()->OnHostTouchEvent(&touchev2); | 462 dispatcher->AsRootWindowHostDelegate()->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, 0x0); | 512 ui::MouseEvent move1(ui::ET_MOUSE_MOVED, point1, point1, 0x0); |
513 dispatcher->AsWindowTreeHostDelegate()->OnHostMouseEvent(&move1); | 513 dispatcher->AsRootWindowHostDelegate()->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, 0x0); | 519 ui::MouseEvent move2(ui::ET_MOUSE_MOVED, point2, point2, 0x0); |
520 dispatcher->AsWindowTreeHostDelegate()->OnHostMouseEvent(&move2); | 520 dispatcher->AsRootWindowHostDelegate()->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, 0x0); | 527 ui::MouseEvent move1(ui::ET_MOUSE_MOVED, point1, point1, 0x0); |
528 dispatcher->AsWindowTreeHostDelegate()->OnHostMouseEvent(&move1); | 528 dispatcher->AsRootWindowHostDelegate()->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, 0x0); | 535 ui::MouseEvent move2(ui::ET_MOUSE_MOVED, point2, point2, 0x0); |
536 dispatcher->AsWindowTreeHostDelegate()->OnHostMouseEvent(&move2); | 536 dispatcher->AsRootWindowHostDelegate()->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, 0x0); | 542 ui::MouseEvent move1(ui::ET_MOUSE_MOVED, point1, point1, 0x0); |
543 dispatcher->AsWindowTreeHostDelegate()->OnHostMouseEvent(&move1); | 543 dispatcher->AsRootWindowHostDelegate()->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, 0x0); | 549 ui::MouseEvent move2(ui::ET_MOUSE_MOVED, point2, point2, 0x0); |
550 dispatcher->AsWindowTreeHostDelegate()->OnHostMouseEvent(&move2); | 550 dispatcher->AsRootWindowHostDelegate()->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, 0x0); | 556 ui::MouseEvent move1(ui::ET_MOUSE_MOVED, point1, point1, 0x0); |
557 dispatcher->AsWindowTreeHostDelegate()->OnHostMouseEvent(&move1); | 557 dispatcher->AsRootWindowHostDelegate()->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, 0x0); | 564 ui::MouseEvent move2(ui::ET_MOUSE_MOVED, point2, point2, 0x0); |
565 dispatcher->AsWindowTreeHostDelegate()->OnHostMouseEvent(&move2); | 565 dispatcher->AsRootWindowHostDelegate()->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, 0x0); | 573 ui::MouseEvent move1(ui::ET_MOUSE_MOVED, point1, point1, 0x0); |
574 dispatcher->AsWindowTreeHostDelegate()->OnHostMouseEvent(&move1); | 574 dispatcher->AsRootWindowHostDelegate()->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 16 matching lines...) Expand all Loading... |
601 d1.SetWindow(w1.get()); | 601 d1.SetWindow(w1.get()); |
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 aura::WindowEventDispatcher* dispatcher = root_window->GetDispatcher(); | 610 aura::WindowEventDispatcher* dispatcher = root_window->GetDispatcher(); |
611 dispatcher->AsWindowTreeHostDelegate()->OnHostMouseEvent(&mouseev1); | 611 dispatcher->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouseev1); |
612 EXPECT_EQ(NULL, aura::client::GetFocusClient(w1.get())->GetFocusedWindow()); | 612 EXPECT_EQ(NULL, aura::client::GetFocusClient(w1.get())->GetFocusedWindow()); |
613 ui::MouseEvent mouseup(ui::ET_MOUSE_RELEASED, | 613 ui::MouseEvent mouseup(ui::ET_MOUSE_RELEASED, |
614 miss_point, | 614 miss_point, |
615 miss_point, | 615 miss_point, |
616 ui::EF_LEFT_MOUSE_BUTTON); | 616 ui::EF_LEFT_MOUSE_BUTTON); |
617 dispatcher->AsWindowTreeHostDelegate()->OnHostMouseEvent(&mouseup); | 617 dispatcher->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouseup); |
618 | 618 |
619 gfx::Point hit_point(5, 15); | 619 gfx::Point hit_point(5, 15); |
620 transform.TransformPoint(&hit_point); | 620 transform.TransformPoint(&hit_point); |
621 ui::MouseEvent mouseev2(ui::ET_MOUSE_PRESSED, | 621 ui::MouseEvent mouseev2(ui::ET_MOUSE_PRESSED, |
622 hit_point, | 622 hit_point, |
623 hit_point, | 623 hit_point, |
624 ui::EF_LEFT_MOUSE_BUTTON); | 624 ui::EF_LEFT_MOUSE_BUTTON); |
625 dispatcher->AsWindowTreeHostDelegate()->OnHostMouseEvent(&mouseev2); | 625 dispatcher->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouseev2); |
626 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); | 626 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); |
627 EXPECT_EQ(w1.get(), | 627 EXPECT_EQ(w1.get(), |
628 aura::client::GetFocusClient(w1.get())->GetFocusedWindow()); | 628 aura::client::GetFocusClient(w1.get())->GetFocusedWindow()); |
629 } | 629 } |
630 | 630 |
631 TEST_F(WindowManagerTest, AdditionalFilters) { | 631 TEST_F(WindowManagerTest, AdditionalFilters) { |
632 // The IME event filter interferes with the basic key event propagation we | 632 // The IME event filter interferes with the basic key event propagation we |
633 // attempt to do here, so we remove it. | 633 // attempt to do here, so we remove it. |
634 test::ShellTestApi shell_test(Shell::GetInstance()); | 634 test::ShellTestApi shell_test(Shell::GetInstance()); |
635 Shell::GetInstance()->RemovePreTargetHandler( | 635 Shell::GetInstance()->RemovePreTargetHandler( |
(...skipping 12 matching lines...) Expand all Loading... |
648 | 648 |
649 // Adds them to root window event filter. | 649 // Adds them to root window event filter. |
650 views::corewm::CompoundEventFilter* env_filter = | 650 views::corewm::CompoundEventFilter* env_filter = |
651 Shell::GetInstance()->env_filter(); | 651 Shell::GetInstance()->env_filter(); |
652 env_filter->AddHandler(f1.get()); | 652 env_filter->AddHandler(f1.get()); |
653 env_filter->AddHandler(f2.get()); | 653 env_filter->AddHandler(f2.get()); |
654 | 654 |
655 // Dispatches mouse and keyboard events. | 655 // Dispatches mouse and keyboard events. |
656 ui::KeyEvent key_event(ui::ET_KEY_PRESSED, ui::VKEY_A, 0, false); | 656 ui::KeyEvent key_event(ui::ET_KEY_PRESSED, ui::VKEY_A, 0, false); |
657 aura::WindowEventDispatcher* dispatcher = root_window->GetDispatcher(); | 657 aura::WindowEventDispatcher* dispatcher = root_window->GetDispatcher(); |
658 dispatcher->AsWindowTreeHostDelegate()->OnHostKeyEvent(&key_event); | 658 dispatcher->AsRootWindowHostDelegate()->OnHostKeyEvent(&key_event); |
659 ui::MouseEvent mouse_pressed( | 659 ui::MouseEvent mouse_pressed( |
660 ui::ET_MOUSE_PRESSED, gfx::Point(0, 0), gfx::Point(0, 0), 0x0); | 660 ui::ET_MOUSE_PRESSED, gfx::Point(0, 0), gfx::Point(0, 0), 0x0); |
661 dispatcher->AsWindowTreeHostDelegate()->OnHostMouseEvent(&mouse_pressed); | 661 dispatcher->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouse_pressed); |
662 | 662 |
663 // Both filters should get the events. | 663 // Both filters should get the events. |
664 EXPECT_EQ(1, f1->num_key_events()); | 664 EXPECT_EQ(1, f1->num_key_events()); |
665 EXPECT_EQ(1, f1->num_mouse_events()); | 665 EXPECT_EQ(1, f1->num_mouse_events()); |
666 EXPECT_EQ(1, f2->num_key_events()); | 666 EXPECT_EQ(1, f2->num_key_events()); |
667 EXPECT_EQ(1, f2->num_mouse_events()); | 667 EXPECT_EQ(1, f2->num_mouse_events()); |
668 | 668 |
669 f1->Reset(); | 669 f1->Reset(); |
670 f2->Reset(); | 670 f2->Reset(); |
671 | 671 |
672 // Makes f1 consume events. | 672 // Makes f1 consume events. |
673 f1->set_key_event_handling_result(ui::ER_CONSUMED); | 673 f1->set_key_event_handling_result(ui::ER_CONSUMED); |
674 f1->set_mouse_event_handling_result(ui::ER_CONSUMED); | 674 f1->set_mouse_event_handling_result(ui::ER_CONSUMED); |
675 | 675 |
676 // Dispatches events. | 676 // Dispatches events. |
677 dispatcher->AsWindowTreeHostDelegate()->OnHostKeyEvent(&key_event); | 677 dispatcher->AsRootWindowHostDelegate()->OnHostKeyEvent(&key_event); |
678 ui::MouseEvent mouse_released( | 678 ui::MouseEvent mouse_released( |
679 ui::ET_MOUSE_RELEASED, gfx::Point(0, 0), gfx::Point(0, 0), 0x0); | 679 ui::ET_MOUSE_RELEASED, gfx::Point(0, 0), gfx::Point(0, 0), 0x0); |
680 dispatcher->AsWindowTreeHostDelegate()->OnHostMouseEvent(&mouse_released); | 680 dispatcher->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouse_released); |
681 | 681 |
682 // f1 should still get the events but f2 no longer gets them. | 682 // f1 should still get the events but f2 no longer gets them. |
683 EXPECT_EQ(1, f1->num_key_events()); | 683 EXPECT_EQ(1, f1->num_key_events()); |
684 EXPECT_EQ(1, f1->num_mouse_events()); | 684 EXPECT_EQ(1, f1->num_mouse_events()); |
685 EXPECT_EQ(0, f2->num_key_events()); | 685 EXPECT_EQ(0, f2->num_key_events()); |
686 EXPECT_EQ(0, f2->num_mouse_events()); | 686 EXPECT_EQ(0, f2->num_mouse_events()); |
687 | 687 |
688 f1->Reset(); | 688 f1->Reset(); |
689 f2->Reset(); | 689 f2->Reset(); |
690 | 690 |
691 // Remove f1 from additonal filters list. | 691 // Remove f1 from additonal filters list. |
692 env_filter->RemoveHandler(f1.get()); | 692 env_filter->RemoveHandler(f1.get()); |
693 | 693 |
694 // Dispatches events. | 694 // Dispatches events. |
695 dispatcher->AsWindowTreeHostDelegate()->OnHostKeyEvent(&key_event); | 695 dispatcher->AsRootWindowHostDelegate()->OnHostKeyEvent(&key_event); |
696 dispatcher->AsWindowTreeHostDelegate()->OnHostMouseEvent(&mouse_pressed); | 696 dispatcher->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouse_pressed); |
697 | 697 |
698 // f1 should get no events since it's out and f2 should get them. | 698 // f1 should get no events since it's out and f2 should get them. |
699 EXPECT_EQ(0, f1->num_key_events()); | 699 EXPECT_EQ(0, f1->num_key_events()); |
700 EXPECT_EQ(0, f1->num_mouse_events()); | 700 EXPECT_EQ(0, f1->num_mouse_events()); |
701 EXPECT_EQ(1, f2->num_key_events()); | 701 EXPECT_EQ(1, f2->num_key_events()); |
702 EXPECT_EQ(1, f2->num_mouse_events()); | 702 EXPECT_EQ(1, f2->num_mouse_events()); |
703 | 703 |
704 env_filter->RemoveHandler(f2.get()); | 704 env_filter->RemoveHandler(f2.get()); |
705 } | 705 } |
706 | 706 |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
806 observer_a.reset(); | 806 observer_a.reset(); |
807 observer_b.reset(); | 807 observer_b.reset(); |
808 generator.MoveMouseTo(50, 50); | 808 generator.MoveMouseTo(50, 50); |
809 EXPECT_TRUE(observer_a.did_visibility_change()); | 809 EXPECT_TRUE(observer_a.did_visibility_change()); |
810 EXPECT_FALSE(observer_b.did_visibility_change()); | 810 EXPECT_FALSE(observer_b.did_visibility_change()); |
811 EXPECT_TRUE(observer_a.is_cursor_visible()); | 811 EXPECT_TRUE(observer_a.is_cursor_visible()); |
812 } | 812 } |
813 #endif | 813 #endif |
814 | 814 |
815 } // namespace ash | 815 } // namespace ash |
OLD | NEW |