| 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.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/public/cpp/app_launch_id.h" | |
| 10 #include "ash/public/cpp/shelf_item_delegate.h" | 9 #include "ash/public/cpp/shelf_item_delegate.h" |
| 11 #include "ash/public/cpp/window_properties.h" | 10 #include "ash/public/cpp/window_properties.h" |
| 12 #include "ash/shelf/app_list_button.h" | 11 #include "ash/shelf/app_list_button.h" |
| 13 #include "ash/shelf/shelf_button.h" | 12 #include "ash/shelf/shelf_button.h" |
| 14 #include "ash/shelf/shelf_constants.h" | 13 #include "ash/shelf/shelf_constants.h" |
| 15 #include "ash/shelf/shelf_model.h" | 14 #include "ash/shelf/shelf_model.h" |
| 16 #include "ash/shelf/shelf_view.h" | 15 #include "ash/shelf/shelf_view.h" |
| 17 #include "ash/shelf/shelf_widget.h" | 16 #include "ash/shelf/shelf_widget.h" |
| 18 #include "ash/shelf/wm_shelf.h" | 17 #include "ash/shelf/wm_shelf.h" |
| 19 #include "ash/shell.h" | 18 #include "ash/shell.h" |
| 20 #include "ash/shell_port.h" | 19 #include "ash/shell_port.h" |
| 21 #include "ash/test/shelf_view_test_api.h" | 20 #include "ash/test/shelf_view_test_api.h" |
| 22 #include "ash/wm/window_properties.h" | |
| 23 #include "ash/wm/window_state.h" | 21 #include "ash/wm/window_state.h" |
| 24 #include "ash/wm/window_state_aura.h" | 22 #include "ash/wm/window_state_aura.h" |
| 25 #include "ash/wm/window_util.h" | 23 #include "ash/wm/window_util.h" |
| 26 #include "ash/wm_window.h" | 24 #include "ash/wm_window.h" |
| 27 #include "base/macros.h" | 25 #include "base/macros.h" |
| 28 #include "base/run_loop.h" | 26 #include "base/run_loop.h" |
| 29 #include "base/strings/stringprintf.h" | 27 #include "base/strings/stringprintf.h" |
| 30 #include "base/strings/utf_string_conversions.h" | 28 #include "base/strings/utf_string_conversions.h" |
| 31 #include "build/build_config.h" | 29 #include "build/build_config.h" |
| 32 #include "chrome/browser/apps/app_browsertest_util.h" | 30 #include "chrome/browser/apps/app_browsertest_util.h" |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 // Ensure ash starts the session and creates the shelf and controller. | 222 // Ensure ash starts the session and creates the shelf and controller. |
| 225 SessionControllerClient::FlushForTesting(); | 223 SessionControllerClient::FlushForTesting(); |
| 226 | 224 |
| 227 controller_ = ChromeLauncherController::instance(); | 225 controller_ = ChromeLauncherController::instance(); |
| 228 ASSERT_TRUE(controller_); | 226 ASSERT_TRUE(controller_); |
| 229 extensions::PlatformAppBrowserTest::SetUpOnMainThread(); | 227 extensions::PlatformAppBrowserTest::SetUpOnMainThread(); |
| 230 } | 228 } |
| 231 | 229 |
| 232 ash::ShelfModel* shelf_model() { return ash::Shell::Get()->shelf_model(); } | 230 ash::ShelfModel* shelf_model() { return ash::Shell::Get()->shelf_model(); } |
| 233 | 231 |
| 234 ash::ShelfID CreateAppShortcutLauncherItem( | 232 ash::ShelfID CreateAppShortcutLauncherItem(const ash::ShelfID& shelf_id) { |
| 235 const ash::AppLaunchId& app_launch_id) { | |
| 236 return controller_->CreateAppShortcutLauncherItem( | 233 return controller_->CreateAppShortcutLauncherItem( |
| 237 app_launch_id, shelf_model()->item_count()); | 234 shelf_id, shelf_model()->item_count()); |
| 238 } | 235 } |
| 239 | 236 |
| 240 const ash::ShelfItem& GetLastLauncherItem() { | 237 const ash::ShelfItem& GetLastLauncherItem() { |
| 241 // Unless there are any panels, the item at index [count - 1] will be | 238 // Unless there are any panels, the item at index [count - 1] will be |
| 242 // the desired item. | 239 // the desired item. |
| 243 return shelf_model()->items()[shelf_model()->item_count() - 1]; | 240 return shelf_model()->items()[shelf_model()->item_count() - 1]; |
| 244 } | 241 } |
| 245 | 242 |
| 246 const ash::ShelfItem& GetLastLauncherPanelItem() { | 243 const ash::ShelfItem& GetLastLauncherPanelItem() { |
| 247 // Panels show up on the right side of the shelf, so the desired item | 244 // Panels show up on the right side of the shelf, so the desired item |
| 248 // will be the last one. | 245 // will be the last one. |
| 249 return shelf_model()->items()[shelf_model()->item_count() - 1]; | 246 return shelf_model()->items()[shelf_model()->item_count() - 1]; |
| 250 } | 247 } |
| 251 | 248 |
| 252 ash::ShelfItemDelegate* GetShelfItemDelegate(ash::ShelfID id) { | 249 ash::ShelfItemDelegate* GetShelfItemDelegate(const ash::ShelfID& id) { |
| 253 return shelf_model()->GetShelfItemDelegate(id); | 250 return shelf_model()->GetShelfItemDelegate(id); |
| 254 } | 251 } |
| 255 | 252 |
| 256 ChromeLauncherController* controller_; | 253 ChromeLauncherController* controller_; |
| 257 | 254 |
| 258 private: | 255 private: |
| 259 DISALLOW_COPY_AND_ASSIGN(LauncherPlatformAppBrowserTest); | 256 DISALLOW_COPY_AND_ASSIGN(LauncherPlatformAppBrowserTest); |
| 260 }; | 257 }; |
| 261 | 258 |
| 262 enum RipOffCommand { | 259 enum RipOffCommand { |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 LoadExtension(test_data_dir_.AppendASCII(name)); | 315 LoadExtension(test_data_dir_.AppendASCII(name)); |
| 319 | 316 |
| 320 // First get app_id. | 317 // First get app_id. |
| 321 const Extension* extension = | 318 const Extension* extension = |
| 322 service->GetExtensionById(last_loaded_extension_id(), false); | 319 service->GetExtensionById(last_loaded_extension_id(), false); |
| 323 const std::string app_id = extension->id(); | 320 const std::string app_id = extension->id(); |
| 324 | 321 |
| 325 // Then create a shortcut. | 322 // Then create a shortcut. |
| 326 int item_count = model_->item_count(); | 323 int item_count = model_->item_count(); |
| 327 ash::ShelfID shortcut_id = controller_->CreateAppShortcutLauncherItem( | 324 ash::ShelfID shortcut_id = controller_->CreateAppShortcutLauncherItem( |
| 328 ash::AppLaunchId(app_id), item_count); | 325 ash::ShelfID(app_id), item_count); |
| 329 controller_->SyncPinPosition(shortcut_id); | 326 controller_->SyncPinPosition(shortcut_id); |
| 330 EXPECT_EQ(++item_count, model_->item_count()); | 327 EXPECT_EQ(++item_count, model_->item_count()); |
| 331 const ash::ShelfItem& item = *model_->ItemByID(shortcut_id); | 328 const ash::ShelfItem& item = *model_->ItemByID(shortcut_id); |
| 332 EXPECT_EQ(ash::TYPE_PINNED_APP, item.type); | 329 EXPECT_EQ(ash::TYPE_PINNED_APP, item.type); |
| 333 return item.id; | 330 return item.id; |
| 334 } | 331 } |
| 335 | 332 |
| 336 ash::ShelfID PinFakeApp(const std::string& app_id) { | 333 ash::ShelfID PinFakeApp(const std::string& app_id) { |
| 337 return controller_->CreateAppShortcutLauncherItem(ash::AppLaunchId(app_id), | 334 return controller_->CreateAppShortcutLauncherItem(ash::ShelfID(app_id), |
| 338 model_->item_count()); | 335 model_->item_count()); |
| 339 } | 336 } |
| 340 | 337 |
| 341 // Get the index of an item which has the given type. | 338 // Get the index of an item which has the given type. |
| 342 int GetIndexOfShelfItemType(ash::ShelfItemType type) { | 339 int GetIndexOfShelfItemType(ash::ShelfItemType type) { |
| 343 return model_->GetItemIndexForType(type); | 340 return model_->GetItemIndexForType(type); |
| 344 } | 341 } |
| 345 | 342 |
| 346 // Try to rip off |item_index|. | 343 // Try to rip off |item_index|. |
| 347 void RipOffItemIndex(int index, | 344 void RipOffItemIndex(int index, |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 // Test that we can launch a platform app that already has a shortcut. | 432 // Test that we can launch a platform app that already has a shortcut. |
| 436 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, LaunchPinned) { | 433 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, LaunchPinned) { |
| 437 int item_count = shelf_model()->item_count(); | 434 int item_count = shelf_model()->item_count(); |
| 438 | 435 |
| 439 // First get app_id. | 436 // First get app_id. |
| 440 const Extension* extension = LoadAndLaunchPlatformApp("launch", "Launched"); | 437 const Extension* extension = LoadAndLaunchPlatformApp("launch", "Launched"); |
| 441 const std::string app_id = extension->id(); | 438 const std::string app_id = extension->id(); |
| 442 | 439 |
| 443 // Then create a shortcut. | 440 // Then create a shortcut. |
| 444 ash::ShelfID shortcut_id = | 441 ash::ShelfID shortcut_id = |
| 445 CreateAppShortcutLauncherItem(ash::AppLaunchId(app_id)); | 442 CreateAppShortcutLauncherItem(ash::ShelfID(app_id)); |
| 446 ++item_count; | 443 ++item_count; |
| 447 ASSERT_EQ(item_count, shelf_model()->item_count()); | 444 ASSERT_EQ(item_count, shelf_model()->item_count()); |
| 448 ash::ShelfItem item = *shelf_model()->ItemByID(shortcut_id); | 445 ash::ShelfItem item = *shelf_model()->ItemByID(shortcut_id); |
| 449 EXPECT_EQ(ash::TYPE_PINNED_APP, item.type); | 446 EXPECT_EQ(ash::TYPE_PINNED_APP, item.type); |
| 450 EXPECT_EQ(ash::STATUS_CLOSED, item.status); | 447 EXPECT_EQ(ash::STATUS_CLOSED, item.status); |
| 451 | 448 |
| 452 // Open a window. Confirm the item is now running. | 449 // Open a window. Confirm the item is now running. |
| 453 AppWindow* window = CreateAppWindow(browser()->profile(), extension); | 450 AppWindow* window = CreateAppWindow(browser()->profile(), extension); |
| 454 ash::wm::ActivateWindow(window->GetNativeWindow()); | 451 ash::wm::ActivateWindow(window->GetNativeWindow()); |
| 455 ASSERT_EQ(item_count, shelf_model()->item_count()); | 452 ASSERT_EQ(item_count, shelf_model()->item_count()); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 471 const Extension* extension = LoadAndLaunchPlatformApp("launch", "Launched"); | 468 const Extension* extension = LoadAndLaunchPlatformApp("launch", "Launched"); |
| 472 AppWindow* window = CreateAppWindow(browser()->profile(), extension); | 469 AppWindow* window = CreateAppWindow(browser()->profile(), extension); |
| 473 ++item_count; | 470 ++item_count; |
| 474 ASSERT_EQ(item_count, shelf_model()->item_count()); | 471 ASSERT_EQ(item_count, shelf_model()->item_count()); |
| 475 const ash::ShelfItem& item1 = GetLastLauncherItem(); | 472 const ash::ShelfItem& item1 = GetLastLauncherItem(); |
| 476 ash::ShelfID id = item1.id; | 473 ash::ShelfID id = item1.id; |
| 477 EXPECT_EQ(ash::TYPE_APP, item1.type); | 474 EXPECT_EQ(ash::TYPE_APP, item1.type); |
| 478 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status); | 475 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status); |
| 479 | 476 |
| 480 // Create a shortcut. The app item should be after it. | 477 // Create a shortcut. The app item should be after it. |
| 481 ash::ShelfID foo_id = CreateAppShortcutLauncherItem(ash::AppLaunchId("foo")); | 478 ash::ShelfID foo_id = CreateAppShortcutLauncherItem(ash::ShelfID("foo")); |
| 482 ++item_count; | 479 ++item_count; |
| 483 ASSERT_EQ(item_count, shelf_model()->item_count()); | 480 ASSERT_EQ(item_count, shelf_model()->item_count()); |
| 484 EXPECT_LT(shelf_model()->ItemIndexByID(foo_id), | 481 EXPECT_LT(shelf_model()->ItemIndexByID(foo_id), |
| 485 shelf_model()->ItemIndexByID(id)); | 482 shelf_model()->ItemIndexByID(id)); |
| 486 | 483 |
| 487 // Pin the app. The item should remain. | 484 // Pin the app. The item should remain. |
| 488 controller_->PinAppWithID(extension->id()); | 485 controller_->PinAppWithID(extension->id()); |
| 489 ASSERT_EQ(item_count, shelf_model()->item_count()); | 486 ASSERT_EQ(item_count, shelf_model()->item_count()); |
| 490 const ash::ShelfItem& item2 = *shelf_model()->ItemByID(id); | 487 const ash::ShelfItem& item2 = *shelf_model()->ItemByID(id); |
| 491 EXPECT_EQ(ash::TYPE_PINNED_APP, item2.type); | 488 EXPECT_EQ(ash::TYPE_PINNED_APP, item2.type); |
| 492 EXPECT_EQ(ash::STATUS_ACTIVE, item2.status); | 489 EXPECT_EQ(ash::STATUS_ACTIVE, item2.status); |
| 493 | 490 |
| 494 // New shortcuts should come after the item. | 491 // New shortcuts should come after the item. |
| 495 ash::ShelfID bar_id = CreateAppShortcutLauncherItem(ash::AppLaunchId("bar")); | 492 ash::ShelfID bar_id = CreateAppShortcutLauncherItem(ash::ShelfID("bar")); |
| 496 ++item_count; | 493 ++item_count; |
| 497 ASSERT_EQ(item_count, shelf_model()->item_count()); | 494 ASSERT_EQ(item_count, shelf_model()->item_count()); |
| 498 EXPECT_LT(shelf_model()->ItemIndexByID(id), | 495 EXPECT_LT(shelf_model()->ItemIndexByID(id), |
| 499 shelf_model()->ItemIndexByID(bar_id)); | 496 shelf_model()->ItemIndexByID(bar_id)); |
| 500 | 497 |
| 501 // Then close it, make sure the item remains. | 498 // Then close it, make sure the item remains. |
| 502 CloseAppWindow(window); | 499 CloseAppWindow(window); |
| 503 ASSERT_EQ(item_count, shelf_model()->item_count()); | 500 ASSERT_EQ(item_count, shelf_model()->item_count()); |
| 504 } | 501 } |
| 505 | 502 |
| 506 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, UnpinRunning) { | 503 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, UnpinRunning) { |
| 507 int item_count = shelf_model()->item_count(); | 504 int item_count = shelf_model()->item_count(); |
| 508 | 505 |
| 509 // First get app_id. | 506 // First get app_id. |
| 510 const Extension* extension = LoadAndLaunchPlatformApp("launch", "Launched"); | 507 const Extension* extension = LoadAndLaunchPlatformApp("launch", "Launched"); |
| 511 const std::string app_id = extension->id(); | 508 const std::string app_id = extension->id(); |
| 512 | 509 |
| 513 // Then create a shortcut. | 510 // Then create a shortcut. |
| 514 ash::ShelfID shortcut_id = | 511 ash::ShelfID shortcut_id = |
| 515 CreateAppShortcutLauncherItem(ash::AppLaunchId(app_id)); | 512 CreateAppShortcutLauncherItem(ash::ShelfID(app_id)); |
| 516 ++item_count; | 513 ++item_count; |
| 517 ASSERT_EQ(item_count, shelf_model()->item_count()); | 514 ASSERT_EQ(item_count, shelf_model()->item_count()); |
| 518 ash::ShelfItem item = *shelf_model()->ItemByID(shortcut_id); | 515 ash::ShelfItem item = *shelf_model()->ItemByID(shortcut_id); |
| 519 EXPECT_EQ(ash::TYPE_PINNED_APP, item.type); | 516 EXPECT_EQ(ash::TYPE_PINNED_APP, item.type); |
| 520 EXPECT_EQ(ash::STATUS_CLOSED, item.status); | 517 EXPECT_EQ(ash::STATUS_CLOSED, item.status); |
| 521 | 518 |
| 522 // Create a second shortcut. This will be needed to force the first one to | 519 // Create a second shortcut. This will be needed to force the first one to |
| 523 // move once it gets unpinned. | 520 // move once it gets unpinned. |
| 524 ash::ShelfID foo_id = CreateAppShortcutLauncherItem(ash::AppLaunchId("foo")); | 521 ash::ShelfID foo_id = CreateAppShortcutLauncherItem(ash::ShelfID("foo")); |
| 525 ++item_count; | 522 ++item_count; |
| 526 ASSERT_EQ(item_count, shelf_model()->item_count()); | 523 ASSERT_EQ(item_count, shelf_model()->item_count()); |
| 527 EXPECT_LT(shelf_model()->ItemIndexByID(shortcut_id), | 524 EXPECT_LT(shelf_model()->ItemIndexByID(shortcut_id), |
| 528 shelf_model()->ItemIndexByID(foo_id)); | 525 shelf_model()->ItemIndexByID(foo_id)); |
| 529 | 526 |
| 530 // Open a window. Confirm the item is now running. | 527 // Open a window. Confirm the item is now running. |
| 531 AppWindow* window = CreateAppWindow(browser()->profile(), extension); | 528 AppWindow* window = CreateAppWindow(browser()->profile(), extension); |
| 532 ash::wm::ActivateWindow(window->GetNativeWindow()); | 529 ash::wm::ActivateWindow(window->GetNativeWindow()); |
| 533 ASSERT_EQ(item_count, shelf_model()->item_count()); | 530 ASSERT_EQ(item_count, shelf_model()->item_count()); |
| 534 item = *shelf_model()->ItemByID(shortcut_id); | 531 item = *shelf_model()->ItemByID(shortcut_id); |
| (...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 942 } | 939 } |
| 943 | 940 |
| 944 // Launches an app in the background and then tries to open it. This is test for | 941 // Launches an app in the background and then tries to open it. This is test for |
| 945 // a crash we had. | 942 // a crash we had. |
| 946 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, LaunchInBackground) { | 943 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, LaunchInBackground) { |
| 947 TabStripModel* tab_strip = browser()->tab_strip_model(); | 944 TabStripModel* tab_strip = browser()->tab_strip_model(); |
| 948 int tab_count = tab_strip->count(); | 945 int tab_count = tab_strip->count(); |
| 949 LoadAndLaunchExtension("app1", extensions::LAUNCH_CONTAINER_TAB, | 946 LoadAndLaunchExtension("app1", extensions::LAUNCH_CONTAINER_TAB, |
| 950 WindowOpenDisposition::NEW_BACKGROUND_TAB); | 947 WindowOpenDisposition::NEW_BACKGROUND_TAB); |
| 951 EXPECT_EQ(++tab_count, tab_strip->count()); | 948 EXPECT_EQ(++tab_count, tab_strip->count()); |
| 952 controller_->LaunchApp(ash::AppLaunchId(last_loaded_extension_id()), | 949 controller_->LaunchApp(ash::ShelfID(last_loaded_extension_id()), |
| 953 ash::LAUNCH_FROM_UNKNOWN, 0); | 950 ash::LAUNCH_FROM_UNKNOWN, 0); |
| 954 } | 951 } |
| 955 | 952 |
| 956 // Confirm that clicking a icon for an app running in one of 2 maxmized windows | 953 // Confirm that clicking a icon for an app running in one of 2 maxmized windows |
| 957 // activates the right window. | 954 // activates the right window. |
| 958 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, LaunchMaximized) { | 955 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, LaunchMaximized) { |
| 959 aura::Window* window1 = browser()->window()->GetNativeWindow(); | 956 aura::Window* window1 = browser()->window()->GetNativeWindow(); |
| 960 ash::wm::WindowState* window1_state = ash::wm::GetWindowState(window1); | 957 ash::wm::WindowState* window1_state = ash::wm::GetWindowState(window1); |
| 961 window1_state->Maximize(); | 958 window1_state->Maximize(); |
| 962 content::WindowedNotificationObserver open_observer( | 959 content::WindowedNotificationObserver open_observer( |
| (...skipping 30 matching lines...) Expand all Loading... |
| 993 controller_->ActivateApp(extension->id(), ash::LAUNCH_FROM_UNKNOWN, 0); | 990 controller_->ActivateApp(extension->id(), ash::LAUNCH_FROM_UNKNOWN, 0); |
| 994 EXPECT_EQ(++tab_count, tab_strip->count()); | 991 EXPECT_EQ(++tab_count, tab_strip->count()); |
| 995 controller_->ActivateApp(extension->id(), ash::LAUNCH_FROM_UNKNOWN, 0); | 992 controller_->ActivateApp(extension->id(), ash::LAUNCH_FROM_UNKNOWN, 0); |
| 996 EXPECT_EQ(tab_count, tab_strip->count()); | 993 EXPECT_EQ(tab_count, tab_strip->count()); |
| 997 } | 994 } |
| 998 | 995 |
| 999 // Launching the same app multiple times should launch a copy for each call. | 996 // Launching the same app multiple times should launch a copy for each call. |
| 1000 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, LaunchApp) { | 997 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, LaunchApp) { |
| 1001 TabStripModel* tab_strip = browser()->tab_strip_model(); | 998 TabStripModel* tab_strip = browser()->tab_strip_model(); |
| 1002 int tab_count = tab_strip->count(); | 999 int tab_count = tab_strip->count(); |
| 1003 ash::AppLaunchId id(LoadExtension(test_data_dir_.AppendASCII("app1"))->id()); | 1000 ash::ShelfID id(LoadExtension(test_data_dir_.AppendASCII("app1"))->id()); |
| 1004 controller_->LaunchApp(id, ash::LAUNCH_FROM_UNKNOWN, 0); | 1001 controller_->LaunchApp(id, ash::LAUNCH_FROM_UNKNOWN, 0); |
| 1005 EXPECT_EQ(++tab_count, tab_strip->count()); | 1002 EXPECT_EQ(++tab_count, tab_strip->count()); |
| 1006 controller_->LaunchApp(id, ash::LAUNCH_FROM_UNKNOWN, 0); | 1003 controller_->LaunchApp(id, ash::LAUNCH_FROM_UNKNOWN, 0); |
| 1007 EXPECT_EQ(++tab_count, tab_strip->count()); | 1004 EXPECT_EQ(++tab_count, tab_strip->count()); |
| 1008 } | 1005 } |
| 1009 | 1006 |
| 1010 // Launch 2 apps and toggle which is active. | 1007 // Launch 2 apps and toggle which is active. |
| 1011 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, MultipleApps) { | 1008 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, MultipleApps) { |
| 1012 int item_count = model_->item_count(); | 1009 int item_count = model_->item_count(); |
| 1013 TabStripModel* tab_strip = browser()->tab_strip_model(); | 1010 TabStripModel* tab_strip = browser()->tab_strip_model(); |
| (...skipping 1109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2123 base::RunLoop().RunUntilIdle(); | 2120 base::RunLoop().RunUntilIdle(); |
| 2124 EXPECT_EQ(tab_count + 1, tab_strip->count()); | 2121 EXPECT_EQ(tab_count + 1, tab_strip->count()); |
| 2125 } | 2122 } |
| 2126 | 2123 |
| 2127 // Check ash::ShelfItemDelegate of Browser Shortcut functionality. | 2124 // Check ash::ShelfItemDelegate of Browser Shortcut functionality. |
| 2128 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTestNoDefaultBrowser, | 2125 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTestNoDefaultBrowser, |
| 2129 BrowserShortcutLauncherItemController) { | 2126 BrowserShortcutLauncherItemController) { |
| 2130 ash::ShelfItemDelegate* item_controller = | 2127 ash::ShelfItemDelegate* item_controller = |
| 2131 controller_->GetBrowserShortcutLauncherItemController(); | 2128 controller_->GetBrowserShortcutLauncherItemController(); |
| 2132 const ash::ShelfID id = item_controller->shelf_id(); | 2129 const ash::ShelfID id = item_controller->shelf_id(); |
| 2133 EXPECT_NE(ash::kInvalidShelfID, id); | 2130 EXPECT_FALSE(id.IsNull()); |
| 2134 | 2131 |
| 2135 // Get the number of browsers. | 2132 // Get the number of browsers. |
| 2136 size_t running_browser = chrome::GetTotalBrowserCount(); | 2133 size_t running_browser = chrome::GetTotalBrowserCount(); |
| 2137 EXPECT_EQ(0u, running_browser); | 2134 EXPECT_EQ(0u, running_browser); |
| 2138 EXPECT_FALSE(controller_->IsOpen(id)); | 2135 EXPECT_FALSE(controller_->IsOpen(id)); |
| 2139 | 2136 |
| 2140 // Activate. This creates new browser | 2137 // Activate. This creates new browser |
| 2141 SelectItem(item_controller, ui::ET_UNKNOWN); | 2138 SelectItem(item_controller, ui::ET_UNKNOWN); |
| 2142 // New Window is created. | 2139 // New Window is created. |
| 2143 running_browser = chrome::GetTotalBrowserCount(); | 2140 running_browser = chrome::GetTotalBrowserCount(); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 2162 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); | 2159 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); |
| 2163 EXPECT_EQ(1, browser()->tab_strip_model()->count()); | 2160 EXPECT_EQ(1, browser()->tab_strip_model()->count()); |
| 2164 EXPECT_EQ(0, browser()->tab_strip_model()->active_index()); | 2161 EXPECT_EQ(0, browser()->tab_strip_model()->active_index()); |
| 2165 EXPECT_EQ(2, model_->item_count()); | 2162 EXPECT_EQ(2, model_->item_count()); |
| 2166 | 2163 |
| 2167 ash::WmWindow* window = | 2164 ash::WmWindow* window = |
| 2168 ash::WmWindow::Get(browser()->window()->GetNativeWindow()); | 2165 ash::WmWindow::Get(browser()->window()->GetNativeWindow()); |
| 2169 | 2166 |
| 2170 int browser_index = GetIndexOfShelfItemType(ash::TYPE_BROWSER_SHORTCUT); | 2167 int browser_index = GetIndexOfShelfItemType(ash::TYPE_BROWSER_SHORTCUT); |
| 2171 ash::ShelfID browser_id = model_->items()[browser_index].id; | 2168 ash::ShelfID browser_id = model_->items()[browser_index].id; |
| 2172 ash::ShelfID id = window->aura_window()->GetProperty(ash::kShelfIDKey); | 2169 ash::ShelfID* id = window->aura_window()->GetProperty(ash::kShelfIDKey); |
| 2173 EXPECT_EQ(browser_id, id); | 2170 ASSERT_NE(nullptr, id); |
| 2171 EXPECT_EQ(browser_id, *id); |
| 2174 | 2172 |
| 2175 ash::ShelfID app_id = CreateShortcut("app1"); | 2173 ash::ShelfID app_id = CreateShortcut("app1"); |
| 2176 EXPECT_EQ(3, model_->item_count()); | 2174 EXPECT_EQ(3, model_->item_count()); |
| 2177 | 2175 |
| 2178 // Create and activate a new tab for "app1" and expect an application ShelfID. | 2176 // Create and activate a new tab for "app1" and expect an application ShelfID. |
| 2179 WmShelf::ActivateShelfItem(model_->ItemIndexByID(app_id)); | 2177 WmShelf::ActivateShelfItem(model_->ItemIndexByID(app_id)); |
| 2180 EXPECT_EQ(2, browser()->tab_strip_model()->count()); | 2178 EXPECT_EQ(2, browser()->tab_strip_model()->count()); |
| 2181 EXPECT_EQ(1, browser()->tab_strip_model()->active_index()); | 2179 EXPECT_EQ(1, browser()->tab_strip_model()->active_index()); |
| 2182 id = window->aura_window()->GetProperty(ash::kShelfIDKey); | 2180 id = window->aura_window()->GetProperty(ash::kShelfIDKey); |
| 2183 EXPECT_EQ(app_id, id); | 2181 ASSERT_NE(nullptr, id); |
| 2182 EXPECT_EQ(app_id, *id); |
| 2184 | 2183 |
| 2185 // Activate the tab at index 0 (NTP) and expect a browser ShelfID. | 2184 // Activate the tab at index 0 (NTP) and expect a browser ShelfID. |
| 2186 browser()->tab_strip_model()->ActivateTabAt(0, false); | 2185 browser()->tab_strip_model()->ActivateTabAt(0, false); |
| 2187 EXPECT_EQ(0, browser()->tab_strip_model()->active_index()); | 2186 EXPECT_EQ(0, browser()->tab_strip_model()->active_index()); |
| 2188 id = window->aura_window()->GetProperty(ash::kShelfIDKey); | 2187 id = window->aura_window()->GetProperty(ash::kShelfIDKey); |
| 2189 EXPECT_EQ(browser_id, id); | 2188 ASSERT_NE(nullptr, id); |
| 2189 EXPECT_EQ(browser_id, *id); |
| 2190 } | 2190 } |
| 2191 | 2191 |
| 2192 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, OverflowBubble) { | 2192 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, OverflowBubble) { |
| 2193 // Make sure to have a browser window | 2193 // Make sure to have a browser window |
| 2194 chrome::NewTab(browser()); | 2194 chrome::NewTab(browser()); |
| 2195 | 2195 |
| 2196 // No overflow yet. | 2196 // No overflow yet. |
| 2197 EXPECT_FALSE(shelf_->shelf_widget()->IsShowingOverflowBubble()); | 2197 EXPECT_FALSE(shelf_->shelf_widget()->IsShowingOverflowBubble()); |
| 2198 | 2198 |
| 2199 ash::test::ShelfViewTestAPI test(shelf_->GetShelfViewForTesting()); | 2199 ash::test::ShelfViewTestAPI test(shelf_->GetShelfViewForTesting()); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 2217 test.RunMessageLoopUntilAnimationsDone(); | 2217 test.RunMessageLoopUntilAnimationsDone(); |
| 2218 EXPECT_FALSE(shelf_->shelf_widget()->IsShowingOverflowBubble()); | 2218 EXPECT_FALSE(shelf_->shelf_widget()->IsShowingOverflowBubble()); |
| 2219 } | 2219 } |
| 2220 | 2220 |
| 2221 // Check that a windowed V1 application can navigate away from its domain, but | 2221 // Check that a windowed V1 application can navigate away from its domain, but |
| 2222 // still gets detected properly. | 2222 // still gets detected properly. |
| 2223 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, V1AppNavigation) { | 2223 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, V1AppNavigation) { |
| 2224 // We assume that the web store is always there (which it apparently is). | 2224 // We assume that the web store is always there (which it apparently is). |
| 2225 controller_->PinAppWithID(extensions::kWebStoreAppId); | 2225 controller_->PinAppWithID(extensions::kWebStoreAppId); |
| 2226 ash::ShelfID id = controller_->GetShelfIDForAppID(extensions::kWebStoreAppId); | 2226 ash::ShelfID id = controller_->GetShelfIDForAppID(extensions::kWebStoreAppId); |
| 2227 DCHECK_NE(id, ash::kInvalidShelfID); | 2227 EXPECT_FALSE(id.IsNull()); |
| 2228 EXPECT_EQ(ash::STATUS_CLOSED, model_->ItemByID(id)->status); | 2228 EXPECT_EQ(ash::STATUS_CLOSED, model_->ItemByID(id)->status); |
| 2229 | 2229 |
| 2230 // Create a windowed application. | 2230 // Create a windowed application. |
| 2231 AppLaunchParams params = CreateAppLaunchParamsUserContainer( | 2231 AppLaunchParams params = CreateAppLaunchParamsUserContainer( |
| 2232 profile(), GetExtensionForAppID(extensions::kWebStoreAppId, profile()), | 2232 profile(), GetExtensionForAppID(extensions::kWebStoreAppId, profile()), |
| 2233 WindowOpenDisposition::NEW_FOREGROUND_TAB, extensions::SOURCE_TEST); | 2233 WindowOpenDisposition::NEW_FOREGROUND_TAB, extensions::SOURCE_TEST); |
| 2234 params.container = extensions::LAUNCH_CONTAINER_WINDOW; | 2234 params.container = extensions::LAUNCH_CONTAINER_WINDOW; |
| 2235 OpenApplication(params); | 2235 OpenApplication(params); |
| 2236 EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(id)->status); | 2236 EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(id)->status); |
| 2237 | 2237 |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2397 | 2397 |
| 2398 // Close all windows via the menu item. | 2398 // Close all windows via the menu item. |
| 2399 CloseBrowserWindow(browser(), menu1.get(), LauncherContextMenu::MENU_CLOSE); | 2399 CloseBrowserWindow(browser(), menu1.get(), LauncherContextMenu::MENU_CLOSE); |
| 2400 EXPECT_EQ(0u, BrowserList::GetInstance()->size()); | 2400 EXPECT_EQ(0u, BrowserList::GetInstance()->size()); |
| 2401 | 2401 |
| 2402 // Check if "Close" is removed from the context menu. | 2402 // Check if "Close" is removed from the context menu. |
| 2403 std::unique_ptr<LauncherContextMenu> menu2 = CreateBrowserItemContextMenu(); | 2403 std::unique_ptr<LauncherContextMenu> menu2 = CreateBrowserItemContextMenu(); |
| 2404 ASSERT_FALSE( | 2404 ASSERT_FALSE( |
| 2405 IsItemPresentInMenu(menu2.get(), LauncherContextMenu::MENU_CLOSE)); | 2405 IsItemPresentInMenu(menu2.get(), LauncherContextMenu::MENU_CLOSE)); |
| 2406 } | 2406 } |
| OLD | NEW |