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

Side by Side Diff: chrome/browser/ui/ash/launcher/chrome_launcher_controller_browsertest.cc

Issue 115113006: Rename Launcher to Shelf. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ShelfTestAPI Created 7 years 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 | Annotate | Revision Log
OLDNEW
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 "apps/shell_window.h" 7 #include "apps/shell_window.h"
8 #include "apps/shell_window_registry.h" 8 #include "apps/shell_window_registry.h"
9 #include "apps/ui/native_app_window.h" 9 #include "apps/ui/native_app_window.h"
10 #include "ash/ash_switches.h" 10 #include "ash/ash_switches.h"
11 #include "ash/display/display_controller.h" 11 #include "ash/display/display_controller.h"
12 #include "ash/launcher/launcher.h" 12 #include "ash/shelf/shelf.h"
13 #include "ash/shelf/shelf_button.h" 13 #include "ash/shelf/shelf_button.h"
14 #include "ash/shelf/shelf_model.h" 14 #include "ash/shelf/shelf_model.h"
15 #include "ash/shelf/shelf_util.h" 15 #include "ash/shelf/shelf_util.h"
16 #include "ash/shelf/shelf_view.h" 16 #include "ash/shelf/shelf_view.h"
17 #include "ash/shell.h" 17 #include "ash/shell.h"
18 #include "ash/test/app_list_controller_test_api.h" 18 #include "ash/test/app_list_controller_test_api.h"
19 #include "ash/test/launcher_test_api.h" 19 #include "ash/test/shelf_test_api.h"
20 #include "ash/test/shelf_view_test_api.h" 20 #include "ash/test/shelf_view_test_api.h"
21 #include "ash/test/shell_test_api.h" 21 #include "ash/test/shell_test_api.h"
22 #include "ash/wm/window_state.h" 22 #include "ash/wm/window_state.h"
23 #include "ash/wm/window_util.h" 23 #include "ash/wm/window_util.h"
24 #include "base/strings/stringprintf.h" 24 #include "base/strings/stringprintf.h"
25 #include "base/strings/utf_string_conversions.h" 25 #include "base/strings/utf_string_conversions.h"
26 #include "chrome/browser/apps/app_browsertest_util.h" 26 #include "chrome/browser/apps/app_browsertest_util.h"
27 #include "chrome/browser/automation/automation_util.h" 27 #include "chrome/browser/automation/automation_util.h"
28 #include "chrome/browser/chrome_notification_types.h" 28 #include "chrome/browser/chrome_notification_types.h"
29 #include "chrome/browser/extensions/extension_apitest.h" 29 #include "chrome/browser/extensions/extension_apitest.h"
(...skipping 1499 matching lines...) Expand 10 before | Expand all | Expand 10 after
1529 browser2); 1529 browser2);
1530 } 1530 }
1531 1531
1532 // Do various drag and drop interaction tests between the application list and 1532 // Do various drag and drop interaction tests between the application list and
1533 // the launcher. 1533 // the launcher.
1534 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, DragAndDrop) { 1534 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, DragAndDrop) {
1535 // Get a number of interfaces we need. 1535 // Get a number of interfaces we need.
1536 aura::test::EventGenerator generator( 1536 aura::test::EventGenerator generator(
1537 ash::Shell::GetPrimaryRootWindow(), gfx::Point()); 1537 ash::Shell::GetPrimaryRootWindow(), gfx::Point());
1538 ash::test::ShelfViewTestAPI test( 1538 ash::test::ShelfViewTestAPI test(
1539 ash::test::LauncherTestAPI(launcher_).shelf_view()); 1539 ash::test::ShelfTestAPI(launcher_).shelf_view());
1540 AppListService* service = AppListService::Get(chrome::GetActiveDesktop()); 1540 AppListService* service = AppListService::Get(chrome::GetActiveDesktop());
1541 1541
1542 // There should be two items in our launcher by this time. 1542 // There should be two items in our launcher by this time.
1543 EXPECT_EQ(2, model_->item_count()); 1543 EXPECT_EQ(2, model_->item_count());
1544 EXPECT_FALSE(service->IsAppListVisible()); 1544 EXPECT_FALSE(service->IsAppListVisible());
1545 1545
1546 // Open the app list menu and check that the drag and drop host was set. 1546 // Open the app list menu and check that the drag and drop host was set.
1547 gfx::Rect app_list_bounds = 1547 gfx::Rect app_list_bounds =
1548 test.shelf_view()->GetAppListButtonView()->GetBoundsInScreen(); 1548 test.shelf_view()->GetAppListButtonView()->GetBoundsInScreen();
1549 generator.MoveMouseTo(app_list_bounds.CenterPoint().x(), 1549 generator.MoveMouseTo(app_list_bounds.CenterPoint().x(),
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
1676 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTestWithMultiMonitor, 1676 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTestWithMultiMonitor,
1677 BasicDragAndDrop) { 1677 BasicDragAndDrop) {
1678 // Get a number of interfaces we need. 1678 // Get a number of interfaces we need.
1679 DCHECK_EQ(ash::Shell::GetAllRootWindows().size(), 2U); 1679 DCHECK_EQ(ash::Shell::GetAllRootWindows().size(), 2U);
1680 aura::Window* secondary_root_window = ash::Shell::GetAllRootWindows()[1]; 1680 aura::Window* secondary_root_window = ash::Shell::GetAllRootWindows()[1];
1681 ash::Launcher* secondary_launcher = 1681 ash::Launcher* secondary_launcher =
1682 ash::Launcher::ForWindow(secondary_root_window); 1682 ash::Launcher::ForWindow(secondary_root_window);
1683 1683
1684 aura::test::EventGenerator generator(secondary_root_window, gfx::Point()); 1684 aura::test::EventGenerator generator(secondary_root_window, gfx::Point());
1685 ash::test::ShelfViewTestAPI test( 1685 ash::test::ShelfViewTestAPI test(
1686 ash::test::LauncherTestAPI(secondary_launcher).shelf_view()); 1686 ash::test::ShelfTestAPI(secondary_launcher).shelf_view());
1687 AppListService* service = AppListService::Get(chrome::GetActiveDesktop()); 1687 AppListService* service = AppListService::Get(chrome::GetActiveDesktop());
1688 1688
1689 // There should be two items in our launcher by this time. 1689 // There should be two items in our launcher by this time.
1690 EXPECT_EQ(2, model_->item_count()); 1690 EXPECT_EQ(2, model_->item_count());
1691 EXPECT_FALSE(service->IsAppListVisible()); 1691 EXPECT_FALSE(service->IsAppListVisible());
1692 1692
1693 // Open the app list menu and check that the drag and drop host was set. 1693 // Open the app list menu and check that the drag and drop host was set.
1694 gfx::Rect app_list_bounds = 1694 gfx::Rect app_list_bounds =
1695 test.shelf_view()->GetAppListButtonView()->GetBoundsInScreen(); 1695 test.shelf_view()->GetAppListButtonView()->GetBoundsInScreen();
1696 gfx::Display display = 1696 gfx::Display display =
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1755 base::MessageLoop::current()->RunUntilIdle(); 1755 base::MessageLoop::current()->RunUntilIdle();
1756 EXPECT_EQ(2, model_->item_count()); 1756 EXPECT_EQ(2, model_->item_count());
1757 } 1757 }
1758 #endif 1758 #endif
1759 1759
1760 // Do tests for removal of items from the shelf by dragging. 1760 // Do tests for removal of items from the shelf by dragging.
1761 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, DragOffShelf) { 1761 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, DragOffShelf) {
1762 aura::test::EventGenerator generator( 1762 aura::test::EventGenerator generator(
1763 ash::Shell::GetPrimaryRootWindow(), gfx::Point()); 1763 ash::Shell::GetPrimaryRootWindow(), gfx::Point());
1764 ash::test::ShelfViewTestAPI test( 1764 ash::test::ShelfViewTestAPI test(
1765 ash::test::LauncherTestAPI(launcher_).shelf_view()); 1765 ash::test::ShelfTestAPI(launcher_).shelf_view());
1766 test.SetAnimationDuration(1); // Speed up animations for test. 1766 test.SetAnimationDuration(1); // Speed up animations for test.
1767 // Create a known application and check that we have 3 items in the launcher. 1767 // Create a known application and check that we have 3 items in the launcher.
1768 CreateShortcut("app1"); 1768 CreateShortcut("app1");
1769 test.RunMessageLoopUntilAnimationsDone(); 1769 test.RunMessageLoopUntilAnimationsDone();
1770 EXPECT_EQ(3, model_->item_count()); 1770 EXPECT_EQ(3, model_->item_count());
1771 1771
1772 // Test #1: Ripping out the browser item should not change anything. 1772 // Test #1: Ripping out the browser item should not change anything.
1773 int browser_index = GetIndexOfShelfItemType(ash::TYPE_BROWSER_SHORTCUT); 1773 int browser_index = GetIndexOfShelfItemType(ash::TYPE_BROWSER_SHORTCUT);
1774 EXPECT_LE(0, browser_index); 1774 EXPECT_LE(0, browser_index);
1775 RipOffItemIndex(browser_index, &generator, &test, RIP_OFF_ITEM); 1775 RipOffItemIndex(browser_index, &generator, &test, RIP_OFF_ITEM);
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
1858 EXPECT_EQ(total_count - 2, model_->item_count()); 1858 EXPECT_EQ(total_count - 2, model_->item_count());
1859 EXPECT_FALSE(test.IsOverflowButtonVisible()); 1859 EXPECT_FALSE(test.IsOverflowButtonVisible());
1860 } 1860 }
1861 1861
1862 // Check that clicking on an app launcher item launches a new browser. 1862 // Check that clicking on an app launcher item launches a new browser.
1863 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, ClickItem) { 1863 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, ClickItem) {
1864 // Get a number of interfaces we need. 1864 // Get a number of interfaces we need.
1865 aura::test::EventGenerator generator( 1865 aura::test::EventGenerator generator(
1866 ash::Shell::GetPrimaryRootWindow(), gfx::Point()); 1866 ash::Shell::GetPrimaryRootWindow(), gfx::Point());
1867 ash::test::ShelfViewTestAPI test( 1867 ash::test::ShelfViewTestAPI test(
1868 ash::test::LauncherTestAPI(launcher_).shelf_view()); 1868 ash::test::ShelfTestAPI(launcher_).shelf_view());
1869 AppListService* service = AppListService::Get(chrome::GetActiveDesktop()); 1869 AppListService* service = AppListService::Get(chrome::GetActiveDesktop());
1870 // There should be two items in our launcher by this time. 1870 // There should be two items in our launcher by this time.
1871 EXPECT_EQ(2, model_->item_count()); 1871 EXPECT_EQ(2, model_->item_count());
1872 EXPECT_FALSE(service->IsAppListVisible()); 1872 EXPECT_FALSE(service->IsAppListVisible());
1873 1873
1874 // Open the app list menu and check that the drag and drop host was set. 1874 // Open the app list menu and check that the drag and drop host was set.
1875 gfx::Rect app_list_bounds = 1875 gfx::Rect app_list_bounds =
1876 test.shelf_view()->GetAppListButtonView()->GetBoundsInScreen(); 1876 test.shelf_view()->GetAppListButtonView()->GetBoundsInScreen();
1877 generator.MoveMouseTo(app_list_bounds.CenterPoint().x(), 1877 generator.MoveMouseTo(app_list_bounds.CenterPoint().x(),
1878 app_list_bounds.CenterPoint().y()); 1878 app_list_bounds.CenterPoint().y());
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1960 } 1960 }
1961 1961
1962 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, OverflowBubble) { 1962 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, OverflowBubble) {
1963 // Make sure to have a browser window 1963 // Make sure to have a browser window
1964 chrome::NewTab(browser()); 1964 chrome::NewTab(browser());
1965 1965
1966 // No overflow yet. 1966 // No overflow yet.
1967 EXPECT_FALSE(launcher_->IsShowingOverflowBubble()); 1967 EXPECT_FALSE(launcher_->IsShowingOverflowBubble());
1968 1968
1969 ash::test::ShelfViewTestAPI test( 1969 ash::test::ShelfViewTestAPI test(
1970 ash::test::LauncherTestAPI(launcher_).shelf_view()); 1970 ash::test::ShelfTestAPI(launcher_).shelf_view());
1971 1971
1972 int items_added = 0; 1972 int items_added = 0;
1973 while (!test.IsOverflowButtonVisible()) { 1973 while (!test.IsOverflowButtonVisible()) {
1974 std::string fake_app_id = base::StringPrintf("fake_app_%d", items_added); 1974 std::string fake_app_id = base::StringPrintf("fake_app_%d", items_added);
1975 PinFakeApp(fake_app_id); 1975 PinFakeApp(fake_app_id);
1976 1976
1977 ++items_added; 1977 ++items_added;
1978 ASSERT_LT(items_added, 10000); 1978 ASSERT_LT(items_added, 10000);
1979 } 1979 }
1980 1980
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
2028 GURL("http://www.foo.com/bar.html")); 2028 GURL("http://www.foo.com/bar.html"));
2029 // Make sure the navigation was entirely performed. 2029 // Make sure the navigation was entirely performed.
2030 base::MessageLoop::current()->RunUntilIdle(); 2030 base::MessageLoop::current()->RunUntilIdle();
2031 EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(id)->status); 2031 EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(id)->status);
2032 app_browser->tab_strip_model()->CloseWebContentsAt(0, 2032 app_browser->tab_strip_model()->CloseWebContentsAt(0,
2033 TabStripModel::CLOSE_NONE); 2033 TabStripModel::CLOSE_NONE);
2034 // Make sure that the app is really gone. 2034 // Make sure that the app is really gone.
2035 base::MessageLoop::current()->RunUntilIdle(); 2035 base::MessageLoop::current()->RunUntilIdle();
2036 EXPECT_EQ(ash::STATUS_CLOSED, model_->ItemByID(id)->status); 2036 EXPECT_EQ(ash::STATUS_CLOSED, model_->ItemByID(id)->status);
2037 } 2037 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698