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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/strings/string_util.h" | 6 #include "base/strings/string_util.h" |
7 #include "chrome/app/chrome_command_ids.h" | 7 #include "chrome/app/chrome_command_ids.h" |
8 #include "chrome/browser/chrome_notification_types.h" | 8 #include "chrome/browser/chrome_notification_types.h" |
9 #include "chrome/browser/extensions/extension_browsertest.h" | 9 #include "chrome/browser/extensions/extension_browsertest.h" |
10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 } | 193 } |
194 | 194 |
195 class NewTabUISortingBrowserTest : public ExtensionInstallUIBrowserTest, | 195 class NewTabUISortingBrowserTest : public ExtensionInstallUIBrowserTest, |
196 public content::NotificationObserver { | 196 public content::NotificationObserver { |
197 public: | 197 public: |
198 NewTabUISortingBrowserTest() {} | 198 NewTabUISortingBrowserTest() {} |
199 | 199 |
200 virtual void Observe(int type, | 200 virtual void Observe(int type, |
201 const content::NotificationSource& source, | 201 const content::NotificationSource& source, |
202 const content::NotificationDetails& details) OVERRIDE { | 202 const content::NotificationDetails& details) OVERRIDE { |
203 if (type != chrome::NOTIFICATION_EXTENSION_LAUNCHER_REORDERED) { | 203 if (type != chrome::NOTIFICATION_APP_LAUNCHER_REORDERED) { |
204 observer_->Observe(type, source, details); | 204 observer_->Observe(type, source, details); |
205 return; | 205 return; |
206 } | 206 } |
207 const std::string* id = content::Details<const std::string>(details).ptr(); | 207 const std::string* id = content::Details<const std::string>(details).ptr(); |
208 EXPECT_TRUE(id); | 208 EXPECT_TRUE(id); |
209 last_reordered_extension_id_ = *id; | 209 last_reordered_extension_id_ = *id; |
210 } | 210 } |
211 | 211 |
212 protected: | 212 protected: |
213 std::string last_reordered_extension_id_; | 213 std::string last_reordered_extension_id_; |
(...skipping 12 matching lines...) Expand all Loading... |
226 base::FilePath app_dir = test_data_dir_.AppendASCII("app"); | 226 base::FilePath app_dir = test_data_dir_.AppendASCII("app"); |
227 const std::string app_id = extensions::id_util::GenerateIdForPath(app_dir); | 227 const std::string app_id = extensions::id_util::GenerateIdForPath(app_dir); |
228 | 228 |
229 const extensions::Extension* webstore_extension = | 229 const extensions::Extension* webstore_extension = |
230 service->GetInstalledExtension(extension_misc::kWebStoreAppId); | 230 service->GetInstalledExtension(extension_misc::kWebStoreAppId); |
231 EXPECT_TRUE(webstore_extension); | 231 EXPECT_TRUE(webstore_extension); |
232 AppSorting* sorting = | 232 AppSorting* sorting = |
233 extensions::ExtensionPrefs::Get(browser()->profile())->app_sorting(); | 233 extensions::ExtensionPrefs::Get(browser()->profile())->app_sorting(); |
234 | 234 |
235 // Register for notifications in the same way as AppLauncherHandler. | 235 // Register for notifications in the same way as AppLauncherHandler. |
236 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LAUNCHER_REORDERED, | 236 registrar_.Add(this, |
237 content::Source<AppSorting>(sorting)); | 237 chrome::NOTIFICATION_APP_LAUNCHER_REORDERED, |
| 238 content::Source<AppSorting>(sorting)); |
238 // ExtensionAppItem calls this when an app install starts. | 239 // ExtensionAppItem calls this when an app install starts. |
239 sorting->EnsureValidOrdinals(app_id, syncer::StringOrdinal()); | 240 sorting->EnsureValidOrdinals(app_id, syncer::StringOrdinal()); |
240 // Vefify the app is not actually installed yet. | 241 // Vefify the app is not actually installed yet. |
241 EXPECT_FALSE(service->GetInstalledExtension(app_id)); | 242 EXPECT_FALSE(service->GetInstalledExtension(app_id)); |
242 // Move the test app from the end to be before the web store. | 243 // Move the test app from the end to be before the web store. |
243 sorting->OnExtensionMoved( | 244 sorting->OnExtensionMoved( |
244 app_id, std::string(), extension_misc::kWebStoreAppId); | 245 app_id, std::string(), extension_misc::kWebStoreAppId); |
245 EXPECT_EQ(app_id, last_reordered_extension_id_); | 246 EXPECT_EQ(app_id, last_reordered_extension_id_); |
246 | 247 |
247 // Now install the app. | 248 // Now install the app. |
248 const extensions::Extension* test_app = LoadExtension(app_dir); | 249 const extensions::Extension* test_app = LoadExtension(app_dir); |
249 ASSERT_TRUE(test_app); | 250 ASSERT_TRUE(test_app); |
250 EXPECT_TRUE(service->GetInstalledExtension(app_id)); | 251 EXPECT_TRUE(service->GetInstalledExtension(app_id)); |
251 EXPECT_EQ(app_id, test_app->id()); | 252 EXPECT_EQ(app_id, test_app->id()); |
252 } | 253 } |
OLD | NEW |