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 |
175 TEST_F(ChromeLauncherControllerTest, UnpinWithUninstall) { | 197 TEST_F(ChromeLauncherControllerTest, UnpinWithUninstall) { |
176 extension_service_->AddExtension(extension3_.get()); | 198 extension_service_->AddExtension(extension3_.get()); |
177 extension_service_->AddExtension(extension4_.get()); | 199 extension_service_->AddExtension(extension4_.get()); |
178 | 200 |
179 ChromeLauncherController launcher_controller(profile_.get(), &model_); | 201 ChromeLauncherController launcher_controller(profile_.get(), &model_); |
180 launcher_controller.Init(); | 202 launcher_controller.Init(); |
181 | 203 |
182 EXPECT_TRUE(launcher_controller.IsAppPinned(extension3_->id())); | 204 EXPECT_TRUE(launcher_controller.IsAppPinned(extension3_->id())); |
183 EXPECT_TRUE(launcher_controller.IsAppPinned(extension4_->id())); | 205 EXPECT_TRUE(launcher_controller.IsAppPinned(extension4_->id())); |
184 | 206 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 | 285 |
264 GetAppLaunchers(&controller, &actual_launchers); | 286 GetAppLaunchers(&controller, &actual_launchers); |
265 EXPECT_EQ(expected_launchers, actual_launchers); | 287 EXPECT_EQ(expected_launchers, actual_launchers); |
266 | 288 |
267 // Install |extension2| and verify it shows up between the other two. | 289 // Install |extension2| and verify it shows up between the other two. |
268 extension_service_->AddExtension(extension2_.get()); | 290 extension_service_->AddExtension(extension2_.get()); |
269 expected_launchers.insert(expected_launchers.begin() + 1, extension2_->id()); | 291 expected_launchers.insert(expected_launchers.begin() + 1, extension2_->id()); |
270 GetAppLaunchers(&controller, &actual_launchers); | 292 GetAppLaunchers(&controller, &actual_launchers); |
271 EXPECT_EQ(expected_launchers, actual_launchers); | 293 EXPECT_EQ(expected_launchers, actual_launchers); |
272 } | 294 } |
OLD | NEW |