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/workspace/workspace_event_handler.h" | 5 #include "ash/wm/workspace/workspace_event_handler.h" |
6 | 6 |
7 #include "ash/screen_util.h" | 7 #include "ash/screen_util.h" |
8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
| 9 #include "ash/shell_port.h" |
9 #include "ash/test/ash_test_base.h" | 10 #include "ash/test/ash_test_base.h" |
10 #include "ash/wm/window_state.h" | 11 #include "ash/wm/window_state.h" |
11 #include "ash/wm/window_state_aura.h" | 12 #include "ash/wm/window_state_aura.h" |
12 #include "ash/wm/window_util.h" | 13 #include "ash/wm/window_util.h" |
13 #include "ash/wm/wm_event.h" | 14 #include "ash/wm/wm_event.h" |
14 #include "ash/wm/workspace_controller.h" | 15 #include "ash/wm/workspace_controller.h" |
15 #include "ash/wm/workspace_controller_test_helper.h" | 16 #include "ash/wm/workspace_controller_test_helper.h" |
16 #include "ash/wm_shell.h" | |
17 #include "base/threading/thread_task_runner_handle.h" | 17 #include "base/threading/thread_task_runner_handle.h" |
18 #include "services/ui/public/interfaces/window_manager_constants.mojom.h" | 18 #include "services/ui/public/interfaces/window_manager_constants.mojom.h" |
19 #include "ui/aura/client/aura_constants.h" | 19 #include "ui/aura/client/aura_constants.h" |
20 #include "ui/aura/test/test_window_delegate.h" | 20 #include "ui/aura/test/test_window_delegate.h" |
21 #include "ui/aura/window.h" | 21 #include "ui/aura/window.h" |
22 #include "ui/aura/window_tree_host.h" | 22 #include "ui/aura/window_tree_host.h" |
23 #include "ui/base/hit_test.h" | 23 #include "ui/base/hit_test.h" |
24 #include "ui/display/screen.h" | 24 #include "ui/display/screen.h" |
25 #include "ui/events/event_processor.h" | 25 #include "ui/events/event_processor.h" |
26 #include "ui/events/event_utils.h" | 26 #include "ui/events/event_utils.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 } | 90 } |
91 | 91 |
92 aura::Window* window_; | 92 aura::Window* window_; |
93 std::vector<const void*> properties_changed_; | 93 std::vector<const void*> properties_changed_; |
94 | 94 |
95 DISALLOW_COPY_AND_ASSIGN(WindowPropertyObserver); | 95 DISALLOW_COPY_AND_ASSIGN(WindowPropertyObserver); |
96 }; | 96 }; |
97 | 97 |
98 TEST_F(WorkspaceEventHandlerTest, DoubleClickSingleAxisResizeEdge) { | 98 TEST_F(WorkspaceEventHandlerTest, DoubleClickSingleAxisResizeEdge) { |
99 // TODO: investigate failure. http://crbug.com/699175. | 99 // TODO: investigate failure. http://crbug.com/699175. |
100 if (WmShell::Get()->IsRunningInMash()) | 100 if (ShellPort::Get()->IsRunningInMash()) |
101 return; | 101 return; |
102 | 102 |
103 // Double clicking the vertical resize edge of a window should maximize it | 103 // Double clicking the vertical resize edge of a window should maximize it |
104 // vertically. | 104 // vertically. |
105 gfx::Rect restored_bounds(10, 10, 50, 50); | 105 gfx::Rect restored_bounds(10, 10, 50, 50); |
106 aura::test::TestWindowDelegate delegate; | 106 aura::test::TestWindowDelegate delegate; |
107 std::unique_ptr<aura::Window> window( | 107 std::unique_ptr<aura::Window> window( |
108 CreateTestWindow(&delegate, restored_bounds)); | 108 CreateTestWindow(&delegate, restored_bounds)); |
109 | 109 |
110 wm::ActivateWindow(window.get()); | 110 wm::ActivateWindow(window.get()); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 EXPECT_FALSE(window_state->IsMaximized()); | 200 EXPECT_FALSE(window_state->IsMaximized()); |
201 | 201 |
202 // Restore. | 202 // Restore. |
203 generator2.DoubleClickLeftButton(); | 203 generator2.DoubleClickLeftButton(); |
204 EXPECT_EQ(restored_bounds.ToString(), window->GetBoundsInScreen().ToString()); | 204 EXPECT_EQ(restored_bounds.ToString(), window->GetBoundsInScreen().ToString()); |
205 } | 205 } |
206 | 206 |
207 // Tests the behavior when double clicking the border of a side snapped window. | 207 // Tests the behavior when double clicking the border of a side snapped window. |
208 TEST_F(WorkspaceEventHandlerTest, DoubleClickSingleAxisWhenSideSnapped) { | 208 TEST_F(WorkspaceEventHandlerTest, DoubleClickSingleAxisWhenSideSnapped) { |
209 // TODO: investigate failure. http://crbug.com/699175. | 209 // TODO: investigate failure. http://crbug.com/699175. |
210 if (WmShell::Get()->IsRunningInMash()) | 210 if (ShellPort::Get()->IsRunningInMash()) |
211 return; | 211 return; |
212 | 212 |
213 gfx::Rect restored_bounds(10, 10, 50, 50); | 213 gfx::Rect restored_bounds(10, 10, 50, 50); |
214 aura::test::TestWindowDelegate delegate; | 214 aura::test::TestWindowDelegate delegate; |
215 std::unique_ptr<aura::Window> window( | 215 std::unique_ptr<aura::Window> window( |
216 CreateTestWindow(&delegate, restored_bounds)); | 216 CreateTestWindow(&delegate, restored_bounds)); |
217 | 217 |
218 gfx::Rect work_area_in_screen = display::Screen::GetScreen() | 218 gfx::Rect work_area_in_screen = display::Screen::GetScreen() |
219 ->GetDisplayNearestWindow(window.get()) | 219 ->GetDisplayNearestWindow(window.get()) |
220 .work_area(); | 220 .work_area(); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 generator.GestureTapAt(gfx::Point(25, 25)); | 319 generator.GestureTapAt(gfx::Point(25, 25)); |
320 generator.GestureTapAt(gfx::Point(25, 25)); | 320 generator.GestureTapAt(gfx::Point(25, 25)); |
321 RunAllPendingInMessageLoop(); | 321 RunAllPendingInMessageLoop(); |
322 EXPECT_EQ("10,20 30x40", window->bounds().ToString()); | 322 EXPECT_EQ("10,20 30x40", window->bounds().ToString()); |
323 EXPECT_FALSE(window_state->IsMaximized()); | 323 EXPECT_FALSE(window_state->IsMaximized()); |
324 } | 324 } |
325 | 325 |
326 // Test the behavior as a result of double clicking the window header. | 326 // Test the behavior as a result of double clicking the window header. |
327 TEST_F(WorkspaceEventHandlerTest, DoubleClickCaptionTogglesMaximize) { | 327 TEST_F(WorkspaceEventHandlerTest, DoubleClickCaptionTogglesMaximize) { |
328 // TODO: investigate failure. http://crbug.com/699175. | 328 // TODO: investigate failure. http://crbug.com/699175. |
329 if (WmShell::Get()->IsRunningInMash()) | 329 if (ShellPort::Get()->IsRunningInMash()) |
330 return; | 330 return; |
331 | 331 |
332 aura::test::TestWindowDelegate delegate; | 332 aura::test::TestWindowDelegate delegate; |
333 std::unique_ptr<aura::Window> window( | 333 std::unique_ptr<aura::Window> window( |
334 CreateTestWindow(&delegate, gfx::Rect(1, 2, 30, 40))); | 334 CreateTestWindow(&delegate, gfx::Rect(1, 2, 30, 40))); |
335 window->SetProperty(aura::client::kResizeBehaviorKey, | 335 window->SetProperty(aura::client::kResizeBehaviorKey, |
336 ui::mojom::kResizeBehaviorCanMaximize); | 336 ui::mojom::kResizeBehaviorCanMaximize); |
337 | 337 |
338 wm::WindowState* window_state = wm::GetWindowState(window.get()); | 338 wm::WindowState* window_state = wm::GetWindowState(window.get()); |
339 gfx::Rect restore_bounds = window->bounds(); | 339 gfx::Rect restore_bounds = window->bounds(); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 ClickButtonWithFlags(&generator, ui::EF_MIDDLE_MOUSE_BUTTON, | 402 ClickButtonWithFlags(&generator, ui::EF_MIDDLE_MOUSE_BUTTON, |
403 ui::EF_IS_DOUBLE_CLICK); | 403 ui::EF_IS_DOUBLE_CLICK); |
404 | 404 |
405 EXPECT_FALSE(wm::GetWindowState(window.get())->IsMaximized()); | 405 EXPECT_FALSE(wm::GetWindowState(window.get())->IsMaximized()); |
406 EXPECT_EQ("1,2 30x40", window->bounds().ToString()); | 406 EXPECT_EQ("1,2 30x40", window->bounds().ToString()); |
407 EXPECT_FALSE(observer.DidPropertyChange(aura::client::kShowStateKey)); | 407 EXPECT_FALSE(observer.DidPropertyChange(aura::client::kShowStateKey)); |
408 } | 408 } |
409 | 409 |
410 TEST_F(WorkspaceEventHandlerTest, DoubleTapCaptionTogglesMaximize) { | 410 TEST_F(WorkspaceEventHandlerTest, DoubleTapCaptionTogglesMaximize) { |
411 // TODO: investigate failure. http://crbug.com/699175. | 411 // TODO: investigate failure. http://crbug.com/699175. |
412 if (WmShell::Get()->IsRunningInMash()) | 412 if (ShellPort::Get()->IsRunningInMash()) |
413 return; | 413 return; |
414 | 414 |
415 aura::test::TestWindowDelegate delegate; | 415 aura::test::TestWindowDelegate delegate; |
416 gfx::Rect bounds(10, 20, 30, 40); | 416 gfx::Rect bounds(10, 20, 30, 40); |
417 std::unique_ptr<aura::Window> window(CreateTestWindow(&delegate, bounds)); | 417 std::unique_ptr<aura::Window> window(CreateTestWindow(&delegate, bounds)); |
418 window->SetProperty(aura::client::kResizeBehaviorKey, | 418 window->SetProperty(aura::client::kResizeBehaviorKey, |
419 ui::mojom::kResizeBehaviorCanMaximize); | 419 ui::mojom::kResizeBehaviorCanMaximize); |
420 delegate.set_window_component(HTCAPTION); | 420 delegate.set_window_component(HTCAPTION); |
421 | 421 |
422 wm::WindowState* window_state = wm::GetWindowState(window.get()); | 422 wm::WindowState* window_state = wm::GetWindowState(window.get()); |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
544 delegate.set_window_component(HTCAPTION); | 544 delegate.set_window_component(HTCAPTION); |
545 generator.PressRightButton(); | 545 generator.PressRightButton(); |
546 generator.ReleaseRightButton(); | 546 generator.ReleaseRightButton(); |
547 EXPECT_FALSE(window_state->IsMaximized()); | 547 EXPECT_FALSE(window_state->IsMaximized()); |
548 ClickButtonWithFlags(&generator, ui::EF_LEFT_MOUSE_BUTTON, | 548 ClickButtonWithFlags(&generator, ui::EF_LEFT_MOUSE_BUTTON, |
549 ui::EF_IS_DOUBLE_CLICK); | 549 ui::EF_IS_DOUBLE_CLICK); |
550 EXPECT_FALSE(window_state->IsMaximized()); | 550 EXPECT_FALSE(window_state->IsMaximized()); |
551 } | 551 } |
552 | 552 |
553 } // namespace ash | 553 } // namespace ash |
OLD | NEW |