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

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

Issue 775553003: Experimental app list: Fixed failing browser tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@app-list-tests-experimental
Patch Set: Formatting. Created 6 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
« no previous file with comments | « chrome/browser/ui/app_list/app_list_controller_browsertest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "ash/ash_switches.h" 7 #include "ash/ash_switches.h"
8 #include "ash/display/display_controller.h" 8 #include "ash/display/display_controller.h"
9 #include "ash/shelf/shelf.h" 9 #include "ash/shelf/shelf.h"
10 #include "ash/shelf/shelf_button.h" 10 #include "ash/shelf/shelf_button.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 #include "content/public/browser/web_contents.h" 49 #include "content/public/browser/web_contents.h"
50 #include "content/public/test/browser_test_utils.h" 50 #include "content/public/test/browser_test_utils.h"
51 #include "extensions/browser/app_window/app_window.h" 51 #include "extensions/browser/app_window/app_window.h"
52 #include "extensions/browser/app_window/app_window_registry.h" 52 #include "extensions/browser/app_window/app_window_registry.h"
53 #include "extensions/browser/app_window/native_app_window.h" 53 #include "extensions/browser/app_window/native_app_window.h"
54 #include "extensions/browser/extension_system.h" 54 #include "extensions/browser/extension_system.h"
55 #include "extensions/common/constants.h" 55 #include "extensions/common/constants.h"
56 #include "extensions/common/switches.h" 56 #include "extensions/common/switches.h"
57 #include "extensions/test/extension_test_message_listener.h" 57 #include "extensions/test/extension_test_message_listener.h"
58 #include "testing/gtest/include/gtest/gtest.h" 58 #include "testing/gtest/include/gtest/gtest.h"
59 #include "ui/app_list/app_list_switches.h"
59 #include "ui/app_list/views/app_list_item_view.h" 60 #include "ui/app_list/views/app_list_item_view.h"
60 #include "ui/app_list/views/apps_grid_view.h" 61 #include "ui/app_list/views/apps_grid_view.h"
62 #include "ui/app_list/views/start_page_view.h"
63 #include "ui/app_list/views/tile_item_view.h"
61 #include "ui/aura/client/aura_constants.h" 64 #include "ui/aura/client/aura_constants.h"
62 #include "ui/aura/window.h" 65 #include "ui/aura/window.h"
63 #include "ui/events/event.h" 66 #include "ui/events/event.h"
64 #include "ui/events/test/event_generator.h" 67 #include "ui/events/test/event_generator.h"
65 68
66 using extensions::AppWindow; 69 using extensions::AppWindow;
67 using extensions::Extension; 70 using extensions::Extension;
68 using content::WebContents; 71 using content::WebContents;
69 72
70 namespace { 73 namespace {
(...skipping 29 matching lines...) Expand all
100 103
101 int icon_updates() { return icon_updates_; } 104 int icon_updates() { return icon_updates_; }
102 105
103 private: 106 private:
104 Profile* profile_; 107 Profile* profile_;
105 int icon_updates_; 108 int icon_updates_;
106 109
107 DISALLOW_COPY_AND_ASSIGN(TestAppWindowRegistryObserver); 110 DISALLOW_COPY_AND_ASSIGN(TestAppWindowRegistryObserver);
108 }; 111 };
109 112
113 // Click the "All Apps" button from the app launcher start page. Assumes that
114 // the app launcher is open to the start page. On the non-experimental launcher,
115 // does nothing.
116 // |display_origin| is the top-left corner of the active display, in screen
117 // coordinates.
118 void OnStartPageClickAllAppsButton(ui::test::EventGenerator* generator,
calamity 2014/12/03 03:39:41 This name is confusing and sounds like an event.
Matt Giuca 2014/12/03 03:44:01 Done.
119 const gfx::Point& display_origin) {
120 if (!app_list::switches::IsExperimentalAppListEnabled())
121 return;
122
123 ash::test::AppListControllerTestApi controller_test(
124 ash::Shell::GetInstance());
125
126 app_list::StartPageView* start_page_view = controller_test.GetStartPageView();
127 DCHECK(start_page_view);
128
129 app_list::TileItemView* all_apps_button = start_page_view->all_apps_button();
130 gfx::Rect all_apps_rect = all_apps_button->GetBoundsInScreen();
131 all_apps_rect.Offset(-display_origin.x(), -display_origin.y());
132 generator->MoveMouseTo(all_apps_rect.CenterPoint().x(),
133 all_apps_rect.CenterPoint().y());
134 generator->ClickLeftButton();
135 base::MessageLoop::current()->RunUntilIdle();
136 // Run Layout() to effectively complete the animation to the apps page.
137 controller_test.LayoutContentsView();
138 }
139
110 } // namespace 140 } // namespace
111 141
112 class LauncherPlatformAppBrowserTest 142 class LauncherPlatformAppBrowserTest
113 : public extensions::PlatformAppBrowserTest { 143 : public extensions::PlatformAppBrowserTest {
114 protected: 144 protected:
115 LauncherPlatformAppBrowserTest() : shelf_(NULL), controller_(NULL) { 145 LauncherPlatformAppBrowserTest() : shelf_(NULL), controller_(NULL) {
116 } 146 }
117 147
118 virtual ~LauncherPlatformAppBrowserTest() {} 148 virtual ~LauncherPlatformAppBrowserTest() {}
119 149
(...skipping 1611 matching lines...) Expand 10 before | Expand all | Expand 10 after
1731 // display environment. 1761 // display environment.
1732 class ShelfAppBrowserTestWithMultiMonitor 1762 class ShelfAppBrowserTestWithMultiMonitor
1733 : public ShelfAppBrowserTestNoDefaultBrowser { 1763 : public ShelfAppBrowserTestNoDefaultBrowser {
1734 protected: 1764 protected:
1735 ShelfAppBrowserTestWithMultiMonitor() {} 1765 ShelfAppBrowserTestWithMultiMonitor() {}
1736 virtual ~ShelfAppBrowserTestWithMultiMonitor() {} 1766 virtual ~ShelfAppBrowserTestWithMultiMonitor() {}
1737 1767
1738 virtual void SetUpCommandLine(CommandLine* command_line) override { 1768 virtual void SetUpCommandLine(CommandLine* command_line) override {
1739 ShelfAppBrowserTestNoDefaultBrowser::SetUpCommandLine(command_line); 1769 ShelfAppBrowserTestNoDefaultBrowser::SetUpCommandLine(command_line);
1740 command_line->AppendSwitchASCII("ash-host-window-bounds", 1770 command_line->AppendSwitchASCII("ash-host-window-bounds",
1741 "800x600,801+0-800x600"); 1771 "800x800,801+0-800x800");
1742 } 1772 }
1743 1773
1744 private: 1774 private:
1745 1775
1746 DISALLOW_COPY_AND_ASSIGN(ShelfAppBrowserTestWithMultiMonitor); 1776 DISALLOW_COPY_AND_ASSIGN(ShelfAppBrowserTestWithMultiMonitor);
1747 }; 1777 };
1748 1778
1749 // Do basic drag and drop interaction tests between the application list and 1779 // Do basic drag and drop interaction tests between the application list and
1750 // the launcher in the secondary monitor. 1780 // the launcher in the secondary monitor.
1751 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTestWithMultiMonitor, 1781 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTestWithMultiMonitor,
(...skipping 15 matching lines...) Expand all
1767 // Open the app list menu and check that the drag and drop host was set. 1797 // Open the app list menu and check that the drag and drop host was set.
1768 gfx::Rect app_list_bounds = 1798 gfx::Rect app_list_bounds =
1769 test.shelf_view()->GetAppListButtonView()->GetBoundsInScreen(); 1799 test.shelf_view()->GetAppListButtonView()->GetBoundsInScreen();
1770 gfx::Display display = 1800 gfx::Display display =
1771 ash::Shell::GetScreen()->GetDisplayNearestWindow(secondary_root_window); 1801 ash::Shell::GetScreen()->GetDisplayNearestWindow(secondary_root_window);
1772 const gfx::Point& origin = display.bounds().origin(); 1802 const gfx::Point& origin = display.bounds().origin();
1773 app_list_bounds.Offset(-origin.x(), -origin.y()); 1803 app_list_bounds.Offset(-origin.x(), -origin.y());
1774 1804
1775 generator.MoveMouseTo(app_list_bounds.CenterPoint().x(), 1805 generator.MoveMouseTo(app_list_bounds.CenterPoint().x(),
1776 app_list_bounds.CenterPoint().y()); 1806 app_list_bounds.CenterPoint().y());
1807 generator.ClickLeftButton();
1777 base::MessageLoop::current()->RunUntilIdle(); 1808 base::MessageLoop::current()->RunUntilIdle();
1778 generator.ClickLeftButton(); 1809 EXPECT_TRUE(service->IsAppListVisible());
1779 1810
1811 // Click the "all apps" button on the start page.
1812 OnStartPageClickAllAppsButton(&generator, origin);
1780 EXPECT_TRUE(service->IsAppListVisible()); 1813 EXPECT_TRUE(service->IsAppListVisible());
1814
1781 app_list::AppsGridView* grid_view = 1815 app_list::AppsGridView* grid_view =
1782 ash::test::AppListControllerTestApi(ash::Shell::GetInstance()). 1816 ash::test::AppListControllerTestApi(ash::Shell::GetInstance()).
1783 GetRootGridView(); 1817 GetRootGridView();
1784 ASSERT_TRUE(grid_view); 1818 ASSERT_TRUE(grid_view);
1785 ASSERT_TRUE(grid_view->has_drag_and_drop_host_for_test()); 1819 ASSERT_TRUE(grid_view->has_drag_and_drop_host_for_test());
1786 1820
1787 // There should be 2 items in our application list. 1821 // There should be 2 items in our application list.
1788 const views::ViewModelT<app_list::AppListItemView>* vm_grid = 1822 const views::ViewModelT<app_list::AppListItemView>* vm_grid =
1789 grid_view->view_model_for_test(); 1823 grid_view->view_model_for_test();
1790 EXPECT_EQ(2, vm_grid->view_size()); 1824 EXPECT_EQ(2, vm_grid->view_size());
(...skipping 21 matching lines...) Expand all
1812 generator.MoveMouseTo(bounds_shelf_1.CenterPoint().x(), 1846 generator.MoveMouseTo(bounds_shelf_1.CenterPoint().x(),
1813 bounds_shelf_1.CenterPoint().y()); 1847 bounds_shelf_1.CenterPoint().y());
1814 base::MessageLoop::current()->RunUntilIdle(); 1848 base::MessageLoop::current()->RunUntilIdle();
1815 1849
1816 // Check that a new item got created. 1850 // Check that a new item got created.
1817 EXPECT_EQ(3, model_->item_count()); 1851 EXPECT_EQ(3, model_->item_count());
1818 EXPECT_TRUE(grid_view->forward_events_to_drag_and_drop_host_for_test()); 1852 EXPECT_TRUE(grid_view->forward_events_to_drag_and_drop_host_for_test());
1819 1853
1820 // Move it to an empty slot on grid_view. 1854 // Move it to an empty slot on grid_view.
1821 gfx::Rect empty_slot_rect = bounds_grid_1; 1855 gfx::Rect empty_slot_rect = bounds_grid_1;
1822 empty_slot_rect.Offset(0, bounds_grid_1.height()); 1856 empty_slot_rect.Offset(0, grid_view->GetTotalTileSize().height());
1823 generator.MoveMouseTo(empty_slot_rect.CenterPoint().x(), 1857 generator.MoveMouseTo(empty_slot_rect.CenterPoint().x(),
1824 empty_slot_rect.CenterPoint().y()); 1858 empty_slot_rect.CenterPoint().y());
1825 base::MessageLoop::current()->RunUntilIdle(); 1859 base::MessageLoop::current()->RunUntilIdle();
1826 EXPECT_EQ(2, model_->item_count()); 1860 EXPECT_EQ(2, model_->item_count());
1827 EXPECT_FALSE(grid_view->forward_events_to_drag_and_drop_host_for_test()); 1861 EXPECT_FALSE(grid_view->forward_events_to_drag_and_drop_host_for_test());
1828 1862
1829 // Dropping it should keep the shelf as it originally was. 1863 // Dropping it should keep the shelf as it originally was.
1830 generator.ReleaseLeftButton(); 1864 generator.ReleaseLeftButton();
1831 base::MessageLoop::current()->RunUntilIdle(); 1865 base::MessageLoop::current()->RunUntilIdle();
1832 EXPECT_EQ(2, model_->item_count()); 1866 EXPECT_EQ(2, model_->item_count());
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
1947 EXPECT_EQ(2, model_->item_count()); 1981 EXPECT_EQ(2, model_->item_count());
1948 EXPECT_FALSE(service->IsAppListVisible()); 1982 EXPECT_FALSE(service->IsAppListVisible());
1949 1983
1950 // Open the app list menu and check that the drag and drop host was set. 1984 // Open the app list menu and check that the drag and drop host was set.
1951 gfx::Rect app_list_bounds = 1985 gfx::Rect app_list_bounds =
1952 test.shelf_view()->GetAppListButtonView()->GetBoundsInScreen(); 1986 test.shelf_view()->GetAppListButtonView()->GetBoundsInScreen();
1953 generator.MoveMouseTo(app_list_bounds.CenterPoint().x(), 1987 generator.MoveMouseTo(app_list_bounds.CenterPoint().x(),
1954 app_list_bounds.CenterPoint().y()); 1988 app_list_bounds.CenterPoint().y());
1955 generator.ClickLeftButton(); 1989 generator.ClickLeftButton();
1956 base::MessageLoop::current()->RunUntilIdle(); 1990 base::MessageLoop::current()->RunUntilIdle();
1991 EXPECT_TRUE(service->IsAppListVisible());
1957 1992
1993 // Click the "all apps" button on the start page.
1994 OnStartPageClickAllAppsButton(&generator, gfx::Point());
1958 EXPECT_TRUE(service->IsAppListVisible()); 1995 EXPECT_TRUE(service->IsAppListVisible());
1996
1997 // Click an app icon in the app grid view.
1959 app_list::AppsGridView* grid_view = 1998 app_list::AppsGridView* grid_view =
1960 ash::test::AppListControllerTestApi(ash::Shell::GetInstance()). 1999 ash::test::AppListControllerTestApi(ash::Shell::GetInstance()).
1961 GetRootGridView(); 2000 GetRootGridView();
1962 ASSERT_TRUE(grid_view); 2001 ASSERT_TRUE(grid_view);
1963 const views::ViewModelT<app_list::AppListItemView>* vm_grid = 2002 const views::ViewModelT<app_list::AppListItemView>* vm_grid =
1964 grid_view->view_model_for_test(); 2003 grid_view->view_model_for_test();
1965 EXPECT_EQ(2, vm_grid->view_size()); 2004 EXPECT_EQ(2, vm_grid->view_size());
1966 gfx::Rect bounds_grid_1 = vm_grid->view_at(1)->GetBoundsInScreen(); 2005 gfx::Rect bounds_grid_1 = vm_grid->view_at(1)->GetBoundsInScreen();
1967 // Test now that a click does create a new application tab. 2006 // Test now that a click does create a new application tab.
1968 TabStripModel* tab_strip = browser()->tab_strip_model(); 2007 TabStripModel* tab_strip = browser()->tab_strip_model();
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
2130 chrome::GetSettingsUrl(std::string())); 2169 chrome::GetSettingsUrl(std::string()));
2131 Browser* settings_browser = 2170 Browser* settings_browser =
2132 settings_manager->FindBrowserForProfile(browser()->profile()); 2171 settings_manager->FindBrowserForProfile(browser()->profile());
2133 ASSERT_TRUE(settings_browser); 2172 ASSERT_TRUE(settings_browser);
2134 EXPECT_EQ(browser_count, NumberOfDetectedLauncherBrowsers(false)); 2173 EXPECT_EQ(browser_count, NumberOfDetectedLauncherBrowsers(false));
2135 EXPECT_EQ(item_count + 1, shelf_model->item_count()); 2174 EXPECT_EQ(item_count + 1, shelf_model->item_count());
2136 2175
2137 // TODO(stevenjb): Test multiprofile on Chrome OS when test support is addded. 2176 // TODO(stevenjb): Test multiprofile on Chrome OS when test support is addded.
2138 // crbug.com/230464. 2177 // crbug.com/230464.
2139 } 2178 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/app_list/app_list_controller_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698