| 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/test/ash_test_base.h" | 9 #include "ash/test/ash_test_base.h" |
| 10 #include "ash/wm/window_state.h" | 10 #include "ash/wm/window_state.h" |
| 11 #include "ash/wm/window_util.h" | 11 #include "ash/wm/window_util.h" |
| 12 #include "ash/wm/wm_event.h" | 12 #include "ash/wm/wm_event.h" |
| 13 #include "ash/wm/workspace_controller.h" | 13 #include "ash/wm/workspace_controller.h" |
| 14 #include "ash/wm/workspace_controller_test_helper.h" | 14 #include "ash/wm/workspace_controller_test_helper.h" |
| 15 #include "ui/aura/client/aura_constants.h" | 15 #include "ui/aura/client/aura_constants.h" |
| 16 #include "ui/aura/test/event_generator.h" | |
| 17 #include "ui/aura/test/test_window_delegate.h" | 16 #include "ui/aura/test/test_window_delegate.h" |
| 18 #include "ui/aura/window.h" | 17 #include "ui/aura/window.h" |
| 19 #include "ui/aura/window_tree_host.h" | 18 #include "ui/aura/window_tree_host.h" |
| 20 #include "ui/base/hit_test.h" | 19 #include "ui/base/hit_test.h" |
| 21 #include "ui/events/event_processor.h" | 20 #include "ui/events/event_processor.h" |
| 21 #include "ui/events/test/event_generator.h" |
| 22 #include "ui/gfx/screen.h" | 22 #include "ui/gfx/screen.h" |
| 23 #include "ui/wm/core/window_util.h" | 23 #include "ui/wm/core/window_util.h" |
| 24 #include "ui/wm/public/window_move_client.h" | 24 #include "ui/wm/public/window_move_client.h" |
| 25 | 25 |
| 26 #if defined(OS_WIN) | 26 #if defined(OS_WIN) |
| 27 #include "base/win/windows_version.h" | 27 #include "base/win/windows_version.h" |
| 28 #endif | 28 #endif |
| 29 | 29 |
| 30 namespace ash { | 30 namespace ash { |
| 31 | 31 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 // vertically. | 86 // vertically. |
| 87 gfx::Rect restored_bounds(10, 10, 50, 50); | 87 gfx::Rect restored_bounds(10, 10, 50, 50); |
| 88 aura::test::TestWindowDelegate delegate; | 88 aura::test::TestWindowDelegate delegate; |
| 89 scoped_ptr<aura::Window> window(CreateTestWindow(&delegate, restored_bounds)); | 89 scoped_ptr<aura::Window> window(CreateTestWindow(&delegate, restored_bounds)); |
| 90 | 90 |
| 91 wm::ActivateWindow(window.get()); | 91 wm::ActivateWindow(window.get()); |
| 92 | 92 |
| 93 gfx::Rect work_area = Shell::GetScreen()->GetDisplayNearestWindow( | 93 gfx::Rect work_area = Shell::GetScreen()->GetDisplayNearestWindow( |
| 94 window.get()).work_area(); | 94 window.get()).work_area(); |
| 95 | 95 |
| 96 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), | 96 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), |
| 97 window.get()); | 97 window.get()); |
| 98 | 98 |
| 99 // Double-click the top resize edge. | 99 // Double-click the top resize edge. |
| 100 delegate.set_window_component(HTTOP); | 100 delegate.set_window_component(HTTOP); |
| 101 // On X a double click actually generates a drag between each press/release. | 101 // On X a double click actually generates a drag between each press/release. |
| 102 // Explicitly trigger this path since we had bugs in dealing with it | 102 // Explicitly trigger this path since we had bugs in dealing with it |
| 103 // correctly. | 103 // correctly. |
| 104 generator.PressLeftButton(); | 104 generator.PressLeftButton(); |
| 105 generator.ReleaseLeftButton(); | 105 generator.ReleaseLeftButton(); |
| 106 generator.set_flags(ui::EF_IS_DOUBLE_CLICK); | 106 generator.set_flags(ui::EF_IS_DOUBLE_CLICK); |
| 107 generator.PressLeftButton(); | 107 generator.PressLeftButton(); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 return; | 146 return; |
| 147 #endif | 147 #endif |
| 148 | 148 |
| 149 // Verify the double clicking the resize edge works on 2nd display too. | 149 // Verify the double clicking the resize edge works on 2nd display too. |
| 150 UpdateDisplay("200x200,400x300"); | 150 UpdateDisplay("200x200,400x300"); |
| 151 gfx::Rect work_area2 = ScreenUtil::GetSecondaryDisplay().work_area(); | 151 gfx::Rect work_area2 = ScreenUtil::GetSecondaryDisplay().work_area(); |
| 152 restored_bounds.SetRect(220, 20, 50, 50); | 152 restored_bounds.SetRect(220, 20, 50, 50); |
| 153 window->SetBoundsInScreen(restored_bounds, ScreenUtil::GetSecondaryDisplay()); | 153 window->SetBoundsInScreen(restored_bounds, ScreenUtil::GetSecondaryDisplay()); |
| 154 aura::Window* second_root = Shell::GetAllRootWindows()[1]; | 154 aura::Window* second_root = Shell::GetAllRootWindows()[1]; |
| 155 EXPECT_EQ(second_root, window->GetRootWindow()); | 155 EXPECT_EQ(second_root, window->GetRootWindow()); |
| 156 aura::test::EventGenerator generator2(second_root, window.get()); | 156 ui::test::EventGenerator generator2(second_root, window.get()); |
| 157 | 157 |
| 158 // Y-axis maximization. | 158 // Y-axis maximization. |
| 159 delegate.set_window_component(HTTOP); | 159 delegate.set_window_component(HTTOP); |
| 160 generator2.PressLeftButton(); | 160 generator2.PressLeftButton(); |
| 161 generator2.ReleaseLeftButton(); | 161 generator2.ReleaseLeftButton(); |
| 162 generator2.set_flags(ui::EF_IS_DOUBLE_CLICK); | 162 generator2.set_flags(ui::EF_IS_DOUBLE_CLICK); |
| 163 generator2.PressLeftButton(); | 163 generator2.PressLeftButton(); |
| 164 generator2.MoveMouseTo(generator.current_location(), 1); | 164 generator2.MoveMouseTo(generator.current_location(), 1); |
| 165 generator2.ReleaseLeftButton(); | 165 generator2.ReleaseLeftButton(); |
| 166 generator.DoubleClickLeftButton(); | 166 generator.DoubleClickLeftButton(); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 | 205 |
| 206 gfx::Rect snapped_bounds_in_screen = window->GetBoundsInScreen(); | 206 gfx::Rect snapped_bounds_in_screen = window->GetBoundsInScreen(); |
| 207 EXPECT_EQ(work_area_in_screen.x(), snapped_bounds_in_screen.x()); | 207 EXPECT_EQ(work_area_in_screen.x(), snapped_bounds_in_screen.x()); |
| 208 EXPECT_EQ(work_area_in_screen.y(), snapped_bounds_in_screen.y()); | 208 EXPECT_EQ(work_area_in_screen.y(), snapped_bounds_in_screen.y()); |
| 209 EXPECT_GT(work_area_in_screen.width(), snapped_bounds_in_screen.width()); | 209 EXPECT_GT(work_area_in_screen.width(), snapped_bounds_in_screen.width()); |
| 210 EXPECT_EQ(work_area_in_screen.height(), snapped_bounds_in_screen.height()); | 210 EXPECT_EQ(work_area_in_screen.height(), snapped_bounds_in_screen.height()); |
| 211 | 211 |
| 212 // Double clicking the top border should not do anything for side snapped | 212 // Double clicking the top border should not do anything for side snapped |
| 213 // windows. (They already take up the entire workspace height and reverting | 213 // windows. (They already take up the entire workspace height and reverting |
| 214 // to the restored bounds would be weird). | 214 // to the restored bounds would be weird). |
| 215 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), | 215 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), |
| 216 window.get()); | 216 window.get()); |
| 217 delegate.set_window_component(HTTOP); | 217 delegate.set_window_component(HTTOP); |
| 218 generator.DoubleClickLeftButton(); | 218 generator.DoubleClickLeftButton(); |
| 219 EXPECT_EQ(wm::WINDOW_STATE_TYPE_LEFT_SNAPPED, window_state->GetStateType()); | 219 EXPECT_EQ(wm::WINDOW_STATE_TYPE_LEFT_SNAPPED, window_state->GetStateType()); |
| 220 EXPECT_EQ(snapped_bounds_in_screen.ToString(), | 220 EXPECT_EQ(snapped_bounds_in_screen.ToString(), |
| 221 window->GetBoundsInScreen().ToString()); | 221 window->GetBoundsInScreen().ToString()); |
| 222 | 222 |
| 223 // Double clicking the right border should exit the side snapped state and | 223 // Double clicking the right border should exit the side snapped state and |
| 224 // make the window take up the entire work area. | 224 // make the window take up the entire work area. |
| 225 delegate.set_window_component(HTRIGHT); | 225 delegate.set_window_component(HTRIGHT); |
| 226 generator.DoubleClickLeftButton(); | 226 generator.DoubleClickLeftButton(); |
| 227 EXPECT_TRUE(window_state->IsNormalStateType()); | 227 EXPECT_TRUE(window_state->IsNormalStateType()); |
| 228 EXPECT_EQ(work_area_in_screen.ToString(), | 228 EXPECT_EQ(work_area_in_screen.ToString(), |
| 229 window->GetBoundsInScreen().ToString()); | 229 window->GetBoundsInScreen().ToString()); |
| 230 } | 230 } |
| 231 | 231 |
| 232 TEST_F(WorkspaceEventHandlerTest, | 232 TEST_F(WorkspaceEventHandlerTest, |
| 233 DoubleClickSingleAxisDoesntResizeVerticalEdgeIfConstrained) { | 233 DoubleClickSingleAxisDoesntResizeVerticalEdgeIfConstrained) { |
| 234 gfx::Rect restored_bounds(10, 10, 50, 50); | 234 gfx::Rect restored_bounds(10, 10, 50, 50); |
| 235 aura::test::TestWindowDelegate delegate; | 235 aura::test::TestWindowDelegate delegate; |
| 236 scoped_ptr<aura::Window> window(CreateTestWindow(&delegate, restored_bounds)); | 236 scoped_ptr<aura::Window> window(CreateTestWindow(&delegate, restored_bounds)); |
| 237 | 237 |
| 238 wm::ActivateWindow(window.get()); | 238 wm::ActivateWindow(window.get()); |
| 239 | 239 |
| 240 gfx::Rect work_area = Shell::GetScreen()->GetDisplayNearestWindow( | 240 gfx::Rect work_area = Shell::GetScreen()->GetDisplayNearestWindow( |
| 241 window.get()).work_area(); | 241 window.get()).work_area(); |
| 242 | 242 |
| 243 delegate.set_maximum_size(gfx::Size(0, 100)); | 243 delegate.set_maximum_size(gfx::Size(0, 100)); |
| 244 | 244 |
| 245 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), | 245 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), |
| 246 window.get()); | 246 window.get()); |
| 247 // Double-click the top resize edge. | 247 // Double-click the top resize edge. |
| 248 delegate.set_window_component(HTTOP); | 248 delegate.set_window_component(HTTOP); |
| 249 generator.DoubleClickLeftButton(); | 249 generator.DoubleClickLeftButton(); |
| 250 | 250 |
| 251 // The size of the window should be unchanged. | 251 // The size of the window should be unchanged. |
| 252 EXPECT_EQ(restored_bounds.y(), window->bounds().y()); | 252 EXPECT_EQ(restored_bounds.y(), window->bounds().y()); |
| 253 EXPECT_EQ(restored_bounds.height(), window->bounds().height()); | 253 EXPECT_EQ(restored_bounds.height(), window->bounds().height()); |
| 254 } | 254 } |
| 255 | 255 |
| 256 TEST_F(WorkspaceEventHandlerTest, | 256 TEST_F(WorkspaceEventHandlerTest, |
| 257 DoubleClickSingleAxisDoesntResizeHorizontalEdgeIfConstrained) { | 257 DoubleClickSingleAxisDoesntResizeHorizontalEdgeIfConstrained) { |
| 258 gfx::Rect restored_bounds(10, 10, 50, 50); | 258 gfx::Rect restored_bounds(10, 10, 50, 50); |
| 259 aura::test::TestWindowDelegate delegate; | 259 aura::test::TestWindowDelegate delegate; |
| 260 scoped_ptr<aura::Window> window(CreateTestWindow(&delegate, restored_bounds)); | 260 scoped_ptr<aura::Window> window(CreateTestWindow(&delegate, restored_bounds)); |
| 261 | 261 |
| 262 wm::ActivateWindow(window.get()); | 262 wm::ActivateWindow(window.get()); |
| 263 | 263 |
| 264 gfx::Rect work_area = Shell::GetScreen()->GetDisplayNearestWindow( | 264 gfx::Rect work_area = Shell::GetScreen()->GetDisplayNearestWindow( |
| 265 window.get()).work_area(); | 265 window.get()).work_area(); |
| 266 | 266 |
| 267 delegate.set_maximum_size(gfx::Size(100, 0)); | 267 delegate.set_maximum_size(gfx::Size(100, 0)); |
| 268 | 268 |
| 269 aura::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(HTRIGHT); | 272 delegate.set_window_component(HTRIGHT); |
| 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.x(), window->bounds().x()); | 276 EXPECT_EQ(restored_bounds.x(), window->bounds().x()); |
| 277 EXPECT_EQ(restored_bounds.width(), window->bounds().width()); | 277 EXPECT_EQ(restored_bounds.width(), window->bounds().width()); |
| 278 } | 278 } |
| 279 | 279 |
| 280 TEST_F(WorkspaceEventHandlerTest, | 280 TEST_F(WorkspaceEventHandlerTest, |
| 281 DoubleClickOrTapWithModalChildDoesntMaximize) { | 281 DoubleClickOrTapWithModalChildDoesntMaximize) { |
| 282 aura::test::TestWindowDelegate delegate1; | 282 aura::test::TestWindowDelegate delegate1; |
| 283 aura::test::TestWindowDelegate delegate2; | 283 aura::test::TestWindowDelegate delegate2; |
| 284 scoped_ptr<aura::Window> window( | 284 scoped_ptr<aura::Window> window( |
| 285 CreateTestWindow(&delegate1, gfx::Rect(10, 20, 30, 40))); | 285 CreateTestWindow(&delegate1, gfx::Rect(10, 20, 30, 40))); |
| 286 scoped_ptr<aura::Window> child( | 286 scoped_ptr<aura::Window> child( |
| 287 CreateTestWindow(&delegate2, gfx::Rect(0, 0, 1, 1))); | 287 CreateTestWindow(&delegate2, gfx::Rect(0, 0, 1, 1))); |
| 288 window->SetProperty(aura::client::kCanMaximizeKey, true); | 288 window->SetProperty(aura::client::kCanMaximizeKey, true); |
| 289 delegate1.set_window_component(HTCAPTION); | 289 delegate1.set_window_component(HTCAPTION); |
| 290 | 290 |
| 291 child->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_WINDOW); | 291 child->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_WINDOW); |
| 292 ::wm::AddTransientChild(window.get(), child.get()); | 292 ::wm::AddTransientChild(window.get(), child.get()); |
| 293 | 293 |
| 294 wm::WindowState* window_state = wm::GetWindowState(window.get()); | 294 wm::WindowState* window_state = wm::GetWindowState(window.get()); |
| 295 EXPECT_FALSE(window_state->IsMaximized()); | 295 EXPECT_FALSE(window_state->IsMaximized()); |
| 296 aura::Window* root = Shell::GetPrimaryRootWindow(); | 296 aura::Window* root = Shell::GetPrimaryRootWindow(); |
| 297 aura::test::EventGenerator generator(root, window.get()); | 297 ui::test::EventGenerator generator(root, window.get()); |
| 298 generator.DoubleClickLeftButton(); | 298 generator.DoubleClickLeftButton(); |
| 299 EXPECT_EQ("10,20 30x40", window->bounds().ToString()); | 299 EXPECT_EQ("10,20 30x40", window->bounds().ToString()); |
| 300 EXPECT_FALSE(window_state->IsMaximized()); | 300 EXPECT_FALSE(window_state->IsMaximized()); |
| 301 | 301 |
| 302 generator.GestureTapAt(gfx::Point(25, 25)); | 302 generator.GestureTapAt(gfx::Point(25, 25)); |
| 303 generator.GestureTapAt(gfx::Point(25, 25)); | 303 generator.GestureTapAt(gfx::Point(25, 25)); |
| 304 RunAllPendingInMessageLoop(); | 304 RunAllPendingInMessageLoop(); |
| 305 EXPECT_EQ("10,20 30x40", window->bounds().ToString()); | 305 EXPECT_EQ("10,20 30x40", window->bounds().ToString()); |
| 306 EXPECT_FALSE(window_state->IsMaximized()); | 306 EXPECT_FALSE(window_state->IsMaximized()); |
| 307 } | 307 } |
| 308 | 308 |
| 309 // Test the behavior as a result of double clicking the window header. | 309 // Test the behavior as a result of double clicking the window header. |
| 310 TEST_F(WorkspaceEventHandlerTest, DoubleClickCaptionTogglesMaximize) { | 310 TEST_F(WorkspaceEventHandlerTest, DoubleClickCaptionTogglesMaximize) { |
| 311 aura::test::TestWindowDelegate delegate; | 311 aura::test::TestWindowDelegate delegate; |
| 312 scoped_ptr<aura::Window> window( | 312 scoped_ptr<aura::Window> window( |
| 313 CreateTestWindow(&delegate, gfx::Rect(1, 2, 30, 40))); | 313 CreateTestWindow(&delegate, gfx::Rect(1, 2, 30, 40))); |
| 314 window->SetProperty(aura::client::kCanMaximizeKey, true); | 314 window->SetProperty(aura::client::kCanMaximizeKey, true); |
| 315 | 315 |
| 316 wm::WindowState* window_state = wm::GetWindowState(window.get()); | 316 wm::WindowState* window_state = wm::GetWindowState(window.get()); |
| 317 gfx::Rect restore_bounds = window->bounds(); | 317 gfx::Rect restore_bounds = window->bounds(); |
| 318 gfx::Rect work_area_in_parent = ScreenUtil::GetDisplayWorkAreaBoundsInParent( | 318 gfx::Rect work_area_in_parent = ScreenUtil::GetDisplayWorkAreaBoundsInParent( |
| 319 window.get()); | 319 window.get()); |
| 320 | 320 |
| 321 EXPECT_FALSE(window_state->IsMaximized()); | 321 EXPECT_FALSE(window_state->IsMaximized()); |
| 322 | 322 |
| 323 // 1) Double clicking a normal window should maximize. | 323 // 1) Double clicking a normal window should maximize. |
| 324 delegate.set_window_component(HTCAPTION); | 324 delegate.set_window_component(HTCAPTION); |
| 325 aura::Window* root = Shell::GetPrimaryRootWindow(); | 325 aura::Window* root = Shell::GetPrimaryRootWindow(); |
| 326 aura::test::EventGenerator generator(root, window.get()); | 326 ui::test::EventGenerator generator(root, window.get()); |
| 327 generator.ClickLeftButton(); | 327 generator.ClickLeftButton(); |
| 328 generator.DoubleClickLeftButton(); | 328 generator.DoubleClickLeftButton(); |
| 329 EXPECT_NE(restore_bounds.ToString(), window->bounds().ToString()); | 329 EXPECT_NE(restore_bounds.ToString(), window->bounds().ToString()); |
| 330 EXPECT_TRUE(window_state->IsMaximized()); | 330 EXPECT_TRUE(window_state->IsMaximized()); |
| 331 | 331 |
| 332 generator.ClickLeftButton(); | 332 generator.ClickLeftButton(); |
| 333 generator.DoubleClickLeftButton(); | 333 generator.DoubleClickLeftButton(); |
| 334 EXPECT_TRUE(window_state->IsNormalStateType()); | 334 EXPECT_TRUE(window_state->IsNormalStateType()); |
| 335 EXPECT_EQ(restore_bounds.ToString(), window->bounds().ToString()); | 335 EXPECT_EQ(restore_bounds.ToString(), window->bounds().ToString()); |
| 336 | 336 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 // Test that double clicking the middle button on the window header does not | 372 // Test that double clicking the middle button on the window header does not |
| 373 // toggle the maximized state. | 373 // toggle the maximized state. |
| 374 TEST_F(WorkspaceEventHandlerTest, | 374 TEST_F(WorkspaceEventHandlerTest, |
| 375 DoubleClickMiddleButtonDoesNotToggleMaximize) { | 375 DoubleClickMiddleButtonDoesNotToggleMaximize) { |
| 376 aura::test::TestWindowDelegate delegate; | 376 aura::test::TestWindowDelegate delegate; |
| 377 scoped_ptr<aura::Window> window( | 377 scoped_ptr<aura::Window> window( |
| 378 CreateTestWindow(&delegate, gfx::Rect(1, 2, 30, 40))); | 378 CreateTestWindow(&delegate, gfx::Rect(1, 2, 30, 40))); |
| 379 window->SetProperty(aura::client::kCanMaximizeKey, true); | 379 window->SetProperty(aura::client::kCanMaximizeKey, true); |
| 380 delegate.set_window_component(HTCAPTION); | 380 delegate.set_window_component(HTCAPTION); |
| 381 aura::Window* root = Shell::GetPrimaryRootWindow(); | 381 aura::Window* root = Shell::GetPrimaryRootWindow(); |
| 382 aura::test::EventGenerator generator(root, window.get()); | 382 ui::test::EventGenerator generator(root, window.get()); |
| 383 | 383 |
| 384 WindowPropertyObserver observer(window.get()); | 384 WindowPropertyObserver observer(window.get()); |
| 385 ui::MouseEvent press(ui::ET_MOUSE_PRESSED, generator.current_location(), | 385 ui::MouseEvent press(ui::ET_MOUSE_PRESSED, generator.current_location(), |
| 386 generator.current_location(), | 386 generator.current_location(), |
| 387 ui::EF_MIDDLE_MOUSE_BUTTON | ui::EF_IS_DOUBLE_CLICK, | 387 ui::EF_MIDDLE_MOUSE_BUTTON | ui::EF_IS_DOUBLE_CLICK, |
| 388 ui::EF_MIDDLE_MOUSE_BUTTON); | 388 ui::EF_MIDDLE_MOUSE_BUTTON); |
| 389 ui::EventProcessor* dispatcher = root->GetHost()->event_processor(); | 389 ui::EventProcessor* dispatcher = root->GetHost()->event_processor(); |
| 390 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&press); | 390 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&press); |
| 391 ASSERT_FALSE(details.dispatcher_destroyed); | 391 ASSERT_FALSE(details.dispatcher_destroyed); |
| 392 ui::MouseEvent release(ui::ET_MOUSE_RELEASED, generator.current_location(), | 392 ui::MouseEvent release(ui::ET_MOUSE_RELEASED, generator.current_location(), |
| (...skipping 10 matching lines...) Expand all Loading... |
| 403 | 403 |
| 404 TEST_F(WorkspaceEventHandlerTest, DoubleTapCaptionTogglesMaximize) { | 404 TEST_F(WorkspaceEventHandlerTest, DoubleTapCaptionTogglesMaximize) { |
| 405 aura::test::TestWindowDelegate delegate; | 405 aura::test::TestWindowDelegate delegate; |
| 406 gfx::Rect bounds(10, 20, 30, 40); | 406 gfx::Rect bounds(10, 20, 30, 40); |
| 407 scoped_ptr<aura::Window> window(CreateTestWindow(&delegate, bounds)); | 407 scoped_ptr<aura::Window> window(CreateTestWindow(&delegate, bounds)); |
| 408 window->SetProperty(aura::client::kCanMaximizeKey, true); | 408 window->SetProperty(aura::client::kCanMaximizeKey, true); |
| 409 delegate.set_window_component(HTCAPTION); | 409 delegate.set_window_component(HTCAPTION); |
| 410 | 410 |
| 411 wm::WindowState* window_state = wm::GetWindowState(window.get()); | 411 wm::WindowState* window_state = wm::GetWindowState(window.get()); |
| 412 EXPECT_FALSE(window_state->IsMaximized()); | 412 EXPECT_FALSE(window_state->IsMaximized()); |
| 413 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), | 413 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), |
| 414 window.get()); | 414 window.get()); |
| 415 generator.GestureTapAt(gfx::Point(25, 25)); | 415 generator.GestureTapAt(gfx::Point(25, 25)); |
| 416 generator.GestureTapAt(gfx::Point(25, 25)); | 416 generator.GestureTapAt(gfx::Point(25, 25)); |
| 417 RunAllPendingInMessageLoop(); | 417 RunAllPendingInMessageLoop(); |
| 418 EXPECT_NE(bounds.ToString(), window->bounds().ToString()); | 418 EXPECT_NE(bounds.ToString(), window->bounds().ToString()); |
| 419 EXPECT_TRUE(window_state->IsMaximized()); | 419 EXPECT_TRUE(window_state->IsMaximized()); |
| 420 | 420 |
| 421 generator.GestureTapAt(gfx::Point(5, 5)); | 421 generator.GestureTapAt(gfx::Point(5, 5)); |
| 422 generator.GestureTapAt(gfx::Point(10, 10)); | 422 generator.GestureTapAt(gfx::Point(10, 10)); |
| 423 | 423 |
| 424 EXPECT_FALSE(window_state->IsMaximized()); | 424 EXPECT_FALSE(window_state->IsMaximized()); |
| 425 EXPECT_EQ(bounds.ToString(), window->bounds().ToString()); | 425 EXPECT_EQ(bounds.ToString(), window->bounds().ToString()); |
| 426 } | 426 } |
| 427 | 427 |
| 428 // Verifies deleting the window while dragging doesn't crash. | 428 // Verifies deleting the window while dragging doesn't crash. |
| 429 TEST_F(WorkspaceEventHandlerTest, DeleteWhenDragging) { | 429 TEST_F(WorkspaceEventHandlerTest, DeleteWhenDragging) { |
| 430 // Create a large window in the background. This is necessary so that when we | 430 // Create a large window in the background. This is necessary so that when we |
| 431 // delete |window| WorkspaceEventHandler is still the active event handler. | 431 // delete |window| WorkspaceEventHandler is still the active event handler. |
| 432 aura::test::TestWindowDelegate delegate2; | 432 aura::test::TestWindowDelegate delegate2; |
| 433 scoped_ptr<aura::Window> window2( | 433 scoped_ptr<aura::Window> window2( |
| 434 CreateTestWindow(&delegate2, gfx::Rect(0, 0, 500, 500))); | 434 CreateTestWindow(&delegate2, gfx::Rect(0, 0, 500, 500))); |
| 435 | 435 |
| 436 aura::test::TestWindowDelegate delegate; | 436 aura::test::TestWindowDelegate delegate; |
| 437 const gfx::Rect bounds(10, 20, 30, 40); | 437 const gfx::Rect bounds(10, 20, 30, 40); |
| 438 scoped_ptr<aura::Window> window(CreateTestWindow(&delegate, bounds)); | 438 scoped_ptr<aura::Window> window(CreateTestWindow(&delegate, bounds)); |
| 439 delegate.set_window_component(HTCAPTION); | 439 delegate.set_window_component(HTCAPTION); |
| 440 aura::test::EventGenerator generator(window->GetRootWindow()); | 440 ui::test::EventGenerator generator(window->GetRootWindow()); |
| 441 generator.MoveMouseToCenterOf(window.get()); | 441 generator.MoveMouseToCenterOf(window.get()); |
| 442 generator.PressLeftButton(); | 442 generator.PressLeftButton(); |
| 443 generator.MoveMouseTo(generator.current_location() + gfx::Vector2d(50, 50)); | 443 generator.MoveMouseTo(generator.current_location() + gfx::Vector2d(50, 50)); |
| 444 DCHECK_NE(bounds.origin().ToString(), window->bounds().origin().ToString()); | 444 DCHECK_NE(bounds.origin().ToString(), window->bounds().origin().ToString()); |
| 445 window.reset(); | 445 window.reset(); |
| 446 generator.MoveMouseTo(generator.current_location() + gfx::Vector2d(50, 50)); | 446 generator.MoveMouseTo(generator.current_location() + gfx::Vector2d(50, 50)); |
| 447 } | 447 } |
| 448 | 448 |
| 449 // Verifies deleting the window while in a run loop doesn't crash. | 449 // Verifies deleting the window while in a run loop doesn't crash. |
| 450 TEST_F(WorkspaceEventHandlerTest, DeleteWhileInRunLoop) { | 450 TEST_F(WorkspaceEventHandlerTest, DeleteWhileInRunLoop) { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 473 wm::WindowState* window_state = wm::GetWindowState(window.get()); | 473 wm::WindowState* window_state = wm::GetWindowState(window.get()); |
| 474 gfx::Rect restore_bounds = window->bounds(); | 474 gfx::Rect restore_bounds = window->bounds(); |
| 475 gfx::Rect work_area_in_parent = ScreenUtil::GetDisplayWorkAreaBoundsInParent( | 475 gfx::Rect work_area_in_parent = ScreenUtil::GetDisplayWorkAreaBoundsInParent( |
| 476 window.get()); | 476 window.get()); |
| 477 | 477 |
| 478 EXPECT_FALSE(window_state->IsMaximized()); | 478 EXPECT_FALSE(window_state->IsMaximized()); |
| 479 | 479 |
| 480 // First click will go to a client | 480 // First click will go to a client |
| 481 delegate.set_window_component(HTCLIENT); | 481 delegate.set_window_component(HTCLIENT); |
| 482 aura::Window* root = Shell::GetPrimaryRootWindow(); | 482 aura::Window* root = Shell::GetPrimaryRootWindow(); |
| 483 aura::test::EventGenerator generator(root, window.get()); | 483 ui::test::EventGenerator generator(root, window.get()); |
| 484 generator.ClickLeftButton(); | 484 generator.ClickLeftButton(); |
| 485 EXPECT_FALSE(window_state->IsMaximized()); | 485 EXPECT_FALSE(window_state->IsMaximized()); |
| 486 | 486 |
| 487 // Second click will go to the header | 487 // Second click will go to the header |
| 488 delegate.set_window_component(HTCAPTION); | 488 delegate.set_window_component(HTCAPTION); |
| 489 generator.DoubleClickLeftButton(); | 489 generator.DoubleClickLeftButton(); |
| 490 EXPECT_FALSE(window_state->IsMaximized()); | 490 EXPECT_FALSE(window_state->IsMaximized()); |
| 491 } | 491 } |
| 492 | 492 |
| 493 // Verifies that double tapping in the header does not maximize if the target | 493 // Verifies that double tapping in the header does not maximize if the target |
| 494 // component has changed. | 494 // component has changed. |
| 495 TEST_F(WorkspaceEventHandlerTest, DoubleTapTwoDifferentTargetsDoesntMaximize) { | 495 TEST_F(WorkspaceEventHandlerTest, DoubleTapTwoDifferentTargetsDoesntMaximize) { |
| 496 aura::test::TestWindowDelegate delegate; | 496 aura::test::TestWindowDelegate delegate; |
| 497 scoped_ptr<aura::Window> window( | 497 scoped_ptr<aura::Window> window( |
| 498 CreateTestWindow(&delegate, gfx::Rect(1, 2, 30, 40))); | 498 CreateTestWindow(&delegate, gfx::Rect(1, 2, 30, 40))); |
| 499 window->SetProperty(aura::client::kCanMaximizeKey, true); | 499 window->SetProperty(aura::client::kCanMaximizeKey, true); |
| 500 | 500 |
| 501 wm::WindowState* window_state = wm::GetWindowState(window.get()); | 501 wm::WindowState* window_state = wm::GetWindowState(window.get()); |
| 502 gfx::Rect restore_bounds = window->bounds(); | 502 gfx::Rect restore_bounds = window->bounds(); |
| 503 gfx::Rect work_area_in_parent = ScreenUtil::GetDisplayWorkAreaBoundsInParent( | 503 gfx::Rect work_area_in_parent = ScreenUtil::GetDisplayWorkAreaBoundsInParent( |
| 504 window.get()); | 504 window.get()); |
| 505 | 505 |
| 506 EXPECT_FALSE(window_state->IsMaximized()); | 506 EXPECT_FALSE(window_state->IsMaximized()); |
| 507 | 507 |
| 508 // First tap will go to a client | 508 // First tap will go to a client |
| 509 delegate.set_window_component(HTCLIENT); | 509 delegate.set_window_component(HTCLIENT); |
| 510 aura::Window* root = Shell::GetPrimaryRootWindow(); | 510 aura::Window* root = Shell::GetPrimaryRootWindow(); |
| 511 aura::test::EventGenerator generator(root, window.get()); | 511 ui::test::EventGenerator generator(root, window.get()); |
| 512 generator.GestureTapAt(gfx::Point(25, 25)); | 512 generator.GestureTapAt(gfx::Point(25, 25)); |
| 513 EXPECT_FALSE(window_state->IsMaximized()); | 513 EXPECT_FALSE(window_state->IsMaximized()); |
| 514 | 514 |
| 515 // Second tap will go to the header | 515 // Second tap will go to the header |
| 516 delegate.set_window_component(HTCAPTION); | 516 delegate.set_window_component(HTCAPTION); |
| 517 generator.GestureTapAt(gfx::Point(25, 25)); | 517 generator.GestureTapAt(gfx::Point(25, 25)); |
| 518 EXPECT_FALSE(window_state->IsMaximized()); | 518 EXPECT_FALSE(window_state->IsMaximized()); |
| 519 } | 519 } |
| 520 | 520 |
| 521 TEST_F(WorkspaceEventHandlerTest, | 521 TEST_F(WorkspaceEventHandlerTest, |
| 522 RightClickDuringDoubleClickDoesntMaximize) { | 522 RightClickDuringDoubleClickDoesntMaximize) { |
| 523 aura::test::TestWindowDelegate delegate; | 523 aura::test::TestWindowDelegate delegate; |
| 524 scoped_ptr<aura::Window> window( | 524 scoped_ptr<aura::Window> window( |
| 525 CreateTestWindow(&delegate, gfx::Rect(1, 2, 30, 40))); | 525 CreateTestWindow(&delegate, gfx::Rect(1, 2, 30, 40))); |
| 526 window->SetProperty(aura::client::kCanMaximizeKey, true); | 526 window->SetProperty(aura::client::kCanMaximizeKey, true); |
| 527 | 527 |
| 528 wm::WindowState* window_state = wm::GetWindowState(window.get()); | 528 wm::WindowState* window_state = wm::GetWindowState(window.get()); |
| 529 gfx::Rect restore_bounds = window->bounds(); | 529 gfx::Rect restore_bounds = window->bounds(); |
| 530 gfx::Rect work_area_in_parent = ScreenUtil::GetDisplayWorkAreaBoundsInParent( | 530 gfx::Rect work_area_in_parent = ScreenUtil::GetDisplayWorkAreaBoundsInParent( |
| 531 window.get()); | 531 window.get()); |
| 532 | 532 |
| 533 EXPECT_FALSE(window_state->IsMaximized()); | 533 EXPECT_FALSE(window_state->IsMaximized()); |
| 534 | 534 |
| 535 // First click will go to a client | 535 // First click will go to a client |
| 536 delegate.set_window_component(HTCLIENT); | 536 delegate.set_window_component(HTCLIENT); |
| 537 aura::Window* root = Shell::GetPrimaryRootWindow(); | 537 aura::Window* root = Shell::GetPrimaryRootWindow(); |
| 538 aura::test::EventGenerator generator(root, window.get()); | 538 ui::test::EventGenerator generator(root, window.get()); |
| 539 generator.ClickLeftButton(); | 539 generator.ClickLeftButton(); |
| 540 EXPECT_FALSE(window_state->IsMaximized()); | 540 EXPECT_FALSE(window_state->IsMaximized()); |
| 541 | 541 |
| 542 // Second click will go to the header | 542 // Second click will go to the header |
| 543 delegate.set_window_component(HTCAPTION); | 543 delegate.set_window_component(HTCAPTION); |
| 544 generator.PressRightButton(); | 544 generator.PressRightButton(); |
| 545 generator.ReleaseRightButton(); | 545 generator.ReleaseRightButton(); |
| 546 EXPECT_FALSE(window_state->IsMaximized()); | 546 EXPECT_FALSE(window_state->IsMaximized()); |
| 547 generator.DoubleClickLeftButton(); | 547 generator.DoubleClickLeftButton(); |
| 548 EXPECT_FALSE(window_state->IsMaximized()); | 548 EXPECT_FALSE(window_state->IsMaximized()); |
| 549 } | 549 } |
| 550 | 550 |
| 551 } // namespace ash | 551 } // namespace ash |
| OLD | NEW |