diff options
author | glen@chromium.org <glen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-09 01:07:42 +0000 |
---|---|---|
committer | glen@chromium.org <glen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-09 01:07:42 +0000 |
commit | 4a19063d1459a4c9c8c4c50ed86eb9048f69ea3f (patch) | |
tree | 69a1e9f78b3a5fa8b909cfab336826b09c44235f /chrome/browser/extensions/extensions_service_unittest.cc | |
parent | 5085ee0b4bfbe4625e63ee6975bb95702e13e0aa (diff) | |
download | chromium_src-4a19063d1459a4c9c8c4c50ed86eb9048f69ea3f.zip chromium_src-4a19063d1459a4c9c8c4c50ed86eb9048f69ea3f.tar.gz chromium_src-4a19063d1459a4c9c8c4c50ed86eb9048f69ea3f.tar.bz2 |
This is the first pass at themes.
This CL is paired with http://codereview.chromium.org/67284
This CL (for commit purposes) includes http://codereview.chromium.org/67284
BUG=4463,11232,11233,11234,11235
Review URL: http://codereview.chromium.org/99030
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15704 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extensions_service_unittest.cc')
-rw-r--r-- | chrome/browser/extensions/extensions_service_unittest.cc | 77 |
1 files changed, 73 insertions, 4 deletions
diff --git a/chrome/browser/extensions/extensions_service_unittest.cc b/chrome/browser/extensions/extensions_service_unittest.cc index e6c27df..dc9be78 100644 --- a/chrome/browser/extensions/extensions_service_unittest.cc +++ b/chrome/browser/extensions/extensions_service_unittest.cc @@ -66,10 +66,19 @@ class ExtensionsServiceTestFrontend return &extensions_; } + void ClearInstalledReinstalled() { + installed_ = NULL; + reinstalled_id_ = std::string(); + } + Extension* installed() { return installed_; } + std::string reinstalled_id() { + return reinstalled_id_; + } + // ExtensionsServiceFrontendInterface virtual MessageLoop* GetMessageLoop() { return &message_loop_; @@ -94,6 +103,10 @@ class ExtensionsServiceTestFrontend installed_ = extension; } + virtual void OnExtensionVersionReinstalled(const std::string& id) { + reinstalled_id_ = id; + } + virtual Extension* GetExtensionByID(std::string id) { return NULL; } @@ -122,11 +135,11 @@ class ExtensionsServiceTestFrontend ExtensionErrorReporter::GetInstance()->ClearErrors(); } - private: MessageLoop message_loop_; ExtensionList extensions_; Extension* installed_; + std::string reinstalled_id_; }; // make the test a PlatformTest to setup autorelease pools properly on mac @@ -277,9 +290,6 @@ TEST_F(ExtensionsServiceTest, InstallExtension) { frontend->TestInstallExtension(path, backend, true); // TODO(erikkay): verify the contents of the installed extension. - // Installing the same extension twice should fail. - frontend->TestInstallExtension(path, backend, false); - // 0-length extension file. path = extensions_path.AppendASCII("not_an_extension.crx"); frontend->TestInstallExtension(path, backend, false); @@ -300,6 +310,65 @@ TEST_F(ExtensionsServiceTest, InstallExtension) { // TODO(erikkay): add tests for upgrade cases. } +TEST_F(ExtensionsServiceTest, ReinstallExtension) { + // In this test, we install two extensions, verify that they both install + // correctly, then install the first extension again and verify that it was + // not installed, and that VersionReinstalled was called instead. + FilePath extensions_path; + ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &extensions_path)); + extensions_path = extensions_path.AppendASCII("extensions"); + + FilePath install_dir; + file_util::CreateNewTempDirectory(FILE_PATH_LITERAL("ext_test"), + &install_dir); + scoped_refptr<ExtensionsServiceBackend> backend( + new ExtensionsServiceBackend(install_dir)); + scoped_refptr<ExtensionsServiceTestFrontend> frontend( + new ExtensionsServiceTestFrontend); + + FilePath path = extensions_path.AppendASCII("good.crx"); + FilePath path2 = extensions_path.AppendASCII("theme.crx"); + + // Verify that our extensions are valid. + ASSERT_TRUE(file_util::PathExists(path)); + ASSERT_TRUE(file_util::PathExists(path2)); + + frontend->ClearInstalledReinstalled(); + // Install an extension. + backend->InstallExtension(path, + scoped_refptr<ExtensionsServiceFrontendInterface>(frontend.get())); + frontend->GetMessageLoop()->RunAllPending(); + std::vector<std::string> errors = GetErrors(); + + // Verify that it was installed. + EXPECT_TRUE(frontend->installed()) << path.value(); + EXPECT_EQ(0u, errors.size()) << path.value(); + + // Install our second extension. + frontend->ClearInstalledReinstalled(); + backend->InstallExtension(path2, + scoped_refptr<ExtensionsServiceFrontendInterface>(frontend.get())); + frontend->GetMessageLoop()->RunAllPending(); + errors = GetErrors(); + + // Verify that it was installed without reinstall getting called. + EXPECT_TRUE(frontend->installed()) << path2.value(); + EXPECT_TRUE(frontend->reinstalled_id().empty()); + EXPECT_EQ(0u, errors.size()) << path.value(); + + // Install the first extension again. + frontend->ClearInstalledReinstalled(); + backend->InstallExtension(path, + scoped_refptr<ExtensionsServiceFrontendInterface>(frontend.get())); + frontend->GetMessageLoop()->RunAllPending(); + errors = GetErrors(); + + // Verify that reinstall was called and installed was not. + EXPECT_FALSE(frontend->installed()) << path.value(); + EXPECT_FALSE(frontend->reinstalled_id().empty()) << path.value(); + EXPECT_EQ(0u, errors.size()) << path.value(); +} + TEST_F(ExtensionsServiceTest, LoadExtension) { FilePath extensions_path; ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &extensions_path)); |