Unconditionally delete the unpack path in the UpdateClient.

Bug: 726959
Change-Id: I002aa30ee0d85d845dba915d9dbd6e5599218184
Reviewed-on: https://chromium-review.googlesource.com/517463
Reviewed-by: Joshua Pawlicki <[email protected]>
Commit-Queue: Sorin Jianu <[email protected]>
Cr-Commit-Position: refs/heads/master@{#475648}
diff --git a/components/update_client/update_client_unittest.cc b/components/update_client/update_client_unittest.cc
index 73e9e9d..fae978c 100644
--- a/components/update_client/update_client_unittest.cc
+++ b/components/update_client/update_client_unittest.cc
@@ -1370,13 +1370,24 @@
                  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 @@
       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);