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> |
11 | 11 |
| 12 #include "ash/public/cpp/config.h" |
12 #include "ash/public/cpp/shell_window_ids.h" | 13 #include "ash/public/cpp/shell_window_ids.h" |
13 #include "ash/root_window_controller.h" | 14 #include "ash/root_window_controller.h" |
14 #include "ash/shelf/app_list_button.h" | 15 #include "ash/shelf/app_list_button.h" |
15 #include "ash/shelf/overflow_bubble.h" | 16 #include "ash/shelf/overflow_bubble.h" |
16 #include "ash/shelf/overflow_bubble_view.h" | 17 #include "ash/shelf/overflow_bubble_view.h" |
17 #include "ash/shelf/overflow_button.h" | 18 #include "ash/shelf/overflow_button.h" |
18 #include "ash/shelf/shelf_button.h" | 19 #include "ash/shelf/shelf_button.h" |
19 #include "ash/shelf/shelf_constants.h" | 20 #include "ash/shelf/shelf_constants.h" |
20 #include "ash/shelf/shelf_model.h" | 21 #include "ash/shelf/shelf_model.h" |
21 #include "ash/shelf/shelf_tooltip_manager.h" | 22 #include "ash/shelf/shelf_tooltip_manager.h" |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 widget.GetNativeWindow()->parent()->RemoveChild(widget.GetNativeWindow()); | 194 widget.GetNativeWindow()->parent()->RemoveChild(widget.GetNativeWindow()); |
194 shelf_view_test()->RunMessageLoopUntilAnimationsDone(); | 195 shelf_view_test()->RunMessageLoopUntilAnimationsDone(); |
195 EXPECT_TRUE(observer()->icon_positions_changed()); | 196 EXPECT_TRUE(observer()->icon_positions_changed()); |
196 observer()->Reset(); | 197 observer()->Reset(); |
197 } | 198 } |
198 | 199 |
199 // Make sure creating/deleting an window on one displays notifies a | 200 // Make sure creating/deleting an window on one displays notifies a |
200 // shelf on external display as well as one on primary. | 201 // shelf on external display as well as one on primary. |
201 TEST_F(WmShelfObserverIconTest, AddRemoveWithMultipleDisplays) { | 202 TEST_F(WmShelfObserverIconTest, AddRemoveWithMultipleDisplays) { |
202 // TODO: investigate failure in mash, http://crbug.com/695751. | 203 // TODO: investigate failure in mash, http://crbug.com/695751. |
203 if (ShellPort::Get()->IsRunningInMash()) | 204 if (Shell::GetAshConfig() == Config::MASH) |
204 return; | 205 return; |
205 | 206 |
206 UpdateDisplay("400x400,400x400"); | 207 UpdateDisplay("400x400,400x400"); |
207 WmWindow* second_root = ShellPort::Get()->GetAllRootWindows()[1]; | 208 WmWindow* second_root = ShellPort::Get()->GetAllRootWindows()[1]; |
208 WmShelf* second_shelf = second_root->GetRootWindowController()->GetShelf(); | 209 WmShelf* second_shelf = second_root->GetRootWindowController()->GetShelf(); |
209 TestWmShelfObserver second_observer(second_shelf); | 210 TestWmShelfObserver second_observer(second_shelf); |
210 | 211 |
211 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); | 212 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
212 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 213 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
213 params.bounds = gfx::Rect(0, 0, 200, 200); | 214 params.bounds = gfx::Rect(0, 0, 200, 200); |
(...skipping 1564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1778 // invisible. | 1779 // invisible. |
1779 SetShelfItemTypeToAppShortcut(platform_app_id); | 1780 SetShelfItemTypeToAppShortcut(platform_app_id); |
1780 EXPECT_FALSE(GetButtonByID(platform_app_id)->visible()); | 1781 EXPECT_FALSE(GetButtonByID(platform_app_id)->visible()); |
1781 } | 1782 } |
1782 | 1783 |
1783 // Verifies that Launcher_ButtonPressed_* UMA user actions are recorded when an | 1784 // Verifies that Launcher_ButtonPressed_* UMA user actions are recorded when an |
1784 // item is selected. | 1785 // item is selected. |
1785 TEST_F(ShelfViewTest, | 1786 TEST_F(ShelfViewTest, |
1786 Launcher_ButtonPressedUserActionsRecordedWhenItemSelected) { | 1787 Launcher_ButtonPressedUserActionsRecordedWhenItemSelected) { |
1787 // TODO: investigate failure in mash, http://crbug.com/695751. | 1788 // TODO: investigate failure in mash, http://crbug.com/695751. |
1788 if (ShellPort::Get()->IsRunningInMash()) | 1789 if (Shell::GetAshConfig() == Config::MASH) |
1789 return; | 1790 return; |
1790 | 1791 |
1791 base::UserActionTester user_action_tester; | 1792 base::UserActionTester user_action_tester; |
1792 | 1793 |
1793 ShelfID browser_shelf_id = model_->items()[browser_index_].id; | 1794 ShelfID browser_shelf_id = model_->items()[browser_index_].id; |
1794 ShelfItemSelectionTracker* selection_tracker = new ShelfItemSelectionTracker; | 1795 ShelfItemSelectionTracker* selection_tracker = new ShelfItemSelectionTracker; |
1795 model_->SetShelfItemDelegate( | 1796 model_->SetShelfItemDelegate( |
1796 browser_shelf_id, | 1797 browser_shelf_id, |
1797 base::WrapUnique<ShelfItemSelectionTracker>(selection_tracker)); | 1798 base::WrapUnique<ShelfItemSelectionTracker>(selection_tracker)); |
1798 | 1799 |
1799 SimulateClick(browser_index_); | 1800 SimulateClick(browser_index_); |
1800 EXPECT_EQ(1, | 1801 EXPECT_EQ(1, |
1801 user_action_tester.GetActionCount("Launcher_ButtonPressed_Mouse")); | 1802 user_action_tester.GetActionCount("Launcher_ButtonPressed_Mouse")); |
1802 } | 1803 } |
1803 | 1804 |
1804 // Verifies that Launcher_*Task UMA user actions are recorded when an item is | 1805 // Verifies that Launcher_*Task UMA user actions are recorded when an item is |
1805 // selected. | 1806 // selected. |
1806 TEST_F(ShelfViewTest, Launcher_TaskUserActionsRecordedWhenItemSelected) { | 1807 TEST_F(ShelfViewTest, Launcher_TaskUserActionsRecordedWhenItemSelected) { |
1807 // TODO: investigate failure in mash, http://crbug.com/695751. | 1808 // TODO: investigate failure in mash, http://crbug.com/695751. |
1808 if (ShellPort::Get()->IsRunningInMash()) | 1809 if (Shell::GetAshConfig() == Config::MASH) |
1809 return; | 1810 return; |
1810 | 1811 |
1811 base::UserActionTester user_action_tester; | 1812 base::UserActionTester user_action_tester; |
1812 | 1813 |
1813 ShelfID browser_shelf_id = model_->items()[browser_index_].id; | 1814 ShelfID browser_shelf_id = model_->items()[browser_index_].id; |
1814 ShelfItemSelectionTracker* selection_tracker = new ShelfItemSelectionTracker; | 1815 ShelfItemSelectionTracker* selection_tracker = new ShelfItemSelectionTracker; |
1815 selection_tracker->set_item_selected_action(SHELF_ACTION_NEW_WINDOW_CREATED); | 1816 selection_tracker->set_item_selected_action(SHELF_ACTION_NEW_WINDOW_CREATED); |
1816 model_->SetShelfItemDelegate( | 1817 model_->SetShelfItemDelegate( |
1817 browser_shelf_id, | 1818 browser_shelf_id, |
1818 base::WrapUnique<ShelfItemSelectionTracker>(selection_tracker)); | 1819 base::WrapUnique<ShelfItemSelectionTracker>(selection_tracker)); |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2090 InkDropSpy* browser_button_ink_drop_ = nullptr; | 2091 InkDropSpy* browser_button_ink_drop_ = nullptr; |
2091 | 2092 |
2092 private: | 2093 private: |
2093 DISALLOW_COPY_AND_ASSIGN(ShelfViewInkDropTest); | 2094 DISALLOW_COPY_AND_ASSIGN(ShelfViewInkDropTest); |
2094 }; | 2095 }; |
2095 | 2096 |
2096 // Tests that changing visibility of the app list transitions app list button's | 2097 // Tests that changing visibility of the app list transitions app list button's |
2097 // ink drop states correctly. | 2098 // ink drop states correctly. |
2098 TEST_F(ShelfViewInkDropTest, AppListButtonWhenVisibilityChanges) { | 2099 TEST_F(ShelfViewInkDropTest, AppListButtonWhenVisibilityChanges) { |
2099 // TODO: investigate failure in mash, http://crbug.com/695751. | 2100 // TODO: investigate failure in mash, http://crbug.com/695751. |
2100 if (ShellPort::Get()->IsRunningInMash()) | 2101 if (Shell::GetAshConfig() == Config::MASH) |
2101 return; | 2102 return; |
2102 | 2103 |
2103 InitAppListButtonInkDrop(); | 2104 InitAppListButtonInkDrop(); |
2104 | 2105 |
2105 ShowAppList(); | 2106 ShowAppList(); |
2106 FinishAppListVisibilityChange(); | 2107 FinishAppListVisibilityChange(); |
2107 EXPECT_EQ(views::InkDropState::ACTIVATED, | 2108 EXPECT_EQ(views::InkDropState::ACTIVATED, |
2108 app_list_button_ink_drop_->GetTargetInkDropState()); | 2109 app_list_button_ink_drop_->GetTargetInkDropState()); |
2109 EXPECT_THAT(app_list_button_ink_drop_->GetAndResetRequestedStates(), | 2110 EXPECT_THAT(app_list_button_ink_drop_->GetAndResetRequestedStates(), |
2110 ElementsAre(views::InkDropState::ACTIVATED)); | 2111 ElementsAre(views::InkDropState::ACTIVATED)); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2147 app_list_button_ink_drop_->GetTargetInkDropState()); | 2148 app_list_button_ink_drop_->GetTargetInkDropState()); |
2148 EXPECT_THAT(app_list_button_ink_drop_->GetAndResetRequestedStates(), | 2149 EXPECT_THAT(app_list_button_ink_drop_->GetAndResetRequestedStates(), |
2149 IsEmpty()); | 2150 IsEmpty()); |
2150 } | 2151 } |
2151 | 2152 |
2152 // Tests that when the app list is visible, mouse press on the app list button, | 2153 // Tests that when the app list is visible, mouse press on the app list button, |
2153 // which dismisses the app list, transitions ink drop states correctly. Also, | 2154 // which dismisses the app list, transitions ink drop states correctly. Also, |
2154 // tests that mouse drag and mouse release does not affect the ink drop state. | 2155 // tests that mouse drag and mouse release does not affect the ink drop state. |
2155 TEST_F(ShelfViewInkDropTest, AppListButtonMouseEventsWhenVisible) { | 2156 TEST_F(ShelfViewInkDropTest, AppListButtonMouseEventsWhenVisible) { |
2156 // TODO: investigate failure in mash, http://crbug.com/695751. | 2157 // TODO: investigate failure in mash, http://crbug.com/695751. |
2157 if (ShellPort::Get()->IsRunningInMash()) | 2158 if (Shell::GetAshConfig() == Config::MASH) |
2158 return; | 2159 return; |
2159 | 2160 |
2160 InitAppListButtonInkDrop(); | 2161 InitAppListButtonInkDrop(); |
2161 | 2162 |
2162 ShowAppList(); | 2163 ShowAppList(); |
2163 FinishAppListVisibilityChange(); | 2164 FinishAppListVisibilityChange(); |
2164 EXPECT_EQ(views::InkDropState::ACTIVATED, | 2165 EXPECT_EQ(views::InkDropState::ACTIVATED, |
2165 app_list_button_ink_drop_->GetTargetInkDropState()); | 2166 app_list_button_ink_drop_->GetTargetInkDropState()); |
2166 EXPECT_THAT(app_list_button_ink_drop_->GetAndResetRequestedStates(), | 2167 EXPECT_THAT(app_list_button_ink_drop_->GetAndResetRequestedStates(), |
2167 ElementsAre(views::InkDropState::ACTIVATED)); | 2168 ElementsAre(views::InkDropState::ACTIVATED)); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2214 EXPECT_EQ(views::InkDropState::ACTIVATED, | 2215 EXPECT_EQ(views::InkDropState::ACTIVATED, |
2215 app_list_button_ink_drop_->GetTargetInkDropState()); | 2216 app_list_button_ink_drop_->GetTargetInkDropState()); |
2216 EXPECT_THAT(app_list_button_ink_drop_->GetAndResetRequestedStates(), | 2217 EXPECT_THAT(app_list_button_ink_drop_->GetAndResetRequestedStates(), |
2217 ElementsAre(views::InkDropState::ACTIVATED)); | 2218 ElementsAre(views::InkDropState::ACTIVATED)); |
2218 } | 2219 } |
2219 | 2220 |
2220 // Tests that when the app list is visible, tapping on the app list button | 2221 // Tests that when the app list is visible, tapping on the app list button |
2221 // transitions ink drop states correctly. | 2222 // transitions ink drop states correctly. |
2222 TEST_F(ShelfViewInkDropTest, AppListButtonGestureTapWhenVisible) { | 2223 TEST_F(ShelfViewInkDropTest, AppListButtonGestureTapWhenVisible) { |
2223 // TODO: investigate failure in mash, http://crbug.com/695751. | 2224 // TODO: investigate failure in mash, http://crbug.com/695751. |
2224 if (ShellPort::Get()->IsRunningInMash()) | 2225 if (Shell::GetAshConfig() == Config::MASH) |
2225 return; | 2226 return; |
2226 | 2227 |
2227 InitAppListButtonInkDrop(); | 2228 InitAppListButtonInkDrop(); |
2228 | 2229 |
2229 ShowAppList(); | 2230 ShowAppList(); |
2230 FinishAppListVisibilityChange(); | 2231 FinishAppListVisibilityChange(); |
2231 EXPECT_EQ(views::InkDropState::ACTIVATED, | 2232 EXPECT_EQ(views::InkDropState::ACTIVATED, |
2232 app_list_button_ink_drop_->GetTargetInkDropState()); | 2233 app_list_button_ink_drop_->GetTargetInkDropState()); |
2233 EXPECT_THAT(app_list_button_ink_drop_->GetAndResetRequestedStates(), | 2234 EXPECT_THAT(app_list_button_ink_drop_->GetAndResetRequestedStates(), |
2234 ElementsAre(views::InkDropState::ACTIVATED)); | 2235 ElementsAre(views::InkDropState::ACTIVATED)); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2284 EXPECT_EQ(views::InkDropState::HIDDEN, | 2285 EXPECT_EQ(views::InkDropState::HIDDEN, |
2285 app_list_button_ink_drop_->GetTargetInkDropState()); | 2286 app_list_button_ink_drop_->GetTargetInkDropState()); |
2286 EXPECT_THAT(app_list_button_ink_drop_->GetAndResetRequestedStates(), | 2287 EXPECT_THAT(app_list_button_ink_drop_->GetAndResetRequestedStates(), |
2287 IsEmpty()); | 2288 IsEmpty()); |
2288 } | 2289 } |
2289 | 2290 |
2290 // Tests that when the app list is visible, tapping down on the app list button | 2291 // Tests that when the app list is visible, tapping down on the app list button |
2291 // and dragging the touch point transitions ink drop states correctly. | 2292 // and dragging the touch point transitions ink drop states correctly. |
2292 TEST_F(ShelfViewInkDropTest, AppListButtonGestureTapDragWhenVisible) { | 2293 TEST_F(ShelfViewInkDropTest, AppListButtonGestureTapDragWhenVisible) { |
2293 // TODO: investigate failure in mash, http://crbug.com/695751. | 2294 // TODO: investigate failure in mash, http://crbug.com/695751. |
2294 if (ShellPort::Get()->IsRunningInMash()) | 2295 if (Shell::GetAshConfig() == Config::MASH) |
2295 return; | 2296 return; |
2296 | 2297 |
2297 InitAppListButtonInkDrop(); | 2298 InitAppListButtonInkDrop(); |
2298 | 2299 |
2299 ShowAppList(); | 2300 ShowAppList(); |
2300 FinishAppListVisibilityChange(); | 2301 FinishAppListVisibilityChange(); |
2301 EXPECT_EQ(views::InkDropState::ACTIVATED, | 2302 EXPECT_EQ(views::InkDropState::ACTIVATED, |
2302 app_list_button_ink_drop_->GetTargetInkDropState()); | 2303 app_list_button_ink_drop_->GetTargetInkDropState()); |
2303 EXPECT_THAT(app_list_button_ink_drop_->GetAndResetRequestedStates(), | 2304 EXPECT_THAT(app_list_button_ink_drop_->GetAndResetRequestedStates(), |
2304 ElementsAre(views::InkDropState::ACTIVATED)); | 2305 ElementsAre(views::InkDropState::ACTIVATED)); |
(...skipping 814 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3119 EXPECT_EQ(views::InkDropState::ACTIVATED, | 3120 EXPECT_EQ(views::InkDropState::ACTIVATED, |
3120 overflow_button_ink_drop_->GetTargetInkDropState()); | 3121 overflow_button_ink_drop_->GetTargetInkDropState()); |
3121 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | 3122 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), |
3122 IsEmpty()); | 3123 IsEmpty()); |
3123 | 3124 |
3124 ASSERT_TRUE(test_api_->IsShowingOverflowBubble()); | 3125 ASSERT_TRUE(test_api_->IsShowingOverflowBubble()); |
3125 } | 3126 } |
3126 | 3127 |
3127 } // namespace test | 3128 } // namespace test |
3128 } // namespace ash | 3129 } // namespace ash |
OLD | NEW |