Chromium Code Reviews| 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/property_util.h" | 10 #include "ash/wm/property_util.h" |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 194 { | 194 { |
| 195 generator.PressLeftButton(); | 195 generator.PressLeftButton(); |
| 196 generator.MoveMouseBy(10, 0); | 196 generator.MoveMouseBy(10, 0); |
| 197 generator.ReleaseLeftButton(); | 197 generator.ReleaseLeftButton(); |
| 198 RunAllPendingInMessageLoop(); | 198 RunAllPendingInMessageLoop(); |
| 199 | 199 |
| 200 EXPECT_FALSE(ash::wm::IsWindowMaximized(window)); | 200 EXPECT_FALSE(ash::wm::IsWindowMaximized(window)); |
| 201 EXPECT_FALSE(ash::wm::IsWindowMinimized(window)); | 201 EXPECT_FALSE(ash::wm::IsWindowMinimized(window)); |
| 202 internal::SnapSizer sizer(window, center, | 202 internal::SnapSizer sizer(window, center, |
| 203 internal::SnapSizer::RIGHT_EDGE, | 203 internal::SnapSizer::RIGHT_EDGE, |
| 204 internal::SnapSizer::OTHER_INPUT); | 204 internal::SnapSizer::STEP_NO); |
| 205 EXPECT_EQ(sizer.target_bounds().ToString(), window->bounds().ToString()); | 205 EXPECT_EQ(sizer.target_bounds().ToString(), window->bounds().ToString()); |
| 206 } | 206 } |
| 207 | 207 |
| 208 // Snap left. | 208 // Snap left. |
| 209 { | 209 { |
| 210 center = view->GetBoundsInScreen().CenterPoint(); | 210 center = view->GetBoundsInScreen().CenterPoint(); |
| 211 generator.MoveMouseTo(center); | 211 generator.MoveMouseTo(center); |
| 212 generator.PressLeftButton(); | 212 generator.PressLeftButton(); |
| 213 generator.MoveMouseBy(-10, 0); | 213 generator.MoveMouseBy(-10, 0); |
| 214 generator.ReleaseLeftButton(); | 214 generator.ReleaseLeftButton(); |
| 215 RunAllPendingInMessageLoop(); | 215 RunAllPendingInMessageLoop(); |
| 216 | 216 |
| 217 EXPECT_FALSE(ash::wm::IsWindowMaximized(window)); | 217 EXPECT_FALSE(ash::wm::IsWindowMaximized(window)); |
| 218 EXPECT_FALSE(ash::wm::IsWindowMinimized(window)); | 218 EXPECT_FALSE(ash::wm::IsWindowMinimized(window)); |
| 219 internal::SnapSizer sizer(window, center, | 219 internal::SnapSizer sizer(window, center, |
| 220 internal::SnapSizer::LEFT_EDGE, | 220 internal::SnapSizer::LEFT_EDGE, |
| 221 internal::SnapSizer::OTHER_INPUT); | 221 internal::SnapSizer::STEP_NO); |
| 222 EXPECT_EQ(sizer.target_bounds().ToString(), window->bounds().ToString()); | 222 EXPECT_EQ(sizer.target_bounds().ToString(), window->bounds().ToString()); |
| 223 } | 223 } |
| 224 | 224 |
| 225 // Minimize. | 225 // Minimize. |
| 226 { | 226 { |
| 227 center = view->GetBoundsInScreen().CenterPoint(); | 227 center = view->GetBoundsInScreen().CenterPoint(); |
| 228 generator.MoveMouseTo(center); | 228 generator.MoveMouseTo(center); |
| 229 generator.PressLeftButton(); | 229 generator.PressLeftButton(); |
| 230 generator.MoveMouseBy(0, 10); | 230 generator.MoveMouseBy(0, 10); |
| 231 generator.ReleaseLeftButton(); | 231 generator.ReleaseLeftButton(); |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 243 center = view->GetBoundsInScreen().CenterPoint(); | 243 center = view->GetBoundsInScreen().CenterPoint(); |
| 244 gfx::Point end = center; | 244 gfx::Point end = center; |
| 245 end.Offset(40, 0); | 245 end.Offset(40, 0); |
| 246 generator.GestureScrollSequence(center, end, | 246 generator.GestureScrollSequence(center, end, |
| 247 base::TimeDelta::FromMilliseconds(100), | 247 base::TimeDelta::FromMilliseconds(100), |
| 248 3); | 248 3); |
| 249 RunAllPendingInMessageLoop(); | 249 RunAllPendingInMessageLoop(); |
| 250 | 250 |
| 251 EXPECT_FALSE(ash::wm::IsWindowMaximized(window)); | 251 EXPECT_FALSE(ash::wm::IsWindowMaximized(window)); |
| 252 EXPECT_FALSE(ash::wm::IsWindowMinimized(window)); | 252 EXPECT_FALSE(ash::wm::IsWindowMinimized(window)); |
| 253 // This is a short resizing distance and different touch behavior | 253 internal::SnapSizer sizer(window, center, |
| 254 // applies which leads in half of the screen being used. | 254 internal::SnapSizer::RIGHT_EDGE, |
| 255 EXPECT_EQ("400,0 400x552", window->bounds().ToString()); | 255 internal::SnapSizer::STEP_NO); |
| 256 EXPECT_EQ(sizer.target_bounds(), window->bounds().ToString()); | |
| 256 } | 257 } |
| 257 | 258 |
| 258 // Snap left. | 259 // Snap left. |
| 259 { | 260 { |
| 260 center = view->GetBoundsInScreen().CenterPoint(); | 261 center = view->GetBoundsInScreen().CenterPoint(); |
| 261 gfx::Point end = center; | 262 gfx::Point end = center; |
| 262 end.Offset(-40, 0); | 263 end.Offset(-40, 0); |
| 263 generator.GestureScrollSequence(center, end, | 264 generator.GestureScrollSequence(center, end, |
| 264 base::TimeDelta::FromMilliseconds(100), | 265 base::TimeDelta::FromMilliseconds(100), |
| 265 3); | 266 3); |
| 266 RunAllPendingInMessageLoop(); | 267 RunAllPendingInMessageLoop(); |
| 267 | 268 |
| 268 EXPECT_FALSE(ash::wm::IsWindowMaximized(window)); | 269 EXPECT_FALSE(ash::wm::IsWindowMaximized(window)); |
| 269 EXPECT_FALSE(ash::wm::IsWindowMinimized(window)); | 270 EXPECT_FALSE(ash::wm::IsWindowMinimized(window)); |
| 270 internal::SnapSizer sizer(window, center, | 271 internal::SnapSizer sizer(window, center, |
| 271 internal::SnapSizer::LEFT_EDGE, | 272 internal::SnapSizer::LEFT_EDGE, |
| 272 internal::SnapSizer::OTHER_INPUT); | 273 internal::SnapSizer::STEP_NO); |
| 273 EXPECT_EQ(sizer.target_bounds().ToString(), window->bounds().ToString()); | 274 EXPECT_EQ(sizer.target_bounds().ToString(), window->bounds().ToString()); |
| 274 } | 275 } |
| 275 | 276 |
| 276 // Minimize. | 277 // Minimize. |
| 277 { | 278 { |
| 278 center = view->GetBoundsInScreen().CenterPoint(); | 279 center = view->GetBoundsInScreen().CenterPoint(); |
| 279 gfx::Point end = center; | 280 gfx::Point end = center; |
| 280 end.Offset(0, 40); | 281 end.Offset(0, 40); |
| 281 generator.GestureScrollSequence(center, end, | 282 generator.GestureScrollSequence(center, end, |
| 282 base::TimeDelta::FromMilliseconds(100), | 283 base::TimeDelta::FromMilliseconds(100), |
| 283 3); | 284 3); |
| 284 RunAllPendingInMessageLoop(); | 285 RunAllPendingInMessageLoop(); |
| 285 | 286 |
| 286 EXPECT_TRUE(ash::wm::IsWindowMinimized(window)); | 287 EXPECT_TRUE(ash::wm::IsWindowMinimized(window)); |
| 287 } | 288 } |
| 288 | 289 |
| 289 // Test with gesture events. | 290 // Test with gesture events. |
| 290 } | 291 } |
| 291 | 292 |
| 292 #if defined(OS_WIN) | |
| 293 // RootWindow and Display can't resize on Windows Ash. http://crbug.com/165962 | |
| 294 #define MAYBE_TouchDragResizeCloseToCornerDiffersFromMouse \ | |
| 295 DISABLED_TouchDragResizeCloseToCornerDiffersFromMouse | |
| 296 #else | |
| 297 #define MAYBE_TouchDragResizeCloseToCornerDiffersFromMouse \ | |
| 298 TouchDragResizeCloseToCornerDiffersFromMouse | |
| 299 #endif | |
| 300 | |
| 301 // Tests Left/Right snapping with resize button touch dragging - which should | |
| 302 // trigger dependent on the available drag distance. | |
| 303 TEST_F(CustomFrameViewAshTest, | |
| 304 MAYBE_TouchDragResizeCloseToCornerDiffersFromMouse) { | |
|
varkha
2013/08/30 17:13:25
I understand that you don't need to test that touc
pkotwicz
2013/08/30 21:10:57
Yes, we test snapping left and right via touch in
| |
| 305 aura::Window* window = widget()->GetNativeWindow(); | |
| 306 views::View* view = maximize_button(); | |
| 307 | |
| 308 gfx::Rect work_area = widget()->GetWorkAreaBoundsInScreen(); | |
| 309 gfx::Rect bounds = window->bounds(); | |
| 310 bounds.set_x(work_area.width() - bounds.width()); | |
| 311 widget()->SetBounds(bounds); | |
| 312 | |
| 313 gfx::Point start_point = view->GetBoundsInScreen().CenterPoint(); | |
| 314 // We want to move all the way to the right (the few pixels we have). | |
| 315 gfx::Point end_point = gfx::Point(work_area.width(), start_point.y()); | |
| 316 | |
| 317 aura::test::EventGenerator generator(window->GetRootWindow(), start_point); | |
| 318 | |
| 319 EXPECT_TRUE(ash::wm::IsWindowNormal(window)); | |
| 320 | |
| 321 // Snap right with a touch drag. | |
| 322 generator.GestureScrollSequence(start_point, | |
| 323 end_point, | |
| 324 base::TimeDelta::FromMilliseconds(100), | |
| 325 10); | |
| 326 RunAllPendingInMessageLoop(); | |
| 327 | |
| 328 EXPECT_FALSE(ash::wm::IsWindowMaximized(window)); | |
| 329 EXPECT_FALSE(ash::wm::IsWindowMinimized(window)); | |
| 330 gfx::Rect touch_result = window->bounds(); | |
| 331 EXPECT_NE(bounds.ToString(), touch_result.ToString()); | |
| 332 | |
| 333 // Set the position back to where it was before and re-try with a mouse. | |
| 334 widget()->SetBounds(bounds); | |
| 335 | |
| 336 generator.MoveMouseTo(start_point); | |
| 337 generator.PressLeftButton(); | |
| 338 generator.MoveMouseTo(end_point, 10); | |
| 339 generator.ReleaseLeftButton(); | |
| 340 RunAllPendingInMessageLoop(); | |
| 341 | |
| 342 EXPECT_FALSE(ash::wm::IsWindowMaximized(window)); | |
| 343 EXPECT_FALSE(ash::wm::IsWindowMinimized(window)); | |
| 344 gfx::Rect mouse_result = window->bounds(); | |
| 345 | |
| 346 // The difference between the two operations should be that the mouse | |
| 347 // operation should have just started to resize and the touch operation is | |
| 348 // already all the way down to the smallest possible size. | |
| 349 EXPECT_NE(mouse_result.ToString(), touch_result.ToString()); | |
| 350 EXPECT_GT(mouse_result.width(), touch_result.width()); | |
| 351 } | |
| 352 | |
| 353 // Test that closing the (browser) window with an opened balloon does not | 293 // Test that closing the (browser) window with an opened balloon does not |
| 354 // crash the system. In other words: Make sure that shutting down the frame | 294 // crash the system. In other words: Make sure that shutting down the frame |
| 355 // destroys the opened balloon in an orderly fashion. | 295 // destroys the opened balloon in an orderly fashion. |
| 356 TEST_F(CustomFrameViewAshTest, MaximizeButtonExternalShutDown) { | 296 TEST_F(CustomFrameViewAshTest, MaximizeButtonExternalShutDown) { |
| 357 aura::Window* window = widget()->GetNativeWindow(); | 297 aura::Window* window = widget()->GetNativeWindow(); |
| 358 ash::FrameMaximizeButton* maximize_button = | 298 ash::FrameMaximizeButton* maximize_button = |
| 359 CustomFrameViewAshTest::maximize_button(); | 299 CustomFrameViewAshTest::maximize_button(); |
| 360 maximize_button->set_bubble_appearance_delay_ms(0); | 300 maximize_button->set_bubble_appearance_delay_ms(0); |
| 361 gfx::Point button_pos = maximize_button->GetBoundsInScreen().CenterPoint(); | 301 gfx::Point button_pos = maximize_button->GetBoundsInScreen().CenterPoint(); |
| 362 gfx::Point off_pos(button_pos.x() + 100, button_pos.y() + 100); | 302 gfx::Point off_pos(button_pos.x() + 100, button_pos.y() + 100); |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 468 EXPECT_TRUE(maximize_button->phantom_window_open()); | 408 EXPECT_TRUE(maximize_button->phantom_window_open()); |
| 469 generator.ClickLeftButton(); | 409 generator.ClickLeftButton(); |
| 470 | 410 |
| 471 EXPECT_FALSE(maximize_button->maximizer()); | 411 EXPECT_FALSE(maximize_button->maximizer()); |
| 472 EXPECT_FALSE(maximize_button->phantom_window_open()); | 412 EXPECT_FALSE(maximize_button->phantom_window_open()); |
| 473 | 413 |
| 474 EXPECT_FALSE(ash::wm::IsWindowMaximized(window)); | 414 EXPECT_FALSE(ash::wm::IsWindowMaximized(window)); |
| 475 EXPECT_FALSE(ash::wm::IsWindowMinimized(window)); | 415 EXPECT_FALSE(ash::wm::IsWindowMinimized(window)); |
| 476 internal::SnapSizer sizer(window, button_pos, | 416 internal::SnapSizer sizer(window, button_pos, |
| 477 internal::SnapSizer::LEFT_EDGE, | 417 internal::SnapSizer::LEFT_EDGE, |
| 478 internal::SnapSizer::OTHER_INPUT); | 418 internal::SnapSizer::STEP_NO); |
| 479 sizer.SelectDefaultSizeAndDisableResize(); | 419 sizer.SelectDefaultSizeAndDisableResize(); |
| 480 EXPECT_EQ(sizer.target_bounds().ToString(), window->bounds().ToString()); | 420 EXPECT_EQ(sizer.target_bounds().ToString(), window->bounds().ToString()); |
| 481 } | 421 } |
| 482 | 422 |
| 483 // Test that the activation focus does not change when the bubble gets shown. | 423 // Test that the activation focus does not change when the bubble gets shown. |
| 484 TEST_F(CustomFrameViewAshTest, MaximizeKeepFocus) { | 424 TEST_F(CustomFrameViewAshTest, MaximizeKeepFocus) { |
| 485 aura::Window* window = widget()->GetNativeWindow(); | 425 aura::Window* window = widget()->GetNativeWindow(); |
| 486 ash::FrameMaximizeButton* maximize_button = | 426 ash::FrameMaximizeButton* maximize_button = |
| 487 CustomFrameViewAshTest::maximize_button(); | 427 CustomFrameViewAshTest::maximize_button(); |
| 488 maximize_button->set_bubble_appearance_delay_ms(0); | 428 maximize_button->set_bubble_appearance_delay_ms(0); |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 806 | 746 |
| 807 // Check that there was no size change. | 747 // Check that there was no size change. |
| 808 EXPECT_EQ(widget()->GetWindowBoundsInScreen().size().ToString(), | 748 EXPECT_EQ(widget()->GetWindowBoundsInScreen().size().ToString(), |
| 809 initial_bounds.size().ToString()); | 749 initial_bounds.size().ToString()); |
| 810 // Check that there is no phantom window left open. | 750 // Check that there is no phantom window left open. |
| 811 EXPECT_FALSE(maximize_button->phantom_window_open()); | 751 EXPECT_FALSE(maximize_button->phantom_window_open()); |
| 812 } | 752 } |
| 813 | 753 |
| 814 } // namespace test | 754 } // namespace test |
| 815 } // namespace ash | 755 } // namespace ash |
| OLD | NEW |