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

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

Issue 1861013004: AppListController refactoring part 3: Switching over to use AppListShower in Ash. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mus_chrome_delegates_ash_impl
Patch Set: Rebase. Created 4 years, 8 months 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/ash/chrome_shell_delegate.cc ('k') | chrome/chrome_browser_ui.gypi » ('j') | 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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include "ash/ash_switches.h" 9 #include "ash/ash_switches.h"
10 #include "ash/shelf/shelf.h" 10 #include "ash/shelf/shelf.h"
11 #include "ash/shelf/shelf_button.h" 11 #include "ash/shelf/shelf_button.h"
12 #include "ash/shelf/shelf_constants.h" 12 #include "ash/shelf/shelf_constants.h"
13 #include "ash/shelf/shelf_model.h" 13 #include "ash/shelf/shelf_model.h"
14 #include "ash/shelf/shelf_util.h" 14 #include "ash/shelf/shelf_util.h"
15 #include "ash/shelf/shelf_view.h" 15 #include "ash/shelf/shelf_view.h"
16 #include "ash/shell.h" 16 #include "ash/shell.h"
17 #include "ash/test/app_list_controller_test_api.h"
18 #include "ash/test/shelf_test_api.h" 17 #include "ash/test/shelf_test_api.h"
19 #include "ash/test/shelf_view_test_api.h" 18 #include "ash/test/shelf_view_test_api.h"
20 #include "ash/test/shell_test_api.h" 19 #include "ash/test/shell_test_api.h"
21 #include "ash/wm/window_state.h" 20 #include "ash/wm/window_state.h"
22 #include "ash/wm/window_util.h" 21 #include "ash/wm/window_util.h"
23 #include "base/macros.h" 22 #include "base/macros.h"
24 #include "base/strings/stringprintf.h" 23 #include "base/strings/stringprintf.h"
25 #include "base/strings/utf_string_conversions.h" 24 #include "base/strings/utf_string_conversions.h"
26 #include "build/build_config.h" 25 #include "build/build_config.h"
27 #include "chrome/browser/apps/app_browsertest_util.h" 26 #include "chrome/browser/apps/app_browsertest_util.h"
28 #include "chrome/browser/chrome_notification_types.h" 27 #include "chrome/browser/chrome_notification_types.h"
29 #include "chrome/browser/extensions/extension_apitest.h" 28 #include "chrome/browser/extensions/extension_apitest.h"
30 #include "chrome/browser/extensions/extension_browsertest.h" 29 #include "chrome/browser/extensions/extension_browsertest.h"
31 #include "chrome/browser/extensions/extension_function_test_utils.h" 30 #include "chrome/browser/extensions/extension_function_test_utils.h"
32 #include "chrome/browser/extensions/extension_service.h" 31 #include "chrome/browser/extensions/extension_service.h"
33 #include "chrome/browser/extensions/launch_util.h" 32 #include "chrome/browser/extensions/launch_util.h"
34 #include "chrome/browser/profiles/profile.h" 33 #include "chrome/browser/profiles/profile.h"
35 #include "chrome/browser/ui/app_list/app_list_service.h" 34 #include "chrome/browser/ui/app_list/app_list_service.h"
35 #include "chrome/browser/ui/ash/app_list/test/app_list_service_ash_test_api.h"
36 #include "chrome/browser/ui/ash/launcher/browser_shortcut_launcher_item_controll er.h" 36 #include "chrome/browser/ui/ash/launcher/browser_shortcut_launcher_item_controll er.h"
37 #include "chrome/browser/ui/ash/launcher/launcher_application_menu_item_model.h" 37 #include "chrome/browser/ui/ash/launcher/launcher_application_menu_item_model.h"
38 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h" 38 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h"
39 #include "chrome/browser/ui/browser.h" 39 #include "chrome/browser/ui/browser.h"
40 #include "chrome/browser/ui/browser_commands.h" 40 #include "chrome/browser/ui/browser_commands.h"
41 #include "chrome/browser/ui/browser_finder.h" 41 #include "chrome/browser/ui/browser_finder.h"
42 #include "chrome/browser/ui/browser_list.h" 42 #include "chrome/browser/ui/browser_list.h"
43 #include "chrome/browser/ui/browser_window.h" 43 #include "chrome/browser/ui/browser_window.h"
44 #include "chrome/browser/ui/chrome_pages.h" 44 #include "chrome/browser/ui/chrome_pages.h"
45 #include "chrome/browser/ui/extensions/app_launch_params.h" 45 #include "chrome/browser/ui/extensions/app_launch_params.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 // Click the "All Apps" button from the app launcher start page. Assumes that 119 // Click the "All Apps" button from the app launcher start page. Assumes that
120 // the app launcher is open to the start page. On the non-experimental launcher, 120 // the app launcher is open to the start page. On the non-experimental launcher,
121 // does nothing. 121 // does nothing.
122 // |display_origin| is the top-left corner of the active display, in screen 122 // |display_origin| is the top-left corner of the active display, in screen
123 // coordinates. 123 // coordinates.
124 void ClickAllAppsButtonFromStartPage(ui::test::EventGenerator* generator, 124 void ClickAllAppsButtonFromStartPage(ui::test::EventGenerator* generator,
125 const gfx::Point& display_origin) { 125 const gfx::Point& display_origin) {
126 if (!app_list::switches::IsExperimentalAppListEnabled()) 126 if (!app_list::switches::IsExperimentalAppListEnabled())
127 return; 127 return;
128 128
129 ash::test::AppListControllerTestApi controller_test( 129 AppListServiceAshTestApi service_test;
130 ash::Shell::GetInstance());
131 130
132 app_list::StartPageView* start_page_view = controller_test.GetStartPageView(); 131 app_list::StartPageView* start_page_view = service_test.GetStartPageView();
133 DCHECK(start_page_view); 132 DCHECK(start_page_view);
134 133
135 app_list::TileItemView* all_apps_button = start_page_view->all_apps_button(); 134 app_list::TileItemView* all_apps_button = start_page_view->all_apps_button();
136 gfx::Rect all_apps_rect = all_apps_button->GetBoundsInScreen(); 135 gfx::Rect all_apps_rect = all_apps_button->GetBoundsInScreen();
137 all_apps_rect.Offset(-display_origin.x(), -display_origin.y()); 136 all_apps_rect.Offset(-display_origin.x(), -display_origin.y());
138 generator->MoveMouseTo(all_apps_rect.CenterPoint().x(), 137 generator->MoveMouseTo(all_apps_rect.CenterPoint().x(),
139 all_apps_rect.CenterPoint().y()); 138 all_apps_rect.CenterPoint().y());
140 generator->ClickLeftButton(); 139 generator->ClickLeftButton();
141 base::MessageLoop::current()->RunUntilIdle(); 140 base::MessageLoop::current()->RunUntilIdle();
142 // Run Layout() to effectively complete the animation to the apps page. 141 // Run Layout() to effectively complete the animation to the apps page.
143 controller_test.LayoutContentsView(); 142 service_test.LayoutContentsView();
144 } 143 }
145 144
146 // Find the browser that associated with |app_name|. 145 // Find the browser that associated with |app_name|.
147 Browser* FindBrowserForApp(const std::string& app_name) { 146 Browser* FindBrowserForApp(const std::string& app_name) {
148 for (auto* browser : *BrowserList::GetInstance()) { 147 for (auto* browser : *BrowserList::GetInstance()) {
149 std::string browser_app_name = 148 std::string browser_app_name =
150 web_app::GetExtensionIdFromApplicationName(browser->app_name()); 149 web_app::GetExtensionIdFromApplicationName(browser->app_name());
151 if (browser_app_name == app_name) 150 if (browser_app_name == app_name)
152 return browser; 151 return browser;
153 } 152 }
(...skipping 1465 matching lines...) Expand 10 before | Expand all | Expand 10 after
1619 // Open the app list menu and check that the drag and drop host was set. 1618 // Open the app list menu and check that the drag and drop host was set.
1620 gfx::Rect app_list_bounds = 1619 gfx::Rect app_list_bounds =
1621 test.shelf_view()->GetAppListButtonView()->GetBoundsInScreen(); 1620 test.shelf_view()->GetAppListButtonView()->GetBoundsInScreen();
1622 generator.MoveMouseTo(app_list_bounds.CenterPoint().x(), 1621 generator.MoveMouseTo(app_list_bounds.CenterPoint().x(),
1623 app_list_bounds.CenterPoint().y()); 1622 app_list_bounds.CenterPoint().y());
1624 base::MessageLoop::current()->RunUntilIdle(); 1623 base::MessageLoop::current()->RunUntilIdle();
1625 generator.ClickLeftButton(); 1624 generator.ClickLeftButton();
1626 1625
1627 EXPECT_TRUE(service->IsAppListVisible()); 1626 EXPECT_TRUE(service->IsAppListVisible());
1628 app_list::AppsGridView* grid_view = 1627 app_list::AppsGridView* grid_view =
1629 ash::test::AppListControllerTestApi(ash::Shell::GetInstance()). 1628 AppListServiceAshTestApi().GetRootGridView();
1630 GetRootGridView();
1631 ASSERT_TRUE(grid_view); 1629 ASSERT_TRUE(grid_view);
1632 ASSERT_TRUE(grid_view->has_drag_and_drop_host_for_test()); 1630 ASSERT_TRUE(grid_view->has_drag_and_drop_host_for_test());
1633 1631
1634 // There should be 2 items in our application list. 1632 // There should be 2 items in our application list.
1635 const views::ViewModelT<app_list::AppListItemView>* vm_grid = 1633 const views::ViewModelT<app_list::AppListItemView>* vm_grid =
1636 grid_view->view_model_for_test(); 1634 grid_view->view_model_for_test();
1637 EXPECT_EQ(2, vm_grid->view_size()); 1635 EXPECT_EQ(2, vm_grid->view_size());
1638 1636
1639 // Test #1: Drag an app list which does not exist yet item into the 1637 // Test #1: Drag an app list which does not exist yet item into the
1640 // launcher. Keeping it dragged, see that a new item gets created. Continuing 1638 // launcher. Keeping it dragged, see that a new item gets created. Continuing
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
1774 app_list_bounds.CenterPoint().y()); 1772 app_list_bounds.CenterPoint().y());
1775 generator.ClickLeftButton(); 1773 generator.ClickLeftButton();
1776 base::MessageLoop::current()->RunUntilIdle(); 1774 base::MessageLoop::current()->RunUntilIdle();
1777 EXPECT_TRUE(service->IsAppListVisible()); 1775 EXPECT_TRUE(service->IsAppListVisible());
1778 1776
1779 // Click the "all apps" button on the start page. 1777 // Click the "all apps" button on the start page.
1780 ClickAllAppsButtonFromStartPage(&generator, origin); 1778 ClickAllAppsButtonFromStartPage(&generator, origin);
1781 EXPECT_TRUE(service->IsAppListVisible()); 1779 EXPECT_TRUE(service->IsAppListVisible());
1782 1780
1783 app_list::AppsGridView* grid_view = 1781 app_list::AppsGridView* grid_view =
1784 ash::test::AppListControllerTestApi(ash::Shell::GetInstance()). 1782 AppListServiceAshTestApi().GetRootGridView();
1785 GetRootGridView();
1786 ASSERT_TRUE(grid_view); 1783 ASSERT_TRUE(grid_view);
1787 ASSERT_TRUE(grid_view->has_drag_and_drop_host_for_test()); 1784 ASSERT_TRUE(grid_view->has_drag_and_drop_host_for_test());
1788 1785
1789 // There should be 2 items in our application list. 1786 // There should be 2 items in our application list.
1790 const views::ViewModelT<app_list::AppListItemView>* vm_grid = 1787 const views::ViewModelT<app_list::AppListItemView>* vm_grid =
1791 grid_view->view_model_for_test(); 1788 grid_view->view_model_for_test();
1792 EXPECT_EQ(2, vm_grid->view_size()); 1789 EXPECT_EQ(2, vm_grid->view_size());
1793 1790
1794 // Drag an app list item which does not exist yet in the shelf. 1791 // Drag an app list item which does not exist yet in the shelf.
1795 // Keeping it dragged, see that a new item gets created. 1792 // Keeping it dragged, see that a new item gets created.
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
1958 generator.ClickLeftButton(); 1955 generator.ClickLeftButton();
1959 base::MessageLoop::current()->RunUntilIdle(); 1956 base::MessageLoop::current()->RunUntilIdle();
1960 EXPECT_TRUE(service->IsAppListVisible()); 1957 EXPECT_TRUE(service->IsAppListVisible());
1961 1958
1962 // Click the "all apps" button on the start page. 1959 // Click the "all apps" button on the start page.
1963 ClickAllAppsButtonFromStartPage(&generator, gfx::Point()); 1960 ClickAllAppsButtonFromStartPage(&generator, gfx::Point());
1964 EXPECT_TRUE(service->IsAppListVisible()); 1961 EXPECT_TRUE(service->IsAppListVisible());
1965 1962
1966 // Click an app icon in the app grid view. 1963 // Click an app icon in the app grid view.
1967 app_list::AppsGridView* grid_view = 1964 app_list::AppsGridView* grid_view =
1968 ash::test::AppListControllerTestApi(ash::Shell::GetInstance()). 1965 AppListServiceAshTestApi().GetRootGridView();
1969 GetRootGridView();
1970 ASSERT_TRUE(grid_view); 1966 ASSERT_TRUE(grid_view);
1971 const views::ViewModelT<app_list::AppListItemView>* vm_grid = 1967 const views::ViewModelT<app_list::AppListItemView>* vm_grid =
1972 grid_view->view_model_for_test(); 1968 grid_view->view_model_for_test();
1973 EXPECT_EQ(2, vm_grid->view_size()); 1969 EXPECT_EQ(2, vm_grid->view_size());
1974 gfx::Rect bounds_grid_1 = vm_grid->view_at(1)->GetBoundsInScreen(); 1970 gfx::Rect bounds_grid_1 = vm_grid->view_at(1)->GetBoundsInScreen();
1975 // Test now that a click does create a new application tab. 1971 // Test now that a click does create a new application tab.
1976 TabStripModel* tab_strip = browser()->tab_strip_model(); 1972 TabStripModel* tab_strip = browser()->tab_strip_model();
1977 int tab_count = tab_strip->count(); 1973 int tab_count = tab_strip->count();
1978 generator.MoveMouseTo(bounds_grid_1.CenterPoint().x(), 1974 generator.MoveMouseTo(bounds_grid_1.CenterPoint().x(),
1979 bounds_grid_1.CenterPoint().y()); 1975 bounds_grid_1.CenterPoint().y());
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
2235 controller_->ActivateApp(bookmark_app->id(), ash::LAUNCH_FROM_APP_LIST, 0); 2231 controller_->ActivateApp(bookmark_app->id(), ash::LAUNCH_FROM_APP_LIST, 0);
2236 2232
2237 // There should be two new browsers. 2233 // There should be two new browsers.
2238 EXPECT_EQ(3u, chrome::GetBrowserCount(browser()->profile())); 2234 EXPECT_EQ(3u, chrome::GetBrowserCount(browser()->profile()));
2239 2235
2240 // The apps should now be running, with the last opened app active. 2236 // The apps should now be running, with the last opened app active.
2241 EXPECT_EQ(ash::STATUS_RUNNING, model_->ItemByID(hosted_app_shelf_id)->status); 2237 EXPECT_EQ(ash::STATUS_RUNNING, model_->ItemByID(hosted_app_shelf_id)->status);
2242 EXPECT_EQ(ash::STATUS_ACTIVE, 2238 EXPECT_EQ(ash::STATUS_ACTIVE,
2243 model_->ItemByID(bookmark_app_shelf_id)->status); 2239 model_->ItemByID(bookmark_app_shelf_id)->status);
2244 } 2240 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/ash/chrome_shell_delegate.cc ('k') | chrome/chrome_browser_ui.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698