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

Side by Side Diff: ash/wm/workspace/workspace_event_handler_unittest.cc

Issue 1924703002: Rename gfx::Display/Screen to display::Display/Screen in ash (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months 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
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/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/test/ash_test_base.h" 9 #include "ash/test/ash_test_base.h"
10 #include "ash/wm/common/window_state.h" 10 #include "ash/wm/common/window_state.h"
11 #include "ash/wm/common/wm_event.h" 11 #include "ash/wm/common/wm_event.h"
12 #include "ash/wm/window_state_aura.h" 12 #include "ash/wm/window_state_aura.h"
13 #include "ash/wm/window_util.h" 13 #include "ash/wm/window_util.h"
14 #include "ash/wm/workspace_controller.h" 14 #include "ash/wm/workspace_controller.h"
15 #include "ash/wm/workspace_controller_test_helper.h" 15 #include "ash/wm/workspace_controller_test_helper.h"
16 #include "base/thread_task_runner_handle.h" 16 #include "base/thread_task_runner_handle.h"
17 #include "ui/aura/client/aura_constants.h" 17 #include "ui/aura/client/aura_constants.h"
18 #include "ui/aura/test/test_window_delegate.h" 18 #include "ui/aura/test/test_window_delegate.h"
19 #include "ui/aura/window.h" 19 #include "ui/aura/window.h"
20 #include "ui/aura/window_tree_host.h" 20 #include "ui/aura/window_tree_host.h"
21 #include "ui/base/hit_test.h" 21 #include "ui/base/hit_test.h"
22 #include "ui/display/screen.h"
22 #include "ui/events/event_processor.h" 23 #include "ui/events/event_processor.h"
23 #include "ui/events/event_utils.h" 24 #include "ui/events/event_utils.h"
24 #include "ui/events/test/event_generator.h" 25 #include "ui/events/test/event_generator.h"
25 #include "ui/gfx/screen.h"
26 #include "ui/wm/core/window_util.h" 26 #include "ui/wm/core/window_util.h"
27 #include "ui/wm/public/window_move_client.h" 27 #include "ui/wm/public/window_move_client.h"
28 28
29 #if defined(OS_WIN) 29 #if defined(OS_WIN)
30 #include "base/win/windows_version.h" 30 #include "base/win/windows_version.h"
31 #endif 31 #endif
32 32
33 namespace ash { 33 namespace ash {
34 34
35 namespace { 35 namespace {
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 TEST_F(WorkspaceEventHandlerTest, DoubleClickSingleAxisResizeEdge) { 102 TEST_F(WorkspaceEventHandlerTest, DoubleClickSingleAxisResizeEdge) {
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());
111 111
112 gfx::Rect work_area = gfx::Screen::GetScreen() 112 gfx::Rect work_area = display::Screen::GetScreen()
113 ->GetDisplayNearestWindow(window.get()) 113 ->GetDisplayNearestWindow(window.get())
114 .work_area(); 114 .work_area();
115 115
116 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), 116 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
117 window.get()); 117 window.get());
118 118
119 // Double-click the top resize edge. 119 // Double-click the top resize edge.
120 delegate.set_window_component(HTTOP); 120 delegate.set_window_component(HTTOP);
121 // On X a double click actually generates a drag between each press/release. 121 // On X a double click actually generates a drag between each press/release.
122 // Explicitly trigger this path since we had bugs in dealing with it 122 // Explicitly trigger this path since we had bugs in dealing with it
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 EXPECT_EQ(restored_bounds.ToString(), window->GetBoundsInScreen().ToString()); 210 EXPECT_EQ(restored_bounds.ToString(), window->GetBoundsInScreen().ToString());
211 } 211 }
212 212
213 // Tests the behavior when double clicking the border of a side snapped window. 213 // Tests the behavior when double clicking the border of a side snapped window.
214 TEST_F(WorkspaceEventHandlerTest, DoubleClickSingleAxisWhenSideSnapped) { 214 TEST_F(WorkspaceEventHandlerTest, DoubleClickSingleAxisWhenSideSnapped) {
215 gfx::Rect restored_bounds(10, 10, 50, 50); 215 gfx::Rect restored_bounds(10, 10, 50, 50);
216 aura::test::TestWindowDelegate delegate; 216 aura::test::TestWindowDelegate delegate;
217 std::unique_ptr<aura::Window> window( 217 std::unique_ptr<aura::Window> window(
218 CreateTestWindow(&delegate, restored_bounds)); 218 CreateTestWindow(&delegate, restored_bounds));
219 219
220 gfx::Rect work_area_in_screen = gfx::Screen::GetScreen() 220 gfx::Rect work_area_in_screen = display::Screen::GetScreen()
221 ->GetDisplayNearestWindow(window.get()) 221 ->GetDisplayNearestWindow(window.get())
222 .work_area(); 222 .work_area();
223 223
224 wm::WindowState* window_state = wm::GetWindowState(window.get()); 224 wm::WindowState* window_state = wm::GetWindowState(window.get());
225 const wm::WMEvent snap_event(wm::WM_EVENT_SNAP_LEFT); 225 const wm::WMEvent snap_event(wm::WM_EVENT_SNAP_LEFT);
226 window_state->OnWMEvent(&snap_event); 226 window_state->OnWMEvent(&snap_event);
227 227
228 gfx::Rect snapped_bounds_in_screen = window->GetBoundsInScreen(); 228 gfx::Rect snapped_bounds_in_screen = window->GetBoundsInScreen();
229 EXPECT_EQ(work_area_in_screen.x(), snapped_bounds_in_screen.x()); 229 EXPECT_EQ(work_area_in_screen.x(), snapped_bounds_in_screen.x());
230 EXPECT_EQ(work_area_in_screen.y(), snapped_bounds_in_screen.y()); 230 EXPECT_EQ(work_area_in_screen.y(), snapped_bounds_in_screen.y());
(...skipping 22 matching lines...) Expand all
253 253
254 TEST_F(WorkspaceEventHandlerTest, 254 TEST_F(WorkspaceEventHandlerTest,
255 DoubleClickSingleAxisDoesntResizeVerticalEdgeIfConstrained) { 255 DoubleClickSingleAxisDoesntResizeVerticalEdgeIfConstrained) {
256 gfx::Rect restored_bounds(10, 10, 50, 50); 256 gfx::Rect restored_bounds(10, 10, 50, 50);
257 aura::test::TestWindowDelegate delegate; 257 aura::test::TestWindowDelegate delegate;
258 std::unique_ptr<aura::Window> window( 258 std::unique_ptr<aura::Window> window(
259 CreateTestWindow(&delegate, restored_bounds)); 259 CreateTestWindow(&delegate, restored_bounds));
260 260
261 wm::ActivateWindow(window.get()); 261 wm::ActivateWindow(window.get());
262 262
263 gfx::Rect work_area = gfx::Screen::GetScreen() 263 gfx::Rect work_area = display::Screen::GetScreen()
264 ->GetDisplayNearestWindow(window.get()) 264 ->GetDisplayNearestWindow(window.get())
265 .work_area(); 265 .work_area();
266 266
267 delegate.set_maximum_size(gfx::Size(0, 100)); 267 delegate.set_maximum_size(gfx::Size(0, 100));
268 268
269 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), 269 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
270 window.get()); 270 window.get());
271 // Double-click the top resize edge. 271 // Double-click the top resize edge.
272 delegate.set_window_component(HTTOP); 272 delegate.set_window_component(HTTOP);
273 generator.DoubleClickLeftButton(); 273 generator.DoubleClickLeftButton();
274 274
275 // The size of the window should be unchanged. 275 // The size of the window should be unchanged.
276 EXPECT_EQ(restored_bounds.y(), window->bounds().y()); 276 EXPECT_EQ(restored_bounds.y(), window->bounds().y());
277 EXPECT_EQ(restored_bounds.height(), window->bounds().height()); 277 EXPECT_EQ(restored_bounds.height(), window->bounds().height());
278 } 278 }
279 279
280 TEST_F(WorkspaceEventHandlerTest, 280 TEST_F(WorkspaceEventHandlerTest,
281 DoubleClickSingleAxisDoesntResizeHorizontalEdgeIfConstrained) { 281 DoubleClickSingleAxisDoesntResizeHorizontalEdgeIfConstrained) {
282 gfx::Rect restored_bounds(10, 10, 50, 50); 282 gfx::Rect restored_bounds(10, 10, 50, 50);
283 aura::test::TestWindowDelegate delegate; 283 aura::test::TestWindowDelegate delegate;
284 std::unique_ptr<aura::Window> window( 284 std::unique_ptr<aura::Window> window(
285 CreateTestWindow(&delegate, restored_bounds)); 285 CreateTestWindow(&delegate, restored_bounds));
286 286
287 wm::ActivateWindow(window.get()); 287 wm::ActivateWindow(window.get());
288 288
289 gfx::Rect work_area = gfx::Screen::GetScreen() 289 gfx::Rect work_area = display::Screen::GetScreen()
290 ->GetDisplayNearestWindow(window.get()) 290 ->GetDisplayNearestWindow(window.get())
291 .work_area(); 291 .work_area();
292 292
293 delegate.set_maximum_size(gfx::Size(100, 0)); 293 delegate.set_maximum_size(gfx::Size(100, 0));
294 294
295 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), 295 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
296 window.get()); 296 window.get());
297 // Double-click the top resize edge. 297 // Double-click the top resize edge.
298 delegate.set_window_component(HTRIGHT); 298 delegate.set_window_component(HTRIGHT);
299 generator.DoubleClickLeftButton(); 299 generator.DoubleClickLeftButton();
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 delegate.set_window_component(HTCAPTION); 553 delegate.set_window_component(HTCAPTION);
554 generator.PressRightButton(); 554 generator.PressRightButton();
555 generator.ReleaseRightButton(); 555 generator.ReleaseRightButton();
556 EXPECT_FALSE(window_state->IsMaximized()); 556 EXPECT_FALSE(window_state->IsMaximized());
557 ClickButtonWithFlags(&generator, ui::EF_LEFT_MOUSE_BUTTON, 557 ClickButtonWithFlags(&generator, ui::EF_LEFT_MOUSE_BUTTON,
558 ui::EF_IS_DOUBLE_CLICK); 558 ui::EF_IS_DOUBLE_CLICK);
559 EXPECT_FALSE(window_state->IsMaximized()); 559 EXPECT_FALSE(window_state->IsMaximized());
560 } 560 }
561 561
562 } // namespace ash 562 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/workspace/multi_window_resize_controller_unittest.cc ('k') | ash/wm/workspace/workspace_layout_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698