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/common/ash_constants.h" | 5 #include "ash/common/ash_constants.h" |
6 #include "ash/common/wm/window_state.h" | 6 #include "ash/common/wm/window_state.h" |
7 #include "ash/frame/custom_frame_view_ash.h" | 7 #include "ash/frame/custom_frame_view_ash.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/test/cursor_manager_test_api.h" | 10 #include "ash/test/cursor_manager_test_api.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 AshTestBase::SetUp(); | 57 AshTestBase::SetUp(); |
58 | 58 |
59 views::Widget* widget(views::Widget::CreateWindowWithContextAndBounds( | 59 views::Widget* widget(views::Widget::CreateWindowWithContextAndBounds( |
60 new TestWidgetDelegate(), CurrentContext(), gfx::Rect(0, 0, 200, 100))); | 60 new TestWidgetDelegate(), CurrentContext(), gfx::Rect(0, 0, 200, 100))); |
61 widget->Show(); | 61 widget->Show(); |
62 window_ = widget->GetNativeView(); | 62 window_ = widget->GetNativeView(); |
63 | 63 |
64 // Add a child window to |window_| in order to properly test that the resize | 64 // Add a child window to |window_| in order to properly test that the resize |
65 // handles and the resize shadows are shown when the mouse is | 65 // handles and the resize shadows are shown when the mouse is |
66 // ash::kResizeInsideBoundsSize inside of |window_|'s edges. | 66 // ash::kResizeInsideBoundsSize inside of |window_|'s edges. |
67 aura::Window* child = CreateTestWindowInShell( | 67 aura::Window* child = |
68 SK_ColorWHITE, 0, gfx::Rect(0, 10, 200, 90)); | 68 CreateTestWindowInShell(SK_ColorWHITE, 0, gfx::Rect(0, 10, 200, 90)); |
69 window_->AddChild(child); | 69 window_->AddChild(child); |
70 } | 70 } |
71 | 71 |
72 // Returns the hit test code if there is a resize shadow. Returns HTNOWHERE if | 72 // Returns the hit test code if there is a resize shadow. Returns HTNOWHERE if |
73 // there is no resize shadow. | 73 // there is no resize shadow. |
74 int ResizeShadowHitTest() const { | 74 int ResizeShadowHitTest() const { |
75 ash::ResizeShadow* resize_shadow = ash::Shell::GetInstance() | 75 ash::ResizeShadow* resize_shadow = ash::Shell::GetInstance() |
76 ->resize_shadow_controller() | 76 ->resize_shadow_controller() |
77 ->GetShadowForWindowForTest(window_); | 77 ->GetShadowForWindowForTest(window_); |
78 return resize_shadow ? resize_shadow->GetLastHitTestForTest() : HTNOWHERE; | 78 return resize_shadow ? resize_shadow->GetLastHitTestForTest() : HTNOWHERE; |
79 } | 79 } |
80 | 80 |
81 // Returns true if there is a resize shadow. | 81 // Returns true if there is a resize shadow. |
82 bool HasResizeShadow() const { | 82 bool HasResizeShadow() const { return ResizeShadowHitTest() != HTNOWHERE; } |
83 return ResizeShadowHitTest() != HTNOWHERE; | |
84 } | |
85 | 83 |
86 // Returns the current cursor type. | 84 // Returns the current cursor type. |
87 int GetCurrentCursorType() const { | 85 int GetCurrentCursorType() const { |
88 CursorManagerTestApi test_api(ash::Shell::GetInstance()->cursor_manager()); | 86 CursorManagerTestApi test_api(ash::Shell::GetInstance()->cursor_manager()); |
89 return test_api.GetCurrentCursor().native_type(); | 87 return test_api.GetCurrentCursor().native_type(); |
90 } | 88 } |
91 | 89 |
92 // Called for each step of a scroll sequence initiated at the bottom right | 90 // Called for each step of a scroll sequence initiated at the bottom right |
93 // corner of |window_|. Tests whether the resize shadow is shown. | 91 // corner of |window_|. Tests whether the resize shadow is shown. |
94 void ProcessBottomRightResizeGesture(ui::EventType type, | 92 void ProcessBottomRightResizeGesture(ui::EventType type, |
95 const gfx::Vector2dF& delta) { | 93 const gfx::Vector2dF& delta) { |
96 if (type == ui::ET_GESTURE_SCROLL_END) { | 94 if (type == ui::ET_GESTURE_SCROLL_END) { |
97 // After gesture scroll ends, there should be no resize shadow. | 95 // After gesture scroll ends, there should be no resize shadow. |
98 EXPECT_FALSE(HasResizeShadow()); | 96 EXPECT_FALSE(HasResizeShadow()); |
99 } else { | 97 } else { |
100 EXPECT_EQ(HTBOTTOMRIGHT, ResizeShadowHitTest()); | 98 EXPECT_EQ(HTBOTTOMRIGHT, ResizeShadowHitTest()); |
101 } | 99 } |
102 } | 100 } |
103 | 101 |
104 aura::Window* window() { | 102 aura::Window* window() { return window_; } |
105 return window_; | |
106 } | |
107 | 103 |
108 private: | 104 private: |
109 aura::Window* window_; | 105 aura::Window* window_; |
110 | 106 |
111 DISALLOW_COPY_AND_ASSIGN(ResizeShadowAndCursorTest); | 107 DISALLOW_COPY_AND_ASSIGN(ResizeShadowAndCursorTest); |
112 }; | 108 }; |
113 | 109 |
114 // Test whether the resize shadows are visible and the cursor type based on the | 110 // Test whether the resize shadows are visible and the cursor type based on the |
115 // mouse's position. | 111 // mouse's position. |
116 TEST_F(ResizeShadowAndCursorTest, MouseHover) { | 112 TEST_F(ResizeShadowAndCursorTest, MouseHover) { |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 } | 175 } |
180 | 176 |
181 // Test that the resize shadows stay visible while resizing a window via touch. | 177 // Test that the resize shadows stay visible while resizing a window via touch. |
182 TEST_F(ResizeShadowAndCursorTest, Touch) { | 178 TEST_F(ResizeShadowAndCursorTest, Touch) { |
183 ASSERT_TRUE(ash::wm::GetWindowState(window())->IsNormalStateType()); | 179 ASSERT_TRUE(ash::wm::GetWindowState(window())->IsNormalStateType()); |
184 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); | 180 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
185 | 181 |
186 int start_x = 200 + ash::kResizeOutsideBoundsSize - 1; | 182 int start_x = 200 + ash::kResizeOutsideBoundsSize - 1; |
187 int start_y = 100 + ash::kResizeOutsideBoundsSize - 1; | 183 int start_y = 100 + ash::kResizeOutsideBoundsSize - 1; |
188 generator.GestureScrollSequenceWithCallback( | 184 generator.GestureScrollSequenceWithCallback( |
189 gfx::Point(start_x, start_y), | 185 gfx::Point(start_x, start_y), gfx::Point(start_x + 50, start_y + 50), |
190 gfx::Point(start_x + 50, start_y + 50), | 186 base::TimeDelta::FromMilliseconds(200), 3, |
191 base::TimeDelta::FromMilliseconds(200), | |
192 3, | |
193 base::Bind(&ResizeShadowAndCursorTest::ProcessBottomRightResizeGesture, | 187 base::Bind(&ResizeShadowAndCursorTest::ProcessBottomRightResizeGesture, |
194 base::Unretained(this))); | 188 base::Unretained(this))); |
195 } | 189 } |
196 | 190 |
197 // Test that the resize shadows are not visible and that the default cursor is | 191 // Test that the resize shadows are not visible and that the default cursor is |
198 // used when the window is maximized. | 192 // used when the window is maximized. |
199 TEST_F(ResizeShadowAndCursorTest, MaximizeRestore) { | 193 TEST_F(ResizeShadowAndCursorTest, MaximizeRestore) { |
200 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); | 194 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
201 ASSERT_TRUE(ash::wm::GetWindowState(window())->IsNormalStateType()); | 195 ASSERT_TRUE(ash::wm::GetWindowState(window())->IsNormalStateType()); |
202 | 196 |
(...skipping 16 matching lines...) Expand all Loading... |
219 generator.MoveMouseTo(200, 50); | 213 generator.MoveMouseTo(200, 50); |
220 EXPECT_EQ(HTRIGHT, ResizeShadowHitTest()); | 214 EXPECT_EQ(HTRIGHT, ResizeShadowHitTest()); |
221 EXPECT_EQ(ui::kCursorEastResize, GetCurrentCursorType()); | 215 EXPECT_EQ(ui::kCursorEastResize, GetCurrentCursorType()); |
222 generator.MoveMouseTo(200 - ash::kResizeInsideBoundsSize, 50); | 216 generator.MoveMouseTo(200 - ash::kResizeInsideBoundsSize, 50); |
223 EXPECT_EQ(HTRIGHT, ResizeShadowHitTest()); | 217 EXPECT_EQ(HTRIGHT, ResizeShadowHitTest()); |
224 EXPECT_EQ(ui::kCursorEastResize, GetCurrentCursorType()); | 218 EXPECT_EQ(ui::kCursorEastResize, GetCurrentCursorType()); |
225 } | 219 } |
226 | 220 |
227 } // namespace test | 221 } // namespace test |
228 } // namespace ash | 222 } // namespace ash |
OLD | NEW |