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

Side by Side Diff: ash/shelf/shelf_view_unittest.cc

Issue 2772513003: Makes AshTestHelper shutdown ChromeOS NetworkHandler (Closed)
Patch Set: comments Created 3 years, 9 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
« no previous file with comments | « ash/mus/window_manager_application.cc ('k') | ash/test/ash_test_helper.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/shelf/shelf_view.h" 5 #include "ash/common/shelf/shelf_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <memory> 8 #include <memory>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 840 matching lines...) Expand 10 before | Expand all | Expand 10 after
851 last_added = AddAppShortcut(); 851 last_added = AddAppShortcut();
852 ++items_added; 852 ++items_added;
853 ASSERT_LT(items_added, 10000); 853 ASSERT_LT(items_added, 10000);
854 } 854 }
855 855
856 // And the platform app button is invisible. 856 // And the platform app button is invisible.
857 EXPECT_FALSE(GetButtonByID(browser_button_id)->visible()); 857 EXPECT_FALSE(GetButtonByID(browser_button_id)->visible());
858 } 858 }
859 859
860 TEST_F(ShelfViewTest, AddPanelHidesPlatformAppButton) { 860 TEST_F(ShelfViewTest, AddPanelHidesPlatformAppButton) {
861 // TODO: investigate failure in mash, http://crbug.com/695751.
862 if (WmShell::Get()->IsRunningInMash())
863 return;
864
865 // All buttons should be visible. 861 // All buttons should be visible.
866 ASSERT_EQ(test_api_->GetButtonCount(), test_api_->GetLastVisibleIndex() + 1); 862 ASSERT_EQ(test_api_->GetButtonCount(), test_api_->GetLastVisibleIndex() + 1);
867 863
868 // Add platform app button until overflow, remember last visible platform app 864 // Add platform app button until overflow, remember last visible platform app
869 // button. 865 // button.
870 int items_added = 0; 866 int items_added = 0;
871 ShelfID first_added = AddApp(); 867 ShelfID first_added = AddApp();
872 EXPECT_TRUE(GetButtonByID(first_added)->visible()); 868 EXPECT_TRUE(GetButtonByID(first_added)->visible());
873 while (true) { 869 while (true) {
874 ShelfID added = AddApp(); 870 ShelfID added = AddApp();
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after
1568 const int app_list_button_index = test_api_->GetButtonCount() - 1; 1564 const int app_list_button_index = test_api_->GetButtonCount() - 1;
1569 const gfx::Rect& app_list_ideal_bounds = 1565 const gfx::Rect& app_list_ideal_bounds =
1570 test_api_->GetIdealBoundsByIndex(app_list_button_index); 1566 test_api_->GetIdealBoundsByIndex(app_list_button_index);
1571 const gfx::Rect& app_list_bounds = 1567 const gfx::Rect& app_list_bounds =
1572 test_api_->GetBoundsByIndex(app_list_button_index); 1568 test_api_->GetBoundsByIndex(app_list_button_index);
1573 EXPECT_EQ(app_list_ideal_bounds, app_list_bounds); 1569 EXPECT_EQ(app_list_ideal_bounds, app_list_bounds);
1574 } 1570 }
1575 1571
1576 // Checks the overflow bubble size when an item is ripped off and re-inserted. 1572 // Checks the overflow bubble size when an item is ripped off and re-inserted.
1577 TEST_F(ShelfViewTest, OverflowBubbleSize) { 1573 TEST_F(ShelfViewTest, OverflowBubbleSize) {
1578 // TODO: investigate failure in mash, http://crbug.com/695751.
1579 if (WmShell::Get()->IsRunningInMash())
1580 return;
1581
1582 shelf_delegate_->set_is_app_pinned(true); 1574 shelf_delegate_->set_is_app_pinned(true);
1583 AddButtonsUntilOverflow(); 1575 AddButtonsUntilOverflow();
1584 // Add one more button to prevent the overflow bubble to disappear upon 1576 // Add one more button to prevent the overflow bubble to disappear upon
1585 // dragging an item out on windows (flakiness, see crbug.com/436131). 1577 // dragging an item out on windows (flakiness, see crbug.com/436131).
1586 AddAppShortcut(); 1578 AddAppShortcut();
1587 1579
1588 // Show overflow bubble. 1580 // Show overflow bubble.
1589 test_api_->ShowOverflowBubble(); 1581 test_api_->ShowOverflowBubble();
1590 ASSERT_TRUE(test_api_->IsShowingOverflowBubble()); 1582 ASSERT_TRUE(test_api_->IsShowingOverflowBubble());
1591 1583
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1625 test_for_overflow_view.GetPreferredSize().width()); 1617 test_for_overflow_view.GetPreferredSize().width());
1626 1618
1627 generator.ReleaseLeftButton(); 1619 generator.ReleaseLeftButton();
1628 test_for_overflow_view.RunMessageLoopUntilAnimationsDone(); 1620 test_for_overflow_view.RunMessageLoopUntilAnimationsDone();
1629 EXPECT_EQ(bubble_size.width(), 1621 EXPECT_EQ(bubble_size.width(),
1630 test_for_overflow_view.GetPreferredSize().width()); 1622 test_for_overflow_view.GetPreferredSize().width());
1631 } 1623 }
1632 1624
1633 // Check the drag insertion bounds of scrolled overflow bubble. 1625 // Check the drag insertion bounds of scrolled overflow bubble.
1634 TEST_F(ShelfViewTest, CheckDragInsertBoundsOfScrolledOverflowBubble) { 1626 TEST_F(ShelfViewTest, CheckDragInsertBoundsOfScrolledOverflowBubble) {
1635 // TODO: investigate failure in mash, http://crbug.com/695751.
1636 if (WmShell::Get()->IsRunningInMash())
1637 return;
1638
1639 UpdateDisplay("400x300"); 1627 UpdateDisplay("400x300");
1640 1628
1641 EXPECT_EQ(2, model_->item_count()); 1629 EXPECT_EQ(2, model_->item_count());
1642 1630
1643 AddButtonsUntilOverflow(); 1631 AddButtonsUntilOverflow();
1644 1632
1645 // Show overflow bubble. 1633 // Show overflow bubble.
1646 test_api_->ShowOverflowBubble(); 1634 test_api_->ShowOverflowBubble();
1647 ASSERT_TRUE(test_api_->IsShowingOverflowBubble()); 1635 ASSERT_TRUE(test_api_->IsShowingOverflowBubble());
1648 1636
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
1780 1768
1781 // Rip off the browser item. 1769 // Rip off the browser item.
1782 generator.PressLeftButton(); 1770 generator.PressLeftButton();
1783 generator.MoveMouseTo(start_point.x() + 400, start_point.y()); 1771 generator.MoveMouseTo(start_point.x() + 400, start_point.y());
1784 test_api_for_secondary_shelf_view.RunMessageLoopUntilAnimationsDone(); 1772 test_api_for_secondary_shelf_view.RunMessageLoopUntilAnimationsDone();
1785 EXPECT_TRUE(test_api_for_secondary_shelf_view.IsRippedOffFromShelf()); 1773 EXPECT_TRUE(test_api_for_secondary_shelf_view.IsRippedOffFromShelf());
1786 } 1774 }
1787 1775
1788 // Checks various drag and drop operations from OverflowBubble to Shelf. 1776 // Checks various drag and drop operations from OverflowBubble to Shelf.
1789 TEST_F(ShelfViewTest, CheckDragAndDropFromOverflowBubbleToShelf) { 1777 TEST_F(ShelfViewTest, CheckDragAndDropFromOverflowBubbleToShelf) {
1790 // TODO: investigate failure in mash, http://crbug.com/695751.
1791 if (WmShell::Get()->IsRunningInMash())
1792 return;
1793
1794 AddButtonsUntilOverflow(); 1778 AddButtonsUntilOverflow();
1795 // Add one more button to prevent the overflow bubble to disappear upon 1779 // Add one more button to prevent the overflow bubble to disappear upon
1796 // dragging an item out on windows (flakiness, see crbug.com/425097). 1780 // dragging an item out on windows (flakiness, see crbug.com/425097).
1797 AddAppShortcut(); 1781 AddAppShortcut();
1798 1782
1799 TestDraggingAnItemFromOverflowToShelf(false); 1783 TestDraggingAnItemFromOverflowToShelf(false);
1800 TestDraggingAnItemFromOverflowToShelf(true); 1784 TestDraggingAnItemFromOverflowToShelf(true);
1801 } 1785 }
1802 1786
1803 // Checks creating app shortcut for an opened platform app in overflow bubble 1787 // Checks creating app shortcut for an opened platform app in overflow bubble
(...skipping 858 matching lines...) Expand 10 before | Expand all | Expand 10 after
2662 overflow_button_ink_drop_->GetTargetInkDropState()); 2646 overflow_button_ink_drop_->GetTargetInkDropState());
2663 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), 2647 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(),
2664 IsEmpty()); 2648 IsEmpty());
2665 2649
2666 EXPECT_FALSE(test_api_->IsShowingOverflowBubble()); 2650 EXPECT_FALSE(test_api_->IsShowingOverflowBubble());
2667 } 2651 }
2668 2652
2669 // Tests ink drop state transitions for the overflow button when the user taps 2653 // Tests ink drop state transitions for the overflow button when the user taps
2670 // on it. 2654 // on it.
2671 TEST_F(OverflowButtonInkDropTest, TouchActivate) { 2655 TEST_F(OverflowButtonInkDropTest, TouchActivate) {
2672 // TODO: flaky in mash, figure out why. http://crbug.com/696769.
2673 if (WmShell::Get()->IsRunningInMash())
2674 return;
2675
2676 ui::test::EventGenerator& generator = GetEventGenerator(); 2656 ui::test::EventGenerator& generator = GetEventGenerator();
2677 generator.set_current_location(GetScreenPointInsideOverflowButton()); 2657 generator.set_current_location(GetScreenPointInsideOverflowButton());
2678 2658
2679 generator.PressTouch(); 2659 generator.PressTouch();
2680 EXPECT_EQ(views::InkDropState::ACTION_PENDING, 2660 EXPECT_EQ(views::InkDropState::ACTION_PENDING,
2681 overflow_button_ink_drop_->GetTargetInkDropState()); 2661 overflow_button_ink_drop_->GetTargetInkDropState());
2682 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), 2662 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(),
2683 ElementsAre(views::InkDropState::ACTION_PENDING)); 2663 ElementsAre(views::InkDropState::ACTION_PENDING));
2684 2664
2685 generator.ReleaseTouch(); 2665 generator.ReleaseTouch();
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
2848 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), 2828 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(),
2849 IsEmpty()); 2829 IsEmpty());
2850 2830
2851 ASSERT_TRUE(test_api_->IsShowingOverflowBubble()); 2831 ASSERT_TRUE(test_api_->IsShowingOverflowBubble());
2852 } 2832 }
2853 2833
2854 // Tests ink drop state transitions for the overflow button when it is active 2834 // Tests ink drop state transitions for the overflow button when it is active
2855 // and the user presses left mouse button on it and drags it out of the button 2835 // and the user presses left mouse button on it and drags it out of the button
2856 // bounds and back. 2836 // bounds and back.
2857 TEST_F(OverflowButtonActiveInkDropTest, MouseDragOutAndBack) { 2837 TEST_F(OverflowButtonActiveInkDropTest, MouseDragOutAndBack) {
2858 // TODO: flaky in mash, figure out why. http://crbug.com/696769.
2859 if (WmShell::Get()->IsRunningInMash())
2860 return;
2861
2862 ui::test::EventGenerator& generator = GetEventGenerator(); 2838 ui::test::EventGenerator& generator = GetEventGenerator();
2863 generator.MoveMouseTo(GetScreenPointInsideOverflowButton()); 2839 generator.MoveMouseTo(GetScreenPointInsideOverflowButton());
2864 2840
2865 generator.PressLeftButton(); 2841 generator.PressLeftButton();
2866 EXPECT_EQ(views::InkDropState::ACTIVATED, 2842 EXPECT_EQ(views::InkDropState::ACTIVATED,
2867 overflow_button_ink_drop_->GetTargetInkDropState()); 2843 overflow_button_ink_drop_->GetTargetInkDropState());
2868 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), 2844 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(),
2869 IsEmpty()); 2845 IsEmpty());
2870 2846
2871 generator.MoveMouseTo(GetScreenPointOutsideOverflowButton()); 2847 generator.MoveMouseTo(GetScreenPointOutsideOverflowButton());
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
2928 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), 2904 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(),
2929 ElementsAre(views::InkDropState::DEACTIVATED, 2905 ElementsAre(views::InkDropState::DEACTIVATED,
2930 views::InkDropState::HIDDEN)); 2906 views::InkDropState::HIDDEN));
2931 2907
2932 EXPECT_FALSE(test_api_->IsShowingOverflowBubble()); 2908 EXPECT_FALSE(test_api_->IsShowingOverflowBubble());
2933 } 2909 }
2934 2910
2935 // Tests ink drop state transitions for the overflow button when it is active 2911 // Tests ink drop state transitions for the overflow button when it is active
2936 // and the user taps down on it and drags it out of the button bounds. 2912 // and the user taps down on it and drags it out of the button bounds.
2937 TEST_F(OverflowButtonActiveInkDropTest, TouchDragOut) { 2913 TEST_F(OverflowButtonActiveInkDropTest, TouchDragOut) {
2938 // TODO: flaky in mash, figure out why. http://crbug.com/696769.
2939 if (WmShell::Get()->IsRunningInMash())
2940 return;
2941
2942 ui::test::EventGenerator& generator = GetEventGenerator(); 2914 ui::test::EventGenerator& generator = GetEventGenerator();
2943 generator.set_current_location(GetScreenPointInsideOverflowButton()); 2915 generator.set_current_location(GetScreenPointInsideOverflowButton());
2944 2916
2945 generator.PressTouch(); 2917 generator.PressTouch();
2946 EXPECT_EQ(views::InkDropState::ACTIVATED, 2918 EXPECT_EQ(views::InkDropState::ACTIVATED,
2947 overflow_button_ink_drop_->GetTargetInkDropState()); 2919 overflow_button_ink_drop_->GetTargetInkDropState());
2948 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), 2920 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(),
2949 IsEmpty()); 2921 IsEmpty());
2950 2922
2951 generator.MoveTouch(GetScreenPointOutsideOverflowButton()); 2923 generator.MoveTouch(GetScreenPointOutsideOverflowButton());
2952 EXPECT_EQ(views::InkDropState::ACTIVATED, 2924 EXPECT_EQ(views::InkDropState::ACTIVATED,
2953 overflow_button_ink_drop_->GetTargetInkDropState()); 2925 overflow_button_ink_drop_->GetTargetInkDropState());
2954 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), 2926 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(),
2955 IsEmpty()); 2927 IsEmpty());
2956 2928
2957 generator.ReleaseTouch(); 2929 generator.ReleaseTouch();
2958 EXPECT_EQ(views::InkDropState::ACTIVATED, 2930 EXPECT_EQ(views::InkDropState::ACTIVATED,
2959 overflow_button_ink_drop_->GetTargetInkDropState()); 2931 overflow_button_ink_drop_->GetTargetInkDropState());
2960 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), 2932 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(),
2961 IsEmpty()); 2933 IsEmpty());
2962 2934
2963 ASSERT_TRUE(test_api_->IsShowingOverflowBubble()); 2935 ASSERT_TRUE(test_api_->IsShowingOverflowBubble());
2964 } 2936 }
2965 2937
2966 // Tests ink drop state transitions for the overflow button when it is active 2938 // Tests ink drop state transitions for the overflow button when it is active
2967 // and the user taps down on it and drags it out of the button bounds and back. 2939 // and the user taps down on it and drags it out of the button bounds and back.
2968 TEST_F(OverflowButtonActiveInkDropTest, TouchDragOutAndBack) { 2940 TEST_F(OverflowButtonActiveInkDropTest, TouchDragOutAndBack) {
2969 // TODO: flaky in mash, figure out why. http://crbug.com/696769.
2970 if (WmShell::Get()->IsRunningInMash())
2971 return;
2972
2973 ui::test::EventGenerator& generator = GetEventGenerator(); 2941 ui::test::EventGenerator& generator = GetEventGenerator();
2974 generator.set_current_location(GetScreenPointInsideOverflowButton()); 2942 generator.set_current_location(GetScreenPointInsideOverflowButton());
2975 2943
2976 generator.PressTouch(); 2944 generator.PressTouch();
2977 EXPECT_EQ(views::InkDropState::ACTIVATED, 2945 EXPECT_EQ(views::InkDropState::ACTIVATED,
2978 overflow_button_ink_drop_->GetTargetInkDropState()); 2946 overflow_button_ink_drop_->GetTargetInkDropState());
2979 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), 2947 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(),
2980 IsEmpty()); 2948 IsEmpty());
2981 2949
2982 generator.MoveTouch(GetScreenPointOutsideOverflowButton()); 2950 generator.MoveTouch(GetScreenPointOutsideOverflowButton());
(...skipping 13 matching lines...) Expand all
2996 overflow_button_ink_drop_->GetTargetInkDropState()); 2964 overflow_button_ink_drop_->GetTargetInkDropState());
2997 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), 2965 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(),
2998 IsEmpty()); 2966 IsEmpty());
2999 2967
3000 ASSERT_TRUE(test_api_->IsShowingOverflowBubble()); 2968 ASSERT_TRUE(test_api_->IsShowingOverflowBubble());
3001 } 2969 }
3002 2970
3003 // Tests ink drop state transitions for the overflow button when it is active 2971 // Tests ink drop state transitions for the overflow button when it is active
3004 // and the user long presses on the button to show the context menu. 2972 // and the user long presses on the button to show the context menu.
3005 TEST_F(OverflowButtonActiveInkDropTest, TouchContextMenu) { 2973 TEST_F(OverflowButtonActiveInkDropTest, TouchContextMenu) {
3006 // TODO: investigate failure in mash, http://crbug.com/695751. Note, that this
3007 // one is a bit flaky. Some times it passes with mash, other times not.
3008 if (WmShell::Get()->IsRunningInMash())
3009 return;
3010
3011 ui::test::EventGenerator& generator = GetEventGenerator(); 2974 ui::test::EventGenerator& generator = GetEventGenerator();
3012 generator.set_current_location(GetScreenPointInsideOverflowButton()); 2975 generator.set_current_location(GetScreenPointInsideOverflowButton());
3013 base::ScopedMockTimeMessageLoopTaskRunner mock_task_runner; 2976 base::ScopedMockTimeMessageLoopTaskRunner mock_task_runner;
3014 2977
3015 generator.PressTouch(); 2978 generator.PressTouch();
3016 EXPECT_EQ(views::InkDropState::ACTIVATED, 2979 EXPECT_EQ(views::InkDropState::ACTIVATED,
3017 overflow_button_ink_drop_->GetTargetInkDropState()); 2980 overflow_button_ink_drop_->GetTargetInkDropState());
3018 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), 2981 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(),
3019 IsEmpty()); 2982 IsEmpty());
3020 2983
3021 mock_task_runner->FastForwardUntilNoTasksRemain(); 2984 mock_task_runner->FastForwardUntilNoTasksRemain();
3022 EXPECT_EQ(views::InkDropState::ACTIVATED, 2985 EXPECT_EQ(views::InkDropState::ACTIVATED,
3023 overflow_button_ink_drop_->GetTargetInkDropState()); 2986 overflow_button_ink_drop_->GetTargetInkDropState());
3024 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), 2987 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(),
3025 IsEmpty()); 2988 IsEmpty());
3026 2989
3027 generator.ReleaseTouch(); 2990 generator.ReleaseTouch();
3028 EXPECT_EQ(views::InkDropState::ACTIVATED, 2991 EXPECT_EQ(views::InkDropState::ACTIVATED,
3029 overflow_button_ink_drop_->GetTargetInkDropState()); 2992 overflow_button_ink_drop_->GetTargetInkDropState());
3030 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), 2993 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(),
3031 IsEmpty()); 2994 IsEmpty());
3032 2995
3033 ASSERT_TRUE(test_api_->IsShowingOverflowBubble()); 2996 ASSERT_TRUE(test_api_->IsShowingOverflowBubble());
3034 } 2997 }
3035 2998
3036 } // namespace test 2999 } // namespace test
3037 } // namespace ash 3000 } // namespace ash
OLDNEW
« no previous file with comments | « ash/mus/window_manager_application.cc ('k') | ash/test/ash_test_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698