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/test/event_generator.h" | |
15 #include "ui/aura/window_event_dispatcher.h" | 14 #include "ui/aura/window_event_dispatcher.h" |
16 #include "ui/base/cursor/cursor.h" | 15 #include "ui/base/cursor/cursor.h" |
17 #include "ui/base/hit_test.h" | 16 #include "ui/base/hit_test.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 { |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 | 109 |
110 private: | 110 private: |
111 aura::Window* window_; | 111 aura::Window* window_; |
112 | 112 |
113 DISALLOW_COPY_AND_ASSIGN(ResizeShadowAndCursorTest); | 113 DISALLOW_COPY_AND_ASSIGN(ResizeShadowAndCursorTest); |
114 }; | 114 }; |
115 | 115 |
116 // Test whether the resize shadows are visible and the cursor type based on the | 116 // Test whether the resize shadows are visible and the cursor type based on the |
117 // mouse's position. | 117 // mouse's position. |
118 TEST_F(ResizeShadowAndCursorTest, MouseHover) { | 118 TEST_F(ResizeShadowAndCursorTest, MouseHover) { |
119 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); | 119 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
120 ASSERT_TRUE(ash::wm::GetWindowState(window())->IsNormalStateType()); | 120 ASSERT_TRUE(ash::wm::GetWindowState(window())->IsNormalStateType()); |
121 | 121 |
122 generator.MoveMouseTo(50, 50); | 122 generator.MoveMouseTo(50, 50); |
123 EXPECT_FALSE(HasResizeShadow()); | 123 EXPECT_FALSE(HasResizeShadow()); |
124 EXPECT_EQ(ui::kCursorNull, GetCurrentCursorType()); | 124 EXPECT_EQ(ui::kCursorNull, GetCurrentCursorType()); |
125 | 125 |
126 generator.MoveMouseTo(gfx::Point(50, 0)); | 126 generator.MoveMouseTo(gfx::Point(50, 0)); |
127 EXPECT_EQ(HTTOP, ResizeShadowHitTest()); | 127 EXPECT_EQ(HTTOP, ResizeShadowHitTest()); |
128 EXPECT_EQ(ui::kCursorNorthResize, GetCurrentCursorType()); | 128 EXPECT_EQ(ui::kCursorNorthResize, GetCurrentCursorType()); |
129 | 129 |
(...skipping 22 matching lines...) Expand all Loading... |
152 EXPECT_EQ(ui::kCursorSouthResize, GetCurrentCursorType()); | 152 EXPECT_EQ(ui::kCursorSouthResize, GetCurrentCursorType()); |
153 | 153 |
154 generator.MoveMouseTo(50, 100 - ash::kResizeInsideBoundsSize - 10); | 154 generator.MoveMouseTo(50, 100 - ash::kResizeInsideBoundsSize - 10); |
155 EXPECT_FALSE(HasResizeShadow()); | 155 EXPECT_FALSE(HasResizeShadow()); |
156 EXPECT_EQ(ui::kCursorNull, GetCurrentCursorType()); | 156 EXPECT_EQ(ui::kCursorNull, GetCurrentCursorType()); |
157 } | 157 } |
158 | 158 |
159 // Test that the resize shadows stay visible and that the cursor stays the same | 159 // Test that the resize shadows stay visible and that the cursor stays the same |
160 // as long as a user is resizing a window. | 160 // as long as a user is resizing a window. |
161 TEST_F(ResizeShadowAndCursorTest, MouseDrag) { | 161 TEST_F(ResizeShadowAndCursorTest, MouseDrag) { |
162 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); | 162 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
163 ASSERT_TRUE(ash::wm::GetWindowState(window())->IsNormalStateType()); | 163 ASSERT_TRUE(ash::wm::GetWindowState(window())->IsNormalStateType()); |
164 gfx::Size initial_size(window()->bounds().size()); | 164 gfx::Size initial_size(window()->bounds().size()); |
165 | 165 |
166 generator.MoveMouseTo(200, 50); | 166 generator.MoveMouseTo(200, 50); |
167 generator.PressLeftButton(); | 167 generator.PressLeftButton(); |
168 EXPECT_EQ(HTRIGHT, ResizeShadowHitTest()); | 168 EXPECT_EQ(HTRIGHT, ResizeShadowHitTest()); |
169 EXPECT_EQ(ui::kCursorEastResize, GetCurrentCursorType()); | 169 EXPECT_EQ(ui::kCursorEastResize, GetCurrentCursorType()); |
170 | 170 |
171 generator.MoveMouseTo(210, 50); | 171 generator.MoveMouseTo(210, 50); |
172 EXPECT_EQ(HTRIGHT, ResizeShadowHitTest()); | 172 EXPECT_EQ(HTRIGHT, ResizeShadowHitTest()); |
173 EXPECT_EQ(ui::kCursorEastResize, GetCurrentCursorType()); | 173 EXPECT_EQ(ui::kCursorEastResize, GetCurrentCursorType()); |
174 | 174 |
175 generator.ReleaseLeftButton(); | 175 generator.ReleaseLeftButton(); |
176 EXPECT_EQ(HTRIGHT, ResizeShadowHitTest()); | 176 EXPECT_EQ(HTRIGHT, ResizeShadowHitTest()); |
177 EXPECT_EQ(ui::kCursorEastResize, GetCurrentCursorType()); | 177 EXPECT_EQ(ui::kCursorEastResize, GetCurrentCursorType()); |
178 | 178 |
179 gfx::Size new_size(window()->bounds().size()); | 179 gfx::Size new_size(window()->bounds().size()); |
180 EXPECT_NE(new_size.ToString(), initial_size.ToString()); | 180 EXPECT_NE(new_size.ToString(), initial_size.ToString()); |
181 } | 181 } |
182 | 182 |
183 // Test that the resize shadows stay visible while resizing a window via touch. | 183 // Test that the resize shadows stay visible while resizing a window via touch. |
184 TEST_F(ResizeShadowAndCursorTest, Touch) { | 184 TEST_F(ResizeShadowAndCursorTest, Touch) { |
185 ASSERT_TRUE(ash::wm::GetWindowState(window())->IsNormalStateType()); | 185 ASSERT_TRUE(ash::wm::GetWindowState(window())->IsNormalStateType()); |
186 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); | 186 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
187 | 187 |
188 int start_x = 200 + ash::kResizeOutsideBoundsSize - 1; | 188 int start_x = 200 + ash::kResizeOutsideBoundsSize - 1; |
189 int start_y = 100 + ash::kResizeOutsideBoundsSize - 1; | 189 int start_y = 100 + ash::kResizeOutsideBoundsSize - 1; |
190 generator.GestureScrollSequenceWithCallback( | 190 generator.GestureScrollSequenceWithCallback( |
191 gfx::Point(start_x, start_y), | 191 gfx::Point(start_x, start_y), |
192 gfx::Point(start_x + 50, start_y + 50), | 192 gfx::Point(start_x + 50, start_y + 50), |
193 base::TimeDelta::FromMilliseconds(200), | 193 base::TimeDelta::FromMilliseconds(200), |
194 3, | 194 3, |
195 base::Bind(&ResizeShadowAndCursorTest::ProcessBottomRightResizeGesture, | 195 base::Bind(&ResizeShadowAndCursorTest::ProcessBottomRightResizeGesture, |
196 base::Unretained(this))); | 196 base::Unretained(this))); |
197 } | 197 } |
198 | 198 |
199 // Test that the resize shadows are not visible and that the default cursor is | 199 // Test that the resize shadows are not visible and that the default cursor is |
200 // used when the window is maximized. | 200 // used when the window is maximized. |
201 TEST_F(ResizeShadowAndCursorTest, MaximizeRestore) { | 201 TEST_F(ResizeShadowAndCursorTest, MaximizeRestore) { |
202 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); | 202 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
203 ASSERT_TRUE(ash::wm::GetWindowState(window())->IsNormalStateType()); | 203 ASSERT_TRUE(ash::wm::GetWindowState(window())->IsNormalStateType()); |
204 | 204 |
205 generator.MoveMouseTo(200, 50); | 205 generator.MoveMouseTo(200, 50); |
206 EXPECT_EQ(HTRIGHT, ResizeShadowHitTest()); | 206 EXPECT_EQ(HTRIGHT, ResizeShadowHitTest()); |
207 EXPECT_EQ(ui::kCursorEastResize, GetCurrentCursorType()); | 207 EXPECT_EQ(ui::kCursorEastResize, GetCurrentCursorType()); |
208 generator.MoveMouseTo(200 - ash::kResizeInsideBoundsSize, 50); | 208 generator.MoveMouseTo(200 - ash::kResizeInsideBoundsSize, 50); |
209 EXPECT_EQ(HTRIGHT, ResizeShadowHitTest()); | 209 EXPECT_EQ(HTRIGHT, ResizeShadowHitTest()); |
210 EXPECT_EQ(ui::kCursorEastResize, GetCurrentCursorType()); | 210 EXPECT_EQ(ui::kCursorEastResize, GetCurrentCursorType()); |
211 | 211 |
212 ash::wm::GetWindowState(window())->Maximize(); | 212 ash::wm::GetWindowState(window())->Maximize(); |
213 gfx::Rect bounds(window()->GetBoundsInRootWindow()); | 213 gfx::Rect bounds(window()->GetBoundsInRootWindow()); |
214 gfx::Point right_center(bounds.right() - 1, | 214 gfx::Point right_center(bounds.right() - 1, |
215 (bounds.y() + bounds.bottom()) / 2); | 215 (bounds.y() + bounds.bottom()) / 2); |
216 generator.MoveMouseTo(right_center); | 216 generator.MoveMouseTo(right_center); |
217 EXPECT_FALSE(HasResizeShadow()); | 217 EXPECT_FALSE(HasResizeShadow()); |
218 EXPECT_EQ(ui::kCursorNull, GetCurrentCursorType()); | 218 EXPECT_EQ(ui::kCursorNull, GetCurrentCursorType()); |
219 | 219 |
220 ash::wm::GetWindowState(window())->Restore(); | 220 ash::wm::GetWindowState(window())->Restore(); |
221 generator.MoveMouseTo(200, 50); | 221 generator.MoveMouseTo(200, 50); |
222 EXPECT_EQ(HTRIGHT, ResizeShadowHitTest()); | 222 EXPECT_EQ(HTRIGHT, ResizeShadowHitTest()); |
223 EXPECT_EQ(ui::kCursorEastResize, GetCurrentCursorType()); | 223 EXPECT_EQ(ui::kCursorEastResize, GetCurrentCursorType()); |
224 generator.MoveMouseTo(200 - ash::kResizeInsideBoundsSize, 50); | 224 generator.MoveMouseTo(200 - ash::kResizeInsideBoundsSize, 50); |
225 EXPECT_EQ(HTRIGHT, ResizeShadowHitTest()); | 225 EXPECT_EQ(HTRIGHT, ResizeShadowHitTest()); |
226 EXPECT_EQ(ui::kCursorEastResize, GetCurrentCursorType()); | 226 EXPECT_EQ(ui::kCursorEastResize, GetCurrentCursorType()); |
227 } | 227 } |
228 | 228 |
229 } // namespace test | 229 } // namespace test |
230 } // namespace ash | 230 } // namespace ash |
OLD | NEW |