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/frame_maximize_button.h" | 5 #include "ash/wm/caption_buttons/frame_maximize_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_container_view.h" | 10 #include "ash/wm/caption_buttons/frame_caption_button_container_view.h" |
11 #include "ash/wm/caption_buttons/maximize_bubble_controller.h" | 11 #include "ash/wm/caption_buttons/maximize_bubble_controller.h" |
12 #include "ash/wm/property_util.h" | 12 #include "ash/wm/window_state.h" |
13 #include "ash/wm/window_util.h" | 13 #include "ash/wm/window_util.h" |
14 #include "ash/wm/workspace/snap_sizer.h" | 14 #include "ash/wm/workspace/snap_sizer.h" |
15 #include "base/command_line.h" | 15 #include "base/command_line.h" |
16 #include "ui/aura/client/aura_constants.h" | 16 #include "ui/aura/client/aura_constants.h" |
17 #include "ui/aura/client/focus_client.h" | 17 #include "ui/aura/client/focus_client.h" |
18 #include "ui/aura/root_window.h" | 18 #include "ui/aura/root_window.h" |
19 #include "ui/aura/test/event_generator.h" | 19 #include "ui/aura/test/event_generator.h" |
20 #include "ui/aura/window.h" | 20 #include "ui/aura/window.h" |
21 #include "ui/base/gestures/gesture_configuration.h" | 21 #include "ui/base/gestures/gesture_configuration.h" |
22 #include "ui/events/event_utils.h" | 22 #include "ui/events/event_utils.h" |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 private: | 159 private: |
160 views::Widget* widget_; | 160 views::Widget* widget_; |
161 FrameMaximizeButton* maximize_button_; | 161 FrameMaximizeButton* maximize_button_; |
162 | 162 |
163 DISALLOW_COPY_AND_ASSIGN(FrameMaximizeButtonTest); | 163 DISALLOW_COPY_AND_ASSIGN(FrameMaximizeButtonTest); |
164 }; | 164 }; |
165 | 165 |
166 // Tests that clicking on the resize-button toggles between maximize and normal | 166 // Tests that clicking on the resize-button toggles between maximize and normal |
167 // state. | 167 // state. |
168 TEST_F(FrameMaximizeButtonTest, ResizeButtonToggleMaximize) { | 168 TEST_F(FrameMaximizeButtonTest, ResizeButtonToggleMaximize) { |
169 aura::Window* window = widget()->GetNativeWindow(); | 169 wm::WindowState* window_state = |
| 170 wm::GetWindowState(widget()->GetNativeWindow()); |
170 views::View* view = maximize_button(); | 171 views::View* view = maximize_button(); |
171 gfx::Point center = view->GetBoundsInScreen().CenterPoint(); | 172 gfx::Point center = view->GetBoundsInScreen().CenterPoint(); |
172 | 173 |
173 aura::test::EventGenerator generator(window->GetRootWindow(), center); | 174 aura::test::EventGenerator generator( |
| 175 window_state->window()->GetRootWindow(), center); |
174 | 176 |
175 EXPECT_FALSE(ash::wm::IsWindowMaximized(window)); | 177 EXPECT_FALSE(window_state->IsMaximized()); |
176 | 178 |
177 generator.ClickLeftButton(); | 179 generator.ClickLeftButton(); |
178 RunAllPendingInMessageLoop(); | 180 RunAllPendingInMessageLoop(); |
179 EXPECT_TRUE(ash::wm::IsWindowMaximized(window)); | 181 EXPECT_TRUE(window_state->IsMaximized()); |
180 | 182 |
181 center = view->GetBoundsInScreen().CenterPoint(); | 183 center = view->GetBoundsInScreen().CenterPoint(); |
182 generator.MoveMouseTo(center); | 184 generator.MoveMouseTo(center); |
183 generator.ClickLeftButton(); | 185 generator.ClickLeftButton(); |
184 RunAllPendingInMessageLoop(); | 186 RunAllPendingInMessageLoop(); |
185 EXPECT_FALSE(ash::wm::IsWindowMaximized(window)); | 187 EXPECT_FALSE(window_state->IsMaximized()); |
186 | 188 |
187 generator.GestureTapAt(view->GetBoundsInScreen().CenterPoint()); | 189 generator.GestureTapAt(view->GetBoundsInScreen().CenterPoint()); |
188 EXPECT_TRUE(ash::wm::IsWindowMaximized(window)); | 190 EXPECT_TRUE(window_state->IsMaximized()); |
189 | 191 |
190 generator.GestureTapAt(view->GetBoundsInScreen().CenterPoint()); | 192 generator.GestureTapAt(view->GetBoundsInScreen().CenterPoint()); |
191 EXPECT_FALSE(ash::wm::IsWindowMaximized(window)); | 193 EXPECT_FALSE(window_state->IsMaximized()); |
192 | 194 |
193 generator.GestureTapDownAndUp(view->GetBoundsInScreen().CenterPoint()); | 195 generator.GestureTapDownAndUp(view->GetBoundsInScreen().CenterPoint()); |
194 EXPECT_TRUE(ash::wm::IsWindowMaximized(window)); | 196 EXPECT_TRUE(window_state->IsMaximized()); |
195 | 197 |
196 generator.GestureTapDownAndUp(view->GetBoundsInScreen().CenterPoint()); | 198 generator.GestureTapDownAndUp(view->GetBoundsInScreen().CenterPoint()); |
197 EXPECT_FALSE(ash::wm::IsWindowMaximized(window)); | 199 EXPECT_FALSE(window_state->IsMaximized()); |
198 } | 200 } |
199 | 201 |
200 #if defined(OS_WIN) | 202 #if defined(OS_WIN) |
201 // RootWindow and Display can't resize on Windows Ash. http://crbug.com/165962 | 203 // RootWindow and Display can't resize on Windows Ash. http://crbug.com/165962 |
202 #define MAYBE_ResizeButtonDrag DISABLED_ResizeButtonDrag | 204 #define MAYBE_ResizeButtonDrag DISABLED_ResizeButtonDrag |
203 #else | 205 #else |
204 #define MAYBE_ResizeButtonDrag ResizeButtonDrag | 206 #define MAYBE_ResizeButtonDrag ResizeButtonDrag |
205 #endif | 207 #endif |
206 | 208 |
207 // Tests that click+dragging on the resize-button tiles or minimizes the window. | 209 // Tests that click+dragging on the resize-button tiles or minimizes the window. |
208 TEST_F(FrameMaximizeButtonTest, MAYBE_ResizeButtonDrag) { | 210 TEST_F(FrameMaximizeButtonTest, MAYBE_ResizeButtonDrag) { |
209 aura::Window* window = widget()->GetNativeWindow(); | 211 aura::Window* window = widget()->GetNativeWindow(); |
210 views::View* view = maximize_button(); | 212 views::View* view = maximize_button(); |
211 gfx::Point center = view->GetBoundsInScreen().CenterPoint(); | 213 gfx::Point center = view->GetBoundsInScreen().CenterPoint(); |
212 | 214 |
213 aura::test::EventGenerator generator(window->GetRootWindow(), center); | 215 aura::test::EventGenerator generator(window->GetRootWindow(), center); |
214 | 216 |
215 EXPECT_TRUE(ash::wm::IsWindowNormal(window)); | 217 wm::WindowState* window_state = wm::GetWindowState(window); |
| 218 EXPECT_TRUE(window_state->IsNormalShowState()); |
216 | 219 |
217 // Snap right. | 220 // Snap right. |
218 { | 221 { |
219 generator.PressLeftButton(); | 222 generator.PressLeftButton(); |
220 generator.MoveMouseBy(10, 0); | 223 generator.MoveMouseBy(10, 0); |
221 generator.ReleaseLeftButton(); | 224 generator.ReleaseLeftButton(); |
222 RunAllPendingInMessageLoop(); | 225 RunAllPendingInMessageLoop(); |
223 | 226 |
224 EXPECT_FALSE(ash::wm::IsWindowMaximized(window)); | 227 EXPECT_FALSE(window_state->IsMaximized()); |
225 EXPECT_FALSE(ash::wm::IsWindowMinimized(window)); | 228 EXPECT_FALSE(window_state->IsMinimized()); |
226 internal::SnapSizer sizer(window, center, | 229 internal::SnapSizer sizer(window, center, |
227 internal::SnapSizer::RIGHT_EDGE, | 230 internal::SnapSizer::RIGHT_EDGE, |
228 internal::SnapSizer::OTHER_INPUT); | 231 internal::SnapSizer::OTHER_INPUT); |
229 EXPECT_EQ(sizer.target_bounds().ToString(), window->bounds().ToString()); | 232 EXPECT_EQ(sizer.target_bounds().ToString(), window->bounds().ToString()); |
230 } | 233 } |
231 | 234 |
232 // Snap left. | 235 // Snap left. |
233 { | 236 { |
234 center = view->GetBoundsInScreen().CenterPoint(); | 237 center = view->GetBoundsInScreen().CenterPoint(); |
235 generator.MoveMouseTo(center); | 238 generator.MoveMouseTo(center); |
236 generator.PressLeftButton(); | 239 generator.PressLeftButton(); |
237 generator.MoveMouseBy(-10, 0); | 240 generator.MoveMouseBy(-10, 0); |
238 generator.ReleaseLeftButton(); | 241 generator.ReleaseLeftButton(); |
239 RunAllPendingInMessageLoop(); | 242 RunAllPendingInMessageLoop(); |
240 | 243 |
241 EXPECT_FALSE(ash::wm::IsWindowMaximized(window)); | 244 EXPECT_FALSE(window_state->IsMaximized()); |
242 EXPECT_FALSE(ash::wm::IsWindowMinimized(window)); | 245 EXPECT_FALSE(window_state->IsMinimized()); |
243 internal::SnapSizer sizer(window, center, | 246 internal::SnapSizer sizer(window, center, |
244 internal::SnapSizer::LEFT_EDGE, | 247 internal::SnapSizer::LEFT_EDGE, |
245 internal::SnapSizer::OTHER_INPUT); | 248 internal::SnapSizer::OTHER_INPUT); |
246 EXPECT_EQ(sizer.target_bounds().ToString(), window->bounds().ToString()); | 249 EXPECT_EQ(sizer.target_bounds().ToString(), window->bounds().ToString()); |
247 } | 250 } |
248 | 251 |
249 // Minimize. | 252 // Minimize. |
250 { | 253 { |
251 center = view->GetBoundsInScreen().CenterPoint(); | 254 center = view->GetBoundsInScreen().CenterPoint(); |
252 generator.MoveMouseTo(center); | 255 generator.MoveMouseTo(center); |
253 generator.PressLeftButton(); | 256 generator.PressLeftButton(); |
254 generator.MoveMouseBy(0, 10); | 257 generator.MoveMouseBy(0, 10); |
255 generator.ReleaseLeftButton(); | 258 generator.ReleaseLeftButton(); |
256 RunAllPendingInMessageLoop(); | 259 RunAllPendingInMessageLoop(); |
257 | 260 |
258 EXPECT_TRUE(ash::wm::IsWindowMinimized(window)); | 261 EXPECT_TRUE(window_state->IsMinimized()); |
259 } | 262 } |
260 | 263 |
261 ash::wm::RestoreWindow(window); | 264 window_state->Restore(); |
262 | 265 |
263 // Now test the same behaviour for gesture events. | 266 // Now test the same behaviour for gesture events. |
264 | 267 |
265 // Snap right. | 268 // Snap right. |
266 { | 269 { |
267 center = view->GetBoundsInScreen().CenterPoint(); | 270 center = view->GetBoundsInScreen().CenterPoint(); |
268 gfx::Point end = center; | 271 gfx::Point end = center; |
269 end.Offset(80, 0); | 272 end.Offset(80, 0); |
270 generator.GestureScrollSequence(center, end, | 273 generator.GestureScrollSequence(center, end, |
271 base::TimeDelta::FromMilliseconds(100), | 274 base::TimeDelta::FromMilliseconds(100), |
272 3); | 275 3); |
273 RunAllPendingInMessageLoop(); | 276 RunAllPendingInMessageLoop(); |
274 | 277 |
275 EXPECT_FALSE(ash::wm::IsWindowMaximized(window)); | 278 EXPECT_FALSE(window_state->IsMaximized()); |
276 EXPECT_FALSE(ash::wm::IsWindowMinimized(window)); | 279 EXPECT_FALSE(window_state->IsMinimized()); |
277 // This is a short resizing distance and different touch behavior | 280 // This is a short resizing distance and different touch behavior |
278 // applies which leads in half of the screen being used. | 281 // applies which leads in half of the screen being used. |
279 EXPECT_EQ("400,0 400x553", window->bounds().ToString()); | 282 EXPECT_EQ("400,0 400x553", window->bounds().ToString()); |
280 } | 283 } |
281 | 284 |
282 // Snap left. | 285 // Snap left. |
283 { | 286 { |
284 center = view->GetBoundsInScreen().CenterPoint(); | 287 center = view->GetBoundsInScreen().CenterPoint(); |
285 gfx::Point end = center; | 288 gfx::Point end = center; |
286 end.Offset(-80, 0); | 289 end.Offset(-80, 0); |
287 generator.GestureScrollSequence(center, end, | 290 generator.GestureScrollSequence(center, end, |
288 base::TimeDelta::FromMilliseconds(100), | 291 base::TimeDelta::FromMilliseconds(100), |
289 3); | 292 3); |
290 RunAllPendingInMessageLoop(); | 293 RunAllPendingInMessageLoop(); |
291 | 294 |
292 EXPECT_FALSE(ash::wm::IsWindowMaximized(window)); | 295 EXPECT_FALSE(window_state->IsMaximized()); |
293 EXPECT_FALSE(ash::wm::IsWindowMinimized(window)); | 296 EXPECT_FALSE(window_state->IsMinimized()); |
294 internal::SnapSizer sizer(window, center, | 297 internal::SnapSizer sizer(window, center, |
295 internal::SnapSizer::LEFT_EDGE, | 298 internal::SnapSizer::LEFT_EDGE, |
296 internal::SnapSizer::OTHER_INPUT); | 299 internal::SnapSizer::OTHER_INPUT); |
297 EXPECT_EQ(sizer.target_bounds().ToString(), window->bounds().ToString()); | 300 EXPECT_EQ(sizer.target_bounds().ToString(), window->bounds().ToString()); |
298 } | 301 } |
299 | 302 |
300 // Minimize. | 303 // Minimize. |
301 { | 304 { |
302 center = view->GetBoundsInScreen().CenterPoint(); | 305 center = view->GetBoundsInScreen().CenterPoint(); |
303 gfx::Point end = center; | 306 gfx::Point end = center; |
304 end.Offset(0, 40); | 307 end.Offset(0, 40); |
305 generator.GestureScrollSequence(center, end, | 308 generator.GestureScrollSequence(center, end, |
306 base::TimeDelta::FromMilliseconds(100), | 309 base::TimeDelta::FromMilliseconds(100), |
307 3); | 310 3); |
308 RunAllPendingInMessageLoop(); | 311 RunAllPendingInMessageLoop(); |
309 | 312 |
310 EXPECT_TRUE(ash::wm::IsWindowMinimized(window)); | 313 EXPECT_TRUE(window_state->IsMinimized()); |
311 } | 314 } |
312 | 315 |
313 // Test with gesture events. | 316 // Test with gesture events. |
314 } | 317 } |
315 | 318 |
316 #if defined(OS_WIN) | 319 #if defined(OS_WIN) |
317 // RootWindow and Display can't resize on Windows Ash. http://crbug.com/165962 | 320 // RootWindow and Display can't resize on Windows Ash. http://crbug.com/165962 |
318 #define MAYBE_TouchDragResizeCloseToCornerDiffersFromMouse \ | 321 #define MAYBE_TouchDragResizeCloseToCornerDiffersFromMouse \ |
319 DISABLED_TouchDragResizeCloseToCornerDiffersFromMouse | 322 DISABLED_TouchDragResizeCloseToCornerDiffersFromMouse |
320 #else | 323 #else |
(...skipping 11 matching lines...) Expand all Loading... |
332 gfx::Rect work_area = widget()->GetWorkAreaBoundsInScreen(); | 335 gfx::Rect work_area = widget()->GetWorkAreaBoundsInScreen(); |
333 gfx::Rect bounds = window->bounds(); | 336 gfx::Rect bounds = window->bounds(); |
334 bounds.set_x(work_area.width() - bounds.width()); | 337 bounds.set_x(work_area.width() - bounds.width()); |
335 widget()->SetBounds(bounds); | 338 widget()->SetBounds(bounds); |
336 | 339 |
337 gfx::Point start_point = view->GetBoundsInScreen().CenterPoint(); | 340 gfx::Point start_point = view->GetBoundsInScreen().CenterPoint(); |
338 // We want to move all the way to the right (the few pixels we have). | 341 // We want to move all the way to the right (the few pixels we have). |
339 gfx::Point end_point = gfx::Point(work_area.width(), start_point.y()); | 342 gfx::Point end_point = gfx::Point(work_area.width(), start_point.y()); |
340 | 343 |
341 aura::test::EventGenerator generator(window->GetRootWindow(), start_point); | 344 aura::test::EventGenerator generator(window->GetRootWindow(), start_point); |
| 345 wm::WindowState* window_state = wm::GetWindowState(window); |
342 | 346 |
343 EXPECT_TRUE(ash::wm::IsWindowNormal(window)); | 347 EXPECT_TRUE(window_state->IsNormalShowState()); |
344 | 348 |
345 // Snap right with a touch drag. | 349 // Snap right with a touch drag. |
346 generator.GestureScrollSequence(start_point, | 350 generator.GestureScrollSequence(start_point, |
347 end_point, | 351 end_point, |
348 base::TimeDelta::FromMilliseconds(100), | 352 base::TimeDelta::FromMilliseconds(100), |
349 10); | 353 10); |
350 RunAllPendingInMessageLoop(); | 354 RunAllPendingInMessageLoop(); |
351 | 355 |
352 EXPECT_FALSE(ash::wm::IsWindowMaximized(window)); | 356 EXPECT_FALSE(window_state->IsMaximized()); |
353 EXPECT_FALSE(ash::wm::IsWindowMinimized(window)); | 357 EXPECT_FALSE(window_state->IsMinimized()); |
354 gfx::Rect touch_result = window->bounds(); | 358 gfx::Rect touch_result = window->bounds(); |
355 EXPECT_NE(bounds.ToString(), touch_result.ToString()); | 359 EXPECT_NE(bounds.ToString(), touch_result.ToString()); |
356 | 360 |
357 // Set the position back to where it was before and re-try with a mouse. | 361 // Set the position back to where it was before and re-try with a mouse. |
358 widget()->SetBounds(bounds); | 362 widget()->SetBounds(bounds); |
359 | 363 |
360 generator.MoveMouseTo(start_point); | 364 generator.MoveMouseTo(start_point); |
361 generator.PressLeftButton(); | 365 generator.PressLeftButton(); |
362 generator.MoveMouseTo(end_point, 10); | 366 generator.MoveMouseTo(end_point, 10); |
363 generator.ReleaseLeftButton(); | 367 generator.ReleaseLeftButton(); |
364 RunAllPendingInMessageLoop(); | 368 RunAllPendingInMessageLoop(); |
365 | 369 |
366 EXPECT_FALSE(ash::wm::IsWindowMaximized(window)); | 370 EXPECT_FALSE(window_state->IsMaximized()); |
367 EXPECT_FALSE(ash::wm::IsWindowMinimized(window)); | 371 EXPECT_FALSE(window_state->IsMinimized()); |
368 gfx::Rect mouse_result = window->bounds(); | 372 gfx::Rect mouse_result = window->bounds(); |
369 | 373 |
370 // The difference between the two operations should be that the mouse | 374 // The difference between the two operations should be that the mouse |
371 // operation should have just started to resize and the touch operation is | 375 // operation should have just started to resize and the touch operation is |
372 // already all the way down to the smallest possible size. | 376 // already all the way down to the smallest possible size. |
373 EXPECT_NE(mouse_result.ToString(), touch_result.ToString()); | 377 EXPECT_NE(mouse_result.ToString(), touch_result.ToString()); |
374 EXPECT_GT(mouse_result.width(), touch_result.width()); | 378 EXPECT_GT(mouse_result.width(), touch_result.width()); |
375 } | 379 } |
376 | 380 |
377 // Test that closing the (browser) window with an opened balloon does not | 381 // Test that closing the (browser) window with an opened balloon does not |
378 // crash the system. In other words: Make sure that shutting down the frame | 382 // crash the system. In other words: Make sure that shutting down the frame |
379 // destroys the opened balloon in an orderly fashion. | 383 // destroys the opened balloon in an orderly fashion. |
380 TEST_F(FrameMaximizeButtonTest, MaximizeButtonExternalShutDown) { | 384 TEST_F(FrameMaximizeButtonTest, MaximizeButtonExternalShutDown) { |
381 aura::Window* window = widget()->GetNativeWindow(); | 385 aura::Window* window = widget()->GetNativeWindow(); |
382 ash::FrameMaximizeButton* maximize_button = | 386 ash::FrameMaximizeButton* maximize_button = |
383 FrameMaximizeButtonTest::maximize_button(); | 387 FrameMaximizeButtonTest::maximize_button(); |
384 maximize_button->set_bubble_appearance_delay_ms(0); | 388 maximize_button->set_bubble_appearance_delay_ms(0); |
385 gfx::Point button_pos = maximize_button->GetBoundsInScreen().CenterPoint(); | 389 gfx::Point button_pos = maximize_button->GetBoundsInScreen().CenterPoint(); |
386 gfx::Point off_pos(button_pos.x() + 100, button_pos.y() + 100); | 390 gfx::Point off_pos(button_pos.x() + 100, button_pos.y() + 100); |
387 | 391 |
388 aura::test::EventGenerator generator(window->GetRootWindow(), off_pos); | 392 aura::test::EventGenerator generator(window->GetRootWindow(), off_pos); |
389 EXPECT_FALSE(maximize_button->maximizer()); | 393 EXPECT_FALSE(maximize_button->maximizer()); |
390 EXPECT_TRUE(ash::wm::IsWindowNormal(window)); | 394 EXPECT_TRUE(wm::GetWindowState(window)->IsNormalShowState()); |
391 | 395 |
392 // Move the mouse cursor over the button to bring up the maximizer bubble. | 396 // Move the mouse cursor over the button to bring up the maximizer bubble. |
393 generator.MoveMouseTo(button_pos); | 397 generator.MoveMouseTo(button_pos); |
394 EXPECT_TRUE(maximize_button->maximizer()); | 398 EXPECT_TRUE(maximize_button->maximizer()); |
395 | 399 |
396 // Even though the widget is closing the bubble menu should not crash upon | 400 // Even though the widget is closing the bubble menu should not crash upon |
397 // its delayed destruction. | 401 // its delayed destruction. |
398 CloseWidget(); | 402 CloseWidget(); |
399 } | 403 } |
400 | 404 |
401 // Test that maximizing the browser after hovering in does not crash the system | 405 // Test that maximizing the browser after hovering in does not crash the system |
402 // when the observer gets removed in the bubble destruction process. | 406 // when the observer gets removed in the bubble destruction process. |
403 TEST_F(FrameMaximizeButtonTest, MaximizeOnHoverThenClick) { | 407 TEST_F(FrameMaximizeButtonTest, MaximizeOnHoverThenClick) { |
404 aura::Window* window = widget()->GetNativeWindow(); | 408 aura::Window* window = widget()->GetNativeWindow(); |
405 ash::FrameMaximizeButton* maximize_button = | 409 ash::FrameMaximizeButton* maximize_button = |
406 FrameMaximizeButtonTest::maximize_button(); | 410 FrameMaximizeButtonTest::maximize_button(); |
407 maximize_button->set_bubble_appearance_delay_ms(0); | 411 maximize_button->set_bubble_appearance_delay_ms(0); |
408 gfx::Point button_pos = maximize_button->GetBoundsInScreen().CenterPoint(); | 412 gfx::Point button_pos = maximize_button->GetBoundsInScreen().CenterPoint(); |
409 gfx::Point off_pos(button_pos.x() + 100, button_pos.y() + 100); | 413 gfx::Point off_pos(button_pos.x() + 100, button_pos.y() + 100); |
410 | 414 |
411 aura::test::EventGenerator generator(window->GetRootWindow(), off_pos); | 415 aura::test::EventGenerator generator(window->GetRootWindow(), off_pos); |
412 EXPECT_FALSE(maximize_button->maximizer()); | 416 EXPECT_FALSE(maximize_button->maximizer()); |
413 EXPECT_TRUE(ash::wm::IsWindowNormal(window)); | 417 EXPECT_TRUE(wm::GetWindowState(window)->IsNormalShowState()); |
414 | 418 |
415 // Move the mouse cursor over the button to bring up the maximizer bubble. | 419 // Move the mouse cursor over the button to bring up the maximizer bubble. |
416 generator.MoveMouseTo(button_pos); | 420 generator.MoveMouseTo(button_pos); |
417 EXPECT_TRUE(maximize_button->maximizer()); | 421 EXPECT_TRUE(maximize_button->maximizer()); |
418 generator.ClickLeftButton(); | 422 generator.ClickLeftButton(); |
419 EXPECT_TRUE(ash::wm::IsWindowMaximized(window)); | 423 EXPECT_TRUE(wm::GetWindowState(window)->IsMaximized()); |
420 } | 424 } |
421 | 425 |
422 // Test that hovering over a button in the balloon dialog will show the phantom | 426 // Test that hovering over a button in the balloon dialog will show the phantom |
423 // window. Moving then away from the button will hide it again. Then check that | 427 // window. Moving then away from the button will hide it again. Then check that |
424 // pressing and dragging the button itself off the button will also release the | 428 // pressing and dragging the button itself off the button will also release the |
425 // phantom window. | 429 // phantom window. |
426 TEST_F(FrameMaximizeButtonTest, MaximizeLeftButtonDragOut) { | 430 TEST_F(FrameMaximizeButtonTest, MaximizeLeftButtonDragOut) { |
427 aura::Window* window = widget()->GetNativeWindow(); | 431 aura::Window* window = widget()->GetNativeWindow(); |
428 ash::FrameMaximizeButton* maximize_button = | 432 ash::FrameMaximizeButton* maximize_button = |
429 FrameMaximizeButtonTest::maximize_button(); | 433 FrameMaximizeButtonTest::maximize_button(); |
430 maximize_button->set_bubble_appearance_delay_ms(0); | 434 maximize_button->set_bubble_appearance_delay_ms(0); |
431 gfx::Point button_pos = maximize_button->GetBoundsInScreen().CenterPoint(); | 435 gfx::Point button_pos = maximize_button->GetBoundsInScreen().CenterPoint(); |
432 gfx::Point off_pos(button_pos.x() + 100, button_pos.y() + 100); | 436 gfx::Point off_pos(button_pos.x() + 100, button_pos.y() + 100); |
433 | 437 |
434 aura::test::EventGenerator generator(window->GetRootWindow(), off_pos); | 438 aura::test::EventGenerator generator(window->GetRootWindow(), off_pos); |
435 EXPECT_FALSE(maximize_button->maximizer()); | 439 EXPECT_FALSE(maximize_button->maximizer()); |
436 EXPECT_TRUE(ash::wm::IsWindowNormal(window)); | 440 EXPECT_TRUE(wm::GetWindowState(window)->IsNormalShowState()); |
437 EXPECT_FALSE(maximize_button->phantom_window_open()); | 441 EXPECT_FALSE(maximize_button->phantom_window_open()); |
438 | 442 |
439 // Move the mouse cursor over the button to bring up the maximizer bubble. | 443 // Move the mouse cursor over the button to bring up the maximizer bubble. |
440 generator.MoveMouseTo(button_pos); | 444 generator.MoveMouseTo(button_pos); |
441 EXPECT_TRUE(maximize_button->maximizer()); | 445 EXPECT_TRUE(maximize_button->maximizer()); |
442 | 446 |
443 // Move the mouse over the left maximize button. | 447 // Move the mouse over the left maximize button. |
444 gfx::Point left_max_pos = maximize_button->maximizer()-> | 448 gfx::Point left_max_pos = maximize_button->maximizer()-> |
445 GetButtonForUnitTest(SNAP_LEFT)->GetBoundsInScreen().CenterPoint(); | 449 GetButtonForUnitTest(SNAP_LEFT)->GetBoundsInScreen().CenterPoint(); |
446 | 450 |
(...skipping 24 matching lines...) Expand all Loading... |
471 TEST_F(FrameMaximizeButtonTest, MaximizeLeftByButton) { | 475 TEST_F(FrameMaximizeButtonTest, MaximizeLeftByButton) { |
472 aura::Window* window = widget()->GetNativeWindow(); | 476 aura::Window* window = widget()->GetNativeWindow(); |
473 ash::FrameMaximizeButton* maximize_button = | 477 ash::FrameMaximizeButton* maximize_button = |
474 FrameMaximizeButtonTest::maximize_button(); | 478 FrameMaximizeButtonTest::maximize_button(); |
475 maximize_button->set_bubble_appearance_delay_ms(0); | 479 maximize_button->set_bubble_appearance_delay_ms(0); |
476 gfx::Point button_pos = maximize_button->GetBoundsInScreen().CenterPoint(); | 480 gfx::Point button_pos = maximize_button->GetBoundsInScreen().CenterPoint(); |
477 gfx::Point off_pos(button_pos.x() + 100, button_pos.y() + 100); | 481 gfx::Point off_pos(button_pos.x() + 100, button_pos.y() + 100); |
478 | 482 |
479 aura::test::EventGenerator generator(window->GetRootWindow(), off_pos); | 483 aura::test::EventGenerator generator(window->GetRootWindow(), off_pos); |
480 EXPECT_FALSE(maximize_button->maximizer()); | 484 EXPECT_FALSE(maximize_button->maximizer()); |
481 EXPECT_TRUE(ash::wm::IsWindowNormal(window)); | 485 EXPECT_TRUE(wm::GetWindowState(window)->IsNormalShowState()); |
482 EXPECT_FALSE(maximize_button->phantom_window_open()); | 486 EXPECT_FALSE(maximize_button->phantom_window_open()); |
483 | 487 |
484 // Move the mouse cursor over the button to bring up the maximizer bubble. | 488 // Move the mouse cursor over the button to bring up the maximizer bubble. |
485 generator.MoveMouseTo(button_pos); | 489 generator.MoveMouseTo(button_pos); |
486 EXPECT_TRUE(maximize_button->maximizer()); | 490 EXPECT_TRUE(maximize_button->maximizer()); |
487 | 491 |
488 // Move the mouse over the left maximize button. | 492 // Move the mouse over the left maximize button. |
489 gfx::Point left_max_pos = maximize_button->maximizer()-> | 493 gfx::Point left_max_pos = maximize_button->maximizer()-> |
490 GetButtonForUnitTest(SNAP_LEFT)->GetBoundsInScreen().CenterPoint(); | 494 GetButtonForUnitTest(SNAP_LEFT)->GetBoundsInScreen().CenterPoint(); |
491 generator.MoveMouseTo(left_max_pos); | 495 generator.MoveMouseTo(left_max_pos); |
492 EXPECT_TRUE(maximize_button->phantom_window_open()); | 496 EXPECT_TRUE(maximize_button->phantom_window_open()); |
493 generator.ClickLeftButton(); | 497 generator.ClickLeftButton(); |
494 | 498 |
495 EXPECT_FALSE(maximize_button->maximizer()); | 499 EXPECT_FALSE(maximize_button->maximizer()); |
496 EXPECT_FALSE(maximize_button->phantom_window_open()); | 500 EXPECT_FALSE(maximize_button->phantom_window_open()); |
497 | 501 |
498 EXPECT_FALSE(ash::wm::IsWindowMaximized(window)); | 502 wm::WindowState* window_state = wm::GetWindowState(window); |
499 EXPECT_FALSE(ash::wm::IsWindowMinimized(window)); | 503 EXPECT_FALSE(window_state->IsMaximized()); |
| 504 EXPECT_FALSE(window_state->IsMinimized()); |
500 internal::SnapSizer sizer(window, button_pos, | 505 internal::SnapSizer sizer(window, button_pos, |
501 internal::SnapSizer::LEFT_EDGE, | 506 internal::SnapSizer::LEFT_EDGE, |
502 internal::SnapSizer::OTHER_INPUT); | 507 internal::SnapSizer::OTHER_INPUT); |
503 sizer.SelectDefaultSizeAndDisableResize(); | 508 sizer.SelectDefaultSizeAndDisableResize(); |
504 EXPECT_EQ(sizer.target_bounds().ToString(), window->bounds().ToString()); | 509 EXPECT_EQ(sizer.target_bounds().ToString(), window->bounds().ToString()); |
505 } | 510 } |
506 | 511 |
507 // Test that the activation focus does not change when the bubble gets shown. | 512 // Test that the activation focus does not change when the bubble gets shown. |
508 TEST_F(FrameMaximizeButtonTest, MaximizeKeepFocus) { | 513 TEST_F(FrameMaximizeButtonTest, MaximizeKeepFocus) { |
509 aura::Window* window = widget()->GetNativeWindow(); | 514 aura::Window* window = widget()->GetNativeWindow(); |
510 ash::FrameMaximizeButton* maximize_button = | 515 ash::FrameMaximizeButton* maximize_button = |
511 FrameMaximizeButtonTest::maximize_button(); | 516 FrameMaximizeButtonTest::maximize_button(); |
512 maximize_button->set_bubble_appearance_delay_ms(0); | 517 maximize_button->set_bubble_appearance_delay_ms(0); |
513 gfx::Point button_pos = maximize_button->GetBoundsInScreen().CenterPoint(); | 518 gfx::Point button_pos = maximize_button->GetBoundsInScreen().CenterPoint(); |
514 gfx::Point off_pos(button_pos.x() + 100, button_pos.y() + 100); | 519 gfx::Point off_pos(button_pos.x() + 100, button_pos.y() + 100); |
515 | 520 |
516 aura::test::EventGenerator generator(window->GetRootWindow(), off_pos); | 521 aura::test::EventGenerator generator(window->GetRootWindow(), off_pos); |
517 EXPECT_FALSE(maximize_button->maximizer()); | 522 EXPECT_FALSE(maximize_button->maximizer()); |
518 EXPECT_TRUE(ash::wm::IsWindowNormal(window)); | 523 EXPECT_TRUE(wm::GetWindowState(window)->IsNormalShowState()); |
519 | 524 |
520 aura::Window* active = | 525 aura::Window* active = |
521 aura::client::GetFocusClient(window)->GetFocusedWindow(); | 526 aura::client::GetFocusClient(window)->GetFocusedWindow(); |
522 | 527 |
523 // Move the mouse cursor over the button to bring up the maximizer bubble. | 528 // Move the mouse cursor over the button to bring up the maximizer bubble. |
524 generator.MoveMouseTo(button_pos); | 529 generator.MoveMouseTo(button_pos); |
525 EXPECT_TRUE(maximize_button->maximizer()); | 530 EXPECT_TRUE(maximize_button->maximizer()); |
526 | 531 |
527 // Check that the focused window is still the same. | 532 // Check that the focused window is still the same. |
528 EXPECT_EQ(active, aura::client::GetFocusClient(window)->GetFocusedWindow()); | 533 EXPECT_EQ(active, aura::client::GetFocusClient(window)->GetFocusedWindow()); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
561 TEST_F(FrameMaximizeButtonTest, OnlyLeftButtonMaximizes) { | 566 TEST_F(FrameMaximizeButtonTest, OnlyLeftButtonMaximizes) { |
562 aura::Window* window = widget()->GetNativeWindow(); | 567 aura::Window* window = widget()->GetNativeWindow(); |
563 ash::FrameMaximizeButton* maximize_button = | 568 ash::FrameMaximizeButton* maximize_button = |
564 FrameMaximizeButtonTest::maximize_button(); | 569 FrameMaximizeButtonTest::maximize_button(); |
565 maximize_button->set_bubble_appearance_delay_ms(0); | 570 maximize_button->set_bubble_appearance_delay_ms(0); |
566 gfx::Point button_pos = maximize_button->GetBoundsInScreen().CenterPoint(); | 571 gfx::Point button_pos = maximize_button->GetBoundsInScreen().CenterPoint(); |
567 gfx::Point off_pos(button_pos.x() + 100, button_pos.y() + 100); | 572 gfx::Point off_pos(button_pos.x() + 100, button_pos.y() + 100); |
568 | 573 |
569 aura::test::EventGenerator generator(window->GetRootWindow(), off_pos); | 574 aura::test::EventGenerator generator(window->GetRootWindow(), off_pos); |
570 EXPECT_FALSE(maximize_button->maximizer()); | 575 EXPECT_FALSE(maximize_button->maximizer()); |
571 EXPECT_TRUE(ash::wm::IsWindowNormal(window)); | 576 wm::WindowState* window_state = wm::GetWindowState(window); |
572 EXPECT_FALSE(ash::wm::IsWindowMaximized(window)); | 577 EXPECT_TRUE(window_state->IsNormalShowState()); |
| 578 EXPECT_FALSE(window_state->IsMaximized()); |
573 | 579 |
574 // Move the mouse cursor over the button. | 580 // Move the mouse cursor over the button. |
575 generator.MoveMouseTo(button_pos); | 581 generator.MoveMouseTo(button_pos); |
576 EXPECT_TRUE(maximize_button->maximizer()); | 582 EXPECT_TRUE(maximize_button->maximizer()); |
577 EXPECT_FALSE(maximize_button->phantom_window_open()); | 583 EXPECT_FALSE(maximize_button->phantom_window_open()); |
578 | 584 |
579 // After pressing the left button the button should get triggered. | 585 // After pressing the left button the button should get triggered. |
580 generator.PressLeftButton(); | 586 generator.PressLeftButton(); |
581 RunAllPendingInMessageLoop(); | 587 RunAllPendingInMessageLoop(); |
582 EXPECT_TRUE(maximize_button->is_snap_enabled()); | 588 EXPECT_TRUE(maximize_button->is_snap_enabled()); |
583 EXPECT_FALSE(ash::wm::IsWindowMaximized(window)); | 589 EXPECT_FALSE(window_state->IsMaximized()); |
584 | 590 |
585 // Pressing the right button then should cancel the operation. | 591 // Pressing the right button then should cancel the operation. |
586 generator.PressRightButton(); | 592 generator.PressRightButton(); |
587 RunAllPendingInMessageLoop(); | 593 RunAllPendingInMessageLoop(); |
588 EXPECT_FALSE(maximize_button->maximizer()); | 594 EXPECT_FALSE(maximize_button->maximizer()); |
589 | 595 |
590 // After releasing the second button the window shouldn't be maximized. | 596 // After releasing the second button the window shouldn't be maximized. |
591 generator.ReleaseRightButton(); | 597 generator.ReleaseRightButton(); |
592 generator.ReleaseLeftButton(); | 598 generator.ReleaseLeftButton(); |
593 RunAllPendingInMessageLoop(); | 599 RunAllPendingInMessageLoop(); |
594 EXPECT_FALSE(ash::wm::IsWindowMaximized(window)); | 600 EXPECT_FALSE(window_state->IsMaximized()); |
595 | 601 |
596 // Second experiment: Starting with right should also not trigger. | 602 // Second experiment: Starting with right should also not trigger. |
597 generator.MoveMouseTo(off_pos); | 603 generator.MoveMouseTo(off_pos); |
598 generator.MoveMouseTo(button_pos); | 604 generator.MoveMouseTo(button_pos); |
599 EXPECT_TRUE(maximize_button->maximizer()); | 605 EXPECT_TRUE(maximize_button->maximizer()); |
600 | 606 |
601 // Pressing first the right button should not activate. | 607 // Pressing first the right button should not activate. |
602 generator.PressRightButton(); | 608 generator.PressRightButton(); |
603 RunAllPendingInMessageLoop(); | 609 RunAllPendingInMessageLoop(); |
604 EXPECT_FALSE(maximize_button->is_snap_enabled()); | 610 EXPECT_FALSE(maximize_button->is_snap_enabled()); |
605 | 611 |
606 // Pressing then additionally the left button shouldn't activate either. | 612 // Pressing then additionally the left button shouldn't activate either. |
607 generator.PressLeftButton(); | 613 generator.PressLeftButton(); |
608 RunAllPendingInMessageLoop(); | 614 RunAllPendingInMessageLoop(); |
609 EXPECT_FALSE(maximize_button->is_snap_enabled()); | 615 EXPECT_FALSE(maximize_button->is_snap_enabled()); |
610 generator.ReleaseRightButton(); | 616 generator.ReleaseRightButton(); |
611 generator.ReleaseLeftButton(); | 617 generator.ReleaseLeftButton(); |
612 EXPECT_FALSE(ash::wm::IsWindowMaximized(window)); | 618 EXPECT_FALSE(window_state->IsMaximized()); |
613 } | 619 } |
614 | 620 |
615 // Click a button of window maximize functionality. | 621 // Click a button of window maximize functionality. |
616 // If |snap_type| is SNAP_NONE the FrameMaximizeButton gets clicked, otherwise | 622 // If |snap_type| is SNAP_NONE the FrameMaximizeButton gets clicked, otherwise |
617 // the associated snap button. | 623 // the associated snap button. |
618 // |Window| is the window which owns the maximize button. | 624 // |Window| is the window which owns the maximize button. |
619 // |maximize_button| is the FrameMaximizeButton which controls the window. | 625 // |maximize_button| is the FrameMaximizeButton which controls the window. |
620 void ClickMaxButton( | 626 void ClickMaxButton( |
621 ash::FrameMaximizeButton* maximize_button, | 627 ash::FrameMaximizeButton* maximize_button, |
622 aura::Window* window, | 628 aura::Window* window, |
(...skipping 24 matching lines...) Expand all Loading... |
647 | 653 |
648 // Test that the restore from left/right maximize is properly done. | 654 // Test that the restore from left/right maximize is properly done. |
649 TEST_F(FrameMaximizeButtonTest, MaximizeLeftRestore) { | 655 TEST_F(FrameMaximizeButtonTest, MaximizeLeftRestore) { |
650 aura::Window* window = widget()->GetNativeWindow(); | 656 aura::Window* window = widget()->GetNativeWindow(); |
651 gfx::Rect initial_bounds = widget()->GetWindowBoundsInScreen(); | 657 gfx::Rect initial_bounds = widget()->GetWindowBoundsInScreen(); |
652 ash::FrameMaximizeButton* maximize_button = | 658 ash::FrameMaximizeButton* maximize_button = |
653 FrameMaximizeButtonTest::maximize_button(); | 659 FrameMaximizeButtonTest::maximize_button(); |
654 maximize_button->set_bubble_appearance_delay_ms(0); | 660 maximize_button->set_bubble_appearance_delay_ms(0); |
655 | 661 |
656 ClickMaxButton(maximize_button, window, SNAP_LEFT); | 662 ClickMaxButton(maximize_button, window, SNAP_LEFT); |
| 663 wm::WindowState* window_state = wm::GetWindowState(window); |
657 // The window should not be maximized. | 664 // The window should not be maximized. |
658 EXPECT_FALSE(ash::wm::IsWindowMaximized(window)); | 665 EXPECT_FALSE(window_state->IsMaximized()); |
659 // But the bounds should be different. | 666 // But the bounds should be different. |
660 gfx::Rect new_bounds = widget()->GetWindowBoundsInScreen(); | 667 gfx::Rect new_bounds = widget()->GetWindowBoundsInScreen(); |
661 EXPECT_EQ(0, new_bounds.x()); | 668 EXPECT_EQ(0, new_bounds.x()); |
662 EXPECT_EQ(0, new_bounds.y()); | 669 EXPECT_EQ(0, new_bounds.y()); |
663 | 670 |
664 // Now click the same button again to see that it restores. | 671 // Now click the same button again to see that it restores. |
665 ClickMaxButton(maximize_button, window, SNAP_LEFT); | 672 ClickMaxButton(maximize_button, window, SNAP_LEFT); |
666 // But the bounds should be restored. | 673 // But the bounds should be restored. |
667 new_bounds = widget()->GetWindowBoundsInScreen(); | 674 new_bounds = widget()->GetWindowBoundsInScreen(); |
668 EXPECT_EQ(new_bounds.x(), initial_bounds.x()); | 675 EXPECT_EQ(new_bounds.x(), initial_bounds.x()); |
669 EXPECT_EQ(new_bounds.y(), initial_bounds.x()); | 676 EXPECT_EQ(new_bounds.y(), initial_bounds.x()); |
670 EXPECT_EQ(new_bounds.width(), initial_bounds.width()); | 677 EXPECT_EQ(new_bounds.width(), initial_bounds.width()); |
671 EXPECT_EQ(new_bounds.height(), initial_bounds.height()); | 678 EXPECT_EQ(new_bounds.height(), initial_bounds.height()); |
672 // Make sure that there is no restore rectangle left. | 679 // Make sure that there is no restore rectangle left. |
673 EXPECT_EQ(NULL, GetRestoreBoundsInScreen(window)); | 680 EXPECT_FALSE(window_state->HasRestoreBounds()); |
674 } | 681 } |
675 | 682 |
676 // Maximize, left/right maximize and then restore should works. | 683 // Maximize, left/right maximize and then restore should works. |
677 TEST_F(FrameMaximizeButtonTest, MaximizeMaximizeLeftRestore) { | 684 TEST_F(FrameMaximizeButtonTest, MaximizeMaximizeLeftRestore) { |
678 aura::Window* window = widget()->GetNativeWindow(); | 685 aura::Window* window = widget()->GetNativeWindow(); |
679 gfx::Rect initial_bounds = widget()->GetWindowBoundsInScreen(); | 686 gfx::Rect initial_bounds = widget()->GetWindowBoundsInScreen(); |
680 ash::FrameMaximizeButton* maximize_button = | 687 ash::FrameMaximizeButton* maximize_button = |
681 FrameMaximizeButtonTest::maximize_button(); | 688 FrameMaximizeButtonTest::maximize_button(); |
682 maximize_button->set_bubble_appearance_delay_ms(0); | 689 maximize_button->set_bubble_appearance_delay_ms(0); |
683 | 690 |
684 ClickMaxButton(maximize_button, window, SNAP_NONE); | 691 ClickMaxButton(maximize_button, window, SNAP_NONE); |
685 EXPECT_TRUE(ash::wm::IsWindowMaximized(window)); | 692 |
| 693 wm::WindowState* window_state = wm::GetWindowState(window); |
| 694 EXPECT_TRUE(window_state->IsMaximized()); |
686 | 695 |
687 ClickMaxButton(maximize_button, window, SNAP_LEFT); | 696 ClickMaxButton(maximize_button, window, SNAP_LEFT); |
688 EXPECT_FALSE(ash::wm::IsWindowMaximized(window)); | 697 EXPECT_FALSE(window_state->IsMaximized()); |
689 gfx::Rect new_bounds = widget()->GetWindowBoundsInScreen(); | 698 gfx::Rect new_bounds = widget()->GetWindowBoundsInScreen(); |
690 EXPECT_EQ(0, new_bounds.x()); | 699 EXPECT_EQ(0, new_bounds.x()); |
691 EXPECT_EQ(0, new_bounds.y()); | 700 EXPECT_EQ(0, new_bounds.y()); |
692 | 701 |
693 // Now click the same button again to see that it restores. | 702 // Now click the same button again to see that it restores. |
694 ClickMaxButton(maximize_button, window, SNAP_LEFT); | 703 ClickMaxButton(maximize_button, window, SNAP_LEFT); |
695 RunAllPendingInMessageLoop(); | 704 RunAllPendingInMessageLoop(); |
696 // But the bounds should be restored. | 705 // But the bounds should be restored. |
697 new_bounds = widget()->GetWindowBoundsInScreen(); | 706 new_bounds = widget()->GetWindowBoundsInScreen(); |
698 EXPECT_EQ(new_bounds.x(), initial_bounds.x()); | 707 EXPECT_EQ(new_bounds.x(), initial_bounds.x()); |
699 EXPECT_EQ(new_bounds.y(), initial_bounds.x()); | 708 EXPECT_EQ(new_bounds.y(), initial_bounds.x()); |
700 EXPECT_EQ(new_bounds.width(), initial_bounds.width()); | 709 EXPECT_EQ(new_bounds.width(), initial_bounds.width()); |
701 EXPECT_EQ(new_bounds.height(), initial_bounds.height()); | 710 EXPECT_EQ(new_bounds.height(), initial_bounds.height()); |
702 // Make sure that there is no restore rectangle left. | 711 // Make sure that there is no restore rectangle left. |
703 EXPECT_EQ(NULL, GetRestoreBoundsInScreen(window)); | 712 EXPECT_FALSE(window_state->HasRestoreBounds()); |
704 } | 713 } |
705 | 714 |
706 // Left/right maximize, maximize and then restore should work. | 715 // Left/right maximize, maximize and then restore should work. |
707 TEST_F(FrameMaximizeButtonTest, MaximizeLeftMaximizeRestore) { | 716 TEST_F(FrameMaximizeButtonTest, MaximizeLeftMaximizeRestore) { |
708 aura::Window* window = widget()->GetNativeWindow(); | 717 aura::Window* window = widget()->GetNativeWindow(); |
709 gfx::Rect initial_bounds = widget()->GetWindowBoundsInScreen(); | 718 gfx::Rect initial_bounds = widget()->GetWindowBoundsInScreen(); |
710 ash::FrameMaximizeButton* maximize_button = | 719 ash::FrameMaximizeButton* maximize_button = |
711 FrameMaximizeButtonTest::maximize_button(); | 720 FrameMaximizeButtonTest::maximize_button(); |
712 maximize_button->set_bubble_appearance_delay_ms(0); | 721 maximize_button->set_bubble_appearance_delay_ms(0); |
713 | 722 |
714 ClickMaxButton(maximize_button, window, SNAP_LEFT); | 723 ClickMaxButton(maximize_button, window, SNAP_LEFT); |
715 EXPECT_FALSE(ash::wm::IsWindowMaximized(window)); | 724 |
| 725 wm::WindowState* window_state = wm::GetWindowState(window); |
| 726 EXPECT_FALSE(window_state->IsMaximized()); |
716 | 727 |
717 ClickMaxButton(maximize_button, window, SNAP_NONE); | 728 ClickMaxButton(maximize_button, window, SNAP_NONE); |
718 EXPECT_TRUE(ash::wm::IsWindowMaximized(window)); | 729 EXPECT_TRUE(window_state->IsMaximized()); |
719 | 730 |
720 ClickMaxButton(maximize_button, window, SNAP_NONE); | 731 ClickMaxButton(maximize_button, window, SNAP_NONE); |
721 EXPECT_FALSE(ash::wm::IsWindowMaximized(window)); | 732 EXPECT_FALSE(window_state->IsMaximized()); |
722 gfx::Rect new_bounds = widget()->GetWindowBoundsInScreen(); | 733 gfx::Rect new_bounds = widget()->GetWindowBoundsInScreen(); |
723 EXPECT_EQ(new_bounds.x(), initial_bounds.x()); | 734 EXPECT_EQ(new_bounds.x(), initial_bounds.x()); |
724 EXPECT_EQ(new_bounds.y(), initial_bounds.x()); | 735 EXPECT_EQ(new_bounds.y(), initial_bounds.x()); |
725 EXPECT_EQ(new_bounds.width(), initial_bounds.width()); | 736 EXPECT_EQ(new_bounds.width(), initial_bounds.width()); |
726 EXPECT_EQ(new_bounds.height(), initial_bounds.height()); | 737 EXPECT_EQ(new_bounds.height(), initial_bounds.height()); |
727 // Make sure that there is no restore rectangle left. | 738 // Make sure that there is no restore rectangle left. |
728 EXPECT_EQ(NULL, GetRestoreBoundsInScreen(window)); | 739 EXPECT_FALSE(window_state->HasRestoreBounds()); |
729 } | 740 } |
| 741 |
730 // Test that minimizing the window per keyboard closes the maximize bubble. | 742 // Test that minimizing the window per keyboard closes the maximize bubble. |
731 TEST_F(FrameMaximizeButtonTest, MinimizePerKeyClosesBubble) { | 743 TEST_F(FrameMaximizeButtonTest, MinimizePerKeyClosesBubble) { |
732 aura::Window* window = widget()->GetNativeWindow(); | 744 aura::Window* window = widget()->GetNativeWindow(); |
733 ash::FrameMaximizeButton* maximize_button = | 745 ash::FrameMaximizeButton* maximize_button = |
734 FrameMaximizeButtonTest::maximize_button(); | 746 FrameMaximizeButtonTest::maximize_button(); |
735 | 747 |
736 gfx::Point button_pos = maximize_button->GetBoundsInScreen().CenterPoint(); | 748 gfx::Point button_pos = maximize_button->GetBoundsInScreen().CenterPoint(); |
737 gfx::Point off_pos(button_pos.x() + 100, button_pos.y() + 100); | 749 gfx::Point off_pos(button_pos.x() + 100, button_pos.y() + 100); |
738 | 750 |
739 aura::test::EventGenerator generator(window->GetRootWindow(), off_pos); | 751 aura::test::EventGenerator generator(window->GetRootWindow(), off_pos); |
740 generator.MoveMouseTo(off_pos); | 752 generator.MoveMouseTo(off_pos); |
741 EXPECT_FALSE(maximize_button->maximizer()); | 753 EXPECT_FALSE(maximize_button->maximizer()); |
742 | 754 |
743 // Move the mouse cursor over the maximize button. | 755 // Move the mouse cursor over the maximize button. |
744 generator.MoveMouseTo(button_pos); | 756 generator.MoveMouseTo(button_pos); |
745 EXPECT_TRUE(maximize_button->maximizer()); | 757 EXPECT_TRUE(maximize_button->maximizer()); |
746 | 758 |
747 // We simulate the keystroke by calling minimizeWindow directly. | 759 // We simulate the keystroke by calling minimizeWindow directly. |
748 wm::MinimizeWindow(window); | 760 wm::WindowState* window_state = wm::GetWindowState(window); |
| 761 window_state->Minimize(); |
749 | 762 |
750 EXPECT_TRUE(ash::wm::IsWindowMinimized(window)); | 763 EXPECT_TRUE(window_state->IsMinimized()); |
751 EXPECT_FALSE(maximize_button->maximizer()); | 764 EXPECT_FALSE(maximize_button->maximizer()); |
752 } | 765 } |
753 | 766 |
754 // Tests that dragging down on the maximize button minimizes the window. | 767 // Tests that dragging down on the maximize button minimizes the window. |
755 TEST_F(FrameMaximizeButtonTest, MaximizeButtonDragDownMinimizes) { | 768 TEST_F(FrameMaximizeButtonTest, MaximizeButtonDragDownMinimizes) { |
756 aura::Window* window = widget()->GetNativeWindow(); | 769 aura::Window* window = widget()->GetNativeWindow(); |
757 ash::FrameMaximizeButton* maximize_button = | 770 ash::FrameMaximizeButton* maximize_button = |
758 FrameMaximizeButtonTest::maximize_button(); | 771 FrameMaximizeButtonTest::maximize_button(); |
759 | 772 |
| 773 wm::WindowState* window_state = wm::GetWindowState(window); |
760 // Drag down on a maximized window. | 774 // Drag down on a maximized window. |
761 wm::MaximizeWindow(window); | 775 window_state->Maximize(); |
762 EXPECT_TRUE(wm::IsWindowMaximized(window)); | 776 EXPECT_TRUE(window_state->IsMaximized()); |
763 gfx::Point button_pos = maximize_button->GetBoundsInScreen().CenterPoint(); | 777 gfx::Point button_pos = maximize_button->GetBoundsInScreen().CenterPoint(); |
764 gfx::Point off_pos(button_pos.x(), button_pos.y() + 100); | 778 gfx::Point off_pos(button_pos.x(), button_pos.y() + 100); |
765 | 779 |
766 aura::test::EventGenerator generator(window->GetRootWindow()); | 780 aura::test::EventGenerator generator(window->GetRootWindow()); |
767 generator.GestureScrollSequence(button_pos, off_pos, | 781 generator.GestureScrollSequence(button_pos, off_pos, |
768 base::TimeDelta::FromMilliseconds(0), 1); | 782 base::TimeDelta::FromMilliseconds(0), 1); |
769 | 783 |
770 EXPECT_TRUE(wm::IsWindowMinimized(window)); | 784 EXPECT_TRUE(window_state->IsMinimized()); |
771 EXPECT_FALSE(maximize_button->maximizer()); | 785 EXPECT_FALSE(maximize_button->maximizer()); |
772 | 786 |
773 // Drag down on a restored window. | 787 // Drag down on a restored window. |
774 wm::RestoreWindow(window); | 788 window_state->Restore(); |
775 | 789 |
776 button_pos = maximize_button->GetBoundsInScreen().CenterPoint(); | 790 button_pos = maximize_button->GetBoundsInScreen().CenterPoint(); |
777 off_pos = gfx::Point(button_pos.x(), button_pos.y() + 200); | 791 off_pos = gfx::Point(button_pos.x(), button_pos.y() + 200); |
778 generator.GestureScrollSequence(button_pos, off_pos, | 792 generator.GestureScrollSequence(button_pos, off_pos, |
779 base::TimeDelta::FromMilliseconds(10), 1); | 793 base::TimeDelta::FromMilliseconds(10), 1); |
780 EXPECT_TRUE(wm::IsWindowMinimized(window)); | 794 EXPECT_TRUE(window_state->IsMinimized()); |
781 EXPECT_FALSE(maximize_button->maximizer()); | 795 EXPECT_FALSE(maximize_button->maximizer()); |
782 } | 796 } |
783 | 797 |
784 // Tests that dragging Left and pressing ESC does properly abort. | 798 // Tests that dragging Left and pressing ESC does properly abort. |
785 TEST_F(FrameMaximizeButtonTest, MaximizeButtonDragLeftEscapeExits) { | 799 TEST_F(FrameMaximizeButtonTest, MaximizeButtonDragLeftEscapeExits) { |
786 aura::Window* window = widget()->GetNativeWindow(); | 800 aura::Window* window = widget()->GetNativeWindow(); |
787 gfx::Rect initial_bounds = widget()->GetWindowBoundsInScreen(); | 801 gfx::Rect initial_bounds = widget()->GetWindowBoundsInScreen(); |
788 ash::FrameMaximizeButton* maximize_button = | 802 ash::FrameMaximizeButton* maximize_button = |
789 FrameMaximizeButtonTest::maximize_button(); | 803 FrameMaximizeButtonTest::maximize_button(); |
790 | 804 |
(...skipping 13 matching lines...) Expand all Loading... |
804 | 818 |
805 // Check that there was no size change. | 819 // Check that there was no size change. |
806 EXPECT_EQ(widget()->GetWindowBoundsInScreen().size().ToString(), | 820 EXPECT_EQ(widget()->GetWindowBoundsInScreen().size().ToString(), |
807 initial_bounds.size().ToString()); | 821 initial_bounds.size().ToString()); |
808 // Check that there is no phantom window left open. | 822 // Check that there is no phantom window left open. |
809 EXPECT_FALSE(maximize_button->phantom_window_open()); | 823 EXPECT_FALSE(maximize_button->phantom_window_open()); |
810 } | 824 } |
811 | 825 |
812 } // namespace test | 826 } // namespace test |
813 } // namespace ash | 827 } // namespace ash |
OLD | NEW |