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/wm/custom_frame_view_ash.h" | 5 #include "ash/wm/custom_frame_view_ash.h" |
6 | 6 |
7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
8 #include "ash/test/ash_test_base.h" | 8 #include "ash/test/ash_test_base.h" |
9 #include "ash/wm/maximize_bubble_controller.h" | 9 #include "ash/wm/maximize_bubble_controller.h" |
10 #include "ash/wm/window_util.h" | 10 #include "ash/wm/window_util.h" |
11 #include "ash/wm/workspace/frame_maximize_button.h" | 11 #include "ash/wm/workspace/frame_maximize_button.h" |
12 #include "ash/wm/workspace/snap_sizer.h" | 12 #include "ash/wm/workspace/snap_sizer.h" |
13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
14 #include "ui/aura/aura_switches.h" | 14 #include "ui/aura/aura_switches.h" |
| 15 #include "ui/aura/focus_manager.h" |
15 #include "ui/aura/test/event_generator.h" | 16 #include "ui/aura/test/event_generator.h" |
16 #include "ui/aura/window.h" | 17 #include "ui/aura/window.h" |
17 #include "ui/views/controls/button/image_button.h" | 18 #include "ui/views/controls/button/image_button.h" |
18 #include "ui/views/test/test_views_delegate.h" | 19 #include "ui/views/test/test_views_delegate.h" |
19 #include "ui/views/widget/widget.h" | 20 #include "ui/views/widget/widget.h" |
20 #include "ui/views/widget/widget_delegate.h" | 21 #include "ui/views/widget/widget_delegate.h" |
21 | 22 |
22 namespace ash { | 23 namespace ash { |
23 namespace internal { | 24 namespace internal { |
24 | 25 |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 EXPECT_FALSE(maximize_button->maximizer()); | 365 EXPECT_FALSE(maximize_button->maximizer()); |
365 EXPECT_FALSE(maximize_button->phantom_window_open()); | 366 EXPECT_FALSE(maximize_button->phantom_window_open()); |
366 | 367 |
367 EXPECT_FALSE(ash::wm::IsWindowMaximized(window)); | 368 EXPECT_FALSE(ash::wm::IsWindowMaximized(window)); |
368 EXPECT_FALSE(ash::wm::IsWindowMinimized(window)); | 369 EXPECT_FALSE(ash::wm::IsWindowMinimized(window)); |
369 internal::SnapSizer sizer(window, button_pos, | 370 internal::SnapSizer sizer(window, button_pos, |
370 internal::SnapSizer::LEFT_EDGE, kGridSize); | 371 internal::SnapSizer::LEFT_EDGE, kGridSize); |
371 EXPECT_EQ(sizer.target_bounds().ToString(), window->bounds().ToString()); | 372 EXPECT_EQ(sizer.target_bounds().ToString(), window->bounds().ToString()); |
372 } | 373 } |
373 | 374 |
| 375 // Test that the activation focus does not change when the bubble gets shown. |
| 376 TEST_F(CustomFrameViewAshTest, MaximizeKeepFocus) { |
| 377 views::Widget* widget = CreateWidget(); |
| 378 aura::Window* window = widget->GetNativeWindow(); |
| 379 CustomFrameViewAsh* frame = custom_frame_view_ash(widget); |
| 380 CustomFrameViewAsh::TestApi test(frame); |
| 381 ash::FrameMaximizeButton* maximize_button = test.maximize_button(); |
| 382 maximize_button->set_bubble_appearance_delay_ms(0); |
| 383 gfx::Point button_pos = maximize_button->GetBoundsInScreen().CenterPoint(); |
| 384 gfx::Point off_pos(button_pos.x() + 100, button_pos.y() + 100); |
| 385 |
| 386 aura::test::EventGenerator generator(window->GetRootWindow(), off_pos); |
| 387 EXPECT_FALSE(maximize_button->maximizer()); |
| 388 EXPECT_TRUE(ash::wm::IsWindowNormal(window)); |
| 389 |
| 390 aura::Window* active = window->GetFocusManager()->GetFocusedWindow(); |
| 391 |
| 392 // Move the mouse cursor over the button to bring up the maximizer bubble. |
| 393 generator.MoveMouseTo(button_pos); |
| 394 EXPECT_TRUE(maximize_button->maximizer()); |
| 395 |
| 396 // Check that the focused window is still the same. |
| 397 EXPECT_EQ(active, window->GetFocusManager()->GetFocusedWindow()); |
| 398 } |
| 399 |
374 } // namespace internal | 400 } // namespace internal |
375 } // namespace ash | 401 } // namespace ash |
OLD | NEW |