| 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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 private: | 209 private: |
| 210 DISALLOW_COPY_AND_ASSIGN(NewTabUISortingBrowserTest); | 210 DISALLOW_COPY_AND_ASSIGN(NewTabUISortingBrowserTest); |
| 211 }; | 211 }; |
| 212 | 212 |
| 213 #if defined(OS_WIN) | 213 #if defined(OS_WIN) |
| 214 #define MAYBE_ReorderDuringInstall DISABLED_ReorderDuringInstall | 214 #define MAYBE_ReorderDuringInstall DISABLED_ReorderDuringInstall |
| 215 #else | 215 #else |
| 216 #define MAYBE_ReorderDuringInstall ReorderDuringInstall | 216 #define MAYBE_ReorderDuringInstall ReorderDuringInstall |
| 217 #endif | 217 #endif |
| 218 IN_PROC_BROWSER_TEST_F(NewTabUISortingBrowserTest, MAYBE_ReorderDuringInstall) { | 218 IN_PROC_BROWSER_TEST_F(NewTabUISortingBrowserTest, MAYBE_ReorderDuringInstall) { |
| 219 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL)); | 219 ui_test_utils::NavigateToURLWithDisposition( |
| 220 browser(), GURL(chrome::kChromeUINewTabURL), CURRENT_TAB, |
| 221 ui_test_utils::BROWSER_TEST_NONE); |
| 220 ExtensionService* service = extensions::ExtensionSystem::Get( | 222 ExtensionService* service = extensions::ExtensionSystem::Get( |
| 221 browser()->profile())->extension_service(); | 223 browser()->profile())->extension_service(); |
| 222 base::FilePath app_dir = test_data_dir_.AppendASCII("app"); | 224 base::FilePath app_dir = test_data_dir_.AppendASCII("app"); |
| 223 const std::string app_id = extensions::id_util::GenerateIdForPath(app_dir); | 225 const std::string app_id = extensions::id_util::GenerateIdForPath(app_dir); |
| 224 | 226 |
| 225 const extensions::Extension* webstore_extension = | 227 const extensions::Extension* webstore_extension = |
| 226 service->GetInstalledExtension(extension_misc::kWebStoreAppId); | 228 service->GetInstalledExtension(extension_misc::kWebStoreAppId); |
| 227 EXPECT_TRUE(webstore_extension); | 229 EXPECT_TRUE(webstore_extension); |
| 228 ExtensionSorting* sorting = service->extension_prefs()->extension_sorting(); | 230 ExtensionSorting* sorting = service->extension_prefs()->extension_sorting(); |
| 229 | 231 |
| 230 // Register for notifications in the same way as AppLauncherHandler. | 232 // Register for notifications in the same way as AppLauncherHandler. |
| 231 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LAUNCHER_REORDERED, | 233 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LAUNCHER_REORDERED, |
| 232 content::Source<ExtensionSorting>(sorting)); | 234 content::Source<ExtensionSorting>(sorting)); |
| 233 // ExtensionAppItem calls this when an app install starts. | 235 // ExtensionAppItem calls this when an app install starts. |
| 234 sorting->EnsureValidOrdinals(app_id, syncer::StringOrdinal()); | 236 sorting->EnsureValidOrdinals(app_id, syncer::StringOrdinal()); |
| 235 // Vefify the app is not actually installed yet. | 237 // Vefify the app is not actually installed yet. |
| 236 EXPECT_FALSE(service->GetInstalledExtension(app_id)); | 238 EXPECT_FALSE(service->GetInstalledExtension(app_id)); |
| 237 // Move the test app from the end to be before the web store. | 239 // Move the test app from the end to be before the web store. |
| 238 service->OnExtensionMoved(app_id, | 240 service->OnExtensionMoved(app_id, |
| 239 std::string(), | 241 std::string(), |
| 240 extension_misc::kWebStoreAppId); | 242 extension_misc::kWebStoreAppId); |
| 241 EXPECT_EQ(app_id, last_reordered_extension_id_); | 243 EXPECT_EQ(app_id, last_reordered_extension_id_); |
| 242 | 244 |
| 243 // Now install the app. | 245 // Now install the app. |
| 244 const extensions::Extension* test_app = LoadExtension(app_dir); | 246 const extensions::Extension* test_app = LoadExtension(app_dir); |
| 245 ASSERT_TRUE(test_app); | 247 ASSERT_TRUE(test_app); |
| 246 EXPECT_TRUE(service->GetInstalledExtension(app_id)); | 248 EXPECT_TRUE(service->GetInstalledExtension(app_id)); |
| 247 EXPECT_EQ(app_id, test_app->id()); | 249 EXPECT_EQ(app_id, test_app->id()); |
| 248 } | 250 } |
| OLD | NEW |