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

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

Issue 2718763003: chromeos: makes more tests run in both mash and ash (Closed)
Patch Set: 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
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 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 widget.Show(); 190 widget.Show();
191 widget.GetNativeWindow()->parent()->RemoveChild(widget.GetNativeWindow()); 191 widget.GetNativeWindow()->parent()->RemoveChild(widget.GetNativeWindow());
192 shelf_view_test()->RunMessageLoopUntilAnimationsDone(); 192 shelf_view_test()->RunMessageLoopUntilAnimationsDone();
193 EXPECT_TRUE(observer()->icon_positions_changed()); 193 EXPECT_TRUE(observer()->icon_positions_changed());
194 observer()->Reset(); 194 observer()->Reset();
195 } 195 }
196 196
197 // Make sure creating/deleting an window on one displays notifies a 197 // Make sure creating/deleting an window on one displays notifies a
198 // shelf on external display as well as one on primary. 198 // shelf on external display as well as one on primary.
199 TEST_F(WmShelfObserverIconTest, AddRemoveWithMultipleDisplays) { 199 TEST_F(WmShelfObserverIconTest, AddRemoveWithMultipleDisplays) {
200 // TODO: investigate failure in mash, http://crbug.com/695751.
201 if (WmShell::Get()->IsRunningInMash())
202 return;
203
200 UpdateDisplay("400x400,400x400"); 204 UpdateDisplay("400x400,400x400");
201 WmWindow* second_root = WmShell::Get()->GetAllRootWindows()[1]; 205 WmWindow* second_root = WmShell::Get()->GetAllRootWindows()[1];
202 WmShelf* second_shelf = second_root->GetRootWindowController()->GetShelf(); 206 WmShelf* second_shelf = second_root->GetRootWindowController()->GetShelf();
203 TestWmShelfObserver second_observer(second_shelf); 207 TestWmShelfObserver second_observer(second_shelf);
204 208
205 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); 209 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
206 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 210 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
207 params.bounds = gfx::Rect(0, 0, 200, 200); 211 params.bounds = gfx::Rect(0, 0, 200, 200);
208 params.context = CurrentContext(); 212 params.context = CurrentContext();
209 views::Widget widget; 213 views::Widget widget;
(...skipping 1406 matching lines...) Expand 10 before | Expand all | Expand 10 after
1616 test_for_overflow_view.GetPreferredSize().width()); 1620 test_for_overflow_view.GetPreferredSize().width());
1617 1621
1618 generator.ReleaseLeftButton(); 1622 generator.ReleaseLeftButton();
1619 test_for_overflow_view.RunMessageLoopUntilAnimationsDone(); 1623 test_for_overflow_view.RunMessageLoopUntilAnimationsDone();
1620 EXPECT_EQ(bubble_size.width(), 1624 EXPECT_EQ(bubble_size.width(),
1621 test_for_overflow_view.GetPreferredSize().width()); 1625 test_for_overflow_view.GetPreferredSize().width());
1622 } 1626 }
1623 1627
1624 // Check the drag insertion bounds of scrolled overflow bubble. 1628 // Check the drag insertion bounds of scrolled overflow bubble.
1625 TEST_F(ShelfViewTest, CheckDragInsertBoundsOfScrolledOverflowBubble) { 1629 TEST_F(ShelfViewTest, CheckDragInsertBoundsOfScrolledOverflowBubble) {
1630 // TODO: investigate failure in mash, http://crbug.com/695751.
1631 if (WmShell::Get()->IsRunningInMash())
1632 return;
1633
1626 UpdateDisplay("400x300"); 1634 UpdateDisplay("400x300");
1627 1635
1628 EXPECT_EQ(2, model_->item_count()); 1636 EXPECT_EQ(2, model_->item_count());
1629 1637
1630 AddButtonsUntilOverflow(); 1638 AddButtonsUntilOverflow();
1631 1639
1632 // Show overflow bubble. 1640 // Show overflow bubble.
1633 test_api_->ShowOverflowBubble(); 1641 test_api_->ShowOverflowBubble();
1634 ASSERT_TRUE(test_api_->IsShowingOverflowBubble()); 1642 ASSERT_TRUE(test_api_->IsShowingOverflowBubble());
1635 1643
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
1796 // This app shortcut should be a swapped view in overflow bubble, which is 1804 // This app shortcut should be a swapped view in overflow bubble, which is
1797 // invisible. 1805 // invisible.
1798 SetShelfItemTypeToAppShortcut(platform_app_id); 1806 SetShelfItemTypeToAppShortcut(platform_app_id);
1799 EXPECT_FALSE(GetButtonByID(platform_app_id)->visible()); 1807 EXPECT_FALSE(GetButtonByID(platform_app_id)->visible());
1800 } 1808 }
1801 1809
1802 // Verifies that Launcher_ButtonPressed_* UMA user actions are recorded when an 1810 // Verifies that Launcher_ButtonPressed_* UMA user actions are recorded when an
1803 // item is selected. 1811 // item is selected.
1804 TEST_F(ShelfViewTest, 1812 TEST_F(ShelfViewTest,
1805 Launcher_ButtonPressedUserActionsRecordedWhenItemSelected) { 1813 Launcher_ButtonPressedUserActionsRecordedWhenItemSelected) {
1814 // TODO: investigate failure in mash, http://crbug.com/695751.
1815 if (WmShell::Get()->IsRunningInMash())
1816 return;
1817
1806 base::UserActionTester user_action_tester; 1818 base::UserActionTester user_action_tester;
1807 1819
1808 ShelfID browser_shelf_id = model_->items()[browser_index_].id; 1820 ShelfID browser_shelf_id = model_->items()[browser_index_].id;
1809 ShelfItemSelectionTracker* selection_tracker = new ShelfItemSelectionTracker; 1821 ShelfItemSelectionTracker* selection_tracker = new ShelfItemSelectionTracker;
1810 model_->SetShelfItemDelegate( 1822 model_->SetShelfItemDelegate(
1811 browser_shelf_id, std::unique_ptr<ShelfItemDelegate>(selection_tracker)); 1823 browser_shelf_id, std::unique_ptr<ShelfItemDelegate>(selection_tracker));
1812 1824
1813 SimulateClick(browser_index_); 1825 SimulateClick(browser_index_);
1814 EXPECT_EQ(1, 1826 EXPECT_EQ(1,
1815 user_action_tester.GetActionCount("Launcher_ButtonPressed_Mouse")); 1827 user_action_tester.GetActionCount("Launcher_ButtonPressed_Mouse"));
1816 } 1828 }
1817 1829
1818 // Verifies that Launcher_*Task UMA user actions are recorded when an item is 1830 // Verifies that Launcher_*Task UMA user actions are recorded when an item is
1819 // selected. 1831 // selected.
1820 TEST_F(ShelfViewTest, Launcher_TaskUserActionsRecordedWhenItemSelected) { 1832 TEST_F(ShelfViewTest, Launcher_TaskUserActionsRecordedWhenItemSelected) {
1833 // TODO: investigate failure in mash, http://crbug.com/695751.
1834 if (WmShell::Get()->IsRunningInMash())
1835 return;
1836
1821 base::UserActionTester user_action_tester; 1837 base::UserActionTester user_action_tester;
1822 1838
1823 ShelfID browser_shelf_id = model_->items()[browser_index_].id; 1839 ShelfID browser_shelf_id = model_->items()[browser_index_].id;
1824 ShelfItemSelectionTracker* selection_tracker = new ShelfItemSelectionTracker; 1840 ShelfItemSelectionTracker* selection_tracker = new ShelfItemSelectionTracker;
1825 selection_tracker->set_item_selected_action(SHELF_ACTION_NEW_WINDOW_CREATED); 1841 selection_tracker->set_item_selected_action(SHELF_ACTION_NEW_WINDOW_CREATED);
1826 model_->SetShelfItemDelegate( 1842 model_->SetShelfItemDelegate(
1827 browser_shelf_id, std::unique_ptr<ShelfItemDelegate>(selection_tracker)); 1843 browser_shelf_id, std::unique_ptr<ShelfItemDelegate>(selection_tracker));
1828 1844
1829 SimulateClick(browser_index_); 1845 SimulateClick(browser_index_);
1830 EXPECT_EQ(1, user_action_tester.GetActionCount("Launcher_LaunchTask")); 1846 EXPECT_EQ(1, user_action_tester.GetActionCount("Launcher_LaunchTask"));
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
2033 ShelfButton* browser_button_ = nullptr; 2049 ShelfButton* browser_button_ = nullptr;
2034 InkDropSpy* browser_button_ink_drop_ = nullptr; 2050 InkDropSpy* browser_button_ink_drop_ = nullptr;
2035 2051
2036 private: 2052 private:
2037 DISALLOW_COPY_AND_ASSIGN(ShelfViewInkDropTest); 2053 DISALLOW_COPY_AND_ASSIGN(ShelfViewInkDropTest);
2038 }; 2054 };
2039 2055
2040 // Tests that changing visibility of the app list transitions app list button's 2056 // Tests that changing visibility of the app list transitions app list button's
2041 // ink drop states correctly. 2057 // ink drop states correctly.
2042 TEST_F(ShelfViewInkDropTest, AppListButtonWhenVisibilityChanges) { 2058 TEST_F(ShelfViewInkDropTest, AppListButtonWhenVisibilityChanges) {
2059 // TODO: investigate failure in mash, http://crbug.com/695751.
2060 if (WmShell::Get()->IsRunningInMash())
2061 return;
2062
2043 InitAppListButtonInkDrop(); 2063 InitAppListButtonInkDrop();
2044 2064
2045 ShowAppList(); 2065 ShowAppList();
2046 FinishAppListVisibilityChange(); 2066 FinishAppListVisibilityChange();
2047 EXPECT_EQ(views::InkDropState::ACTIVATED, 2067 EXPECT_EQ(views::InkDropState::ACTIVATED,
2048 app_list_button_ink_drop_->GetTargetInkDropState()); 2068 app_list_button_ink_drop_->GetTargetInkDropState());
2049 EXPECT_THAT(app_list_button_ink_drop_->GetAndResetRequestedStates(), 2069 EXPECT_THAT(app_list_button_ink_drop_->GetAndResetRequestedStates(),
2050 ElementsAre(views::InkDropState::ACTIVATED)); 2070 ElementsAre(views::InkDropState::ACTIVATED));
2051 2071
2052 DismissAppList(); 2072 DismissAppList();
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
2086 EXPECT_EQ(views::InkDropState::ACTIVATED, 2106 EXPECT_EQ(views::InkDropState::ACTIVATED,
2087 app_list_button_ink_drop_->GetTargetInkDropState()); 2107 app_list_button_ink_drop_->GetTargetInkDropState());
2088 EXPECT_THAT(app_list_button_ink_drop_->GetAndResetRequestedStates(), 2108 EXPECT_THAT(app_list_button_ink_drop_->GetAndResetRequestedStates(),
2089 IsEmpty()); 2109 IsEmpty());
2090 } 2110 }
2091 2111
2092 // Tests that when the app list is visible, mouse press on the app list button, 2112 // Tests that when the app list is visible, mouse press on the app list button,
2093 // which dismisses the app list, transitions ink drop states correctly. Also, 2113 // which dismisses the app list, transitions ink drop states correctly. Also,
2094 // tests that mouse drag and mouse release does not affect the ink drop state. 2114 // tests that mouse drag and mouse release does not affect the ink drop state.
2095 TEST_F(ShelfViewInkDropTest, AppListButtonMouseEventsWhenVisible) { 2115 TEST_F(ShelfViewInkDropTest, AppListButtonMouseEventsWhenVisible) {
2116 // TODO: investigate failure in mash, http://crbug.com/695751.
2117 if (WmShell::Get()->IsRunningInMash())
2118 return;
2119
2096 InitAppListButtonInkDrop(); 2120 InitAppListButtonInkDrop();
2097 2121
2098 ShowAppList(); 2122 ShowAppList();
2099 FinishAppListVisibilityChange(); 2123 FinishAppListVisibilityChange();
2100 EXPECT_EQ(views::InkDropState::ACTIVATED, 2124 EXPECT_EQ(views::InkDropState::ACTIVATED,
2101 app_list_button_ink_drop_->GetTargetInkDropState()); 2125 app_list_button_ink_drop_->GetTargetInkDropState());
2102 EXPECT_THAT(app_list_button_ink_drop_->GetAndResetRequestedStates(), 2126 EXPECT_THAT(app_list_button_ink_drop_->GetAndResetRequestedStates(),
2103 ElementsAre(views::InkDropState::ACTIVATED)); 2127 ElementsAre(views::InkDropState::ACTIVATED));
2104 2128
2105 ui::test::EventGenerator& generator = GetEventGenerator(); 2129 ui::test::EventGenerator& generator = GetEventGenerator();
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
2149 FinishAppListVisibilityChange(); 2173 FinishAppListVisibilityChange();
2150 EXPECT_EQ(views::InkDropState::ACTIVATED, 2174 EXPECT_EQ(views::InkDropState::ACTIVATED,
2151 app_list_button_ink_drop_->GetTargetInkDropState()); 2175 app_list_button_ink_drop_->GetTargetInkDropState());
2152 EXPECT_THAT(app_list_button_ink_drop_->GetAndResetRequestedStates(), 2176 EXPECT_THAT(app_list_button_ink_drop_->GetAndResetRequestedStates(),
2153 ElementsAre(views::InkDropState::ACTIVATED)); 2177 ElementsAre(views::InkDropState::ACTIVATED));
2154 } 2178 }
2155 2179
2156 // Tests that when the app list is visible, tapping on the app list button 2180 // Tests that when the app list is visible, tapping on the app list button
2157 // transitions ink drop states correctly. 2181 // transitions ink drop states correctly.
2158 TEST_F(ShelfViewInkDropTest, AppListButtonGestureTapWhenVisible) { 2182 TEST_F(ShelfViewInkDropTest, AppListButtonGestureTapWhenVisible) {
2183 // TODO: investigate failure in mash, http://crbug.com/695751.
2184 if (WmShell::Get()->IsRunningInMash())
2185 return;
2186
2159 InitAppListButtonInkDrop(); 2187 InitAppListButtonInkDrop();
2160 2188
2161 ShowAppList(); 2189 ShowAppList();
2162 FinishAppListVisibilityChange(); 2190 FinishAppListVisibilityChange();
2163 EXPECT_EQ(views::InkDropState::ACTIVATED, 2191 EXPECT_EQ(views::InkDropState::ACTIVATED,
2164 app_list_button_ink_drop_->GetTargetInkDropState()); 2192 app_list_button_ink_drop_->GetTargetInkDropState());
2165 EXPECT_THAT(app_list_button_ink_drop_->GetAndResetRequestedStates(), 2193 EXPECT_THAT(app_list_button_ink_drop_->GetAndResetRequestedStates(),
2166 ElementsAre(views::InkDropState::ACTIVATED)); 2194 ElementsAre(views::InkDropState::ACTIVATED));
2167 2195
2168 ui::test::EventGenerator& generator = GetEventGenerator(); 2196 ui::test::EventGenerator& generator = GetEventGenerator();
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
2215 generator.ReleaseTouch(); 2243 generator.ReleaseTouch();
2216 EXPECT_EQ(views::InkDropState::HIDDEN, 2244 EXPECT_EQ(views::InkDropState::HIDDEN,
2217 app_list_button_ink_drop_->GetTargetInkDropState()); 2245 app_list_button_ink_drop_->GetTargetInkDropState());
2218 EXPECT_THAT(app_list_button_ink_drop_->GetAndResetRequestedStates(), 2246 EXPECT_THAT(app_list_button_ink_drop_->GetAndResetRequestedStates(),
2219 IsEmpty()); 2247 IsEmpty());
2220 } 2248 }
2221 2249
2222 // Tests that when the app list is visible, tapping down on the app list button 2250 // Tests that when the app list is visible, tapping down on the app list button
2223 // and dragging the touch point transitions ink drop states correctly. 2251 // and dragging the touch point transitions ink drop states correctly.
2224 TEST_F(ShelfViewInkDropTest, AppListButtonGestureTapDragWhenVisible) { 2252 TEST_F(ShelfViewInkDropTest, AppListButtonGestureTapDragWhenVisible) {
2253 // TODO: investigate failure in mash, http://crbug.com/695751.
2254 if (WmShell::Get()->IsRunningInMash())
2255 return;
2256
2225 InitAppListButtonInkDrop(); 2257 InitAppListButtonInkDrop();
2226 2258
2227 ShowAppList(); 2259 ShowAppList();
2228 FinishAppListVisibilityChange(); 2260 FinishAppListVisibilityChange();
2229 EXPECT_EQ(views::InkDropState::ACTIVATED, 2261 EXPECT_EQ(views::InkDropState::ACTIVATED,
2230 app_list_button_ink_drop_->GetTargetInkDropState()); 2262 app_list_button_ink_drop_->GetTargetInkDropState());
2231 EXPECT_THAT(app_list_button_ink_drop_->GetAndResetRequestedStates(), 2263 EXPECT_THAT(app_list_button_ink_drop_->GetAndResetRequestedStates(),
2232 ElementsAre(views::InkDropState::ACTIVATED)); 2264 ElementsAre(views::InkDropState::ACTIVATED));
2233 2265
2234 ui::test::EventGenerator& generator = GetEventGenerator(); 2266 ui::test::EventGenerator& generator = GetEventGenerator();
(...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after
2961 EXPECT_EQ(views::InkDropState::ACTIVATED, 2993 EXPECT_EQ(views::InkDropState::ACTIVATED,
2962 overflow_button_ink_drop_->GetTargetInkDropState()); 2994 overflow_button_ink_drop_->GetTargetInkDropState());
2963 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), 2995 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(),
2964 IsEmpty()); 2996 IsEmpty());
2965 2997
2966 ASSERT_TRUE(test_api_->IsShowingOverflowBubble()); 2998 ASSERT_TRUE(test_api_->IsShowingOverflowBubble());
2967 } 2999 }
2968 3000
2969 } // namespace test 3001 } // namespace test
2970 } // namespace ash 3002 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698