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

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

Issue 1866403006: Revert of 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: 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"
17 #include "ash/test/shelf_test_api.h" 18 #include "ash/test/shelf_test_api.h"
18 #include "ash/test/shelf_view_test_api.h" 19 #include "ash/test/shelf_view_test_api.h"
19 #include "ash/test/shell_test_api.h" 20 #include "ash/test/shell_test_api.h"
20 #include "ash/wm/window_state.h" 21 #include "ash/wm/window_state.h"
21 #include "ash/wm/window_util.h" 22 #include "ash/wm/window_util.h"
22 #include "base/macros.h" 23 #include "base/macros.h"
23 #include "base/strings/stringprintf.h" 24 #include "base/strings/stringprintf.h"
24 #include "base/strings/utf_string_conversions.h" 25 #include "base/strings/utf_string_conversions.h"
25 #include "build/build_config.h" 26 #include "build/build_config.h"
26 #include "chrome/browser/apps/app_browsertest_util.h" 27 #include "chrome/browser/apps/app_browsertest_util.h"
27 #include "chrome/browser/chrome_notification_types.h" 28 #include "chrome/browser/chrome_notification_types.h"
28 #include "chrome/browser/extensions/extension_apitest.h" 29 #include "chrome/browser/extensions/extension_apitest.h"
29 #include "chrome/browser/extensions/extension_browsertest.h" 30 #include "chrome/browser/extensions/extension_browsertest.h"
30 #include "chrome/browser/extensions/extension_function_test_utils.h" 31 #include "chrome/browser/extensions/extension_function_test_utils.h"
31 #include "chrome/browser/extensions/extension_service.h" 32 #include "chrome/browser/extensions/extension_service.h"
32 #include "chrome/browser/extensions/launch_util.h" 33 #include "chrome/browser/extensions/launch_util.h"
33 #include "chrome/browser/profiles/profile.h" 34 #include "chrome/browser/profiles/profile.h"
34 #include "chrome/browser/ui/app_list/app_list_service.h" 35 #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 AppListServiceAshTestApi service_test; 129 ash::test::AppListControllerTestApi controller_test(
130 ash::Shell::GetInstance());
130 131
131 app_list::StartPageView* start_page_view = service_test.GetStartPageView(); 132 app_list::StartPageView* start_page_view = controller_test.GetStartPageView();
132 DCHECK(start_page_view); 133 DCHECK(start_page_view);
133 134
134 app_list::TileItemView* all_apps_button = start_page_view->all_apps_button(); 135 app_list::TileItemView* all_apps_button = start_page_view->all_apps_button();
135 gfx::Rect all_apps_rect = all_apps_button->GetBoundsInScreen(); 136 gfx::Rect all_apps_rect = all_apps_button->GetBoundsInScreen();
136 all_apps_rect.Offset(-display_origin.x(), -display_origin.y()); 137 all_apps_rect.Offset(-display_origin.x(), -display_origin.y());
137 generator->MoveMouseTo(all_apps_rect.CenterPoint().x(), 138 generator->MoveMouseTo(all_apps_rect.CenterPoint().x(),
138 all_apps_rect.CenterPoint().y()); 139 all_apps_rect.CenterPoint().y());
139 generator->ClickLeftButton(); 140 generator->ClickLeftButton();
140 base::MessageLoop::current()->RunUntilIdle(); 141 base::MessageLoop::current()->RunUntilIdle();
141 // Run Layout() to effectively complete the animation to the apps page. 142 // Run Layout() to effectively complete the animation to the apps page.
142 service_test.LayoutContentsView(); 143 controller_test.LayoutContentsView();
143 } 144 }
144 145
145 // Find the browser that associated with |app_name|. 146 // Find the browser that associated with |app_name|.
146 Browser* FindBrowserForApp(const std::string& app_name) { 147 Browser* FindBrowserForApp(const std::string& app_name) {
147 for (auto* browser : *BrowserList::GetInstance()) { 148 for (auto* browser : *BrowserList::GetInstance()) {
148 std::string browser_app_name = 149 std::string browser_app_name =
149 web_app::GetExtensionIdFromApplicationName(browser->app_name()); 150 web_app::GetExtensionIdFromApplicationName(browser->app_name());
150 if (browser_app_name == app_name) 151 if (browser_app_name == app_name)
151 return browser; 152 return browser;
152 } 153 }
(...skipping 1465 matching lines...) Expand 10 before | Expand all | Expand 10 after
1618 // Open the app list menu and check that the drag and drop host was set. 1619 // Open the app list menu and check that the drag and drop host was set.
1619 gfx::Rect app_list_bounds = 1620 gfx::Rect app_list_bounds =
1620 test.shelf_view()->GetAppListButtonView()->GetBoundsInScreen(); 1621 test.shelf_view()->GetAppListButtonView()->GetBoundsInScreen();
1621 generator.MoveMouseTo(app_list_bounds.CenterPoint().x(), 1622 generator.MoveMouseTo(app_list_bounds.CenterPoint().x(),
1622 app_list_bounds.CenterPoint().y()); 1623 app_list_bounds.CenterPoint().y());
1623 base::MessageLoop::current()->RunUntilIdle(); 1624 base::MessageLoop::current()->RunUntilIdle();
1624 generator.ClickLeftButton(); 1625 generator.ClickLeftButton();
1625 1626
1626 EXPECT_TRUE(service->IsAppListVisible()); 1627 EXPECT_TRUE(service->IsAppListVisible());
1627 app_list::AppsGridView* grid_view = 1628 app_list::AppsGridView* grid_view =
1628 AppListServiceAshTestApi().GetRootGridView(); 1629 ash::test::AppListControllerTestApi(ash::Shell::GetInstance()).
1630 GetRootGridView();
1629 ASSERT_TRUE(grid_view); 1631 ASSERT_TRUE(grid_view);
1630 ASSERT_TRUE(grid_view->has_drag_and_drop_host_for_test()); 1632 ASSERT_TRUE(grid_view->has_drag_and_drop_host_for_test());
1631 1633
1632 // There should be 2 items in our application list. 1634 // There should be 2 items in our application list.
1633 const views::ViewModelT<app_list::AppListItemView>* vm_grid = 1635 const views::ViewModelT<app_list::AppListItemView>* vm_grid =
1634 grid_view->view_model_for_test(); 1636 grid_view->view_model_for_test();
1635 EXPECT_EQ(2, vm_grid->view_size()); 1637 EXPECT_EQ(2, vm_grid->view_size());
1636 1638
1637 // Test #1: Drag an app list which does not exist yet item into the 1639 // Test #1: Drag an app list which does not exist yet item into the
1638 // launcher. Keeping it dragged, see that a new item gets created. Continuing 1640 // launcher. Keeping it dragged, see that a new item gets created. Continuing
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
1772 app_list_bounds.CenterPoint().y()); 1774 app_list_bounds.CenterPoint().y());
1773 generator.ClickLeftButton(); 1775 generator.ClickLeftButton();
1774 base::MessageLoop::current()->RunUntilIdle(); 1776 base::MessageLoop::current()->RunUntilIdle();
1775 EXPECT_TRUE(service->IsAppListVisible()); 1777 EXPECT_TRUE(service->IsAppListVisible());
1776 1778
1777 // Click the "all apps" button on the start page. 1779 // Click the "all apps" button on the start page.
1778 ClickAllAppsButtonFromStartPage(&generator, origin); 1780 ClickAllAppsButtonFromStartPage(&generator, origin);
1779 EXPECT_TRUE(service->IsAppListVisible()); 1781 EXPECT_TRUE(service->IsAppListVisible());
1780 1782
1781 app_list::AppsGridView* grid_view = 1783 app_list::AppsGridView* grid_view =
1782 AppListServiceAshTestApi().GetRootGridView(); 1784 ash::test::AppListControllerTestApi(ash::Shell::GetInstance()).
1785 GetRootGridView();
1783 ASSERT_TRUE(grid_view); 1786 ASSERT_TRUE(grid_view);
1784 ASSERT_TRUE(grid_view->has_drag_and_drop_host_for_test()); 1787 ASSERT_TRUE(grid_view->has_drag_and_drop_host_for_test());
1785 1788
1786 // There should be 2 items in our application list. 1789 // There should be 2 items in our application list.
1787 const views::ViewModelT<app_list::AppListItemView>* vm_grid = 1790 const views::ViewModelT<app_list::AppListItemView>* vm_grid =
1788 grid_view->view_model_for_test(); 1791 grid_view->view_model_for_test();
1789 EXPECT_EQ(2, vm_grid->view_size()); 1792 EXPECT_EQ(2, vm_grid->view_size());
1790 1793
1791 // Drag an app list item which does not exist yet in the shelf. 1794 // Drag an app list item which does not exist yet in the shelf.
1792 // Keeping it dragged, see that a new item gets created. 1795 // Keeping it dragged, see that a new item gets created.
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
1955 generator.ClickLeftButton(); 1958 generator.ClickLeftButton();
1956 base::MessageLoop::current()->RunUntilIdle(); 1959 base::MessageLoop::current()->RunUntilIdle();
1957 EXPECT_TRUE(service->IsAppListVisible()); 1960 EXPECT_TRUE(service->IsAppListVisible());
1958 1961
1959 // Click the "all apps" button on the start page. 1962 // Click the "all apps" button on the start page.
1960 ClickAllAppsButtonFromStartPage(&generator, gfx::Point()); 1963 ClickAllAppsButtonFromStartPage(&generator, gfx::Point());
1961 EXPECT_TRUE(service->IsAppListVisible()); 1964 EXPECT_TRUE(service->IsAppListVisible());
1962 1965
1963 // Click an app icon in the app grid view. 1966 // Click an app icon in the app grid view.
1964 app_list::AppsGridView* grid_view = 1967 app_list::AppsGridView* grid_view =
1965 AppListServiceAshTestApi().GetRootGridView(); 1968 ash::test::AppListControllerTestApi(ash::Shell::GetInstance()).
1969 GetRootGridView();
1966 ASSERT_TRUE(grid_view); 1970 ASSERT_TRUE(grid_view);
1967 const views::ViewModelT<app_list::AppListItemView>* vm_grid = 1971 const views::ViewModelT<app_list::AppListItemView>* vm_grid =
1968 grid_view->view_model_for_test(); 1972 grid_view->view_model_for_test();
1969 EXPECT_EQ(2, vm_grid->view_size()); 1973 EXPECT_EQ(2, vm_grid->view_size());
1970 gfx::Rect bounds_grid_1 = vm_grid->view_at(1)->GetBoundsInScreen(); 1974 gfx::Rect bounds_grid_1 = vm_grid->view_at(1)->GetBoundsInScreen();
1971 // Test now that a click does create a new application tab. 1975 // Test now that a click does create a new application tab.
1972 TabStripModel* tab_strip = browser()->tab_strip_model(); 1976 TabStripModel* tab_strip = browser()->tab_strip_model();
1973 int tab_count = tab_strip->count(); 1977 int tab_count = tab_strip->count();
1974 generator.MoveMouseTo(bounds_grid_1.CenterPoint().x(), 1978 generator.MoveMouseTo(bounds_grid_1.CenterPoint().x(),
1975 bounds_grid_1.CenterPoint().y()); 1979 bounds_grid_1.CenterPoint().y());
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
2231 controller_->ActivateApp(bookmark_app->id(), ash::LAUNCH_FROM_APP_LIST, 0); 2235 controller_->ActivateApp(bookmark_app->id(), ash::LAUNCH_FROM_APP_LIST, 0);
2232 2236
2233 // There should be two new browsers. 2237 // There should be two new browsers.
2234 EXPECT_EQ(3u, chrome::GetBrowserCount(browser()->profile())); 2238 EXPECT_EQ(3u, chrome::GetBrowserCount(browser()->profile()));
2235 2239
2236 // The apps should now be running, with the last opened app active. 2240 // The apps should now be running, with the last opened app active.
2237 EXPECT_EQ(ash::STATUS_RUNNING, model_->ItemByID(hosted_app_shelf_id)->status); 2241 EXPECT_EQ(ash::STATUS_RUNNING, model_->ItemByID(hosted_app_shelf_id)->status);
2238 EXPECT_EQ(ash::STATUS_ACTIVE, 2242 EXPECT_EQ(ash::STATUS_ACTIVE,
2239 model_->ItemByID(bookmark_app_shelf_id)->status); 2243 model_->ItemByID(bookmark_app_shelf_id)->status);
2240 } 2244 }
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