| 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/common/shelf/app_list_button.h" | 9 #include "ash/common/shelf/app_list_button.h" |
| 10 #include "ash/common/shelf/shelf_button.h" | 10 #include "ash/common/shelf/shelf_button.h" |
| 11 #include "ash/common/shelf/shelf_constants.h" | 11 #include "ash/common/shelf/shelf_constants.h" |
| 12 #include "ash/common/shelf/shelf_model.h" | 12 #include "ash/common/shelf/shelf_model.h" |
| 13 #include "ash/common/shelf/shelf_view.h" | 13 #include "ash/common/shelf/shelf_view.h" |
| 14 #include "ash/common/shelf/shelf_widget.h" | 14 #include "ash/common/shelf/shelf_widget.h" |
| 15 #include "ash/common/shelf/wm_shelf.h" | 15 #include "ash/common/shelf/wm_shelf.h" |
| 16 #include "ash/common/wm/window_state.h" | 16 #include "ash/common/wm/window_state.h" |
| 17 #include "ash/common/wm_shell.h" | 17 #include "ash/common/wm_shell.h" |
| 18 #include "ash/common/wm_window.h" | 18 #include "ash/common/wm_window.h" |
| 19 #include "ash/public/cpp/app_launch_id.h" |
| 19 #include "ash/public/cpp/window_properties.h" | 20 #include "ash/public/cpp/window_properties.h" |
| 20 #include "ash/shell.h" | 21 #include "ash/shell.h" |
| 21 #include "ash/test/shelf_view_test_api.h" | 22 #include "ash/test/shelf_view_test_api.h" |
| 22 #include "ash/wm/window_properties.h" | 23 #include "ash/wm/window_properties.h" |
| 23 #include "ash/wm/window_state_aura.h" | 24 #include "ash/wm/window_state_aura.h" |
| 24 #include "ash/wm/window_util.h" | 25 #include "ash/wm/window_util.h" |
| 25 #include "base/macros.h" | 26 #include "base/macros.h" |
| 26 #include "base/run_loop.h" | 27 #include "base/run_loop.h" |
| 27 #include "base/strings/stringprintf.h" | 28 #include "base/strings/stringprintf.h" |
| 28 #include "base/strings/utf_string_conversions.h" | 29 #include "base/strings/utf_string_conversions.h" |
| 29 #include "build/build_config.h" | 30 #include "build/build_config.h" |
| 30 #include "chrome/browser/apps/app_browsertest_util.h" | 31 #include "chrome/browser/apps/app_browsertest_util.h" |
| 31 #include "chrome/browser/chrome_notification_types.h" | 32 #include "chrome/browser/chrome_notification_types.h" |
| 32 #include "chrome/browser/extensions/extension_apitest.h" | 33 #include "chrome/browser/extensions/extension_apitest.h" |
| 33 #include "chrome/browser/extensions/extension_browsertest.h" | 34 #include "chrome/browser/extensions/extension_browsertest.h" |
| 34 #include "chrome/browser/extensions/extension_function_test_utils.h" | 35 #include "chrome/browser/extensions/extension_function_test_utils.h" |
| 35 #include "chrome/browser/extensions/extension_service.h" | 36 #include "chrome/browser/extensions/extension_service.h" |
| 36 #include "chrome/browser/extensions/launch_util.h" | 37 #include "chrome/browser/extensions/launch_util.h" |
| 37 #include "chrome/browser/profiles/profile.h" | 38 #include "chrome/browser/profiles/profile.h" |
| 38 #include "chrome/browser/ui/app_list/app_list_service.h" | 39 #include "chrome/browser/ui/app_list/app_list_service.h" |
| 39 #include "chrome/browser/ui/ash/app_launcher_id.h" | |
| 40 #include "chrome/browser/ui/ash/app_list/test/app_list_service_ash_test_api.h" | 40 #include "chrome/browser/ui/ash/app_list/test/app_list_service_ash_test_api.h" |
| 41 #include "chrome/browser/ui/ash/launcher/browser_shortcut_launcher_item_controll
er.h" | 41 #include "chrome/browser/ui/ash/launcher/browser_shortcut_launcher_item_controll
er.h" |
| 42 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_util.h" | 42 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_util.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/ash/session_controller_client.h" |
| 46 #include "chrome/browser/ui/browser.h" | 46 #include "chrome/browser/ui/browser.h" |
| 47 #include "chrome/browser/ui/browser_commands.h" | 47 #include "chrome/browser/ui/browser_commands.h" |
| 48 #include "chrome/browser/ui/browser_finder.h" | 48 #include "chrome/browser/ui/browser_finder.h" |
| 49 #include "chrome/browser/ui/browser_list.h" | 49 #include "chrome/browser/ui/browser_list.h" |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 return extensions::PlatformAppBrowserTest::RunTestOnMainThreadLoop(); |
| 234 } | 234 } |
| 235 | 235 |
| 236 ash::ShelfModel* shelf_model() { return ash::WmShell::Get()->shelf_model(); } | 236 ash::ShelfModel* shelf_model() { return ash::WmShell::Get()->shelf_model(); } |
| 237 | 237 |
| 238 ash::ShelfID CreateAppShortcutLauncherItem( | 238 ash::ShelfID CreateAppShortcutLauncherItem( |
| 239 const ash::AppLauncherId& app_launcher_id) { | 239 const ash::AppLaunchId& app_launch_id) { |
| 240 return controller_->CreateAppShortcutLauncherItem( | 240 return controller_->CreateAppShortcutLauncherItem( |
| 241 app_launcher_id, shelf_model()->item_count()); | 241 app_launch_id, shelf_model()->item_count()); |
| 242 } | 242 } |
| 243 | 243 |
| 244 const ash::ShelfItem& GetLastLauncherItem() { | 244 const ash::ShelfItem& GetLastLauncherItem() { |
| 245 // Unless there are any panels, the item at index [count - 1] will be | 245 // Unless there are any panels, the item at index [count - 1] will be |
| 246 // the desired item. | 246 // the desired item. |
| 247 return shelf_model()->items()[shelf_model()->item_count() - 1]; | 247 return shelf_model()->items()[shelf_model()->item_count() - 1]; |
| 248 } | 248 } |
| 249 | 249 |
| 250 const ash::ShelfItem& GetLastLauncherPanelItem() { | 250 const ash::ShelfItem& GetLastLauncherPanelItem() { |
| 251 // Panels show up on the right side of the shelf, so the desired item | 251 // Panels show up on the right side of the shelf, so the desired item |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 LoadExtension(test_data_dir_.AppendASCII(name)); | 324 LoadExtension(test_data_dir_.AppendASCII(name)); |
| 325 | 325 |
| 326 // First get app_id. | 326 // First get app_id. |
| 327 const Extension* extension = | 327 const Extension* extension = |
| 328 service->GetExtensionById(last_loaded_extension_id(), false); | 328 service->GetExtensionById(last_loaded_extension_id(), false); |
| 329 const std::string app_id = extension->id(); | 329 const std::string app_id = extension->id(); |
| 330 | 330 |
| 331 // Then create a shortcut. | 331 // Then create a shortcut. |
| 332 int item_count = model_->item_count(); | 332 int item_count = model_->item_count(); |
| 333 ash::ShelfID shortcut_id = controller_->CreateAppShortcutLauncherItem( | 333 ash::ShelfID shortcut_id = controller_->CreateAppShortcutLauncherItem( |
| 334 ash::AppLauncherId(app_id), item_count); | 334 ash::AppLaunchId(app_id), item_count); |
| 335 controller_->SyncPinPosition(shortcut_id); | 335 controller_->SyncPinPosition(shortcut_id); |
| 336 EXPECT_EQ(++item_count, model_->item_count()); | 336 EXPECT_EQ(++item_count, model_->item_count()); |
| 337 const ash::ShelfItem& item = *model_->ItemByID(shortcut_id); | 337 const ash::ShelfItem& item = *model_->ItemByID(shortcut_id); |
| 338 EXPECT_EQ(ash::TYPE_PINNED_APP, item.type); | 338 EXPECT_EQ(ash::TYPE_PINNED_APP, item.type); |
| 339 return item.id; | 339 return item.id; |
| 340 } | 340 } |
| 341 | 341 |
| 342 void RemoveShortcut(ash::ShelfID id) { | 342 void RemoveShortcut(ash::ShelfID id) { |
| 343 controller_->Unpin(id); | 343 controller_->Unpin(id); |
| 344 } | 344 } |
| 345 | 345 |
| 346 ash::ShelfID PinFakeApp(const std::string& app_id) { | 346 ash::ShelfID PinFakeApp(const std::string& app_id) { |
| 347 return controller_->CreateAppShortcutLauncherItem( | 347 return controller_->CreateAppShortcutLauncherItem(ash::AppLaunchId(app_id), |
| 348 ash::AppLauncherId(app_id), model_->item_count()); | 348 model_->item_count()); |
| 349 } | 349 } |
| 350 | 350 |
| 351 // Get the index of an item which has the given type. | 351 // Get the index of an item which has the given type. |
| 352 int GetIndexOfShelfItemType(ash::ShelfItemType type) { | 352 int GetIndexOfShelfItemType(ash::ShelfItemType type) { |
| 353 return model_->GetItemIndexForType(type); | 353 return model_->GetItemIndexForType(type); |
| 354 } | 354 } |
| 355 | 355 |
| 356 // Try to rip off |item_index|. | 356 // Try to rip off |item_index|. |
| 357 void RipOffItemIndex(int index, | 357 void RipOffItemIndex(int index, |
| 358 ui::test::EventGenerator* generator, | 358 ui::test::EventGenerator* generator, |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 // Test that we can launch a platform app that already has a shortcut. | 445 // Test that we can launch a platform app that already has a shortcut. |
| 446 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, LaunchPinned) { | 446 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, LaunchPinned) { |
| 447 int item_count = shelf_model()->item_count(); | 447 int item_count = shelf_model()->item_count(); |
| 448 | 448 |
| 449 // First get app_id. | 449 // First get app_id. |
| 450 const Extension* extension = LoadAndLaunchPlatformApp("launch", "Launched"); | 450 const Extension* extension = LoadAndLaunchPlatformApp("launch", "Launched"); |
| 451 const std::string app_id = extension->id(); | 451 const std::string app_id = extension->id(); |
| 452 | 452 |
| 453 // Then create a shortcut. | 453 // Then create a shortcut. |
| 454 ash::ShelfID shortcut_id = | 454 ash::ShelfID shortcut_id = |
| 455 CreateAppShortcutLauncherItem(ash::AppLauncherId(app_id)); | 455 CreateAppShortcutLauncherItem(ash::AppLaunchId(app_id)); |
| 456 ++item_count; | 456 ++item_count; |
| 457 ASSERT_EQ(item_count, shelf_model()->item_count()); | 457 ASSERT_EQ(item_count, shelf_model()->item_count()); |
| 458 ash::ShelfItem item = *shelf_model()->ItemByID(shortcut_id); | 458 ash::ShelfItem item = *shelf_model()->ItemByID(shortcut_id); |
| 459 EXPECT_EQ(ash::TYPE_PINNED_APP, item.type); | 459 EXPECT_EQ(ash::TYPE_PINNED_APP, item.type); |
| 460 EXPECT_EQ(ash::STATUS_CLOSED, item.status); | 460 EXPECT_EQ(ash::STATUS_CLOSED, item.status); |
| 461 | 461 |
| 462 // Open a window. Confirm the item is now running. | 462 // Open a window. Confirm the item is now running. |
| 463 AppWindow* window = CreateAppWindow(browser()->profile(), extension); | 463 AppWindow* window = CreateAppWindow(browser()->profile(), extension); |
| 464 ash::wm::ActivateWindow(window->GetNativeWindow()); | 464 ash::wm::ActivateWindow(window->GetNativeWindow()); |
| 465 ASSERT_EQ(item_count, shelf_model()->item_count()); | 465 ASSERT_EQ(item_count, shelf_model()->item_count()); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 481 const Extension* extension = LoadAndLaunchPlatformApp("launch", "Launched"); | 481 const Extension* extension = LoadAndLaunchPlatformApp("launch", "Launched"); |
| 482 AppWindow* window = CreateAppWindow(browser()->profile(), extension); | 482 AppWindow* window = CreateAppWindow(browser()->profile(), extension); |
| 483 ++item_count; | 483 ++item_count; |
| 484 ASSERT_EQ(item_count, shelf_model()->item_count()); | 484 ASSERT_EQ(item_count, shelf_model()->item_count()); |
| 485 const ash::ShelfItem& item1 = GetLastLauncherItem(); | 485 const ash::ShelfItem& item1 = GetLastLauncherItem(); |
| 486 ash::ShelfID id = item1.id; | 486 ash::ShelfID id = item1.id; |
| 487 EXPECT_EQ(ash::TYPE_APP, item1.type); | 487 EXPECT_EQ(ash::TYPE_APP, item1.type); |
| 488 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status); | 488 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status); |
| 489 | 489 |
| 490 // Create a shortcut. The app item should be after it. | 490 // Create a shortcut. The app item should be after it. |
| 491 ash::ShelfID foo_id = | 491 ash::ShelfID foo_id = CreateAppShortcutLauncherItem(ash::AppLaunchId("foo")); |
| 492 CreateAppShortcutLauncherItem(ash::AppLauncherId("foo")); | |
| 493 ++item_count; | 492 ++item_count; |
| 494 ASSERT_EQ(item_count, shelf_model()->item_count()); | 493 ASSERT_EQ(item_count, shelf_model()->item_count()); |
| 495 EXPECT_LT(shelf_model()->ItemIndexByID(foo_id), | 494 EXPECT_LT(shelf_model()->ItemIndexByID(foo_id), |
| 496 shelf_model()->ItemIndexByID(id)); | 495 shelf_model()->ItemIndexByID(id)); |
| 497 | 496 |
| 498 // Pin the app. The item should remain. | 497 // Pin the app. The item should remain. |
| 499 controller_->Pin(id); | 498 controller_->Pin(id); |
| 500 ASSERT_EQ(item_count, shelf_model()->item_count()); | 499 ASSERT_EQ(item_count, shelf_model()->item_count()); |
| 501 const ash::ShelfItem& item2 = *shelf_model()->ItemByID(id); | 500 const ash::ShelfItem& item2 = *shelf_model()->ItemByID(id); |
| 502 EXPECT_EQ(ash::TYPE_PINNED_APP, item2.type); | 501 EXPECT_EQ(ash::TYPE_PINNED_APP, item2.type); |
| 503 EXPECT_EQ(ash::STATUS_ACTIVE, item2.status); | 502 EXPECT_EQ(ash::STATUS_ACTIVE, item2.status); |
| 504 | 503 |
| 505 // New shortcuts should come after the item. | 504 // New shortcuts should come after the item. |
| 506 ash::ShelfID bar_id = | 505 ash::ShelfID bar_id = CreateAppShortcutLauncherItem(ash::AppLaunchId("bar")); |
| 507 CreateAppShortcutLauncherItem(ash::AppLauncherId("bar")); | |
| 508 ++item_count; | 506 ++item_count; |
| 509 ASSERT_EQ(item_count, shelf_model()->item_count()); | 507 ASSERT_EQ(item_count, shelf_model()->item_count()); |
| 510 EXPECT_LT(shelf_model()->ItemIndexByID(id), | 508 EXPECT_LT(shelf_model()->ItemIndexByID(id), |
| 511 shelf_model()->ItemIndexByID(bar_id)); | 509 shelf_model()->ItemIndexByID(bar_id)); |
| 512 | 510 |
| 513 // Then close it, make sure the item remains. | 511 // Then close it, make sure the item remains. |
| 514 CloseAppWindow(window); | 512 CloseAppWindow(window); |
| 515 ASSERT_EQ(item_count, shelf_model()->item_count()); | 513 ASSERT_EQ(item_count, shelf_model()->item_count()); |
| 516 } | 514 } |
| 517 | 515 |
| 518 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, UnpinRunning) { | 516 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, UnpinRunning) { |
| 519 int item_count = shelf_model()->item_count(); | 517 int item_count = shelf_model()->item_count(); |
| 520 | 518 |
| 521 // First get app_id. | 519 // First get app_id. |
| 522 const Extension* extension = LoadAndLaunchPlatformApp("launch", "Launched"); | 520 const Extension* extension = LoadAndLaunchPlatformApp("launch", "Launched"); |
| 523 const std::string app_id = extension->id(); | 521 const std::string app_id = extension->id(); |
| 524 | 522 |
| 525 // Then create a shortcut. | 523 // Then create a shortcut. |
| 526 ash::ShelfID shortcut_id = | 524 ash::ShelfID shortcut_id = |
| 527 CreateAppShortcutLauncherItem(ash::AppLauncherId(app_id)); | 525 CreateAppShortcutLauncherItem(ash::AppLaunchId(app_id)); |
| 528 ++item_count; | 526 ++item_count; |
| 529 ASSERT_EQ(item_count, shelf_model()->item_count()); | 527 ASSERT_EQ(item_count, shelf_model()->item_count()); |
| 530 ash::ShelfItem item = *shelf_model()->ItemByID(shortcut_id); | 528 ash::ShelfItem item = *shelf_model()->ItemByID(shortcut_id); |
| 531 EXPECT_EQ(ash::TYPE_PINNED_APP, item.type); | 529 EXPECT_EQ(ash::TYPE_PINNED_APP, item.type); |
| 532 EXPECT_EQ(ash::STATUS_CLOSED, item.status); | 530 EXPECT_EQ(ash::STATUS_CLOSED, item.status); |
| 533 | 531 |
| 534 // Create a second shortcut. This will be needed to force the first one to | 532 // Create a second shortcut. This will be needed to force the first one to |
| 535 // move once it gets unpinned. | 533 // move once it gets unpinned. |
| 536 ash::ShelfID foo_id = | 534 ash::ShelfID foo_id = CreateAppShortcutLauncherItem(ash::AppLaunchId("foo")); |
| 537 CreateAppShortcutLauncherItem(ash::AppLauncherId("foo")); | |
| 538 ++item_count; | 535 ++item_count; |
| 539 ASSERT_EQ(item_count, shelf_model()->item_count()); | 536 ASSERT_EQ(item_count, shelf_model()->item_count()); |
| 540 EXPECT_LT(shelf_model()->ItemIndexByID(shortcut_id), | 537 EXPECT_LT(shelf_model()->ItemIndexByID(shortcut_id), |
| 541 shelf_model()->ItemIndexByID(foo_id)); | 538 shelf_model()->ItemIndexByID(foo_id)); |
| 542 | 539 |
| 543 // Open a window. Confirm the item is now running. | 540 // Open a window. Confirm the item is now running. |
| 544 AppWindow* window = CreateAppWindow(browser()->profile(), extension); | 541 AppWindow* window = CreateAppWindow(browser()->profile(), extension); |
| 545 ash::wm::ActivateWindow(window->GetNativeWindow()); | 542 ash::wm::ActivateWindow(window->GetNativeWindow()); |
| 546 ASSERT_EQ(item_count, shelf_model()->item_count()); | 543 ASSERT_EQ(item_count, shelf_model()->item_count()); |
| 547 item = *shelf_model()->ItemByID(shortcut_id); | 544 item = *shelf_model()->ItemByID(shortcut_id); |
| (...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 948 } | 945 } |
| 949 | 946 |
| 950 // Launches an app in the background and then tries to open it. This is test for | 947 // Launches an app in the background and then tries to open it. This is test for |
| 951 // a crash we had. | 948 // a crash we had. |
| 952 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, LaunchInBackground) { | 949 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, LaunchInBackground) { |
| 953 TabStripModel* tab_strip = browser()->tab_strip_model(); | 950 TabStripModel* tab_strip = browser()->tab_strip_model(); |
| 954 int tab_count = tab_strip->count(); | 951 int tab_count = tab_strip->count(); |
| 955 LoadAndLaunchExtension("app1", extensions::LAUNCH_CONTAINER_TAB, | 952 LoadAndLaunchExtension("app1", extensions::LAUNCH_CONTAINER_TAB, |
| 956 WindowOpenDisposition::NEW_BACKGROUND_TAB); | 953 WindowOpenDisposition::NEW_BACKGROUND_TAB); |
| 957 EXPECT_EQ(++tab_count, tab_strip->count()); | 954 EXPECT_EQ(++tab_count, tab_strip->count()); |
| 958 controller_->LaunchApp(ash::AppLauncherId(last_loaded_extension_id()), | 955 controller_->LaunchApp(ash::AppLaunchId(last_loaded_extension_id()), |
| 959 ash::LAUNCH_FROM_UNKNOWN, 0); | 956 ash::LAUNCH_FROM_UNKNOWN, 0); |
| 960 } | 957 } |
| 961 | 958 |
| 962 // Confirm that clicking a icon for an app running in one of 2 maxmized windows | 959 // Confirm that clicking a icon for an app running in one of 2 maxmized windows |
| 963 // activates the right window. | 960 // activates the right window. |
| 964 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, LaunchMaximized) { | 961 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, LaunchMaximized) { |
| 965 aura::Window* window1 = browser()->window()->GetNativeWindow(); | 962 aura::Window* window1 = browser()->window()->GetNativeWindow(); |
| 966 ash::wm::WindowState* window1_state = ash::wm::GetWindowState(window1); | 963 ash::wm::WindowState* window1_state = ash::wm::GetWindowState(window1); |
| 967 window1_state->Maximize(); | 964 window1_state->Maximize(); |
| 968 content::WindowedNotificationObserver open_observer( | 965 content::WindowedNotificationObserver open_observer( |
| (...skipping 30 matching lines...) Expand all Loading... |
| 999 controller_->ActivateApp(extension->id(), ash::LAUNCH_FROM_UNKNOWN, 0); | 996 controller_->ActivateApp(extension->id(), ash::LAUNCH_FROM_UNKNOWN, 0); |
| 1000 EXPECT_EQ(++tab_count, tab_strip->count()); | 997 EXPECT_EQ(++tab_count, tab_strip->count()); |
| 1001 controller_->ActivateApp(extension->id(), ash::LAUNCH_FROM_UNKNOWN, 0); | 998 controller_->ActivateApp(extension->id(), ash::LAUNCH_FROM_UNKNOWN, 0); |
| 1002 EXPECT_EQ(tab_count, tab_strip->count()); | 999 EXPECT_EQ(tab_count, tab_strip->count()); |
| 1003 } | 1000 } |
| 1004 | 1001 |
| 1005 // Launching the same app multiple times should launch a copy for each call. | 1002 // Launching the same app multiple times should launch a copy for each call. |
| 1006 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, LaunchApp) { | 1003 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, LaunchApp) { |
| 1007 TabStripModel* tab_strip = browser()->tab_strip_model(); | 1004 TabStripModel* tab_strip = browser()->tab_strip_model(); |
| 1008 int tab_count = tab_strip->count(); | 1005 int tab_count = tab_strip->count(); |
| 1009 ash::AppLauncherId id( | 1006 ash::AppLaunchId id(LoadExtension(test_data_dir_.AppendASCII("app1"))->id()); |
| 1010 LoadExtension(test_data_dir_.AppendASCII("app1"))->id()); | |
| 1011 controller_->LaunchApp(id, ash::LAUNCH_FROM_UNKNOWN, 0); | 1007 controller_->LaunchApp(id, ash::LAUNCH_FROM_UNKNOWN, 0); |
| 1012 EXPECT_EQ(++tab_count, tab_strip->count()); | 1008 EXPECT_EQ(++tab_count, tab_strip->count()); |
| 1013 controller_->LaunchApp(id, ash::LAUNCH_FROM_UNKNOWN, 0); | 1009 controller_->LaunchApp(id, ash::LAUNCH_FROM_UNKNOWN, 0); |
| 1014 EXPECT_EQ(++tab_count, tab_strip->count()); | 1010 EXPECT_EQ(++tab_count, tab_strip->count()); |
| 1015 } | 1011 } |
| 1016 | 1012 |
| 1017 // Launch 2 apps and toggle which is active. | 1013 // Launch 2 apps and toggle which is active. |
| 1018 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, MultipleApps) { | 1014 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, MultipleApps) { |
| 1019 int item_count = model_->item_count(); | 1015 int item_count = model_->item_count(); |
| 1020 TabStripModel* tab_strip = browser()->tab_strip_model(); | 1016 TabStripModel* tab_strip = browser()->tab_strip_model(); |
| (...skipping 1394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2415 | 2411 |
| 2416 // Close all windows via the menu item. | 2412 // Close all windows via the menu item. |
| 2417 CloseBrowserWindow(browser(), menu1.get(), LauncherContextMenu::MENU_CLOSE); | 2413 CloseBrowserWindow(browser(), menu1.get(), LauncherContextMenu::MENU_CLOSE); |
| 2418 EXPECT_EQ(0u, BrowserList::GetInstance()->size()); | 2414 EXPECT_EQ(0u, BrowserList::GetInstance()->size()); |
| 2419 | 2415 |
| 2420 // Check if "Close" is removed from the context menu. | 2416 // Check if "Close" is removed from the context menu. |
| 2421 std::unique_ptr<LauncherContextMenu> menu2 = CreateBrowserItemContextMenu(); | 2417 std::unique_ptr<LauncherContextMenu> menu2 = CreateBrowserItemContextMenu(); |
| 2422 ASSERT_FALSE( | 2418 ASSERT_FALSE( |
| 2423 IsItemPresentInMenu(menu2.get(), LauncherContextMenu::MENU_CLOSE)); | 2419 IsItemPresentInMenu(menu2.get(), LauncherContextMenu::MENU_CLOSE)); |
| 2424 } | 2420 } |
| OLD | NEW |