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

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

Issue 11519040: More unittests passing with new focus controller. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years 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/toplevel_window_event_handler_unittest.cc ('k') | ui/views/bubble/bubble_delegate.cc » ('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/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/activation_controller.h" 10 #include "ash/wm/activation_controller.h"
11 #include "ash/wm/cursor_manager.h" 11 #include "ash/wm/cursor_manager.h"
12 #include "ash/wm/window_util.h" 12 #include "ash/wm/window_util.h"
13 #include "ui/aura/client/activation_client.h" 13 #include "ui/aura/client/activation_client.h"
14 #include "ui/aura/client/activation_delegate.h" 14 #include "ui/aura/client/activation_delegate.h"
15 #include "ui/aura/client/focus_client.h" 15 #include "ui/aura/client/focus_client.h"
16 #include "ui/aura/env.h" 16 #include "ui/aura/env.h"
17 #include "ui/aura/root_window.h" 17 #include "ui/aura/root_window.h"
18 #include "ui/aura/test/aura_test_base.h" 18 #include "ui/aura/test/aura_test_base.h"
19 #include "ui/aura/test/event_generator.h" 19 #include "ui/aura/test/event_generator.h"
20 #include "ui/aura/test/test_event_handler.h" 20 #include "ui/aura/test/test_event_handler.h"
21 #include "ui/aura/test/test_window_delegate.h" 21 #include "ui/aura/test/test_window_delegate.h"
22 #include "ui/aura/test/test_windows.h" 22 #include "ui/aura/test/test_windows.h"
23 #include "ui/base/cursor/cursor.h" 23 #include "ui/base/cursor/cursor.h"
24 #include "ui/base/events/event.h" 24 #include "ui/base/events/event.h"
25 #include "ui/base/hit_test.h" 25 #include "ui/base/hit_test.h"
26 #include "ui/gfx/screen.h" 26 #include "ui/gfx/screen.h"
27 #include "ui/views/corewm/compound_event_filter.h" 27 #include "ui/views/corewm/compound_event_filter.h"
28 #include "ui/views/corewm/corewm_switches.h"
28 #include "ui/views/corewm/input_method_event_filter.h" 29 #include "ui/views/corewm/input_method_event_filter.h"
29 30
30 namespace { 31 namespace {
31 32
32 base::TimeDelta getTime() { 33 base::TimeDelta getTime() {
33 return base::Time::NowFromSystemTime() - base::Time(); 34 return base::Time::NowFromSystemTime() - base::Time();
34 } 35 }
35 36
36 // A slightly changed TestEventHandler which can be configured to return a 37 // A slightly changed TestEventHandler which can be configured to return a
37 // specified value for key/mouse event handling. 38 // specified value for key/mouse event handling.
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 TEST_F(WindowManagerTest, ActivateOnMouse) { 227 TEST_F(WindowManagerTest, ActivateOnMouse) {
227 aura::RootWindow* root_window = Shell::GetPrimaryRootWindow(); 228 aura::RootWindow* root_window = Shell::GetPrimaryRootWindow();
228 229
229 test::TestActivationDelegate d1; 230 test::TestActivationDelegate d1;
230 aura::test::TestWindowDelegate wd; 231 aura::test::TestWindowDelegate wd;
231 scoped_ptr<aura::Window> w1(CreateTestWindowInShellWithDelegate( 232 scoped_ptr<aura::Window> w1(CreateTestWindowInShellWithDelegate(
232 &wd, -1, gfx::Rect(10, 10, 50, 50))); 233 &wd, -1, gfx::Rect(10, 10, 50, 50)));
233 d1.SetWindow(w1.get()); 234 d1.SetWindow(w1.get());
234 test::TestActivationDelegate d2; 235 test::TestActivationDelegate d2;
235 scoped_ptr<aura::Window> w2(CreateTestWindowInShellWithDelegate( 236 scoped_ptr<aura::Window> w2(CreateTestWindowInShellWithDelegate(
236 &wd, -1, gfx::Rect(70, 70, 50, 50))); 237 &wd, -2, gfx::Rect(70, 70, 50, 50)));
237 d2.SetWindow(w2.get()); 238 d2.SetWindow(w2.get());
238 239
239 aura::client::FocusClient* focus_client = 240 aura::client::FocusClient* focus_client =
240 aura::client::GetFocusClient(w1.get()); 241 aura::client::GetFocusClient(w1.get());
241 242
242 d1.Clear(); 243 d1.Clear();
243 d2.Clear(); 244 d2.Clear();
244 245
245 // Activate window1. 246 // Activate window1.
246 wm::ActivateWindow(w1.get()); 247 wm::ActivateWindow(w1.get());
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 EXPECT_EQ(0, d2.activated_count()); 283 EXPECT_EQ(0, d2.activated_count());
283 EXPECT_EQ(0, d2.lost_active_count()); 284 EXPECT_EQ(0, d2.lost_active_count());
284 d1.Clear(); 285 d1.Clear();
285 d2.Clear(); 286 d2.Clear();
286 } 287 }
287 288
288 // Destroy window2, this should make window1 active. 289 // Destroy window2, this should make window1 active.
289 d1.set_activate(true); 290 d1.set_activate(true);
290 w2.reset(); 291 w2.reset();
291 EXPECT_EQ(0, d2.activated_count()); 292 EXPECT_EQ(0, d2.activated_count());
292 EXPECT_EQ(0, d2.lost_active_count()); 293 EXPECT_EQ(views::corewm::UseFocusController() ? 1 : 0,
294 d2.lost_active_count());
293 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); 295 EXPECT_TRUE(wm::IsActiveWindow(w1.get()));
294 EXPECT_EQ(w1.get(), focus_client->GetFocusedWindow()); 296 EXPECT_EQ(w1.get(), focus_client->GetFocusedWindow());
295 EXPECT_EQ(1, d1.activated_count()); 297 EXPECT_EQ(1, d1.activated_count());
296 EXPECT_EQ(0, d1.lost_active_count()); 298 EXPECT_EQ(0, d1.lost_active_count());
297 299
298 // Clicking an active window with a child shouldn't steal the 300 // Clicking an active window with a child shouldn't steal the
299 // focus from the child. 301 // focus from the child.
300 { 302 {
301 scoped_ptr<aura::Window> w11(CreateTestWindowWithDelegate( 303 scoped_ptr<aura::Window> w11(CreateTestWindowWithDelegate(
302 &wd, -1, gfx::Rect(10, 10, 10, 10), w1.get())); 304 &wd, -11, gfx::Rect(10, 10, 10, 10), w1.get()));
303 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), 305 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
304 w11.get()); 306 w11.get());
305 // First set the focus to the child |w11|. 307 // First set the focus to the child |w11|.
306 generator.ClickLeftButton(); 308 generator.ClickLeftButton();
307 EXPECT_EQ(w11.get(), focus_client->GetFocusedWindow()); 309 EXPECT_EQ(w11.get(), focus_client->GetFocusedWindow());
308 EXPECT_EQ(w1.get(), wm::GetActiveWindow()); 310 EXPECT_EQ(w1.get(), wm::GetActiveWindow());
309 311
310 // Then click the parent active window. The focus shouldn't move. 312 // Then click the parent active window. The focus shouldn't move.
311 gfx::Point left_top = w1->bounds().origin(); 313 gfx::Point left_top = w1->bounds().origin();
312 aura::Window::ConvertPointToTarget(w1->parent(), root_window, &left_top); 314 aura::Window::ConvertPointToTarget(w1->parent(), root_window, &left_top);
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 EXPECT_EQ(0, d1.lost_active_count()); 399 EXPECT_EQ(0, d1.lost_active_count());
398 EXPECT_EQ(0, d2.activated_count()); 400 EXPECT_EQ(0, d2.activated_count());
399 EXPECT_EQ(0, d2.lost_active_count()); 401 EXPECT_EQ(0, d2.lost_active_count());
400 d1.Clear(); 402 d1.Clear();
401 d2.Clear(); 403 d2.Clear();
402 404
403 // Destroy window2, this should make window1 active. 405 // Destroy window2, this should make window1 active.
404 d1.set_activate(true); 406 d1.set_activate(true);
405 w2.reset(); 407 w2.reset();
406 EXPECT_EQ(0, d2.activated_count()); 408 EXPECT_EQ(0, d2.activated_count());
407 EXPECT_EQ(0, d2.lost_active_count()); 409 EXPECT_EQ(views::corewm::UseFocusController() ? 1 : 0,
410 d2.lost_active_count());
408 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); 411 EXPECT_TRUE(wm::IsActiveWindow(w1.get()));
409 EXPECT_EQ(w1.get(), focus_client->GetFocusedWindow()); 412 EXPECT_EQ(w1.get(), focus_client->GetFocusedWindow());
410 EXPECT_EQ(1, d1.activated_count()); 413 EXPECT_EQ(1, d1.activated_count());
411 EXPECT_EQ(0, d1.lost_active_count()); 414 EXPECT_EQ(0, d1.lost_active_count());
412 } 415 }
413 416
414 TEST_F(WindowManagerTest, MouseEventCursors) { 417 TEST_F(WindowManagerTest, MouseEventCursors) {
415 aura::RootWindow* root_window = Shell::GetPrimaryRootWindow(); 418 aura::RootWindow* root_window = Shell::GetPrimaryRootWindow();
416 419
417 // Create a window. 420 // Create a window.
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
678 EXPECT_TRUE(cursor_manager->IsCursorVisible()); 681 EXPECT_TRUE(cursor_manager->IsCursorVisible());
679 root_window->AsRootWindowHostDelegate()->OnHostTouchEvent(&touch_pressed2); 682 root_window->AsRootWindowHostDelegate()->OnHostTouchEvent(&touch_pressed2);
680 EXPECT_FALSE(cursor_manager->IsCursorVisible()); 683 EXPECT_FALSE(cursor_manager->IsCursorVisible());
681 root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouse_moved); 684 root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouse_moved);
682 EXPECT_TRUE(cursor_manager->IsCursorVisible()); 685 EXPECT_TRUE(cursor_manager->IsCursorVisible());
683 root_window->AsRootWindowHostDelegate()->OnHostTouchEvent(&touch_released2); 686 root_window->AsRootWindowHostDelegate()->OnHostTouchEvent(&touch_released2);
684 EXPECT_TRUE(cursor_manager->IsCursorVisible()); 687 EXPECT_TRUE(cursor_manager->IsCursorVisible());
685 } 688 }
686 689
687 } // namespace ash 690 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/toplevel_window_event_handler_unittest.cc ('k') | ui/views/bubble/bubble_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698