| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" | 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "ash/public/cpp/shelf_item_delegate.h" | 9 #include "ash/public/cpp/shelf_item_delegate.h" |
| 10 #include "ash/public/cpp/window_properties.h" | 10 #include "ash/public/cpp/window_properties.h" |
| (...skipping 2063 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2074 // overflow button). | 2074 // overflow button). |
| 2075 EXPECT_EQ(total_count - 1, model_->item_count()); | 2075 EXPECT_EQ(total_count - 1, model_->item_count()); |
| 2076 EXPECT_TRUE(test.IsOverflowButtonVisible()); | 2076 EXPECT_TRUE(test.IsOverflowButtonVisible()); |
| 2077 | 2077 |
| 2078 // Rip off again and the overflow button should has disappeared. | 2078 // Rip off again and the overflow button should has disappeared. |
| 2079 RipOffItemIndex(app_index, &generator, &test, RIP_OFF_ITEM); | 2079 RipOffItemIndex(app_index, &generator, &test, RIP_OFF_ITEM); |
| 2080 EXPECT_EQ(total_count - 2, model_->item_count()); | 2080 EXPECT_EQ(total_count - 2, model_->item_count()); |
| 2081 EXPECT_FALSE(test.IsOverflowButtonVisible()); | 2081 EXPECT_FALSE(test.IsOverflowButtonVisible()); |
| 2082 } | 2082 } |
| 2083 | 2083 |
| 2084 // Validates that context menu is shown on right click and drag context is not |
| 2085 // set in this case and set on left click. |
| 2086 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, ShelfButtonContextMenu) { |
| 2087 ui::test::EventGenerator generator(ash::Shell::GetPrimaryRootWindow(), |
| 2088 gfx::Point()); |
| 2089 ash::test::ShelfViewTestAPI test(shelf_->GetShelfViewForTesting()); |
| 2090 const int browser_index = GetIndexOfShelfItemType(ash::TYPE_BROWSER_SHORTCUT); |
| 2091 ASSERT_LE(0, browser_index); |
| 2092 ash::ShelfButton* button = test.GetButton(browser_index); |
| 2093 ASSERT_TRUE(button); |
| 2094 |
| 2095 // No context menu is shown at this time. |
| 2096 EXPECT_FALSE(test.shelf_view()->IsShowingMenu()); |
| 2097 const gfx::Rect bounds = button->GetBoundsInScreen(); |
| 2098 generator.MoveMouseTo(bounds.CenterPoint().x(), bounds.CenterPoint().y()); |
| 2099 generator.PressRightButton(); |
| 2100 // Context menu is shown on right button press and no drag context is set. |
| 2101 EXPECT_TRUE(test.shelf_view()->IsShowingMenu()); |
| 2102 EXPECT_FALSE(test.shelf_view()->drag_view()); |
| 2103 generator.ReleaseRightButton(); |
| 2104 EXPECT_FALSE(test.shelf_view()->drag_view()); |
| 2105 |
| 2106 // Press left button. Menu should close and drag context is set to |button|. |
| 2107 generator.PressLeftButton(); |
| 2108 EXPECT_FALSE(test.shelf_view()->IsShowingMenu()); |
| 2109 base::RunLoop().RunUntilIdle(); |
| 2110 EXPECT_EQ(test.shelf_view()->drag_view(), button); |
| 2111 generator.ReleaseLeftButton(); |
| 2112 EXPECT_FALSE(test.shelf_view()->drag_view()); |
| 2113 } |
| 2114 |
| 2084 // Check that clicking on an app shelf item launches a new browser. | 2115 // Check that clicking on an app shelf item launches a new browser. |
| 2085 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, ClickItem) { | 2116 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, ClickItem) { |
| 2086 // Get a number of interfaces we need. | 2117 // Get a number of interfaces we need. |
| 2087 ui::test::EventGenerator generator(ash::Shell::GetPrimaryRootWindow(), | 2118 ui::test::EventGenerator generator(ash::Shell::GetPrimaryRootWindow(), |
| 2088 gfx::Point()); | 2119 gfx::Point()); |
| 2089 ash::test::ShelfViewTestAPI test(shelf_->GetShelfViewForTesting()); | 2120 ash::test::ShelfViewTestAPI test(shelf_->GetShelfViewForTesting()); |
| 2090 AppListService* service = AppListService::Get(); | 2121 AppListService* service = AppListService::Get(); |
| 2091 // There should be two items in our shelf by this time. | 2122 // There should be two items in our shelf by this time. |
| 2092 EXPECT_EQ(2, model_->item_count()); | 2123 EXPECT_EQ(2, model_->item_count()); |
| 2093 EXPECT_FALSE(service->IsAppListVisible()); | 2124 EXPECT_FALSE(service->IsAppListVisible()); |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2401 | 2432 |
| 2402 // Close all windows via the menu item. | 2433 // Close all windows via the menu item. |
| 2403 CloseBrowserWindow(browser(), menu1.get(), LauncherContextMenu::MENU_CLOSE); | 2434 CloseBrowserWindow(browser(), menu1.get(), LauncherContextMenu::MENU_CLOSE); |
| 2404 EXPECT_EQ(0u, BrowserList::GetInstance()->size()); | 2435 EXPECT_EQ(0u, BrowserList::GetInstance()->size()); |
| 2405 | 2436 |
| 2406 // Check if "Close" is removed from the context menu. | 2437 // Check if "Close" is removed from the context menu. |
| 2407 std::unique_ptr<LauncherContextMenu> menu2 = CreateBrowserItemContextMenu(); | 2438 std::unique_ptr<LauncherContextMenu> menu2 = CreateBrowserItemContextMenu(); |
| 2408 ASSERT_FALSE( | 2439 ASSERT_FALSE( |
| 2409 IsItemPresentInMenu(menu2.get(), LauncherContextMenu::MENU_CLOSE)); | 2440 IsItemPresentInMenu(menu2.get(), LauncherContextMenu::MENU_CLOSE)); |
| 2410 } | 2441 } |
| OLD | NEW |