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/activation_controller.h" | 9 #include "ash/wm/activation_controller.h" |
10 #include "ash/wm/cursor_manager.h" | 10 #include "ash/wm/cursor_manager.h" |
11 #include "ash/wm/window_util.h" | 11 #include "ash/wm/window_util.h" |
12 #include "ui/aura/client/activation_client.h" | 12 #include "ui/aura/client/activation_client.h" |
13 #include "ui/aura/client/activation_delegate.h" | 13 #include "ui/aura/client/activation_delegate.h" |
14 #include "ui/aura/env.h" | 14 #include "ui/aura/env.h" |
15 #include "ui/aura/event.h" | |
16 #include "ui/aura/focus_manager.h" | 15 #include "ui/aura/focus_manager.h" |
17 #include "ui/aura/root_window.h" | 16 #include "ui/aura/root_window.h" |
18 #include "ui/aura/shared/compound_event_filter.h" | 17 #include "ui/aura/shared/compound_event_filter.h" |
19 #include "ui/aura/shared/input_method_event_filter.h" | 18 #include "ui/aura/shared/input_method_event_filter.h" |
20 #include "ui/aura/test/aura_test_base.h" | 19 #include "ui/aura/test/aura_test_base.h" |
21 #include "ui/aura/test/event_generator.h" | 20 #include "ui/aura/test/event_generator.h" |
22 #include "ui/aura/test/test_event_filter.h" | 21 #include "ui/aura/test/test_event_filter.h" |
23 #include "ui/aura/test/test_window_delegate.h" | 22 #include "ui/aura/test/test_window_delegate.h" |
24 #include "ui/aura/test/test_windows.h" | 23 #include "ui/aura/test/test_windows.h" |
25 #include "ui/base/cursor/cursor.h" | 24 #include "ui/base/cursor/cursor.h" |
| 25 #include "ui/base/event.h" |
26 #include "ui/base/hit_test.h" | 26 #include "ui/base/hit_test.h" |
27 #include "ui/gfx/screen.h" | 27 #include "ui/gfx/screen.h" |
28 | 28 |
29 namespace { | 29 namespace { |
30 | 30 |
31 base::TimeDelta getTime() { | 31 base::TimeDelta getTime() { |
32 return base::Time::NowFromSystemTime() - base::Time(); | 32 return base::Time::NowFromSystemTime() - base::Time(); |
33 } | 33 } |
34 | 34 |
35 } // namespace | 35 } // namespace |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 | 109 |
110 // Click on a sub-window (w121) to focus it. | 110 // Click on a sub-window (w121) to focus it. |
111 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), | 111 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), |
112 w121.get()); | 112 w121.get()); |
113 generator.ClickLeftButton(); | 113 generator.ClickLeftButton(); |
114 | 114 |
115 aura::FocusManager* focus_manager = w121->GetFocusManager(); | 115 aura::FocusManager* focus_manager = w121->GetFocusManager(); |
116 EXPECT_EQ(w121.get(), focus_manager->GetFocusedWindow()); | 116 EXPECT_EQ(w121.get(), focus_manager->GetFocusedWindow()); |
117 | 117 |
118 // The key press should be sent to the focused sub-window. | 118 // The key press should be sent to the focused sub-window. |
119 aura::KeyEvent keyev(ui::ET_KEY_PRESSED, ui::VKEY_E, 0); | 119 ui::KeyEvent keyev(ui::ET_KEY_PRESSED, ui::VKEY_E, 0); |
120 root_window->AsRootWindowHostDelegate()->OnHostKeyEvent(&keyev); | 120 root_window->AsRootWindowHostDelegate()->OnHostKeyEvent(&keyev); |
121 EXPECT_EQ(ui::VKEY_E, w121delegate->last_key_code()); | 121 EXPECT_EQ(ui::VKEY_E, w121delegate->last_key_code()); |
122 | 122 |
123 // Touch on a sub-window (w122) to focus it. | 123 // Touch on a sub-window (w122) to focus it. |
124 gfx::Point click_point = w122->bounds().CenterPoint(); | 124 gfx::Point click_point = w122->bounds().CenterPoint(); |
125 aura::Window::ConvertPointToWindow(w122->parent(), root_window, &click_point); | 125 aura::Window::ConvertPointToTarget(w122->parent(), root_window, &click_point); |
126 aura::TouchEvent touchev(ui::ET_TOUCH_PRESSED, click_point, 0, getTime()); | 126 ui::TouchEventImpl touchev(ui::ET_TOUCH_PRESSED, click_point, 0, getTime()); |
127 root_window->AsRootWindowHostDelegate()->OnHostTouchEvent(&touchev); | 127 root_window->AsRootWindowHostDelegate()->OnHostTouchEvent(&touchev); |
128 focus_manager = w122->GetFocusManager(); | 128 focus_manager = w122->GetFocusManager(); |
129 EXPECT_EQ(w122.get(), focus_manager->GetFocusedWindow()); | 129 EXPECT_EQ(w122.get(), focus_manager->GetFocusedWindow()); |
130 | 130 |
131 // The key press should be sent to the focused sub-window. | 131 // The key press should be sent to the focused sub-window. |
132 root_window->AsRootWindowHostDelegate()->OnHostKeyEvent(&keyev); | 132 root_window->AsRootWindowHostDelegate()->OnHostKeyEvent(&keyev); |
133 EXPECT_EQ(ui::VKEY_E, w122delegate->last_key_code()); | 133 EXPECT_EQ(ui::VKEY_E, w122delegate->last_key_code()); |
134 | 134 |
135 // Hiding the focused window will set the focus to its parent if | 135 // Hiding the focused window will set the focus to its parent if |
136 // it's focusable. | 136 // it's focusable. |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 &wd, -1, gfx::Rect(10, 10, 10, 10), w1.get())); | 256 &wd, -1, gfx::Rect(10, 10, 10, 10), w1.get())); |
257 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), | 257 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), |
258 w11.get()); | 258 w11.get()); |
259 // First set the focus to the child |w11|. | 259 // First set the focus to the child |w11|. |
260 generator.ClickLeftButton(); | 260 generator.ClickLeftButton(); |
261 EXPECT_EQ(w11.get(), focus_manager->GetFocusedWindow()); | 261 EXPECT_EQ(w11.get(), focus_manager->GetFocusedWindow()); |
262 EXPECT_EQ(w1.get(), wm::GetActiveWindow()); | 262 EXPECT_EQ(w1.get(), wm::GetActiveWindow()); |
263 | 263 |
264 // Then click the parent active window. The focus shouldn't move. | 264 // Then click the parent active window. The focus shouldn't move. |
265 gfx::Point left_top = w1->bounds().origin(); | 265 gfx::Point left_top = w1->bounds().origin(); |
266 aura::Window::ConvertPointToWindow(w1->parent(), root_window, &left_top); | 266 aura::Window::ConvertPointToTarget(w1->parent(), root_window, &left_top); |
267 left_top.Offset(1, 1); | 267 left_top.Offset(1, 1); |
268 generator.MoveMouseTo(left_top); | 268 generator.MoveMouseTo(left_top); |
269 generator.ClickLeftButton(); | 269 generator.ClickLeftButton(); |
270 EXPECT_EQ(w11.get(), focus_manager->GetFocusedWindow()); | 270 EXPECT_EQ(w11.get(), focus_manager->GetFocusedWindow()); |
271 EXPECT_EQ(w1.get(), wm::GetActiveWindow()); | 271 EXPECT_EQ(w1.get(), wm::GetActiveWindow()); |
272 } | 272 } |
273 | 273 |
274 // Clicking on a non-focusable window inside a background window should still | 274 // Clicking on a non-focusable window inside a background window should still |
275 // give focus to the background window. | 275 // give focus to the background window. |
276 { | 276 { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 // Activate window1. | 315 // Activate window1. |
316 wm::ActivateWindow(w1.get()); | 316 wm::ActivateWindow(w1.get()); |
317 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); | 317 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); |
318 EXPECT_EQ(w1.get(), focus_manager->GetFocusedWindow()); | 318 EXPECT_EQ(w1.get(), focus_manager->GetFocusedWindow()); |
319 EXPECT_EQ(1, d1.activated_count()); | 319 EXPECT_EQ(1, d1.activated_count()); |
320 EXPECT_EQ(0, d1.lost_active_count()); | 320 EXPECT_EQ(0, d1.lost_active_count()); |
321 d1.Clear(); | 321 d1.Clear(); |
322 | 322 |
323 // Touch window2. | 323 // Touch window2. |
324 gfx::Point press_point = w2->bounds().CenterPoint(); | 324 gfx::Point press_point = w2->bounds().CenterPoint(); |
325 aura::Window::ConvertPointToWindow(w2->parent(), root_window, &press_point); | 325 aura::Window::ConvertPointToTarget(w2->parent(), root_window, &press_point); |
326 aura::TouchEvent touchev1(ui::ET_TOUCH_PRESSED, press_point, 0, getTime()); | 326 ui::TouchEventImpl touchev1(ui::ET_TOUCH_PRESSED, press_point, 0, getTime()); |
327 root_window->AsRootWindowHostDelegate()->OnHostTouchEvent(&touchev1); | 327 root_window->AsRootWindowHostDelegate()->OnHostTouchEvent(&touchev1); |
328 | 328 |
329 // Window2 should have become active. | 329 // Window2 should have become active. |
330 EXPECT_TRUE(wm::IsActiveWindow(w2.get())); | 330 EXPECT_TRUE(wm::IsActiveWindow(w2.get())); |
331 EXPECT_EQ(w2.get(), focus_manager->GetFocusedWindow()); | 331 EXPECT_EQ(w2.get(), focus_manager->GetFocusedWindow()); |
332 EXPECT_EQ(0, d1.activated_count()); | 332 EXPECT_EQ(0, d1.activated_count()); |
333 EXPECT_EQ(1, d1.lost_active_count()); | 333 EXPECT_EQ(1, d1.lost_active_count()); |
334 EXPECT_EQ(1, d2.activated_count()); | 334 EXPECT_EQ(1, d2.activated_count()); |
335 EXPECT_EQ(0, d2.lost_active_count()); | 335 EXPECT_EQ(0, d2.lost_active_count()); |
336 d1.Clear(); | 336 d1.Clear(); |
337 d2.Clear(); | 337 d2.Clear(); |
338 | 338 |
339 // Touch window1, but set it up so w1 doesn't activate on touch. | 339 // Touch window1, but set it up so w1 doesn't activate on touch. |
340 press_point = w1->bounds().CenterPoint(); | 340 press_point = w1->bounds().CenterPoint(); |
341 aura::Window::ConvertPointToWindow(w1->parent(), root_window, &press_point); | 341 aura::Window::ConvertPointToTarget(w1->parent(), root_window, &press_point); |
342 d1.set_activate(false); | 342 d1.set_activate(false); |
343 aura::TouchEvent touchev2(ui::ET_TOUCH_PRESSED, press_point, 1, getTime()); | 343 ui::TouchEventImpl touchev2(ui::ET_TOUCH_PRESSED, press_point, 1, getTime()); |
344 root_window->AsRootWindowHostDelegate()->OnHostTouchEvent(&touchev2); | 344 root_window->AsRootWindowHostDelegate()->OnHostTouchEvent(&touchev2); |
345 | 345 |
346 // Window2 should still be active and focused. | 346 // Window2 should still be active and focused. |
347 EXPECT_TRUE(wm::IsActiveWindow(w2.get())); | 347 EXPECT_TRUE(wm::IsActiveWindow(w2.get())); |
348 EXPECT_EQ(w2.get(), focus_manager->GetFocusedWindow()); | 348 EXPECT_EQ(w2.get(), focus_manager->GetFocusedWindow()); |
349 EXPECT_EQ(0, d1.activated_count()); | 349 EXPECT_EQ(0, d1.activated_count()); |
350 EXPECT_EQ(0, d1.lost_active_count()); | 350 EXPECT_EQ(0, d1.lost_active_count()); |
351 EXPECT_EQ(0, d2.activated_count()); | 351 EXPECT_EQ(0, d2.activated_count()); |
352 EXPECT_EQ(0, d2.lost_active_count()); | 352 EXPECT_EQ(0, d2.lost_active_count()); |
353 d1.Clear(); | 353 d1.Clear(); |
(...skipping 21 matching lines...) Expand all Loading... |
375 const int kWindowTop = 45; | 375 const int kWindowTop = 45; |
376 HitTestWindowDelegate window_delegate; | 376 HitTestWindowDelegate window_delegate; |
377 scoped_ptr<aura::Window> window(aura::test::CreateTestWindowWithDelegate( | 377 scoped_ptr<aura::Window> window(aura::test::CreateTestWindowWithDelegate( |
378 &window_delegate, | 378 &window_delegate, |
379 -1, | 379 -1, |
380 gfx::Rect(kWindowLeft, kWindowTop, 640, 480), | 380 gfx::Rect(kWindowLeft, kWindowTop, 640, 480), |
381 NULL)); | 381 NULL)); |
382 | 382 |
383 // Create two mouse movement events we can switch between. | 383 // Create two mouse movement events we can switch between. |
384 gfx::Point point1(kWindowLeft, kWindowTop); | 384 gfx::Point point1(kWindowLeft, kWindowTop); |
385 aura::Window::ConvertPointToWindow(window->parent(), root_window, &point1); | 385 aura::Window::ConvertPointToTarget(window->parent(), root_window, &point1); |
386 aura::MouseEvent move1(ui::ET_MOUSE_MOVED, point1, point1, 0x0); | 386 ui::MouseEvent move1(ui::ET_MOUSE_MOVED, point1, point1, 0x0); |
387 | 387 |
388 gfx::Point point2(kWindowLeft + 1, kWindowTop + 1); | 388 gfx::Point point2(kWindowLeft + 1, kWindowTop + 1); |
389 aura::Window::ConvertPointToWindow(window->parent(), root_window, &point2); | 389 aura::Window::ConvertPointToTarget(window->parent(), root_window, &point2); |
390 aura::MouseEvent move2(ui::ET_MOUSE_MOVED, point2, point2, 0x0); | 390 ui::MouseEvent move2(ui::ET_MOUSE_MOVED, point2, point2, 0x0); |
391 | 391 |
392 // Cursor starts as a pointer (set during Shell::Init()). | 392 // Cursor starts as a pointer (set during Shell::Init()). |
393 EXPECT_EQ(ui::kCursorPointer, root_window->last_cursor().native_type()); | 393 EXPECT_EQ(ui::kCursorPointer, root_window->last_cursor().native_type()); |
394 | 394 |
395 // Resize edges and corners show proper cursors. | 395 // Resize edges and corners show proper cursors. |
396 window_delegate.set_hittest_code(HTBOTTOM); | 396 window_delegate.set_hittest_code(HTBOTTOM); |
397 root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&move1); | 397 root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&move1); |
398 EXPECT_EQ(ui::kCursorSouthResize, root_window->last_cursor().native_type()); | 398 EXPECT_EQ(ui::kCursorSouthResize, root_window->last_cursor().native_type()); |
399 | 399 |
400 window_delegate.set_hittest_code(HTBOTTOMLEFT); | 400 window_delegate.set_hittest_code(HTBOTTOMLEFT); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
459 | 459 |
460 test::TestActivationDelegate d1; | 460 test::TestActivationDelegate d1; |
461 aura::test::TestWindowDelegate wd; | 461 aura::test::TestWindowDelegate wd; |
462 scoped_ptr<aura::Window> w1( | 462 scoped_ptr<aura::Window> w1( |
463 CreateTestWindowWithDelegate(&wd, 1, gfx::Rect(0, 10, 50, 50), NULL)); | 463 CreateTestWindowWithDelegate(&wd, 1, gfx::Rect(0, 10, 50, 50), NULL)); |
464 d1.SetWindow(w1.get()); | 464 d1.SetWindow(w1.get()); |
465 w1->Show(); | 465 w1->Show(); |
466 | 466 |
467 gfx::Point miss_point(5, 5); | 467 gfx::Point miss_point(5, 5); |
468 transform.TransformPoint(miss_point); | 468 transform.TransformPoint(miss_point); |
469 aura::MouseEvent mouseev1(ui::ET_MOUSE_PRESSED, | 469 ui::MouseEvent mouseev1(ui::ET_MOUSE_PRESSED, |
470 miss_point, | 470 miss_point, |
471 miss_point, | 471 miss_point, |
472 ui::EF_LEFT_MOUSE_BUTTON); | 472 ui::EF_LEFT_MOUSE_BUTTON); |
473 root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouseev1); | 473 root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouseev1); |
474 EXPECT_FALSE(w1->GetFocusManager()->GetFocusedWindow()); | 474 EXPECT_FALSE(w1->GetFocusManager()->GetFocusedWindow()); |
475 aura::MouseEvent mouseup(ui::ET_MOUSE_RELEASED, | 475 ui::MouseEvent mouseup(ui::ET_MOUSE_RELEASED, |
476 miss_point, | 476 miss_point, |
477 miss_point, | 477 miss_point, |
478 ui::EF_LEFT_MOUSE_BUTTON); | 478 ui::EF_LEFT_MOUSE_BUTTON); |
479 root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouseup); | 479 root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouseup); |
480 | 480 |
481 gfx::Point hit_point(5, 15); | 481 gfx::Point hit_point(5, 15); |
482 transform.TransformPoint(hit_point); | 482 transform.TransformPoint(hit_point); |
483 aura::MouseEvent mouseev2(ui::ET_MOUSE_PRESSED, | 483 ui::MouseEvent mouseev2(ui::ET_MOUSE_PRESSED, |
484 hit_point, | 484 hit_point, |
485 hit_point, | 485 hit_point, |
486 ui::EF_LEFT_MOUSE_BUTTON); | 486 ui::EF_LEFT_MOUSE_BUTTON); |
487 root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouseev2); | 487 root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouseev2); |
488 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); | 488 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); |
489 EXPECT_EQ(w1.get(), w1->GetFocusManager()->GetFocusedWindow()); | 489 EXPECT_EQ(w1.get(), w1->GetFocusManager()->GetFocusedWindow()); |
490 } | 490 } |
491 | 491 |
492 TEST_F(WindowManagerTest, AdditionalFilters) { | 492 TEST_F(WindowManagerTest, AdditionalFilters) { |
493 // The IME event filter interferes with the basic key event propagation we | 493 // The IME event filter interferes with the basic key event propagation we |
494 // attempt to do here, so we remove it. | 494 // attempt to do here, so we remove it. |
495 Shell::TestApi shell_test(Shell::GetInstance()); | 495 Shell::TestApi shell_test(Shell::GetInstance()); |
496 Shell::GetInstance()->RemoveEnvEventFilter( | 496 Shell::GetInstance()->RemoveEnvEventFilter( |
(...skipping 10 matching lines...) Expand all Loading... |
507 scoped_ptr<aura::test::TestEventFilter> f1(new aura::test::TestEventFilter); | 507 scoped_ptr<aura::test::TestEventFilter> f1(new aura::test::TestEventFilter); |
508 scoped_ptr<aura::test::TestEventFilter> f2(new aura::test::TestEventFilter); | 508 scoped_ptr<aura::test::TestEventFilter> f2(new aura::test::TestEventFilter); |
509 | 509 |
510 // Adds them to root window event filter. | 510 // Adds them to root window event filter. |
511 aura::shared::CompoundEventFilter* env_filter = | 511 aura::shared::CompoundEventFilter* env_filter = |
512 Shell::GetInstance()->env_filter(); | 512 Shell::GetInstance()->env_filter(); |
513 env_filter->AddFilter(f1.get()); | 513 env_filter->AddFilter(f1.get()); |
514 env_filter->AddFilter(f2.get()); | 514 env_filter->AddFilter(f2.get()); |
515 | 515 |
516 // Dispatches mouse and keyboard events. | 516 // Dispatches mouse and keyboard events. |
517 aura::KeyEvent key_event(ui::ET_KEY_PRESSED, ui::VKEY_A, 0); | 517 ui::KeyEvent key_event(ui::ET_KEY_PRESSED, ui::VKEY_A, 0); |
518 root_window->AsRootWindowHostDelegate()->OnHostKeyEvent(&key_event); | 518 root_window->AsRootWindowHostDelegate()->OnHostKeyEvent(&key_event); |
519 aura::MouseEvent mouse_pressed( | 519 ui::MouseEvent mouse_pressed( |
520 ui::ET_MOUSE_PRESSED, gfx::Point(0, 0), gfx::Point(0, 0), 0x0); | 520 ui::ET_MOUSE_PRESSED, gfx::Point(0, 0), gfx::Point(0, 0), 0x0); |
521 root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouse_pressed); | 521 root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouse_pressed); |
522 | 522 |
523 // Both filters should get the events. | 523 // Both filters should get the events. |
524 EXPECT_EQ(1, f1->key_event_count()); | 524 EXPECT_EQ(1, f1->key_event_count()); |
525 EXPECT_EQ(1, f1->mouse_event_count()); | 525 EXPECT_EQ(1, f1->mouse_event_count()); |
526 EXPECT_EQ(1, f2->key_event_count()); | 526 EXPECT_EQ(1, f2->key_event_count()); |
527 EXPECT_EQ(1, f2->mouse_event_count()); | 527 EXPECT_EQ(1, f2->mouse_event_count()); |
528 | 528 |
529 f1->ResetCounts(); | 529 f1->ResetCounts(); |
530 f2->ResetCounts(); | 530 f2->ResetCounts(); |
531 | 531 |
532 // Makes f1 consume events. | 532 // Makes f1 consume events. |
533 f1->set_consumes_key_events(true); | 533 f1->set_consumes_key_events(true); |
534 f1->set_consumes_mouse_events(true); | 534 f1->set_consumes_mouse_events(true); |
535 | 535 |
536 // Dispatches events. | 536 // Dispatches events. |
537 root_window->AsRootWindowHostDelegate()->OnHostKeyEvent(&key_event); | 537 root_window->AsRootWindowHostDelegate()->OnHostKeyEvent(&key_event); |
538 aura::MouseEvent mouse_released( | 538 ui::MouseEvent mouse_released( |
539 ui::ET_MOUSE_RELEASED, gfx::Point(0, 0), gfx::Point(0, 0), 0x0); | 539 ui::ET_MOUSE_RELEASED, gfx::Point(0, 0), gfx::Point(0, 0), 0x0); |
540 root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouse_released); | 540 root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouse_released); |
541 | 541 |
542 // f1 should still get the events but f2 no longer gets them. | 542 // f1 should still get the events but f2 no longer gets them. |
543 EXPECT_EQ(1, f1->key_event_count()); | 543 EXPECT_EQ(1, f1->key_event_count()); |
544 EXPECT_EQ(1, f1->mouse_event_count()); | 544 EXPECT_EQ(1, f1->mouse_event_count()); |
545 EXPECT_EQ(0, f2->key_event_count()); | 545 EXPECT_EQ(0, f2->key_event_count()); |
546 EXPECT_EQ(0, f2->mouse_event_count()); | 546 EXPECT_EQ(0, f2->mouse_event_count()); |
547 | 547 |
548 f1->ResetCounts(); | 548 f1->ResetCounts(); |
(...skipping 21 matching lines...) Expand all Loading... |
570 aura::RootWindow* root_window = Shell::GetPrimaryRootWindow(); | 570 aura::RootWindow* root_window = Shell::GetPrimaryRootWindow(); |
571 root_window->SetBounds(gfx::Rect(0, 0, 500, 500)); | 571 root_window->SetBounds(gfx::Rect(0, 0, 500, 500)); |
572 scoped_ptr<aura::Window> window(aura::test::CreateTestWindow( | 572 scoped_ptr<aura::Window> window(aura::test::CreateTestWindow( |
573 SK_ColorWHITE, -1, gfx::Rect(0, 0, 500, 500), NULL)); | 573 SK_ColorWHITE, -1, gfx::Rect(0, 0, 500, 500), NULL)); |
574 | 574 |
575 aura::shared::CompoundEventFilter* env_filter = | 575 aura::shared::CompoundEventFilter* env_filter = |
576 Shell::GetInstance()->env_filter(); | 576 Shell::GetInstance()->env_filter(); |
577 ash::CursorManager* cursor_manager = | 577 ash::CursorManager* cursor_manager = |
578 ash::Shell::GetInstance()->cursor_manager(); | 578 ash::Shell::GetInstance()->cursor_manager(); |
579 | 579 |
580 aura::MouseEvent mouse_moved( | 580 ui::MouseEvent mouse_moved( |
581 ui::ET_MOUSE_MOVED, gfx::Point(0, 0), gfx::Point(0, 0), 0x0); | 581 ui::ET_MOUSE_MOVED, gfx::Point(0, 0), gfx::Point(0, 0), 0x0); |
582 aura::TouchEvent touch_pressed1( | 582 ui::TouchEventImpl touch_pressed1( |
583 ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), 0, getTime()); | 583 ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), 0, getTime()); |
584 aura::TouchEvent touch_pressed2( | 584 ui::TouchEventImpl touch_pressed2( |
585 ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), 1, getTime()); | 585 ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), 1, getTime()); |
586 | 586 |
587 env_filter->set_update_cursor_visibility(true); | 587 env_filter->set_update_cursor_visibility(true); |
588 root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouse_moved); | 588 root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouse_moved); |
589 EXPECT_TRUE(cursor_manager->cursor_visible()); | 589 EXPECT_TRUE(cursor_manager->cursor_visible()); |
590 root_window->AsRootWindowHostDelegate()->OnHostTouchEvent(&touch_pressed1); | 590 root_window->AsRootWindowHostDelegate()->OnHostTouchEvent(&touch_pressed1); |
591 EXPECT_FALSE(cursor_manager->cursor_visible()); | 591 EXPECT_FALSE(cursor_manager->cursor_visible()); |
592 root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouse_moved); | 592 root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouse_moved); |
593 EXPECT_TRUE(cursor_manager->cursor_visible()); | 593 EXPECT_TRUE(cursor_manager->cursor_visible()); |
594 | 594 |
595 env_filter->set_update_cursor_visibility(false); | 595 env_filter->set_update_cursor_visibility(false); |
596 cursor_manager->ShowCursor(false); | 596 cursor_manager->ShowCursor(false); |
597 root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouse_moved); | 597 root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouse_moved); |
598 EXPECT_FALSE(cursor_manager->cursor_visible()); | 598 EXPECT_FALSE(cursor_manager->cursor_visible()); |
599 cursor_manager->ShowCursor(true); | 599 cursor_manager->ShowCursor(true); |
600 root_window->AsRootWindowHostDelegate()->OnHostTouchEvent(&touch_pressed2); | 600 root_window->AsRootWindowHostDelegate()->OnHostTouchEvent(&touch_pressed2); |
601 EXPECT_TRUE(cursor_manager->cursor_visible()); | 601 EXPECT_TRUE(cursor_manager->cursor_visible()); |
602 } | 602 } |
603 | 603 |
604 } // namespace ash | 604 } // namespace ash |
OLD | NEW |