| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <string> | 5 #include <string> |
| 6 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| 11 #include "base/json/json_file_value_serializer.h" | 11 #include "base/json/json_file_value_serializer.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/message_loop.h" | 13 #include "base/message_loop.h" |
| 14 #include "base/path_service.h" | 14 #include "base/path_service.h" |
| 15 #include "base/scoped_temp_dir.h" | 15 #include "base/scoped_temp_dir.h" |
| 16 #include "base/stringprintf.h" | 16 #include "base/stringprintf.h" |
| 17 #include "base/threading/sequenced_worker_pool.h" | 17 #include "base/threading/sequenced_worker_pool.h" |
| 18 #include "base/values.h" | 18 #include "base/values.h" |
| 19 #include "chrome/browser/chromeos/cros/cros_library.h" | 19 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 20 #include "chrome/browser/chromeos/gdata/drive.pb.h" | 20 #include "chrome/browser/chromeos/gdata/drive.pb.h" |
| 21 #include "chrome/browser/chromeos/gdata/drive_api_parser.h" | 21 #include "chrome/browser/chromeos/gdata/drive_api_parser.h" |
| 22 #include "chrome/browser/chromeos/gdata/drive_file_system.h" |
| 22 #include "chrome/browser/chromeos/gdata/drive_webapps_registry.h" | 23 #include "chrome/browser/chromeos/gdata/drive_webapps_registry.h" |
| 23 #include "chrome/browser/chromeos/gdata/gdata_file_system.h" | |
| 24 #include "chrome/browser/chromeos/gdata/gdata_test_util.h" | 24 #include "chrome/browser/chromeos/gdata/gdata_test_util.h" |
| 25 #include "chrome/browser/chromeos/gdata/gdata_uploader.h" | 25 #include "chrome/browser/chromeos/gdata/gdata_uploader.h" |
| 26 #include "chrome/browser/chromeos/gdata/gdata_util.h" | 26 #include "chrome/browser/chromeos/gdata/gdata_util.h" |
| 27 #include "chrome/browser/chromeos/gdata/mock_directory_change_observer.h" | 27 #include "chrome/browser/chromeos/gdata/mock_directory_change_observer.h" |
| 28 #include "chrome/browser/chromeos/gdata/mock_drive_cache_observer.h" | 28 #include "chrome/browser/chromeos/gdata/mock_drive_cache_observer.h" |
| 29 #include "chrome/browser/chromeos/gdata/mock_drive_service.h" | 29 #include "chrome/browser/chromeos/gdata/mock_drive_service.h" |
| 30 #include "chrome/common/chrome_paths.h" | 30 #include "chrome/common/chrome_paths.h" |
| 31 #include "chrome/test/base/testing_profile.h" | 31 #include "chrome/test/base/testing_profile.h" |
| 32 #include "content/public/browser/browser_thread.h" | 32 #include "content/public/browser/browser_thread.h" |
| 33 #include "content/public/test/test_browser_thread.h" | 33 #include "content/public/test/test_browser_thread.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 46 | 46 |
| 47 const char kSymLinkToDevNull[] = "/dev/null"; | 47 const char kSymLinkToDevNull[] = "/dev/null"; |
| 48 | 48 |
| 49 const int64 kLotsOfSpace = kMinFreeSpace * 10; | 49 const int64 kLotsOfSpace = kMinFreeSpace * 10; |
| 50 | 50 |
| 51 struct SearchResultPair { | 51 struct SearchResultPair { |
| 52 const char* path; | 52 const char* path; |
| 53 const bool is_directory; | 53 const bool is_directory; |
| 54 }; | 54 }; |
| 55 | 55 |
| 56 // Callback to GDataFileSystem::Search used in ContentSearch tests. | 56 // Callback to DriveFileSystem::Search used in ContentSearch tests. |
| 57 // Verifies returned vector of results. | 57 // Verifies returned vector of results. |
| 58 void DriveSearchCallback( | 58 void DriveSearchCallback( |
| 59 MessageLoop* message_loop, | 59 MessageLoop* message_loop, |
| 60 const SearchResultPair* expected_results, | 60 const SearchResultPair* expected_results, |
| 61 size_t expected_results_size, | 61 size_t expected_results_size, |
| 62 DriveFileError error, | 62 DriveFileError error, |
| 63 const GURL& next_feed, | 63 const GURL& next_feed, |
| 64 scoped_ptr<std::vector<SearchResultInfo> > results) { | 64 scoped_ptr<std::vector<SearchResultInfo> > results) { |
| 65 ASSERT_TRUE(results.get()); | 65 ASSERT_TRUE(results.get()); |
| 66 ASSERT_EQ(expected_results_size, results->size()); | 66 ASSERT_EQ(expected_results_size, results->size()); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 91 upload_file_info->file_path = local_file_path; | 91 upload_file_info->file_path = local_file_path; |
| 92 upload_file_info->entry.reset(document_entry); | 92 upload_file_info->entry.reset(document_entry); |
| 93 base::MessageLoopProxy::current()->PostTask(FROM_HERE, | 93 base::MessageLoopProxy::current()->PostTask(FROM_HERE, |
| 94 base::Bind(arg5, error, base::Passed(&upload_file_info))); | 94 base::Bind(arg5, error, base::Passed(&upload_file_info))); |
| 95 | 95 |
| 96 const int kUploadId = 123; | 96 const int kUploadId = 123; |
| 97 return kUploadId; | 97 return kUploadId; |
| 98 } | 98 } |
| 99 | 99 |
| 100 // Action used to set mock expectations for | 100 // Action used to set mock expectations for |
| 101 // GDataFileSystem::CopyDocument(). | 101 // DriveFileSystem::CopyDocument(). |
| 102 ACTION_P2(MockCopyDocument, status, value) { | 102 ACTION_P2(MockCopyDocument, status, value) { |
| 103 base::MessageLoopProxy::current()->PostTask( | 103 base::MessageLoopProxy::current()->PostTask( |
| 104 FROM_HERE, | 104 FROM_HERE, |
| 105 base::Bind(arg2, status, base::Passed(value))); | 105 base::Bind(arg2, status, base::Passed(value))); |
| 106 } | 106 } |
| 107 | 107 |
| 108 // Returns the absolute path for a test file stored under | 108 // Returns the absolute path for a test file stored under |
| 109 // chrome/test/data/chromeos/gdata. | 109 // chrome/test/data/chromeos/gdata. |
| 110 FilePath GetTestFilePath(const FilePath::StringType& base_name) { | 110 FilePath GetTestFilePath(const FilePath::StringType& base_name) { |
| 111 FilePath path; | 111 FilePath path; |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 | 195 |
| 196 MOCK_METHOD3(GetWebAppsForFile, void(const FilePath& file, | 196 MOCK_METHOD3(GetWebAppsForFile, void(const FilePath& file, |
| 197 const std::string& mime_type, | 197 const std::string& mime_type, |
| 198 ScopedVector<DriveWebAppInfo>* apps)); | 198 ScopedVector<DriveWebAppInfo>* apps)); |
| 199 MOCK_METHOD1(GetExtensionsForWebStoreApp, | 199 MOCK_METHOD1(GetExtensionsForWebStoreApp, |
| 200 std::set<std::string>(const std::string& web_store_id)); | 200 std::set<std::string>(const std::string& web_store_id)); |
| 201 MOCK_METHOD1(UpdateFromFeed, void(const AccountMetadataFeed& metadata)); | 201 MOCK_METHOD1(UpdateFromFeed, void(const AccountMetadataFeed& metadata)); |
| 202 MOCK_METHOD1(UpdateFromApplicationList, void(const AppList& applist)); | 202 MOCK_METHOD1(UpdateFromApplicationList, void(const AppList& applist)); |
| 203 }; | 203 }; |
| 204 | 204 |
| 205 class GDataFileSystemTest : public testing::Test { | 205 class DriveFileSystemTest : public testing::Test { |
| 206 protected: | 206 protected: |
| 207 GDataFileSystemTest() | 207 DriveFileSystemTest() |
| 208 : ui_thread_(content::BrowserThread::UI, &message_loop_), | 208 : ui_thread_(content::BrowserThread::UI, &message_loop_), |
| 209 io_thread_(content::BrowserThread::IO), | 209 io_thread_(content::BrowserThread::IO), |
| 210 cache_(NULL), | 210 cache_(NULL), |
| 211 file_system_(NULL), | 211 file_system_(NULL), |
| 212 mock_drive_service_(NULL), | 212 mock_drive_service_(NULL), |
| 213 mock_webapps_registry_(NULL), | 213 mock_webapps_registry_(NULL), |
| 214 num_callback_invocations_(0), | 214 num_callback_invocations_(0), |
| 215 expected_error_(DRIVE_FILE_OK), | 215 expected_error_(DRIVE_FILE_OK), |
| 216 expected_cache_state_(0), | 216 expected_cache_state_(0), |
| 217 expected_sub_dir_type_(DriveCache::CACHE_TYPE_META), | 217 expected_sub_dir_type_(DriveCache::CACHE_TYPE_META), |
| 218 expected_success_(true), | 218 expected_success_(true), |
| 219 expect_outgoing_symlink_(false), | 219 expect_outgoing_symlink_(false), |
| 220 root_feed_changestamp_(0) { | 220 root_feed_changestamp_(0) { |
| 221 } | 221 } |
| 222 | 222 |
| 223 virtual void SetUp() OVERRIDE { | 223 virtual void SetUp() OVERRIDE { |
| 224 chromeos::CrosLibrary::Initialize(true /* use_stub */); | 224 chromeos::CrosLibrary::Initialize(true /* use_stub */); |
| 225 io_thread_.StartIOThread(); | 225 io_thread_.StartIOThread(); |
| 226 | 226 |
| 227 profile_.reset(new TestingProfile); | 227 profile_.reset(new TestingProfile); |
| 228 | 228 |
| 229 callback_helper_ = new CallbackHelper; | 229 callback_helper_ = new CallbackHelper; |
| 230 | 230 |
| 231 // Allocate and keep a pointer to the mock, and inject it into the | 231 // Allocate and keep a pointer to the mock, and inject it into the |
| 232 // GDataFileSystem object, which will own the mock object. | 232 // DriveFileSystem object, which will own the mock object. |
| 233 mock_drive_service_ = new StrictMock<MockDriveService>; | 233 mock_drive_service_ = new StrictMock<MockDriveService>; |
| 234 | 234 |
| 235 EXPECT_CALL(*mock_drive_service_, Initialize(profile_.get())).Times(1); | 235 EXPECT_CALL(*mock_drive_service_, Initialize(profile_.get())).Times(1); |
| 236 | 236 |
| 237 // Likewise, this will be owned by GDataFileSystem. | 237 // Likewise, this will be owned by DriveFileSystem. |
| 238 mock_free_disk_space_checker_ = new StrictMock<MockFreeDiskSpaceGetter>; | 238 mock_free_disk_space_checker_ = new StrictMock<MockFreeDiskSpaceGetter>; |
| 239 SetFreeDiskSpaceGetterForTesting(mock_free_disk_space_checker_); | 239 SetFreeDiskSpaceGetterForTesting(mock_free_disk_space_checker_); |
| 240 | 240 |
| 241 scoped_refptr<base::SequencedWorkerPool> pool = | 241 scoped_refptr<base::SequencedWorkerPool> pool = |
| 242 content::BrowserThread::GetBlockingPool(); | 242 content::BrowserThread::GetBlockingPool(); |
| 243 blocking_task_runner_ = | 243 blocking_task_runner_ = |
| 244 pool->GetSequencedTaskRunner(pool->GetSequenceToken()); | 244 pool->GetSequencedTaskRunner(pool->GetSequenceToken()); |
| 245 | 245 |
| 246 cache_ = DriveCache::CreateDriveCacheOnUIThread( | 246 cache_ = DriveCache::CreateDriveCacheOnUIThread( |
| 247 DriveCache::GetCacheRootPath(profile_.get()), blocking_task_runner_); | 247 DriveCache::GetCacheRootPath(profile_.get()), blocking_task_runner_); |
| 248 | 248 |
| 249 mock_uploader_.reset(new StrictMock<MockGDataUploader>); | 249 mock_uploader_.reset(new StrictMock<MockGDataUploader>); |
| 250 mock_webapps_registry_.reset(new StrictMock<MockDriveWebAppsRegistry>); | 250 mock_webapps_registry_.reset(new StrictMock<MockDriveWebAppsRegistry>); |
| 251 | 251 |
| 252 ASSERT_FALSE(file_system_); | 252 ASSERT_FALSE(file_system_); |
| 253 file_system_ = new GDataFileSystem(profile_.get(), | 253 file_system_ = new DriveFileSystem(profile_.get(), |
| 254 cache_, | 254 cache_, |
| 255 mock_drive_service_, | 255 mock_drive_service_, |
| 256 mock_uploader_.get(), | 256 mock_uploader_.get(), |
| 257 mock_webapps_registry_.get(), | 257 mock_webapps_registry_.get(), |
| 258 blocking_task_runner_); | 258 blocking_task_runner_); |
| 259 | 259 |
| 260 mock_cache_observer_.reset(new StrictMock<MockDriveCacheObserver>); | 260 mock_cache_observer_.reset(new StrictMock<MockDriveCacheObserver>); |
| 261 cache_->AddObserver(mock_cache_observer_.get()); | 261 cache_->AddObserver(mock_cache_observer_.get()); |
| 262 | 262 |
| 263 mock_directory_observer_.reset(new StrictMock<MockDirectoryChangeObserver>); | 263 mock_directory_observer_.reset(new StrictMock<MockDirectoryChangeObserver>); |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 return ""; | 395 return ""; |
| 396 } | 396 } |
| 397 | 397 |
| 398 // Helper function to call GetCacheEntry from origin thread. | 398 // Helper function to call GetCacheEntry from origin thread. |
| 399 bool GetCacheEntryFromOriginThread(const std::string& resource_id, | 399 bool GetCacheEntryFromOriginThread(const std::string& resource_id, |
| 400 const std::string& md5, | 400 const std::string& md5, |
| 401 DriveCacheEntry* cache_entry) { | 401 DriveCacheEntry* cache_entry) { |
| 402 bool result = false; | 402 bool result = false; |
| 403 blocking_task_runner_->PostTask( | 403 blocking_task_runner_->PostTask( |
| 404 FROM_HERE, | 404 FROM_HERE, |
| 405 base::Bind(&GDataFileSystemTest::GetCacheEntryFromOriginThreadInternal, | 405 base::Bind(&DriveFileSystemTest::GetCacheEntryFromOriginThreadInternal, |
| 406 base::Unretained(this), | 406 base::Unretained(this), |
| 407 resource_id, | 407 resource_id, |
| 408 md5, | 408 md5, |
| 409 cache_entry, | 409 cache_entry, |
| 410 &result)); | 410 &result)); |
| 411 test_util::RunBlockingPoolTask(); | 411 test_util::RunBlockingPoolTask(); |
| 412 return result; | 412 return result; |
| 413 } | 413 } |
| 414 | 414 |
| 415 // Used to implement GetCacheEntry. | 415 // Used to implement GetCacheEntry. |
| (...skipping 30 matching lines...) Expand all Loading... |
| 446 DriveFileError expected_error, | 446 DriveFileError expected_error, |
| 447 int expected_cache_state, | 447 int expected_cache_state, |
| 448 DriveCache::CacheSubDirectoryType expected_sub_dir_type) { | 448 DriveCache::CacheSubDirectoryType expected_sub_dir_type) { |
| 449 expected_error_ = expected_error; | 449 expected_error_ = expected_error; |
| 450 expected_cache_state_ = expected_cache_state; | 450 expected_cache_state_ = expected_cache_state; |
| 451 expected_sub_dir_type_ = expected_sub_dir_type; | 451 expected_sub_dir_type_ = expected_sub_dir_type; |
| 452 | 452 |
| 453 cache_->StoreOnUIThread( | 453 cache_->StoreOnUIThread( |
| 454 resource_id, md5, source_path, | 454 resource_id, md5, source_path, |
| 455 DriveCache::FILE_OPERATION_COPY, | 455 DriveCache::FILE_OPERATION_COPY, |
| 456 base::Bind(&GDataFileSystemTest::VerifyCacheFileState, | 456 base::Bind(&DriveFileSystemTest::VerifyCacheFileState, |
| 457 base::Unretained(this))); | 457 base::Unretained(this))); |
| 458 | 458 |
| 459 test_util::RunBlockingPoolTask(); | 459 test_util::RunBlockingPoolTask(); |
| 460 } | 460 } |
| 461 | 461 |
| 462 void TestPin( | 462 void TestPin( |
| 463 const std::string& resource_id, | 463 const std::string& resource_id, |
| 464 const std::string& md5, | 464 const std::string& md5, |
| 465 DriveFileError expected_error, | 465 DriveFileError expected_error, |
| 466 int expected_cache_state, | 466 int expected_cache_state, |
| 467 DriveCache::CacheSubDirectoryType expected_sub_dir_type) { | 467 DriveCache::CacheSubDirectoryType expected_sub_dir_type) { |
| 468 expected_error_ = expected_error; | 468 expected_error_ = expected_error; |
| 469 expected_cache_state_ = expected_cache_state; | 469 expected_cache_state_ = expected_cache_state; |
| 470 expected_sub_dir_type_ = expected_sub_dir_type; | 470 expected_sub_dir_type_ = expected_sub_dir_type; |
| 471 | 471 |
| 472 cache_->PinOnUIThread( | 472 cache_->PinOnUIThread( |
| 473 resource_id, md5, | 473 resource_id, md5, |
| 474 base::Bind(&GDataFileSystemTest::VerifyCacheFileState, | 474 base::Bind(&DriveFileSystemTest::VerifyCacheFileState, |
| 475 base::Unretained(this))); | 475 base::Unretained(this))); |
| 476 | 476 |
| 477 test_util::RunBlockingPoolTask(); | 477 test_util::RunBlockingPoolTask(); |
| 478 } | 478 } |
| 479 | 479 |
| 480 void TestMarkDirty( | 480 void TestMarkDirty( |
| 481 const std::string& resource_id, | 481 const std::string& resource_id, |
| 482 const std::string& md5, | 482 const std::string& md5, |
| 483 DriveFileError expected_error, | 483 DriveFileError expected_error, |
| 484 int expected_cache_state, | 484 int expected_cache_state, |
| 485 DriveCache::CacheSubDirectoryType expected_sub_dir_type) { | 485 DriveCache::CacheSubDirectoryType expected_sub_dir_type) { |
| 486 expected_error_ = expected_error; | 486 expected_error_ = expected_error; |
| 487 expected_cache_state_ = expected_cache_state; | 487 expected_cache_state_ = expected_cache_state; |
| 488 expected_sub_dir_type_ = expected_sub_dir_type; | 488 expected_sub_dir_type_ = expected_sub_dir_type; |
| 489 expect_outgoing_symlink_ = false; | 489 expect_outgoing_symlink_ = false; |
| 490 | 490 |
| 491 cache_->MarkDirtyOnUIThread( | 491 cache_->MarkDirtyOnUIThread( |
| 492 resource_id, md5, | 492 resource_id, md5, |
| 493 base::Bind(&GDataFileSystemTest::VerifyMarkDirty, | 493 base::Bind(&DriveFileSystemTest::VerifyMarkDirty, |
| 494 base::Unretained(this))); | 494 base::Unretained(this))); |
| 495 | 495 |
| 496 test_util::RunBlockingPoolTask(); | 496 test_util::RunBlockingPoolTask(); |
| 497 } | 497 } |
| 498 | 498 |
| 499 void VerifyMarkDirty(DriveFileError error, | 499 void VerifyMarkDirty(DriveFileError error, |
| 500 const std::string& resource_id, | 500 const std::string& resource_id, |
| 501 const std::string& md5, | 501 const std::string& md5, |
| 502 const FilePath& cache_file_path) { | 502 const FilePath& cache_file_path) { |
| 503 VerifyCacheFileState(error, resource_id, md5); | 503 VerifyCacheFileState(error, resource_id, md5); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 520 DriveFileError expected_error, | 520 DriveFileError expected_error, |
| 521 int expected_cache_state, | 521 int expected_cache_state, |
| 522 DriveCache::CacheSubDirectoryType expected_sub_dir_type) { | 522 DriveCache::CacheSubDirectoryType expected_sub_dir_type) { |
| 523 expected_error_ = expected_error; | 523 expected_error_ = expected_error; |
| 524 expected_cache_state_ = expected_cache_state; | 524 expected_cache_state_ = expected_cache_state; |
| 525 expected_sub_dir_type_ = expected_sub_dir_type; | 525 expected_sub_dir_type_ = expected_sub_dir_type; |
| 526 expect_outgoing_symlink_ = true; | 526 expect_outgoing_symlink_ = true; |
| 527 | 527 |
| 528 cache_->CommitDirtyOnUIThread( | 528 cache_->CommitDirtyOnUIThread( |
| 529 resource_id, md5, | 529 resource_id, md5, |
| 530 base::Bind(&GDataFileSystemTest::VerifyCacheFileState, | 530 base::Bind(&DriveFileSystemTest::VerifyCacheFileState, |
| 531 base::Unretained(this))); | 531 base::Unretained(this))); |
| 532 | 532 |
| 533 test_util::RunBlockingPoolTask(); | 533 test_util::RunBlockingPoolTask(); |
| 534 } | 534 } |
| 535 | 535 |
| 536 // Verify the file identified by |resource_id| and |md5| is in the expected | 536 // Verify the file identified by |resource_id| and |md5| is in the expected |
| 537 // cache state after |OpenFile|, that is, marked dirty and has no outgoing | 537 // cache state after |OpenFile|, that is, marked dirty and has no outgoing |
| 538 // symlink, etc. | 538 // symlink, etc. |
| 539 void VerifyCacheStateAfterOpenFile(DriveFileError error, | 539 void VerifyCacheStateAfterOpenFile(DriveFileError error, |
| 540 const std::string& resource_id, | 540 const std::string& resource_id, |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 841 MessageLoopForUI message_loop_; | 841 MessageLoopForUI message_loop_; |
| 842 // The order of the test threads is important, do not change the order. | 842 // The order of the test threads is important, do not change the order. |
| 843 // See also content/browser/browser_thread_impl.cc. | 843 // See also content/browser/browser_thread_impl.cc. |
| 844 content::TestBrowserThread ui_thread_; | 844 content::TestBrowserThread ui_thread_; |
| 845 content::TestBrowserThread io_thread_; | 845 content::TestBrowserThread io_thread_; |
| 846 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; | 846 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; |
| 847 scoped_ptr<TestingProfile> profile_; | 847 scoped_ptr<TestingProfile> profile_; |
| 848 scoped_refptr<CallbackHelper> callback_helper_; | 848 scoped_refptr<CallbackHelper> callback_helper_; |
| 849 DriveCache* cache_; | 849 DriveCache* cache_; |
| 850 scoped_ptr<StrictMock<MockGDataUploader> > mock_uploader_; | 850 scoped_ptr<StrictMock<MockGDataUploader> > mock_uploader_; |
| 851 GDataFileSystem* file_system_; | 851 DriveFileSystem* file_system_; |
| 852 StrictMock<MockDriveService>* mock_drive_service_; | 852 StrictMock<MockDriveService>* mock_drive_service_; |
| 853 scoped_ptr<StrictMock<MockDriveWebAppsRegistry> > mock_webapps_registry_; | 853 scoped_ptr<StrictMock<MockDriveWebAppsRegistry> > mock_webapps_registry_; |
| 854 StrictMock<MockFreeDiskSpaceGetter>* mock_free_disk_space_checker_; | 854 StrictMock<MockFreeDiskSpaceGetter>* mock_free_disk_space_checker_; |
| 855 scoped_ptr<StrictMock<MockDriveCacheObserver> > mock_cache_observer_; | 855 scoped_ptr<StrictMock<MockDriveCacheObserver> > mock_cache_observer_; |
| 856 scoped_ptr<StrictMock<MockDirectoryChangeObserver> > mock_directory_observer_; | 856 scoped_ptr<StrictMock<MockDirectoryChangeObserver> > mock_directory_observer_; |
| 857 | 857 |
| 858 int num_callback_invocations_; | 858 int num_callback_invocations_; |
| 859 DriveFileError expected_error_; | 859 DriveFileError expected_error_; |
| 860 int expected_cache_state_; | 860 int expected_cache_state_; |
| 861 DriveCache::CacheSubDirectoryType expected_sub_dir_type_; | 861 DriveCache::CacheSubDirectoryType expected_sub_dir_type_; |
| 862 bool expected_success_; | 862 bool expected_success_; |
| 863 bool expect_outgoing_symlink_; | 863 bool expect_outgoing_symlink_; |
| 864 std::string expected_file_extension_; | 864 std::string expected_file_extension_; |
| 865 int root_feed_changestamp_; | 865 int root_feed_changestamp_; |
| 866 static bool cros_initialized_; | 866 static bool cros_initialized_; |
| 867 }; | 867 }; |
| 868 | 868 |
| 869 bool GDataFileSystemTest::cros_initialized_ = false; | 869 bool DriveFileSystemTest::cros_initialized_ = false; |
| 870 | 870 |
| 871 void AsyncInitializationCallback( | 871 void AsyncInitializationCallback( |
| 872 int* counter, | 872 int* counter, |
| 873 int expected_counter, | 873 int expected_counter, |
| 874 const FilePath& expected_file_path, | 874 const FilePath& expected_file_path, |
| 875 MessageLoop* message_loop, | 875 MessageLoop* message_loop, |
| 876 DriveFileError error, | 876 DriveFileError error, |
| 877 scoped_ptr<DriveEntryProto> entry_proto) { | 877 scoped_ptr<DriveEntryProto> entry_proto) { |
| 878 ASSERT_EQ(DRIVE_FILE_OK, error); | 878 ASSERT_EQ(DRIVE_FILE_OK, error); |
| 879 ASSERT_TRUE(entry_proto.get()); | 879 ASSERT_TRUE(entry_proto.get()); |
| 880 ASSERT_TRUE(entry_proto->file_info().is_directory()); | 880 ASSERT_TRUE(entry_proto->file_info().is_directory()); |
| 881 EXPECT_EQ(expected_file_path.value(), entry_proto->base_name()); | 881 EXPECT_EQ(expected_file_path.value(), entry_proto->base_name()); |
| 882 | 882 |
| 883 (*counter)++; | 883 (*counter)++; |
| 884 if (*counter >= expected_counter) | 884 if (*counter >= expected_counter) |
| 885 message_loop->Quit(); | 885 message_loop->Quit(); |
| 886 } | 886 } |
| 887 | 887 |
| 888 TEST_F(GDataFileSystemTest, DuplicatedAsyncInitialization) { | 888 TEST_F(DriveFileSystemTest, DuplicatedAsyncInitialization) { |
| 889 int counter = 0; | 889 int counter = 0; |
| 890 GetEntryInfoCallback callback = base::Bind( | 890 GetEntryInfoCallback callback = base::Bind( |
| 891 &AsyncInitializationCallback, | 891 &AsyncInitializationCallback, |
| 892 &counter, | 892 &counter, |
| 893 2, | 893 2, |
| 894 FilePath(FILE_PATH_LITERAL("drive")), | 894 FilePath(FILE_PATH_LITERAL("drive")), |
| 895 &message_loop_); | 895 &message_loop_); |
| 896 | 896 |
| 897 EXPECT_CALL(*mock_drive_service_, GetAccountMetadata(_)).Times(1); | 897 EXPECT_CALL(*mock_drive_service_, GetAccountMetadata(_)).Times(1); |
| 898 EXPECT_CALL(*mock_drive_service_, | 898 EXPECT_CALL(*mock_drive_service_, |
| 899 GetDocuments(Eq(GURL()), _, _, _, _)).Times(1); | 899 GetDocuments(Eq(GURL()), _, _, _, _)).Times(1); |
| 900 | 900 |
| 901 EXPECT_CALL(*mock_webapps_registry_, UpdateFromFeed(_)).Times(1); | 901 EXPECT_CALL(*mock_webapps_registry_, UpdateFromFeed(_)).Times(1); |
| 902 | 902 |
| 903 file_system_->GetEntryInfoByPath( | 903 file_system_->GetEntryInfoByPath( |
| 904 FilePath(FILE_PATH_LITERAL("drive")), callback); | 904 FilePath(FILE_PATH_LITERAL("drive")), callback); |
| 905 file_system_->GetEntryInfoByPath( | 905 file_system_->GetEntryInfoByPath( |
| 906 FilePath(FILE_PATH_LITERAL("drive")), callback); | 906 FilePath(FILE_PATH_LITERAL("drive")), callback); |
| 907 message_loop_.Run(); // Wait to get our result | 907 message_loop_.Run(); // Wait to get our result |
| 908 EXPECT_EQ(2, counter); | 908 EXPECT_EQ(2, counter); |
| 909 } | 909 } |
| 910 | 910 |
| 911 TEST_F(GDataFileSystemTest, SearchRootDirectory) { | 911 TEST_F(DriveFileSystemTest, SearchRootDirectory) { |
| 912 LoadRootFeedDocument("root_feed.json"); | 912 LoadRootFeedDocument("root_feed.json"); |
| 913 | 913 |
| 914 const FilePath kFilePath = FilePath(FILE_PATH_LITERAL("drive")); | 914 const FilePath kFilePath = FilePath(FILE_PATH_LITERAL("drive")); |
| 915 scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync( | 915 scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync( |
| 916 FilePath(FILE_PATH_LITERAL(kFilePath))); | 916 FilePath(FILE_PATH_LITERAL(kFilePath))); |
| 917 ASSERT_TRUE(entry.get()); | 917 ASSERT_TRUE(entry.get()); |
| 918 EXPECT_EQ(kDriveRootDirectoryResourceId, entry->resource_id()); | 918 EXPECT_EQ(kDriveRootDirectoryResourceId, entry->resource_id()); |
| 919 } | 919 } |
| 920 | 920 |
| 921 TEST_F(GDataFileSystemTest, SearchExistingFile) { | 921 TEST_F(DriveFileSystemTest, SearchExistingFile) { |
| 922 LoadRootFeedDocument("root_feed.json"); | 922 LoadRootFeedDocument("root_feed.json"); |
| 923 | 923 |
| 924 const FilePath kFilePath = FilePath( | 924 const FilePath kFilePath = FilePath( |
| 925 FILE_PATH_LITERAL("drive/File 1.txt")); | 925 FILE_PATH_LITERAL("drive/File 1.txt")); |
| 926 scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync(kFilePath); | 926 scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync(kFilePath); |
| 927 ASSERT_TRUE(entry.get()); | 927 ASSERT_TRUE(entry.get()); |
| 928 EXPECT_EQ("file:2_file_resource_id", entry->resource_id()); | 928 EXPECT_EQ("file:2_file_resource_id", entry->resource_id()); |
| 929 } | 929 } |
| 930 | 930 |
| 931 TEST_F(GDataFileSystemTest, SearchExistingDocument) { | 931 TEST_F(DriveFileSystemTest, SearchExistingDocument) { |
| 932 LoadRootFeedDocument("root_feed.json"); | 932 LoadRootFeedDocument("root_feed.json"); |
| 933 | 933 |
| 934 const FilePath kFilePath = FilePath( | 934 const FilePath kFilePath = FilePath( |
| 935 FILE_PATH_LITERAL("drive/Document 1.gdoc")); | 935 FILE_PATH_LITERAL("drive/Document 1.gdoc")); |
| 936 scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync(kFilePath); | 936 scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync(kFilePath); |
| 937 ASSERT_TRUE(entry.get()); | 937 ASSERT_TRUE(entry.get()); |
| 938 EXPECT_EQ("document:5_document_resource_id", entry->resource_id()); | 938 EXPECT_EQ("document:5_document_resource_id", entry->resource_id()); |
| 939 } | 939 } |
| 940 | 940 |
| 941 TEST_F(GDataFileSystemTest, SearchNonExistingFile) { | 941 TEST_F(DriveFileSystemTest, SearchNonExistingFile) { |
| 942 LoadRootFeedDocument("root_feed.json"); | 942 LoadRootFeedDocument("root_feed.json"); |
| 943 | 943 |
| 944 const FilePath kFilePath = FilePath( | 944 const FilePath kFilePath = FilePath( |
| 945 FILE_PATH_LITERAL("drive/nonexisting.file")); | 945 FILE_PATH_LITERAL("drive/nonexisting.file")); |
| 946 scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync(kFilePath); | 946 scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync(kFilePath); |
| 947 ASSERT_FALSE(entry.get()); | 947 ASSERT_FALSE(entry.get()); |
| 948 } | 948 } |
| 949 | 949 |
| 950 TEST_F(GDataFileSystemTest, SearchEncodedFileNames) { | 950 TEST_F(DriveFileSystemTest, SearchEncodedFileNames) { |
| 951 LoadRootFeedDocument("root_feed.json"); | 951 LoadRootFeedDocument("root_feed.json"); |
| 952 | 952 |
| 953 const FilePath kFilePath1 = FilePath( | 953 const FilePath kFilePath1 = FilePath( |
| 954 FILE_PATH_LITERAL("drive/Slash / in file 1.txt")); | 954 FILE_PATH_LITERAL("drive/Slash / in file 1.txt")); |
| 955 scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync(kFilePath1); | 955 scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync(kFilePath1); |
| 956 ASSERT_FALSE(entry.get()); | 956 ASSERT_FALSE(entry.get()); |
| 957 | 957 |
| 958 const FilePath kFilePath2 = FilePath::FromUTF8Unsafe( | 958 const FilePath kFilePath2 = FilePath::FromUTF8Unsafe( |
| 959 "drive/Slash \xE2\x88\x95 in file 1.txt"); | 959 "drive/Slash \xE2\x88\x95 in file 1.txt"); |
| 960 entry = GetEntryInfoByPathSync(kFilePath2); | 960 entry = GetEntryInfoByPathSync(kFilePath2); |
| 961 ASSERT_TRUE(entry.get()); | 961 ASSERT_TRUE(entry.get()); |
| 962 EXPECT_EQ("file:slash_file_resource_id", entry->resource_id()); | 962 EXPECT_EQ("file:slash_file_resource_id", entry->resource_id()); |
| 963 | 963 |
| 964 const FilePath kFilePath3 = FilePath::FromUTF8Unsafe( | 964 const FilePath kFilePath3 = FilePath::FromUTF8Unsafe( |
| 965 "drive/Slash \xE2\x88\x95 in directory/Slash SubDir File.txt"); | 965 "drive/Slash \xE2\x88\x95 in directory/Slash SubDir File.txt"); |
| 966 entry = GetEntryInfoByPathSync(kFilePath3); | 966 entry = GetEntryInfoByPathSync(kFilePath3); |
| 967 ASSERT_TRUE(entry.get()); | 967 ASSERT_TRUE(entry.get()); |
| 968 EXPECT_EQ("file:slash_subdir_file", entry->resource_id()); | 968 EXPECT_EQ("file:slash_subdir_file", entry->resource_id()); |
| 969 } | 969 } |
| 970 | 970 |
| 971 TEST_F(GDataFileSystemTest, SearchEncodedFileNamesLoadingRoot) { | 971 TEST_F(DriveFileSystemTest, SearchEncodedFileNamesLoadingRoot) { |
| 972 LoadRootFeedDocument("root_feed.json"); | 972 LoadRootFeedDocument("root_feed.json"); |
| 973 | 973 |
| 974 const FilePath kFilePath1 = FilePath( | 974 const FilePath kFilePath1 = FilePath( |
| 975 FILE_PATH_LITERAL("drive/Slash / in file 1.txt")); | 975 FILE_PATH_LITERAL("drive/Slash / in file 1.txt")); |
| 976 scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync(kFilePath1); | 976 scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync(kFilePath1); |
| 977 ASSERT_FALSE(entry.get()); | 977 ASSERT_FALSE(entry.get()); |
| 978 | 978 |
| 979 const FilePath kFilePath2 = FilePath::FromUTF8Unsafe( | 979 const FilePath kFilePath2 = FilePath::FromUTF8Unsafe( |
| 980 "drive/Slash \xE2\x88\x95 in file 1.txt"); | 980 "drive/Slash \xE2\x88\x95 in file 1.txt"); |
| 981 entry = GetEntryInfoByPathSync(kFilePath2); | 981 entry = GetEntryInfoByPathSync(kFilePath2); |
| 982 ASSERT_TRUE(entry.get()); | 982 ASSERT_TRUE(entry.get()); |
| 983 EXPECT_EQ("file:slash_file_resource_id", entry->resource_id()); | 983 EXPECT_EQ("file:slash_file_resource_id", entry->resource_id()); |
| 984 | 984 |
| 985 const FilePath kFilePath3 = FilePath::FromUTF8Unsafe( | 985 const FilePath kFilePath3 = FilePath::FromUTF8Unsafe( |
| 986 "drive/Slash \xE2\x88\x95 in directory/Slash SubDir File.txt"); | 986 "drive/Slash \xE2\x88\x95 in directory/Slash SubDir File.txt"); |
| 987 entry = GetEntryInfoByPathSync(kFilePath3); | 987 entry = GetEntryInfoByPathSync(kFilePath3); |
| 988 ASSERT_TRUE(entry.get()); | 988 ASSERT_TRUE(entry.get()); |
| 989 EXPECT_EQ("file:slash_subdir_file", entry->resource_id()); | 989 EXPECT_EQ("file:slash_subdir_file", entry->resource_id()); |
| 990 } | 990 } |
| 991 | 991 |
| 992 TEST_F(GDataFileSystemTest, SearchDuplicateNames) { | 992 TEST_F(DriveFileSystemTest, SearchDuplicateNames) { |
| 993 LoadRootFeedDocument("root_feed.json"); | 993 LoadRootFeedDocument("root_feed.json"); |
| 994 | 994 |
| 995 const FilePath kFilePath1 = FilePath( | 995 const FilePath kFilePath1 = FilePath( |
| 996 FILE_PATH_LITERAL("drive/Duplicate Name.txt")); | 996 FILE_PATH_LITERAL("drive/Duplicate Name.txt")); |
| 997 scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync(kFilePath1); | 997 scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync(kFilePath1); |
| 998 ASSERT_TRUE(entry.get()); | 998 ASSERT_TRUE(entry.get()); |
| 999 EXPECT_EQ("file:3_file_resource_id", entry->resource_id()); | 999 EXPECT_EQ("file:3_file_resource_id", entry->resource_id()); |
| 1000 | 1000 |
| 1001 const FilePath kFilePath2 = FilePath( | 1001 const FilePath kFilePath2 = FilePath( |
| 1002 FILE_PATH_LITERAL("drive/Duplicate Name (2).txt")); | 1002 FILE_PATH_LITERAL("drive/Duplicate Name (2).txt")); |
| 1003 entry = GetEntryInfoByPathSync(kFilePath2); | 1003 entry = GetEntryInfoByPathSync(kFilePath2); |
| 1004 ASSERT_TRUE(entry.get()); | 1004 ASSERT_TRUE(entry.get()); |
| 1005 EXPECT_EQ("file:4_file_resource_id", entry->resource_id()); | 1005 EXPECT_EQ("file:4_file_resource_id", entry->resource_id()); |
| 1006 } | 1006 } |
| 1007 | 1007 |
| 1008 TEST_F(GDataFileSystemTest, SearchExistingDirectory) { | 1008 TEST_F(DriveFileSystemTest, SearchExistingDirectory) { |
| 1009 LoadRootFeedDocument("root_feed.json"); | 1009 LoadRootFeedDocument("root_feed.json"); |
| 1010 | 1010 |
| 1011 const FilePath kFilePath = FilePath( | 1011 const FilePath kFilePath = FilePath( |
| 1012 FILE_PATH_LITERAL("drive/Directory 1")); | 1012 FILE_PATH_LITERAL("drive/Directory 1")); |
| 1013 scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync(kFilePath); | 1013 scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync(kFilePath); |
| 1014 ASSERT_TRUE(entry.get()); | 1014 ASSERT_TRUE(entry.get()); |
| 1015 ASSERT_EQ("folder:1_folder_resource_id", entry->resource_id()); | 1015 ASSERT_EQ("folder:1_folder_resource_id", entry->resource_id()); |
| 1016 } | 1016 } |
| 1017 | 1017 |
| 1018 TEST_F(GDataFileSystemTest, SearchInSubdir) { | 1018 TEST_F(DriveFileSystemTest, SearchInSubdir) { |
| 1019 LoadRootFeedDocument("root_feed.json"); | 1019 LoadRootFeedDocument("root_feed.json"); |
| 1020 | 1020 |
| 1021 const FilePath kFilePath = FilePath( | 1021 const FilePath kFilePath = FilePath( |
| 1022 FILE_PATH_LITERAL("drive/Directory 1/SubDirectory File 1.txt")); | 1022 FILE_PATH_LITERAL("drive/Directory 1/SubDirectory File 1.txt")); |
| 1023 scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync(kFilePath); | 1023 scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync(kFilePath); |
| 1024 ASSERT_TRUE(entry.get()); | 1024 ASSERT_TRUE(entry.get()); |
| 1025 ASSERT_EQ("file:subdirectory_file_1_id", entry->resource_id()); | 1025 ASSERT_EQ("file:subdirectory_file_1_id", entry->resource_id()); |
| 1026 } | 1026 } |
| 1027 | 1027 |
| 1028 // Check the reconstruction of the directory structure from only the root feed. | 1028 // Check the reconstruction of the directory structure from only the root feed. |
| 1029 TEST_F(GDataFileSystemTest, SearchInSubSubdir) { | 1029 TEST_F(DriveFileSystemTest, SearchInSubSubdir) { |
| 1030 LoadRootFeedDocument("root_feed.json"); | 1030 LoadRootFeedDocument("root_feed.json"); |
| 1031 | 1031 |
| 1032 const FilePath kFilePath = FilePath( | 1032 const FilePath kFilePath = FilePath( |
| 1033 FILE_PATH_LITERAL("drive/Directory 1/Sub Directory Folder/" | 1033 FILE_PATH_LITERAL("drive/Directory 1/Sub Directory Folder/" |
| 1034 "Sub Sub Directory Folder")); | 1034 "Sub Sub Directory Folder")); |
| 1035 scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync(kFilePath); | 1035 scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync(kFilePath); |
| 1036 ASSERT_TRUE(entry.get()); | 1036 ASSERT_TRUE(entry.get()); |
| 1037 ASSERT_EQ("folder:sub_sub_directory_folder_id", entry->resource_id()); | 1037 ASSERT_EQ("folder:sub_sub_directory_folder_id", entry->resource_id()); |
| 1038 } | 1038 } |
| 1039 | 1039 |
| 1040 TEST_F(GDataFileSystemTest, FilePathTests) { | 1040 TEST_F(DriveFileSystemTest, FilePathTests) { |
| 1041 LoadRootFeedDocument("root_feed.json"); | 1041 LoadRootFeedDocument("root_feed.json"); |
| 1042 | 1042 |
| 1043 EXPECT_TRUE(EntryExists(FilePath(FILE_PATH_LITERAL("drive/File 1.txt")))); | 1043 EXPECT_TRUE(EntryExists(FilePath(FILE_PATH_LITERAL("drive/File 1.txt")))); |
| 1044 EXPECT_TRUE(EntryExists(FilePath(FILE_PATH_LITERAL("drive/Directory 1")))); | 1044 EXPECT_TRUE(EntryExists(FilePath(FILE_PATH_LITERAL("drive/Directory 1")))); |
| 1045 EXPECT_TRUE(EntryExists( | 1045 EXPECT_TRUE(EntryExists( |
| 1046 FilePath( | 1046 FilePath( |
| 1047 FILE_PATH_LITERAL("drive/Directory 1/SubDirectory File 1.txt")))); | 1047 FILE_PATH_LITERAL("drive/Directory 1/SubDirectory File 1.txt")))); |
| 1048 } | 1048 } |
| 1049 | 1049 |
| 1050 TEST_F(GDataFileSystemTest, ChangeFeed_AddAndDeleteFileInRoot) { | 1050 TEST_F(DriveFileSystemTest, ChangeFeed_AddAndDeleteFileInRoot) { |
| 1051 int latest_changelog = 0; | 1051 int latest_changelog = 0; |
| 1052 LoadRootFeedDocument("root_feed.json"); | 1052 LoadRootFeedDocument("root_feed.json"); |
| 1053 | 1053 |
| 1054 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( | 1054 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| 1055 Eq(FilePath(FILE_PATH_LITERAL("drive"))))).Times(2); | 1055 Eq(FilePath(FILE_PATH_LITERAL("drive"))))).Times(2); |
| 1056 | 1056 |
| 1057 LoadChangeFeed("delta_file_added_in_root.json", ++latest_changelog); | 1057 LoadChangeFeed("delta_file_added_in_root.json", ++latest_changelog); |
| 1058 EXPECT_TRUE( | 1058 EXPECT_TRUE( |
| 1059 EntryExists(FilePath(FILE_PATH_LITERAL("drive/Added file.gdoc")))); | 1059 EntryExists(FilePath(FILE_PATH_LITERAL("drive/Added file.gdoc")))); |
| 1060 | 1060 |
| 1061 LoadChangeFeed("delta_file_deleted_in_root.json", ++latest_changelog); | 1061 LoadChangeFeed("delta_file_deleted_in_root.json", ++latest_changelog); |
| 1062 EXPECT_FALSE( | 1062 EXPECT_FALSE( |
| 1063 EntryExists(FilePath(FILE_PATH_LITERAL("drive/Added file.gdoc")))); | 1063 EntryExists(FilePath(FILE_PATH_LITERAL("drive/Added file.gdoc")))); |
| 1064 } | 1064 } |
| 1065 | 1065 |
| 1066 | 1066 |
| 1067 TEST_F(GDataFileSystemTest, ChangeFeed_AddAndDeleteFileFromExistingDirectory) { | 1067 TEST_F(DriveFileSystemTest, ChangeFeed_AddAndDeleteFileFromExistingDirectory) { |
| 1068 int latest_changelog = 0; | 1068 int latest_changelog = 0; |
| 1069 LoadRootFeedDocument("root_feed.json"); | 1069 LoadRootFeedDocument("root_feed.json"); |
| 1070 | 1070 |
| 1071 EXPECT_TRUE(EntryExists(FilePath( | 1071 EXPECT_TRUE(EntryExists(FilePath( |
| 1072 FILE_PATH_LITERAL("drive/Directory 1")))); | 1072 FILE_PATH_LITERAL("drive/Directory 1")))); |
| 1073 | 1073 |
| 1074 // Add file to an existing directory. | 1074 // Add file to an existing directory. |
| 1075 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( | 1075 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| 1076 Eq(FilePath(FILE_PATH_LITERAL("drive"))))).Times(1); | 1076 Eq(FilePath(FILE_PATH_LITERAL("drive"))))).Times(1); |
| 1077 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( | 1077 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| 1078 Eq(FilePath(FILE_PATH_LITERAL("drive/Directory 1"))))).Times(1); | 1078 Eq(FilePath(FILE_PATH_LITERAL("drive/Directory 1"))))).Times(1); |
| 1079 LoadChangeFeed("delta_file_added_in_directory.json", ++latest_changelog); | 1079 LoadChangeFeed("delta_file_added_in_directory.json", ++latest_changelog); |
| 1080 EXPECT_TRUE(EntryExists(FilePath( | 1080 EXPECT_TRUE(EntryExists(FilePath( |
| 1081 FILE_PATH_LITERAL("drive/Directory 1/Added file.gdoc")))); | 1081 FILE_PATH_LITERAL("drive/Directory 1/Added file.gdoc")))); |
| 1082 | 1082 |
| 1083 // Remove that file from the directory. | 1083 // Remove that file from the directory. |
| 1084 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( | 1084 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| 1085 Eq(FilePath(FILE_PATH_LITERAL("drive/Directory 1"))))).Times(1); | 1085 Eq(FilePath(FILE_PATH_LITERAL("drive/Directory 1"))))).Times(1); |
| 1086 LoadChangeFeed("delta_file_deleted_in_directory.json", ++latest_changelog); | 1086 LoadChangeFeed("delta_file_deleted_in_directory.json", ++latest_changelog); |
| 1087 EXPECT_TRUE(EntryExists(FilePath( | 1087 EXPECT_TRUE(EntryExists(FilePath( |
| 1088 FILE_PATH_LITERAL("drive/Directory 1")))); | 1088 FILE_PATH_LITERAL("drive/Directory 1")))); |
| 1089 EXPECT_FALSE(EntryExists(FilePath( | 1089 EXPECT_FALSE(EntryExists(FilePath( |
| 1090 FILE_PATH_LITERAL("drive/Directory 1/Added file.gdoc")))); | 1090 FILE_PATH_LITERAL("drive/Directory 1/Added file.gdoc")))); |
| 1091 } | 1091 } |
| 1092 | 1092 |
| 1093 TEST_F(GDataFileSystemTest, ChangeFeed_AddFileToNewDirectory) { | 1093 TEST_F(DriveFileSystemTest, ChangeFeed_AddFileToNewDirectory) { |
| 1094 int latest_changelog = 0; | 1094 int latest_changelog = 0; |
| 1095 LoadRootFeedDocument("root_feed.json"); | 1095 LoadRootFeedDocument("root_feed.json"); |
| 1096 // Add file to a new directory. | 1096 // Add file to a new directory. |
| 1097 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( | 1097 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| 1098 Eq(FilePath(FILE_PATH_LITERAL("drive"))))).Times(1); | 1098 Eq(FilePath(FILE_PATH_LITERAL("drive"))))).Times(1); |
| 1099 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( | 1099 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| 1100 Eq(FilePath(FILE_PATH_LITERAL("drive/New Directory"))))).Times(1); | 1100 Eq(FilePath(FILE_PATH_LITERAL("drive/New Directory"))))).Times(1); |
| 1101 | 1101 |
| 1102 LoadChangeFeed("delta_file_added_in_new_directory.json", ++latest_changelog); | 1102 LoadChangeFeed("delta_file_added_in_new_directory.json", ++latest_changelog); |
| 1103 | 1103 |
| 1104 EXPECT_TRUE(EntryExists(FilePath( | 1104 EXPECT_TRUE(EntryExists(FilePath( |
| 1105 FILE_PATH_LITERAL("drive/New Directory")))); | 1105 FILE_PATH_LITERAL("drive/New Directory")))); |
| 1106 EXPECT_TRUE(EntryExists(FilePath( | 1106 EXPECT_TRUE(EntryExists(FilePath( |
| 1107 FILE_PATH_LITERAL("drive/New Directory/File in new dir.gdoc")))); | 1107 FILE_PATH_LITERAL("drive/New Directory/File in new dir.gdoc")))); |
| 1108 } | 1108 } |
| 1109 | 1109 |
| 1110 TEST_F(GDataFileSystemTest, ChangeFeed_AddFileToNewButDeletedDirectory) { | 1110 TEST_F(DriveFileSystemTest, ChangeFeed_AddFileToNewButDeletedDirectory) { |
| 1111 int latest_changelog = 0; | 1111 int latest_changelog = 0; |
| 1112 LoadRootFeedDocument("root_feed.json"); | 1112 LoadRootFeedDocument("root_feed.json"); |
| 1113 | 1113 |
| 1114 // This feed contains thw following updates: | 1114 // This feed contains thw following updates: |
| 1115 // 1) A new PDF file is added to a new directory | 1115 // 1) A new PDF file is added to a new directory |
| 1116 // 2) but the new directory is marked "deleted" (i.e. moved to Trash) | 1116 // 2) but the new directory is marked "deleted" (i.e. moved to Trash) |
| 1117 // Hence, the PDF file should be just ignored. | 1117 // Hence, the PDF file should be just ignored. |
| 1118 LoadChangeFeed("delta_file_added_in_new_but_deleted_directory.json", | 1118 LoadChangeFeed("delta_file_added_in_new_but_deleted_directory.json", |
| 1119 ++latest_changelog); | 1119 ++latest_changelog); |
| 1120 } | 1120 } |
| 1121 | 1121 |
| 1122 TEST_F(GDataFileSystemTest, ChangeFeed_DirectoryMovedFromRootToDirectory) { | 1122 TEST_F(DriveFileSystemTest, ChangeFeed_DirectoryMovedFromRootToDirectory) { |
| 1123 int latest_changelog = 0; | 1123 int latest_changelog = 0; |
| 1124 LoadRootFeedDocument("root_feed.json"); | 1124 LoadRootFeedDocument("root_feed.json"); |
| 1125 | 1125 |
| 1126 EXPECT_TRUE(EntryExists(FilePath(FILE_PATH_LITERAL( | 1126 EXPECT_TRUE(EntryExists(FilePath(FILE_PATH_LITERAL( |
| 1127 "drive/Directory 2")))); | 1127 "drive/Directory 2")))); |
| 1128 EXPECT_TRUE(EntryExists(FilePath(FILE_PATH_LITERAL( | 1128 EXPECT_TRUE(EntryExists(FilePath(FILE_PATH_LITERAL( |
| 1129 "drive/Directory 1")))); | 1129 "drive/Directory 1")))); |
| 1130 EXPECT_TRUE(EntryExists(FilePath(FILE_PATH_LITERAL( | 1130 EXPECT_TRUE(EntryExists(FilePath(FILE_PATH_LITERAL( |
| 1131 "drive/Directory 1/SubDirectory File 1.txt")))); | 1131 "drive/Directory 1/SubDirectory File 1.txt")))); |
| 1132 EXPECT_TRUE(EntryExists(FilePath(FILE_PATH_LITERAL( | 1132 EXPECT_TRUE(EntryExists(FilePath(FILE_PATH_LITERAL( |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1152 "drive/Directory 2/Directory 1")))); | 1152 "drive/Directory 2/Directory 1")))); |
| 1153 EXPECT_TRUE(EntryExists(FilePath(FILE_PATH_LITERAL( | 1153 EXPECT_TRUE(EntryExists(FilePath(FILE_PATH_LITERAL( |
| 1154 "drive/Directory 2/Directory 1/SubDirectory File 1.txt")))); | 1154 "drive/Directory 2/Directory 1/SubDirectory File 1.txt")))); |
| 1155 EXPECT_TRUE(EntryExists(FilePath(FILE_PATH_LITERAL( | 1155 EXPECT_TRUE(EntryExists(FilePath(FILE_PATH_LITERAL( |
| 1156 "drive/Directory 2/Directory 1/Sub Directory Folder")))); | 1156 "drive/Directory 2/Directory 1/Sub Directory Folder")))); |
| 1157 EXPECT_TRUE(EntryExists(FilePath(FILE_PATH_LITERAL( | 1157 EXPECT_TRUE(EntryExists(FilePath(FILE_PATH_LITERAL( |
| 1158 "drive/Directory 2/Directory 1/Sub Directory Folder/" | 1158 "drive/Directory 2/Directory 1/Sub Directory Folder/" |
| 1159 "Sub Sub Directory Folder")))); | 1159 "Sub Sub Directory Folder")))); |
| 1160 } | 1160 } |
| 1161 | 1161 |
| 1162 TEST_F(GDataFileSystemTest, ChangeFeed_FileMovedFromDirectoryToRoot) { | 1162 TEST_F(DriveFileSystemTest, ChangeFeed_FileMovedFromDirectoryToRoot) { |
| 1163 int latest_changelog = 0; | 1163 int latest_changelog = 0; |
| 1164 LoadRootFeedDocument("root_feed.json"); | 1164 LoadRootFeedDocument("root_feed.json"); |
| 1165 | 1165 |
| 1166 EXPECT_TRUE(EntryExists(FilePath(FILE_PATH_LITERAL( | 1166 EXPECT_TRUE(EntryExists(FilePath(FILE_PATH_LITERAL( |
| 1167 "drive/Directory 1")))); | 1167 "drive/Directory 1")))); |
| 1168 EXPECT_TRUE(EntryExists(FilePath(FILE_PATH_LITERAL( | 1168 EXPECT_TRUE(EntryExists(FilePath(FILE_PATH_LITERAL( |
| 1169 "drive/Directory 1/Sub Directory Folder")))); | 1169 "drive/Directory 1/Sub Directory Folder")))); |
| 1170 EXPECT_TRUE(EntryExists(FilePath(FILE_PATH_LITERAL( | 1170 EXPECT_TRUE(EntryExists(FilePath(FILE_PATH_LITERAL( |
| 1171 "drive/Directory 1/Sub Directory Folder/Sub Sub Directory Folder")))); | 1171 "drive/Directory 1/Sub Directory Folder/Sub Sub Directory Folder")))); |
| 1172 EXPECT_TRUE(EntryExists(FilePath(FILE_PATH_LITERAL( | 1172 EXPECT_TRUE(EntryExists(FilePath(FILE_PATH_LITERAL( |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1184 EXPECT_TRUE(EntryExists(FilePath(FILE_PATH_LITERAL( | 1184 EXPECT_TRUE(EntryExists(FilePath(FILE_PATH_LITERAL( |
| 1185 "drive/Directory 1/Sub Directory Folder")))); | 1185 "drive/Directory 1/Sub Directory Folder")))); |
| 1186 EXPECT_TRUE(EntryExists(FilePath(FILE_PATH_LITERAL( | 1186 EXPECT_TRUE(EntryExists(FilePath(FILE_PATH_LITERAL( |
| 1187 "drive/Directory 1/Sub Directory Folder/Sub Sub Directory Folder")))); | 1187 "drive/Directory 1/Sub Directory Folder/Sub Sub Directory Folder")))); |
| 1188 EXPECT_FALSE(EntryExists(FilePath(FILE_PATH_LITERAL( | 1188 EXPECT_FALSE(EntryExists(FilePath(FILE_PATH_LITERAL( |
| 1189 "drive/Directory 1/SubDirectory File 1.txt")))); | 1189 "drive/Directory 1/SubDirectory File 1.txt")))); |
| 1190 EXPECT_TRUE(EntryExists(FilePath(FILE_PATH_LITERAL( | 1190 EXPECT_TRUE(EntryExists(FilePath(FILE_PATH_LITERAL( |
| 1191 "drive/SubDirectory File 1.txt")))); | 1191 "drive/SubDirectory File 1.txt")))); |
| 1192 } | 1192 } |
| 1193 | 1193 |
| 1194 TEST_F(GDataFileSystemTest, ChangeFeed_FileRenamedInDirectory) { | 1194 TEST_F(DriveFileSystemTest, ChangeFeed_FileRenamedInDirectory) { |
| 1195 int latest_changelog = 0; | 1195 int latest_changelog = 0; |
| 1196 LoadRootFeedDocument("root_feed.json"); | 1196 LoadRootFeedDocument("root_feed.json"); |
| 1197 | 1197 |
| 1198 EXPECT_TRUE(EntryExists(FilePath(FILE_PATH_LITERAL( | 1198 EXPECT_TRUE(EntryExists(FilePath(FILE_PATH_LITERAL( |
| 1199 "drive/Directory 1")))); | 1199 "drive/Directory 1")))); |
| 1200 EXPECT_TRUE(EntryExists(FilePath(FILE_PATH_LITERAL( | 1200 EXPECT_TRUE(EntryExists(FilePath(FILE_PATH_LITERAL( |
| 1201 "drive/Directory 1/SubDirectory File 1.txt")))); | 1201 "drive/Directory 1/SubDirectory File 1.txt")))); |
| 1202 | 1202 |
| 1203 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( | 1203 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| 1204 Eq(FilePath(FILE_PATH_LITERAL("drive"))))).Times(1); | 1204 Eq(FilePath(FILE_PATH_LITERAL("drive"))))).Times(1); |
| 1205 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( | 1205 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| 1206 Eq(FilePath(FILE_PATH_LITERAL("drive/Directory 1"))))).Times(1); | 1206 Eq(FilePath(FILE_PATH_LITERAL("drive/Directory 1"))))).Times(1); |
| 1207 LoadChangeFeed("delta_file_renamed_in_directory.json", | 1207 LoadChangeFeed("delta_file_renamed_in_directory.json", |
| 1208 ++latest_changelog); | 1208 ++latest_changelog); |
| 1209 | 1209 |
| 1210 EXPECT_TRUE(EntryExists(FilePath(FILE_PATH_LITERAL( | 1210 EXPECT_TRUE(EntryExists(FilePath(FILE_PATH_LITERAL( |
| 1211 "drive/Directory 1")))); | 1211 "drive/Directory 1")))); |
| 1212 EXPECT_FALSE(EntryExists(FilePath(FILE_PATH_LITERAL( | 1212 EXPECT_FALSE(EntryExists(FilePath(FILE_PATH_LITERAL( |
| 1213 "drive/Directory 1/SubDirectory File 1.txt")))); | 1213 "drive/Directory 1/SubDirectory File 1.txt")))); |
| 1214 EXPECT_TRUE(EntryExists(FilePath(FILE_PATH_LITERAL( | 1214 EXPECT_TRUE(EntryExists(FilePath(FILE_PATH_LITERAL( |
| 1215 "drive/Directory 1/New SubDirectory File 1.txt")))); | 1215 "drive/Directory 1/New SubDirectory File 1.txt")))); |
| 1216 } | 1216 } |
| 1217 | 1217 |
| 1218 TEST_F(GDataFileSystemTest, CachedFeedLoading) { | 1218 TEST_F(DriveFileSystemTest, CachedFeedLoading) { |
| 1219 SaveTestFileSystem(); | 1219 SaveTestFileSystem(); |
| 1220 TestLoadMetadataFromCache(); | 1220 TestLoadMetadataFromCache(); |
| 1221 | 1221 |
| 1222 EXPECT_TRUE(EntryExists(FilePath(FILE_PATH_LITERAL("drive/File1")))); | 1222 EXPECT_TRUE(EntryExists(FilePath(FILE_PATH_LITERAL("drive/File1")))); |
| 1223 EXPECT_TRUE(EntryExists(FilePath(FILE_PATH_LITERAL("drive/Dir1")))); | 1223 EXPECT_TRUE(EntryExists(FilePath(FILE_PATH_LITERAL("drive/Dir1")))); |
| 1224 EXPECT_TRUE(EntryExists(FilePath(FILE_PATH_LITERAL("drive/Dir1/File2")))); | 1224 EXPECT_TRUE(EntryExists(FilePath(FILE_PATH_LITERAL("drive/Dir1/File2")))); |
| 1225 EXPECT_TRUE(EntryExists(FilePath(FILE_PATH_LITERAL("drive/Dir1/SubDir2")))); | 1225 EXPECT_TRUE(EntryExists(FilePath(FILE_PATH_LITERAL("drive/Dir1/SubDir2")))); |
| 1226 EXPECT_TRUE(EntryExists( | 1226 EXPECT_TRUE(EntryExists( |
| 1227 FilePath(FILE_PATH_LITERAL("drive/Dir1/SubDir2/File3")))); | 1227 FilePath(FILE_PATH_LITERAL("drive/Dir1/SubDir2/File3")))); |
| 1228 } | 1228 } |
| 1229 | 1229 |
| 1230 TEST_F(GDataFileSystemTest, CachedFeadLoadingThenServerFeedLoading) { | 1230 TEST_F(DriveFileSystemTest, CachedFeadLoadingThenServerFeedLoading) { |
| 1231 SaveTestFileSystem(); | 1231 SaveTestFileSystem(); |
| 1232 | 1232 |
| 1233 // SaveTestFileSystem and "account_metadata.json" have the same changestamp, | 1233 // SaveTestFileSystem and "account_metadata.json" have the same changestamp, |
| 1234 // so no request for new feeds (i.e., call to GetDocuments) should happen. | 1234 // so no request for new feeds (i.e., call to GetDocuments) should happen. |
| 1235 mock_drive_service_->set_account_metadata( | 1235 mock_drive_service_->set_account_metadata( |
| 1236 LoadJSONFile("account_metadata.json")); | 1236 LoadJSONFile("account_metadata.json")); |
| 1237 EXPECT_CALL(*mock_drive_service_, GetAccountMetadata(_)).Times(1); | 1237 EXPECT_CALL(*mock_drive_service_, GetAccountMetadata(_)).Times(1); |
| 1238 EXPECT_CALL(*mock_webapps_registry_, UpdateFromFeed(_)).Times(1); | 1238 EXPECT_CALL(*mock_webapps_registry_, UpdateFromFeed(_)).Times(1); |
| 1239 EXPECT_CALL(*mock_drive_service_, GetDocuments(_, _, _, _, _)).Times(0); | 1239 EXPECT_CALL(*mock_drive_service_, GetDocuments(_, _, _, _, _)).Times(0); |
| 1240 | 1240 |
| 1241 // Kicks loading of cached file system and query for server update. | 1241 // Kicks loading of cached file system and query for server update. |
| 1242 EXPECT_TRUE(EntryExists(FilePath(FILE_PATH_LITERAL("drive/File1")))); | 1242 EXPECT_TRUE(EntryExists(FilePath(FILE_PATH_LITERAL("drive/File1")))); |
| 1243 | 1243 |
| 1244 // Since the file system has verified that it holds the latest snapshot, | 1244 // Since the file system has verified that it holds the latest snapshot, |
| 1245 // it should change its state to FROM_SERVER, which admits periodic refresh. | 1245 // it should change its state to FROM_SERVER, which admits periodic refresh. |
| 1246 // To test it, call CheckForUpdates and verify it does try to check updates. | 1246 // To test it, call CheckForUpdates and verify it does try to check updates. |
| 1247 mock_drive_service_->set_account_metadata( | 1247 mock_drive_service_->set_account_metadata( |
| 1248 LoadJSONFile("account_metadata.json")); | 1248 LoadJSONFile("account_metadata.json")); |
| 1249 EXPECT_CALL(*mock_drive_service_, GetAccountMetadata(_)).Times(1); | 1249 EXPECT_CALL(*mock_drive_service_, GetAccountMetadata(_)).Times(1); |
| 1250 EXPECT_CALL(*mock_webapps_registry_, UpdateFromFeed(_)).Times(1); | 1250 EXPECT_CALL(*mock_webapps_registry_, UpdateFromFeed(_)).Times(1); |
| 1251 | 1251 |
| 1252 file_system_->CheckForUpdates(); | 1252 file_system_->CheckForUpdates(); |
| 1253 test_util::RunBlockingPoolTask(); | 1253 test_util::RunBlockingPoolTask(); |
| 1254 } | 1254 } |
| 1255 | 1255 |
| 1256 TEST_F(GDataFileSystemTest, TransferFileFromLocalToRemote_RegularFile) { | 1256 TEST_F(DriveFileSystemTest, TransferFileFromLocalToRemote_RegularFile) { |
| 1257 EXPECT_CALL(*mock_free_disk_space_checker_, AmountOfFreeDiskSpace()) | 1257 EXPECT_CALL(*mock_free_disk_space_checker_, AmountOfFreeDiskSpace()) |
| 1258 .Times(AtLeast(1)).WillRepeatedly(Return(kLotsOfSpace)); | 1258 .Times(AtLeast(1)).WillRepeatedly(Return(kLotsOfSpace)); |
| 1259 | 1259 |
| 1260 LoadRootFeedDocument("root_feed.json"); | 1260 LoadRootFeedDocument("root_feed.json"); |
| 1261 | 1261 |
| 1262 // We'll add a file to the Drive root directory. | 1262 // We'll add a file to the Drive root directory. |
| 1263 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( | 1263 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| 1264 Eq(FilePath(FILE_PATH_LITERAL("drive"))))).Times(1); | 1264 Eq(FilePath(FILE_PATH_LITERAL("drive"))))).Times(1); |
| 1265 | 1265 |
| 1266 FileOperationCallback callback = | 1266 FileOperationCallback callback = |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1282 file_system_->TransferFileFromLocalToRemote( | 1282 file_system_->TransferFileFromLocalToRemote( |
| 1283 local_src_file_path, remote_dest_file_path, callback); | 1283 local_src_file_path, remote_dest_file_path, callback); |
| 1284 test_util::RunBlockingPoolTask(); | 1284 test_util::RunBlockingPoolTask(); |
| 1285 | 1285 |
| 1286 EXPECT_EQ(DRIVE_FILE_OK, callback_helper_->last_error_); | 1286 EXPECT_EQ(DRIVE_FILE_OK, callback_helper_->last_error_); |
| 1287 | 1287 |
| 1288 // Now the remote file should exist. | 1288 // Now the remote file should exist. |
| 1289 EXPECT_TRUE(EntryExists(remote_dest_file_path)); | 1289 EXPECT_TRUE(EntryExists(remote_dest_file_path)); |
| 1290 } | 1290 } |
| 1291 | 1291 |
| 1292 TEST_F(GDataFileSystemTest, TransferFileFromLocalToRemote_HostedDocument) { | 1292 TEST_F(DriveFileSystemTest, TransferFileFromLocalToRemote_HostedDocument) { |
| 1293 LoadRootFeedDocument("root_feed.json"); | 1293 LoadRootFeedDocument("root_feed.json"); |
| 1294 | 1294 |
| 1295 // Prepare a local file, which is a json file of a hosted document, which | 1295 // Prepare a local file, which is a json file of a hosted document, which |
| 1296 // matches "Document 1" in root_feed.json. | 1296 // matches "Document 1" in root_feed.json. |
| 1297 ScopedTempDir temp_dir; | 1297 ScopedTempDir temp_dir; |
| 1298 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 1298 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
| 1299 const FilePath local_src_file_path = temp_dir.path().Append("local.gdoc"); | 1299 const FilePath local_src_file_path = temp_dir.path().Append("local.gdoc"); |
| 1300 const std::string kEditUrl = | 1300 const std::string kEditUrl = |
| 1301 "https://3_document_self_link/document:5_document_resource_id"; | 1301 "https://3_document_self_link/document:5_document_resource_id"; |
| 1302 const std::string kResourceId = "document:5_document_resource_id"; | 1302 const std::string kResourceId = "document:5_document_resource_id"; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1334 file_system_->TransferFileFromLocalToRemote( | 1334 file_system_->TransferFileFromLocalToRemote( |
| 1335 local_src_file_path, remote_dest_file_path, callback); | 1335 local_src_file_path, remote_dest_file_path, callback); |
| 1336 test_util::RunBlockingPoolTask(); | 1336 test_util::RunBlockingPoolTask(); |
| 1337 | 1337 |
| 1338 EXPECT_EQ(DRIVE_FILE_OK, callback_helper_->last_error_); | 1338 EXPECT_EQ(DRIVE_FILE_OK, callback_helper_->last_error_); |
| 1339 | 1339 |
| 1340 // Now the remote file should exist. | 1340 // Now the remote file should exist. |
| 1341 EXPECT_TRUE(EntryExists(remote_dest_file_path)); | 1341 EXPECT_TRUE(EntryExists(remote_dest_file_path)); |
| 1342 } | 1342 } |
| 1343 | 1343 |
| 1344 TEST_F(GDataFileSystemTest, TransferFileFromRemoteToLocal_RegularFile) { | 1344 TEST_F(DriveFileSystemTest, TransferFileFromRemoteToLocal_RegularFile) { |
| 1345 LoadRootFeedDocument("root_feed.json"); | 1345 LoadRootFeedDocument("root_feed.json"); |
| 1346 | 1346 |
| 1347 FileOperationCallback callback = | 1347 FileOperationCallback callback = |
| 1348 base::Bind(&CallbackHelper::FileOperationCallback, | 1348 base::Bind(&CallbackHelper::FileOperationCallback, |
| 1349 callback_helper_.get()); | 1349 callback_helper_.get()); |
| 1350 | 1350 |
| 1351 ScopedTempDir temp_dir; | 1351 ScopedTempDir temp_dir; |
| 1352 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 1352 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
| 1353 FilePath local_dest_file_path = temp_dir.path().Append("local_copy.txt"); | 1353 FilePath local_dest_file_path = temp_dir.path().Append("local_copy.txt"); |
| 1354 | 1354 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1389 std::string cache_file_data; | 1389 std::string cache_file_data; |
| 1390 EXPECT_TRUE(file_util::ReadFileToString(cache_file, &cache_file_data)); | 1390 EXPECT_TRUE(file_util::ReadFileToString(cache_file, &cache_file_data)); |
| 1391 EXPECT_EQ(remote_src_file_data, cache_file_data); | 1391 EXPECT_EQ(remote_src_file_data, cache_file_data); |
| 1392 | 1392 |
| 1393 std::string local_dest_file_data; | 1393 std::string local_dest_file_data; |
| 1394 EXPECT_TRUE(file_util::ReadFileToString(local_dest_file_path, | 1394 EXPECT_TRUE(file_util::ReadFileToString(local_dest_file_path, |
| 1395 &local_dest_file_data)); | 1395 &local_dest_file_data)); |
| 1396 EXPECT_EQ(remote_src_file_data, local_dest_file_data); | 1396 EXPECT_EQ(remote_src_file_data, local_dest_file_data); |
| 1397 } | 1397 } |
| 1398 | 1398 |
| 1399 TEST_F(GDataFileSystemTest, TransferFileFromRemoteToLocal_HostedDocument) { | 1399 TEST_F(DriveFileSystemTest, TransferFileFromRemoteToLocal_HostedDocument) { |
| 1400 LoadRootFeedDocument("root_feed.json"); | 1400 LoadRootFeedDocument("root_feed.json"); |
| 1401 | 1401 |
| 1402 FileOperationCallback callback = | 1402 FileOperationCallback callback = |
| 1403 base::Bind(&CallbackHelper::FileOperationCallback, | 1403 base::Bind(&CallbackHelper::FileOperationCallback, |
| 1404 callback_helper_.get()); | 1404 callback_helper_.get()); |
| 1405 | 1405 |
| 1406 ScopedTempDir temp_dir; | 1406 ScopedTempDir temp_dir; |
| 1407 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 1407 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
| 1408 FilePath local_dest_file_path = temp_dir.path().Append("local_copy.txt"); | 1408 FilePath local_dest_file_path = temp_dir.path().Append("local_copy.txt"); |
| 1409 FilePath remote_src_file_path(FILE_PATH_LITERAL("drive/Document 1.gdoc")); | 1409 FilePath remote_src_file_path(FILE_PATH_LITERAL("drive/Document 1.gdoc")); |
| 1410 file_system_->TransferFileFromRemoteToLocal( | 1410 file_system_->TransferFileFromRemoteToLocal( |
| 1411 remote_src_file_path, local_dest_file_path, callback); | 1411 remote_src_file_path, local_dest_file_path, callback); |
| 1412 test_util::RunBlockingPoolTask(); | 1412 test_util::RunBlockingPoolTask(); |
| 1413 | 1413 |
| 1414 EXPECT_EQ(DRIVE_FILE_OK, callback_helper_->last_error_); | 1414 EXPECT_EQ(DRIVE_FILE_OK, callback_helper_->last_error_); |
| 1415 | 1415 |
| 1416 scoped_ptr<DriveEntryProto> entry_proto = GetEntryInfoByPathSync( | 1416 scoped_ptr<DriveEntryProto> entry_proto = GetEntryInfoByPathSync( |
| 1417 remote_src_file_path); | 1417 remote_src_file_path); |
| 1418 ASSERT_TRUE(entry_proto.get()); | 1418 ASSERT_TRUE(entry_proto.get()); |
| 1419 VerifyHostedDocumentJSONFile(*entry_proto, local_dest_file_path); | 1419 VerifyHostedDocumentJSONFile(*entry_proto, local_dest_file_path); |
| 1420 } | 1420 } |
| 1421 | 1421 |
| 1422 TEST_F(GDataFileSystemTest, CopyNotExistingFile) { | 1422 TEST_F(DriveFileSystemTest, CopyNotExistingFile) { |
| 1423 FilePath src_file_path(FILE_PATH_LITERAL("drive/Dummy file.txt")); | 1423 FilePath src_file_path(FILE_PATH_LITERAL("drive/Dummy file.txt")); |
| 1424 FilePath dest_file_path(FILE_PATH_LITERAL("drive/Test.log")); | 1424 FilePath dest_file_path(FILE_PATH_LITERAL("drive/Test.log")); |
| 1425 | 1425 |
| 1426 LoadRootFeedDocument("root_feed.json"); | 1426 LoadRootFeedDocument("root_feed.json"); |
| 1427 | 1427 |
| 1428 EXPECT_FALSE(EntryExists(src_file_path)); | 1428 EXPECT_FALSE(EntryExists(src_file_path)); |
| 1429 | 1429 |
| 1430 FileOperationCallback callback = | 1430 FileOperationCallback callback = |
| 1431 base::Bind(&CallbackHelper::FileOperationCallback, | 1431 base::Bind(&CallbackHelper::FileOperationCallback, |
| 1432 callback_helper_.get()); | 1432 callback_helper_.get()); |
| 1433 | 1433 |
| 1434 file_system_->Copy(src_file_path, dest_file_path, callback); | 1434 file_system_->Copy(src_file_path, dest_file_path, callback); |
| 1435 test_util::RunBlockingPoolTask(); | 1435 test_util::RunBlockingPoolTask(); |
| 1436 EXPECT_EQ(DRIVE_FILE_ERROR_NOT_FOUND, callback_helper_->last_error_); | 1436 EXPECT_EQ(DRIVE_FILE_ERROR_NOT_FOUND, callback_helper_->last_error_); |
| 1437 | 1437 |
| 1438 EXPECT_FALSE(EntryExists(src_file_path)); | 1438 EXPECT_FALSE(EntryExists(src_file_path)); |
| 1439 EXPECT_FALSE(EntryExists(dest_file_path)); | 1439 EXPECT_FALSE(EntryExists(dest_file_path)); |
| 1440 } | 1440 } |
| 1441 | 1441 |
| 1442 TEST_F(GDataFileSystemTest, CopyFileToNonExistingDirectory) { | 1442 TEST_F(DriveFileSystemTest, CopyFileToNonExistingDirectory) { |
| 1443 FilePath src_file_path(FILE_PATH_LITERAL("drive/File 1.txt")); | 1443 FilePath src_file_path(FILE_PATH_LITERAL("drive/File 1.txt")); |
| 1444 FilePath dest_parent_path(FILE_PATH_LITERAL("drive/Dummy")); | 1444 FilePath dest_parent_path(FILE_PATH_LITERAL("drive/Dummy")); |
| 1445 FilePath dest_file_path(FILE_PATH_LITERAL("drive/Dummy/Test.log")); | 1445 FilePath dest_file_path(FILE_PATH_LITERAL("drive/Dummy/Test.log")); |
| 1446 | 1446 |
| 1447 LoadRootFeedDocument("root_feed.json"); | 1447 LoadRootFeedDocument("root_feed.json"); |
| 1448 | 1448 |
| 1449 ASSERT_TRUE(EntryExists(src_file_path)); | 1449 ASSERT_TRUE(EntryExists(src_file_path)); |
| 1450 scoped_ptr<DriveEntryProto> src_entry_proto = GetEntryInfoByPathSync( | 1450 scoped_ptr<DriveEntryProto> src_entry_proto = GetEntryInfoByPathSync( |
| 1451 src_file_path); | 1451 src_file_path); |
| 1452 ASSERT_TRUE(src_entry_proto.get()); | 1452 ASSERT_TRUE(src_entry_proto.get()); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1464 test_util::RunBlockingPoolTask(); | 1464 test_util::RunBlockingPoolTask(); |
| 1465 EXPECT_EQ(DRIVE_FILE_ERROR_NOT_FOUND, callback_helper_->last_error_); | 1465 EXPECT_EQ(DRIVE_FILE_ERROR_NOT_FOUND, callback_helper_->last_error_); |
| 1466 | 1466 |
| 1467 EXPECT_TRUE(EntryExists(src_file_path)); | 1467 EXPECT_TRUE(EntryExists(src_file_path)); |
| 1468 EXPECT_FALSE(EntryExists(dest_parent_path)); | 1468 EXPECT_FALSE(EntryExists(dest_parent_path)); |
| 1469 EXPECT_FALSE(EntryExists(dest_file_path)); | 1469 EXPECT_FALSE(EntryExists(dest_file_path)); |
| 1470 } | 1470 } |
| 1471 | 1471 |
| 1472 // Test the case where the parent of |dest_file_path| is an existing file, | 1472 // Test the case where the parent of |dest_file_path| is an existing file, |
| 1473 // not a directory. | 1473 // not a directory. |
| 1474 TEST_F(GDataFileSystemTest, CopyFileToInvalidPath) { | 1474 TEST_F(DriveFileSystemTest, CopyFileToInvalidPath) { |
| 1475 FilePath src_file_path(FILE_PATH_LITERAL("drive/Document 1.gdoc")); | 1475 FilePath src_file_path(FILE_PATH_LITERAL("drive/Document 1.gdoc")); |
| 1476 FilePath dest_parent_path(FILE_PATH_LITERAL("drive/Duplicate Name.txt")); | 1476 FilePath dest_parent_path(FILE_PATH_LITERAL("drive/Duplicate Name.txt")); |
| 1477 FilePath dest_file_path(FILE_PATH_LITERAL( | 1477 FilePath dest_file_path(FILE_PATH_LITERAL( |
| 1478 "drive/Duplicate Name.txt/Document 1.gdoc")); | 1478 "drive/Duplicate Name.txt/Document 1.gdoc")); |
| 1479 | 1479 |
| 1480 LoadRootFeedDocument("root_feed.json"); | 1480 LoadRootFeedDocument("root_feed.json"); |
| 1481 | 1481 |
| 1482 ASSERT_TRUE(EntryExists(src_file_path)); | 1482 ASSERT_TRUE(EntryExists(src_file_path)); |
| 1483 scoped_ptr<DriveEntryProto> src_entry_proto = GetEntryInfoByPathSync( | 1483 scoped_ptr<DriveEntryProto> src_entry_proto = GetEntryInfoByPathSync( |
| 1484 src_file_path); | 1484 src_file_path); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1501 EXPECT_EQ(DRIVE_FILE_ERROR_NOT_A_DIRECTORY, | 1501 EXPECT_EQ(DRIVE_FILE_ERROR_NOT_A_DIRECTORY, |
| 1502 callback_helper_->last_error_); | 1502 callback_helper_->last_error_); |
| 1503 | 1503 |
| 1504 EXPECT_TRUE(EntryExists(src_file_path)); | 1504 EXPECT_TRUE(EntryExists(src_file_path)); |
| 1505 EXPECT_TRUE(EntryExists(src_file_path)); | 1505 EXPECT_TRUE(EntryExists(src_file_path)); |
| 1506 EXPECT_TRUE(EntryExists(dest_parent_path)); | 1506 EXPECT_TRUE(EntryExists(dest_parent_path)); |
| 1507 | 1507 |
| 1508 EXPECT_FALSE(EntryExists(dest_file_path)); | 1508 EXPECT_FALSE(EntryExists(dest_file_path)); |
| 1509 } | 1509 } |
| 1510 | 1510 |
| 1511 TEST_F(GDataFileSystemTest, RenameFile) { | 1511 TEST_F(DriveFileSystemTest, RenameFile) { |
| 1512 const FilePath src_file_path( | 1512 const FilePath src_file_path( |
| 1513 FILE_PATH_LITERAL("drive/Directory 1/SubDirectory File 1.txt")); | 1513 FILE_PATH_LITERAL("drive/Directory 1/SubDirectory File 1.txt")); |
| 1514 const FilePath src_parent_path(FILE_PATH_LITERAL("drive/Directory 1")); | 1514 const FilePath src_parent_path(FILE_PATH_LITERAL("drive/Directory 1")); |
| 1515 const FilePath dest_file_path( | 1515 const FilePath dest_file_path( |
| 1516 FILE_PATH_LITERAL("drive/Directory 1/Test.log")); | 1516 FILE_PATH_LITERAL("drive/Directory 1/Test.log")); |
| 1517 | 1517 |
| 1518 LoadRootFeedDocument("root_feed.json"); | 1518 LoadRootFeedDocument("root_feed.json"); |
| 1519 | 1519 |
| 1520 ASSERT_TRUE(EntryExists(src_file_path)); | 1520 ASSERT_TRUE(EntryExists(src_file_path)); |
| 1521 scoped_ptr<DriveEntryProto> src_entry_proto = GetEntryInfoByPathSync( | 1521 scoped_ptr<DriveEntryProto> src_entry_proto = GetEntryInfoByPathSync( |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1537 | 1537 |
| 1538 file_system_->Move(src_file_path, dest_file_path, callback); | 1538 file_system_->Move(src_file_path, dest_file_path, callback); |
| 1539 test_util::RunBlockingPoolTask(); | 1539 test_util::RunBlockingPoolTask(); |
| 1540 EXPECT_EQ(DRIVE_FILE_OK, callback_helper_->last_error_); | 1540 EXPECT_EQ(DRIVE_FILE_OK, callback_helper_->last_error_); |
| 1541 | 1541 |
| 1542 EXPECT_FALSE(EntryExists(src_file_path)); | 1542 EXPECT_FALSE(EntryExists(src_file_path)); |
| 1543 EXPECT_TRUE(EntryExists(dest_file_path)); | 1543 EXPECT_TRUE(EntryExists(dest_file_path)); |
| 1544 EXPECT_EQ(src_file_resource_id, GetResourceIdByPath(dest_file_path)); | 1544 EXPECT_EQ(src_file_resource_id, GetResourceIdByPath(dest_file_path)); |
| 1545 } | 1545 } |
| 1546 | 1546 |
| 1547 TEST_F(GDataFileSystemTest, MoveFileFromRootToSubDirectory) { | 1547 TEST_F(DriveFileSystemTest, MoveFileFromRootToSubDirectory) { |
| 1548 FilePath src_file_path(FILE_PATH_LITERAL("drive/File 1.txt")); | 1548 FilePath src_file_path(FILE_PATH_LITERAL("drive/File 1.txt")); |
| 1549 FilePath dest_parent_path(FILE_PATH_LITERAL("drive/Directory 1")); | 1549 FilePath dest_parent_path(FILE_PATH_LITERAL("drive/Directory 1")); |
| 1550 FilePath dest_file_path(FILE_PATH_LITERAL("drive/Directory 1/Test.log")); | 1550 FilePath dest_file_path(FILE_PATH_LITERAL("drive/Directory 1/Test.log")); |
| 1551 | 1551 |
| 1552 LoadRootFeedDocument("root_feed.json"); | 1552 LoadRootFeedDocument("root_feed.json"); |
| 1553 | 1553 |
| 1554 ASSERT_TRUE(EntryExists(src_file_path)); | 1554 ASSERT_TRUE(EntryExists(src_file_path)); |
| 1555 scoped_ptr<DriveEntryProto> src_entry_proto = GetEntryInfoByPathSync( | 1555 scoped_ptr<DriveEntryProto> src_entry_proto = GetEntryInfoByPathSync( |
| 1556 src_file_path); | 1556 src_file_path); |
| 1557 ASSERT_TRUE(src_entry_proto.get()); | 1557 ASSERT_TRUE(src_entry_proto.get()); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1586 | 1586 |
| 1587 file_system_->Move(src_file_path, dest_file_path, callback); | 1587 file_system_->Move(src_file_path, dest_file_path, callback); |
| 1588 test_util::RunBlockingPoolTask(); | 1588 test_util::RunBlockingPoolTask(); |
| 1589 EXPECT_EQ(DRIVE_FILE_OK, callback_helper_->last_error_); | 1589 EXPECT_EQ(DRIVE_FILE_OK, callback_helper_->last_error_); |
| 1590 | 1590 |
| 1591 EXPECT_FALSE(EntryExists(src_file_path)); | 1591 EXPECT_FALSE(EntryExists(src_file_path)); |
| 1592 EXPECT_TRUE(EntryExists(dest_file_path)); | 1592 EXPECT_TRUE(EntryExists(dest_file_path)); |
| 1593 EXPECT_EQ(src_file_resource_id, GetResourceIdByPath(dest_file_path)); | 1593 EXPECT_EQ(src_file_resource_id, GetResourceIdByPath(dest_file_path)); |
| 1594 } | 1594 } |
| 1595 | 1595 |
| 1596 TEST_F(GDataFileSystemTest, MoveFileFromSubDirectoryToRoot) { | 1596 TEST_F(DriveFileSystemTest, MoveFileFromSubDirectoryToRoot) { |
| 1597 FilePath src_parent_path(FILE_PATH_LITERAL("drive/Directory 1")); | 1597 FilePath src_parent_path(FILE_PATH_LITERAL("drive/Directory 1")); |
| 1598 FilePath src_file_path( | 1598 FilePath src_file_path( |
| 1599 FILE_PATH_LITERAL("drive/Directory 1/SubDirectory File 1.txt")); | 1599 FILE_PATH_LITERAL("drive/Directory 1/SubDirectory File 1.txt")); |
| 1600 FilePath dest_file_path(FILE_PATH_LITERAL("drive/Test.log")); | 1600 FilePath dest_file_path(FILE_PATH_LITERAL("drive/Test.log")); |
| 1601 | 1601 |
| 1602 LoadRootFeedDocument("root_feed.json"); | 1602 LoadRootFeedDocument("root_feed.json"); |
| 1603 | 1603 |
| 1604 ASSERT_TRUE(EntryExists(src_file_path)); | 1604 ASSERT_TRUE(EntryExists(src_file_path)); |
| 1605 scoped_ptr<DriveEntryProto> src_entry_proto = GetEntryInfoByPathSync( | 1605 scoped_ptr<DriveEntryProto> src_entry_proto = GetEntryInfoByPathSync( |
| 1606 src_file_path); | 1606 src_file_path); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1637 | 1637 |
| 1638 file_system_->Move(src_file_path, dest_file_path, callback); | 1638 file_system_->Move(src_file_path, dest_file_path, callback); |
| 1639 test_util::RunBlockingPoolTask(); | 1639 test_util::RunBlockingPoolTask(); |
| 1640 EXPECT_EQ(DRIVE_FILE_OK, callback_helper_->last_error_); | 1640 EXPECT_EQ(DRIVE_FILE_OK, callback_helper_->last_error_); |
| 1641 | 1641 |
| 1642 EXPECT_FALSE(EntryExists(src_file_path)); | 1642 EXPECT_FALSE(EntryExists(src_file_path)); |
| 1643 ASSERT_TRUE(EntryExists(dest_file_path)); | 1643 ASSERT_TRUE(EntryExists(dest_file_path)); |
| 1644 EXPECT_EQ(src_file_resource_id, GetResourceIdByPath(dest_file_path)); | 1644 EXPECT_EQ(src_file_resource_id, GetResourceIdByPath(dest_file_path)); |
| 1645 } | 1645 } |
| 1646 | 1646 |
| 1647 TEST_F(GDataFileSystemTest, MoveFileBetweenSubDirectories) { | 1647 TEST_F(DriveFileSystemTest, MoveFileBetweenSubDirectories) { |
| 1648 FilePath src_parent_path(FILE_PATH_LITERAL("drive/Directory 1")); | 1648 FilePath src_parent_path(FILE_PATH_LITERAL("drive/Directory 1")); |
| 1649 FilePath src_file_path( | 1649 FilePath src_file_path( |
| 1650 FILE_PATH_LITERAL("drive/Directory 1/SubDirectory File 1.txt")); | 1650 FILE_PATH_LITERAL("drive/Directory 1/SubDirectory File 1.txt")); |
| 1651 FilePath dest_parent_path(FILE_PATH_LITERAL("drive/New Folder 1")); | 1651 FilePath dest_parent_path(FILE_PATH_LITERAL("drive/New Folder 1")); |
| 1652 FilePath dest_file_path(FILE_PATH_LITERAL("drive/New Folder 1/Test.log")); | 1652 FilePath dest_file_path(FILE_PATH_LITERAL("drive/New Folder 1/Test.log")); |
| 1653 FilePath interim_file_path(FILE_PATH_LITERAL("drive/Test.log")); | 1653 FilePath interim_file_path(FILE_PATH_LITERAL("drive/Test.log")); |
| 1654 | 1654 |
| 1655 LoadRootFeedDocument("root_feed.json"); | 1655 LoadRootFeedDocument("root_feed.json"); |
| 1656 | 1656 |
| 1657 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( | 1657 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1715 EXPECT_EQ(DRIVE_FILE_OK, callback_helper_->last_error_); | 1715 EXPECT_EQ(DRIVE_FILE_OK, callback_helper_->last_error_); |
| 1716 | 1716 |
| 1717 EXPECT_FALSE(EntryExists(src_file_path)); | 1717 EXPECT_FALSE(EntryExists(src_file_path)); |
| 1718 EXPECT_FALSE(EntryExists(interim_file_path)); | 1718 EXPECT_FALSE(EntryExists(interim_file_path)); |
| 1719 | 1719 |
| 1720 EXPECT_FALSE(EntryExists(src_file_path)); | 1720 EXPECT_FALSE(EntryExists(src_file_path)); |
| 1721 EXPECT_TRUE(EntryExists(dest_file_path)); | 1721 EXPECT_TRUE(EntryExists(dest_file_path)); |
| 1722 EXPECT_EQ(src_file_resource_id, GetResourceIdByPath(dest_file_path)); | 1722 EXPECT_EQ(src_file_resource_id, GetResourceIdByPath(dest_file_path)); |
| 1723 } | 1723 } |
| 1724 | 1724 |
| 1725 TEST_F(GDataFileSystemTest, MoveNotExistingFile) { | 1725 TEST_F(DriveFileSystemTest, MoveNotExistingFile) { |
| 1726 FilePath src_file_path(FILE_PATH_LITERAL("drive/Dummy file.txt")); | 1726 FilePath src_file_path(FILE_PATH_LITERAL("drive/Dummy file.txt")); |
| 1727 FilePath dest_file_path(FILE_PATH_LITERAL("drive/Test.log")); | 1727 FilePath dest_file_path(FILE_PATH_LITERAL("drive/Test.log")); |
| 1728 | 1728 |
| 1729 LoadRootFeedDocument("root_feed.json"); | 1729 LoadRootFeedDocument("root_feed.json"); |
| 1730 | 1730 |
| 1731 EXPECT_FALSE(EntryExists(src_file_path)); | 1731 EXPECT_FALSE(EntryExists(src_file_path)); |
| 1732 | 1732 |
| 1733 FileOperationCallback callback = | 1733 FileOperationCallback callback = |
| 1734 base::Bind(&CallbackHelper::FileOperationCallback, | 1734 base::Bind(&CallbackHelper::FileOperationCallback, |
| 1735 callback_helper_.get()); | 1735 callback_helper_.get()); |
| 1736 | 1736 |
| 1737 file_system_->Move(src_file_path, dest_file_path, callback); | 1737 file_system_->Move(src_file_path, dest_file_path, callback); |
| 1738 test_util::RunBlockingPoolTask(); | 1738 test_util::RunBlockingPoolTask(); |
| 1739 EXPECT_EQ(DRIVE_FILE_ERROR_NOT_FOUND, callback_helper_->last_error_); | 1739 EXPECT_EQ(DRIVE_FILE_ERROR_NOT_FOUND, callback_helper_->last_error_); |
| 1740 | 1740 |
| 1741 EXPECT_FALSE(EntryExists(src_file_path)); | 1741 EXPECT_FALSE(EntryExists(src_file_path)); |
| 1742 EXPECT_FALSE(EntryExists(dest_file_path)); | 1742 EXPECT_FALSE(EntryExists(dest_file_path)); |
| 1743 } | 1743 } |
| 1744 | 1744 |
| 1745 TEST_F(GDataFileSystemTest, MoveFileToNonExistingDirectory) { | 1745 TEST_F(DriveFileSystemTest, MoveFileToNonExistingDirectory) { |
| 1746 FilePath src_file_path(FILE_PATH_LITERAL("drive/File 1.txt")); | 1746 FilePath src_file_path(FILE_PATH_LITERAL("drive/File 1.txt")); |
| 1747 FilePath dest_parent_path(FILE_PATH_LITERAL("drive/Dummy")); | 1747 FilePath dest_parent_path(FILE_PATH_LITERAL("drive/Dummy")); |
| 1748 FilePath dest_file_path(FILE_PATH_LITERAL("drive/Dummy/Test.log")); | 1748 FilePath dest_file_path(FILE_PATH_LITERAL("drive/Dummy/Test.log")); |
| 1749 | 1749 |
| 1750 LoadRootFeedDocument("root_feed.json"); | 1750 LoadRootFeedDocument("root_feed.json"); |
| 1751 | 1751 |
| 1752 ASSERT_TRUE(EntryExists(src_file_path)); | 1752 ASSERT_TRUE(EntryExists(src_file_path)); |
| 1753 scoped_ptr<DriveEntryProto> src_entry_proto = GetEntryInfoByPathSync( | 1753 scoped_ptr<DriveEntryProto> src_entry_proto = GetEntryInfoByPathSync( |
| 1754 src_file_path); | 1754 src_file_path); |
| 1755 ASSERT_TRUE(src_entry_proto.get()); | 1755 ASSERT_TRUE(src_entry_proto.get()); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1767 test_util::RunBlockingPoolTask(); | 1767 test_util::RunBlockingPoolTask(); |
| 1768 EXPECT_EQ(DRIVE_FILE_ERROR_NOT_FOUND, callback_helper_->last_error_); | 1768 EXPECT_EQ(DRIVE_FILE_ERROR_NOT_FOUND, callback_helper_->last_error_); |
| 1769 | 1769 |
| 1770 | 1770 |
| 1771 EXPECT_FALSE(EntryExists(dest_parent_path)); | 1771 EXPECT_FALSE(EntryExists(dest_parent_path)); |
| 1772 EXPECT_FALSE(EntryExists(dest_file_path)); | 1772 EXPECT_FALSE(EntryExists(dest_file_path)); |
| 1773 } | 1773 } |
| 1774 | 1774 |
| 1775 // Test the case where the parent of |dest_file_path| is a existing file, | 1775 // Test the case where the parent of |dest_file_path| is a existing file, |
| 1776 // not a directory. | 1776 // not a directory. |
| 1777 TEST_F(GDataFileSystemTest, MoveFileToInvalidPath) { | 1777 TEST_F(DriveFileSystemTest, MoveFileToInvalidPath) { |
| 1778 FilePath src_file_path(FILE_PATH_LITERAL("drive/File 1.txt")); | 1778 FilePath src_file_path(FILE_PATH_LITERAL("drive/File 1.txt")); |
| 1779 FilePath dest_parent_path(FILE_PATH_LITERAL("drive/Duplicate Name.txt")); | 1779 FilePath dest_parent_path(FILE_PATH_LITERAL("drive/Duplicate Name.txt")); |
| 1780 FilePath dest_file_path(FILE_PATH_LITERAL( | 1780 FilePath dest_file_path(FILE_PATH_LITERAL( |
| 1781 "drive/Duplicate Name.txt/Test.log")); | 1781 "drive/Duplicate Name.txt/Test.log")); |
| 1782 | 1782 |
| 1783 LoadRootFeedDocument("root_feed.json"); | 1783 LoadRootFeedDocument("root_feed.json"); |
| 1784 | 1784 |
| 1785 ASSERT_TRUE(EntryExists(src_file_path)); | 1785 ASSERT_TRUE(EntryExists(src_file_path)); |
| 1786 scoped_ptr<DriveEntryProto> src_entry_proto = GetEntryInfoByPathSync( | 1786 scoped_ptr<DriveEntryProto> src_entry_proto = GetEntryInfoByPathSync( |
| 1787 src_file_path); | 1787 src_file_path); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1802 file_system_->Move(src_file_path, dest_file_path, callback); | 1802 file_system_->Move(src_file_path, dest_file_path, callback); |
| 1803 test_util::RunBlockingPoolTask(); | 1803 test_util::RunBlockingPoolTask(); |
| 1804 EXPECT_EQ(DRIVE_FILE_ERROR_NOT_A_DIRECTORY, | 1804 EXPECT_EQ(DRIVE_FILE_ERROR_NOT_A_DIRECTORY, |
| 1805 callback_helper_->last_error_); | 1805 callback_helper_->last_error_); |
| 1806 | 1806 |
| 1807 EXPECT_TRUE(EntryExists(src_file_path)); | 1807 EXPECT_TRUE(EntryExists(src_file_path)); |
| 1808 EXPECT_TRUE(EntryExists(dest_parent_path)); | 1808 EXPECT_TRUE(EntryExists(dest_parent_path)); |
| 1809 EXPECT_FALSE(EntryExists(dest_file_path)); | 1809 EXPECT_FALSE(EntryExists(dest_file_path)); |
| 1810 } | 1810 } |
| 1811 | 1811 |
| 1812 TEST_F(GDataFileSystemTest, RemoveEntries) { | 1812 TEST_F(DriveFileSystemTest, RemoveEntries) { |
| 1813 LoadRootFeedDocument("root_feed.json"); | 1813 LoadRootFeedDocument("root_feed.json"); |
| 1814 | 1814 |
| 1815 FilePath nonexisting_file(FILE_PATH_LITERAL("drive/Dummy file.txt")); | 1815 FilePath nonexisting_file(FILE_PATH_LITERAL("drive/Dummy file.txt")); |
| 1816 FilePath file_in_root(FILE_PATH_LITERAL("drive/File 1.txt")); | 1816 FilePath file_in_root(FILE_PATH_LITERAL("drive/File 1.txt")); |
| 1817 FilePath dir_in_root(FILE_PATH_LITERAL("drive/Directory 1")); | 1817 FilePath dir_in_root(FILE_PATH_LITERAL("drive/Directory 1")); |
| 1818 FilePath file_in_subdir( | 1818 FilePath file_in_subdir( |
| 1819 FILE_PATH_LITERAL("drive/Directory 1/SubDirectory File 1.txt")); | 1819 FILE_PATH_LITERAL("drive/Directory 1/SubDirectory File 1.txt")); |
| 1820 | 1820 |
| 1821 ASSERT_TRUE(EntryExists(file_in_root)); | 1821 ASSERT_TRUE(EntryExists(file_in_root)); |
| 1822 scoped_ptr<DriveEntryProto> file_in_root_proto = GetEntryInfoByPathSync( | 1822 scoped_ptr<DriveEntryProto> file_in_root_proto = GetEntryInfoByPathSync( |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1856 // Try removing non-existing file. | 1856 // Try removing non-existing file. |
| 1857 EXPECT_FALSE(RemoveEntry(nonexisting_file)); | 1857 EXPECT_FALSE(RemoveEntry(nonexisting_file)); |
| 1858 | 1858 |
| 1859 // Try removing root file element. | 1859 // Try removing root file element. |
| 1860 EXPECT_FALSE(RemoveEntry(FilePath(FILE_PATH_LITERAL("drive")))); | 1860 EXPECT_FALSE(RemoveEntry(FilePath(FILE_PATH_LITERAL("drive")))); |
| 1861 | 1861 |
| 1862 // Need this to ensure OnDirectoryChanged() is run. | 1862 // Need this to ensure OnDirectoryChanged() is run. |
| 1863 test_util::RunBlockingPoolTask(); | 1863 test_util::RunBlockingPoolTask(); |
| 1864 } | 1864 } |
| 1865 | 1865 |
| 1866 TEST_F(GDataFileSystemTest, CreateDirectory) { | 1866 TEST_F(DriveFileSystemTest, CreateDirectory) { |
| 1867 LoadRootFeedDocument("root_feed.json"); | 1867 LoadRootFeedDocument("root_feed.json"); |
| 1868 | 1868 |
| 1869 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( | 1869 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| 1870 Eq(FilePath(FILE_PATH_LITERAL("drive"))))).Times(1); | 1870 Eq(FilePath(FILE_PATH_LITERAL("drive"))))).Times(1); |
| 1871 | 1871 |
| 1872 // Create directory in root. | 1872 // Create directory in root. |
| 1873 FilePath dir_path(FILE_PATH_LITERAL("drive/New Folder 1")); | 1873 FilePath dir_path(FILE_PATH_LITERAL("drive/New Folder 1")); |
| 1874 EXPECT_FALSE(EntryExists(dir_path)); | 1874 EXPECT_FALSE(EntryExists(dir_path)); |
| 1875 AddDirectoryFromFile(dir_path, "directory_entry_atom.json"); | 1875 AddDirectoryFromFile(dir_path, "directory_entry_atom.json"); |
| 1876 EXPECT_TRUE(EntryExists(dir_path)); | 1876 EXPECT_TRUE(EntryExists(dir_path)); |
| 1877 | 1877 |
| 1878 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( | 1878 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| 1879 Eq(FilePath(FILE_PATH_LITERAL("drive/New Folder 1"))))).Times(1); | 1879 Eq(FilePath(FILE_PATH_LITERAL("drive/New Folder 1"))))).Times(1); |
| 1880 | 1880 |
| 1881 // Create directory in a sub directory. | 1881 // Create directory in a sub directory. |
| 1882 FilePath subdir_path(FILE_PATH_LITERAL("drive/New Folder 1/New Folder 2")); | 1882 FilePath subdir_path(FILE_PATH_LITERAL("drive/New Folder 1/New Folder 2")); |
| 1883 EXPECT_FALSE(EntryExists(subdir_path)); | 1883 EXPECT_FALSE(EntryExists(subdir_path)); |
| 1884 AddDirectoryFromFile(subdir_path, "directory_entry_atom2.json"); | 1884 AddDirectoryFromFile(subdir_path, "directory_entry_atom2.json"); |
| 1885 EXPECT_TRUE(EntryExists(subdir_path)); | 1885 EXPECT_TRUE(EntryExists(subdir_path)); |
| 1886 } | 1886 } |
| 1887 | 1887 |
| 1888 TEST_F(GDataFileSystemTest, FindFirstMissingParentDirectory) { | 1888 TEST_F(DriveFileSystemTest, FindFirstMissingParentDirectory) { |
| 1889 LoadRootFeedDocument("root_feed.json"); | 1889 LoadRootFeedDocument("root_feed.json"); |
| 1890 | 1890 |
| 1891 GURL last_dir_content_url; | 1891 GURL last_dir_content_url; |
| 1892 FilePath first_missing_parent_path; | 1892 FilePath first_missing_parent_path; |
| 1893 | 1893 |
| 1894 // Create directory in root. | 1894 // Create directory in root. |
| 1895 FilePath dir_path(FILE_PATH_LITERAL("drive/New Folder 1")); | 1895 FilePath dir_path(FILE_PATH_LITERAL("drive/New Folder 1")); |
| 1896 EXPECT_EQ( | 1896 EXPECT_EQ( |
| 1897 GDataFileSystem::FOUND_MISSING, | 1897 DriveFileSystem::FOUND_MISSING, |
| 1898 file_system_->FindFirstMissingParentDirectory(dir_path, | 1898 file_system_->FindFirstMissingParentDirectory(dir_path, |
| 1899 &last_dir_content_url, | 1899 &last_dir_content_url, |
| 1900 &first_missing_parent_path)); | 1900 &first_missing_parent_path)); |
| 1901 EXPECT_EQ(FilePath(FILE_PATH_LITERAL("drive/New Folder 1")), | 1901 EXPECT_EQ(FilePath(FILE_PATH_LITERAL("drive/New Folder 1")), |
| 1902 first_missing_parent_path); | 1902 first_missing_parent_path); |
| 1903 EXPECT_TRUE(last_dir_content_url.is_empty()); // root directory. | 1903 EXPECT_TRUE(last_dir_content_url.is_empty()); // root directory. |
| 1904 | 1904 |
| 1905 // Missing folders in subdir of an existing folder. | 1905 // Missing folders in subdir of an existing folder. |
| 1906 FilePath dir_path2(FILE_PATH_LITERAL("drive/Directory 1/New Folder 2")); | 1906 FilePath dir_path2(FILE_PATH_LITERAL("drive/Directory 1/New Folder 2")); |
| 1907 EXPECT_EQ( | 1907 EXPECT_EQ( |
| 1908 GDataFileSystem::FOUND_MISSING, | 1908 DriveFileSystem::FOUND_MISSING, |
| 1909 file_system_->FindFirstMissingParentDirectory(dir_path2, | 1909 file_system_->FindFirstMissingParentDirectory(dir_path2, |
| 1910 &last_dir_content_url, | 1910 &last_dir_content_url, |
| 1911 &first_missing_parent_path)); | 1911 &first_missing_parent_path)); |
| 1912 EXPECT_EQ(FilePath(FILE_PATH_LITERAL("drive/Directory 1/New Folder 2")), | 1912 EXPECT_EQ(FilePath(FILE_PATH_LITERAL("drive/Directory 1/New Folder 2")), |
| 1913 first_missing_parent_path); | 1913 first_missing_parent_path); |
| 1914 EXPECT_FALSE(last_dir_content_url.is_empty()); // non-root directory. | 1914 EXPECT_FALSE(last_dir_content_url.is_empty()); // non-root directory. |
| 1915 | 1915 |
| 1916 // Missing two folders on the path. | 1916 // Missing two folders on the path. |
| 1917 FilePath dir_path3 = dir_path2.Append(FILE_PATH_LITERAL("Another Folder")); | 1917 FilePath dir_path3 = dir_path2.Append(FILE_PATH_LITERAL("Another Folder")); |
| 1918 EXPECT_EQ( | 1918 EXPECT_EQ( |
| 1919 GDataFileSystem::FOUND_MISSING, | 1919 DriveFileSystem::FOUND_MISSING, |
| 1920 file_system_->FindFirstMissingParentDirectory(dir_path3, | 1920 file_system_->FindFirstMissingParentDirectory(dir_path3, |
| 1921 &last_dir_content_url, | 1921 &last_dir_content_url, |
| 1922 &first_missing_parent_path)); | 1922 &first_missing_parent_path)); |
| 1923 EXPECT_EQ(FilePath(FILE_PATH_LITERAL("drive/Directory 1/New Folder 2")), | 1923 EXPECT_EQ(FilePath(FILE_PATH_LITERAL("drive/Directory 1/New Folder 2")), |
| 1924 first_missing_parent_path); | 1924 first_missing_parent_path); |
| 1925 EXPECT_FALSE(last_dir_content_url.is_empty()); // non-root directory. | 1925 EXPECT_FALSE(last_dir_content_url.is_empty()); // non-root directory. |
| 1926 | 1926 |
| 1927 // Folders on top of an existing file. | 1927 // Folders on top of an existing file. |
| 1928 EXPECT_EQ( | 1928 EXPECT_EQ( |
| 1929 GDataFileSystem::FOUND_INVALID, | 1929 DriveFileSystem::FOUND_INVALID, |
| 1930 file_system_->FindFirstMissingParentDirectory( | 1930 file_system_->FindFirstMissingParentDirectory( |
| 1931 FilePath(FILE_PATH_LITERAL("drive/File 1.txt/BadDir")), | 1931 FilePath(FILE_PATH_LITERAL("drive/File 1.txt/BadDir")), |
| 1932 &last_dir_content_url, | 1932 &last_dir_content_url, |
| 1933 &first_missing_parent_path)); | 1933 &first_missing_parent_path)); |
| 1934 | 1934 |
| 1935 // Existing folder. | 1935 // Existing folder. |
| 1936 EXPECT_EQ( | 1936 EXPECT_EQ( |
| 1937 GDataFileSystem::DIRECTORY_ALREADY_PRESENT, | 1937 DriveFileSystem::DIRECTORY_ALREADY_PRESENT, |
| 1938 file_system_->FindFirstMissingParentDirectory( | 1938 file_system_->FindFirstMissingParentDirectory( |
| 1939 FilePath(FILE_PATH_LITERAL("drive/Directory 1")), | 1939 FilePath(FILE_PATH_LITERAL("drive/Directory 1")), |
| 1940 &last_dir_content_url, | 1940 &last_dir_content_url, |
| 1941 &first_missing_parent_path)); | 1941 &first_missing_parent_path)); |
| 1942 } | 1942 } |
| 1943 | 1943 |
| 1944 // Create a directory through the document service | 1944 // Create a directory through the document service |
| 1945 TEST_F(GDataFileSystemTest, CreateDirectoryWithService) { | 1945 TEST_F(DriveFileSystemTest, CreateDirectoryWithService) { |
| 1946 LoadRootFeedDocument("root_feed.json"); | 1946 LoadRootFeedDocument("root_feed.json"); |
| 1947 EXPECT_CALL(*mock_drive_service_, | 1947 EXPECT_CALL(*mock_drive_service_, |
| 1948 CreateDirectory(_, "Sample Directory Title", _)).Times(1); | 1948 CreateDirectory(_, "Sample Directory Title", _)).Times(1); |
| 1949 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( | 1949 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| 1950 Eq(FilePath(FILE_PATH_LITERAL("drive"))))).Times(1); | 1950 Eq(FilePath(FILE_PATH_LITERAL("drive"))))).Times(1); |
| 1951 | 1951 |
| 1952 // Set last error so it's not a valid error code. | 1952 // Set last error so it's not a valid error code. |
| 1953 callback_helper_->last_error_ = static_cast<DriveFileError>(1); | 1953 callback_helper_->last_error_ = static_cast<DriveFileError>(1); |
| 1954 file_system_->CreateDirectory( | 1954 file_system_->CreateDirectory( |
| 1955 FilePath(FILE_PATH_LITERAL("drive/Sample Directory Title")), | 1955 FilePath(FILE_PATH_LITERAL("drive/Sample Directory Title")), |
| 1956 false, // is_exclusive | 1956 false, // is_exclusive |
| 1957 true, // is_recursive | 1957 true, // is_recursive |
| 1958 base::Bind(&CallbackHelper::FileOperationCallback, | 1958 base::Bind(&CallbackHelper::FileOperationCallback, |
| 1959 callback_helper_.get())); | 1959 callback_helper_.get())); |
| 1960 test_util::RunBlockingPoolTask(); | 1960 test_util::RunBlockingPoolTask(); |
| 1961 // TODO(gspencer): Uncomment this when we get a blob that | 1961 // TODO(gspencer): Uncomment this when we get a blob that |
| 1962 // works that can be returned from the mock. | 1962 // works that can be returned from the mock. |
| 1963 // EXPECT_EQ(DRIVE_FILE_OK, callback_helper_->last_error_); | 1963 // EXPECT_EQ(DRIVE_FILE_OK, callback_helper_->last_error_); |
| 1964 } | 1964 } |
| 1965 | 1965 |
| 1966 TEST_F(GDataFileSystemTest, GetFileByPath_FromGData_EnoughSpace) { | 1966 TEST_F(DriveFileSystemTest, GetFileByPath_FromGData_EnoughSpace) { |
| 1967 LoadRootFeedDocument("root_feed.json"); | 1967 LoadRootFeedDocument("root_feed.json"); |
| 1968 | 1968 |
| 1969 GetFileCallback callback = | 1969 GetFileCallback callback = |
| 1970 base::Bind(&CallbackHelper::GetFileCallback, | 1970 base::Bind(&CallbackHelper::GetFileCallback, |
| 1971 callback_helper_.get()); | 1971 callback_helper_.get()); |
| 1972 | 1972 |
| 1973 FilePath file_in_root(FILE_PATH_LITERAL("drive/File 1.txt")); | 1973 FilePath file_in_root(FILE_PATH_LITERAL("drive/File 1.txt")); |
| 1974 scoped_ptr<DriveEntryProto> entry_proto(GetEntryInfoByPathSync(file_in_root)); | 1974 scoped_ptr<DriveEntryProto> entry_proto(GetEntryInfoByPathSync(file_in_root)); |
| 1975 FilePath downloaded_file = GetCachePathForFile( | 1975 FilePath downloaded_file = GetCachePathForFile( |
| 1976 entry_proto->resource_id(), | 1976 entry_proto->resource_id(), |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1997 file_system_->GetFileByPath(file_in_root, callback, | 1997 file_system_->GetFileByPath(file_in_root, callback, |
| 1998 GetContentCallback()); | 1998 GetContentCallback()); |
| 1999 test_util::RunBlockingPoolTask(); | 1999 test_util::RunBlockingPoolTask(); |
| 2000 | 2000 |
| 2001 EXPECT_EQ(DRIVE_FILE_OK, callback_helper_->last_error_); | 2001 EXPECT_EQ(DRIVE_FILE_OK, callback_helper_->last_error_); |
| 2002 EXPECT_EQ(REGULAR_FILE, callback_helper_->file_type_); | 2002 EXPECT_EQ(REGULAR_FILE, callback_helper_->file_type_); |
| 2003 EXPECT_EQ(downloaded_file.value(), | 2003 EXPECT_EQ(downloaded_file.value(), |
| 2004 callback_helper_->download_path_.value()); | 2004 callback_helper_->download_path_.value()); |
| 2005 } | 2005 } |
| 2006 | 2006 |
| 2007 TEST_F(GDataFileSystemTest, GetFileByPath_FromGData_NoSpaceAtAll) { | 2007 TEST_F(DriveFileSystemTest, GetFileByPath_FromGData_NoSpaceAtAll) { |
| 2008 LoadRootFeedDocument("root_feed.json"); | 2008 LoadRootFeedDocument("root_feed.json"); |
| 2009 | 2009 |
| 2010 GetFileCallback callback = | 2010 GetFileCallback callback = |
| 2011 base::Bind(&CallbackHelper::GetFileCallback, | 2011 base::Bind(&CallbackHelper::GetFileCallback, |
| 2012 callback_helper_.get()); | 2012 callback_helper_.get()); |
| 2013 | 2013 |
| 2014 FilePath file_in_root(FILE_PATH_LITERAL("drive/File 1.txt")); | 2014 FilePath file_in_root(FILE_PATH_LITERAL("drive/File 1.txt")); |
| 2015 scoped_ptr<DriveEntryProto> entry_proto(GetEntryInfoByPathSync(file_in_root)); | 2015 scoped_ptr<DriveEntryProto> entry_proto(GetEntryInfoByPathSync(file_in_root)); |
| 2016 FilePath downloaded_file = GetCachePathForFile( | 2016 FilePath downloaded_file = GetCachePathForFile( |
| 2017 entry_proto->resource_id(), | 2017 entry_proto->resource_id(), |
| (...skipping 17 matching lines...) Expand all Loading... |
| 2035 .Times(0); | 2035 .Times(0); |
| 2036 | 2036 |
| 2037 file_system_->GetFileByPath(file_in_root, callback, | 2037 file_system_->GetFileByPath(file_in_root, callback, |
| 2038 GetContentCallback()); | 2038 GetContentCallback()); |
| 2039 test_util::RunBlockingPoolTask(); | 2039 test_util::RunBlockingPoolTask(); |
| 2040 | 2040 |
| 2041 EXPECT_EQ(DRIVE_FILE_ERROR_NO_SPACE, | 2041 EXPECT_EQ(DRIVE_FILE_ERROR_NO_SPACE, |
| 2042 callback_helper_->last_error_); | 2042 callback_helper_->last_error_); |
| 2043 } | 2043 } |
| 2044 | 2044 |
| 2045 TEST_F(GDataFileSystemTest, GetFileByPath_FromGData_NoEnoughSpaceButCanFreeUp) { | 2045 TEST_F(DriveFileSystemTest, GetFileByPath_FromGData_NoEnoughSpaceButCanFreeUp) { |
| 2046 LoadRootFeedDocument("root_feed.json"); | 2046 LoadRootFeedDocument("root_feed.json"); |
| 2047 | 2047 |
| 2048 GetFileCallback callback = | 2048 GetFileCallback callback = |
| 2049 base::Bind(&CallbackHelper::GetFileCallback, | 2049 base::Bind(&CallbackHelper::GetFileCallback, |
| 2050 callback_helper_.get()); | 2050 callback_helper_.get()); |
| 2051 | 2051 |
| 2052 FilePath file_in_root(FILE_PATH_LITERAL("drive/File 1.txt")); | 2052 FilePath file_in_root(FILE_PATH_LITERAL("drive/File 1.txt")); |
| 2053 scoped_ptr<DriveEntryProto> entry_proto(GetEntryInfoByPathSync(file_in_root)); | 2053 scoped_ptr<DriveEntryProto> entry_proto(GetEntryInfoByPathSync(file_in_root)); |
| 2054 FilePath downloaded_file = GetCachePathForFile( | 2054 FilePath downloaded_file = GetCachePathForFile( |
| 2055 entry_proto->resource_id(), | 2055 entry_proto->resource_id(), |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2097 EXPECT_EQ(REGULAR_FILE, callback_helper_->file_type_); | 2097 EXPECT_EQ(REGULAR_FILE, callback_helper_->file_type_); |
| 2098 EXPECT_EQ(downloaded_file.value(), | 2098 EXPECT_EQ(downloaded_file.value(), |
| 2099 callback_helper_->download_path_.value()); | 2099 callback_helper_->download_path_.value()); |
| 2100 | 2100 |
| 2101 // The file should be removed in order to free up space, and the cache | 2101 // The file should be removed in order to free up space, and the cache |
| 2102 // entry should also be removed. | 2102 // entry should also be removed. |
| 2103 ASSERT_FALSE(CacheEntryExists("<resource_id>", "<md5>")); | 2103 ASSERT_FALSE(CacheEntryExists("<resource_id>", "<md5>")); |
| 2104 ASSERT_FALSE(CacheFileExists("<resource_id>", "<md5>")); | 2104 ASSERT_FALSE(CacheFileExists("<resource_id>", "<md5>")); |
| 2105 } | 2105 } |
| 2106 | 2106 |
| 2107 TEST_F(GDataFileSystemTest, GetFileByPath_FromGData_EnoughSpaceButBecomeFull) { | 2107 TEST_F(DriveFileSystemTest, GetFileByPath_FromGData_EnoughSpaceButBecomeFull) { |
| 2108 LoadRootFeedDocument("root_feed.json"); | 2108 LoadRootFeedDocument("root_feed.json"); |
| 2109 | 2109 |
| 2110 GetFileCallback callback = | 2110 GetFileCallback callback = |
| 2111 base::Bind(&CallbackHelper::GetFileCallback, | 2111 base::Bind(&CallbackHelper::GetFileCallback, |
| 2112 callback_helper_.get()); | 2112 callback_helper_.get()); |
| 2113 | 2113 |
| 2114 FilePath file_in_root(FILE_PATH_LITERAL("drive/File 1.txt")); | 2114 FilePath file_in_root(FILE_PATH_LITERAL("drive/File 1.txt")); |
| 2115 scoped_ptr<DriveEntryProto> entry_proto(GetEntryInfoByPathSync(file_in_root)); | 2115 scoped_ptr<DriveEntryProto> entry_proto(GetEntryInfoByPathSync(file_in_root)); |
| 2116 FilePath downloaded_file = GetCachePathForFile( | 2116 FilePath downloaded_file = GetCachePathForFile( |
| 2117 entry_proto->resource_id(), | 2117 entry_proto->resource_id(), |
| (...skipping 23 matching lines...) Expand all Loading... |
| 2141 .Times(1); | 2141 .Times(1); |
| 2142 | 2142 |
| 2143 file_system_->GetFileByPath(file_in_root, callback, | 2143 file_system_->GetFileByPath(file_in_root, callback, |
| 2144 GetContentCallback()); | 2144 GetContentCallback()); |
| 2145 test_util::RunBlockingPoolTask(); | 2145 test_util::RunBlockingPoolTask(); |
| 2146 | 2146 |
| 2147 EXPECT_EQ(DRIVE_FILE_ERROR_NO_SPACE, | 2147 EXPECT_EQ(DRIVE_FILE_ERROR_NO_SPACE, |
| 2148 callback_helper_->last_error_); | 2148 callback_helper_->last_error_); |
| 2149 } | 2149 } |
| 2150 | 2150 |
| 2151 TEST_F(GDataFileSystemTest, GetFileByPath_FromCache) { | 2151 TEST_F(DriveFileSystemTest, GetFileByPath_FromCache) { |
| 2152 EXPECT_CALL(*mock_free_disk_space_checker_, AmountOfFreeDiskSpace()) | 2152 EXPECT_CALL(*mock_free_disk_space_checker_, AmountOfFreeDiskSpace()) |
| 2153 .Times(AtLeast(1)).WillRepeatedly(Return(kLotsOfSpace)); | 2153 .Times(AtLeast(1)).WillRepeatedly(Return(kLotsOfSpace)); |
| 2154 | 2154 |
| 2155 LoadRootFeedDocument("root_feed.json"); | 2155 LoadRootFeedDocument("root_feed.json"); |
| 2156 | 2156 |
| 2157 GetFileCallback callback = | 2157 GetFileCallback callback = |
| 2158 base::Bind(&CallbackHelper::GetFileCallback, | 2158 base::Bind(&CallbackHelper::GetFileCallback, |
| 2159 callback_helper_.get()); | 2159 callback_helper_.get()); |
| 2160 | 2160 |
| 2161 FilePath file_in_root(FILE_PATH_LITERAL("drive/File 1.txt")); | 2161 FilePath file_in_root(FILE_PATH_LITERAL("drive/File 1.txt")); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 2185 | 2185 |
| 2186 file_system_->GetFileByPath(file_in_root, callback, | 2186 file_system_->GetFileByPath(file_in_root, callback, |
| 2187 GetContentCallback()); | 2187 GetContentCallback()); |
| 2188 test_util::RunBlockingPoolTask(); | 2188 test_util::RunBlockingPoolTask(); |
| 2189 | 2189 |
| 2190 EXPECT_EQ(REGULAR_FILE, callback_helper_->file_type_); | 2190 EXPECT_EQ(REGULAR_FILE, callback_helper_->file_type_); |
| 2191 EXPECT_EQ(downloaded_file.value(), | 2191 EXPECT_EQ(downloaded_file.value(), |
| 2192 callback_helper_->download_path_.value()); | 2192 callback_helper_->download_path_.value()); |
| 2193 } | 2193 } |
| 2194 | 2194 |
| 2195 TEST_F(GDataFileSystemTest, GetFileByPath_HostedDocument) { | 2195 TEST_F(DriveFileSystemTest, GetFileByPath_HostedDocument) { |
| 2196 LoadRootFeedDocument("root_feed.json"); | 2196 LoadRootFeedDocument("root_feed.json"); |
| 2197 | 2197 |
| 2198 GetFileCallback callback = | 2198 GetFileCallback callback = |
| 2199 base::Bind(&CallbackHelper::GetFileCallback, | 2199 base::Bind(&CallbackHelper::GetFileCallback, |
| 2200 callback_helper_.get()); | 2200 callback_helper_.get()); |
| 2201 | 2201 |
| 2202 FilePath file_in_root(FILE_PATH_LITERAL("drive/Document 1.gdoc")); | 2202 FilePath file_in_root(FILE_PATH_LITERAL("drive/Document 1.gdoc")); |
| 2203 scoped_ptr<DriveEntryProto> src_entry_proto = | 2203 scoped_ptr<DriveEntryProto> src_entry_proto = |
| 2204 GetEntryInfoByPathSync(file_in_root); | 2204 GetEntryInfoByPathSync(file_in_root); |
| 2205 ASSERT_TRUE(src_entry_proto.get()); | 2205 ASSERT_TRUE(src_entry_proto.get()); |
| 2206 | 2206 |
| 2207 file_system_->GetFileByPath(file_in_root, callback, | 2207 file_system_->GetFileByPath(file_in_root, callback, |
| 2208 GetContentCallback()); | 2208 GetContentCallback()); |
| 2209 test_util::RunBlockingPoolTask(); | 2209 test_util::RunBlockingPoolTask(); |
| 2210 | 2210 |
| 2211 EXPECT_EQ(HOSTED_DOCUMENT, callback_helper_->file_type_); | 2211 EXPECT_EQ(HOSTED_DOCUMENT, callback_helper_->file_type_); |
| 2212 EXPECT_FALSE(callback_helper_->download_path_.empty()); | 2212 EXPECT_FALSE(callback_helper_->download_path_.empty()); |
| 2213 | 2213 |
| 2214 ASSERT_TRUE(src_entry_proto.get()); | 2214 ASSERT_TRUE(src_entry_proto.get()); |
| 2215 VerifyHostedDocumentJSONFile(*src_entry_proto, | 2215 VerifyHostedDocumentJSONFile(*src_entry_proto, |
| 2216 callback_helper_->download_path_); | 2216 callback_helper_->download_path_); |
| 2217 } | 2217 } |
| 2218 | 2218 |
| 2219 TEST_F(GDataFileSystemTest, GetFileByResourceId) { | 2219 TEST_F(DriveFileSystemTest, GetFileByResourceId) { |
| 2220 EXPECT_CALL(*mock_free_disk_space_checker_, AmountOfFreeDiskSpace()) | 2220 EXPECT_CALL(*mock_free_disk_space_checker_, AmountOfFreeDiskSpace()) |
| 2221 .Times(AtLeast(1)).WillRepeatedly(Return(kLotsOfSpace)); | 2221 .Times(AtLeast(1)).WillRepeatedly(Return(kLotsOfSpace)); |
| 2222 | 2222 |
| 2223 LoadRootFeedDocument("root_feed.json"); | 2223 LoadRootFeedDocument("root_feed.json"); |
| 2224 | 2224 |
| 2225 GetFileCallback callback = | 2225 GetFileCallback callback = |
| 2226 base::Bind(&CallbackHelper::GetFileCallback, | 2226 base::Bind(&CallbackHelper::GetFileCallback, |
| 2227 callback_helper_.get()); | 2227 callback_helper_.get()); |
| 2228 | 2228 |
| 2229 FilePath file_in_root(FILE_PATH_LITERAL("drive/File 1.txt")); | 2229 FilePath file_in_root(FILE_PATH_LITERAL("drive/File 1.txt")); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 2249 file_system_->GetFileByResourceId(entry_proto->resource_id(), | 2249 file_system_->GetFileByResourceId(entry_proto->resource_id(), |
| 2250 callback, | 2250 callback, |
| 2251 GetContentCallback()); | 2251 GetContentCallback()); |
| 2252 test_util::RunBlockingPoolTask(); | 2252 test_util::RunBlockingPoolTask(); |
| 2253 | 2253 |
| 2254 EXPECT_EQ(REGULAR_FILE, callback_helper_->file_type_); | 2254 EXPECT_EQ(REGULAR_FILE, callback_helper_->file_type_); |
| 2255 EXPECT_EQ(downloaded_file.value(), | 2255 EXPECT_EQ(downloaded_file.value(), |
| 2256 callback_helper_->download_path_.value()); | 2256 callback_helper_->download_path_.value()); |
| 2257 } | 2257 } |
| 2258 | 2258 |
| 2259 TEST_F(GDataFileSystemTest, GetFileByResourceId_FromCache) { | 2259 TEST_F(DriveFileSystemTest, GetFileByResourceId_FromCache) { |
| 2260 EXPECT_CALL(*mock_free_disk_space_checker_, AmountOfFreeDiskSpace()) | 2260 EXPECT_CALL(*mock_free_disk_space_checker_, AmountOfFreeDiskSpace()) |
| 2261 .Times(AtLeast(1)).WillRepeatedly(Return(kLotsOfSpace)); | 2261 .Times(AtLeast(1)).WillRepeatedly(Return(kLotsOfSpace)); |
| 2262 | 2262 |
| 2263 LoadRootFeedDocument("root_feed.json"); | 2263 LoadRootFeedDocument("root_feed.json"); |
| 2264 | 2264 |
| 2265 GetFileCallback callback = | 2265 GetFileCallback callback = |
| 2266 base::Bind(&CallbackHelper::GetFileCallback, | 2266 base::Bind(&CallbackHelper::GetFileCallback, |
| 2267 callback_helper_.get()); | 2267 callback_helper_.get()); |
| 2268 | 2268 |
| 2269 FilePath file_in_root(FILE_PATH_LITERAL("drive/File 1.txt")); | 2269 FilePath file_in_root(FILE_PATH_LITERAL("drive/File 1.txt")); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 2288 file_system_->GetFileByResourceId(entry_proto->resource_id(), | 2288 file_system_->GetFileByResourceId(entry_proto->resource_id(), |
| 2289 callback, | 2289 callback, |
| 2290 GetContentCallback()); | 2290 GetContentCallback()); |
| 2291 test_util::RunBlockingPoolTask(); | 2291 test_util::RunBlockingPoolTask(); |
| 2292 | 2292 |
| 2293 EXPECT_EQ(REGULAR_FILE, callback_helper_->file_type_); | 2293 EXPECT_EQ(REGULAR_FILE, callback_helper_->file_type_); |
| 2294 EXPECT_EQ(downloaded_file.value(), | 2294 EXPECT_EQ(downloaded_file.value(), |
| 2295 callback_helper_->download_path_.value()); | 2295 callback_helper_->download_path_.value()); |
| 2296 } | 2296 } |
| 2297 | 2297 |
| 2298 TEST_F(GDataFileSystemTest, UpdateFileByResourceId_PersistentFile) { | 2298 TEST_F(DriveFileSystemTest, UpdateFileByResourceId_PersistentFile) { |
| 2299 EXPECT_CALL(*mock_free_disk_space_checker_, AmountOfFreeDiskSpace()) | 2299 EXPECT_CALL(*mock_free_disk_space_checker_, AmountOfFreeDiskSpace()) |
| 2300 .Times(AtLeast(1)).WillRepeatedly(Return(kLotsOfSpace)); | 2300 .Times(AtLeast(1)).WillRepeatedly(Return(kLotsOfSpace)); |
| 2301 | 2301 |
| 2302 LoadRootFeedDocument("root_feed.json"); | 2302 LoadRootFeedDocument("root_feed.json"); |
| 2303 | 2303 |
| 2304 // This is a file defined in root_feed.json. | 2304 // This is a file defined in root_feed.json. |
| 2305 const FilePath kFilePath(FILE_PATH_LITERAL("drive/File 1.txt")); | 2305 const FilePath kFilePath(FILE_PATH_LITERAL("drive/File 1.txt")); |
| 2306 const std::string kResourceId("file:2_file_resource_id"); | 2306 const std::string kResourceId("file:2_file_resource_id"); |
| 2307 const std::string kMd5("3b4382ebefec6e743578c76bbd0575ce"); | 2307 const std::string kMd5("3b4382ebefec6e743578c76bbd0575ce"); |
| 2308 | 2308 |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2432 EXPECT_EQ(DRIVE_FILE_OK, callback_helper_->last_error_); | 2432 EXPECT_EQ(DRIVE_FILE_OK, callback_helper_->last_error_); |
| 2433 // Make sure that the number of files did not change (i.e. we updated an | 2433 // Make sure that the number of files did not change (i.e. we updated an |
| 2434 // existing file, rather than adding a new file. The number of files | 2434 // existing file, rather than adding a new file. The number of files |
| 2435 // increases if we don't handle the file update right). | 2435 // increases if we don't handle the file update right). |
| 2436 EXPECT_EQ(num_files_in_root, CountFiles(*root_directory_entries)); | 2436 EXPECT_EQ(num_files_in_root, CountFiles(*root_directory_entries)); |
| 2437 // After the file is updated, the dirty bit is cleared, hence the symlink | 2437 // After the file is updated, the dirty bit is cleared, hence the symlink |
| 2438 // should be gone. | 2438 // should be gone. |
| 2439 ASSERT_FALSE(file_util::PathExists(outgoing_symlink_path)); | 2439 ASSERT_FALSE(file_util::PathExists(outgoing_symlink_path)); |
| 2440 } | 2440 } |
| 2441 | 2441 |
| 2442 TEST_F(GDataFileSystemTest, UpdateFileByResourceId_NonexistentFile) { | 2442 TEST_F(DriveFileSystemTest, UpdateFileByResourceId_NonexistentFile) { |
| 2443 LoadRootFeedDocument("root_feed.json"); | 2443 LoadRootFeedDocument("root_feed.json"); |
| 2444 | 2444 |
| 2445 // This is nonexistent in root_feed.json. | 2445 // This is nonexistent in root_feed.json. |
| 2446 const FilePath kFilePath(FILE_PATH_LITERAL("drive/Nonexistent.txt")); | 2446 const FilePath kFilePath(FILE_PATH_LITERAL("drive/Nonexistent.txt")); |
| 2447 const std::string kResourceId("file:nonexistent_resource_id"); | 2447 const std::string kResourceId("file:nonexistent_resource_id"); |
| 2448 const std::string kMd5("nonexistent_md5"); | 2448 const std::string kMd5("nonexistent_md5"); |
| 2449 | 2449 |
| 2450 // The callback will be called upon completion of | 2450 // The callback will be called upon completion of |
| 2451 // UpdateFileByResourceId(). | 2451 // UpdateFileByResourceId(). |
| 2452 FileOperationCallback callback = | 2452 FileOperationCallback callback = |
| 2453 base::Bind(&CallbackHelper::FileOperationCallback, | 2453 base::Bind(&CallbackHelper::FileOperationCallback, |
| 2454 callback_helper_.get()); | 2454 callback_helper_.get()); |
| 2455 | 2455 |
| 2456 file_system_->UpdateFileByResourceId(kResourceId, callback); | 2456 file_system_->UpdateFileByResourceId(kResourceId, callback); |
| 2457 test_util::RunBlockingPoolTask(); | 2457 test_util::RunBlockingPoolTask(); |
| 2458 EXPECT_EQ(DRIVE_FILE_ERROR_NOT_FOUND, callback_helper_->last_error_); | 2458 EXPECT_EQ(DRIVE_FILE_ERROR_NOT_FOUND, callback_helper_->last_error_); |
| 2459 } | 2459 } |
| 2460 | 2460 |
| 2461 TEST_F(GDataFileSystemTest, ContentSearch) { | 2461 TEST_F(DriveFileSystemTest, ContentSearch) { |
| 2462 LoadRootFeedDocument("root_feed.json"); | 2462 LoadRootFeedDocument("root_feed.json"); |
| 2463 | 2463 |
| 2464 mock_drive_service_->set_search_result("search_result_feed.json"); | 2464 mock_drive_service_->set_search_result("search_result_feed.json"); |
| 2465 | 2465 |
| 2466 EXPECT_CALL(*mock_drive_service_, GetDocuments(Eq(GURL()), _, "foo", _, _)) | 2466 EXPECT_CALL(*mock_drive_service_, GetDocuments(Eq(GURL()), _, "foo", _, _)) |
| 2467 .Times(1); | 2467 .Times(1); |
| 2468 | 2468 |
| 2469 const SearchResultPair kExpectedResults[] = { | 2469 const SearchResultPair kExpectedResults[] = { |
| 2470 { "drive/Directory 1/SubDirectory File 1.txt", false }, | 2470 { "drive/Directory 1/SubDirectory File 1.txt", false }, |
| 2471 { "drive/Directory 1", true } | 2471 { "drive/Directory 1", true } |
| 2472 }; | 2472 }; |
| 2473 | 2473 |
| 2474 SearchCallback callback = base::Bind(&DriveSearchCallback, | 2474 SearchCallback callback = base::Bind(&DriveSearchCallback, |
| 2475 &message_loop_, kExpectedResults, ARRAYSIZE_UNSAFE(kExpectedResults)); | 2475 &message_loop_, kExpectedResults, ARRAYSIZE_UNSAFE(kExpectedResults)); |
| 2476 | 2476 |
| 2477 file_system_->Search("foo", GURL(), callback); | 2477 file_system_->Search("foo", GURL(), callback); |
| 2478 message_loop_.Run(); // Wait to get our result. | 2478 message_loop_.Run(); // Wait to get our result. |
| 2479 } | 2479 } |
| 2480 | 2480 |
| 2481 TEST_F(GDataFileSystemTest, ContentSearchWithNewEntry) { | 2481 TEST_F(DriveFileSystemTest, ContentSearchWithNewEntry) { |
| 2482 LoadRootFeedDocument("root_feed.json"); | 2482 LoadRootFeedDocument("root_feed.json"); |
| 2483 | 2483 |
| 2484 // Search result returning two entries "Directory 1/" and | 2484 // Search result returning two entries "Directory 1/" and |
| 2485 // "Directory 1/SubDirectory Newly Added File.txt". The latter is not | 2485 // "Directory 1/SubDirectory Newly Added File.txt". The latter is not |
| 2486 // contained in the root feed. | 2486 // contained in the root feed. |
| 2487 mock_drive_service_->set_search_result( | 2487 mock_drive_service_->set_search_result( |
| 2488 "search_result_with_new_entry_feed.json"); | 2488 "search_result_with_new_entry_feed.json"); |
| 2489 | 2489 |
| 2490 EXPECT_CALL(*mock_drive_service_, GetDocuments(Eq(GURL()), _, "foo", _, _)) | 2490 EXPECT_CALL(*mock_drive_service_, GetDocuments(Eq(GURL()), _, "foo", _, _)) |
| 2491 .Times(1); | 2491 .Times(1); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 2504 .Times(1); | 2504 .Times(1); |
| 2505 EXPECT_CALL(*mock_webapps_registry_, UpdateFromFeed(_)).Times(1); | 2505 EXPECT_CALL(*mock_webapps_registry_, UpdateFromFeed(_)).Times(1); |
| 2506 | 2506 |
| 2507 SearchCallback callback = base::Bind(&DriveSearchCallback, | 2507 SearchCallback callback = base::Bind(&DriveSearchCallback, |
| 2508 &message_loop_, kExpectedResults, ARRAYSIZE_UNSAFE(kExpectedResults)); | 2508 &message_loop_, kExpectedResults, ARRAYSIZE_UNSAFE(kExpectedResults)); |
| 2509 | 2509 |
| 2510 file_system_->Search("foo", GURL(), callback); | 2510 file_system_->Search("foo", GURL(), callback); |
| 2511 message_loop_.Run(); // Wait to get our result. | 2511 message_loop_.Run(); // Wait to get our result. |
| 2512 } | 2512 } |
| 2513 | 2513 |
| 2514 TEST_F(GDataFileSystemTest, ContentSearchEmptyResult) { | 2514 TEST_F(DriveFileSystemTest, ContentSearchEmptyResult) { |
| 2515 LoadRootFeedDocument("root_feed.json"); | 2515 LoadRootFeedDocument("root_feed.json"); |
| 2516 | 2516 |
| 2517 mock_drive_service_->set_search_result("empty_feed.json"); | 2517 mock_drive_service_->set_search_result("empty_feed.json"); |
| 2518 | 2518 |
| 2519 EXPECT_CALL(*mock_drive_service_, GetDocuments(Eq(GURL()), _, "foo", _, _)) | 2519 EXPECT_CALL(*mock_drive_service_, GetDocuments(Eq(GURL()), _, "foo", _, _)) |
| 2520 .Times(1); | 2520 .Times(1); |
| 2521 | 2521 |
| 2522 const SearchResultPair* expected_results = NULL; | 2522 const SearchResultPair* expected_results = NULL; |
| 2523 | 2523 |
| 2524 SearchCallback callback = base::Bind(&DriveSearchCallback, | 2524 SearchCallback callback = base::Bind(&DriveSearchCallback, |
| 2525 &message_loop_, expected_results, 0u); | 2525 &message_loop_, expected_results, 0u); |
| 2526 | 2526 |
| 2527 file_system_->Search("foo", GURL(), callback); | 2527 file_system_->Search("foo", GURL(), callback); |
| 2528 message_loop_.Run(); // Wait to get our result. | 2528 message_loop_.Run(); // Wait to get our result. |
| 2529 } | 2529 } |
| 2530 | 2530 |
| 2531 TEST_F(GDataFileSystemTest, GetAvailableSpace) { | 2531 TEST_F(DriveFileSystemTest, GetAvailableSpace) { |
| 2532 GetAvailableSpaceCallback callback = | 2532 GetAvailableSpaceCallback callback = |
| 2533 base::Bind(&CallbackHelper::GetAvailableSpaceCallback, | 2533 base::Bind(&CallbackHelper::GetAvailableSpaceCallback, |
| 2534 callback_helper_.get()); | 2534 callback_helper_.get()); |
| 2535 | 2535 |
| 2536 EXPECT_CALL(*mock_drive_service_, GetAccountMetadata(_)); | 2536 EXPECT_CALL(*mock_drive_service_, GetAccountMetadata(_)); |
| 2537 | 2537 |
| 2538 file_system_->GetAvailableSpace(callback); | 2538 file_system_->GetAvailableSpace(callback); |
| 2539 test_util::RunBlockingPoolTask(); | 2539 test_util::RunBlockingPoolTask(); |
| 2540 EXPECT_EQ(GG_LONGLONG(6789012345), callback_helper_->quota_bytes_used_); | 2540 EXPECT_EQ(GG_LONGLONG(6789012345), callback_helper_->quota_bytes_used_); |
| 2541 EXPECT_EQ(GG_LONGLONG(9876543210), callback_helper_->quota_bytes_total_); | 2541 EXPECT_EQ(GG_LONGLONG(9876543210), callback_helper_->quota_bytes_total_); |
| 2542 } | 2542 } |
| 2543 | 2543 |
| 2544 TEST_F(GDataFileSystemTest, RequestDirectoryRefresh) { | 2544 TEST_F(DriveFileSystemTest, RequestDirectoryRefresh) { |
| 2545 LoadRootFeedDocument("root_feed.json"); | 2545 LoadRootFeedDocument("root_feed.json"); |
| 2546 | 2546 |
| 2547 // We'll fetch documents in the root directory with its resource ID. | 2547 // We'll fetch documents in the root directory with its resource ID. |
| 2548 EXPECT_CALL(*mock_drive_service_, | 2548 EXPECT_CALL(*mock_drive_service_, |
| 2549 GetDocuments(Eq(GURL()), _, _, kDriveRootDirectoryResourceId, _)) | 2549 GetDocuments(Eq(GURL()), _, _, kDriveRootDirectoryResourceId, _)) |
| 2550 .Times(1); | 2550 .Times(1); |
| 2551 // We'll notify the directory change to the observer. | 2551 // We'll notify the directory change to the observer. |
| 2552 EXPECT_CALL(*mock_directory_observer_, | 2552 EXPECT_CALL(*mock_directory_observer_, |
| 2553 OnDirectoryChanged(Eq(FilePath(kDriveRootDirectory)))).Times(1); | 2553 OnDirectoryChanged(Eq(FilePath(kDriveRootDirectory)))).Times(1); |
| 2554 | 2554 |
| 2555 file_system_->RequestDirectoryRefresh(FilePath(kDriveRootDirectory)); | 2555 file_system_->RequestDirectoryRefresh(FilePath(kDriveRootDirectory)); |
| 2556 test_util::RunBlockingPoolTask(); | 2556 test_util::RunBlockingPoolTask(); |
| 2557 } | 2557 } |
| 2558 | 2558 |
| 2559 TEST_F(GDataFileSystemTest, OpenAndCloseFile) { | 2559 TEST_F(DriveFileSystemTest, OpenAndCloseFile) { |
| 2560 LoadRootFeedDocument("root_feed.json"); | 2560 LoadRootFeedDocument("root_feed.json"); |
| 2561 | 2561 |
| 2562 OpenFileCallback callback = | 2562 OpenFileCallback callback = |
| 2563 base::Bind(&CallbackHelper::OpenFileCallback, | 2563 base::Bind(&CallbackHelper::OpenFileCallback, |
| 2564 callback_helper_.get()); | 2564 callback_helper_.get()); |
| 2565 FileOperationCallback close_file_callback = | 2565 FileOperationCallback close_file_callback = |
| 2566 base::Bind(&CallbackHelper::CloseFileCallback, | 2566 base::Bind(&CallbackHelper::CloseFileCallback, |
| 2567 callback_helper_.get()); | 2567 callback_helper_.get()); |
| 2568 | 2568 |
| 2569 const FilePath kFileInRoot(FILE_PATH_LITERAL("drive/File 1.txt")); | 2569 const FilePath kFileInRoot(FILE_PATH_LITERAL("drive/File 1.txt")); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2640 | 2640 |
| 2641 // Try to close the same file twice. | 2641 // Try to close the same file twice. |
| 2642 file_system_->CloseFile(kFileInRoot, close_file_callback); | 2642 file_system_->CloseFile(kFileInRoot, close_file_callback); |
| 2643 message_loop_.Run(); | 2643 message_loop_.Run(); |
| 2644 | 2644 |
| 2645 // It must fail. | 2645 // It must fail. |
| 2646 EXPECT_EQ(DRIVE_FILE_ERROR_NOT_FOUND, callback_helper_->last_error_); | 2646 EXPECT_EQ(DRIVE_FILE_ERROR_NOT_FOUND, callback_helper_->last_error_); |
| 2647 } | 2647 } |
| 2648 | 2648 |
| 2649 } // namespace gdata | 2649 } // namespace gdata |
| OLD | NEW |