| 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 <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 2721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2732 items[1]->Execute(ui::EF_SHIFT_DOWN); | 2732 items[1]->Execute(ui::EF_SHIFT_DOWN); |
| 2733 EXPECT_EQ(--tabs, browser()->tab_strip_model()->count()); | 2733 EXPECT_EQ(--tabs, browser()->tab_strip_model()->count()); |
| 2734 } | 2734 } |
| 2735 } | 2735 } |
| 2736 | 2736 |
| 2737 // Tests that panels create launcher items correctly | 2737 // Tests that panels create launcher items correctly |
| 2738 TEST_F(ChromeLauncherControllerTest, AppPanels) { | 2738 TEST_F(ChromeLauncherControllerTest, AppPanels) { |
| 2739 InitLauncherControllerWithBrowser(); | 2739 InitLauncherControllerWithBrowser(); |
| 2740 // App list and Browser shortcut ShelfItems are added. | 2740 // App list and Browser shortcut ShelfItems are added. |
| 2741 EXPECT_EQ(2, model_observer_->added()); | 2741 EXPECT_EQ(2, model_observer_->added()); |
| 2742 EXPECT_EQ(1, model_observer_->changed()); |
| 2742 | 2743 |
| 2743 const std::string app_id = extension1_->id(); | 2744 const std::string app_id = extension1_->id(); |
| 2744 // app_icon_loader is owned by ChromeLauncherController. | 2745 // app_icon_loader is owned by ChromeLauncherController. |
| 2745 TestAppIconLoaderImpl* app_icon_loader = new TestAppIconLoaderImpl(); | 2746 TestAppIconLoaderImpl* app_icon_loader = new TestAppIconLoaderImpl(); |
| 2746 app_icon_loader->AddSupportedApp(app_id); | 2747 app_icon_loader->AddSupportedApp(app_id); |
| 2747 SetAppIconLoader(std::unique_ptr<AppIconLoader>(app_icon_loader)); | 2748 SetAppIconLoader(std::unique_ptr<AppIconLoader>(app_icon_loader)); |
| 2748 | 2749 |
| 2749 // Test adding an app panel | 2750 // Test adding an app panel |
| 2750 AppWindowLauncherItemController* app_panel_controller = | 2751 AppWindowLauncherItemController* app_panel_controller = |
| 2751 new ExtensionAppWindowLauncherItemController( | 2752 new ExtensionAppWindowLauncherItemController( |
| 2752 LauncherItemController::TYPE_APP_PANEL, "id", app_id, | 2753 LauncherItemController::TYPE_APP_PANEL, "id", app_id, |
| 2753 launcher_controller_.get()); | 2754 launcher_controller_.get()); |
| 2754 ash::ShelfID shelf_id1 = launcher_controller_->CreateAppLauncherItem( | 2755 ash::ShelfID shelf_id1 = launcher_controller_->CreateAppLauncherItem( |
| 2755 app_panel_controller, app_id, ash::STATUS_RUNNING); | 2756 app_panel_controller, app_id, ash::STATUS_RUNNING); |
| 2756 int panel_index = model_observer_->last_index(); | 2757 int panel_index = model_observer_->last_index(); |
| 2757 EXPECT_EQ(3, model_observer_->added()); | 2758 EXPECT_EQ(3, model_observer_->added()); |
| 2758 EXPECT_EQ(0, model_observer_->changed()); | 2759 EXPECT_EQ(1, model_observer_->changed()); |
| 2759 EXPECT_EQ(1, app_icon_loader->fetch_count()); | 2760 EXPECT_EQ(1, app_icon_loader->fetch_count()); |
| 2760 model_observer_->clear_counts(); | 2761 model_observer_->clear_counts(); |
| 2761 | 2762 |
| 2762 // App panels should have a separate identifier than the app id | 2763 // App panels should have a separate identifier than the app id |
| 2763 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(app_id)); | 2764 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(app_id)); |
| 2764 | 2765 |
| 2765 // Setting the app image image should not change the panel if it set its icon | 2766 // Setting the app image image should not change the panel if it set its icon |
| 2766 app_panel_controller->set_image_set_by_controller(true); | 2767 app_panel_controller->set_image_set_by_controller(true); |
| 2767 gfx::ImageSkia image; | 2768 gfx::ImageSkia image; |
| 2768 launcher_controller_->OnAppImageUpdated(app_id, image); | 2769 launcher_controller_->OnAppImageUpdated(app_id, image); |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3067 // by hash we can determine that appropriate package was set by policy. | 3068 // by hash we can determine that appropriate package was set by policy. |
| 3068 base::ListValue policy_value; | 3069 base::ListValue policy_value; |
| 3069 InsertPrefValue(&policy_value, 0, appinfo.package_name); | 3070 InsertPrefValue(&policy_value, 0, appinfo.package_name); |
| 3070 profile()->GetTestingPrefService()->SetManagedPref( | 3071 profile()->GetTestingPrefService()->SetManagedPref( |
| 3071 prefs::kPolicyPinnedLauncherApps, policy_value.DeepCopy()); | 3072 prefs::kPolicyPinnedLauncherApps, policy_value.DeepCopy()); |
| 3072 | 3073 |
| 3073 EXPECT_TRUE(launcher_controller_->IsAppPinned(app_id)); | 3074 EXPECT_TRUE(launcher_controller_->IsAppPinned(app_id)); |
| 3074 EXPECT_EQ(AppListControllerDelegate::PIN_FIXED, | 3075 EXPECT_EQ(AppListControllerDelegate::PIN_FIXED, |
| 3075 launcher_controller_->GetPinnable(app_id)); | 3076 launcher_controller_->GetPinnable(app_id)); |
| 3076 } | 3077 } |
| OLD | NEW |