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

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: 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
114 // Click the "All Apps" button from the app launcher start page. Assumes that
115 // the app launcher is open to the start page. On the non-experimental launcher,
116 // does nothing.
117 // |display_origin| is the top-left corner of the active display, in screen
118 // coordinates.
119 void OnStartPageClickAllAppsButton(ui::test::EventGenerator* generator,
120 const gfx::Point& display_origin) {
121 if (!app_list::switches::IsExperimentalAppListEnabled())
122 return;
123
124 ash::test::AppListControllerTestApi controller_test(
125 ash::Shell::GetInstance());
126
127 app_list::StartPageView* start_page_view = controller_test.GetStartPageView();
128 DCHECK(start_page_view);
129
130 app_list::TileItemView* all_apps_button = start_page_view->all_apps_button();
131 gfx::Rect all_apps_rect = all_apps_button->GetBoundsInScreen();
132 all_apps_rect.Offset(-display_origin.x(), -display_origin.y());
133 generator->MoveMouseTo(all_apps_rect.CenterPoint().x(),
134 all_apps_rect.CenterPoint().y());
Daniel Erat 2014/12/02 15:09:57 nit: fix indenting
Matt Giuca 2014/12/03 00:47:50 Done.
135 generator->ClickLeftButton();
136 base::MessageLoop::current()->RunUntilIdle();
137 // Run Layout() to effectively complete the animation to the apps page.
138 controller_test.LayoutContentsView();
139 }
140
110 } // namespace 141 } // namespace
111 142
112 class LauncherPlatformAppBrowserTest 143 class LauncherPlatformAppBrowserTest
113 : public extensions::PlatformAppBrowserTest { 144 : public extensions::PlatformAppBrowserTest {
114 protected: 145 protected:
115 LauncherPlatformAppBrowserTest() : shelf_(NULL), controller_(NULL) { 146 LauncherPlatformAppBrowserTest() : shelf_(NULL), controller_(NULL) {
116 } 147 }
117 148
118 virtual ~LauncherPlatformAppBrowserTest() {} 149 virtual ~LauncherPlatformAppBrowserTest() {}
119 150
(...skipping 1611 matching lines...) Expand 10 before | Expand all | Expand 10 after
1731 // display environment. 1762 // display environment.
1732 class ShelfAppBrowserTestWithMultiMonitor 1763 class ShelfAppBrowserTestWithMultiMonitor
1733 : public ShelfAppBrowserTestNoDefaultBrowser { 1764 : public ShelfAppBrowserTestNoDefaultBrowser {
1734 protected: 1765 protected:
1735 ShelfAppBrowserTestWithMultiMonitor() {} 1766 ShelfAppBrowserTestWithMultiMonitor() {}
1736 virtual ~ShelfAppBrowserTestWithMultiMonitor() {} 1767 virtual ~ShelfAppBrowserTestWithMultiMonitor() {}
1737 1768
1738 virtual void SetUpCommandLine(CommandLine* command_line) override { 1769 virtual void SetUpCommandLine(CommandLine* command_line) override {
1739 ShelfAppBrowserTestNoDefaultBrowser::SetUpCommandLine(command_line); 1770 ShelfAppBrowserTestNoDefaultBrowser::SetUpCommandLine(command_line);
1740 command_line->AppendSwitchASCII("ash-host-window-bounds", 1771 command_line->AppendSwitchASCII("ash-host-window-bounds",
1741 "800x600,801+0-800x600"); 1772 "800x800,801+0-800x800");
1742 } 1773 }
1743 1774
1744 private: 1775 private:
1745 1776
1746 DISALLOW_COPY_AND_ASSIGN(ShelfAppBrowserTestWithMultiMonitor); 1777 DISALLOW_COPY_AND_ASSIGN(ShelfAppBrowserTestWithMultiMonitor);
1747 }; 1778 };
1748 1779
1749 // Do basic drag and drop interaction tests between the application list and 1780 // Do basic drag and drop interaction tests between the application list and
1750 // the launcher in the secondary monitor. 1781 // the launcher in the secondary monitor.
1751 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTestWithMultiMonitor, 1782 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. 1798 // Open the app list menu and check that the drag and drop host was set.
1768 gfx::Rect app_list_bounds = 1799 gfx::Rect app_list_bounds =
1769 test.shelf_view()->GetAppListButtonView()->GetBoundsInScreen(); 1800 test.shelf_view()->GetAppListButtonView()->GetBoundsInScreen();
1770 gfx::Display display = 1801 gfx::Display display =
1771 ash::Shell::GetScreen()->GetDisplayNearestWindow(secondary_root_window); 1802 ash::Shell::GetScreen()->GetDisplayNearestWindow(secondary_root_window);
1772 const gfx::Point& origin = display.bounds().origin(); 1803 const gfx::Point& origin = display.bounds().origin();
1773 app_list_bounds.Offset(-origin.x(), -origin.y()); 1804 app_list_bounds.Offset(-origin.x(), -origin.y());
1774 1805
1775 generator.MoveMouseTo(app_list_bounds.CenterPoint().x(), 1806 generator.MoveMouseTo(app_list_bounds.CenterPoint().x(),
1776 app_list_bounds.CenterPoint().y()); 1807 app_list_bounds.CenterPoint().y());
1808 generator.ClickLeftButton();
1777 base::MessageLoop::current()->RunUntilIdle(); 1809 base::MessageLoop::current()->RunUntilIdle();
1778 generator.ClickLeftButton(); 1810 EXPECT_TRUE(service->IsAppListVisible());
1779 1811
1812 // Click the "all apps" button on the start page.
1813 OnStartPageClickAllAppsButton(&generator, origin);
1780 EXPECT_TRUE(service->IsAppListVisible()); 1814 EXPECT_TRUE(service->IsAppListVisible());
1815
1781 app_list::AppsGridView* grid_view = 1816 app_list::AppsGridView* grid_view =
1782 ash::test::AppListControllerTestApi(ash::Shell::GetInstance()). 1817 ash::test::AppListControllerTestApi(ash::Shell::GetInstance()).
1783 GetRootGridView(); 1818 GetRootGridView();
1784 ASSERT_TRUE(grid_view); 1819 ASSERT_TRUE(grid_view);
1785 ASSERT_TRUE(grid_view->has_drag_and_drop_host_for_test()); 1820 ASSERT_TRUE(grid_view->has_drag_and_drop_host_for_test());
1786 1821
1787 // There should be 2 items in our application list. 1822 // There should be 2 items in our application list.
1788 const views::ViewModelT<app_list::AppListItemView>* vm_grid = 1823 const views::ViewModelT<app_list::AppListItemView>* vm_grid =
1789 grid_view->view_model_for_test(); 1824 grid_view->view_model_for_test();
1790 EXPECT_EQ(2, vm_grid->view_size()); 1825 EXPECT_EQ(2, vm_grid->view_size());
(...skipping 21 matching lines...) Expand all
1812 generator.MoveMouseTo(bounds_shelf_1.CenterPoint().x(), 1847 generator.MoveMouseTo(bounds_shelf_1.CenterPoint().x(),
1813 bounds_shelf_1.CenterPoint().y()); 1848 bounds_shelf_1.CenterPoint().y());
1814 base::MessageLoop::current()->RunUntilIdle(); 1849 base::MessageLoop::current()->RunUntilIdle();
1815 1850
1816 // Check that a new item got created. 1851 // Check that a new item got created.
1817 EXPECT_EQ(3, model_->item_count()); 1852 EXPECT_EQ(3, model_->item_count());
1818 EXPECT_TRUE(grid_view->forward_events_to_drag_and_drop_host_for_test()); 1853 EXPECT_TRUE(grid_view->forward_events_to_drag_and_drop_host_for_test());
1819 1854
1820 // Move it to an empty slot on grid_view. 1855 // Move it to an empty slot on grid_view.
1821 gfx::Rect empty_slot_rect = bounds_grid_1; 1856 gfx::Rect empty_slot_rect = bounds_grid_1;
1822 empty_slot_rect.Offset(0, bounds_grid_1.height()); 1857 empty_slot_rect.Offset(0, grid_view->GetTotalTileSize().height());
1823 generator.MoveMouseTo(empty_slot_rect.CenterPoint().x(), 1858 generator.MoveMouseTo(empty_slot_rect.CenterPoint().x(),
1824 empty_slot_rect.CenterPoint().y()); 1859 empty_slot_rect.CenterPoint().y());
1825 base::MessageLoop::current()->RunUntilIdle(); 1860 base::MessageLoop::current()->RunUntilIdle();
1826 EXPECT_EQ(2, model_->item_count()); 1861 EXPECT_EQ(2, model_->item_count());
1827 EXPECT_FALSE(grid_view->forward_events_to_drag_and_drop_host_for_test()); 1862 EXPECT_FALSE(grid_view->forward_events_to_drag_and_drop_host_for_test());
1828 1863
1829 // Dropping it should keep the shelf as it originally was. 1864 // Dropping it should keep the shelf as it originally was.
1830 generator.ReleaseLeftButton(); 1865 generator.ReleaseLeftButton();
1831 base::MessageLoop::current()->RunUntilIdle(); 1866 base::MessageLoop::current()->RunUntilIdle();
1832 EXPECT_EQ(2, model_->item_count()); 1867 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()); 1982 EXPECT_EQ(2, model_->item_count());
1948 EXPECT_FALSE(service->IsAppListVisible()); 1983 EXPECT_FALSE(service->IsAppListVisible());
1949 1984
1950 // Open the app list menu and check that the drag and drop host was set. 1985 // Open the app list menu and check that the drag and drop host was set.
1951 gfx::Rect app_list_bounds = 1986 gfx::Rect app_list_bounds =
1952 test.shelf_view()->GetAppListButtonView()->GetBoundsInScreen(); 1987 test.shelf_view()->GetAppListButtonView()->GetBoundsInScreen();
1953 generator.MoveMouseTo(app_list_bounds.CenterPoint().x(), 1988 generator.MoveMouseTo(app_list_bounds.CenterPoint().x(),
1954 app_list_bounds.CenterPoint().y()); 1989 app_list_bounds.CenterPoint().y());
1955 generator.ClickLeftButton(); 1990 generator.ClickLeftButton();
1956 base::MessageLoop::current()->RunUntilIdle(); 1991 base::MessageLoop::current()->RunUntilIdle();
1992 EXPECT_TRUE(service->IsAppListVisible());
1957 1993
1994 // Click the "all apps" button on the start page.
1995 OnStartPageClickAllAppsButton(&generator, gfx::Point());
1958 EXPECT_TRUE(service->IsAppListVisible()); 1996 EXPECT_TRUE(service->IsAppListVisible());
1997
1998 // Click an app icon in the app grid view.
1959 app_list::AppsGridView* grid_view = 1999 app_list::AppsGridView* grid_view =
1960 ash::test::AppListControllerTestApi(ash::Shell::GetInstance()). 2000 ash::test::AppListControllerTestApi(ash::Shell::GetInstance()).
1961 GetRootGridView(); 2001 GetRootGridView();
1962 ASSERT_TRUE(grid_view); 2002 ASSERT_TRUE(grid_view);
1963 const views::ViewModelT<app_list::AppListItemView>* vm_grid = 2003 const views::ViewModelT<app_list::AppListItemView>* vm_grid =
1964 grid_view->view_model_for_test(); 2004 grid_view->view_model_for_test();
1965 EXPECT_EQ(2, vm_grid->view_size()); 2005 EXPECT_EQ(2, vm_grid->view_size());
1966 gfx::Rect bounds_grid_1 = vm_grid->view_at(1)->GetBoundsInScreen(); 2006 gfx::Rect bounds_grid_1 = vm_grid->view_at(1)->GetBoundsInScreen();
1967 // Test now that a click does create a new application tab. 2007 // Test now that a click does create a new application tab.
1968 TabStripModel* tab_strip = browser()->tab_strip_model(); 2008 TabStripModel* tab_strip = browser()->tab_strip_model();
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
2130 chrome::GetSettingsUrl(std::string())); 2170 chrome::GetSettingsUrl(std::string()));
2131 Browser* settings_browser = 2171 Browser* settings_browser =
2132 settings_manager->FindBrowserForProfile(browser()->profile()); 2172 settings_manager->FindBrowserForProfile(browser()->profile());
2133 ASSERT_TRUE(settings_browser); 2173 ASSERT_TRUE(settings_browser);
2134 EXPECT_EQ(browser_count, NumberOfDetectedLauncherBrowsers(false)); 2174 EXPECT_EQ(browser_count, NumberOfDetectedLauncherBrowsers(false));
2135 EXPECT_EQ(item_count + 1, shelf_model->item_count()); 2175 EXPECT_EQ(item_count + 1, shelf_model->item_count());
2136 2176
2137 // TODO(stevenjb): Test multiprofile on Chrome OS when test support is addded. 2177 // TODO(stevenjb): Test multiprofile on Chrome OS when test support is addded.
2138 // crbug.com/230464. 2178 // crbug.com/230464.
2139 } 2179 }
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