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

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

Issue 10825050: Introduce RootWindowHostDelegate. The RootWindowHost performs most of its communication with RootWi… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ash/wm/system_gesture_event_filter_unittest.cc ('k') | ui/aura/aura.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "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"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 aura::KeyEvent keyev(ui::ET_KEY_PRESSED, ui::VKEY_E, 0);
120 root_window->DispatchKeyEvent(&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::ConvertPointToWindow(w122->parent(), root_window, &click_point);
126 aura::TouchEvent touchev(ui::ET_TOUCH_PRESSED, click_point, 0, getTime()); 126 aura::TouchEvent touchev(ui::ET_TOUCH_PRESSED, click_point, 0, getTime());
127 root_window->DispatchTouchEvent(&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->DispatchKeyEvent(&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.
137 w122->Hide(); 137 w122->Hide();
138 EXPECT_EQ(w12->GetFocusManager(), w122->GetFocusManager()); 138 EXPECT_EQ(w12->GetFocusManager(), w122->GetFocusManager());
139 EXPECT_EQ(w12.get(), w12->GetFocusManager()->GetFocusedWindow()); 139 EXPECT_EQ(w12.get(), w12->GetFocusManager()->GetFocusedWindow());
140 140
141 // Sets the focus back to w122. 141 // Sets the focus back to w122.
142 w122->Show(); 142 w122->Show();
(...skipping 11 matching lines...) Expand all
154 test::TestActivationDelegate(false); 154 test::TestActivationDelegate(false);
155 w123->Focus(); 155 w123->Focus();
156 EXPECT_EQ(w123.get(), w12->GetFocusManager()->GetFocusedWindow()); 156 EXPECT_EQ(w123.get(), w12->GetFocusManager()->GetFocusedWindow());
157 aura::client::SetActivationDelegate(w1.get(), activation_delegate); 157 aura::client::SetActivationDelegate(w1.get(), activation_delegate);
158 158
159 // Hiding the focused window will set the focus to NULL because 159 // Hiding the focused window will set the focus to NULL because
160 // parent window is not focusable. 160 // parent window is not focusable.
161 w123->Hide(); 161 w123->Hide();
162 EXPECT_EQ(w12->GetFocusManager(), w123->GetFocusManager()); 162 EXPECT_EQ(w12->GetFocusManager(), w123->GetFocusManager());
163 EXPECT_EQ(NULL, w12->GetFocusManager()->GetFocusedWindow()); 163 EXPECT_EQ(NULL, w12->GetFocusManager()->GetFocusedWindow());
164 EXPECT_FALSE(root_window->DispatchKeyEvent(&keyev)); 164 EXPECT_FALSE(root_window->AsRootWindowHostDelegate()->OnHostKeyEvent(&keyev));
165 165
166 // Set the focus back to w123 166 // Set the focus back to w123
167 aura::client::SetActivationDelegate(w1.get(), NULL); 167 aura::client::SetActivationDelegate(w1.get(), NULL);
168 w123->Show(); 168 w123->Show();
169 w123->Focus(); 169 w123->Focus();
170 EXPECT_EQ(w123.get(), w12->GetFocusManager()->GetFocusedWindow()); 170 EXPECT_EQ(w123.get(), w12->GetFocusManager()->GetFocusedWindow());
171 aura::client::SetActivationDelegate(w1.get(), activation_delegate); 171 aura::client::SetActivationDelegate(w1.get(), activation_delegate);
172 172
173 // Removing the focused window will set the focus to NULL because 173 // Removing the focused window will set the focus to NULL because
174 // parent window is not focusable. 174 // parent window is not focusable.
175 w12->RemoveChild(w123.get()); 175 w12->RemoveChild(w123.get());
176 EXPECT_EQ(NULL, w123->GetFocusManager()); 176 EXPECT_EQ(NULL, w123->GetFocusManager());
177 EXPECT_FALSE(root_window->DispatchKeyEvent(&keyev)); 177 EXPECT_FALSE(root_window->AsRootWindowHostDelegate()->OnHostKeyEvent(&keyev));
178 } 178 }
179 179
180 // Various assertion testing for activating windows. 180 // Various assertion testing for activating windows.
181 TEST_F(WindowManagerTest, ActivateOnMouse) { 181 TEST_F(WindowManagerTest, ActivateOnMouse) {
182 aura::RootWindow* root_window = Shell::GetPrimaryRootWindow(); 182 aura::RootWindow* root_window = Shell::GetPrimaryRootWindow();
183 183
184 test::TestActivationDelegate d1; 184 test::TestActivationDelegate d1;
185 aura::test::TestWindowDelegate wd; 185 aura::test::TestWindowDelegate wd;
186 scoped_ptr<aura::Window> w1(aura::test::CreateTestWindowWithDelegate( 186 scoped_ptr<aura::Window> w1(aura::test::CreateTestWindowWithDelegate(
187 &wd, -1, gfx::Rect(10, 10, 50, 50), NULL)); 187 &wd, -1, gfx::Rect(10, 10, 50, 50), NULL));
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
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::ConvertPointToWindow(w2->parent(), root_window, &press_point);
326 aura::TouchEvent touchev1(ui::ET_TOUCH_PRESSED, press_point, 0, getTime()); 326 aura::TouchEvent touchev1(ui::ET_TOUCH_PRESSED, press_point, 0, getTime());
327 root_window->DispatchTouchEvent(&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::ConvertPointToWindow(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 aura::TouchEvent touchev2(ui::ET_TOUCH_PRESSED, press_point, 1, getTime());
344 root_window->DispatchTouchEvent(&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();
354 d2.Clear(); 354 d2.Clear();
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
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::ConvertPointToWindow(window->parent(), root_window, &point2);
390 aura::MouseEvent move2(ui::ET_MOUSE_MOVED, point2, point2, 0x0); 390 aura::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->DispatchMouseEvent(&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);
401 root_window->DispatchMouseEvent(&move2); 401 root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&move2);
402 EXPECT_EQ(ui::kCursorSouthWestResize, 402 EXPECT_EQ(ui::kCursorSouthWestResize,
403 root_window->last_cursor().native_type()); 403 root_window->last_cursor().native_type());
404 404
405 window_delegate.set_hittest_code(HTBOTTOMRIGHT); 405 window_delegate.set_hittest_code(HTBOTTOMRIGHT);
406 root_window->DispatchMouseEvent(&move1); 406 root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&move1);
407 EXPECT_EQ(ui::kCursorSouthEastResize, 407 EXPECT_EQ(ui::kCursorSouthEastResize,
408 root_window->last_cursor().native_type()); 408 root_window->last_cursor().native_type());
409 409
410 window_delegate.set_hittest_code(HTLEFT); 410 window_delegate.set_hittest_code(HTLEFT);
411 root_window->DispatchMouseEvent(&move2); 411 root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&move2);
412 EXPECT_EQ(ui::kCursorWestResize, root_window->last_cursor().native_type()); 412 EXPECT_EQ(ui::kCursorWestResize, root_window->last_cursor().native_type());
413 413
414 window_delegate.set_hittest_code(HTRIGHT); 414 window_delegate.set_hittest_code(HTRIGHT);
415 root_window->DispatchMouseEvent(&move1); 415 root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&move1);
416 EXPECT_EQ(ui::kCursorEastResize, root_window->last_cursor().native_type()); 416 EXPECT_EQ(ui::kCursorEastResize, root_window->last_cursor().native_type());
417 417
418 window_delegate.set_hittest_code(HTTOP); 418 window_delegate.set_hittest_code(HTTOP);
419 root_window->DispatchMouseEvent(&move2); 419 root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&move2);
420 EXPECT_EQ(ui::kCursorNorthResize, root_window->last_cursor().native_type()); 420 EXPECT_EQ(ui::kCursorNorthResize, root_window->last_cursor().native_type());
421 421
422 window_delegate.set_hittest_code(HTTOPLEFT); 422 window_delegate.set_hittest_code(HTTOPLEFT);
423 root_window->DispatchMouseEvent(&move1); 423 root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&move1);
424 EXPECT_EQ(ui::kCursorNorthWestResize, 424 EXPECT_EQ(ui::kCursorNorthWestResize,
425 root_window->last_cursor().native_type()); 425 root_window->last_cursor().native_type());
426 426
427 window_delegate.set_hittest_code(HTTOPRIGHT); 427 window_delegate.set_hittest_code(HTTOPRIGHT);
428 root_window->DispatchMouseEvent(&move2); 428 root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&move2);
429 EXPECT_EQ(ui::kCursorNorthEastResize, 429 EXPECT_EQ(ui::kCursorNorthEastResize,
430 root_window->last_cursor().native_type()); 430 root_window->last_cursor().native_type());
431 431
432 // Client area uses null cursor. 432 // Client area uses null cursor.
433 window_delegate.set_hittest_code(HTCLIENT); 433 window_delegate.set_hittest_code(HTCLIENT);
434 root_window->DispatchMouseEvent(&move1); 434 root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&move1);
435 EXPECT_EQ(ui::kCursorNull, root_window->last_cursor().native_type()); 435 EXPECT_EQ(ui::kCursorNull, root_window->last_cursor().native_type());
436 } 436 }
437 437
438 #if defined(OS_MACOSX) 438 #if defined(OS_MACOSX)
439 #define MAYBE_TransformActivate FAILS_TransformActivate 439 #define MAYBE_TransformActivate FAILS_TransformActivate
440 #else 440 #else
441 #define MAYBE_TransformActivate TransformActivate 441 #define MAYBE_TransformActivate TransformActivate
442 #endif 442 #endif
443 TEST_F(WindowManagerTest, MAYBE_TransformActivate) { 443 TEST_F(WindowManagerTest, MAYBE_TransformActivate) {
444 // Disable ash grid so that test can place a window at 444 // Disable ash grid so that test can place a window at
(...skipping 18 matching lines...) Expand all
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 aura::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->DispatchMouseEvent(&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 aura::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->DispatchMouseEvent(&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 aura::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->DispatchMouseEvent(&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(
497 shell_test.input_method_event_filter()); 497 shell_test.input_method_event_filter());
(...skipping 10 matching lines...) Expand all
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 aura::KeyEvent key_event(ui::ET_KEY_PRESSED, ui::VKEY_A, 0);
518 root_window->DispatchKeyEvent(&key_event); 518 root_window->AsRootWindowHostDelegate()->OnHostKeyEvent(&key_event);
519 aura::MouseEvent mouse_pressed( 519 aura::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->DispatchMouseEvent(&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->DispatchKeyEvent(&key_event); 537 root_window->AsRootWindowHostDelegate()->OnHostKeyEvent(&key_event);
538 aura::MouseEvent mouse_released( 538 aura::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->DispatchMouseEvent(&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();
549 f2->ResetCounts(); 549 f2->ResetCounts();
550 550
551 // Remove f1 from additonal filters list. 551 // Remove f1 from additonal filters list.
552 env_filter->RemoveFilter(f1.get()); 552 env_filter->RemoveFilter(f1.get());
553 553
554 // Dispatches events. 554 // Dispatches events.
555 root_window->DispatchKeyEvent(&key_event); 555 root_window->AsRootWindowHostDelegate()->OnHostKeyEvent(&key_event);
556 root_window->DispatchMouseEvent(&mouse_pressed); 556 root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouse_pressed);
557 557
558 // f1 should get no events since it's out and f2 should get them. 558 // f1 should get no events since it's out and f2 should get them.
559 EXPECT_EQ(0, f1->key_event_count()); 559 EXPECT_EQ(0, f1->key_event_count());
560 EXPECT_EQ(0, f1->mouse_event_count()); 560 EXPECT_EQ(0, f1->mouse_event_count());
561 EXPECT_EQ(1, f2->key_event_count()); 561 EXPECT_EQ(1, f2->key_event_count());
562 EXPECT_EQ(1, f2->mouse_event_count()); 562 EXPECT_EQ(1, f2->mouse_event_count());
563 563
564 env_filter->RemoveFilter(f2.get()); 564 env_filter->RemoveFilter(f2.get());
565 } 565 }
566 566
(...skipping 11 matching lines...) Expand all
578 ash::Shell::GetInstance()->cursor_manager(); 578 ash::Shell::GetInstance()->cursor_manager();
579 579
580 aura::MouseEvent mouse_moved( 580 aura::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 aura::TouchEvent 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 aura::TouchEvent 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->DispatchMouseEvent(&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->DispatchTouchEvent(&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->DispatchMouseEvent(&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->DispatchMouseEvent(&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->DispatchTouchEvent(&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
OLDNEW
« no previous file with comments | « ash/wm/system_gesture_event_filter_unittest.cc ('k') | ui/aura/aura.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698