| 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/ash_constants.h" | 5 #include "ash/ash_constants.h" |
| 6 #include "ash/frame/custom_frame_view_ash.h" | 6 #include "ash/frame/custom_frame_view_ash.h" |
| 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/test/cursor_manager_test_api.h" | 9 #include "ash/test/cursor_manager_test_api.h" |
| 10 #include "ash/wm/resize_shadow.h" | 10 #include "ash/wm/resize_shadow.h" |
| 11 #include "ash/wm/resize_shadow_controller.h" | 11 #include "ash/wm/resize_shadow_controller.h" |
| 12 #include "ash/wm/window_state.h" | 12 #include "ash/wm/window_state.h" |
| 13 #include "base/bind.h" | 13 #include "base/bind.h" |
| 14 #include "ui/aura/window_event_dispatcher.h" | 14 #include "ui/aura/window_event_dispatcher.h" |
| 15 #include "ui/base/cursor/cursor.h" | 15 #include "ui/base/cursor/cursor.h" |
| 16 #include "ui/base/hit_test.h" | 16 #include "ui/base/hit_test.h" |
| 17 #include "ui/events/test/event_generator.h" | 17 #include "ui/events/test/event_generator.h" |
| 18 #include "ui/views/widget/widget.h" | 18 #include "ui/views/widget/widget.h" |
| 19 #include "ui/views/widget/widget_delegate.h" | 19 #include "ui/views/widget/widget_delegate.h" |
| 20 | 20 |
| 21 namespace ash { | 21 namespace ash { |
| 22 namespace test { | 22 namespace test { |
| 23 | 23 |
| 24 namespace { | 24 namespace { |
| 25 | 25 |
| 26 // views::WidgetDelegate which uses ash::CustomFrameViewAsh. | 26 // views::WidgetDelegate which uses ash::CustomFrameViewAsh. |
| 27 class TestWidgetDelegate : public views::WidgetDelegateView { | 27 class TestWidgetDelegate : public views::WidgetDelegateView { |
| 28 public: | 28 public: |
| 29 TestWidgetDelegate() {} | 29 TestWidgetDelegate() {} |
| 30 virtual ~TestWidgetDelegate() {} | 30 ~TestWidgetDelegate() override {} |
| 31 | 31 |
| 32 // views::WidgetDelegateView overrides: | 32 // views::WidgetDelegateView overrides: |
| 33 virtual bool CanResize() const override { | 33 bool CanResize() const override { return true; } |
| 34 return true; | 34 bool CanMaximize() const override { return true; } |
| 35 } | 35 bool CanMinimize() const override { return true; } |
| 36 virtual bool CanMaximize() const override { | 36 views::NonClientFrameView* CreateNonClientFrameView( |
| 37 return true; | |
| 38 } | |
| 39 virtual bool CanMinimize() const override { | |
| 40 return true; | |
| 41 } | |
| 42 virtual views::NonClientFrameView* CreateNonClientFrameView( | |
| 43 views::Widget* widget) override { | 37 views::Widget* widget) override { |
| 44 return new ash::CustomFrameViewAsh(widget); | 38 return new ash::CustomFrameViewAsh(widget); |
| 45 } | 39 } |
| 46 | 40 |
| 47 private: | 41 private: |
| 48 DISALLOW_COPY_AND_ASSIGN(TestWidgetDelegate); | 42 DISALLOW_COPY_AND_ASSIGN(TestWidgetDelegate); |
| 49 }; | 43 }; |
| 50 | 44 |
| 51 } // namespace | 45 } // namespace |
| 52 | 46 |
| 53 // The test tests that the mouse cursor is changed and that the resize shadows | 47 // The test tests that the mouse cursor is changed and that the resize shadows |
| 54 // are shown when the mouse is hovered over the window edge. | 48 // are shown when the mouse is hovered over the window edge. |
| 55 class ResizeShadowAndCursorTest : public AshTestBase { | 49 class ResizeShadowAndCursorTest : public AshTestBase { |
| 56 public: | 50 public: |
| 57 ResizeShadowAndCursorTest() {} | 51 ResizeShadowAndCursorTest() {} |
| 58 virtual ~ResizeShadowAndCursorTest() {} | 52 ~ResizeShadowAndCursorTest() override {} |
| 59 | 53 |
| 60 // AshTestBase override: | 54 // AshTestBase override: |
| 61 virtual void SetUp() override { | 55 void SetUp() override { |
| 62 AshTestBase::SetUp(); | 56 AshTestBase::SetUp(); |
| 63 | 57 |
| 64 views::Widget* widget(views::Widget::CreateWindowWithContextAndBounds( | 58 views::Widget* widget(views::Widget::CreateWindowWithContextAndBounds( |
| 65 new TestWidgetDelegate(), CurrentContext(), gfx::Rect(0, 0, 200, 100))); | 59 new TestWidgetDelegate(), CurrentContext(), gfx::Rect(0, 0, 200, 100))); |
| 66 widget->Show(); | 60 widget->Show(); |
| 67 window_ = widget->GetNativeView(); | 61 window_ = widget->GetNativeView(); |
| 68 | 62 |
| 69 // Add a child window to |window_| in order to properly test that the resize | 63 // Add a child window to |window_| in order to properly test that the resize |
| 70 // handles and the resize shadows are shown when the mouse is | 64 // handles and the resize shadows are shown when the mouse is |
| 71 // ash::kResizeInsideBoundsSize inside of |window_|'s edges. | 65 // ash::kResizeInsideBoundsSize inside of |window_|'s edges. |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 generator.MoveMouseTo(200, 50); | 218 generator.MoveMouseTo(200, 50); |
| 225 EXPECT_EQ(HTRIGHT, ResizeShadowHitTest()); | 219 EXPECT_EQ(HTRIGHT, ResizeShadowHitTest()); |
| 226 EXPECT_EQ(ui::kCursorEastResize, GetCurrentCursorType()); | 220 EXPECT_EQ(ui::kCursorEastResize, GetCurrentCursorType()); |
| 227 generator.MoveMouseTo(200 - ash::kResizeInsideBoundsSize, 50); | 221 generator.MoveMouseTo(200 - ash::kResizeInsideBoundsSize, 50); |
| 228 EXPECT_EQ(HTRIGHT, ResizeShadowHitTest()); | 222 EXPECT_EQ(HTRIGHT, ResizeShadowHitTest()); |
| 229 EXPECT_EQ(ui::kCursorEastResize, GetCurrentCursorType()); | 223 EXPECT_EQ(ui::kCursorEastResize, GetCurrentCursorType()); |
| 230 } | 224 } |
| 231 | 225 |
| 232 } // namespace test | 226 } // namespace test |
| 233 } // namespace ash | 227 } // namespace ash |
| OLD | NEW |