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/activation_controller.h" | |
11 #include "ash/wm/window_util.h" | 10 #include "ash/wm/window_util.h" |
12 #include "ui/aura/client/activation_client.h" | 11 #include "ui/aura/client/activation_client.h" |
13 #include "ui/aura/client/activation_delegate.h" | 12 #include "ui/aura/client/activation_delegate.h" |
14 #include "ui/aura/client/cursor_client_observer.h" | 13 #include "ui/aura/client/cursor_client_observer.h" |
15 #include "ui/aura/client/focus_client.h" | 14 #include "ui/aura/client/focus_client.h" |
16 #include "ui/aura/env.h" | 15 #include "ui/aura/env.h" |
17 #include "ui/aura/root_window.h" | 16 #include "ui/aura/root_window.h" |
18 #include "ui/aura/test/aura_test_base.h" | 17 #include "ui/aura/test/aura_test_base.h" |
19 #include "ui/aura/test/event_generator.h" | 18 #include "ui/aura/test/event_generator.h" |
20 #include "ui/aura/test/test_event_handler.h" | 19 #include "ui/aura/test/test_event_handler.h" |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 EXPECT_EQ(0, d2.activated_count()); | 311 EXPECT_EQ(0, d2.activated_count()); |
313 EXPECT_EQ(0, d2.lost_active_count()); | 312 EXPECT_EQ(0, d2.lost_active_count()); |
314 d1.Clear(); | 313 d1.Clear(); |
315 d2.Clear(); | 314 d2.Clear(); |
316 } | 315 } |
317 | 316 |
318 // Destroy window2, this should make window1 active. | 317 // Destroy window2, this should make window1 active. |
319 d1.set_activate(true); | 318 d1.set_activate(true); |
320 w2.reset(); | 319 w2.reset(); |
321 EXPECT_EQ(0, d2.activated_count()); | 320 EXPECT_EQ(0, d2.activated_count()); |
322 EXPECT_EQ(views::corewm::UseFocusController() ? 1 : 0, | 321 EXPECT_EQ(1, d2.lost_active_count()); |
323 d2.lost_active_count()); | |
324 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); | 322 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); |
325 EXPECT_EQ(w1.get(), focus_client->GetFocusedWindow()); | 323 EXPECT_EQ(w1.get(), focus_client->GetFocusedWindow()); |
326 EXPECT_EQ(1, d1.activated_count()); | 324 EXPECT_EQ(1, d1.activated_count()); |
327 EXPECT_EQ(0, d1.lost_active_count()); | 325 EXPECT_EQ(0, d1.lost_active_count()); |
328 | 326 |
329 // Clicking an active window with a child shouldn't steal the | 327 // Clicking an active window with a child shouldn't steal the |
330 // focus from the child. | 328 // focus from the child. |
331 { | 329 { |
332 scoped_ptr<aura::Window> w11(CreateTestWindowWithDelegate( | 330 scoped_ptr<aura::Window> w11(CreateTestWindowWithDelegate( |
333 &wd, -11, gfx::Rect(10, 10, 10, 10), w1.get())); | 331 &wd, -11, gfx::Rect(10, 10, 10, 10), w1.get())); |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 EXPECT_EQ(0, d1.lost_active_count()); | 464 EXPECT_EQ(0, d1.lost_active_count()); |
467 EXPECT_EQ(0, d2.activated_count()); | 465 EXPECT_EQ(0, d2.activated_count()); |
468 EXPECT_EQ(0, d2.lost_active_count()); | 466 EXPECT_EQ(0, d2.lost_active_count()); |
469 d1.Clear(); | 467 d1.Clear(); |
470 d2.Clear(); | 468 d2.Clear(); |
471 | 469 |
472 // Destroy window2, this should make window1 active. | 470 // Destroy window2, this should make window1 active. |
473 d1.set_activate(true); | 471 d1.set_activate(true); |
474 w2.reset(); | 472 w2.reset(); |
475 EXPECT_EQ(0, d2.activated_count()); | 473 EXPECT_EQ(0, d2.activated_count()); |
476 EXPECT_EQ(views::corewm::UseFocusController() ? 1 : 0, | 474 EXPECT_EQ(1, d2.lost_active_count()); |
477 d2.lost_active_count()); | |
478 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); | 475 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); |
479 EXPECT_EQ(w1.get(), focus_client->GetFocusedWindow()); | 476 EXPECT_EQ(w1.get(), focus_client->GetFocusedWindow()); |
480 EXPECT_EQ(1, d1.activated_count()); | 477 EXPECT_EQ(1, d1.activated_count()); |
481 EXPECT_EQ(0, d1.lost_active_count()); | 478 EXPECT_EQ(0, d1.lost_active_count()); |
482 } | 479 } |
483 | 480 |
484 TEST_F(WindowManagerTest, MouseEventCursors) { | 481 TEST_F(WindowManagerTest, MouseEventCursors) { |
485 aura::RootWindow* root_window = Shell::GetPrimaryRootWindow(); | 482 aura::RootWindow* root_window = Shell::GetPrimaryRootWindow(); |
486 | 483 |
487 // Create a window. | 484 // Create a window. |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
831 // Mouse move should show the cursor. | 828 // Mouse move should show the cursor. |
832 observer_a.reset(); | 829 observer_a.reset(); |
833 observer_b.reset(); | 830 observer_b.reset(); |
834 generator.MoveMouseTo(50, 50); | 831 generator.MoveMouseTo(50, 50); |
835 EXPECT_TRUE(observer_a.did_visibility_change()); | 832 EXPECT_TRUE(observer_a.did_visibility_change()); |
836 EXPECT_FALSE(observer_b.did_visibility_change()); | 833 EXPECT_FALSE(observer_b.did_visibility_change()); |
837 EXPECT_TRUE(observer_a.is_cursor_visible()); | 834 EXPECT_TRUE(observer_a.is_cursor_visible()); |
838 } | 835 } |
839 | 836 |
840 } // namespace ash | 837 } // namespace ash |
OLD | NEW |