OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/caption_buttons/alternate_frame_size_button.h" | 5 #include "ash/wm/caption_buttons/alternate_frame_size_button.h" |
6 | 6 |
7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.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/caption_buttons/frame_caption_button.h" | 10 #include "ash/wm/caption_buttons/frame_caption_button.h" |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 // the minimize and close button icons changing. | 315 // the minimize and close button icons changing. |
316 aura::test::EventGenerator& generator = GetEventGenerator(); | 316 aura::test::EventGenerator& generator = GetEventGenerator(); |
317 generator.MoveMouseTo(CenterPointInScreen(size_button())); | 317 generator.MoveMouseTo(CenterPointInScreen(size_button())); |
318 generator.PressLeftButton(); | 318 generator.PressLeftButton(); |
319 EXPECT_EQ(views::Button::STATE_NORMAL, minimize_button()->state()); | 319 EXPECT_EQ(views::Button::STATE_NORMAL, minimize_button()->state()); |
320 EXPECT_EQ(views::Button::STATE_PRESSED, size_button()->state()); | 320 EXPECT_EQ(views::Button::STATE_PRESSED, size_button()->state()); |
321 EXPECT_EQ(views::Button::STATE_NORMAL, close_button()->state()); | 321 EXPECT_EQ(views::Button::STATE_NORMAL, close_button()->state()); |
322 EXPECT_EQ(CAPTION_BUTTON_ICON_LEFT_SNAPPED, minimize_button()->icon()); | 322 EXPECT_EQ(CAPTION_BUTTON_ICON_LEFT_SNAPPED, minimize_button()->icon()); |
323 EXPECT_EQ(CAPTION_BUTTON_ICON_RIGHT_SNAPPED, close_button()->icon()); | 323 EXPECT_EQ(CAPTION_BUTTON_ICON_RIGHT_SNAPPED, close_button()->icon()); |
324 | 324 |
325 // Dragging the mouse over the minimize button should press the minimize | 325 // Dragging the mouse over the minimize button should hover the minimize |
326 // button and the minimize and close button icons should stay changed. | 326 // button and the minimize and close button icons should stay changed. |
327 generator.MoveMouseTo(CenterPointInScreen(minimize_button())); | 327 generator.MoveMouseTo(CenterPointInScreen(minimize_button())); |
328 EXPECT_EQ(views::Button::STATE_PRESSED, minimize_button()->state()); | 328 EXPECT_EQ(views::Button::STATE_HOVERED, minimize_button()->state()); |
329 EXPECT_EQ(views::Button::STATE_NORMAL, size_button()->state()); | 329 EXPECT_EQ(views::Button::STATE_PRESSED, size_button()->state()); |
330 EXPECT_EQ(views::Button::STATE_NORMAL, close_button()->state()); | 330 EXPECT_EQ(views::Button::STATE_NORMAL, close_button()->state()); |
331 EXPECT_EQ(CAPTION_BUTTON_ICON_LEFT_SNAPPED, minimize_button()->icon()); | 331 EXPECT_EQ(CAPTION_BUTTON_ICON_LEFT_SNAPPED, minimize_button()->icon()); |
332 EXPECT_EQ(CAPTION_BUTTON_ICON_RIGHT_SNAPPED, close_button()->icon()); | 332 EXPECT_EQ(CAPTION_BUTTON_ICON_RIGHT_SNAPPED, close_button()->icon()); |
333 | 333 |
334 // Release the mouse, snapping the window left. | 334 // Release the mouse, snapping the window left. |
335 generator.ReleaseLeftButton(); | 335 generator.ReleaseLeftButton(); |
336 RunAllPendingInMessageLoop(); | 336 RunAllPendingInMessageLoop(); |
337 EXPECT_TRUE(IsSnapped(internal::SnapSizer::LEFT_EDGE)); | 337 EXPECT_TRUE(IsSnapped(internal::SnapSizer::LEFT_EDGE)); |
338 | 338 |
339 // None of the buttons should stay pressed and the buttons should have their | 339 // None of the buttons should stay pressed and the buttons should have their |
(...skipping 28 matching lines...) Expand all Loading... |
368 RunAllPendingInMessageLoop(); | 368 RunAllPendingInMessageLoop(); |
369 EXPECT_TRUE(IsSnapped(internal::SnapSizer::LEFT_EDGE)); | 369 EXPECT_TRUE(IsSnapped(internal::SnapSizer::LEFT_EDGE)); |
370 | 370 |
371 // The buttons should stay unpressed and the buttons should now have their | 371 // The buttons should stay unpressed and the buttons should now have their |
372 // regular icons. | 372 // regular icons. |
373 EXPECT_TRUE(AllButtonsInNormalState()); | 373 EXPECT_TRUE(AllButtonsInNormalState()); |
374 EXPECT_EQ(CAPTION_BUTTON_ICON_MINIMIZE, minimize_button()->icon()); | 374 EXPECT_EQ(CAPTION_BUTTON_ICON_MINIMIZE, minimize_button()->icon()); |
375 EXPECT_EQ(CAPTION_BUTTON_ICON_CLOSE, close_button()->icon()); | 375 EXPECT_EQ(CAPTION_BUTTON_ICON_CLOSE, close_button()->icon()); |
376 } | 376 } |
377 | 377 |
| 378 // Test that the size button is pressed whenever the snap left/right buttons |
| 379 // are hovered. |
| 380 TEST_F(AlternateFrameSizeButtonTest, SizeButtonPressedWhenSnapButtonHovered) { |
| 381 EXPECT_EQ(CAPTION_BUTTON_ICON_MINIMIZE, minimize_button()->icon()); |
| 382 EXPECT_EQ(CAPTION_BUTTON_ICON_CLOSE, close_button()->icon()); |
| 383 EXPECT_TRUE(AllButtonsInNormalState()); |
| 384 |
| 385 // Pressing the size button should result in the size button being pressed and |
| 386 // the minimize and close button icons changing. |
| 387 aura::test::EventGenerator& generator = GetEventGenerator(); |
| 388 generator.MoveMouseTo(CenterPointInScreen(size_button())); |
| 389 generator.PressLeftButton(); |
| 390 EXPECT_EQ(views::Button::STATE_NORMAL, minimize_button()->state()); |
| 391 EXPECT_EQ(views::Button::STATE_PRESSED, size_button()->state()); |
| 392 EXPECT_EQ(views::Button::STATE_NORMAL, close_button()->state()); |
| 393 EXPECT_EQ(CAPTION_BUTTON_ICON_LEFT_SNAPPED, minimize_button()->icon()); |
| 394 EXPECT_EQ(CAPTION_BUTTON_ICON_RIGHT_SNAPPED, close_button()->icon()); |
| 395 |
| 396 // Dragging the mouse over the minimize button (snap left button) should hover |
| 397 // the minimize button and keep the size button pressed. |
| 398 generator.MoveMouseTo(CenterPointInScreen(minimize_button())); |
| 399 EXPECT_EQ(views::Button::STATE_HOVERED, minimize_button()->state()); |
| 400 EXPECT_EQ(views::Button::STATE_PRESSED, size_button()->state()); |
| 401 EXPECT_EQ(views::Button::STATE_NORMAL, close_button()->state()); |
| 402 |
| 403 // Moving the mouse far away from the caption buttons and then moving it over |
| 404 // the close button (snap right button) should hover the close button and |
| 405 // keep the size button pressed. |
| 406 const gfx::Rect& kWorkAreaBoundsInScreen = |
| 407 ash::Shell::GetScreen()->GetPrimaryDisplay().work_area(); |
| 408 generator.MoveMouseTo(kWorkAreaBoundsInScreen.bottom_left()); |
| 409 EXPECT_TRUE(AllButtonsInNormalState()); |
| 410 generator.MoveMouseTo(CenterPointInScreen(close_button())); |
| 411 EXPECT_EQ(views::Button::STATE_NORMAL, minimize_button()->state()); |
| 412 EXPECT_EQ(views::Button::STATE_PRESSED, size_button()->state()); |
| 413 EXPECT_EQ(views::Button::STATE_HOVERED, close_button()->state()); |
| 414 } |
| 415 |
378 } // namespace test | 416 } // namespace test |
379 } // namespace ash | 417 } // namespace ash |
OLD | NEW |