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

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

Issue 10831240: Remove TouchEvent interface, and rename TouchEventImpl to TouchEvent (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge-tot 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/window_cycle_controller.cc ('k') | ash/wm/window_modality_controller.h » ('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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 ui::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::ConvertPointToTarget(w122->parent(), root_window, &click_point); 125 aura::Window::ConvertPointToTarget(w122->parent(), root_window, &click_point);
126 ui::TouchEventImpl touchev(ui::ET_TOUCH_PRESSED, click_point, 0, getTime()); 126 ui::TouchEvent 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 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
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::ConvertPointToTarget(w2->parent(), root_window, &press_point); 325 aura::Window::ConvertPointToTarget(w2->parent(), root_window, &press_point);
326 ui::TouchEventImpl touchev1(ui::ET_TOUCH_PRESSED, press_point, 0, getTime()); 326 ui::TouchEvent 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::ConvertPointToTarget(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 ui::TouchEventImpl touchev2(ui::ET_TOUCH_PRESSED, press_point, 1, getTime()); 343 ui::TouchEvent 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 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 ui::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 ui::TouchEventImpl touch_pressed1( 582 ui::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 ui::TouchEventImpl touch_pressed2( 584 ui::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->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
OLDNEW
« no previous file with comments | « ash/wm/window_cycle_controller.cc ('k') | ash/wm/window_modality_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698