Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Side by Side Diff: ash/wm/caption_buttons/alternate_frame_size_button_unittest.cc

Issue 168943006: Keep the size button pressed when the user hovers the snap left or snap right button (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/alternate_frame_size_button.h" 5 #include "ash/wm/caption_buttons/alternate_frame_size_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.h" 10 #include "ash/wm/caption_buttons/frame_caption_button.h"
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 // the minimize and close button icons changing. 303 // the minimize and close button icons changing.
304 aura::test::EventGenerator& generator = GetEventGenerator(); 304 aura::test::EventGenerator& generator = GetEventGenerator();
305 generator.MoveMouseTo(CenterPointInScreen(size_button())); 305 generator.MoveMouseTo(CenterPointInScreen(size_button()));
306 generator.PressLeftButton(); 306 generator.PressLeftButton();
307 EXPECT_EQ(views::Button::STATE_NORMAL, minimize_button()->state()); 307 EXPECT_EQ(views::Button::STATE_NORMAL, minimize_button()->state());
308 EXPECT_EQ(views::Button::STATE_PRESSED, size_button()->state()); 308 EXPECT_EQ(views::Button::STATE_PRESSED, size_button()->state());
309 EXPECT_EQ(views::Button::STATE_NORMAL, close_button()->state()); 309 EXPECT_EQ(views::Button::STATE_NORMAL, close_button()->state());
310 EXPECT_EQ(CAPTION_BUTTON_ICON_LEFT_SNAPPED, minimize_button()->icon()); 310 EXPECT_EQ(CAPTION_BUTTON_ICON_LEFT_SNAPPED, minimize_button()->icon());
311 EXPECT_EQ(CAPTION_BUTTON_ICON_RIGHT_SNAPPED, close_button()->icon()); 311 EXPECT_EQ(CAPTION_BUTTON_ICON_RIGHT_SNAPPED, close_button()->icon());
312 312
313 // Dragging the mouse over the minimize button should press the minimize 313 // Dragging the mouse over the minimize button should hover the minimize
314 // button and the minimize and close button icons should stay changed. 314 // button and the minimize and close button icons should stay changed.
315 generator.MoveMouseTo(CenterPointInScreen(minimize_button())); 315 generator.MoveMouseTo(CenterPointInScreen(minimize_button()));
316 EXPECT_EQ(views::Button::STATE_PRESSED, minimize_button()->state()); 316 EXPECT_EQ(views::Button::STATE_HOVERED, minimize_button()->state());
317 EXPECT_EQ(views::Button::STATE_NORMAL, size_button()->state()); 317 EXPECT_EQ(views::Button::STATE_PRESSED, size_button()->state());
318 EXPECT_EQ(views::Button::STATE_NORMAL, close_button()->state()); 318 EXPECT_EQ(views::Button::STATE_NORMAL, close_button()->state());
319 EXPECT_EQ(CAPTION_BUTTON_ICON_LEFT_SNAPPED, minimize_button()->icon()); 319 EXPECT_EQ(CAPTION_BUTTON_ICON_LEFT_SNAPPED, minimize_button()->icon());
320 EXPECT_EQ(CAPTION_BUTTON_ICON_RIGHT_SNAPPED, close_button()->icon()); 320 EXPECT_EQ(CAPTION_BUTTON_ICON_RIGHT_SNAPPED, close_button()->icon());
321 321
322 // Release the mouse, snapping the window left. 322 // Release the mouse, snapping the window left.
323 generator.ReleaseLeftButton(); 323 generator.ReleaseLeftButton();
324 RunAllPendingInMessageLoop(); 324 RunAllPendingInMessageLoop();
325 EXPECT_TRUE(IsSnapped(internal::SnapSizer::LEFT_EDGE)); 325 EXPECT_TRUE(IsSnapped(internal::SnapSizer::LEFT_EDGE));
326 326
327 // None of the buttons should stay pressed and the buttons should have their 327 // None of the buttons should stay pressed and the buttons should have their
(...skipping 28 matching lines...) Expand all
356 RunAllPendingInMessageLoop(); 356 RunAllPendingInMessageLoop();
357 EXPECT_TRUE(IsSnapped(internal::SnapSizer::LEFT_EDGE)); 357 EXPECT_TRUE(IsSnapped(internal::SnapSizer::LEFT_EDGE));
358 358
359 // The buttons should stay unpressed and the buttons should now have their 359 // The buttons should stay unpressed and the buttons should now have their
360 // regular icons. 360 // regular icons.
361 EXPECT_TRUE(AllButtonsInNormalState()); 361 EXPECT_TRUE(AllButtonsInNormalState());
362 EXPECT_EQ(CAPTION_BUTTON_ICON_MINIMIZE, minimize_button()->icon()); 362 EXPECT_EQ(CAPTION_BUTTON_ICON_MINIMIZE, minimize_button()->icon());
363 EXPECT_EQ(CAPTION_BUTTON_ICON_CLOSE, close_button()->icon()); 363 EXPECT_EQ(CAPTION_BUTTON_ICON_CLOSE, close_button()->icon());
364 } 364 }
365 365
366 // Test that the size button is pressed whenever the snap left/right buttons
367 // are hovered.
368 TEST_F(AlternateFrameSizeButtonTest, SizeButtonPressedWhenSnapButtonHovered) {
369 EXPECT_EQ(CAPTION_BUTTON_ICON_MINIMIZE, minimize_button()->icon());
370 EXPECT_EQ(CAPTION_BUTTON_ICON_CLOSE, close_button()->icon());
371 EXPECT_TRUE(AllButtonsInNormalState());
372
373 // Pressing the size button should result in the size button being pressed and
374 // the minimize and close button icons changing.
375 aura::test::EventGenerator& generator = GetEventGenerator();
376 generator.MoveMouseTo(CenterPointInScreen(size_button()));
377 generator.PressLeftButton();
378 EXPECT_EQ(views::Button::STATE_NORMAL, minimize_button()->state());
379 EXPECT_EQ(views::Button::STATE_PRESSED, size_button()->state());
380 EXPECT_EQ(views::Button::STATE_NORMAL, close_button()->state());
381 EXPECT_EQ(CAPTION_BUTTON_ICON_LEFT_SNAPPED, minimize_button()->icon());
382 EXPECT_EQ(CAPTION_BUTTON_ICON_RIGHT_SNAPPED, close_button()->icon());
James Cook 2014/02/19 00:31:27 optional nit: This block of assertions seems cover
383
384 // Dragging the mouse over the minimize button (snap left button) should hover
385 // the minimize button and keep the size button pressed.
386 generator.MoveMouseTo(CenterPointInScreen(minimize_button()));
387 EXPECT_EQ(views::Button::STATE_HOVERED, minimize_button()->state());
388 EXPECT_EQ(views::Button::STATE_PRESSED, size_button()->state());
389 EXPECT_EQ(views::Button::STATE_NORMAL, close_button()->state());
390
391 // Moving the mouse far away from the caption buttons and then moving it over
392 // the close button (snap right button) should hover the close button and
393 // keep the size button pressed.
394 const gfx::Rect& kWorkAreaBoundsInScreen =
395 ash::Shell::GetScreen()->GetPrimaryDisplay().work_area();
396 generator.MoveMouseTo(kWorkAreaBoundsInScreen.bottom_left());
397 EXPECT_TRUE(AllButtonsInNormalState());
398 generator.MoveMouseTo(CenterPointInScreen(close_button()));
399 EXPECT_EQ(views::Button::STATE_NORMAL, minimize_button()->state());
400 EXPECT_EQ(views::Button::STATE_PRESSED, size_button()->state());
401 EXPECT_EQ(views::Button::STATE_HOVERED, close_button()->state());
402 }
403
366 } // namespace test 404 } // namespace test
367 } // namespace ash 405 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698