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