Chromium Code Reviews| Index: chrome/browser/extensions/extension_service_test_with_install.cc |
| diff --git a/chrome/browser/extensions/extension_service_test_with_install.cc b/chrome/browser/extensions/extension_service_test_with_install.cc |
| index 9ff4cf07e22e1857a8d6baa20e5c2f03e42d08cc..aea8e970e224fb7c3073b410bc8b2d106bedcfcd 100644 |
| --- a/chrome/browser/extensions/extension_service_test_with_install.cc |
| +++ b/chrome/browser/extensions/extension_service_test_with_install.cc |
| @@ -126,6 +126,29 @@ const Extension* ExtensionServiceTestWithInstall::PackAndInstallCRX( |
| Extension::NO_FLAGS); |
| } |
| +const Extension* ExtensionServiceTestWithInstall::PackAndInstallCRXWithLocation( |
| + const base::FilePath& dir_path, |
| + Manifest::Location install_location, |
| + InstallState install_state) { |
| + base::FilePath crx_path; |
|
Devlin
2016/09/26 20:13:09
With functions like these, it's best to house the
catmullings
2016/10/06 18:24:19
Wrt "add a new version of PackAndInstallCRX that i
Devlin
2016/10/10 15:27:28
Not quite. With these types of functions, where t
catmullings
2016/10/12 18:58:58
Done.
|
| + base::ScopedTempDir temp_dir; |
| + EXPECT_TRUE(temp_dir.CreateUniqueTempDir()); |
| + crx_path = temp_dir.GetPath().AppendASCII("temp.crx"); |
| + |
| + PackCRX(dir_path, base::FilePath(), crx_path); |
| + |
| + scoped_refptr<CrxInstaller> installer(CrxInstaller::CreateSilent(service())); |
| + installer->set_install_source(install_location); |
| + |
| + content::WindowedNotificationObserver observer( |
| + extensions::NOTIFICATION_CRX_INSTALLER_DONE, |
| + content::NotificationService::AllSources()); |
| + installer->InstallCrx(crx_path); |
| + observer.Wait(); |
| + |
| + return VerifyCrxInstall(crx_path, install_state); |
| +} |
| + |
| // Attempts to install an extension. Use INSTALL_FAILED if the installation |
| // is expected to fail. |
| // If |install_state| is INSTALL_UPDATED, and |expected_old_name| is |
| @@ -330,6 +353,9 @@ void ExtensionServiceTestWithInstall::UninstallExtension( |
| EXPECT_GT(pref_key_count, 0u); |
| ValidateIntegerPref(id, "state", expected_state); |
| + // We make a copy of the extension's id since the extension can be deleted |
| + // once it's uninstalled. |
| + std::string extension_id = id; |
| // Uninstall it. |
| if (use_helper) { |
| EXPECT_TRUE(ExtensionService::UninstallExtensionHelper( |
| @@ -343,7 +369,7 @@ void ExtensionServiceTestWithInstall::UninstallExtension( |
| // We should get an unload notification. |
| EXPECT_FALSE(unloaded_id_.empty()); |
| - EXPECT_EQ(id, unloaded_id_); |
| + EXPECT_EQ(extension_id, unloaded_id_); |
| // Verify uninstalled state. |
| size_t new_pref_key_count = GetPrefKeyCount(); |
| @@ -355,7 +381,7 @@ void ExtensionServiceTestWithInstall::UninstallExtension( |
| } |
| // The extension should not be in the service anymore. |
| - EXPECT_FALSE(service()->GetInstalledExtension(id)); |
| + EXPECT_FALSE(service()->GetInstalledExtension(extension_id)); |
| base::RunLoop().RunUntilIdle(); |
| // The directory should be gone. |