12a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Copyright (c) 2013 The Chromium Authors. All rights reserved.
22a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
32a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// found in the LICENSE file.
42a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
5c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "chrome/browser/chromeos/drive/download_handler.h"
62a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
72a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/files/scoped_temp_dir.h"
8868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "chrome/browser/chromeos/drive/dummy_file_system.h"
9c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "chrome/browser/chromeos/drive/file_system_util.h"
105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "chrome/test/base/testing_profile.h"
112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "content/public/test/mock_download_item.h"
122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "content/public/test/mock_download_manager.h"
137d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)#include "content/public/test/test_browser_thread_bundle.h"
14116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#include "content/public/test/test_utils.h"
15116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#include "google_apis/drive/test_util.h"
162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "testing/gtest/include/gtest/gtest.h"
172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)namespace drive {
192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)namespace {
212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
22868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// Test file system for verifying the behavior of DownloadHandler, by simulating
23868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// various responses from FileSystem.
24868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)class DownloadHandlerTestFileSystem : public DummyFileSystem {
25868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) public:
26a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  DownloadHandlerTestFileSystem() : error_(FILE_ERROR_FAILED) {}
27868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
28a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  void set_error(FileError error) { error_ = error; }
29868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
30868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  // FileSystemInterface overrides.
31f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  virtual void GetResourceEntry(
32868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)      const base::FilePath& file_path,
33868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)      const GetResourceEntryCallback& callback) OVERRIDE {
34a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)    callback.Run(error_, scoped_ptr<ResourceEntry>(
35a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)        error_ == FILE_ERROR_OK ? new ResourceEntry : NULL));
36a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  }
37a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
38a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  virtual void CreateDirectory(
39a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)      const base::FilePath& directory_path,
40a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)      bool is_exclusive,
41a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)      bool is_recursive,
42a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)      const FileOperationCallback& callback) OVERRIDE {
43a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)    callback.Run(error_);
44a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  }
45868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
46868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) private:
47a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  FileError error_;
48868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)};
492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}  // namespace
512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
52c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)class DownloadHandlerTest : public testing::Test {
532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) public:
54c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  DownloadHandlerTest()
557d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)      : download_manager_(new content::MockDownloadManager) {}
562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual void SetUp() OVERRIDE {
582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    // Set expectations for download item.
612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    EXPECT_CALL(download_item_, GetState())
62868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)        .WillRepeatedly(testing::Return(content::DownloadItem::IN_PROGRESS));
632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
643551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)    download_handler_.reset(new DownloadHandler(&test_file_system_));
6590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)    download_handler_->Initialize(download_manager_.get(), temp_dir_.path());
662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) protected:
692a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  base::ScopedTempDir temp_dir_;
707d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)  content::TestBrowserThreadBundle thread_bundle_;
715d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  TestingProfile profile_;
7290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  scoped_ptr<content::MockDownloadManager> download_manager_;
73868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  DownloadHandlerTestFileSystem test_file_system_;
74c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  scoped_ptr<DownloadHandler> download_handler_;
752a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  content::MockDownloadItem download_item_;
762a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)};
772a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
78c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)TEST_F(DownloadHandlerTest, SubstituteDriveDownloadPathNonDrivePath) {
792a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  const base::FilePath non_drive_path(FILE_PATH_LITERAL("/foo/bar"));
802a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  ASSERT_FALSE(util::IsUnderDriveMountPoint(non_drive_path));
812a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
822a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Call SubstituteDriveDownloadPath()
832a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  base::FilePath substituted_path;
842a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  download_handler_->SubstituteDriveDownloadPath(
852a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      non_drive_path,
862a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      &download_item_,
87868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)      google_apis::test_util::CreateCopyResultCallback(&substituted_path));
88116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  content::RunAllBlockingPoolTasksUntilIdle();
892a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
902a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Check the result.
912a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  EXPECT_EQ(non_drive_path, substituted_path);
922a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  EXPECT_FALSE(download_handler_->IsDriveDownload(&download_item_));
932a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
942a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
95c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)TEST_F(DownloadHandlerTest, SubstituteDriveDownloadPath) {
962a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  const base::FilePath drive_path =
975d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      util::GetDriveMountPointPath(&profile_).AppendASCII("test.dat");
982a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
99868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  // Test the case that the download target directory already exists.
100a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  test_file_system_.set_error(FILE_ERROR_OK);
101868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
1022a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Call SubstituteDriveDownloadPath()
1032a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  base::FilePath substituted_path;
1042a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  download_handler_->SubstituteDriveDownloadPath(
1052a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      drive_path,
1062a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      &download_item_,
107868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)      google_apis::test_util::CreateCopyResultCallback(&substituted_path));
108116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  content::RunAllBlockingPoolTasksUntilIdle();
1092a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Check the result.
1112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  EXPECT_TRUE(temp_dir_.path().IsParent(substituted_path));
1122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  ASSERT_TRUE(download_handler_->IsDriveDownload(&download_item_));
1132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  EXPECT_EQ(drive_path, download_handler_->GetTargetPath(&download_item_));
1142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
1152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
116c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)TEST_F(DownloadHandlerTest, SubstituteDriveDownloadPathGetEntryFailure) {
1172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  const base::FilePath drive_path =
1185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      util::GetDriveMountPointPath(&profile_).AppendASCII("test.dat");
1192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
120868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  // Test the case that access to the download target directory failed for some
121868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  // reason.
122a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  test_file_system_.set_error(FILE_ERROR_FAILED);
123868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
1242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Call SubstituteDriveDownloadPath()
1252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  base::FilePath substituted_path;
1262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  download_handler_->SubstituteDriveDownloadPath(
1272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      drive_path,
1282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      &download_item_,
129868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)      google_apis::test_util::CreateCopyResultCallback(&substituted_path));
130116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  content::RunAllBlockingPoolTasksUntilIdle();
1312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Check the result.
1332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  EXPECT_TRUE(substituted_path.empty());
1342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
1352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// content::SavePackage calls SubstituteDriveDownloadPath before creating
1372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// DownloadItem.
138c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)TEST_F(DownloadHandlerTest, SubstituteDriveDownloadPathForSavePackage) {
1392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  const base::FilePath drive_path =
1405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      util::GetDriveMountPointPath(&profile_).AppendASCII("test.dat");
141a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  test_file_system_.set_error(FILE_ERROR_OK);
1422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Call SubstituteDriveDownloadPath()
1442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  base::FilePath substituted_path;
1452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  download_handler_->SubstituteDriveDownloadPath(
1462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      drive_path,
1472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      NULL,  // DownloadItem is not available at this moment.
148868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)      google_apis::test_util::CreateCopyResultCallback(&substituted_path));
149116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  content::RunAllBlockingPoolTasksUntilIdle();
1502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Check the result of SubstituteDriveDownloadPath().
1522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  EXPECT_TRUE(temp_dir_.path().IsParent(substituted_path));
1532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // |download_item_| is not a drive download yet.
1552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  EXPECT_FALSE(download_handler_->IsDriveDownload(&download_item_));
1562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Call SetDownloadParams().
1582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  download_handler_->SetDownloadParams(drive_path, &download_item_);
1592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // |download_item_| is a drive download now.
1612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  ASSERT_TRUE(download_handler_->IsDriveDownload(&download_item_));
1622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  EXPECT_EQ(drive_path, download_handler_->GetTargetPath(&download_item_));
1632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
1642a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
165c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)TEST_F(DownloadHandlerTest, CheckForFileExistence) {
1662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  const base::FilePath drive_path =
1675d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      util::GetDriveMountPointPath(&profile_).AppendASCII("test.dat");
1682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1692a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Make |download_item_| a drive download.
1702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  download_handler_->SetDownloadParams(drive_path, &download_item_);
1712a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  ASSERT_TRUE(download_handler_->IsDriveDownload(&download_item_));
1722a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  EXPECT_EQ(drive_path, download_handler_->GetTargetPath(&download_item_));
1732a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
174868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  // Test for the case when the path exists.
175a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  test_file_system_.set_error(FILE_ERROR_OK);
176868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
1772a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Call CheckForFileExistence.
1782a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  bool file_exists = false;
1792a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  download_handler_->CheckForFileExistence(
1802a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      &download_item_,
181868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)      google_apis::test_util::CreateCopyResultCallback(&file_exists));
182116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  content::RunAllBlockingPoolTasksUntilIdle();
1832a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1842a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Check the result.
1852a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  EXPECT_TRUE(file_exists);
1862a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
187868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  // Test for the case when the path does not exist.
188a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  test_file_system_.set_error(FILE_ERROR_NOT_FOUND);
1892a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1902a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Call CheckForFileExistence again.
1912a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  download_handler_->CheckForFileExistence(
1922a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      &download_item_,
193868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)      google_apis::test_util::CreateCopyResultCallback(&file_exists));
194116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  content::RunAllBlockingPoolTasksUntilIdle();
1952a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1962a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Check the result.
1972a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  EXPECT_FALSE(file_exists);
1982a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
1992a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
2002a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}  // namespace drive
201