Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(382)

Unified Diff: components/update_client/update_client_unittest.cc

Issue 2918653003: Unconditionally delete the unpack path in the UpdateClient. (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/update_client/test_installer.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/update_client/update_client_unittest.cc
diff --git a/components/update_client/update_client_unittest.cc b/components/update_client/update_client_unittest.cc
index 73e9e9d8e2128b30fca147887e7cca19e92bd30e..fae978c077533b23fa0df6fe9857557d54164883 100644
--- a/components/update_client/update_client_unittest.cc
+++ b/components/update_client/update_client_unittest.cc
@@ -1370,13 +1370,24 @@ TEST_F(UpdateClientTest, OneCrxInstallError) {
bool(const std::string& file, base::FilePath* installed_file));
MOCK_METHOD0(Uninstall, bool());
- static void OnInstall(const base::DictionaryValue& manifest,
- const base::FilePath& unpack_path) {
- base::DeleteFile(unpack_path, true);
+ void OnInstall(const base::DictionaryValue& manifest,
+ const base::FilePath& unpack_path) {
+ unpack_path_ = unpack_path;
+ EXPECT_TRUE(base::DirectoryExists(unpack_path_));
}
protected:
- ~MockInstaller() override {}
+ ~MockInstaller() override {
+ // The unpack path is deleted unconditionally by the component state code,
+ // which is driving this installer. Therefore, the unpack path must not
+ // exist when this object is destroyed.
+ if (!unpack_path_.empty())
+ EXPECT_FALSE(base::DirectoryExists(unpack_path_));
+ }
+
+ private:
+ // Contains the |unpack_path| argument of the Install call.
+ base::FilePath unpack_path_;
};
class DataCallbackFake {
@@ -1389,7 +1400,7 @@ TEST_F(UpdateClientTest, OneCrxInstallError) {
EXPECT_CALL(*installer, OnUpdateError(_)).Times(0);
EXPECT_CALL(*installer, Install(_, _))
.WillOnce(
- DoAll(Invoke(MockInstaller::OnInstall),
+ DoAll(Invoke(installer.get(), &MockInstaller::OnInstall),
Return(CrxInstaller::Result(InstallError::GENERIC_ERROR))));
EXPECT_CALL(*installer, GetInstalledFile(_, _)).Times(0);
EXPECT_CALL(*installer, Uninstall()).Times(0);
« no previous file with comments | « components/update_client/test_installer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698