| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/frame/caption_buttons/frame_size_button.h" | 5 #include "ash/frame/caption_buttons/frame_size_button.h" |
| 6 | 6 |
| 7 #include "ash/ash_layout_constants.h" | 7 #include "ash/ash_layout_constants.h" |
| 8 #include "ash/frame/caption_buttons/frame_caption_button.h" | 8 #include "ash/frame/caption_buttons/frame_caption_button.h" |
| 9 #include "ash/frame/caption_buttons/frame_caption_button_container_view.h" | 9 #include "ash/frame/caption_buttons/frame_caption_button_container_view.h" |
| 10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| 11 #include "ash/test/ash_test_base.h" | 11 #include "ash/test/ash_test_base.h" |
| 12 #include "ash/wm/common/window_state.h" | 12 #include "ash/wm/common/window_state.h" |
| 13 #include "ash/wm/window_state_aura.h" | 13 #include "ash/wm/window_state_aura.h" |
| 14 #include "base/i18n/rtl.h" | 14 #include "base/i18n/rtl.h" |
| 15 #include "grit/ash_resources.h" | 15 #include "grit/ash_resources.h" |
| 16 #include "ui/aura/window.h" | 16 #include "ui/aura/window.h" |
| 17 #include "ui/display/display.h" |
| 18 #include "ui/display/screen.h" |
| 17 #include "ui/events/gesture_detection/gesture_configuration.h" | 19 #include "ui/events/gesture_detection/gesture_configuration.h" |
| 18 #include "ui/events/test/event_generator.h" | 20 #include "ui/events/test/event_generator.h" |
| 19 #include "ui/gfx/display.h" | |
| 20 #include "ui/gfx/screen.h" | |
| 21 #include "ui/gfx/vector_icons_public.h" | 21 #include "ui/gfx/vector_icons_public.h" |
| 22 #include "ui/views/widget/widget.h" | 22 #include "ui/views/widget/widget.h" |
| 23 #include "ui/views/widget/widget_delegate.h" | 23 #include "ui/views/widget/widget_delegate.h" |
| 24 | 24 |
| 25 namespace ash { | 25 namespace ash { |
| 26 namespace test { | 26 namespace test { |
| 27 | 27 |
| 28 namespace { | 28 namespace { |
| 29 | 29 |
| 30 class TestWidgetDelegate : public views::WidgetDelegateView { | 30 class TestWidgetDelegate : public views::WidgetDelegateView { |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 // because the code path is different. | 330 // because the code path is different. |
| 331 generator.MoveMouseTo(CenterPointInScreen(size_button())); | 331 generator.MoveMouseTo(CenterPointInScreen(size_button())); |
| 332 generator.PressLeftButton(); | 332 generator.PressLeftButton(); |
| 333 EXPECT_EQ(views::Button::STATE_NORMAL, minimize_button()->state()); | 333 EXPECT_EQ(views::Button::STATE_NORMAL, minimize_button()->state()); |
| 334 EXPECT_EQ(views::Button::STATE_PRESSED, size_button()->state()); | 334 EXPECT_EQ(views::Button::STATE_PRESSED, size_button()->state()); |
| 335 EXPECT_EQ(views::Button::STATE_NORMAL, close_button()->state()); | 335 EXPECT_EQ(views::Button::STATE_NORMAL, close_button()->state()); |
| 336 EXPECT_EQ(CAPTION_BUTTON_ICON_LEFT_SNAPPED, minimize_button()->icon()); | 336 EXPECT_EQ(CAPTION_BUTTON_ICON_LEFT_SNAPPED, minimize_button()->icon()); |
| 337 EXPECT_EQ(CAPTION_BUTTON_ICON_RIGHT_SNAPPED, close_button()->icon()); | 337 EXPECT_EQ(CAPTION_BUTTON_ICON_RIGHT_SNAPPED, close_button()->icon()); |
| 338 | 338 |
| 339 const gfx::Rect& kWorkAreaBoundsInScreen = | 339 const gfx::Rect& kWorkAreaBoundsInScreen = |
| 340 gfx::Screen::GetScreen()->GetPrimaryDisplay().work_area(); | 340 display::Screen::GetScreen()->GetPrimaryDisplay().work_area(); |
| 341 generator.MoveMouseTo(kWorkAreaBoundsInScreen.bottom_left()); | 341 generator.MoveMouseTo(kWorkAreaBoundsInScreen.bottom_left()); |
| 342 | 342 |
| 343 // None of the buttons should be pressed because we are really far away from | 343 // None of the buttons should be pressed because we are really far away from |
| 344 // any of the caption buttons. The minimize and close button icons should | 344 // any of the caption buttons. The minimize and close button icons should |
| 345 // be changed because the mouse is pressed. | 345 // be changed because the mouse is pressed. |
| 346 EXPECT_TRUE(AllButtonsInNormalState()); | 346 EXPECT_TRUE(AllButtonsInNormalState()); |
| 347 EXPECT_EQ(CAPTION_BUTTON_ICON_LEFT_SNAPPED, minimize_button()->icon()); | 347 EXPECT_EQ(CAPTION_BUTTON_ICON_LEFT_SNAPPED, minimize_button()->icon()); |
| 348 EXPECT_EQ(CAPTION_BUTTON_ICON_RIGHT_SNAPPED, close_button()->icon()); | 348 EXPECT_EQ(CAPTION_BUTTON_ICON_RIGHT_SNAPPED, close_button()->icon()); |
| 349 | 349 |
| 350 // Release the mouse. The window should stay snapped left. | 350 // Release the mouse. The window should stay snapped left. |
| (...skipping 30 matching lines...) Expand all Loading... |
| 381 // the minimize button and keep the size button pressed. | 381 // the minimize button and keep the size button pressed. |
| 382 generator.MoveMouseTo(CenterPointInScreen(minimize_button())); | 382 generator.MoveMouseTo(CenterPointInScreen(minimize_button())); |
| 383 EXPECT_EQ(views::Button::STATE_HOVERED, minimize_button()->state()); | 383 EXPECT_EQ(views::Button::STATE_HOVERED, minimize_button()->state()); |
| 384 EXPECT_EQ(views::Button::STATE_PRESSED, size_button()->state()); | 384 EXPECT_EQ(views::Button::STATE_PRESSED, size_button()->state()); |
| 385 EXPECT_EQ(views::Button::STATE_NORMAL, close_button()->state()); | 385 EXPECT_EQ(views::Button::STATE_NORMAL, close_button()->state()); |
| 386 | 386 |
| 387 // Moving the mouse far away from the caption buttons and then moving it over | 387 // Moving the mouse far away from the caption buttons and then moving it over |
| 388 // the close button (snap right button) should hover the close button and | 388 // the close button (snap right button) should hover the close button and |
| 389 // keep the size button pressed. | 389 // keep the size button pressed. |
| 390 const gfx::Rect& kWorkAreaBoundsInScreen = | 390 const gfx::Rect& kWorkAreaBoundsInScreen = |
| 391 gfx::Screen::GetScreen()->GetPrimaryDisplay().work_area(); | 391 display::Screen::GetScreen()->GetPrimaryDisplay().work_area(); |
| 392 generator.MoveMouseTo(kWorkAreaBoundsInScreen.bottom_left()); | 392 generator.MoveMouseTo(kWorkAreaBoundsInScreen.bottom_left()); |
| 393 EXPECT_TRUE(AllButtonsInNormalState()); | 393 EXPECT_TRUE(AllButtonsInNormalState()); |
| 394 generator.MoveMouseTo(CenterPointInScreen(close_button())); | 394 generator.MoveMouseTo(CenterPointInScreen(close_button())); |
| 395 EXPECT_EQ(views::Button::STATE_NORMAL, minimize_button()->state()); | 395 EXPECT_EQ(views::Button::STATE_NORMAL, minimize_button()->state()); |
| 396 EXPECT_EQ(views::Button::STATE_PRESSED, size_button()->state()); | 396 EXPECT_EQ(views::Button::STATE_PRESSED, size_button()->state()); |
| 397 EXPECT_EQ(views::Button::STATE_HOVERED, close_button()->state()); | 397 EXPECT_EQ(views::Button::STATE_HOVERED, close_button()->state()); |
| 398 } | 398 } |
| 399 | 399 |
| 400 class FrameSizeButtonTestRTL : public FrameSizeButtonTest { | 400 class FrameSizeButtonTestRTL : public FrameSizeButtonTest { |
| 401 public: | 401 public: |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 | 460 |
| 461 // None of the buttons should stay pressed and the buttons should have their | 461 // None of the buttons should stay pressed and the buttons should have their |
| 462 // regular icons. | 462 // regular icons. |
| 463 EXPECT_TRUE(AllButtonsInNormalState()); | 463 EXPECT_TRUE(AllButtonsInNormalState()); |
| 464 EXPECT_EQ(CAPTION_BUTTON_ICON_MINIMIZE, minimize_button()->icon()); | 464 EXPECT_EQ(CAPTION_BUTTON_ICON_MINIMIZE, minimize_button()->icon()); |
| 465 EXPECT_EQ(CAPTION_BUTTON_ICON_CLOSE, close_button()->icon()); | 465 EXPECT_EQ(CAPTION_BUTTON_ICON_CLOSE, close_button()->icon()); |
| 466 } | 466 } |
| 467 | 467 |
| 468 } // namespace test | 468 } // namespace test |
| 469 } // namespace ash | 469 } // namespace ash |
| OLD | NEW |