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" |
11 #include "chrome/browser/infobars/infobar_service.h" | 11 #include "chrome/browser/infobars/infobar_service.h" |
12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/browser/themes/theme_service.h" | 13 #include "chrome/browser/themes/theme_service.h" |
14 #include "chrome/browser/themes/theme_service_factory.h" | 14 #include "chrome/browser/themes/theme_service_factory.h" |
15 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
16 #include "chrome/browser/ui/browser_commands.h" | 16 #include "chrome/browser/ui/browser_commands.h" |
17 #include "chrome/browser/ui/browser_finder.h" | 17 #include "chrome/browser/ui/browser_finder.h" |
18 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 18 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
19 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" | 19 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" |
20 #include "chrome/common/url_constants.h" | 20 #include "chrome/common/url_constants.h" |
21 #include "chrome/test/base/test_switches.h" | 21 #include "chrome/test/base/test_switches.h" |
22 #include "chrome/test/base/ui_test_utils.h" | 22 #include "chrome/test/base/ui_test_utils.h" |
23 #include "components/crx_file/id_util.h" | 23 #include "components/crx_file/id_util.h" |
24 #include "components/infobars/core/confirm_infobar_delegate.h" | 24 #include "components/infobars/core/confirm_infobar_delegate.h" |
25 #include "components/infobars/core/infobar.h" | 25 #include "components/infobars/core/infobar.h" |
26 #include "content/public/browser/web_contents.h" | 26 #include "content/public/browser/web_contents.h" |
27 #include "content/public/test/browser_test_utils.h" | 27 #include "content/public/test/browser_test_utils.h" |
28 #include "extensions/browser/app_sorting.h" | 28 #include "extensions/browser/app_sorting.h" |
29 #include "extensions/browser/extension_prefs.h" | |
30 #include "extensions/common/constants.h" | 29 #include "extensions/common/constants.h" |
31 | 30 |
32 using content::WebContents; | 31 using content::WebContents; |
33 using extensions::AppSorting; | 32 using extensions::AppSorting; |
34 using extensions::Extension; | 33 using extensions::Extension; |
35 | 34 |
36 class ExtensionInstallUIBrowserTest : public ExtensionBrowserTest { | 35 class ExtensionInstallUIBrowserTest : public ExtensionBrowserTest { |
37 public: | 36 public: |
38 // Checks that a theme info bar is currently visible and issues an undo to | 37 // Checks that a theme info bar is currently visible and issues an undo to |
39 // revert to the previous theme. | 38 // revert to the previous theme. |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL)); | 226 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL)); |
228 ExtensionService* service = extensions::ExtensionSystem::Get( | 227 ExtensionService* service = extensions::ExtensionSystem::Get( |
229 browser()->profile())->extension_service(); | 228 browser()->profile())->extension_service(); |
230 base::FilePath app_dir = test_data_dir_.AppendASCII("app"); | 229 base::FilePath app_dir = test_data_dir_.AppendASCII("app"); |
231 const std::string app_id = crx_file::id_util::GenerateIdForPath(app_dir); | 230 const std::string app_id = crx_file::id_util::GenerateIdForPath(app_dir); |
232 | 231 |
233 const extensions::Extension* webstore_extension = | 232 const extensions::Extension* webstore_extension = |
234 service->GetInstalledExtension(extensions::kWebStoreAppId); | 233 service->GetInstalledExtension(extensions::kWebStoreAppId); |
235 EXPECT_TRUE(webstore_extension); | 234 EXPECT_TRUE(webstore_extension); |
236 AppSorting* sorting = | 235 AppSorting* sorting = |
237 extensions::ExtensionPrefs::Get(browser()->profile())->app_sorting(); | 236 extensions::ExtensionSystem::Get(browser()->profile())->app_sorting(); |
238 | 237 |
239 // Register for notifications in the same way as AppLauncherHandler. | 238 // Register for notifications in the same way as AppLauncherHandler. |
240 registrar_.Add(this, | 239 registrar_.Add(this, |
241 chrome::NOTIFICATION_APP_LAUNCHER_REORDERED, | 240 chrome::NOTIFICATION_APP_LAUNCHER_REORDERED, |
242 content::Source<AppSorting>(sorting)); | 241 content::Source<AppSorting>(sorting)); |
243 // ExtensionAppItem calls this when an app install starts. | 242 // ExtensionAppItem calls this when an app install starts. |
244 sorting->EnsureValidOrdinals(app_id, syncer::StringOrdinal()); | 243 sorting->EnsureValidOrdinals(app_id, syncer::StringOrdinal()); |
245 // Vefify the app is not actually installed yet. | 244 // Vefify the app is not actually installed yet. |
246 EXPECT_FALSE(service->GetInstalledExtension(app_id)); | 245 EXPECT_FALSE(service->GetInstalledExtension(app_id)); |
247 // Move the test app from the end to be before the web store. | 246 // Move the test app from the end to be before the web store. |
248 sorting->OnExtensionMoved( | 247 sorting->OnExtensionMoved( |
249 app_id, std::string(), extensions::kWebStoreAppId); | 248 app_id, std::string(), extensions::kWebStoreAppId); |
250 EXPECT_EQ(app_id, last_reordered_extension_id_); | 249 EXPECT_EQ(app_id, last_reordered_extension_id_); |
251 | 250 |
252 // Now install the app. | 251 // Now install the app. |
253 const extensions::Extension* test_app = LoadExtension(app_dir); | 252 const extensions::Extension* test_app = LoadExtension(app_dir); |
254 ASSERT_TRUE(test_app); | 253 ASSERT_TRUE(test_app); |
255 EXPECT_TRUE(service->GetInstalledExtension(app_id)); | 254 EXPECT_TRUE(service->GetInstalledExtension(app_id)); |
256 EXPECT_EQ(app_id, test_app->id()); | 255 EXPECT_EQ(app_id, test_app->id()); |
257 } | 256 } |
OLD | NEW |