| 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 "apps/app_window.h" | 7 #include "apps/app_window.h" |
| 8 #include "apps/app_window_registry.h" | 8 #include "apps/app_window_registry.h" |
| 9 #include "apps/ui/native_app_window.h" | 9 #include "apps/ui/native_app_window.h" |
| 10 #include "ash/ash_switches.h" | 10 #include "ash/ash_switches.h" |
| (...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 624 // First app should be active again. | 624 // First app should be active again. |
| 625 EXPECT_EQ(ash::STATUS_ACTIVE, shelf_model()->ItemByID(item_id1)->status); | 625 EXPECT_EQ(ash::STATUS_ACTIVE, shelf_model()->ItemByID(item_id1)->status); |
| 626 | 626 |
| 627 // Close first app. | 627 // Close first app. |
| 628 CloseAppWindow(window1b); | 628 CloseAppWindow(window1b); |
| 629 CloseAppWindow(window1); | 629 CloseAppWindow(window1); |
| 630 --item_count; | 630 --item_count; |
| 631 EXPECT_EQ(item_count, shelf_model()->item_count()); | 631 EXPECT_EQ(item_count, shelf_model()->item_count()); |
| 632 } | 632 } |
| 633 | 633 |
| 634 // Verify that ChromeLauncherController::CanInstall() returns true for ephemeral |
| 635 // apps and false when the app is promoted to a regular installed app. |
| 636 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, InstallEphemeralApp) { |
| 637 int item_count = shelf_model()->item_count(); |
| 638 |
| 639 // Sanity check to verify that ChromeLauncherController::CanInstall() returns |
| 640 // false for apps that are fully installed. |
| 641 const Extension* app = LoadAndLaunchPlatformApp("launch"); |
| 642 ASSERT_TRUE(app); |
| 643 CreateAppWindow(app); |
| 644 ++item_count; |
| 645 ASSERT_EQ(item_count, shelf_model()->item_count()); |
| 646 const ash::ShelfItem& app_item = GetLastLauncherItem(); |
| 647 ash::ShelfID app_id = app_item.id; |
| 648 EXPECT_FALSE(controller_->CanInstall(app_id)); |
| 649 |
| 650 // Add an ephemeral app. |
| 651 const Extension* ephemeral_app = InstallEphemeralAppWithSourceAndFlags( |
| 652 test_data_dir_.AppendASCII("platform_apps").AppendASCII("launch_2"), |
| 653 1, |
| 654 extensions::Manifest::INTERNAL, |
| 655 Extension::NO_FLAGS); |
| 656 ASSERT_TRUE(ephemeral_app); |
| 657 CreateAppWindow(ephemeral_app); |
| 658 ++item_count; |
| 659 ASSERT_EQ(item_count, shelf_model()->item_count()); |
| 660 const ash::ShelfItem& ephemeral_item = GetLastLauncherItem(); |
| 661 ash::ShelfID ephemeral_id = ephemeral_item.id; |
| 662 |
| 663 // Verify that the shelf item for the ephemeral app can be installed. |
| 664 EXPECT_TRUE(controller_->CanInstall(ephemeral_id)); |
| 665 |
| 666 // Promote the ephemeral app to a regular installed app. |
| 667 ExtensionService* service = |
| 668 extensions::ExtensionSystem::Get(profile())->extension_service(); |
| 669 service->PromoteEphemeralApp(ephemeral_app, false); |
| 670 |
| 671 // Verify that the shelf item for the app can no longer be installed. |
| 672 EXPECT_FALSE(controller_->CanInstall(ephemeral_id)); |
| 673 } |
| 674 |
| 634 // Confirm that Click behavior for app windows is correnct. | 675 // Confirm that Click behavior for app windows is correnct. |
| 635 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserNoMinimizeOnClick, AppClickBehavior) { | 676 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserNoMinimizeOnClick, AppClickBehavior) { |
| 636 // Launch a platform app and create a window for it. | 677 // Launch a platform app and create a window for it. |
| 637 const Extension* extension1 = LoadAndLaunchPlatformApp("launch"); | 678 const Extension* extension1 = LoadAndLaunchPlatformApp("launch"); |
| 638 AppWindow* window1 = CreateAppWindow(extension1); | 679 AppWindow* window1 = CreateAppWindow(extension1); |
| 639 EXPECT_TRUE(window1->GetNativeWindow()->IsVisible()); | 680 EXPECT_TRUE(window1->GetNativeWindow()->IsVisible()); |
| 640 EXPECT_TRUE(window1->GetBaseWindow()->IsActive()); | 681 EXPECT_TRUE(window1->GetBaseWindow()->IsActive()); |
| 641 // Confirm that a controller item was created and is the correct state. | 682 // Confirm that a controller item was created and is the correct state. |
| 642 const ash::ShelfItem& item1 = GetLastLauncherItem(); | 683 const ash::ShelfItem& item1 = GetLastLauncherItem(); |
| 643 LauncherItemController* item1_controller = GetItemController(item1.id); | 684 LauncherItemController* item1_controller = GetItemController(item1.id); |
| (...skipping 1437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2081 // number of shelf items should increase. | 2122 // number of shelf items should increase. |
| 2082 settings_manager->ShowChromePageForProfile( | 2123 settings_manager->ShowChromePageForProfile( |
| 2083 browser()->profile(), | 2124 browser()->profile(), |
| 2084 chrome::GetSettingsUrl(std::string())); | 2125 chrome::GetSettingsUrl(std::string())); |
| 2085 Browser* settings_browser = | 2126 Browser* settings_browser = |
| 2086 settings_manager->FindBrowserForProfile(browser()->profile()); | 2127 settings_manager->FindBrowserForProfile(browser()->profile()); |
| 2087 ASSERT_TRUE(settings_browser); | 2128 ASSERT_TRUE(settings_browser); |
| 2088 EXPECT_EQ(browser_count, NumberOfDetectedLauncherBrowsers(false)); | 2129 EXPECT_EQ(browser_count, NumberOfDetectedLauncherBrowsers(false)); |
| 2089 EXPECT_EQ(item_count + 1, shelf_model->item_count()); | 2130 EXPECT_EQ(item_count + 1, shelf_model->item_count()); |
| 2090 } | 2131 } |
| OLD | NEW |