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

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

Issue 169443005: Fix crash which occurs when a widget destroys itself as a result of ET_GESTURE_TAP_DOWN (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/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"
(...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after
743 EXPECT_FALSE(window_state->IsMaximized()); 743 EXPECT_FALSE(window_state->IsMaximized());
744 gfx::Rect new_bounds = widget()->GetWindowBoundsInScreen(); 744 gfx::Rect new_bounds = widget()->GetWindowBoundsInScreen();
745 EXPECT_EQ(new_bounds.x(), initial_bounds.x()); 745 EXPECT_EQ(new_bounds.x(), initial_bounds.x());
746 EXPECT_EQ(new_bounds.y(), initial_bounds.x()); 746 EXPECT_EQ(new_bounds.y(), initial_bounds.x());
747 EXPECT_EQ(new_bounds.width(), initial_bounds.width()); 747 EXPECT_EQ(new_bounds.width(), initial_bounds.width());
748 EXPECT_EQ(new_bounds.height(), initial_bounds.height()); 748 EXPECT_EQ(new_bounds.height(), initial_bounds.height());
749 // Make sure that there is no restore rectangle left. 749 // Make sure that there is no restore rectangle left.
750 EXPECT_FALSE(window_state->HasRestoreBounds()); 750 EXPECT_FALSE(window_state->HasRestoreBounds());
751 } 751 }
752 752
753 // Test hovering over the minimize button in the help bubble then tapping the
754 // snap left button.
755 TEST_F(FrameMaximizeButtonTest, MaximizeBubbleMouseHoverAndTouch) {
756 aura::Window* window = widget()->GetNativeWindow();
757 ash::FrameMaximizeButton* maximize_button =
758 FrameMaximizeButtonTest::maximize_button();
759 maximize_button->set_bubble_appearance_delay_ms(0);
760
761 // Move the mouse cursor over the maximize button to make the help bubble
762 // appear.
763 aura::test::EventGenerator generator(window->GetRootWindow());
764 generator.MoveMouseTo(maximize_button->GetBoundsInScreen().CenterPoint());
765 MaximizeBubbleController* maximizer = maximize_button->maximizer();
766 ASSERT_TRUE(maximizer);
767
768 // Move the mouse cursor over the minimize button in the help bubble.
769 gfx::Point minimize_pos = maximizer->GetButtonForUnitTest(SNAP_MINIMIZE)->
770 GetBoundsInScreen().CenterPoint();
771 generator.MoveMouseTo(minimize_pos);
772
773 // Tap the snap left button in the help bubble.
774 gfx::Point snap_pos = maximizer->GetButtonForUnitTest(SNAP_LEFT)->
775 GetBoundsInScreen().CenterPoint();
776 generator.GestureTapAt(snap_pos);
777 internal::SnapSizer sizer(wm::GetWindowState(window), gfx::Point(),
778 internal::SnapSizer::LEFT_EDGE,
779 internal::SnapSizer::OTHER_INPUT);
780 EXPECT_EQ(sizer.target_bounds().ToString(), window->bounds().ToString());
781 }
782
753 // Test that minimizing the window per keyboard closes the maximize bubble. 783 // Test that minimizing the window per keyboard closes the maximize bubble.
754 TEST_F(FrameMaximizeButtonTest, MinimizePerKeyClosesBubble) { 784 TEST_F(FrameMaximizeButtonTest, MinimizePerKeyClosesBubble) {
755 aura::Window* window = widget()->GetNativeWindow(); 785 aura::Window* window = widget()->GetNativeWindow();
756 ash::FrameMaximizeButton* maximize_button = 786 ash::FrameMaximizeButton* maximize_button =
757 FrameMaximizeButtonTest::maximize_button(); 787 FrameMaximizeButtonTest::maximize_button();
758 788
759 gfx::Point button_pos = maximize_button->GetBoundsInScreen().CenterPoint(); 789 gfx::Point button_pos = maximize_button->GetBoundsInScreen().CenterPoint();
760 gfx::Point off_pos(button_pos.x() + 100, button_pos.y() + 100); 790 gfx::Point off_pos(button_pos.x() + 100, button_pos.y() + 100);
761 791
762 aura::test::EventGenerator generator(window->GetRootWindow(), off_pos); 792 aura::test::EventGenerator generator(window->GetRootWindow(), off_pos);
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
871 901
872 // Test that we have properly reset the state of the now inactive window. 902 // Test that we have properly reset the state of the now inactive window.
873 EXPECT_FALSE(maximize_button->maximizer()); 903 EXPECT_FALSE(maximize_button->maximizer());
874 EXPECT_FALSE(maximize_button->phantom_window_open()); 904 EXPECT_FALSE(maximize_button->phantom_window_open());
875 EXPECT_TRUE(wm::GetWindowState(window)->IsNormalShowState()); 905 EXPECT_TRUE(wm::GetWindowState(window)->IsNormalShowState());
876 EXPECT_EQ(initial_bounds.ToString(), window->GetBoundsInScreen().ToString()); 906 EXPECT_EQ(initial_bounds.ToString(), window->GetBoundsInScreen().ToString());
877 } 907 }
878 908
879 } // namespace test 909 } // namespace test
880 } // namespace ash 910 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698