OLD | NEW |
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_impl.h" | 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "ash/aura/wm_window_aura.h" | 9 #include "ash/aura/wm_window_aura.h" |
10 #include "ash/common/shelf/app_list_button.h" | 10 #include "ash/common/shelf/app_list_button.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 #include "chrome/browser/extensions/extension_service.h" | 35 #include "chrome/browser/extensions/extension_service.h" |
36 #include "chrome/browser/extensions/launch_util.h" | 36 #include "chrome/browser/extensions/launch_util.h" |
37 #include "chrome/browser/profiles/profile.h" | 37 #include "chrome/browser/profiles/profile.h" |
38 #include "chrome/browser/ui/app_list/app_list_service.h" | 38 #include "chrome/browser/ui/app_list/app_list_service.h" |
39 #include "chrome/browser/ui/ash/app_list/test/app_list_service_ash_test_api.h" | 39 #include "chrome/browser/ui/ash/app_list/test/app_list_service_ash_test_api.h" |
40 #include "chrome/browser/ui/ash/launcher/browser_shortcut_launcher_item_controll
er.h" | 40 #include "chrome/browser/ui/ash/launcher/browser_shortcut_launcher_item_controll
er.h" |
41 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_util.h" | 41 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_util.h" |
42 #include "chrome/browser/ui/ash/launcher/launcher_application_menu_item_model.h" | 42 #include "chrome/browser/ui/ash/launcher/launcher_application_menu_item_model.h" |
43 #include "chrome/browser/ui/ash/launcher/launcher_context_menu.h" | 43 #include "chrome/browser/ui/ash/launcher/launcher_context_menu.h" |
44 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h" | 44 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h" |
| 45 #include "chrome/browser/ui/ash/session_controller_client.h" |
45 #include "chrome/browser/ui/browser.h" | 46 #include "chrome/browser/ui/browser.h" |
46 #include "chrome/browser/ui/browser_commands.h" | 47 #include "chrome/browser/ui/browser_commands.h" |
47 #include "chrome/browser/ui/browser_finder.h" | 48 #include "chrome/browser/ui/browser_finder.h" |
48 #include "chrome/browser/ui/browser_list.h" | 49 #include "chrome/browser/ui/browser_list.h" |
49 #include "chrome/browser/ui/browser_window.h" | 50 #include "chrome/browser/ui/browser_window.h" |
50 #include "chrome/browser/ui/chrome_pages.h" | 51 #include "chrome/browser/ui/chrome_pages.h" |
51 #include "chrome/browser/ui/extensions/app_launch_params.h" | 52 #include "chrome/browser/ui/extensions/app_launch_params.h" |
52 #include "chrome/browser/ui/extensions/application_launch.h" | 53 #include "chrome/browser/ui/extensions/application_launch.h" |
53 #include "chrome/browser/ui/settings_window_manager.h" | 54 #include "chrome/browser/ui/settings_window_manager.h" |
54 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 55 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 } // namespace | 186 } // namespace |
186 | 187 |
187 class LauncherPlatformAppBrowserTest | 188 class LauncherPlatformAppBrowserTest |
188 : public extensions::PlatformAppBrowserTest { | 189 : public extensions::PlatformAppBrowserTest { |
189 protected: | 190 protected: |
190 LauncherPlatformAppBrowserTest() : controller_(nullptr) {} | 191 LauncherPlatformAppBrowserTest() : controller_(nullptr) {} |
191 | 192 |
192 ~LauncherPlatformAppBrowserTest() override {} | 193 ~LauncherPlatformAppBrowserTest() override {} |
193 | 194 |
194 void RunTestOnMainThreadLoop() override { | 195 void RunTestOnMainThreadLoop() override { |
| 196 // Ensure ash starts the session and creates the shelf and controller. |
| 197 SessionControllerClient::FlushForTesting(); |
| 198 |
195 controller_ = GetChromeLauncherControllerImpl(); | 199 controller_ = GetChromeLauncherControllerImpl(); |
| 200 ASSERT_TRUE(controller_); |
196 return extensions::PlatformAppBrowserTest::RunTestOnMainThreadLoop(); | 201 return extensions::PlatformAppBrowserTest::RunTestOnMainThreadLoop(); |
197 } | 202 } |
198 | 203 |
199 ash::ShelfModel* shelf_model() { return ash::WmShell::Get()->shelf_model(); } | 204 ash::ShelfModel* shelf_model() { return ash::WmShell::Get()->shelf_model(); } |
200 | 205 |
201 ash::ShelfID CreateAppShortcutLauncherItem( | 206 ash::ShelfID CreateAppShortcutLauncherItem( |
202 const ash::launcher::AppLauncherId& app_launcher_id) { | 207 const ash::launcher::AppLauncherId& app_launcher_id) { |
203 return controller_->CreateAppShortcutLauncherItem( | 208 return controller_->CreateAppShortcutLauncherItem( |
204 app_launcher_id, shelf_model()->item_count()); | 209 app_launcher_id, shelf_model()->item_count()); |
205 } | 210 } |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 }; | 257 }; |
253 | 258 |
254 class ShelfAppBrowserTest : public ExtensionBrowserTest { | 259 class ShelfAppBrowserTest : public ExtensionBrowserTest { |
255 protected: | 260 protected: |
256 ShelfAppBrowserTest() : shelf_(NULL), model_(NULL), controller_(NULL) { | 261 ShelfAppBrowserTest() : shelf_(NULL), model_(NULL), controller_(NULL) { |
257 } | 262 } |
258 | 263 |
259 ~ShelfAppBrowserTest() override {} | 264 ~ShelfAppBrowserTest() override {} |
260 | 265 |
261 void RunTestOnMainThreadLoop() override { | 266 void RunTestOnMainThreadLoop() override { |
| 267 // Ensure ash starts the session and creates the shelf and controller. |
| 268 SessionControllerClient::FlushForTesting(); |
| 269 |
262 shelf_ = | 270 shelf_ = |
263 ash::WmShelf::ForWindow(ash::WmShell::Get()->GetPrimaryRootWindow()); | 271 ash::WmShelf::ForWindow(ash::WmShell::Get()->GetPrimaryRootWindow()); |
264 model_ = ash::WmShell::Get()->shelf_model(); | 272 model_ = ash::WmShell::Get()->shelf_model(); |
265 controller_ = GetChromeLauncherControllerImpl(); | 273 controller_ = GetChromeLauncherControllerImpl(); |
| 274 ASSERT_TRUE(controller_); |
266 return ExtensionBrowserTest::RunTestOnMainThreadLoop(); | 275 return ExtensionBrowserTest::RunTestOnMainThreadLoop(); |
267 } | 276 } |
268 | 277 |
269 size_t NumberOfDetectedLauncherBrowsers(bool show_all_tabs) { | 278 size_t NumberOfDetectedLauncherBrowsers(bool show_all_tabs) { |
270 LauncherItemController* item_controller = | 279 LauncherItemController* item_controller = |
271 controller_->GetBrowserShortcutLauncherItemController(); | 280 controller_->GetBrowserShortcutLauncherItemController(); |
272 int items = item_controller->GetApplicationList( | 281 int items = item_controller->GetApplicationList( |
273 show_all_tabs ? ui::EF_SHIFT_DOWN : 0).size(); | 282 show_all_tabs ? ui::EF_SHIFT_DOWN : 0).size(); |
274 // If we have at least one item, we have also a title which we remove here. | 283 // If we have at least one item, we have also a title which we remove here. |
275 return items ? (items - 1) : 0; | 284 return items ? (items - 1) : 0; |
(...skipping 2127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2403 | 2412 |
2404 // Close all windows via the menu item. | 2413 // Close all windows via the menu item. |
2405 CloseBrowserWindow(browser(), menu1.get(), LauncherContextMenu::MENU_CLOSE); | 2414 CloseBrowserWindow(browser(), menu1.get(), LauncherContextMenu::MENU_CLOSE); |
2406 EXPECT_EQ(0u, BrowserList::GetInstance()->size()); | 2415 EXPECT_EQ(0u, BrowserList::GetInstance()->size()); |
2407 | 2416 |
2408 // Check if "Close" is removed from the context menu. | 2417 // Check if "Close" is removed from the context menu. |
2409 std::unique_ptr<LauncherContextMenu> menu2 = CreateBrowserItemContextMenu(); | 2418 std::unique_ptr<LauncherContextMenu> menu2 = CreateBrowserItemContextMenu(); |
2410 ASSERT_FALSE( | 2419 ASSERT_FALSE( |
2411 IsItemPresentInMenu(menu2.get(), LauncherContextMenu::MENU_CLOSE)); | 2420 IsItemPresentInMenu(menu2.get(), LauncherContextMenu::MENU_CLOSE)); |
2412 } | 2421 } |
OLD | NEW |