| 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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 ThemeServiceFactory::GetForProfile(browser()->profile())->UseDefaultTheme(); | 135 ThemeServiceFactory::GetForProfile(browser()->profile())->UseDefaultTheme(); |
| 136 ASSERT_FALSE(GetTheme()); | 136 ASSERT_FALSE(GetTheme()); |
| 137 } | 137 } |
| 138 | 138 |
| 139 IN_PROC_BROWSER_TEST_F(ExtensionInstallUIBrowserTest, | 139 IN_PROC_BROWSER_TEST_F(ExtensionInstallUIBrowserTest, |
| 140 TestInstallThemeInFullScreen) { | 140 TestInstallThemeInFullScreen) { |
| 141 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_FULLSCREEN)); | 141 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_FULLSCREEN)); |
| 142 InstallThemeAndVerify("theme", "camo theme"); | 142 InstallThemeAndVerify("theme", "camo theme"); |
| 143 } | 143 } |
| 144 | 144 |
| 145 // TODO(samarth): delete along with rest of NTP4 code. |
| 145 IN_PROC_BROWSER_TEST_F(ExtensionInstallUIBrowserTest, | 146 IN_PROC_BROWSER_TEST_F(ExtensionInstallUIBrowserTest, |
| 146 AppInstallConfirmation) { | 147 DISABLED_AppInstallConfirmation) { |
| 147 int num_tabs = browser()->tab_strip_model()->count(); | 148 int num_tabs = browser()->tab_strip_model()->count(); |
| 148 | 149 |
| 149 base::FilePath app_dir = test_data_dir_.AppendASCII("app"); | 150 base::FilePath app_dir = test_data_dir_.AppendASCII("app"); |
| 150 ASSERT_TRUE(InstallExtensionWithUIAutoConfirm(app_dir, 1, browser())); | 151 ASSERT_TRUE(InstallExtensionWithUIAutoConfirm(app_dir, 1, browser())); |
| 151 | 152 |
| 152 if (NewTabUI::ShouldShowApps()) { | 153 if (NewTabUI::ShouldShowApps()) { |
| 153 EXPECT_EQ(num_tabs + 1, browser()->tab_strip_model()->count()); | 154 EXPECT_EQ(num_tabs + 1, browser()->tab_strip_model()->count()); |
| 154 WebContents* web_contents = | 155 WebContents* web_contents = |
| 155 browser()->tab_strip_model()->GetActiveWebContents(); | 156 browser()->tab_strip_model()->GetActiveWebContents(); |
| 156 ASSERT_TRUE(web_contents); | 157 ASSERT_TRUE(web_contents); |
| 157 EXPECT_TRUE(StartsWithASCII(web_contents->GetURL().spec(), | 158 EXPECT_TRUE(StartsWithASCII(web_contents->GetURL().spec(), |
| 158 "chrome://newtab/", false)); | 159 "chrome://newtab/", false)); |
| 159 } else { | 160 } else { |
| 160 // TODO(xiyuan): Figure out how to test extension installed bubble? | 161 // TODO(xiyuan): Figure out how to test extension installed bubble? |
| 161 } | 162 } |
| 162 } | 163 } |
| 163 | 164 |
| 165 // TODO(samarth): delete along with rest of NTP4 code. |
| 164 IN_PROC_BROWSER_TEST_F(ExtensionInstallUIBrowserTest, | 166 IN_PROC_BROWSER_TEST_F(ExtensionInstallUIBrowserTest, |
| 165 AppInstallConfirmation_Incognito) { | 167 DISABLED_AppInstallConfirmation_Incognito) { |
| 166 Browser* incognito_browser = CreateIncognitoBrowser(); | 168 Browser* incognito_browser = CreateIncognitoBrowser(); |
| 167 | 169 |
| 168 int num_incognito_tabs = incognito_browser->tab_strip_model()->count(); | 170 int num_incognito_tabs = incognito_browser->tab_strip_model()->count(); |
| 169 int num_normal_tabs = browser()->tab_strip_model()->count(); | 171 int num_normal_tabs = browser()->tab_strip_model()->count(); |
| 170 | 172 |
| 171 base::FilePath app_dir = test_data_dir_.AppendASCII("app"); | 173 base::FilePath app_dir = test_data_dir_.AppendASCII("app"); |
| 172 ASSERT_TRUE(InstallExtensionWithUIAutoConfirm(app_dir, 1, | 174 ASSERT_TRUE(InstallExtensionWithUIAutoConfirm(app_dir, 1, |
| 173 incognito_browser)); | 175 incognito_browser)); |
| 174 | 176 |
| 175 EXPECT_EQ(num_incognito_tabs, | 177 EXPECT_EQ(num_incognito_tabs, |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 private: | 211 private: |
| 210 DISALLOW_COPY_AND_ASSIGN(NewTabUISortingBrowserTest); | 212 DISALLOW_COPY_AND_ASSIGN(NewTabUISortingBrowserTest); |
| 211 }; | 213 }; |
| 212 | 214 |
| 213 #if defined(OS_WIN) | 215 #if defined(OS_WIN) |
| 214 #define MAYBE_ReorderDuringInstall DISABLED_ReorderDuringInstall | 216 #define MAYBE_ReorderDuringInstall DISABLED_ReorderDuringInstall |
| 215 #else | 217 #else |
| 216 #define MAYBE_ReorderDuringInstall ReorderDuringInstall | 218 #define MAYBE_ReorderDuringInstall ReorderDuringInstall |
| 217 #endif | 219 #endif |
| 218 IN_PROC_BROWSER_TEST_F(NewTabUISortingBrowserTest, MAYBE_ReorderDuringInstall) { | 220 IN_PROC_BROWSER_TEST_F(NewTabUISortingBrowserTest, MAYBE_ReorderDuringInstall) { |
| 219 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL)); | 221 ui_test_utils::NavigateToURLWithDisposition( |
| 222 browser(), GURL(chrome::kChromeUINewTabURL), CURRENT_TAB, |
| 223 ui_test_utils::BROWSER_TEST_NONE); |
| 220 ExtensionService* service = extensions::ExtensionSystem::Get( | 224 ExtensionService* service = extensions::ExtensionSystem::Get( |
| 221 browser()->profile())->extension_service(); | 225 browser()->profile())->extension_service(); |
| 222 base::FilePath app_dir = test_data_dir_.AppendASCII("app"); | 226 base::FilePath app_dir = test_data_dir_.AppendASCII("app"); |
| 223 const std::string app_id = extensions::id_util::GenerateIdForPath(app_dir); | 227 const std::string app_id = extensions::id_util::GenerateIdForPath(app_dir); |
| 224 | 228 |
| 225 const extensions::Extension* webstore_extension = | 229 const extensions::Extension* webstore_extension = |
| 226 service->GetInstalledExtension(extension_misc::kWebStoreAppId); | 230 service->GetInstalledExtension(extension_misc::kWebStoreAppId); |
| 227 EXPECT_TRUE(webstore_extension); | 231 EXPECT_TRUE(webstore_extension); |
| 228 ExtensionSorting* sorting = service->extension_prefs()->extension_sorting(); | 232 ExtensionSorting* sorting = service->extension_prefs()->extension_sorting(); |
| 229 | 233 |
| 230 // Register for notifications in the same way as AppLauncherHandler. | 234 // Register for notifications in the same way as AppLauncherHandler. |
| 231 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LAUNCHER_REORDERED, | 235 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LAUNCHER_REORDERED, |
| 232 content::Source<ExtensionSorting>(sorting)); | 236 content::Source<ExtensionSorting>(sorting)); |
| 233 // ExtensionAppItem calls this when an app install starts. | 237 // ExtensionAppItem calls this when an app install starts. |
| 234 sorting->EnsureValidOrdinals(app_id, syncer::StringOrdinal()); | 238 sorting->EnsureValidOrdinals(app_id, syncer::StringOrdinal()); |
| 235 // Vefify the app is not actually installed yet. | 239 // Vefify the app is not actually installed yet. |
| 236 EXPECT_FALSE(service->GetInstalledExtension(app_id)); | 240 EXPECT_FALSE(service->GetInstalledExtension(app_id)); |
| 237 // Move the test app from the end to be before the web store. | 241 // Move the test app from the end to be before the web store. |
| 238 service->OnExtensionMoved(app_id, | 242 service->OnExtensionMoved(app_id, |
| 239 std::string(), | 243 std::string(), |
| 240 extension_misc::kWebStoreAppId); | 244 extension_misc::kWebStoreAppId); |
| 241 EXPECT_EQ(app_id, last_reordered_extension_id_); | 245 EXPECT_EQ(app_id, last_reordered_extension_id_); |
| 242 | 246 |
| 243 // Now install the app. | 247 // Now install the app. |
| 244 const extensions::Extension* test_app = LoadExtension(app_dir); | 248 const extensions::Extension* test_app = LoadExtension(app_dir); |
| 245 ASSERT_TRUE(test_app); | 249 ASSERT_TRUE(test_app); |
| 246 EXPECT_TRUE(service->GetInstalledExtension(app_id)); | 250 EXPECT_TRUE(service->GetInstalledExtension(app_id)); |
| 247 EXPECT_EQ(app_id, test_app->id()); | 251 EXPECT_EQ(app_id, test_app->id()); |
| 248 } | 252 } |
| OLD | NEW |