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/public/cpp/app_launch_id.h" | 9 #include "ash/public/cpp/app_launch_id.h" |
10 #include "ash/public/cpp/shelf_item_delegate.h" | 10 #include "ash/public/cpp/shelf_item_delegate.h" |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 | 217 |
218 } // namespace | 218 } // namespace |
219 | 219 |
220 class LauncherPlatformAppBrowserTest | 220 class LauncherPlatformAppBrowserTest |
221 : public extensions::PlatformAppBrowserTest { | 221 : public extensions::PlatformAppBrowserTest { |
222 protected: | 222 protected: |
223 LauncherPlatformAppBrowserTest() : controller_(nullptr) {} | 223 LauncherPlatformAppBrowserTest() : controller_(nullptr) {} |
224 | 224 |
225 ~LauncherPlatformAppBrowserTest() override {} | 225 ~LauncherPlatformAppBrowserTest() override {} |
226 | 226 |
227 void RunTestOnMainThreadLoop() override { | 227 void SetUpOnMainThread() override { |
228 // Ensure ash starts the session and creates the shelf and controller. | 228 // Ensure ash starts the session and creates the shelf and controller. |
229 SessionControllerClient::FlushForTesting(); | 229 SessionControllerClient::FlushForTesting(); |
230 | 230 |
231 controller_ = GetChromeLauncherControllerImpl(); | 231 controller_ = GetChromeLauncherControllerImpl(); |
232 ASSERT_TRUE(controller_); | 232 ASSERT_TRUE(controller_); |
233 return extensions::PlatformAppBrowserTest::RunTestOnMainThreadLoop(); | 233 extensions::PlatformAppBrowserTest::SetUpOnMainThread(); |
234 } | 234 } |
235 | 235 |
236 ash::ShelfModel* shelf_model() { return ash::Shell::Get()->shelf_model(); } | 236 ash::ShelfModel* shelf_model() { return ash::Shell::Get()->shelf_model(); } |
237 | 237 |
238 ash::ShelfID CreateAppShortcutLauncherItem( | 238 ash::ShelfID CreateAppShortcutLauncherItem( |
239 const ash::AppLaunchId& app_launch_id) { | 239 const ash::AppLaunchId& app_launch_id) { |
240 return controller_->CreateAppShortcutLauncherItem( | 240 return controller_->CreateAppShortcutLauncherItem( |
241 app_launch_id, shelf_model()->item_count()); | 241 app_launch_id, shelf_model()->item_count()); |
242 } | 242 } |
243 | 243 |
(...skipping 30 matching lines...) Expand all Loading... |
274 RIP_OFF_ITEM_AND_DONT_RELEASE_MOUSE, | 274 RIP_OFF_ITEM_AND_DONT_RELEASE_MOUSE, |
275 }; | 275 }; |
276 | 276 |
277 class ShelfAppBrowserTest : public ExtensionBrowserTest { | 277 class ShelfAppBrowserTest : public ExtensionBrowserTest { |
278 protected: | 278 protected: |
279 ShelfAppBrowserTest() : shelf_(NULL), model_(NULL), controller_(NULL) { | 279 ShelfAppBrowserTest() : shelf_(NULL), model_(NULL), controller_(NULL) { |
280 } | 280 } |
281 | 281 |
282 ~ShelfAppBrowserTest() override {} | 282 ~ShelfAppBrowserTest() override {} |
283 | 283 |
284 void RunTestOnMainThreadLoop() override { | 284 void SetUpOnMainThread() override { |
285 // Ensure ash starts the session and creates the shelf and controller. | 285 // Ensure ash starts the session and creates the shelf and controller. |
286 SessionControllerClient::FlushForTesting(); | 286 SessionControllerClient::FlushForTesting(); |
287 | 287 |
288 shelf_ = | 288 shelf_ = |
289 ash::WmShelf::ForWindow(ash::ShellPort::Get()->GetPrimaryRootWindow()); | 289 ash::WmShelf::ForWindow(ash::ShellPort::Get()->GetPrimaryRootWindow()); |
290 model_ = ash::Shell::Get()->shelf_model(); | 290 model_ = ash::Shell::Get()->shelf_model(); |
291 controller_ = GetChromeLauncherControllerImpl(); | 291 controller_ = GetChromeLauncherControllerImpl(); |
292 ASSERT_TRUE(controller_); | 292 ASSERT_TRUE(controller_); |
293 return ExtensionBrowserTest::RunTestOnMainThreadLoop(); | 293 ExtensionBrowserTest::SetUpOnMainThread(); |
294 } | 294 } |
295 | 295 |
296 size_t NumberOfDetectedLauncherBrowsers(bool show_all_tabs) { | 296 size_t NumberOfDetectedLauncherBrowsers(bool show_all_tabs) { |
297 ash::ShelfItemDelegate* item_controller = | 297 ash::ShelfItemDelegate* item_controller = |
298 controller_->GetBrowserShortcutLauncherItemController(); | 298 controller_->GetBrowserShortcutLauncherItemController(); |
299 return item_controller | 299 return item_controller |
300 ->GetAppMenuItems(show_all_tabs ? ui::EF_SHIFT_DOWN : 0) | 300 ->GetAppMenuItems(show_all_tabs ? ui::EF_SHIFT_DOWN : 0) |
301 .size(); | 301 .size(); |
302 } | 302 } |
303 | 303 |
(...skipping 2105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2409 | 2409 |
2410 // Close all windows via the menu item. | 2410 // Close all windows via the menu item. |
2411 CloseBrowserWindow(browser(), menu1.get(), LauncherContextMenu::MENU_CLOSE); | 2411 CloseBrowserWindow(browser(), menu1.get(), LauncherContextMenu::MENU_CLOSE); |
2412 EXPECT_EQ(0u, BrowserList::GetInstance()->size()); | 2412 EXPECT_EQ(0u, BrowserList::GetInstance()->size()); |
2413 | 2413 |
2414 // Check if "Close" is removed from the context menu. | 2414 // Check if "Close" is removed from the context menu. |
2415 std::unique_ptr<LauncherContextMenu> menu2 = CreateBrowserItemContextMenu(); | 2415 std::unique_ptr<LauncherContextMenu> menu2 = CreateBrowserItemContextMenu(); |
2416 ASSERT_FALSE( | 2416 ASSERT_FALSE( |
2417 IsItemPresentInMenu(menu2.get(), LauncherContextMenu::MENU_CLOSE)); | 2417 IsItemPresentInMenu(menu2.get(), LauncherContextMenu::MENU_CLOSE)); |
2418 } | 2418 } |
OLD | NEW |