| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 policy_value.Remove(0, NULL); | 165 policy_value.Remove(0, NULL); |
| 166 profile_->GetTestingPrefService()->SetManagedPref(prefs::kPinnedLauncherApps, | 166 profile_->GetTestingPrefService()->SetManagedPref(prefs::kPinnedLauncherApps, |
| 167 policy_value.DeepCopy()); | 167 policy_value.DeepCopy()); |
| 168 EXPECT_EQ(3, model_.item_count()); | 168 EXPECT_EQ(3, model_.item_count()); |
| 169 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_.items()[1].type); | 169 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_.items()[1].type); |
| 170 EXPECT_FALSE(launcher_controller.IsAppPinned(extension1_->id())); | 170 EXPECT_FALSE(launcher_controller.IsAppPinned(extension1_->id())); |
| 171 EXPECT_TRUE(launcher_controller.IsAppPinned(extension2_->id())); | 171 EXPECT_TRUE(launcher_controller.IsAppPinned(extension2_->id())); |
| 172 EXPECT_FALSE(launcher_controller.IsAppPinned(extension3_->id())); | 172 EXPECT_FALSE(launcher_controller.IsAppPinned(extension3_->id())); |
| 173 } | 173 } |
| 174 | 174 |
| 175 TEST_F(ChromeLauncherControllerTest, UnloadAndLoad) { | |
| 176 extension_service_->AddExtension(extension3_.get()); | |
| 177 extension_service_->AddExtension(extension4_.get()); | |
| 178 | |
| 179 ChromeLauncherController launcher_controller(profile_.get(), &model_); | |
| 180 launcher_controller.Init(); | |
| 181 | |
| 182 EXPECT_TRUE(launcher_controller.IsAppPinned(extension3_->id())); | |
| 183 EXPECT_TRUE(launcher_controller.IsAppPinned(extension4_->id())); | |
| 184 | |
| 185 extension_service_->UnloadExtension(extension3_->id(), | |
| 186 extension_misc::UNLOAD_REASON_UPDATE); | |
| 187 EXPECT_TRUE(launcher_controller.IsAppPinned(extension3_->id())); | |
| 188 EXPECT_EQ(ash::STATUS_IS_PENDING, model_.items()[1].status); | |
| 189 | |
| 190 extension_service_->AddExtension(extension3_.get()); | |
| 191 EXPECT_TRUE(launcher_controller.IsAppPinned(extension3_->id())); | |
| 192 EXPECT_EQ(ash::STATUS_CLOSED, model_.items()[1].status); | |
| 193 | |
| 194 EXPECT_TRUE(launcher_controller.IsAppPinned(extension4_->id())); | |
| 195 } | |
| 196 | |
| 197 TEST_F(ChromeLauncherControllerTest, UnpinWithUninstall) { | 175 TEST_F(ChromeLauncherControllerTest, UnpinWithUninstall) { |
| 198 extension_service_->AddExtension(extension3_.get()); | 176 extension_service_->AddExtension(extension3_.get()); |
| 199 extension_service_->AddExtension(extension4_.get()); | 177 extension_service_->AddExtension(extension4_.get()); |
| 200 | 178 |
| 201 ChromeLauncherController launcher_controller(profile_.get(), &model_); | 179 ChromeLauncherController launcher_controller(profile_.get(), &model_); |
| 202 launcher_controller.Init(); | 180 launcher_controller.Init(); |
| 203 | 181 |
| 204 EXPECT_TRUE(launcher_controller.IsAppPinned(extension3_->id())); | 182 EXPECT_TRUE(launcher_controller.IsAppPinned(extension3_->id())); |
| 205 EXPECT_TRUE(launcher_controller.IsAppPinned(extension4_->id())); | 183 EXPECT_TRUE(launcher_controller.IsAppPinned(extension4_->id())); |
| 206 | 184 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 | 263 |
| 286 GetAppLaunchers(&controller, &actual_launchers); | 264 GetAppLaunchers(&controller, &actual_launchers); |
| 287 EXPECT_EQ(expected_launchers, actual_launchers); | 265 EXPECT_EQ(expected_launchers, actual_launchers); |
| 288 | 266 |
| 289 // Install |extension2| and verify it shows up between the other two. | 267 // Install |extension2| and verify it shows up between the other two. |
| 290 extension_service_->AddExtension(extension2_.get()); | 268 extension_service_->AddExtension(extension2_.get()); |
| 291 expected_launchers.insert(expected_launchers.begin() + 1, extension2_->id()); | 269 expected_launchers.insert(expected_launchers.begin() + 1, extension2_->id()); |
| 292 GetAppLaunchers(&controller, &actual_launchers); | 270 GetAppLaunchers(&controller, &actual_launchers); |
| 293 EXPECT_EQ(expected_launchers, actual_launchers); | 271 EXPECT_EQ(expected_launchers, actual_launchers); |
| 294 } | 272 } |
| OLD | NEW |