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" |
11 #include "ui/aura/client/cursor_client_observer.h" | 11 #include "ui/aura/client/cursor_client_observer.h" |
12 #include "ui/aura/client/focus_client.h" | 12 #include "ui/aura/client/focus_client.h" |
13 #include "ui/aura/env.h" | 13 #include "ui/aura/env.h" |
14 #include "ui/aura/test/aura_test_base.h" | 14 #include "ui/aura/test/aura_test_base.h" |
| 15 #include "ui/aura/test/event_generator.h" |
15 #include "ui/aura/test/test_window_delegate.h" | 16 #include "ui/aura/test/test_window_delegate.h" |
16 #include "ui/aura/test/test_windows.h" | 17 #include "ui/aura/test/test_windows.h" |
17 #include "ui/base/cursor/cursor.h" | 18 #include "ui/base/cursor/cursor.h" |
18 #include "ui/base/hit_test.h" | 19 #include "ui/base/hit_test.h" |
19 #include "ui/events/event.h" | 20 #include "ui/events/event.h" |
20 #include "ui/events/event_processor.h" | 21 #include "ui/events/event_processor.h" |
21 #include "ui/events/event_utils.h" | 22 #include "ui/events/event_utils.h" |
22 #include "ui/events/test/event_generator.h" | |
23 #include "ui/events/test/test_event_handler.h" | 23 #include "ui/events/test/test_event_handler.h" |
24 #include "ui/gfx/screen.h" | 24 #include "ui/gfx/screen.h" |
25 #include "ui/wm/core/compound_event_filter.h" | 25 #include "ui/wm/core/compound_event_filter.h" |
26 #include "ui/wm/core/input_method_event_filter.h" | 26 #include "ui/wm/core/input_method_event_filter.h" |
27 #include "ui/wm/public/activation_client.h" | 27 #include "ui/wm/public/activation_client.h" |
28 #include "ui/wm/public/activation_delegate.h" | 28 #include "ui/wm/public/activation_delegate.h" |
29 | 29 |
30 namespace { | 30 namespace { |
31 | 31 |
32 class TestingCursorClientObserver : public aura::client::CursorClientObserver { | 32 class TestingCursorClientObserver : public aura::client::CursorClientObserver { |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 scoped_ptr<aura::Window> w122(aura::test::CreateTestWindowWithDelegate( | 167 scoped_ptr<aura::Window> w122(aura::test::CreateTestWindowWithDelegate( |
168 w122delegate, -122, gfx::Rect(10, 5, 5, 5), w12.get())); | 168 w122delegate, -122, gfx::Rect(10, 5, 5, 5), w12.get())); |
169 aura::test::ColorTestWindowDelegate* w123delegate = | 169 aura::test::ColorTestWindowDelegate* w123delegate = |
170 new aura::test::ColorTestWindowDelegate(SK_ColorRED); | 170 new aura::test::ColorTestWindowDelegate(SK_ColorRED); |
171 scoped_ptr<aura::Window> w123(aura::test::CreateTestWindowWithDelegate( | 171 scoped_ptr<aura::Window> w123(aura::test::CreateTestWindowWithDelegate( |
172 w123delegate, -123, gfx::Rect(15, 5, 5, 5), w12.get())); | 172 w123delegate, -123, gfx::Rect(15, 5, 5, 5), w12.get())); |
173 scoped_ptr<aura::Window> w13(aura::test::CreateTestWindow( | 173 scoped_ptr<aura::Window> w13(aura::test::CreateTestWindow( |
174 SK_ColorGRAY, -13, gfx::Rect(5, 470, 50, 50), w1.get())); | 174 SK_ColorGRAY, -13, gfx::Rect(5, 470, 50, 50), w1.get())); |
175 | 175 |
176 // Click on a sub-window (w121) to focus it. | 176 // Click on a sub-window (w121) to focus it. |
177 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), w121.get()); | 177 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), |
| 178 w121.get()); |
178 generator.ClickLeftButton(); | 179 generator.ClickLeftButton(); |
179 | 180 |
180 aura::client::FocusClient* focus_client = | 181 aura::client::FocusClient* focus_client = |
181 aura::client::GetFocusClient(w121.get()); | 182 aura::client::GetFocusClient(w121.get()); |
182 EXPECT_EQ(w121.get(), focus_client->GetFocusedWindow()); | 183 EXPECT_EQ(w121.get(), focus_client->GetFocusedWindow()); |
183 | 184 |
184 ui::EventProcessor* dispatcher = root_window->GetHost()->event_processor(); | 185 ui::EventProcessor* dispatcher = root_window->GetHost()->event_processor(); |
185 | 186 |
186 // The key press should be sent to the focused sub-window. | 187 // The key press should be sent to the focused sub-window. |
187 ui::KeyEvent keyev(ui::ET_KEY_PRESSED, ui::VKEY_E, 0, false); | 188 ui::KeyEvent keyev(ui::ET_KEY_PRESSED, ui::VKEY_E, 0, false); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 // Activate window1. | 280 // Activate window1. |
280 wm::ActivateWindow(w1.get()); | 281 wm::ActivateWindow(w1.get()); |
281 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); | 282 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); |
282 EXPECT_EQ(w1.get(), focus_client->GetFocusedWindow()); | 283 EXPECT_EQ(w1.get(), focus_client->GetFocusedWindow()); |
283 EXPECT_EQ(1, d1.activated_count()); | 284 EXPECT_EQ(1, d1.activated_count()); |
284 EXPECT_EQ(0, d1.lost_active_count()); | 285 EXPECT_EQ(0, d1.lost_active_count()); |
285 d1.Clear(); | 286 d1.Clear(); |
286 | 287 |
287 { | 288 { |
288 // Click on window2. | 289 // Click on window2. |
289 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), w2.get()); | 290 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), |
| 291 w2.get()); |
290 generator.ClickLeftButton(); | 292 generator.ClickLeftButton(); |
291 | 293 |
292 // Window2 should have become active. | 294 // Window2 should have become active. |
293 EXPECT_TRUE(wm::IsActiveWindow(w2.get())); | 295 EXPECT_TRUE(wm::IsActiveWindow(w2.get())); |
294 EXPECT_EQ(w2.get(), focus_client->GetFocusedWindow()); | 296 EXPECT_EQ(w2.get(), focus_client->GetFocusedWindow()); |
295 EXPECT_EQ(0, d1.activated_count()); | 297 EXPECT_EQ(0, d1.activated_count()); |
296 EXPECT_EQ(1, d1.lost_active_count()); | 298 EXPECT_EQ(1, d1.lost_active_count()); |
297 EXPECT_EQ(1, d2.activated_count()); | 299 EXPECT_EQ(1, d2.activated_count()); |
298 EXPECT_EQ(0, d2.lost_active_count()); | 300 EXPECT_EQ(0, d2.lost_active_count()); |
299 d1.Clear(); | 301 d1.Clear(); |
300 d2.Clear(); | 302 d2.Clear(); |
301 } | 303 } |
302 | 304 |
303 { | 305 { |
304 // Click back on window1, but set it up so w1 doesn't activate on click. | 306 // Click back on window1, but set it up so w1 doesn't activate on click. |
305 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), w1.get()); | 307 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), |
| 308 w1.get()); |
306 d1.set_activate(false); | 309 d1.set_activate(false); |
307 generator.ClickLeftButton(); | 310 generator.ClickLeftButton(); |
308 | 311 |
309 // Window2 should still be active and focused. | 312 // Window2 should still be active and focused. |
310 EXPECT_TRUE(wm::IsActiveWindow(w2.get())); | 313 EXPECT_TRUE(wm::IsActiveWindow(w2.get())); |
311 EXPECT_EQ(w2.get(), focus_client->GetFocusedWindow()); | 314 EXPECT_EQ(w2.get(), focus_client->GetFocusedWindow()); |
312 EXPECT_EQ(0, d1.activated_count()); | 315 EXPECT_EQ(0, d1.activated_count()); |
313 EXPECT_EQ(0, d1.lost_active_count()); | 316 EXPECT_EQ(0, d1.lost_active_count()); |
314 EXPECT_EQ(0, d2.activated_count()); | 317 EXPECT_EQ(0, d2.activated_count()); |
315 EXPECT_EQ(0, d2.lost_active_count()); | 318 EXPECT_EQ(0, d2.lost_active_count()); |
316 d1.Clear(); | 319 d1.Clear(); |
317 d2.Clear(); | 320 d2.Clear(); |
318 } | 321 } |
319 | 322 |
320 // Destroy window2, this should make window1 active. | 323 // Destroy window2, this should make window1 active. |
321 d1.set_activate(true); | 324 d1.set_activate(true); |
322 w2.reset(); | 325 w2.reset(); |
323 EXPECT_EQ(0, d2.activated_count()); | 326 EXPECT_EQ(0, d2.activated_count()); |
324 EXPECT_EQ(1, d2.lost_active_count()); | 327 EXPECT_EQ(1, d2.lost_active_count()); |
325 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); | 328 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); |
326 EXPECT_EQ(w1.get(), focus_client->GetFocusedWindow()); | 329 EXPECT_EQ(w1.get(), focus_client->GetFocusedWindow()); |
327 EXPECT_EQ(1, d1.activated_count()); | 330 EXPECT_EQ(1, d1.activated_count()); |
328 EXPECT_EQ(0, d1.lost_active_count()); | 331 EXPECT_EQ(0, d1.lost_active_count()); |
329 | 332 |
330 // Clicking an active window with a child shouldn't steal the | 333 // Clicking an active window with a child shouldn't steal the |
331 // focus from the child. | 334 // focus from the child. |
332 { | 335 { |
333 scoped_ptr<aura::Window> w11(CreateTestWindowWithDelegate( | 336 scoped_ptr<aura::Window> w11(CreateTestWindowWithDelegate( |
334 &wd, -11, gfx::Rect(10, 10, 10, 10), w1.get())); | 337 &wd, -11, gfx::Rect(10, 10, 10, 10), w1.get())); |
335 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), | 338 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), |
336 w11.get()); | 339 w11.get()); |
337 // First set the focus to the child |w11|. | 340 // First set the focus to the child |w11|. |
338 generator.ClickLeftButton(); | 341 generator.ClickLeftButton(); |
339 EXPECT_EQ(w11.get(), focus_client->GetFocusedWindow()); | 342 EXPECT_EQ(w11.get(), focus_client->GetFocusedWindow()); |
340 EXPECT_EQ(w1.get(), wm::GetActiveWindow()); | 343 EXPECT_EQ(w1.get(), wm::GetActiveWindow()); |
341 | 344 |
342 // Then click the parent active window. The focus shouldn't move. | 345 // Then click the parent active window. The focus shouldn't move. |
343 gfx::Point left_top = w1->bounds().origin(); | 346 gfx::Point left_top = w1->bounds().origin(); |
344 aura::Window::ConvertPointToTarget(w1->parent(), root_window, &left_top); | 347 aura::Window::ConvertPointToTarget(w1->parent(), root_window, &left_top); |
345 left_top.Offset(1, 1); | 348 left_top.Offset(1, 1); |
346 generator.MoveMouseTo(left_top); | 349 generator.MoveMouseTo(left_top); |
347 generator.ClickLeftButton(); | 350 generator.ClickLeftButton(); |
348 EXPECT_EQ(w11.get(), focus_client->GetFocusedWindow()); | 351 EXPECT_EQ(w11.get(), focus_client->GetFocusedWindow()); |
349 EXPECT_EQ(w1.get(), wm::GetActiveWindow()); | 352 EXPECT_EQ(w1.get(), wm::GetActiveWindow()); |
350 } | 353 } |
351 | 354 |
352 // Clicking on a non-focusable window inside a background window should still | 355 // Clicking on a non-focusable window inside a background window should still |
353 // give focus to the background window. | 356 // give focus to the background window. |
354 { | 357 { |
355 NonFocusableDelegate nfd; | 358 NonFocusableDelegate nfd; |
356 scoped_ptr<aura::Window> w11(CreateTestWindowWithDelegate( | 359 scoped_ptr<aura::Window> w11(CreateTestWindowWithDelegate( |
357 &nfd, -1, gfx::Rect(10, 10, 10, 10), w1.get())); | 360 &nfd, -1, gfx::Rect(10, 10, 10, 10), w1.get())); |
358 // Move focus to |w2| first. | 361 // Move focus to |w2| first. |
359 scoped_ptr<aura::Window> w2(CreateTestWindowInShellWithDelegate( | 362 scoped_ptr<aura::Window> w2(CreateTestWindowInShellWithDelegate( |
360 &wd, -1, gfx::Rect(70, 70, 50, 50))); | 363 &wd, -1, gfx::Rect(70, 70, 50, 50))); |
361 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), w2.get()); | 364 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), |
| 365 w2.get()); |
362 generator.ClickLeftButton(); | 366 generator.ClickLeftButton(); |
363 EXPECT_EQ(w2.get(), focus_client->GetFocusedWindow()); | 367 EXPECT_EQ(w2.get(), focus_client->GetFocusedWindow()); |
364 EXPECT_FALSE(w11->CanFocus()); | 368 EXPECT_FALSE(w11->CanFocus()); |
365 | 369 |
366 // Click on |w11|. This should focus w1. | 370 // Click on |w11|. This should focus w1. |
367 generator.MoveMouseToCenterOf(w11.get()); | 371 generator.MoveMouseToCenterOf(w11.get()); |
368 generator.ClickLeftButton(); | 372 generator.ClickLeftButton(); |
369 EXPECT_EQ(w1.get(), focus_client->GetFocusedWindow()); | 373 EXPECT_EQ(w1.get(), focus_client->GetFocusedWindow()); |
370 } | 374 } |
371 } | 375 } |
(...skipping 20 matching lines...) Expand all Loading... |
392 // Activate w1. | 396 // Activate w1. |
393 wm::ActivateWindow(w1.get()); | 397 wm::ActivateWindow(w1.get()); |
394 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); | 398 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); |
395 EXPECT_EQ(w1.get(), focus_client->GetFocusedWindow()); | 399 EXPECT_EQ(w1.get(), focus_client->GetFocusedWindow()); |
396 | 400 |
397 // Clicking on a non-activatable window should not change the active window. | 401 // Clicking on a non-activatable window should not change the active window. |
398 { | 402 { |
399 NonFocusableDelegate nfd; | 403 NonFocusableDelegate nfd; |
400 scoped_ptr<aura::Window> w3(CreateTestWindowInShellWithDelegate( | 404 scoped_ptr<aura::Window> w3(CreateTestWindowInShellWithDelegate( |
401 &nfd, -1, gfx::Rect(70, 70, 50, 50))); | 405 &nfd, -1, gfx::Rect(70, 70, 50, 50))); |
402 ui::test::EventGenerator generator3(Shell::GetPrimaryRootWindow(), | 406 aura::test::EventGenerator generator3(Shell::GetPrimaryRootWindow(), |
403 w3.get()); | 407 w3.get()); |
404 wm::ActivateWindow(p1.get()); | 408 wm::ActivateWindow(p1.get()); |
405 EXPECT_TRUE(wm::IsActiveWindow(p1.get())); | 409 EXPECT_TRUE(wm::IsActiveWindow(p1.get())); |
406 generator3.ClickLeftButton(); | 410 generator3.ClickLeftButton(); |
407 EXPECT_TRUE(wm::IsActiveWindow(p1.get())); | 411 EXPECT_TRUE(wm::IsActiveWindow(p1.get())); |
408 } | 412 } |
409 } | 413 } |
410 | 414 |
411 // Essentially the same as ActivateOnMouse, but for touch events. | 415 // Essentially the same as ActivateOnMouse, but for touch events. |
412 TEST_F(WindowManagerTest, ActivateOnTouch) { | 416 TEST_F(WindowManagerTest, ActivateOnTouch) { |
413 aura::Window* root_window = Shell::GetPrimaryRootWindow(); | 417 aura::Window* root_window = Shell::GetPrimaryRootWindow(); |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
720 EXPECT_EQ(0, f1->num_mouse_events()); | 724 EXPECT_EQ(0, f1->num_mouse_events()); |
721 EXPECT_EQ(1, f2->num_key_events()); | 725 EXPECT_EQ(1, f2->num_key_events()); |
722 EXPECT_EQ(1, f2->num_mouse_events()); | 726 EXPECT_EQ(1, f2->num_mouse_events()); |
723 | 727 |
724 env_filter->RemoveHandler(f2.get()); | 728 env_filter->RemoveHandler(f2.get()); |
725 } | 729 } |
726 | 730 |
727 #if defined(OS_CHROMEOS) || defined(OS_WIN) | 731 #if defined(OS_CHROMEOS) || defined(OS_WIN) |
728 // Touch visually hides the cursor on ChromeOS and Windows | 732 // Touch visually hides the cursor on ChromeOS and Windows |
729 TEST_F(WindowManagerTest, UpdateCursorVisibility) { | 733 TEST_F(WindowManagerTest, UpdateCursorVisibility) { |
730 ui::test::EventGenerator& generator = GetEventGenerator(); | 734 aura::test::EventGenerator& generator = GetEventGenerator(); |
731 ::wm::CursorManager* cursor_manager = | 735 ::wm::CursorManager* cursor_manager = |
732 ash::Shell::GetInstance()->cursor_manager(); | 736 ash::Shell::GetInstance()->cursor_manager(); |
733 | 737 |
734 generator.MoveMouseTo(gfx::Point(0, 0)); | 738 generator.MoveMouseTo(gfx::Point(0, 0)); |
735 EXPECT_TRUE(cursor_manager->IsCursorVisible()); | 739 EXPECT_TRUE(cursor_manager->IsCursorVisible()); |
736 EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled()); | 740 EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled()); |
737 generator.PressTouch(); | 741 generator.PressTouch(); |
738 EXPECT_FALSE(cursor_manager->IsCursorVisible()); | 742 EXPECT_FALSE(cursor_manager->IsCursorVisible()); |
739 EXPECT_FALSE(cursor_manager->IsMouseEventsEnabled()); | 743 EXPECT_FALSE(cursor_manager->IsMouseEventsEnabled()); |
740 generator.MoveMouseTo(gfx::Point(0, 0)); | 744 generator.MoveMouseTo(gfx::Point(0, 0)); |
741 EXPECT_TRUE(cursor_manager->IsCursorVisible()); | 745 EXPECT_TRUE(cursor_manager->IsCursorVisible()); |
742 EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled()); | 746 EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled()); |
743 generator.ReleaseTouch(); | 747 generator.ReleaseTouch(); |
744 EXPECT_TRUE(cursor_manager->IsCursorVisible()); | 748 EXPECT_TRUE(cursor_manager->IsCursorVisible()); |
745 EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled()); | 749 EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled()); |
746 } | 750 } |
747 #endif // defined(OS_CHROMEOS) || defined(OS_WIN) | 751 #endif // defined(OS_CHROMEOS) || defined(OS_WIN) |
748 | 752 |
749 #if defined(OS_CHROMEOS) | 753 #if defined(OS_CHROMEOS) |
750 // ChromeOS is the only platform for which the cursor is hidden on keypress | 754 // ChromeOS is the only platform for which the cursor is hidden on keypress |
751 // (crbug.com/304296). | 755 // (crbug.com/304296). |
752 TEST_F(WindowManagerTest, UpdateCursorVisibilityOnKeyEvent) { | 756 TEST_F(WindowManagerTest, UpdateCursorVisibilityOnKeyEvent) { |
753 ui::test::EventGenerator& generator = GetEventGenerator(); | 757 aura::test::EventGenerator& generator = GetEventGenerator(); |
754 ::wm::CursorManager* cursor_manager = | 758 ::wm::CursorManager* cursor_manager = |
755 ash::Shell::GetInstance()->cursor_manager(); | 759 ash::Shell::GetInstance()->cursor_manager(); |
756 | 760 |
757 // Pressing a key hides the cursor but does not disable mouse events. | 761 // Pressing a key hides the cursor but does not disable mouse events. |
758 generator.PressKey(ui::VKEY_A, ui::EF_NONE); | 762 generator.PressKey(ui::VKEY_A, ui::EF_NONE); |
759 EXPECT_FALSE(cursor_manager->IsCursorVisible()); | 763 EXPECT_FALSE(cursor_manager->IsCursorVisible()); |
760 EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled()); | 764 EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled()); |
761 // Moving mouse shows the cursor. | 765 // Moving mouse shows the cursor. |
762 generator.MoveMouseTo(gfx::Point(0, 0)); | 766 generator.MoveMouseTo(gfx::Point(0, 0)); |
763 EXPECT_TRUE(cursor_manager->IsCursorVisible()); | 767 EXPECT_TRUE(cursor_manager->IsCursorVisible()); |
764 EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled()); | 768 EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled()); |
765 // Releasing a key also hides the cursor but does not disable mouse events. | 769 // Releasing a key also hides the cursor but does not disable mouse events. |
766 generator.ReleaseKey(ui::VKEY_A, ui::EF_NONE); | 770 generator.ReleaseKey(ui::VKEY_A, ui::EF_NONE); |
767 EXPECT_FALSE(cursor_manager->IsCursorVisible()); | 771 EXPECT_FALSE(cursor_manager->IsCursorVisible()); |
768 EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled()); | 772 EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled()); |
769 // Moving mouse shows the cursor again. | 773 // Moving mouse shows the cursor again. |
770 generator.MoveMouseTo(gfx::Point(0, 0)); | 774 generator.MoveMouseTo(gfx::Point(0, 0)); |
771 EXPECT_TRUE(cursor_manager->IsCursorVisible()); | 775 EXPECT_TRUE(cursor_manager->IsCursorVisible()); |
772 EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled()); | 776 EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled()); |
773 } | 777 } |
774 | 778 |
775 TEST_F(WindowManagerTest, TestCursorClientObserver) { | 779 TEST_F(WindowManagerTest, TestCursorClientObserver) { |
776 ui::test::EventGenerator& generator = GetEventGenerator(); | 780 aura::test::EventGenerator& generator = GetEventGenerator(); |
777 ::wm::CursorManager* cursor_manager = | 781 ::wm::CursorManager* cursor_manager = |
778 ash::Shell::GetInstance()->cursor_manager(); | 782 ash::Shell::GetInstance()->cursor_manager(); |
779 | 783 |
780 scoped_ptr<aura::Window> w1(CreateTestWindowInShell( | 784 scoped_ptr<aura::Window> w1(CreateTestWindowInShell( |
781 SK_ColorWHITE, -1, gfx::Rect(0, 0, 100, 100))); | 785 SK_ColorWHITE, -1, gfx::Rect(0, 0, 100, 100))); |
782 wm::ActivateWindow(w1.get()); | 786 wm::ActivateWindow(w1.get()); |
783 | 787 |
784 // Add two observers. Both should have OnCursorVisibilityChanged() | 788 // Add two observers. Both should have OnCursorVisibilityChanged() |
785 // invoked when an event changes the visibility of the cursor. | 789 // invoked when an event changes the visibility of the cursor. |
786 TestingCursorClientObserver observer_a; | 790 TestingCursorClientObserver observer_a; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
828 observer_a.reset(); | 832 observer_a.reset(); |
829 observer_b.reset(); | 833 observer_b.reset(); |
830 generator.MoveMouseTo(50, 50); | 834 generator.MoveMouseTo(50, 50); |
831 EXPECT_TRUE(observer_a.did_visibility_change()); | 835 EXPECT_TRUE(observer_a.did_visibility_change()); |
832 EXPECT_FALSE(observer_b.did_visibility_change()); | 836 EXPECT_FALSE(observer_b.did_visibility_change()); |
833 EXPECT_TRUE(observer_a.is_cursor_visible()); | 837 EXPECT_TRUE(observer_a.is_cursor_visible()); |
834 } | 838 } |
835 #endif // defined(OS_CHROMEOS) | 839 #endif // defined(OS_CHROMEOS) |
836 | 840 |
837 } // namespace ash | 841 } // namespace ash |
OLD | NEW |