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