OLD | NEW |
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/shelf/shelf_view.h" | 5 #include "ash/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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 | 65 |
66 namespace ash { | 66 namespace ash { |
67 namespace test { | 67 namespace test { |
68 | 68 |
69 //////////////////////////////////////////////////////////////////////////////// | 69 //////////////////////////////////////////////////////////////////////////////// |
70 // ShelfIconObserver tests. | 70 // ShelfIconObserver tests. |
71 | 71 |
72 class TestShelfIconObserver : public ShelfIconObserver { | 72 class TestShelfIconObserver : public ShelfIconObserver { |
73 public: | 73 public: |
74 explicit TestShelfIconObserver(Shelf* shelf) | 74 explicit TestShelfIconObserver(Shelf* shelf) |
75 : shelf_(shelf), | 75 : shelf_(shelf), change_notified_(false) { |
76 change_notified_(false) { | |
77 if (shelf_) | 76 if (shelf_) |
78 shelf_->AddIconObserver(this); | 77 shelf_->AddIconObserver(this); |
79 } | 78 } |
80 | 79 |
81 ~TestShelfIconObserver() override { | 80 ~TestShelfIconObserver() override { |
82 if (shelf_) | 81 if (shelf_) |
83 shelf_->RemoveIconObserver(this); | 82 shelf_->RemoveIconObserver(this); |
84 } | 83 } |
85 | 84 |
86 // ShelfIconObserver implementation. | 85 // ShelfIconObserver implementation. |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 | 142 |
144 // Resets to the initial state. | 143 // Resets to the initial state. |
145 void Reset() { selected_ = false; } | 144 void Reset() { selected_ = false; } |
146 | 145 |
147 void set_item_selected_action( | 146 void set_item_selected_action( |
148 ShelfItemDelegate::PerformedAction item_selected_action) { | 147 ShelfItemDelegate::PerformedAction item_selected_action) { |
149 item_selected_action_ = item_selected_action; | 148 item_selected_action_ = item_selected_action; |
150 } | 149 } |
151 | 150 |
152 // Returns true if the delegate was selected. | 151 // Returns true if the delegate was selected. |
153 bool WasSelected() { | 152 bool WasSelected() { return selected_; } |
154 return selected_; | |
155 } | |
156 | 153 |
157 // TestShelfItemDelegate: | 154 // TestShelfItemDelegate: |
158 ShelfItemDelegate::PerformedAction ItemSelected( | 155 ShelfItemDelegate::PerformedAction ItemSelected( |
159 const ui::Event& event) override { | 156 const ui::Event& event) override { |
160 selected_ = true; | 157 selected_ = true; |
161 return item_selected_action_; | 158 return item_selected_action_; |
162 } | 159 } |
163 | 160 |
164 private: | 161 private: |
165 bool selected_; | 162 bool selected_; |
(...skipping 23 matching lines...) Expand all Loading... |
189 widget->Show(); | 186 widget->Show(); |
190 widget->GetNativeWindow()->parent()->RemoveChild(widget->GetNativeWindow()); | 187 widget->GetNativeWindow()->parent()->RemoveChild(widget->GetNativeWindow()); |
191 shelf_view_test()->RunMessageLoopUntilAnimationsDone(); | 188 shelf_view_test()->RunMessageLoopUntilAnimationsDone(); |
192 EXPECT_TRUE(observer()->change_notified()); | 189 EXPECT_TRUE(observer()->change_notified()); |
193 observer()->Reset(); | 190 observer()->Reset(); |
194 } | 191 } |
195 | 192 |
196 // Sometimes fails on trybots on win7_aura. http://crbug.com/177135 | 193 // Sometimes fails on trybots on win7_aura. http://crbug.com/177135 |
197 #if defined(OS_WIN) | 194 #if defined(OS_WIN) |
198 #define MAYBE_AddRemoveWithMultipleDisplays \ | 195 #define MAYBE_AddRemoveWithMultipleDisplays \ |
199 DISABLED_AddRemoveWithMultipleDisplays | 196 DISABLED_AddRemoveWithMultipleDisplays |
200 #else | 197 #else |
201 #define MAYBE_AddRemoveWithMultipleDisplays \ | 198 #define MAYBE_AddRemoveWithMultipleDisplays AddRemoveWithMultipleDisplays |
202 AddRemoveWithMultipleDisplays | |
203 #endif | 199 #endif |
204 // Make sure creating/deleting an window on one displays notifies a | 200 // Make sure creating/deleting an window on one displays notifies a |
205 // shelf on external display as well as one on primary. | 201 // shelf on external display as well as one on primary. |
206 TEST_F(ShelfViewIconObserverTest, MAYBE_AddRemoveWithMultipleDisplays) { | 202 TEST_F(ShelfViewIconObserverTest, MAYBE_AddRemoveWithMultipleDisplays) { |
207 UpdateDisplay("400x400,400x400"); | 203 UpdateDisplay("400x400,400x400"); |
208 TestShelfIconObserver second_observer(ShelfForSecondaryDisplay()); | 204 TestShelfIconObserver second_observer(ShelfForSecondaryDisplay()); |
209 | 205 |
210 TestShelfDelegate* shelf_delegate = TestShelfDelegate::instance(); | 206 TestShelfDelegate* shelf_delegate = TestShelfDelegate::instance(); |
211 ASSERT_TRUE(shelf_delegate); | 207 ASSERT_TRUE(shelf_delegate); |
212 | 208 |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 int index = model_->ItemIndexByID(id); | 426 int index = model_->ItemIndexByID(id); |
431 return test_api_->GetButton(index); | 427 return test_api_->GetButton(index); |
432 } | 428 } |
433 | 429 |
434 ShelfItem GetItemByID(ShelfID id) { | 430 ShelfItem GetItemByID(ShelfID id) { |
435 ShelfItems::const_iterator items = model_->ItemByID(id); | 431 ShelfItems::const_iterator items = model_->ItemByID(id); |
436 return *items; | 432 return *items; |
437 } | 433 } |
438 | 434 |
439 void CheckModelIDs( | 435 void CheckModelIDs( |
440 const std::vector<std::pair<ShelfID, views::View*> >& id_map) { | 436 const std::vector<std::pair<ShelfID, views::View*>>& id_map) { |
441 size_t map_index = 0; | 437 size_t map_index = 0; |
442 for (size_t model_index = 0; | 438 for (size_t model_index = 0; model_index < model_->items().size(); |
443 model_index < model_->items().size(); | |
444 ++model_index) { | 439 ++model_index) { |
445 ShelfItem item = model_->items()[model_index]; | 440 ShelfItem item = model_->items()[model_index]; |
446 ShelfID id = item.id; | 441 ShelfID id = item.id; |
447 EXPECT_EQ(id_map[map_index].first, id); | 442 EXPECT_EQ(id_map[map_index].first, id); |
448 EXPECT_EQ(id_map[map_index].second, GetButtonByID(id)); | 443 EXPECT_EQ(id_map[map_index].second, GetButtonByID(id)); |
449 ++map_index; | 444 ++map_index; |
450 } | 445 } |
451 ASSERT_EQ(map_index, id_map.size()); | 446 ASSERT_EQ(map_index, id_map.size()); |
452 } | 447 } |
453 | 448 |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
567 ShelfView* shelf_view, | 562 ShelfView* shelf_view, |
568 const std::vector<std::pair<int, views::View*>>& expected_id_map) { | 563 const std::vector<std::pair<int, views::View*>>& expected_id_map) { |
569 views::View* dragged_button = | 564 views::View* dragged_button = |
570 SimulateDrag(ShelfView::MOUSE, from, to, true); | 565 SimulateDrag(ShelfView::MOUSE, from, to, true); |
571 shelf_view->PointerReleasedOnButton(dragged_button, ShelfView::MOUSE, | 566 shelf_view->PointerReleasedOnButton(dragged_button, ShelfView::MOUSE, |
572 false); | 567 false); |
573 test_api_->RunMessageLoopUntilAnimationsDone(); | 568 test_api_->RunMessageLoopUntilAnimationsDone(); |
574 ASSERT_NO_FATAL_FAILURE(CheckModelIDs(expected_id_map)); | 569 ASSERT_NO_FATAL_FAILURE(CheckModelIDs(expected_id_map)); |
575 } | 570 } |
576 | 571 |
577 void SetupForDragTest( | 572 void SetupForDragTest(std::vector<std::pair<ShelfID, views::View*>>* id_map) { |
578 std::vector<std::pair<ShelfID, views::View*> >* id_map) { | |
579 // Initialize |id_map| with the automatically-created shelf buttons. | 573 // Initialize |id_map| with the automatically-created shelf buttons. |
580 for (size_t i = 0; i < model_->items().size(); ++i) { | 574 for (size_t i = 0; i < model_->items().size(); ++i) { |
581 ShelfButton* button = test_api_->GetButton(i); | 575 ShelfButton* button = test_api_->GetButton(i); |
582 id_map->push_back(std::make_pair(model_->items()[i].id, button)); | 576 id_map->push_back(std::make_pair(model_->items()[i].id, button)); |
583 } | 577 } |
584 ASSERT_NO_FATAL_FAILURE(CheckModelIDs(*id_map)); | 578 ASSERT_NO_FATAL_FAILURE(CheckModelIDs(*id_map)); |
585 | 579 |
586 // Add 5 app shelf buttons for testing. | 580 // Add 5 app shelf buttons for testing. |
587 for (int i = 0; i < 5; ++i) { | 581 for (int i = 0; i < 5; ++i) { |
588 ShelfID id = AddAppShortcut(); | 582 ShelfID id = AddAppShortcut(); |
(...skipping 26 matching lines...) Expand all Loading... |
615 | 609 |
616 int last_visible_item_id_in_shelf = | 610 int last_visible_item_id_in_shelf = |
617 GetItemId(test_api_->GetLastVisibleIndex()); | 611 GetItemId(test_api_->GetLastVisibleIndex()); |
618 int second_last_visible_item_id_in_shelf = | 612 int second_last_visible_item_id_in_shelf = |
619 GetItemId(test_api_->GetLastVisibleIndex() - 1); | 613 GetItemId(test_api_->GetLastVisibleIndex() - 1); |
620 int first_visible_item_id_in_overflow = | 614 int first_visible_item_id_in_overflow = |
621 GetItemId(test_api_for_overflow.GetFirstVisibleIndex()); | 615 GetItemId(test_api_for_overflow.GetFirstVisibleIndex()); |
622 int second_last_visible_item_id_in_overflow = | 616 int second_last_visible_item_id_in_overflow = |
623 GetItemId(test_api_for_overflow.GetLastVisibleIndex() - 1); | 617 GetItemId(test_api_for_overflow.GetLastVisibleIndex() - 1); |
624 | 618 |
625 int drag_item_index = | 619 int drag_item_index = test_api_for_overflow.GetLastVisibleIndex(); |
626 test_api_for_overflow.GetLastVisibleIndex(); | |
627 ShelfID drag_item_id = GetItemId(drag_item_index); | 620 ShelfID drag_item_id = GetItemId(drag_item_index); |
628 ShelfButton* drag_button = test_api_for_overflow.GetButton(drag_item_index); | 621 ShelfButton* drag_button = test_api_for_overflow.GetButton(drag_item_index); |
629 gfx::Point center_point_of_drag_item = | 622 gfx::Point center_point_of_drag_item = |
630 drag_button->GetBoundsInScreen().CenterPoint(); | 623 drag_button->GetBoundsInScreen().CenterPoint(); |
631 | 624 |
632 ui::test::EventGenerator generator(ash::Shell::GetPrimaryRootWindow(), | 625 ui::test::EventGenerator generator(ash::Shell::GetPrimaryRootWindow(), |
633 center_point_of_drag_item); | 626 center_point_of_drag_item); |
634 // Rip an item off to OverflowBubble. | 627 // Rip an item off to OverflowBubble. |
635 generator.PressLeftButton(); | 628 generator.PressLeftButton(); |
636 gfx::Point rip_off_point(center_point_of_drag_item.x(), 0); | 629 gfx::Point rip_off_point(center_point_of_drag_item.x(), 0); |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
740 | 733 |
741 private: | 734 private: |
742 void CheckTextDirectionIsCorrect() { | 735 void CheckTextDirectionIsCorrect() { |
743 ASSERT_EQ(is_rtl_, base::i18n::IsRTL()); | 736 ASSERT_EQ(is_rtl_, base::i18n::IsRTL()); |
744 } | 737 } |
745 | 738 |
746 bool is_rtl_; | 739 bool is_rtl_; |
747 std::string original_locale_; | 740 std::string original_locale_; |
748 }; | 741 }; |
749 | 742 |
750 class ShelfViewTextDirectionTest | 743 class ShelfViewTextDirectionTest : public ShelfViewTest, |
751 : public ShelfViewTest, | 744 public testing::WithParamInterface<bool> { |
752 public testing::WithParamInterface<bool> { | |
753 public: | 745 public: |
754 ShelfViewTextDirectionTest() : text_direction_change_(GetParam()) {} | 746 ShelfViewTextDirectionTest() : text_direction_change_(GetParam()) {} |
755 virtual ~ShelfViewTextDirectionTest() {} | 747 virtual ~ShelfViewTextDirectionTest() {} |
756 | 748 |
757 void SetUp() override { ShelfViewTest::SetUp(); } | 749 void SetUp() override { ShelfViewTest::SetUp(); } |
758 | 750 |
759 void TearDown() override { ShelfViewTest::TearDown(); } | 751 void TearDown() override { ShelfViewTest::TearDown(); } |
760 | 752 |
761 private: | 753 private: |
762 ScopedTextDirectionChange text_direction_change_; | 754 ScopedTextDirectionChange text_direction_change_; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
804 // identical whereas the first one does not match either of them. | 796 // identical whereas the first one does not match either of them. |
805 EXPECT_EQ(first_bounds.size().ToString(), last_bounds.size().ToString()); | 797 EXPECT_EQ(first_bounds.size().ToString(), last_bounds.size().ToString()); |
806 EXPECT_NE(first_bounds.ToString(), last_bounds.ToString()); | 798 EXPECT_NE(first_bounds.ToString(), last_bounds.ToString()); |
807 EXPECT_EQ(overflow_bounds.ToString(), last_bounds.ToString()); | 799 EXPECT_EQ(overflow_bounds.ToString(), last_bounds.ToString()); |
808 } | 800 } |
809 | 801 |
810 // Checks that shelf view contents are considered in the correct drag group. | 802 // Checks that shelf view contents are considered in the correct drag group. |
811 TEST_F(ShelfViewTest, EnforceDragType) { | 803 TEST_F(ShelfViewTest, EnforceDragType) { |
812 EXPECT_TRUE(test_api_->SameDragType(TYPE_PLATFORM_APP, TYPE_PLATFORM_APP)); | 804 EXPECT_TRUE(test_api_->SameDragType(TYPE_PLATFORM_APP, TYPE_PLATFORM_APP)); |
813 EXPECT_FALSE(test_api_->SameDragType(TYPE_PLATFORM_APP, TYPE_APP_SHORTCUT)); | 805 EXPECT_FALSE(test_api_->SameDragType(TYPE_PLATFORM_APP, TYPE_APP_SHORTCUT)); |
814 EXPECT_FALSE(test_api_->SameDragType(TYPE_PLATFORM_APP, | 806 EXPECT_FALSE( |
815 TYPE_BROWSER_SHORTCUT)); | 807 test_api_->SameDragType(TYPE_PLATFORM_APP, TYPE_BROWSER_SHORTCUT)); |
816 EXPECT_FALSE(test_api_->SameDragType(TYPE_PLATFORM_APP, TYPE_WINDOWED_APP)); | 808 EXPECT_FALSE(test_api_->SameDragType(TYPE_PLATFORM_APP, TYPE_WINDOWED_APP)); |
817 EXPECT_FALSE(test_api_->SameDragType(TYPE_PLATFORM_APP, TYPE_APP_LIST)); | 809 EXPECT_FALSE(test_api_->SameDragType(TYPE_PLATFORM_APP, TYPE_APP_LIST)); |
818 EXPECT_FALSE(test_api_->SameDragType(TYPE_PLATFORM_APP, TYPE_APP_PANEL)); | 810 EXPECT_FALSE(test_api_->SameDragType(TYPE_PLATFORM_APP, TYPE_APP_PANEL)); |
819 | 811 |
820 EXPECT_TRUE(test_api_->SameDragType(TYPE_APP_SHORTCUT, TYPE_APP_SHORTCUT)); | 812 EXPECT_TRUE(test_api_->SameDragType(TYPE_APP_SHORTCUT, TYPE_APP_SHORTCUT)); |
821 EXPECT_TRUE(test_api_->SameDragType(TYPE_APP_SHORTCUT, | 813 EXPECT_TRUE( |
822 TYPE_BROWSER_SHORTCUT)); | 814 test_api_->SameDragType(TYPE_APP_SHORTCUT, TYPE_BROWSER_SHORTCUT)); |
823 EXPECT_FALSE(test_api_->SameDragType(TYPE_APP_SHORTCUT, | 815 EXPECT_FALSE(test_api_->SameDragType(TYPE_APP_SHORTCUT, TYPE_WINDOWED_APP)); |
824 TYPE_WINDOWED_APP)); | |
825 EXPECT_FALSE(test_api_->SameDragType(TYPE_APP_SHORTCUT, TYPE_APP_LIST)); | 816 EXPECT_FALSE(test_api_->SameDragType(TYPE_APP_SHORTCUT, TYPE_APP_LIST)); |
826 EXPECT_FALSE(test_api_->SameDragType(TYPE_APP_SHORTCUT, TYPE_APP_PANEL)); | 817 EXPECT_FALSE(test_api_->SameDragType(TYPE_APP_SHORTCUT, TYPE_APP_PANEL)); |
827 | 818 |
828 EXPECT_TRUE(test_api_->SameDragType(TYPE_BROWSER_SHORTCUT, | 819 EXPECT_TRUE( |
829 TYPE_BROWSER_SHORTCUT)); | 820 test_api_->SameDragType(TYPE_BROWSER_SHORTCUT, TYPE_BROWSER_SHORTCUT)); |
830 EXPECT_FALSE(test_api_->SameDragType(TYPE_BROWSER_SHORTCUT, | 821 EXPECT_FALSE( |
831 TYPE_WINDOWED_APP)); | 822 test_api_->SameDragType(TYPE_BROWSER_SHORTCUT, TYPE_WINDOWED_APP)); |
832 EXPECT_FALSE(test_api_->SameDragType(TYPE_BROWSER_SHORTCUT, TYPE_APP_LIST)); | 823 EXPECT_FALSE(test_api_->SameDragType(TYPE_BROWSER_SHORTCUT, TYPE_APP_LIST)); |
833 EXPECT_FALSE(test_api_->SameDragType(TYPE_BROWSER_SHORTCUT, TYPE_APP_PANEL)); | 824 EXPECT_FALSE(test_api_->SameDragType(TYPE_BROWSER_SHORTCUT, TYPE_APP_PANEL)); |
834 | 825 |
835 EXPECT_TRUE(test_api_->SameDragType(TYPE_WINDOWED_APP, TYPE_WINDOWED_APP)); | 826 EXPECT_TRUE(test_api_->SameDragType(TYPE_WINDOWED_APP, TYPE_WINDOWED_APP)); |
836 EXPECT_FALSE(test_api_->SameDragType(TYPE_WINDOWED_APP, TYPE_APP_LIST)); | 827 EXPECT_FALSE(test_api_->SameDragType(TYPE_WINDOWED_APP, TYPE_APP_LIST)); |
837 EXPECT_FALSE(test_api_->SameDragType(TYPE_WINDOWED_APP, TYPE_APP_PANEL)); | 828 EXPECT_FALSE(test_api_->SameDragType(TYPE_WINDOWED_APP, TYPE_APP_PANEL)); |
838 | 829 |
839 EXPECT_TRUE(test_api_->SameDragType(TYPE_APP_LIST, TYPE_APP_LIST)); | 830 EXPECT_TRUE(test_api_->SameDragType(TYPE_APP_LIST, TYPE_APP_LIST)); |
840 EXPECT_FALSE(test_api_->SameDragType(TYPE_APP_LIST, TYPE_APP_PANEL)); | 831 EXPECT_FALSE(test_api_->SameDragType(TYPE_APP_LIST, TYPE_APP_PANEL)); |
841 | 832 |
842 EXPECT_TRUE(test_api_->SameDragType(TYPE_APP_PANEL, TYPE_APP_PANEL)); | 833 EXPECT_TRUE(test_api_->SameDragType(TYPE_APP_PANEL, TYPE_APP_PANEL)); |
843 } | 834 } |
844 | 835 |
845 // Adds platform app button until overflow and verifies that the last added | 836 // Adds platform app button until overflow and verifies that the last added |
846 // platform app button is hidden. | 837 // platform app button is hidden. |
847 TEST_F(ShelfViewTest, AddBrowserUntilOverflow) { | 838 TEST_F(ShelfViewTest, AddBrowserUntilOverflow) { |
848 // All buttons should be visible. | 839 // All buttons should be visible. |
849 ASSERT_EQ(test_api_->GetButtonCount(), | 840 ASSERT_EQ(test_api_->GetButtonCount(), test_api_->GetLastVisibleIndex() + 1); |
850 test_api_->GetLastVisibleIndex() + 1); | |
851 | 841 |
852 // Add platform app button until overflow. | 842 // Add platform app button until overflow. |
853 int items_added = 0; | 843 int items_added = 0; |
854 ShelfID last_added = AddPlatformApp(); | 844 ShelfID last_added = AddPlatformApp(); |
855 while (!test_api_->IsOverflowButtonVisible()) { | 845 while (!test_api_->IsOverflowButtonVisible()) { |
856 // Added button is visible after animation while in this loop. | 846 // Added button is visible after animation while in this loop. |
857 EXPECT_TRUE(GetButtonByID(last_added)->visible()); | 847 EXPECT_TRUE(GetButtonByID(last_added)->visible()); |
858 | 848 |
859 last_added = AddPlatformApp(); | 849 last_added = AddPlatformApp(); |
860 ++items_added; | 850 ++items_added; |
861 ASSERT_LT(items_added, 10000); | 851 ASSERT_LT(items_added, 10000); |
862 } | 852 } |
863 | 853 |
864 // The last added button should be invisible. | 854 // The last added button should be invisible. |
865 EXPECT_FALSE(GetButtonByID(last_added)->visible()); | 855 EXPECT_FALSE(GetButtonByID(last_added)->visible()); |
866 } | 856 } |
867 | 857 |
868 // Adds one platform app button then adds app shortcut until overflow. Verifies | 858 // Adds one platform app button then adds app shortcut until overflow. Verifies |
869 // that the browser button gets hidden on overflow and last added app shortcut | 859 // that the browser button gets hidden on overflow and last added app shortcut |
870 // is still visible. | 860 // is still visible. |
871 TEST_F(ShelfViewTest, AddAppShortcutWithBrowserButtonUntilOverflow) { | 861 TEST_F(ShelfViewTest, AddAppShortcutWithBrowserButtonUntilOverflow) { |
872 // All buttons should be visible. | 862 // All buttons should be visible. |
873 ASSERT_EQ(test_api_->GetButtonCount(), | 863 ASSERT_EQ(test_api_->GetButtonCount(), test_api_->GetLastVisibleIndex() + 1); |
874 test_api_->GetLastVisibleIndex() + 1); | |
875 | 864 |
876 ShelfID browser_button_id = AddPlatformApp(); | 865 ShelfID browser_button_id = AddPlatformApp(); |
877 | 866 |
878 // Add app shortcut until overflow. | 867 // Add app shortcut until overflow. |
879 int items_added = 0; | 868 int items_added = 0; |
880 ShelfID last_added = AddAppShortcut(); | 869 ShelfID last_added = AddAppShortcut(); |
881 while (!test_api_->IsOverflowButtonVisible()) { | 870 while (!test_api_->IsOverflowButtonVisible()) { |
882 // Added button is visible after animation while in this loop. | 871 // Added button is visible after animation while in this loop. |
883 EXPECT_TRUE(GetButtonByID(last_added)->visible()); | 872 EXPECT_TRUE(GetButtonByID(last_added)->visible()); |
884 | 873 |
885 last_added = AddAppShortcut(); | 874 last_added = AddAppShortcut(); |
886 ++items_added; | 875 ++items_added; |
887 ASSERT_LT(items_added, 10000); | 876 ASSERT_LT(items_added, 10000); |
888 } | 877 } |
889 | 878 |
890 // And the platform app button is invisible. | 879 // And the platform app button is invisible. |
891 EXPECT_FALSE(GetButtonByID(browser_button_id)->visible()); | 880 EXPECT_FALSE(GetButtonByID(browser_button_id)->visible()); |
892 } | 881 } |
893 | 882 |
894 TEST_F(ShelfViewTest, AddPanelHidesPlatformAppButton) { | 883 TEST_F(ShelfViewTest, AddPanelHidesPlatformAppButton) { |
895 // All buttons should be visible. | 884 // All buttons should be visible. |
896 ASSERT_EQ(test_api_->GetButtonCount(), | 885 ASSERT_EQ(test_api_->GetButtonCount(), test_api_->GetLastVisibleIndex() + 1); |
897 test_api_->GetLastVisibleIndex() + 1); | |
898 | 886 |
899 // Add platform app button until overflow, remember last visible platform app | 887 // Add platform app button until overflow, remember last visible platform app |
900 // button. | 888 // button. |
901 int items_added = 0; | 889 int items_added = 0; |
902 ShelfID first_added = AddPlatformApp(); | 890 ShelfID first_added = AddPlatformApp(); |
903 EXPECT_TRUE(GetButtonByID(first_added)->visible()); | 891 EXPECT_TRUE(GetButtonByID(first_added)->visible()); |
904 while (true) { | 892 while (true) { |
905 ShelfID added = AddPlatformApp(); | 893 ShelfID added = AddPlatformApp(); |
906 if (test_api_->IsOverflowButtonVisible()) { | 894 if (test_api_->IsOverflowButtonVisible()) { |
907 EXPECT_FALSE(GetButtonByID(added)->visible()); | 895 EXPECT_FALSE(GetButtonByID(added)->visible()); |
908 RemoveByID(added); | 896 RemoveByID(added); |
909 break; | 897 break; |
910 } | 898 } |
911 ++items_added; | 899 ++items_added; |
912 ASSERT_LT(items_added, 10000); | 900 ASSERT_LT(items_added, 10000); |
913 } | 901 } |
914 | 902 |
915 ShelfID panel = AddPanel(); | 903 ShelfID panel = AddPanel(); |
916 EXPECT_TRUE(test_api_->IsOverflowButtonVisible()); | 904 EXPECT_TRUE(test_api_->IsOverflowButtonVisible()); |
917 | 905 |
918 RemoveByID(panel); | 906 RemoveByID(panel); |
919 EXPECT_FALSE(test_api_->IsOverflowButtonVisible()); | 907 EXPECT_FALSE(test_api_->IsOverflowButtonVisible()); |
920 } | 908 } |
921 | 909 |
922 // When there are more panels then platform app buttons we should hide panels | 910 // When there are more panels then platform app buttons we should hide panels |
923 // rather than platform apps. | 911 // rather than platform apps. |
924 TEST_F(ShelfViewTest, PlatformAppHidesExcessPanels) { | 912 TEST_F(ShelfViewTest, PlatformAppHidesExcessPanels) { |
925 // All buttons should be visible. | 913 // All buttons should be visible. |
926 ASSERT_EQ(test_api_->GetButtonCount(), | 914 ASSERT_EQ(test_api_->GetButtonCount(), test_api_->GetLastVisibleIndex() + 1); |
927 test_api_->GetLastVisibleIndex() + 1); | |
928 | 915 |
929 // Add platform app button. | 916 // Add platform app button. |
930 ShelfID platform_app = AddPlatformApp(); | 917 ShelfID platform_app = AddPlatformApp(); |
931 ShelfID first_panel = AddPanel(); | 918 ShelfID first_panel = AddPanel(); |
932 | 919 |
933 EXPECT_TRUE(GetButtonByID(platform_app)->visible()); | 920 EXPECT_TRUE(GetButtonByID(platform_app)->visible()); |
934 EXPECT_TRUE(GetButtonByID(first_panel)->visible()); | 921 EXPECT_TRUE(GetButtonByID(first_panel)->visible()); |
935 | 922 |
936 // Add panels until there is an overflow. | 923 // Add panels until there is an overflow. |
937 ShelfID last_panel = first_panel; | 924 ShelfID last_panel = first_panel; |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1044 EXPECT_EQ(kArrows[i], | 1031 EXPECT_EQ(kArrows[i], |
1045 bubble_view_api.GetBubbleFrameView()->bubble_border()->arrow()); | 1032 bubble_view_api.GetBubbleFrameView()->bubble_border()->arrow()); |
1046 } | 1033 } |
1047 } | 1034 } |
1048 | 1035 |
1049 // Adds button until overflow then removes first added one. Verifies that | 1036 // Adds button until overflow then removes first added one. Verifies that |
1050 // the last added one changes from invisible to visible and overflow | 1037 // the last added one changes from invisible to visible and overflow |
1051 // chevron is gone. | 1038 // chevron is gone. |
1052 TEST_F(ShelfViewTest, RemoveButtonRevealsOverflowed) { | 1039 TEST_F(ShelfViewTest, RemoveButtonRevealsOverflowed) { |
1053 // All buttons should be visible. | 1040 // All buttons should be visible. |
1054 ASSERT_EQ(test_api_->GetButtonCount(), | 1041 ASSERT_EQ(test_api_->GetButtonCount(), test_api_->GetLastVisibleIndex() + 1); |
1055 test_api_->GetLastVisibleIndex() + 1); | |
1056 | 1042 |
1057 // Add platform app buttons until overflow. | 1043 // Add platform app buttons until overflow. |
1058 int items_added = 0; | 1044 int items_added = 0; |
1059 ShelfID first_added = AddPlatformApp(); | 1045 ShelfID first_added = AddPlatformApp(); |
1060 ShelfID last_added = first_added; | 1046 ShelfID last_added = first_added; |
1061 while (!test_api_->IsOverflowButtonVisible()) { | 1047 while (!test_api_->IsOverflowButtonVisible()) { |
1062 last_added = AddPlatformApp(); | 1048 last_added = AddPlatformApp(); |
1063 ++items_added; | 1049 ++items_added; |
1064 ASSERT_LT(items_added, 10000); | 1050 ASSERT_LT(items_added, 10000); |
1065 } | 1051 } |
1066 | 1052 |
1067 // Expect add more than 1 button. First added is visible and last is not. | 1053 // Expect add more than 1 button. First added is visible and last is not. |
1068 EXPECT_NE(first_added, last_added); | 1054 EXPECT_NE(first_added, last_added); |
1069 EXPECT_TRUE(GetButtonByID(first_added)->visible()); | 1055 EXPECT_TRUE(GetButtonByID(first_added)->visible()); |
1070 EXPECT_FALSE(GetButtonByID(last_added)->visible()); | 1056 EXPECT_FALSE(GetButtonByID(last_added)->visible()); |
1071 | 1057 |
1072 // Remove first added. | 1058 // Remove first added. |
1073 RemoveByID(first_added); | 1059 RemoveByID(first_added); |
1074 | 1060 |
1075 // Last added button becomes visible and overflow chevron is gone. | 1061 // Last added button becomes visible and overflow chevron is gone. |
1076 EXPECT_TRUE(GetButtonByID(last_added)->visible()); | 1062 EXPECT_TRUE(GetButtonByID(last_added)->visible()); |
1077 EXPECT_EQ(1.0f, GetButtonByID(last_added)->layer()->opacity()); | 1063 EXPECT_EQ(1.0f, GetButtonByID(last_added)->layer()->opacity()); |
1078 EXPECT_FALSE(test_api_->IsOverflowButtonVisible()); | 1064 EXPECT_FALSE(test_api_->IsOverflowButtonVisible()); |
1079 } | 1065 } |
1080 | 1066 |
1081 // Verifies that remove last overflowed button should hide overflow chevron. | 1067 // Verifies that remove last overflowed button should hide overflow chevron. |
1082 TEST_F(ShelfViewTest, RemoveLastOverflowed) { | 1068 TEST_F(ShelfViewTest, RemoveLastOverflowed) { |
1083 // All buttons should be visible. | 1069 // All buttons should be visible. |
1084 ASSERT_EQ(test_api_->GetButtonCount(), | 1070 ASSERT_EQ(test_api_->GetButtonCount(), test_api_->GetLastVisibleIndex() + 1); |
1085 test_api_->GetLastVisibleIndex() + 1); | |
1086 | 1071 |
1087 // Add platform app button until overflow. | 1072 // Add platform app button until overflow. |
1088 int items_added = 0; | 1073 int items_added = 0; |
1089 ShelfID last_added = AddPlatformApp(); | 1074 ShelfID last_added = AddPlatformApp(); |
1090 while (!test_api_->IsOverflowButtonVisible()) { | 1075 while (!test_api_->IsOverflowButtonVisible()) { |
1091 last_added = AddPlatformApp(); | 1076 last_added = AddPlatformApp(); |
1092 ++items_added; | 1077 ++items_added; |
1093 ASSERT_LT(items_added, 10000); | 1078 ASSERT_LT(items_added, 10000); |
1094 } | 1079 } |
1095 | 1080 |
1096 RemoveByID(last_added); | 1081 RemoveByID(last_added); |
1097 EXPECT_FALSE(test_api_->IsOverflowButtonVisible()); | 1082 EXPECT_FALSE(test_api_->IsOverflowButtonVisible()); |
1098 } | 1083 } |
1099 | 1084 |
1100 // Adds platform app button without waiting for animation to finish and verifies | 1085 // Adds platform app button without waiting for animation to finish and verifies |
1101 // that all added buttons are visible. | 1086 // that all added buttons are visible. |
1102 TEST_F(ShelfViewTest, AddButtonQuickly) { | 1087 TEST_F(ShelfViewTest, AddButtonQuickly) { |
1103 // All buttons should be visible. | 1088 // All buttons should be visible. |
1104 ASSERT_EQ(test_api_->GetButtonCount(), | 1089 ASSERT_EQ(test_api_->GetButtonCount(), test_api_->GetLastVisibleIndex() + 1); |
1105 test_api_->GetLastVisibleIndex() + 1); | |
1106 | 1090 |
1107 // Add a few platform buttons quickly without wait for animation. | 1091 // Add a few platform buttons quickly without wait for animation. |
1108 int added_count = 0; | 1092 int added_count = 0; |
1109 while (!test_api_->IsOverflowButtonVisible()) { | 1093 while (!test_api_->IsOverflowButtonVisible()) { |
1110 AddPlatformAppNoWait(); | 1094 AddPlatformAppNoWait(); |
1111 ++added_count; | 1095 ++added_count; |
1112 ASSERT_LT(added_count, 10000); | 1096 ASSERT_LT(added_count, 10000); |
1113 } | 1097 } |
1114 | 1098 |
1115 // ShelfView should be big enough to hold at least 3 new buttons. | 1099 // ShelfView should be big enough to hold at least 3 new buttons. |
1116 ASSERT_GE(added_count, 3); | 1100 ASSERT_GE(added_count, 3); |
1117 | 1101 |
1118 // Wait for the last animation to finish. | 1102 // Wait for the last animation to finish. |
1119 test_api_->RunMessageLoopUntilAnimationsDone(); | 1103 test_api_->RunMessageLoopUntilAnimationsDone(); |
1120 | 1104 |
1121 // Verifies non-overflow buttons are visible. | 1105 // Verifies non-overflow buttons are visible. |
1122 for (int i = 0; i <= test_api_->GetLastVisibleIndex(); ++i) { | 1106 for (int i = 0; i <= test_api_->GetLastVisibleIndex(); ++i) { |
1123 ShelfButton* button = test_api_->GetButton(i); | 1107 ShelfButton* button = test_api_->GetButton(i); |
1124 if (button) { | 1108 if (button) { |
1125 EXPECT_TRUE(button->visible()) << "button index=" << i; | 1109 EXPECT_TRUE(button->visible()) << "button index=" << i; |
1126 EXPECT_EQ(1.0f, button->layer()->opacity()) << "button index=" << i; | 1110 EXPECT_EQ(1.0f, button->layer()->opacity()) << "button index=" << i; |
1127 } | 1111 } |
1128 } | 1112 } |
1129 } | 1113 } |
1130 | 1114 |
1131 // Check that model changes are handled correctly while a shelf icon is being | 1115 // Check that model changes are handled correctly while a shelf icon is being |
1132 // dragged. | 1116 // dragged. |
1133 TEST_F(ShelfViewTest, ModelChangesWhileDragging) { | 1117 TEST_F(ShelfViewTest, ModelChangesWhileDragging) { |
1134 std::vector<std::pair<ShelfID, views::View*> > id_map; | 1118 std::vector<std::pair<ShelfID, views::View*>> id_map; |
1135 SetupForDragTest(&id_map); | 1119 SetupForDragTest(&id_map); |
1136 | 1120 |
1137 // Dragging browser shortcut at index 1. | 1121 // Dragging browser shortcut at index 1. |
1138 EXPECT_TRUE(model_->items()[1].type == TYPE_BROWSER_SHORTCUT); | 1122 EXPECT_TRUE(model_->items()[1].type == TYPE_BROWSER_SHORTCUT); |
1139 views::View* dragged_button = SimulateDrag(ShelfView::MOUSE, 1, 3, false); | 1123 views::View* dragged_button = SimulateDrag(ShelfView::MOUSE, 1, 3, false); |
1140 std::rotate(id_map.begin() + 1, | 1124 std::rotate(id_map.begin() + 1, id_map.begin() + 2, id_map.begin() + 4); |
1141 id_map.begin() + 2, | |
1142 id_map.begin() + 4); | |
1143 ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map)); | 1125 ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map)); |
1144 shelf_view_->PointerReleasedOnButton(dragged_button, ShelfView::MOUSE, false); | 1126 shelf_view_->PointerReleasedOnButton(dragged_button, ShelfView::MOUSE, false); |
1145 EXPECT_TRUE(model_->items()[3].type == TYPE_BROWSER_SHORTCUT); | 1127 EXPECT_TRUE(model_->items()[3].type == TYPE_BROWSER_SHORTCUT); |
1146 | 1128 |
1147 // Dragging changes model order. | 1129 // Dragging changes model order. |
1148 dragged_button = SimulateDrag(ShelfView::MOUSE, 1, 3, false); | 1130 dragged_button = SimulateDrag(ShelfView::MOUSE, 1, 3, false); |
1149 std::rotate(id_map.begin() + 1, | 1131 std::rotate(id_map.begin() + 1, id_map.begin() + 2, id_map.begin() + 4); |
1150 id_map.begin() + 2, | |
1151 id_map.begin() + 4); | |
1152 ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map)); | 1132 ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map)); |
1153 | 1133 |
1154 // Cancelling the drag operation restores previous order. | 1134 // Cancelling the drag operation restores previous order. |
1155 shelf_view_->PointerReleasedOnButton(dragged_button, ShelfView::MOUSE, true); | 1135 shelf_view_->PointerReleasedOnButton(dragged_button, ShelfView::MOUSE, true); |
1156 std::rotate(id_map.begin() + 1, | 1136 std::rotate(id_map.begin() + 1, id_map.begin() + 3, id_map.begin() + 4); |
1157 id_map.begin() + 3, | |
1158 id_map.begin() + 4); | |
1159 ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map)); | 1137 ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map)); |
1160 | 1138 |
1161 // Deleting an item keeps the remaining intact. | 1139 // Deleting an item keeps the remaining intact. |
1162 dragged_button = SimulateDrag(ShelfView::MOUSE, 1, 3, false); | 1140 dragged_button = SimulateDrag(ShelfView::MOUSE, 1, 3, false); |
1163 model_->RemoveItemAt(1); | 1141 model_->RemoveItemAt(1); |
1164 id_map.erase(id_map.begin() + 1); | 1142 id_map.erase(id_map.begin() + 1); |
1165 ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map)); | 1143 ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map)); |
1166 shelf_view_->PointerReleasedOnButton(dragged_button, ShelfView::MOUSE, false); | 1144 shelf_view_->PointerReleasedOnButton(dragged_button, ShelfView::MOUSE, false); |
1167 | 1145 |
1168 // Adding a shelf item cancels the drag and respects the order. | 1146 // Adding a shelf item cancels the drag and respects the order. |
1169 dragged_button = SimulateDrag(ShelfView::MOUSE, 1, 3, false); | 1147 dragged_button = SimulateDrag(ShelfView::MOUSE, 1, 3, false); |
1170 ShelfID new_id = AddAppShortcut(); | 1148 ShelfID new_id = AddAppShortcut(); |
1171 id_map.insert(id_map.begin() + 6, | 1149 id_map.insert(id_map.begin() + 6, |
1172 std::make_pair(new_id, GetButtonByID(new_id))); | 1150 std::make_pair(new_id, GetButtonByID(new_id))); |
1173 ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map)); | 1151 ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map)); |
1174 shelf_view_->PointerReleasedOnButton(dragged_button, ShelfView::MOUSE, false); | 1152 shelf_view_->PointerReleasedOnButton(dragged_button, ShelfView::MOUSE, false); |
1175 | 1153 |
1176 // Adding a shelf item at the end (i.e. a panel) canels drag and respects | 1154 // Adding a shelf item at the end (i.e. a panel) canels drag and respects |
1177 // the order. | 1155 // the order. |
1178 dragged_button = SimulateDrag(ShelfView::MOUSE, 1, 3, false); | 1156 dragged_button = SimulateDrag(ShelfView::MOUSE, 1, 3, false); |
1179 new_id = AddPanel(); | 1157 new_id = AddPanel(); |
1180 id_map.insert(id_map.begin() + 7, | 1158 id_map.insert(id_map.begin() + 7, |
1181 std::make_pair(new_id, GetButtonByID(new_id))); | 1159 std::make_pair(new_id, GetButtonByID(new_id))); |
1182 ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map)); | 1160 ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map)); |
1183 shelf_view_->PointerReleasedOnButton(dragged_button, ShelfView::MOUSE, false); | 1161 shelf_view_->PointerReleasedOnButton(dragged_button, ShelfView::MOUSE, false); |
1184 } | 1162 } |
1185 | 1163 |
1186 // Check that 2nd drag from the other pointer would be ignored. | 1164 // Check that 2nd drag from the other pointer would be ignored. |
1187 TEST_F(ShelfViewTest, SimultaneousDrag) { | 1165 TEST_F(ShelfViewTest, SimultaneousDrag) { |
1188 std::vector<std::pair<ShelfID, views::View*> > id_map; | 1166 std::vector<std::pair<ShelfID, views::View*>> id_map; |
1189 SetupForDragTest(&id_map); | 1167 SetupForDragTest(&id_map); |
1190 | 1168 |
1191 // Start a mouse drag. | 1169 // Start a mouse drag. |
1192 views::View* dragged_button_mouse = | 1170 views::View* dragged_button_mouse = |
1193 SimulateDrag(ShelfView::MOUSE, 1, 3, false); | 1171 SimulateDrag(ShelfView::MOUSE, 1, 3, false); |
1194 std::rotate(id_map.begin() + 1, | 1172 std::rotate(id_map.begin() + 1, id_map.begin() + 2, id_map.begin() + 4); |
1195 id_map.begin() + 2, | |
1196 id_map.begin() + 4); | |
1197 ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map)); | 1173 ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map)); |
1198 // Attempt a touch drag before the mouse drag finishes. | 1174 // Attempt a touch drag before the mouse drag finishes. |
1199 views::View* dragged_button_touch = | 1175 views::View* dragged_button_touch = |
1200 SimulateDrag(ShelfView::TOUCH, 4, 2, false); | 1176 SimulateDrag(ShelfView::TOUCH, 4, 2, false); |
1201 | 1177 |
1202 // Nothing changes since 2nd drag is ignored. | 1178 // Nothing changes since 2nd drag is ignored. |
1203 ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map)); | 1179 ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map)); |
1204 | 1180 |
1205 // Finish the mouse drag. | 1181 // Finish the mouse drag. |
1206 shelf_view_->PointerReleasedOnButton(dragged_button_mouse, ShelfView::MOUSE, | 1182 shelf_view_->PointerReleasedOnButton(dragged_button_mouse, ShelfView::MOUSE, |
1207 false); | 1183 false); |
1208 ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map)); | 1184 ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map)); |
1209 | 1185 |
1210 // Now start a touch drag. | 1186 // Now start a touch drag. |
1211 dragged_button_touch = SimulateDrag(ShelfView::TOUCH, 4, 2, false); | 1187 dragged_button_touch = SimulateDrag(ShelfView::TOUCH, 4, 2, false); |
1212 std::rotate(id_map.begin() + 3, | 1188 std::rotate(id_map.begin() + 3, id_map.begin() + 4, id_map.begin() + 5); |
1213 id_map.begin() + 4, | |
1214 id_map.begin() + 5); | |
1215 ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map)); | 1189 ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map)); |
1216 | 1190 |
1217 // And attempt a mouse drag before the touch drag finishes. | 1191 // And attempt a mouse drag before the touch drag finishes. |
1218 dragged_button_mouse = SimulateDrag(ShelfView::MOUSE, 1, 2, false); | 1192 dragged_button_mouse = SimulateDrag(ShelfView::MOUSE, 1, 2, false); |
1219 | 1193 |
1220 // Nothing changes since 2nd drag is ignored. | 1194 // Nothing changes since 2nd drag is ignored. |
1221 ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map)); | 1195 ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map)); |
1222 | 1196 |
1223 shelf_view_->PointerReleasedOnButton(dragged_button_touch, ShelfView::TOUCH, | 1197 shelf_view_->PointerReleasedOnButton(dragged_button_touch, ShelfView::TOUCH, |
1224 false); | 1198 false); |
(...skipping 18 matching lines...) Expand all Loading... |
1243 | 1217 |
1244 std::rotate(id_map.begin() + 3, id_map.begin() + 4, id_map.begin() + 5); | 1218 std::rotate(id_map.begin() + 3, id_map.begin() + 4, id_map.begin() + 5); |
1245 ASSERT_NO_FATAL_FAILURE(DragAndVerify(4, 1, shelf_view_, id_map)); | 1219 ASSERT_NO_FATAL_FAILURE(DragAndVerify(4, 1, shelf_view_, id_map)); |
1246 std::rotate(id_map.begin() + 3, id_map.begin() + 5, id_map.begin() + 6); | 1220 std::rotate(id_map.begin() + 3, id_map.begin() + 5, id_map.begin() + 6); |
1247 ASSERT_NO_FATAL_FAILURE(DragAndVerify(5, 1, shelf_view_, id_map)); | 1221 ASSERT_NO_FATAL_FAILURE(DragAndVerify(5, 1, shelf_view_, id_map)); |
1248 } | 1222 } |
1249 | 1223 |
1250 // Check that clicking first on one item and then dragging another works as | 1224 // Check that clicking first on one item and then dragging another works as |
1251 // expected. | 1225 // expected. |
1252 TEST_F(ShelfViewTest, ClickOneDragAnother) { | 1226 TEST_F(ShelfViewTest, ClickOneDragAnother) { |
1253 std::vector<std::pair<ShelfID, views::View*> > id_map; | 1227 std::vector<std::pair<ShelfID, views::View*>> id_map; |
1254 SetupForDragTest(&id_map); | 1228 SetupForDragTest(&id_map); |
1255 | 1229 |
1256 // A click on item 1 is simulated. | 1230 // A click on item 1 is simulated. |
1257 SimulateClick(1); | 1231 SimulateClick(1); |
1258 | 1232 |
1259 // Dragging browser index at 0 should change the model order correctly. | 1233 // Dragging browser index at 0 should change the model order correctly. |
1260 EXPECT_TRUE(model_->items()[1].type == TYPE_BROWSER_SHORTCUT); | 1234 EXPECT_TRUE(model_->items()[1].type == TYPE_BROWSER_SHORTCUT); |
1261 views::View* dragged_button = SimulateDrag(ShelfView::MOUSE, 1, 3, false); | 1235 views::View* dragged_button = SimulateDrag(ShelfView::MOUSE, 1, 3, false); |
1262 std::rotate(id_map.begin() + 1, id_map.begin() + 2, id_map.begin() + 4); | 1236 std::rotate(id_map.begin() + 1, id_map.begin() + 2, id_map.begin() + 4); |
1263 ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map)); | 1237 ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map)); |
(...skipping 15 matching lines...) Expand all Loading... |
1279 | 1253 |
1280 // A double-click does not select the item. | 1254 // A double-click does not select the item. |
1281 selection_tracker->Reset(); | 1255 selection_tracker->Reset(); |
1282 SimulateDoubleClick(browser_index_); | 1256 SimulateDoubleClick(browser_index_); |
1283 EXPECT_FALSE(selection_tracker->WasSelected()); | 1257 EXPECT_FALSE(selection_tracker->WasSelected()); |
1284 } | 1258 } |
1285 | 1259 |
1286 // Check that clicking an item and jittering the mouse a bit still selects the | 1260 // Check that clicking an item and jittering the mouse a bit still selects the |
1287 // item. | 1261 // item. |
1288 TEST_F(ShelfViewTest, ClickAndMoveSlightly) { | 1262 TEST_F(ShelfViewTest, ClickAndMoveSlightly) { |
1289 std::vector<std::pair<ShelfID, views::View*> > id_map; | 1263 std::vector<std::pair<ShelfID, views::View*>> id_map; |
1290 SetupForDragTest(&id_map); | 1264 SetupForDragTest(&id_map); |
1291 | 1265 |
1292 ShelfID shelf_id = (id_map.begin() + 1)->first; | 1266 ShelfID shelf_id = (id_map.begin() + 1)->first; |
1293 views::View* button = (id_map.begin() + 1)->second; | 1267 views::View* button = (id_map.begin() + 1)->second; |
1294 | 1268 |
1295 // Replace the ShelfItemDelegate for |shelf_id| with one which tracks whether | 1269 // Replace the ShelfItemDelegate for |shelf_id| with one which tracks whether |
1296 // the shelf item gets selected. | 1270 // the shelf item gets selected. |
1297 ShelfItemSelectionTracker* selection_tracker = new ShelfItemSelectionTracker; | 1271 ShelfItemSelectionTracker* selection_tracker = new ShelfItemSelectionTracker; |
1298 item_manager_->SetShelfItemDelegate( | 1272 item_manager_->SetShelfItemDelegate( |
1299 shelf_id, std::unique_ptr<ShelfItemDelegate>(selection_tracker)); | 1273 shelf_id, std::unique_ptr<ShelfItemDelegate>(selection_tracker)); |
(...skipping 25 matching lines...) Expand all Loading... |
1325 press_location_in_screen + gfx::Vector2d(-1, 0), ui::EventTimeForNow(), | 1299 press_location_in_screen + gfx::Vector2d(-1, 0), ui::EventTimeForNow(), |
1326 ui::EF_LEFT_MOUSE_BUTTON, 0); | 1300 ui::EF_LEFT_MOUSE_BUTTON, 0); |
1327 button->OnMouseReleased(release_event); | 1301 button->OnMouseReleased(release_event); |
1328 | 1302 |
1329 EXPECT_TRUE(selection_tracker->WasSelected()); | 1303 EXPECT_TRUE(selection_tracker->WasSelected()); |
1330 } | 1304 } |
1331 | 1305 |
1332 // Confirm that item status changes are reflected in the buttons. | 1306 // Confirm that item status changes are reflected in the buttons. |
1333 TEST_F(ShelfViewTest, ShelfItemStatus) { | 1307 TEST_F(ShelfViewTest, ShelfItemStatus) { |
1334 // All buttons should be visible. | 1308 // All buttons should be visible. |
1335 ASSERT_EQ(test_api_->GetButtonCount(), | 1309 ASSERT_EQ(test_api_->GetButtonCount(), test_api_->GetLastVisibleIndex() + 1); |
1336 test_api_->GetLastVisibleIndex() + 1); | |
1337 | 1310 |
1338 // Add platform app button. | 1311 // Add platform app button. |
1339 ShelfID last_added = AddPlatformApp(); | 1312 ShelfID last_added = AddPlatformApp(); |
1340 ShelfItem item = GetItemByID(last_added); | 1313 ShelfItem item = GetItemByID(last_added); |
1341 int index = model_->ItemIndexByID(last_added); | 1314 int index = model_->ItemIndexByID(last_added); |
1342 ShelfButton* button = GetButtonByID(last_added); | 1315 ShelfButton* button = GetButtonByID(last_added); |
1343 ASSERT_EQ(ShelfButton::STATE_RUNNING, button->state()); | 1316 ASSERT_EQ(ShelfButton::STATE_RUNNING, button->state()); |
1344 item.status = STATUS_ACTIVE; | 1317 item.status = STATUS_ACTIVE; |
1345 model_->Set(index, item); | 1318 model_->Set(index, item); |
1346 ASSERT_EQ(ShelfButton::STATE_ACTIVE, button->state()); | 1319 ASSERT_EQ(ShelfButton::STATE_ACTIVE, button->state()); |
1347 item.status = STATUS_ATTENTION; | 1320 item.status = STATUS_ATTENTION; |
1348 model_->Set(index, item); | 1321 model_->Set(index, item); |
1349 ASSERT_EQ(ShelfButton::STATE_ATTENTION, button->state()); | 1322 ASSERT_EQ(ShelfButton::STATE_ATTENTION, button->state()); |
1350 } | 1323 } |
1351 | 1324 |
1352 // Confirm that item status changes are reflected in the buttons | 1325 // Confirm that item status changes are reflected in the buttons |
1353 // for platform apps. | 1326 // for platform apps. |
1354 TEST_F(ShelfViewTest, ShelfItemStatusPlatformApp) { | 1327 TEST_F(ShelfViewTest, ShelfItemStatusPlatformApp) { |
1355 // All buttons should be visible. | 1328 // All buttons should be visible. |
1356 ASSERT_EQ(test_api_->GetButtonCount(), | 1329 ASSERT_EQ(test_api_->GetButtonCount(), test_api_->GetLastVisibleIndex() + 1); |
1357 test_api_->GetLastVisibleIndex() + 1); | |
1358 | 1330 |
1359 // Add platform app button. | 1331 // Add platform app button. |
1360 ShelfID last_added = AddPlatformApp(); | 1332 ShelfID last_added = AddPlatformApp(); |
1361 ShelfItem item = GetItemByID(last_added); | 1333 ShelfItem item = GetItemByID(last_added); |
1362 int index = model_->ItemIndexByID(last_added); | 1334 int index = model_->ItemIndexByID(last_added); |
1363 ShelfButton* button = GetButtonByID(last_added); | 1335 ShelfButton* button = GetButtonByID(last_added); |
1364 ASSERT_EQ(ShelfButton::STATE_RUNNING, button->state()); | 1336 ASSERT_EQ(ShelfButton::STATE_RUNNING, button->state()); |
1365 item.status = STATUS_ACTIVE; | 1337 item.status = STATUS_ACTIVE; |
1366 model_->Set(index, item); | 1338 model_->Set(index, item); |
1367 ASSERT_EQ(ShelfButton::STATE_ACTIVE, button->state()); | 1339 ASSERT_EQ(ShelfButton::STATE_ACTIVE, button->state()); |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1576 // Wait until the delayed close kicked in. | 1548 // Wait until the delayed close kicked in. |
1577 RunAllPendingInMessageLoop(); | 1549 RunAllPendingInMessageLoop(); |
1578 EXPECT_FALSE(tooltip_manager->IsVisible()); | 1550 EXPECT_FALSE(tooltip_manager->IsVisible()); |
1579 } | 1551 } |
1580 | 1552 |
1581 // Resizing shelf view while an add animation without fade-in is running, | 1553 // Resizing shelf view while an add animation without fade-in is running, |
1582 // which happens when overflow happens. App list button should end up in its | 1554 // which happens when overflow happens. App list button should end up in its |
1583 // new ideal bounds. | 1555 // new ideal bounds. |
1584 TEST_F(ShelfViewTest, ResizeDuringOverflowAddAnimation) { | 1556 TEST_F(ShelfViewTest, ResizeDuringOverflowAddAnimation) { |
1585 // All buttons should be visible. | 1557 // All buttons should be visible. |
1586 ASSERT_EQ(test_api_->GetButtonCount(), | 1558 ASSERT_EQ(test_api_->GetButtonCount(), test_api_->GetLastVisibleIndex() + 1); |
1587 test_api_->GetLastVisibleIndex() + 1); | |
1588 | 1559 |
1589 // Add buttons until overflow. Let the non-overflow add animations finish but | 1560 // Add buttons until overflow. Let the non-overflow add animations finish but |
1590 // leave the last running. | 1561 // leave the last running. |
1591 int items_added = 0; | 1562 int items_added = 0; |
1592 AddPlatformAppNoWait(); | 1563 AddPlatformAppNoWait(); |
1593 while (!test_api_->IsOverflowButtonVisible()) { | 1564 while (!test_api_->IsOverflowButtonVisible()) { |
1594 test_api_->RunMessageLoopUntilAnimationsDone(); | 1565 test_api_->RunMessageLoopUntilAnimationsDone(); |
1595 AddPlatformAppNoWait(); | 1566 AddPlatformAppNoWait(); |
1596 ++items_added; | 1567 ++items_added; |
1597 ASSERT_LT(items_added, 10000); | 1568 ASSERT_LT(items_added, 10000); |
(...skipping 29 matching lines...) Expand all Loading... |
1627 test_api_->ShowOverflowBubble(); | 1598 test_api_->ShowOverflowBubble(); |
1628 ASSERT_TRUE(test_api_->overflow_bubble() && | 1599 ASSERT_TRUE(test_api_->overflow_bubble() && |
1629 test_api_->overflow_bubble()->IsShowing()); | 1600 test_api_->overflow_bubble()->IsShowing()); |
1630 | 1601 |
1631 ShelfViewTestAPI test_for_overflow_view( | 1602 ShelfViewTestAPI test_for_overflow_view( |
1632 test_api_->overflow_bubble()->shelf_view()); | 1603 test_api_->overflow_bubble()->shelf_view()); |
1633 | 1604 |
1634 int ripped_index = test_for_overflow_view.GetLastVisibleIndex(); | 1605 int ripped_index = test_for_overflow_view.GetLastVisibleIndex(); |
1635 gfx::Size bubble_size = test_for_overflow_view.GetPreferredSize(); | 1606 gfx::Size bubble_size = test_for_overflow_view.GetPreferredSize(); |
1636 int item_width = test_for_overflow_view.GetButtonSize() + | 1607 int item_width = test_for_overflow_view.GetButtonSize() + |
1637 test_for_overflow_view.GetButtonSpacing(); | 1608 test_for_overflow_view.GetButtonSpacing(); |
1638 | 1609 |
1639 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), | 1610 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), |
1640 gfx::Point()); | 1611 gfx::Point()); |
1641 ShelfButton* button = test_for_overflow_view.GetButton(ripped_index); | 1612 ShelfButton* button = test_for_overflow_view.GetButton(ripped_index); |
1642 // Rip off the last visible item. | 1613 // Rip off the last visible item. |
1643 gfx::Point start_point = button->GetBoundsInScreen().CenterPoint(); | 1614 gfx::Point start_point = button->GetBoundsInScreen().CenterPoint(); |
1644 gfx::Point rip_off_point(start_point.x(), 0); | 1615 gfx::Point rip_off_point(start_point.x(), 0); |
1645 generator.MoveMouseTo(start_point.x(), start_point.y()); | 1616 generator.MoveMouseTo(start_point.x(), start_point.y()); |
1646 base::RunLoop().RunUntilIdle(); | 1617 base::RunLoop().RunUntilIdle(); |
1647 generator.PressLeftButton(); | 1618 generator.PressLeftButton(); |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1753 | 1724 |
1754 ShelfButton* button = test_api_for_overflow_view.GetButton( | 1725 ShelfButton* button = test_api_for_overflow_view.GetButton( |
1755 test_api_for_overflow_view.GetLastVisibleIndex()); | 1726 test_api_for_overflow_view.GetLastVisibleIndex()); |
1756 | 1727 |
1757 // Checks that a point in shelf is contained in drag insert bounds. | 1728 // Checks that a point in shelf is contained in drag insert bounds. |
1758 gfx::Point point_in_shelf_view = button->GetBoundsInScreen().CenterPoint(); | 1729 gfx::Point point_in_shelf_view = button->GetBoundsInScreen().CenterPoint(); |
1759 gfx::Rect drag_reinsert_bounds = | 1730 gfx::Rect drag_reinsert_bounds = |
1760 test_api_for_overflow_view.GetBoundsForDragInsertInScreen(); | 1731 test_api_for_overflow_view.GetBoundsForDragInsertInScreen(); |
1761 EXPECT_TRUE(drag_reinsert_bounds.Contains(point_in_shelf_view)); | 1732 EXPECT_TRUE(drag_reinsert_bounds.Contains(point_in_shelf_view)); |
1762 // Checks that a point out of shelf is not contained in drag insert bounds. | 1733 // Checks that a point out of shelf is not contained in drag insert bounds. |
1763 EXPECT_FALSE(drag_reinsert_bounds.Contains( | 1734 EXPECT_FALSE( |
1764 gfx::Point(point_in_shelf_view.x(), 0))); | 1735 drag_reinsert_bounds.Contains(gfx::Point(point_in_shelf_view.x(), 0))); |
1765 | 1736 |
1766 // Test #2: Test drag insertion bounds of secondary shelf. | 1737 // Test #2: Test drag insertion bounds of secondary shelf. |
1767 // Show overflow bubble. | 1738 // Show overflow bubble. |
1768 test_api_for_secondary.ShowOverflowBubble(); | 1739 test_api_for_secondary.ShowOverflowBubble(); |
1769 ASSERT_TRUE(test_api_for_secondary.overflow_bubble() && | 1740 ASSERT_TRUE(test_api_for_secondary.overflow_bubble() && |
1770 test_api_for_secondary.overflow_bubble()->IsShowing()); | 1741 test_api_for_secondary.overflow_bubble()->IsShowing()); |
1771 | 1742 |
1772 ShelfViewTestAPI test_api_for_overflow_view_of_secondary( | 1743 ShelfViewTestAPI test_api_for_overflow_view_of_secondary( |
1773 test_api_for_secondary.overflow_bubble()->shelf_view()); | 1744 test_api_for_secondary.overflow_bubble()->shelf_view()); |
1774 | 1745 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1858 EXPECT_FALSE(GetButtonByID(platform_app_id)->visible()); | 1829 EXPECT_FALSE(GetButtonByID(platform_app_id)->visible()); |
1859 } | 1830 } |
1860 | 1831 |
1861 // Tests that the AppListButton renders as active in response to touches. | 1832 // Tests that the AppListButton renders as active in response to touches. |
1862 TEST_F(ShelfViewTest, AppListButtonTouchFeedback) { | 1833 TEST_F(ShelfViewTest, AppListButtonTouchFeedback) { |
1863 AppListButton* app_list_button = | 1834 AppListButton* app_list_button = |
1864 static_cast<AppListButton*>(shelf_view_->GetAppListButtonView()); | 1835 static_cast<AppListButton*>(shelf_view_->GetAppListButtonView()); |
1865 EXPECT_FALSE(app_list_button->draw_background_as_active()); | 1836 EXPECT_FALSE(app_list_button->draw_background_as_active()); |
1866 | 1837 |
1867 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); | 1838 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
1868 generator.set_current_location(app_list_button-> | 1839 generator.set_current_location( |
1869 GetBoundsInScreen().CenterPoint()); | 1840 app_list_button->GetBoundsInScreen().CenterPoint()); |
1870 generator.PressTouch(); | 1841 generator.PressTouch(); |
1871 EXPECT_TRUE(app_list_button->draw_background_as_active()); | 1842 EXPECT_TRUE(app_list_button->draw_background_as_active()); |
1872 | 1843 |
1873 generator.ReleaseTouch(); | 1844 generator.ReleaseTouch(); |
1874 EXPECT_FALSE(app_list_button->draw_background_as_active()); | 1845 EXPECT_FALSE(app_list_button->draw_background_as_active()); |
1875 EXPECT_TRUE(Shell::GetInstance()->GetAppListTargetVisibility()); | 1846 EXPECT_TRUE(Shell::GetInstance()->GetAppListTargetVisibility()); |
1876 } | 1847 } |
1877 | 1848 |
1878 // Tests that a touch that slides out of the bounds of the AppListButton leads | 1849 // Tests that a touch that slides out of the bounds of the AppListButton leads |
1879 // to the end of rendering an active state. | 1850 // to the end of rendering an active state. |
1880 TEST_F(ShelfViewTest, AppListButtonTouchFeedbackCancellation) { | 1851 TEST_F(ShelfViewTest, AppListButtonTouchFeedbackCancellation) { |
1881 AppListButton* app_list_button = | 1852 AppListButton* app_list_button = |
1882 static_cast<AppListButton*>(shelf_view_->GetAppListButtonView()); | 1853 static_cast<AppListButton*>(shelf_view_->GetAppListButtonView()); |
1883 EXPECT_FALSE(app_list_button->draw_background_as_active()); | 1854 EXPECT_FALSE(app_list_button->draw_background_as_active()); |
1884 | 1855 |
1885 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); | 1856 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
1886 generator.set_current_location(app_list_button-> | 1857 generator.set_current_location( |
1887 GetBoundsInScreen().CenterPoint()); | 1858 app_list_button->GetBoundsInScreen().CenterPoint()); |
1888 generator.PressTouch(); | 1859 generator.PressTouch(); |
1889 EXPECT_TRUE(app_list_button->draw_background_as_active()); | 1860 EXPECT_TRUE(app_list_button->draw_background_as_active()); |
1890 | 1861 |
1891 gfx::Point moved_point(app_list_button->GetBoundsInScreen().right() + 1, | 1862 gfx::Point moved_point( |
1892 app_list_button-> | 1863 app_list_button->GetBoundsInScreen().right() + 1, |
1893 GetBoundsInScreen().CenterPoint().y()); | 1864 app_list_button->GetBoundsInScreen().CenterPoint().y()); |
1894 generator.MoveTouch(moved_point); | 1865 generator.MoveTouch(moved_point); |
1895 EXPECT_FALSE(app_list_button->draw_background_as_active()); | 1866 EXPECT_FALSE(app_list_button->draw_background_as_active()); |
1896 | 1867 |
1897 generator.set_current_location(moved_point); | 1868 generator.set_current_location(moved_point); |
1898 generator.ReleaseTouch(); | 1869 generator.ReleaseTouch(); |
1899 EXPECT_FALSE(app_list_button->draw_background_as_active()); | 1870 EXPECT_FALSE(app_list_button->draw_background_as_active()); |
1900 EXPECT_FALSE(Shell::GetInstance()->GetAppListTargetVisibility()); | 1871 EXPECT_FALSE(Shell::GetInstance()->GetAppListTargetVisibility()); |
1901 } | 1872 } |
1902 | 1873 |
1903 // Verifies that Launcher_ButtonPressed_* UMA user actions are recorded when an | 1874 // Verifies that Launcher_ButtonPressed_* UMA user actions are recorded when an |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1971 gfx::Rect shelf_bounds = shelf_view_->GetBoundsInScreen(); | 1942 gfx::Rect shelf_bounds = shelf_view_->GetBoundsInScreen(); |
1972 EXPECT_TRUE(shelf_bounds.Contains(visible_bounds)); | 1943 EXPECT_TRUE(shelf_bounds.Contains(visible_bounds)); |
1973 for (int i = 0; i < test_api_->GetButtonCount(); ++i) | 1944 for (int i = 0; i < test_api_->GetButtonCount(); ++i) |
1974 if (ShelfButton* button = test_api_->GetButton(i)) | 1945 if (ShelfButton* button = test_api_->GetButton(i)) |
1975 EXPECT_TRUE(visible_bounds.Contains(button->GetBoundsInScreen())); | 1946 EXPECT_TRUE(visible_bounds.Contains(button->GetBoundsInScreen())); |
1976 CheckAppListButtonIsInBounds(); | 1947 CheckAppListButtonIsInBounds(); |
1977 } | 1948 } |
1978 | 1949 |
1979 void CheckAppListButtonIsInBounds() { | 1950 void CheckAppListButtonIsInBounds() { |
1980 gfx::Rect visible_bounds = shelf_view_->GetVisibleItemsBoundsInScreen(); | 1951 gfx::Rect visible_bounds = shelf_view_->GetVisibleItemsBoundsInScreen(); |
1981 gfx::Rect app_list_button_bounds = shelf_view_->GetAppListButtonView()-> | 1952 gfx::Rect app_list_button_bounds = |
1982 GetBoundsInScreen(); | 1953 shelf_view_->GetAppListButtonView()->GetBoundsInScreen(); |
1983 EXPECT_TRUE(visible_bounds.Contains(app_list_button_bounds)); | 1954 EXPECT_TRUE(visible_bounds.Contains(app_list_button_bounds)); |
1984 } | 1955 } |
1985 | 1956 |
1986 private: | 1957 private: |
1987 ScopedTextDirectionChange text_direction_change_; | 1958 ScopedTextDirectionChange text_direction_change_; |
1988 | 1959 |
1989 DISALLOW_COPY_AND_ASSIGN(ShelfViewVisibleBoundsTest); | 1960 DISALLOW_COPY_AND_ASSIGN(ShelfViewVisibleBoundsTest); |
1990 }; | 1961 }; |
1991 | 1962 |
1992 TEST_P(ShelfViewVisibleBoundsTest, ItemsAreInBounds) { | 1963 TEST_P(ShelfViewVisibleBoundsTest, ItemsAreInBounds) { |
1993 // Adding elements leaving some empty space. | 1964 // Adding elements leaving some empty space. |
1994 for (int i = 0; i < 3; i++) { | 1965 for (int i = 0; i < 3; i++) { |
1995 AddAppShortcut(); | 1966 AddAppShortcut(); |
1996 } | 1967 } |
1997 test_api_->RunMessageLoopUntilAnimationsDone(); | 1968 test_api_->RunMessageLoopUntilAnimationsDone(); |
1998 EXPECT_FALSE(test_api_->IsOverflowButtonVisible()); | 1969 EXPECT_FALSE(test_api_->IsOverflowButtonVisible()); |
1999 CheckAllItemsAreInBounds(); | 1970 CheckAllItemsAreInBounds(); |
2000 // Same for overflow case. | 1971 // Same for overflow case. |
2001 while (!test_api_->IsOverflowButtonVisible()) { | 1972 while (!test_api_->IsOverflowButtonVisible()) { |
2002 AddAppShortcut(); | 1973 AddAppShortcut(); |
2003 } | 1974 } |
2004 test_api_->RunMessageLoopUntilAnimationsDone(); | 1975 test_api_->RunMessageLoopUntilAnimationsDone(); |
2005 CheckAllItemsAreInBounds(); | 1976 CheckAllItemsAreInBounds(); |
2006 } | 1977 } |
2007 | 1978 |
2008 INSTANTIATE_TEST_CASE_P(LtrRtl, ShelfViewTextDirectionTest, testing::Bool()); | 1979 INSTANTIATE_TEST_CASE_P(LtrRtl, ShelfViewTextDirectionTest, testing::Bool()); |
2009 INSTANTIATE_TEST_CASE_P(VisibleBounds, ShelfViewVisibleBoundsTest, | 1980 INSTANTIATE_TEST_CASE_P(VisibleBounds, |
2010 testing::Bool()); | 1981 ShelfViewVisibleBoundsTest, |
| 1982 testing::Bool()); |
2011 | 1983 |
2012 namespace { | 1984 namespace { |
2013 | 1985 |
2014 // An InkDrop implementation that wraps another InkDrop instance to keep track | 1986 // An InkDrop implementation that wraps another InkDrop instance to keep track |
2015 // of state changes requested on it. Note that this will only track transitions | 1987 // of state changes requested on it. Note that this will only track transitions |
2016 // routed through AnimateToState() and not the ones performed directly on the | 1988 // routed through AnimateToState() and not the ones performed directly on the |
2017 // ripple inside the contained |ink_drop|. | 1989 // ripple inside the contained |ink_drop|. |
2018 class InkDropSpy : public views::InkDrop { | 1990 class InkDropSpy : public views::InkDrop { |
2019 public: | 1991 public: |
2020 explicit InkDropSpy(std::unique_ptr<views::InkDrop> ink_drop) | 1992 explicit InkDropSpy(std::unique_ptr<views::InkDrop> ink_drop) |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2281 ui::EF_LEFT_MOUSE_BUTTON, 0); | 2253 ui::EF_LEFT_MOUSE_BUTTON, 0); |
2282 button->OnMouseReleased(release_event); | 2254 button->OnMouseReleased(release_event); |
2283 EXPECT_EQ(views::InkDropState::HIDDEN, ink_drop_->GetTargetInkDropState()); | 2255 EXPECT_EQ(views::InkDropState::HIDDEN, ink_drop_->GetTargetInkDropState()); |
2284 EXPECT_THAT(ink_drop_->GetAndResetRequestedStates(), | 2256 EXPECT_THAT(ink_drop_->GetAndResetRequestedStates(), |
2285 ElementsAre(views::InkDropState::ACTIVATED, | 2257 ElementsAre(views::InkDropState::ACTIVATED, |
2286 views::InkDropState::DEACTIVATED)); | 2258 views::InkDropState::DEACTIVATED)); |
2287 } | 2259 } |
2288 | 2260 |
2289 } // namespace test | 2261 } // namespace test |
2290 } // namespace ash | 2262 } // namespace ash |
OLD | NEW |