| 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 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 CreateAndSetShelfItemDelegateForID(id); | 386 CreateAndSetShelfItemDelegateForID(id); |
| 387 return id; | 387 return id; |
| 388 } | 388 } |
| 389 | 389 |
| 390 ShelfID AddPlatformApp() { | 390 ShelfID AddPlatformApp() { |
| 391 ShelfID id = AddPlatformAppNoWait(); | 391 ShelfID id = AddPlatformAppNoWait(); |
| 392 test_api_->RunMessageLoopUntilAnimationsDone(); | 392 test_api_->RunMessageLoopUntilAnimationsDone(); |
| 393 return id; | 393 return id; |
| 394 } | 394 } |
| 395 | 395 |
| 396 void SetShelfItemTypeToAppShortcut(ShelfID id) { |
| 397 int index = model_->ItemIndexByID(id); |
| 398 DCHECK_GE(index, 0); |
| 399 |
| 400 ShelfItem item = model_->items()[index]; |
| 401 |
| 402 if (item.type == TYPE_PLATFORM_APP || item.type == TYPE_WINDOWED_APP) { |
| 403 item.type = TYPE_APP_SHORTCUT; |
| 404 model_->Set(index, item); |
| 405 } |
| 406 test_api_->RunMessageLoopUntilAnimationsDone(); |
| 407 } |
| 408 |
| 396 void RemoveByID(ShelfID id) { | 409 void RemoveByID(ShelfID id) { |
| 397 model_->RemoveItemAt(model_->ItemIndexByID(id)); | 410 model_->RemoveItemAt(model_->ItemIndexByID(id)); |
| 398 test_api_->RunMessageLoopUntilAnimationsDone(); | 411 test_api_->RunMessageLoopUntilAnimationsDone(); |
| 399 } | 412 } |
| 400 | 413 |
| 401 ShelfButton* GetButtonByID(ShelfID id) { | 414 ShelfButton* GetButtonByID(ShelfID id) { |
| 402 int index = model_->ItemIndexByID(id); | 415 int index = model_->ItemIndexByID(id); |
| 403 return test_api_->GetButton(index); | 416 return test_api_->GetButton(index); |
| 404 } | 417 } |
| 405 | 418 |
| (...skipping 1403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1809 TEST_F(ShelfViewTest, CheckDragAndDropFromOverflowBubbleToShelf) { | 1822 TEST_F(ShelfViewTest, CheckDragAndDropFromOverflowBubbleToShelf) { |
| 1810 AddButtonsUntilOverflow(); | 1823 AddButtonsUntilOverflow(); |
| 1811 // Add one more button to prevent the overflow bubble to disappear upon | 1824 // Add one more button to prevent the overflow bubble to disappear upon |
| 1812 // dragging an item out on windows (flakiness, see crbug.com/425097). | 1825 // dragging an item out on windows (flakiness, see crbug.com/425097). |
| 1813 AddAppShortcut(); | 1826 AddAppShortcut(); |
| 1814 | 1827 |
| 1815 TestDraggingAnItemFromOverflowToShelf(false); | 1828 TestDraggingAnItemFromOverflowToShelf(false); |
| 1816 TestDraggingAnItemFromOverflowToShelf(true); | 1829 TestDraggingAnItemFromOverflowToShelf(true); |
| 1817 } | 1830 } |
| 1818 | 1831 |
| 1832 // Checks creating app shortcut for an opened platform app in overflow bubble |
| 1833 // should be invisible to the shelf. See crbug.com/605793. |
| 1834 TEST_F(ShelfViewTest, CheckOverflowStatusPinOpenedAppToShelf) { |
| 1835 AddButtonsUntilOverflow(); |
| 1836 |
| 1837 // Add a running Platform app. |
| 1838 ShelfID platform_app_id = AddPlatformApp(); |
| 1839 EXPECT_FALSE(GetButtonByID(platform_app_id)->visible()); |
| 1840 |
| 1841 // Make the added running platform app to be an app shortcut. |
| 1842 // This app shortcut should be a swapped view in overflow bubble, which is |
| 1843 // invisible. |
| 1844 SetShelfItemTypeToAppShortcut(platform_app_id); |
| 1845 EXPECT_FALSE(GetButtonByID(platform_app_id)->visible()); |
| 1846 } |
| 1847 |
| 1819 // Tests that the AppListButton renders as active in response to touches. | 1848 // Tests that the AppListButton renders as active in response to touches. |
| 1820 TEST_F(ShelfViewTest, AppListButtonTouchFeedback) { | 1849 TEST_F(ShelfViewTest, AppListButtonTouchFeedback) { |
| 1821 AppListButton* app_list_button = | 1850 AppListButton* app_list_button = |
| 1822 static_cast<AppListButton*>(shelf_view_->GetAppListButtonView()); | 1851 static_cast<AppListButton*>(shelf_view_->GetAppListButtonView()); |
| 1823 EXPECT_FALSE(app_list_button->draw_background_as_active()); | 1852 EXPECT_FALSE(app_list_button->draw_background_as_active()); |
| 1824 | 1853 |
| 1825 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); | 1854 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
| 1826 generator.set_current_location(app_list_button-> | 1855 generator.set_current_location(app_list_button-> |
| 1827 GetBoundsInScreen().CenterPoint()); | 1856 GetBoundsInScreen().CenterPoint()); |
| 1828 generator.PressTouch(); | 1857 generator.PressTouch(); |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1956 test_api_->RunMessageLoopUntilAnimationsDone(); | 1985 test_api_->RunMessageLoopUntilAnimationsDone(); |
| 1957 CheckAllItemsAreInBounds(); | 1986 CheckAllItemsAreInBounds(); |
| 1958 } | 1987 } |
| 1959 | 1988 |
| 1960 INSTANTIATE_TEST_CASE_P(LtrRtl, ShelfViewTextDirectionTest, testing::Bool()); | 1989 INSTANTIATE_TEST_CASE_P(LtrRtl, ShelfViewTextDirectionTest, testing::Bool()); |
| 1961 INSTANTIATE_TEST_CASE_P(VisibleBounds, ShelfViewVisibleBoundsTest, | 1990 INSTANTIATE_TEST_CASE_P(VisibleBounds, ShelfViewVisibleBoundsTest, |
| 1962 testing::Bool()); | 1991 testing::Bool()); |
| 1963 | 1992 |
| 1964 } // namespace test | 1993 } // namespace test |
| 1965 } // namespace ash | 1994 } // namespace ash |
| OLD | NEW |