Chromium Code Reviews| 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 "chrome/browser/chromeos/drive/drive_file_system.h" | 5 #include "chrome/browser/chromeos/drive/drive_file_system.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 301 return GetCacheEntryFromOriginThread(resource_id, md5, &cache_entry); | 301 return GetCacheEntryFromOriginThread(resource_id, md5, &cache_entry); |
| 302 } | 302 } |
| 303 | 303 |
| 304 // Flag for specifying the timestamp of the test filesystem cache. | 304 // Flag for specifying the timestamp of the test filesystem cache. |
| 305 enum SaveTestFileSystemParam { | 305 enum SaveTestFileSystemParam { |
| 306 USE_OLD_TIMESTAMP, | 306 USE_OLD_TIMESTAMP, |
| 307 USE_SERVER_TIMESTAMP, | 307 USE_SERVER_TIMESTAMP, |
| 308 }; | 308 }; |
| 309 | 309 |
| 310 // Saves a file representing a filesystem with directories: | 310 // Saves a file representing a filesystem with directories: |
| 311 // drive, drive/Dir1, drive/Dir1/SubDir2 | 311 // drive/root, drive/root/Dir1, drive/root/Dir1/SubDir2 |
| 312 // and files | 312 // and files |
| 313 // drive/File1, drive/Dir1/File2, drive/Dir1/SubDir2/File3. | 313 // drive/root/File1, drive/root/Dir1/File2, drive/root/Dir1/SubDir2/File3. |
| 314 // If |use_up_to_date_timestamp| is true, sets the changestamp to 654321, | 314 // If |use_up_to_date_timestamp| is true, sets the changestamp to 654321, |
| 315 // equal to that of "account_metadata.json" test data, indicating the cache is | 315 // equal to that of "account_metadata.json" test data, indicating the cache is |
| 316 // holding the latest file system info. | 316 // holding the latest file system info. |
| 317 bool SaveTestFileSystem(SaveTestFileSystemParam param) { | 317 bool SaveTestFileSystem(SaveTestFileSystemParam param) { |
| 318 // Destroy the existing resource metadata to close DB. | 318 // Destroy the existing resource metadata to close DB. |
| 319 resource_metadata_.reset(); | 319 resource_metadata_.reset(); |
| 320 | 320 |
| 321 const std::string root_resource_id = | 321 const std::string root_resource_id = |
| 322 fake_drive_service_->GetRootResourceId(); | 322 fake_drive_service_->GetRootResourceId(); |
| 323 scoped_ptr<DriveResourceMetadata, test_util::DestroyHelperForTests> | 323 scoped_ptr<DriveResourceMetadata, test_util::DestroyHelperForTests> |
| 324 resource_metadata(new DriveResourceMetadata( | 324 resource_metadata(new DriveResourceMetadata( |
| 325 root_resource_id, | 325 root_resource_id, |
| 326 cache_->GetCacheDirectoryPath(DriveCache::CACHE_TYPE_META), | 326 cache_->GetCacheDirectoryPath(DriveCache::CACHE_TYPE_META), |
| 327 blocking_task_runner_)); | 327 blocking_task_runner_)); |
| 328 | 328 |
| 329 DriveFileError error = DRIVE_FILE_ERROR_FAILED; | 329 DriveFileError error = DRIVE_FILE_ERROR_FAILED; |
| 330 resource_metadata->Initialize( | 330 resource_metadata->Initialize( |
| 331 google_apis::test_util::CreateCopyResultCallback(&error)); | 331 google_apis::test_util::CreateCopyResultCallback(&error)); |
| 332 google_apis::test_util::RunBlockingPoolTask(); | 332 google_apis::test_util::RunBlockingPoolTask(); |
| 333 if (error != DRIVE_FILE_OK) | 333 if (error != DRIVE_FILE_OK) |
| 334 return false; | 334 return false; |
| 335 | 335 |
| 336 resource_metadata->SetLargestChangestamp( | 336 resource_metadata->SetLargestChangestamp( |
| 337 param == USE_SERVER_TIMESTAMP ? 654321 : 1, | 337 param == USE_SERVER_TIMESTAMP ? 654321 : 1, |
| 338 google_apis::test_util::CreateCopyResultCallback(&error)); | 338 google_apis::test_util::CreateCopyResultCallback(&error)); |
| 339 google_apis::test_util::RunBlockingPoolTask(); | 339 google_apis::test_util::RunBlockingPoolTask(); |
| 340 if (error != DRIVE_FILE_OK) | 340 if (error != DRIVE_FILE_OK) |
| 341 return false; | 341 return false; |
| 342 | 342 |
| 343 // drive/File1 | 343 // drive/root is already prepared by DriveResourceMetadata. |
| 344 // TODO(haruki): Create drive/root here when we start creating it in | |
| 345 // ChangeListLoader. | |
| 346 base::FilePath file_path; | |
| 347 | |
| 348 // drive/root/File1 | |
| 344 DriveEntryProto file1; | 349 DriveEntryProto file1; |
| 345 file1.set_title("File1"); | 350 file1.set_title("File1"); |
| 346 file1.set_resource_id("resource_id:File1"); | 351 file1.set_resource_id("resource_id:File1"); |
| 347 file1.set_parent_resource_id(root_resource_id); | 352 file1.set_parent_resource_id(root_resource_id); |
| 348 file1.set_upload_url("http://resumable-edit-media/1"); | 353 file1.set_upload_url("http://resumable-edit-media/1"); |
| 349 file1.mutable_file_specific_info()->set_file_md5("md5"); | 354 file1.mutable_file_specific_info()->set_file_md5("md5"); |
| 350 file1.mutable_file_info()->set_is_directory(false); | 355 file1.mutable_file_info()->set_is_directory(false); |
| 351 file1.mutable_file_info()->set_size(1048576); | 356 file1.mutable_file_info()->set_size(1048576); |
| 352 base::FilePath file_path; | |
| 353 resource_metadata->AddEntry( | 357 resource_metadata->AddEntry( |
| 354 file1, | 358 file1, |
| 355 google_apis::test_util::CreateCopyResultCallback(&error, &file_path)); | 359 google_apis::test_util::CreateCopyResultCallback(&error, &file_path)); |
| 356 google_apis::test_util::RunBlockingPoolTask(); | 360 google_apis::test_util::RunBlockingPoolTask(); |
| 357 if (error != DRIVE_FILE_OK) | 361 if (error != DRIVE_FILE_OK) |
| 358 return false; | 362 return false; |
| 359 | 363 |
| 360 // drive/Dir1 | 364 // drive/root/Dir1 |
| 361 DriveEntryProto dir1; | 365 DriveEntryProto dir1; |
| 362 dir1.set_title("Dir1"); | 366 dir1.set_title("Dir1"); |
| 363 dir1.set_resource_id("resource_id:Dir1"); | 367 dir1.set_resource_id("resource_id:Dir1"); |
| 364 dir1.set_parent_resource_id(root_resource_id); | 368 dir1.set_parent_resource_id(root_resource_id); |
| 365 dir1.set_upload_url("http://resumable-create-media/2"); | 369 dir1.set_upload_url("http://resumable-create-media/2"); |
| 366 dir1.mutable_file_info()->set_is_directory(true); | 370 dir1.mutable_file_info()->set_is_directory(true); |
| 367 resource_metadata->AddEntry( | 371 resource_metadata->AddEntry( |
| 368 dir1, | 372 dir1, |
| 369 google_apis::test_util::CreateCopyResultCallback(&error, &file_path)); | 373 google_apis::test_util::CreateCopyResultCallback(&error, &file_path)); |
| 370 google_apis::test_util::RunBlockingPoolTask(); | 374 google_apis::test_util::RunBlockingPoolTask(); |
| 371 if (error != DRIVE_FILE_OK) | 375 if (error != DRIVE_FILE_OK) |
| 372 return false; | 376 return false; |
| 373 | 377 |
| 374 // drive/Dir1/File2 | 378 // drive/root/Dir1/File2 |
| 375 DriveEntryProto file2; | 379 DriveEntryProto file2; |
| 376 file2.set_title("File2"); | 380 file2.set_title("File2"); |
| 377 file2.set_resource_id("resource_id:File2"); | 381 file2.set_resource_id("resource_id:File2"); |
| 378 file2.set_parent_resource_id(dir1.resource_id()); | 382 file2.set_parent_resource_id(dir1.resource_id()); |
| 379 file2.set_upload_url("http://resumable-edit-media/2"); | 383 file2.set_upload_url("http://resumable-edit-media/2"); |
| 380 file2.mutable_file_specific_info()->set_file_md5("md5"); | 384 file2.mutable_file_specific_info()->set_file_md5("md5"); |
| 381 file2.mutable_file_info()->set_is_directory(false); | 385 file2.mutable_file_info()->set_is_directory(false); |
| 382 file2.mutable_file_info()->set_size(555); | 386 file2.mutable_file_info()->set_size(555); |
| 383 resource_metadata->AddEntry( | 387 resource_metadata->AddEntry( |
| 384 file2, | 388 file2, |
| 385 google_apis::test_util::CreateCopyResultCallback(&error, &file_path)); | 389 google_apis::test_util::CreateCopyResultCallback(&error, &file_path)); |
| 386 google_apis::test_util::RunBlockingPoolTask(); | 390 google_apis::test_util::RunBlockingPoolTask(); |
| 387 if (error != DRIVE_FILE_OK) | 391 if (error != DRIVE_FILE_OK) |
| 388 return false; | 392 return false; |
| 389 | 393 |
| 390 // drive/Dir1/SubDir2 | 394 // drive/root/Dir1/SubDir2 |
| 391 DriveEntryProto dir2; | 395 DriveEntryProto dir2; |
| 392 dir2.set_title("SubDir2"); | 396 dir2.set_title("SubDir2"); |
| 393 dir2.set_resource_id("resource_id:SubDir2"); | 397 dir2.set_resource_id("resource_id:SubDir2"); |
| 394 dir2.set_parent_resource_id(dir1.resource_id()); | 398 dir2.set_parent_resource_id(dir1.resource_id()); |
| 395 dir2.set_upload_url("http://resumable-create-media/3"); | 399 dir2.set_upload_url("http://resumable-create-media/3"); |
| 396 dir2.mutable_file_info()->set_is_directory(true); | 400 dir2.mutable_file_info()->set_is_directory(true); |
| 397 resource_metadata->AddEntry( | 401 resource_metadata->AddEntry( |
| 398 dir2, | 402 dir2, |
| 399 google_apis::test_util::CreateCopyResultCallback(&error, &file_path)); | 403 google_apis::test_util::CreateCopyResultCallback(&error, &file_path)); |
| 400 google_apis::test_util::RunBlockingPoolTask(); | 404 google_apis::test_util::RunBlockingPoolTask(); |
| 401 if (error != DRIVE_FILE_OK) | 405 if (error != DRIVE_FILE_OK) |
| 402 return false; | 406 return false; |
| 403 | 407 |
| 404 // drive/Dir1/SubDir2/File3 | 408 // drive/root/Dir1/SubDir2/File3 |
| 405 DriveEntryProto file3; | 409 DriveEntryProto file3; |
| 406 file3.set_title("File3"); | 410 file3.set_title("File3"); |
| 407 file3.set_resource_id("resource_id:File3"); | 411 file3.set_resource_id("resource_id:File3"); |
| 408 file3.set_parent_resource_id(dir2.resource_id()); | 412 file3.set_parent_resource_id(dir2.resource_id()); |
| 409 file3.set_upload_url("http://resumable-edit-media/3"); | 413 file3.set_upload_url("http://resumable-edit-media/3"); |
| 410 file3.mutable_file_specific_info()->set_file_md5("md5"); | 414 file3.mutable_file_specific_info()->set_file_md5("md5"); |
| 411 file3.mutable_file_info()->set_is_directory(false); | 415 file3.mutable_file_info()->set_is_directory(false); |
| 412 file3.mutable_file_info()->set_size(12345); | 416 file3.mutable_file_info()->set_size(12345); |
| 413 resource_metadata->AddEntry( | 417 resource_metadata->AddEntry( |
| 414 file3, | 418 file3, |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 482 ASSERT_FALSE(entries->empty()); | 486 ASSERT_FALSE(entries->empty()); |
| 483 | 487 |
| 484 (*counter)++; | 488 (*counter)++; |
| 485 if (*counter >= expected_counter) | 489 if (*counter >= expected_counter) |
| 486 message_loop->Quit(); | 490 message_loop->Quit(); |
| 487 } | 491 } |
| 488 | 492 |
| 489 TEST_F(DriveFileSystemTest, DuplicatedAsyncInitialization) { | 493 TEST_F(DriveFileSystemTest, DuplicatedAsyncInitialization) { |
| 490 // The root directory will be loaded that triggers the event. | 494 // The root directory will be loaded that triggers the event. |
| 491 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( | 495 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| 492 Eq(base::FilePath(FILE_PATH_LITERAL("drive"))))).Times(1); | 496 Eq(base::FilePath(FILE_PATH_LITERAL("drive/root"))))).Times(1); |
| 493 | 497 |
| 494 int counter = 0; | 498 int counter = 0; |
| 495 ReadDirectoryWithSettingCallback callback = base::Bind( | 499 ReadDirectoryWithSettingCallback callback = base::Bind( |
| 496 &AsyncInitializationCallback, | 500 &AsyncInitializationCallback, |
| 497 &counter, | 501 &counter, |
| 498 2, | 502 2, |
| 499 &message_loop_); | 503 &message_loop_); |
| 500 | 504 |
| 501 file_system_->ReadDirectoryByPath( | 505 file_system_->ReadDirectoryByPath( |
| 502 base::FilePath(FILE_PATH_LITERAL("drive")), callback); | 506 base::FilePath(FILE_PATH_LITERAL("drive/root")), callback); |
| 503 file_system_->ReadDirectoryByPath( | 507 file_system_->ReadDirectoryByPath( |
| 504 base::FilePath(FILE_PATH_LITERAL("drive")), callback); | 508 base::FilePath(FILE_PATH_LITERAL("drive/root")), callback); |
| 505 message_loop_.Run(); // Wait to get our result | 509 message_loop_.Run(); // Wait to get our result |
| 506 EXPECT_EQ(2, counter); | 510 EXPECT_EQ(2, counter); |
| 507 | 511 |
| 508 // ReadDirectoryByPath() was called twice, but the account metadata should | 512 // ReadDirectoryByPath() was called twice, but the account metadata should |
| 509 // only be loaded once. In the past, there was a bug that caused it to be | 513 // only be loaded once. In the past, there was a bug that caused it to be |
| 510 // loaded twice. | 514 // loaded twice. |
| 511 EXPECT_EQ(1, fake_drive_service_->about_resource_load_count()); | 515 EXPECT_EQ(1, fake_drive_service_->about_resource_load_count()); |
| 512 // On the other hand, the resource list could be loaded twice. One for | 516 // On the other hand, the resource list could be loaded twice. One for |
| 513 // just the directory contents, and one for the entire resource list. | 517 // just the directory contents, and one for the entire resource list. |
| 514 // | 518 // |
| 515 // The |callback| function gets called back soon after the directory content | 519 // The |callback| function gets called back soon after the directory content |
| 516 // is loaded, and the full resource load is done in background asynchronously. | 520 // is loaded, and the full resource load is done in background asynchronously. |
| 517 // So it depends on timing whether we receive the full resource load request | 521 // So it depends on timing whether we receive the full resource load request |
| 518 // at this point. | 522 // at this point. |
| 519 EXPECT_TRUE(fake_drive_service_->resource_list_load_count() == 1 || | 523 EXPECT_TRUE(fake_drive_service_->resource_list_load_count() == 1 || |
| 520 fake_drive_service_->resource_list_load_count() == 2) | 524 fake_drive_service_->resource_list_load_count() == 2) |
| 521 << ": " << fake_drive_service_->resource_list_load_count(); | 525 << ": " << fake_drive_service_->resource_list_load_count(); |
| 522 } | 526 } |
| 523 | 527 |
| 524 TEST_F(DriveFileSystemTest, GetRootEntry) { | 528 TEST_F(DriveFileSystemTest, GetGrandRootEntry) { |
| 525 const base::FilePath kFilePath = base::FilePath(FILE_PATH_LITERAL("drive")); | 529 const base::FilePath kFilePath = |
| 530 base::FilePath(FILE_PATH_LITERAL("drive")); | |
| 531 scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync(kFilePath); | |
| 532 ASSERT_TRUE(entry.get()); | |
| 533 EXPECT_EQ(util::kDriveGrandRootSpecialResourceId, entry->resource_id()); | |
| 534 | |
| 535 // Getting the grand root entry should not cause the resource load to happen. | |
| 536 EXPECT_EQ(0, fake_drive_service_->about_resource_load_count()); | |
| 537 EXPECT_EQ(0, fake_drive_service_->resource_list_load_count()); | |
| 538 } | |
| 539 | |
| 540 TEST_F(DriveFileSystemTest, GetMyDriveRootEntry) { | |
|
satorux1
2013/04/05 01:55:30
Shouldn't we have a test for drive/other too?
Haruki Sato
2013/04/05 04:35:25
Done.
| |
| 541 const base::FilePath kFilePath = | |
| 542 base::FilePath(FILE_PATH_LITERAL("drive/root")); | |
| 526 scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync(kFilePath); | 543 scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync(kFilePath); |
| 527 ASSERT_TRUE(entry.get()); | 544 ASSERT_TRUE(entry.get()); |
| 528 EXPECT_EQ(fake_drive_service_->GetRootResourceId(), entry->resource_id()); | 545 EXPECT_EQ(fake_drive_service_->GetRootResourceId(), entry->resource_id()); |
| 529 | 546 |
| 530 // Getting the root entry should not cause the resource load to happen. | 547 // Getting the "My Drive" root entry should not cause the resource load to |
| 548 // happen. | |
| 531 EXPECT_EQ(0, fake_drive_service_->about_resource_load_count()); | 549 EXPECT_EQ(0, fake_drive_service_->about_resource_load_count()); |
| 532 EXPECT_EQ(0, fake_drive_service_->resource_list_load_count()); | 550 EXPECT_EQ(0, fake_drive_service_->resource_list_load_count()); |
| 533 } | 551 } |
| 534 | 552 |
| 535 TEST_F(DriveFileSystemTest, GetNonRootEntry) { | 553 TEST_F(DriveFileSystemTest, GetNonRootEntry) { |
| 536 const base::FilePath kFilePath = | 554 const base::FilePath kFilePath = |
| 537 base::FilePath(FILE_PATH_LITERAL("drive/whatever.txt")); | 555 base::FilePath(FILE_PATH_LITERAL("drive/root/whatever.txt")); |
| 538 scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync(kFilePath); | 556 scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync(kFilePath); |
| 539 // The entry should not exist as the resource metadata only contains the | 557 // The entry should not exist as the resource metadata only contains the |
| 540 // root entry now. | 558 // root entry now. |
| 541 ASSERT_FALSE(entry.get()); | 559 ASSERT_FALSE(entry.get()); |
| 542 | 560 |
| 543 // The resource load should happen because non-root entry is requested. | 561 // The resource load should happen because non-root entry is requested. |
| 544 EXPECT_EQ(1, fake_drive_service_->about_resource_load_count()); | 562 EXPECT_EQ(1, fake_drive_service_->about_resource_load_count()); |
| 545 EXPECT_EQ(1, fake_drive_service_->resource_list_load_count()); | 563 EXPECT_EQ(1, fake_drive_service_->resource_list_load_count()); |
| 546 } | 564 } |
| 547 | 565 |
| 548 TEST_F(DriveFileSystemTest, SearchRootDirectory) { | 566 TEST_F(DriveFileSystemTest, SearchRootDirectory) { |
| 549 ASSERT_TRUE(LoadRootFeedDocument()); | 567 ASSERT_TRUE(LoadRootFeedDocument()); |
| 550 | 568 |
| 551 const base::FilePath kFilePath = base::FilePath(FILE_PATH_LITERAL("drive")); | 569 const base::FilePath kFilePath = |
| 570 base::FilePath(FILE_PATH_LITERAL("drive/root")); | |
| 552 scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync(kFilePath); | 571 scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync(kFilePath); |
| 553 ASSERT_TRUE(entry.get()); | 572 ASSERT_TRUE(entry.get()); |
| 554 EXPECT_EQ(fake_drive_service_->GetRootResourceId(), entry->resource_id()); | 573 EXPECT_EQ(fake_drive_service_->GetRootResourceId(), entry->resource_id()); |
| 555 | 574 |
| 556 // The changestamp should be propagated to the root directory. | 575 // The changestamp should be propagated to the root directory. |
| 557 EXPECT_EQ(fake_drive_service_->largest_changestamp(), | 576 EXPECT_EQ(fake_drive_service_->largest_changestamp(), |
| 558 entry->directory_specific_info().changestamp()); | 577 entry->directory_specific_info().changestamp()); |
| 559 } | 578 } |
| 560 | 579 |
| 561 TEST_F(DriveFileSystemTest, SearchExistingFile) { | 580 TEST_F(DriveFileSystemTest, SearchExistingFile) { |
| 562 ASSERT_TRUE(LoadRootFeedDocument()); | 581 ASSERT_TRUE(LoadRootFeedDocument()); |
| 563 | 582 |
| 564 const base::FilePath kFilePath = base::FilePath( | 583 const base::FilePath kFilePath = base::FilePath( |
| 565 FILE_PATH_LITERAL("drive/File 1.txt")); | 584 FILE_PATH_LITERAL("drive/root/File 1.txt")); |
| 566 scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync(kFilePath); | 585 scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync(kFilePath); |
| 567 ASSERT_TRUE(entry.get()); | 586 ASSERT_TRUE(entry.get()); |
| 568 EXPECT_EQ("file:2_file_resource_id", entry->resource_id()); | 587 EXPECT_EQ("file:2_file_resource_id", entry->resource_id()); |
| 569 } | 588 } |
| 570 | 589 |
| 571 TEST_F(DriveFileSystemTest, SearchExistingDocument) { | 590 TEST_F(DriveFileSystemTest, SearchExistingDocument) { |
| 572 ASSERT_TRUE(LoadRootFeedDocument()); | 591 ASSERT_TRUE(LoadRootFeedDocument()); |
| 573 | 592 |
| 574 const base::FilePath kFilePath = base::FilePath( | 593 const base::FilePath kFilePath = base::FilePath( |
| 575 FILE_PATH_LITERAL("drive/Document 1.gdoc")); | 594 FILE_PATH_LITERAL("drive/root/Document 1.gdoc")); |
| 576 scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync(kFilePath); | 595 scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync(kFilePath); |
| 577 ASSERT_TRUE(entry.get()); | 596 ASSERT_TRUE(entry.get()); |
| 578 EXPECT_EQ("document:5_document_resource_id", entry->resource_id()); | 597 EXPECT_EQ("document:5_document_resource_id", entry->resource_id()); |
| 579 } | 598 } |
| 580 | 599 |
| 581 TEST_F(DriveFileSystemTest, SearchNonExistingFile) { | 600 TEST_F(DriveFileSystemTest, SearchNonExistingFile) { |
| 582 ASSERT_TRUE(LoadRootFeedDocument()); | 601 ASSERT_TRUE(LoadRootFeedDocument()); |
| 583 | 602 |
| 584 const base::FilePath kFilePath = base::FilePath( | 603 const base::FilePath kFilePath = base::FilePath( |
| 585 FILE_PATH_LITERAL("drive/nonexisting.file")); | 604 FILE_PATH_LITERAL("drive/root/nonexisting.file")); |
| 586 scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync(kFilePath); | 605 scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync(kFilePath); |
| 587 ASSERT_FALSE(entry.get()); | 606 ASSERT_FALSE(entry.get()); |
| 588 } | 607 } |
| 589 | 608 |
| 590 TEST_F(DriveFileSystemTest, SearchEncodedFileNames) { | 609 TEST_F(DriveFileSystemTest, SearchEncodedFileNames) { |
| 591 ASSERT_TRUE(LoadRootFeedDocument()); | 610 ASSERT_TRUE(LoadRootFeedDocument()); |
| 592 | 611 |
| 593 const base::FilePath kFilePath1 = base::FilePath( | 612 const base::FilePath kFilePath1 = base::FilePath( |
| 594 FILE_PATH_LITERAL("drive/Slash / in file 1.txt")); | 613 FILE_PATH_LITERAL("drive/root/Slash / in file 1.txt")); |
| 595 scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync(kFilePath1); | 614 scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync(kFilePath1); |
| 596 ASSERT_FALSE(entry.get()); | 615 ASSERT_FALSE(entry.get()); |
| 597 | 616 |
| 598 const base::FilePath kFilePath2 = base::FilePath::FromUTF8Unsafe( | 617 const base::FilePath kFilePath2 = base::FilePath::FromUTF8Unsafe( |
| 599 "drive/Slash \xE2\x88\x95 in file 1.txt"); | 618 "drive/root/Slash \xE2\x88\x95 in file 1.txt"); |
| 600 entry = GetEntryInfoByPathSync(kFilePath2); | 619 entry = GetEntryInfoByPathSync(kFilePath2); |
| 601 ASSERT_TRUE(entry.get()); | 620 ASSERT_TRUE(entry.get()); |
| 602 EXPECT_EQ("file:slash_file_resource_id", entry->resource_id()); | 621 EXPECT_EQ("file:slash_file_resource_id", entry->resource_id()); |
| 603 | 622 |
| 604 const base::FilePath kFilePath3 = base::FilePath::FromUTF8Unsafe( | 623 const base::FilePath kFilePath3 = base::FilePath::FromUTF8Unsafe( |
| 605 "drive/Slash \xE2\x88\x95 in directory/Slash SubDir File.txt"); | 624 "drive/root/Slash \xE2\x88\x95 in directory/Slash SubDir File.txt"); |
| 606 entry = GetEntryInfoByPathSync(kFilePath3); | 625 entry = GetEntryInfoByPathSync(kFilePath3); |
| 607 ASSERT_TRUE(entry.get()); | 626 ASSERT_TRUE(entry.get()); |
| 608 EXPECT_EQ("file:slash_subdir_file", entry->resource_id()); | 627 EXPECT_EQ("file:slash_subdir_file", entry->resource_id()); |
| 609 } | 628 } |
| 610 | 629 |
| 611 TEST_F(DriveFileSystemTest, SearchEncodedFileNamesLoadingRoot) { | 630 TEST_F(DriveFileSystemTest, SearchEncodedFileNamesLoadingRoot) { |
| 612 ASSERT_TRUE(LoadRootFeedDocument()); | 631 ASSERT_TRUE(LoadRootFeedDocument()); |
| 613 | 632 |
| 614 const base::FilePath kFilePath1 = base::FilePath( | 633 const base::FilePath kFilePath1 = base::FilePath( |
| 615 FILE_PATH_LITERAL("drive/Slash / in file 1.txt")); | 634 FILE_PATH_LITERAL("drive/root/Slash / in file 1.txt")); |
| 616 scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync(kFilePath1); | 635 scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync(kFilePath1); |
| 617 ASSERT_FALSE(entry.get()); | 636 ASSERT_FALSE(entry.get()); |
| 618 | 637 |
| 619 const base::FilePath kFilePath2 = base::FilePath::FromUTF8Unsafe( | 638 const base::FilePath kFilePath2 = base::FilePath::FromUTF8Unsafe( |
| 620 "drive/Slash \xE2\x88\x95 in file 1.txt"); | 639 "drive/root/Slash \xE2\x88\x95 in file 1.txt"); |
| 621 entry = GetEntryInfoByPathSync(kFilePath2); | 640 entry = GetEntryInfoByPathSync(kFilePath2); |
| 622 ASSERT_TRUE(entry.get()); | 641 ASSERT_TRUE(entry.get()); |
| 623 EXPECT_EQ("file:slash_file_resource_id", entry->resource_id()); | 642 EXPECT_EQ("file:slash_file_resource_id", entry->resource_id()); |
| 624 | 643 |
| 625 const base::FilePath kFilePath3 = base::FilePath::FromUTF8Unsafe( | 644 const base::FilePath kFilePath3 = base::FilePath::FromUTF8Unsafe( |
| 626 "drive/Slash \xE2\x88\x95 in directory/Slash SubDir File.txt"); | 645 "drive/root/Slash \xE2\x88\x95 in directory/Slash SubDir File.txt"); |
| 627 entry = GetEntryInfoByPathSync(kFilePath3); | 646 entry = GetEntryInfoByPathSync(kFilePath3); |
| 628 ASSERT_TRUE(entry.get()); | 647 ASSERT_TRUE(entry.get()); |
| 629 EXPECT_EQ("file:slash_subdir_file", entry->resource_id()); | 648 EXPECT_EQ("file:slash_subdir_file", entry->resource_id()); |
| 630 } | 649 } |
| 631 | 650 |
| 632 TEST_F(DriveFileSystemTest, SearchDuplicateNames) { | 651 TEST_F(DriveFileSystemTest, SearchDuplicateNames) { |
| 633 ASSERT_TRUE(LoadRootFeedDocument()); | 652 ASSERT_TRUE(LoadRootFeedDocument()); |
| 634 | 653 |
| 635 const base::FilePath kFilePath1 = base::FilePath( | 654 const base::FilePath kFilePath1 = base::FilePath( |
| 636 FILE_PATH_LITERAL("drive/Duplicate Name.txt")); | 655 FILE_PATH_LITERAL("drive/root/Duplicate Name.txt")); |
| 637 scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync(kFilePath1); | 656 scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync(kFilePath1); |
| 638 ASSERT_TRUE(entry.get()); | 657 ASSERT_TRUE(entry.get()); |
| 639 const std::string resource_id1 = entry->resource_id(); | 658 const std::string resource_id1 = entry->resource_id(); |
| 640 | 659 |
| 641 const base::FilePath kFilePath2 = base::FilePath( | 660 const base::FilePath kFilePath2 = base::FilePath( |
| 642 FILE_PATH_LITERAL("drive/Duplicate Name (2).txt")); | 661 FILE_PATH_LITERAL("drive/root/Duplicate Name (2).txt")); |
| 643 entry = GetEntryInfoByPathSync(kFilePath2); | 662 entry = GetEntryInfoByPathSync(kFilePath2); |
| 644 ASSERT_TRUE(entry.get()); | 663 ASSERT_TRUE(entry.get()); |
| 645 const std::string resource_id2 = entry->resource_id(); | 664 const std::string resource_id2 = entry->resource_id(); |
| 646 | 665 |
| 647 // The entries are de-duped non-deterministically, so we shouldn't rely on the | 666 // The entries are de-duped non-deterministically, so we shouldn't rely on the |
| 648 // names matching specific resource ids. | 667 // names matching specific resource ids. |
| 649 const std::string file3_resource_id = "file:3_file_resource_id"; | 668 const std::string file3_resource_id = "file:3_file_resource_id"; |
| 650 const std::string file4_resource_id = "file:4_file_resource_id"; | 669 const std::string file4_resource_id = "file:4_file_resource_id"; |
| 651 EXPECT_TRUE(file3_resource_id == resource_id1 || | 670 EXPECT_TRUE(file3_resource_id == resource_id1 || |
| 652 file3_resource_id == resource_id2); | 671 file3_resource_id == resource_id2); |
| 653 EXPECT_TRUE(file4_resource_id == resource_id1 || | 672 EXPECT_TRUE(file4_resource_id == resource_id1 || |
| 654 file4_resource_id == resource_id2); | 673 file4_resource_id == resource_id2); |
| 655 } | 674 } |
| 656 | 675 |
| 657 TEST_F(DriveFileSystemTest, SearchExistingDirectory) { | 676 TEST_F(DriveFileSystemTest, SearchExistingDirectory) { |
| 658 ASSERT_TRUE(LoadRootFeedDocument()); | 677 ASSERT_TRUE(LoadRootFeedDocument()); |
| 659 | 678 |
| 660 const base::FilePath kFilePath = base::FilePath( | 679 const base::FilePath kFilePath = base::FilePath( |
| 661 FILE_PATH_LITERAL("drive/Directory 1")); | 680 FILE_PATH_LITERAL("drive/root/Directory 1")); |
| 662 scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync(kFilePath); | 681 scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync(kFilePath); |
| 663 ASSERT_TRUE(entry.get()); | 682 ASSERT_TRUE(entry.get()); |
| 664 ASSERT_EQ("folder:1_folder_resource_id", entry->resource_id()); | 683 ASSERT_EQ("folder:1_folder_resource_id", entry->resource_id()); |
| 665 | 684 |
| 666 // The changestamp should be propagated to the directory. | 685 // The changestamp should be propagated to the directory. |
| 667 EXPECT_EQ(fake_drive_service_->largest_changestamp(), | 686 EXPECT_EQ(fake_drive_service_->largest_changestamp(), |
| 668 entry->directory_specific_info().changestamp()); | 687 entry->directory_specific_info().changestamp()); |
| 669 } | 688 } |
| 670 | 689 |
| 671 TEST_F(DriveFileSystemTest, SearchInSubdir) { | 690 TEST_F(DriveFileSystemTest, SearchInSubdir) { |
| 672 ASSERT_TRUE(LoadRootFeedDocument()); | 691 ASSERT_TRUE(LoadRootFeedDocument()); |
| 673 | 692 |
| 674 const base::FilePath kFilePath = base::FilePath( | 693 const base::FilePath kFilePath = base::FilePath( |
| 675 FILE_PATH_LITERAL("drive/Directory 1/SubDirectory File 1.txt")); | 694 FILE_PATH_LITERAL("drive/root/Directory 1/SubDirectory File 1.txt")); |
| 676 scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync(kFilePath); | 695 scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync(kFilePath); |
| 677 ASSERT_TRUE(entry.get()); | 696 ASSERT_TRUE(entry.get()); |
| 678 ASSERT_EQ("file:subdirectory_file_1_id", entry->resource_id()); | 697 ASSERT_EQ("file:subdirectory_file_1_id", entry->resource_id()); |
| 679 } | 698 } |
| 680 | 699 |
| 681 // Check the reconstruction of the directory structure from only the root feed. | 700 // Check the reconstruction of the directory structure from only the root feed. |
| 682 TEST_F(DriveFileSystemTest, SearchInSubSubdir) { | 701 TEST_F(DriveFileSystemTest, SearchInSubSubdir) { |
| 683 ASSERT_TRUE(LoadRootFeedDocument()); | 702 ASSERT_TRUE(LoadRootFeedDocument()); |
| 684 | 703 |
| 685 const base::FilePath kFilePath = base::FilePath( | 704 const base::FilePath kFilePath = base::FilePath( |
| 686 FILE_PATH_LITERAL("drive/Directory 1/Sub Directory Folder/" | 705 FILE_PATH_LITERAL("drive/root/Directory 1/Sub Directory Folder/" |
| 687 "Sub Sub Directory Folder")); | 706 "Sub Sub Directory Folder")); |
| 688 scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync(kFilePath); | 707 scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync(kFilePath); |
| 689 ASSERT_TRUE(entry.get()); | 708 ASSERT_TRUE(entry.get()); |
| 690 ASSERT_EQ("folder:sub_sub_directory_folder_id", entry->resource_id()); | 709 ASSERT_EQ("folder:sub_sub_directory_folder_id", entry->resource_id()); |
| 691 } | 710 } |
| 692 | 711 |
| 693 TEST_F(DriveFileSystemTest, ReadDirectoryByPath_Root) { | 712 TEST_F(DriveFileSystemTest, ReadDirectoryByPath_Root) { |
| 694 // The root directory will be loaded that triggers the event. | |
| 695 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( | 713 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| 696 Eq(base::FilePath(FILE_PATH_LITERAL("drive"))))).Times(1); | 714 Eq(base::FilePath(FILE_PATH_LITERAL("drive/root"))))).Times(1); |
| 697 | 715 |
| 698 // ReadDirectoryByPath() should kick off the resource list loading. | 716 // ReadDirectoryByPath() should kick off the resource list loading. |
| 699 scoped_ptr<DriveEntryProtoVector> entries( | 717 scoped_ptr<DriveEntryProtoVector> entries( |
| 700 ReadDirectoryByPathSync(base::FilePath::FromUTF8Unsafe("drive"))); | 718 ReadDirectoryByPathSync(base::FilePath::FromUTF8Unsafe("drive/root"))); |
| 701 // The root directory should be read correctly. | 719 // The root directory should be read correctly. |
| 702 ASSERT_TRUE(entries.get()); | 720 ASSERT_TRUE(entries.get()); |
| 703 EXPECT_EQ(8U, entries->size()); | 721 EXPECT_EQ(8U, entries->size()); |
| 704 } | 722 } |
| 705 | 723 |
| 706 TEST_F(DriveFileSystemTest, ReadDirectoryByPath_NonRootDirectory) { | 724 TEST_F(DriveFileSystemTest, ReadDirectoryByPath_NonRootDirectory) { |
| 707 // ReadDirectoryByPath() should kick off the resource list loading. | 725 // ReadDirectoryByPath() should kick off the resource list loading. |
| 708 scoped_ptr<DriveEntryProtoVector> entries( | 726 scoped_ptr<DriveEntryProtoVector> entries( |
| 709 ReadDirectoryByPathSync( | 727 ReadDirectoryByPathSync( |
| 710 base::FilePath::FromUTF8Unsafe("drive/Directory 1"))); | 728 base::FilePath::FromUTF8Unsafe("drive/root/Directory 1"))); |
| 711 // The non root directory should also be read correctly. | 729 // The non root directory should also be read correctly. |
| 712 // There was a bug (crbug.com/181487), which broke this behavior. | 730 // There was a bug (crbug.com/181487), which broke this behavior. |
| 713 // Make sure this is fixed. | 731 // Make sure this is fixed. |
| 714 ASSERT_TRUE(entries.get()); | 732 ASSERT_TRUE(entries.get()); |
| 715 EXPECT_EQ(3U, entries->size()); | 733 EXPECT_EQ(3U, entries->size()); |
| 716 } | 734 } |
| 717 | 735 |
| 718 TEST_F(DriveFileSystemTest, FilePathTests) { | 736 TEST_F(DriveFileSystemTest, FilePathTests) { |
| 719 ASSERT_TRUE(LoadRootFeedDocument()); | 737 ASSERT_TRUE(LoadRootFeedDocument()); |
| 720 | 738 |
| 721 EXPECT_TRUE( | 739 EXPECT_TRUE( |
| 722 EntryExists(base::FilePath(FILE_PATH_LITERAL("drive/File 1.txt")))); | 740 EntryExists(base::FilePath(FILE_PATH_LITERAL("drive/root/File 1.txt")))); |
| 723 EXPECT_TRUE( | 741 EXPECT_TRUE( |
| 724 EntryExists(base::FilePath(FILE_PATH_LITERAL("drive/Directory 1")))); | 742 EntryExists(base::FilePath(FILE_PATH_LITERAL("drive/root/Directory 1")))); |
| 725 EXPECT_TRUE(EntryExists( | 743 EXPECT_TRUE(EntryExists(base::FilePath( |
| 726 base::FilePath( | 744 FILE_PATH_LITERAL("drive/root/Directory 1/SubDirectory File 1.txt")))); |
| 727 FILE_PATH_LITERAL("drive/Directory 1/SubDirectory File 1.txt")))); | |
| 728 } | 745 } |
| 729 | 746 |
| 730 TEST_F(DriveFileSystemTest, ChangeFeed_AddAndDeleteFileInRoot) { | 747 TEST_F(DriveFileSystemTest, ChangeFeed_AddAndDeleteFileInRoot) { |
| 731 ASSERT_TRUE(LoadRootFeedDocument()); | 748 ASSERT_TRUE(LoadRootFeedDocument()); |
| 732 | 749 |
| 733 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( | 750 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| 734 Eq(base::FilePath(FILE_PATH_LITERAL("drive"))))).Times(2); | 751 Eq(base::FilePath(FILE_PATH_LITERAL("drive/root"))))).Times(2); |
| 735 | 752 |
| 736 ASSERT_TRUE(LoadChangeFeed("chromeos/gdata/delta_file_added_in_root.json")); | 753 ASSERT_TRUE(LoadChangeFeed("chromeos/gdata/delta_file_added_in_root.json")); |
| 737 EXPECT_TRUE( | 754 EXPECT_TRUE(EntryExists( |
| 738 EntryExists(base::FilePath(FILE_PATH_LITERAL("drive/Added file.gdoc")))); | 755 base::FilePath(FILE_PATH_LITERAL("drive/root/Added file.gdoc")))); |
| 739 | 756 |
| 740 ASSERT_TRUE(LoadChangeFeed("chromeos/gdata/delta_file_deleted_in_root.json")); | 757 ASSERT_TRUE(LoadChangeFeed("chromeos/gdata/delta_file_deleted_in_root.json")); |
| 741 EXPECT_FALSE( | 758 EXPECT_FALSE(EntryExists( |
| 742 EntryExists(base::FilePath(FILE_PATH_LITERAL("drive/Added file.gdoc")))); | 759 base::FilePath(FILE_PATH_LITERAL("drive/root/Added file.gdoc")))); |
| 743 } | 760 } |
| 744 | 761 |
| 745 | 762 |
| 746 TEST_F(DriveFileSystemTest, ChangeFeed_AddAndDeleteFileFromExistingDirectory) { | 763 TEST_F(DriveFileSystemTest, ChangeFeed_AddAndDeleteFileFromExistingDirectory) { |
| 747 ASSERT_TRUE(LoadRootFeedDocument()); | 764 ASSERT_TRUE(LoadRootFeedDocument()); |
| 748 | 765 |
| 749 EXPECT_TRUE( | 766 EXPECT_TRUE( |
| 750 EntryExists(base::FilePath(FILE_PATH_LITERAL("drive/Directory 1")))); | 767 EntryExists(base::FilePath(FILE_PATH_LITERAL("drive/root/Directory 1")))); |
| 751 | 768 |
| 752 // Add file to an existing directory. | 769 // Add file to an existing directory. |
| 753 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( | 770 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| 754 Eq(base::FilePath(FILE_PATH_LITERAL("drive"))))).Times(1); | 771 Eq(base::FilePath(FILE_PATH_LITERAL("drive/root"))))).Times(1); |
| 755 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( | 772 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| 756 Eq(base::FilePath(FILE_PATH_LITERAL("drive/Directory 1"))))).Times(1); | 773 Eq(base::FilePath(FILE_PATH_LITERAL("drive/root/Directory 1"))))) |
| 774 .Times(1); | |
| 757 ASSERT_TRUE( | 775 ASSERT_TRUE( |
| 758 LoadChangeFeed("chromeos/gdata/delta_file_added_in_directory.json")); | 776 LoadChangeFeed("chromeos/gdata/delta_file_added_in_directory.json")); |
| 759 EXPECT_TRUE(EntryExists(base::FilePath( | 777 EXPECT_TRUE(EntryExists(base::FilePath( |
| 760 FILE_PATH_LITERAL("drive/Directory 1/Added file.gdoc")))); | 778 FILE_PATH_LITERAL("drive/root/Directory 1/Added file.gdoc")))); |
| 761 | 779 |
| 762 // Remove that file from the directory. | 780 // Remove that file from the directory. |
| 763 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( | 781 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| 764 Eq(base::FilePath(FILE_PATH_LITERAL("drive/Directory 1"))))).Times(1); | 782 Eq(base::FilePath(FILE_PATH_LITERAL("drive/root/Directory 1"))))) |
| 783 .Times(1); | |
| 765 ASSERT_TRUE( | 784 ASSERT_TRUE( |
| 766 LoadChangeFeed("chromeos/gdata/delta_file_deleted_in_directory.json")); | 785 LoadChangeFeed("chromeos/gdata/delta_file_deleted_in_directory.json")); |
| 767 EXPECT_TRUE( | 786 EXPECT_TRUE( |
| 768 EntryExists(base::FilePath(FILE_PATH_LITERAL("drive/Directory 1")))); | 787 EntryExists(base::FilePath(FILE_PATH_LITERAL("drive/root/Directory 1")))); |
| 769 EXPECT_FALSE(EntryExists(base::FilePath( | 788 EXPECT_FALSE(EntryExists(base::FilePath( |
| 770 FILE_PATH_LITERAL("drive/Directory 1/Added file.gdoc")))); | 789 FILE_PATH_LITERAL("drive/root/Directory 1/Added file.gdoc")))); |
| 771 } | 790 } |
| 772 | 791 |
| 773 TEST_F(DriveFileSystemTest, ChangeFeed_AddFileToNewDirectory) { | 792 TEST_F(DriveFileSystemTest, ChangeFeed_AddFileToNewDirectory) { |
| 774 ASSERT_TRUE(LoadRootFeedDocument()); | 793 ASSERT_TRUE(LoadRootFeedDocument()); |
| 775 // Add file to a new directory. | 794 // Add file to a new directory. |
| 776 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( | 795 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| 777 Eq(base::FilePath(FILE_PATH_LITERAL("drive"))))).Times(1); | 796 Eq(base::FilePath(FILE_PATH_LITERAL("drive/root"))))).Times(1); |
| 778 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( | 797 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| 779 Eq(base::FilePath(FILE_PATH_LITERAL("drive/New Directory"))))).Times(1); | 798 Eq(base::FilePath(FILE_PATH_LITERAL("drive/root/New Directory"))))) |
| 799 .Times(1); | |
| 780 | 800 |
| 781 ASSERT_TRUE( | 801 ASSERT_TRUE( |
| 782 LoadChangeFeed("chromeos/gdata/delta_file_added_in_new_directory.json")); | 802 LoadChangeFeed("chromeos/gdata/delta_file_added_in_new_directory.json")); |
| 783 | 803 |
| 784 EXPECT_TRUE( | 804 EXPECT_TRUE( |
| 785 EntryExists(base::FilePath(FILE_PATH_LITERAL("drive/New Directory")))); | 805 EntryExists(base::FilePath( |
| 806 FILE_PATH_LITERAL("drive/root/New Directory")))); | |
| 786 EXPECT_TRUE(EntryExists(base::FilePath( | 807 EXPECT_TRUE(EntryExists(base::FilePath( |
| 787 FILE_PATH_LITERAL("drive/New Directory/File in new dir.gdoc")))); | 808 FILE_PATH_LITERAL("drive/root/New Directory/File in new dir.gdoc")))); |
| 788 } | 809 } |
| 789 | 810 |
| 790 TEST_F(DriveFileSystemTest, ChangeFeed_AddFileToNewButDeletedDirectory) { | 811 TEST_F(DriveFileSystemTest, ChangeFeed_AddFileToNewButDeletedDirectory) { |
| 791 ASSERT_TRUE(LoadRootFeedDocument()); | 812 ASSERT_TRUE(LoadRootFeedDocument()); |
| 792 | 813 |
| 793 // This feed contains the following updates: | 814 // This feed contains the following updates: |
| 794 // 1) A new PDF file is added to a new directory | 815 // 1) A new PDF file is added to a new directory |
| 795 // 2) but the new directory is marked "deleted" (i.e. moved to Trash) | 816 // 2) but the new directory is marked "deleted" (i.e. moved to Trash) |
| 796 // Hence, the PDF file should be just ignored. | 817 // Hence, the PDF file should be just ignored. |
| 797 ASSERT_TRUE(LoadChangeFeed( | 818 ASSERT_TRUE(LoadChangeFeed( |
| 798 "chromeos/gdata/delta_file_added_in_new_but_deleted_directory.json")); | 819 "chromeos/gdata/delta_file_added_in_new_but_deleted_directory.json")); |
| 799 } | 820 } |
| 800 | 821 |
| 801 TEST_F(DriveFileSystemTest, ChangeFeed_DirectoryMovedFromRootToDirectory) { | 822 TEST_F(DriveFileSystemTest, ChangeFeed_DirectoryMovedFromRootToDirectory) { |
| 802 ASSERT_TRUE(LoadRootFeedDocument()); | 823 ASSERT_TRUE(LoadRootFeedDocument()); |
| 803 | 824 |
| 804 EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL( | 825 EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL( |
| 805 "drive/Directory 2")))); | 826 "drive/root/Directory 2")))); |
| 806 EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL( | 827 EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL( |
| 807 "drive/Directory 1")))); | 828 "drive/root/Directory 1")))); |
| 808 EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL( | 829 EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL( |
| 809 "drive/Directory 1/SubDirectory File 1.txt")))); | 830 "drive/root/Directory 1/SubDirectory File 1.txt")))); |
| 810 EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL( | 831 EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL( |
| 811 "drive/Directory 1/Sub Directory Folder")))); | 832 "drive/root/Directory 1/Sub Directory Folder")))); |
| 812 EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL( | 833 EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL( |
| 813 "drive/Directory 1/Sub Directory Folder/Sub Sub Directory Folder")))); | 834 "drive/root/Directory 1/Sub Directory Folder/" |
| 835 "Sub Sub Directory Folder")))); | |
| 814 | 836 |
| 815 // This will move "Directory 1" from "drive/" to "drive/Directory 2/". | 837 // This will move "Directory 1" from "drive/root/" to |
| 838 // "drive/root/Directory 2/". | |
| 816 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( | 839 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| 817 Eq(base::FilePath(FILE_PATH_LITERAL("drive"))))).Times(1); | 840 Eq(base::FilePath(FILE_PATH_LITERAL("drive/root"))))).Times(1); |
| 818 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( | 841 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| 819 Eq(base::FilePath(FILE_PATH_LITERAL("drive/Directory 1"))))).Times(1); | 842 Eq(base::FilePath(FILE_PATH_LITERAL("drive/root/Directory 1"))))) |
| 843 .Times(1); | |
| 820 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( | 844 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| 821 Eq(base::FilePath(FILE_PATH_LITERAL("drive/Directory 2"))))).Times(1); | 845 Eq(base::FilePath(FILE_PATH_LITERAL("drive/root/Directory 2"))))) |
| 846 .Times(1); | |
| 822 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( | 847 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| 823 Eq(base::FilePath(FILE_PATH_LITERAL("drive/Directory 2/Directory 1"))))) | 848 Eq(base::FilePath( |
| 824 .Times(1); | 849 FILE_PATH_LITERAL("drive/root/Directory 2/Directory 1"))))).Times(1); |
| 825 ASSERT_TRUE(LoadChangeFeed( | 850 ASSERT_TRUE(LoadChangeFeed( |
| 826 "chromeos/gdata/delta_dir_moved_from_root_to_directory.json")); | 851 "chromeos/gdata/delta_dir_moved_from_root_to_directory.json")); |
| 827 | 852 |
| 828 EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL( | 853 EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL( |
| 829 "drive/Directory 2")))); | 854 "drive/root/Directory 2")))); |
| 830 EXPECT_FALSE(EntryExists(base::FilePath(FILE_PATH_LITERAL( | 855 EXPECT_FALSE(EntryExists(base::FilePath(FILE_PATH_LITERAL( |
| 831 "drive/Directory 1")))); | 856 "drive/root/Directory 1")))); |
| 832 EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL( | 857 EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL( |
| 833 "drive/Directory 2/Directory 1")))); | 858 "drive/root/Directory 2/Directory 1")))); |
| 834 EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL( | 859 EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL( |
| 835 "drive/Directory 2/Directory 1/SubDirectory File 1.txt")))); | 860 "drive/root/Directory 2/Directory 1/SubDirectory File 1.txt")))); |
| 836 EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL( | 861 EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL( |
| 837 "drive/Directory 2/Directory 1/Sub Directory Folder")))); | 862 "drive/root/Directory 2/Directory 1/Sub Directory Folder")))); |
| 838 EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL( | 863 EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL( |
| 839 "drive/Directory 2/Directory 1/Sub Directory Folder/" | 864 "drive/root/Directory 2/Directory 1/Sub Directory Folder/" |
| 840 "Sub Sub Directory Folder")))); | 865 "Sub Sub Directory Folder")))); |
| 841 } | 866 } |
| 842 | 867 |
| 843 TEST_F(DriveFileSystemTest, ChangeFeed_FileMovedFromDirectoryToRoot) { | 868 TEST_F(DriveFileSystemTest, ChangeFeed_FileMovedFromDirectoryToRoot) { |
| 844 ASSERT_TRUE(LoadRootFeedDocument()); | 869 ASSERT_TRUE(LoadRootFeedDocument()); |
| 845 | 870 |
| 846 EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL( | 871 EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL( |
| 847 "drive/Directory 1")))); | 872 "drive/root/Directory 1")))); |
| 848 EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL( | 873 EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL( |
| 849 "drive/Directory 1/Sub Directory Folder")))); | 874 "drive/root/Directory 1/Sub Directory Folder")))); |
| 850 EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL( | 875 EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL( |
| 851 "drive/Directory 1/Sub Directory Folder/Sub Sub Directory Folder")))); | 876 "drive/root/Directory 1/Sub Directory Folder/" |
| 877 "Sub Sub Directory Folder")))); | |
| 852 EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL( | 878 EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL( |
| 853 "drive/Directory 1/SubDirectory File 1.txt")))); | 879 "drive/root/Directory 1/SubDirectory File 1.txt")))); |
| 854 | 880 |
| 855 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( | 881 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| 856 Eq(base::FilePath(FILE_PATH_LITERAL("drive"))))).Times(1); | 882 Eq(base::FilePath(FILE_PATH_LITERAL("drive/root"))))).Times(1); |
| 857 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( | 883 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| 858 Eq(base::FilePath(FILE_PATH_LITERAL("drive/Directory 1"))))).Times(1); | 884 Eq(base::FilePath(FILE_PATH_LITERAL("drive/root/Directory 1"))))) |
| 885 .Times(1); | |
| 859 ASSERT_TRUE(LoadChangeFeed( | 886 ASSERT_TRUE(LoadChangeFeed( |
| 860 "chromeos/gdata/delta_file_moved_from_directory_to_root.json")); | 887 "chromeos/gdata/delta_file_moved_from_directory_to_root.json")); |
| 861 | 888 |
| 862 EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL( | 889 EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL( |
| 863 "drive/Directory 1")))); | 890 "drive/root/Directory 1")))); |
| 864 EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL( | 891 EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL( |
| 865 "drive/Directory 1/Sub Directory Folder")))); | 892 "drive/root/Directory 1/Sub Directory Folder")))); |
| 866 EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL( | 893 EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL( |
| 867 "drive/Directory 1/Sub Directory Folder/Sub Sub Directory Folder")))); | 894 "drive/root/Directory 1/Sub Directory Folder/" |
| 895 "Sub Sub Directory Folder")))); | |
| 868 EXPECT_FALSE(EntryExists(base::FilePath(FILE_PATH_LITERAL( | 896 EXPECT_FALSE(EntryExists(base::FilePath(FILE_PATH_LITERAL( |
| 869 "drive/Directory 1/SubDirectory File 1.txt")))); | 897 "drive/root/Directory 1/SubDirectory File 1.txt")))); |
| 870 EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL( | 898 EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL( |
| 871 "drive/SubDirectory File 1.txt")))); | 899 "drive/root/SubDirectory File 1.txt")))); |
| 872 } | 900 } |
| 873 | 901 |
| 874 TEST_F(DriveFileSystemTest, ChangeFeed_FileRenamedInDirectory) { | 902 TEST_F(DriveFileSystemTest, ChangeFeed_FileRenamedInDirectory) { |
| 875 ASSERT_TRUE(LoadRootFeedDocument()); | 903 ASSERT_TRUE(LoadRootFeedDocument()); |
| 876 | 904 |
| 877 EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL( | 905 EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL( |
| 878 "drive/Directory 1")))); | 906 "drive/root/Directory 1")))); |
| 879 EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL( | 907 EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL( |
| 880 "drive/Directory 1/SubDirectory File 1.txt")))); | 908 "drive/root/Directory 1/SubDirectory File 1.txt")))); |
| 881 | 909 |
| 882 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( | 910 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| 883 Eq(base::FilePath(FILE_PATH_LITERAL("drive"))))).Times(1); | 911 Eq(base::FilePath(FILE_PATH_LITERAL("drive/root"))))).Times(1); |
| 884 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( | 912 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| 885 Eq(base::FilePath(FILE_PATH_LITERAL("drive/Directory 1"))))).Times(1); | 913 Eq(base::FilePath(FILE_PATH_LITERAL("drive/root/Directory 1"))))) |
| 914 .Times(1); | |
| 886 ASSERT_TRUE(LoadChangeFeed( | 915 ASSERT_TRUE(LoadChangeFeed( |
| 887 "chromeos/gdata/delta_file_renamed_in_directory.json")); | 916 "chromeos/gdata/delta_file_renamed_in_directory.json")); |
| 888 | 917 |
| 889 EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL( | 918 EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL( |
| 890 "drive/Directory 1")))); | 919 "drive/root/Directory 1")))); |
| 891 EXPECT_FALSE(EntryExists(base::FilePath(FILE_PATH_LITERAL( | 920 EXPECT_FALSE(EntryExists(base::FilePath(FILE_PATH_LITERAL( |
| 892 "drive/Directory 1/SubDirectory File 1.txt")))); | 921 "drive/root/Directory 1/SubDirectory File 1.txt")))); |
| 893 EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL( | 922 EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL( |
| 894 "drive/Directory 1/New SubDirectory File 1.txt")))); | 923 "drive/root/Directory 1/New SubDirectory File 1.txt")))); |
| 895 } | 924 } |
| 896 | 925 |
| 897 TEST_F(DriveFileSystemTest, CachedFeedLoading) { | 926 TEST_F(DriveFileSystemTest, CachedFeedLoading) { |
| 898 ASSERT_TRUE(SaveTestFileSystem(USE_OLD_TIMESTAMP)); | 927 ASSERT_TRUE(SaveTestFileSystem(USE_OLD_TIMESTAMP)); |
| 899 // Tests that cached data can be loaded even if the server is not reachable. | 928 // Tests that cached data can be loaded even if the server is not reachable. |
| 900 fake_drive_service_->set_offline(true); | 929 fake_drive_service_->set_offline(true); |
| 901 | 930 |
| 902 EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL("drive/File1")))); | 931 EXPECT_TRUE(EntryExists(base::FilePath( |
| 903 EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL("drive/Dir1")))); | 932 FILE_PATH_LITERAL("drive/root/File1")))); |
| 933 EXPECT_TRUE(EntryExists(base::FilePath( | |
| 934 FILE_PATH_LITERAL("drive/root/Dir1")))); | |
| 904 EXPECT_TRUE( | 935 EXPECT_TRUE( |
| 905 EntryExists(base::FilePath(FILE_PATH_LITERAL("drive/Dir1/File2")))); | 936 EntryExists(base::FilePath(FILE_PATH_LITERAL("drive/root/Dir1/File2")))); |
| 906 EXPECT_TRUE( | 937 EXPECT_TRUE(EntryExists(base::FilePath( |
| 907 EntryExists(base::FilePath(FILE_PATH_LITERAL("drive/Dir1/SubDir2")))); | 938 FILE_PATH_LITERAL("drive/root/Dir1/SubDir2")))); |
| 908 EXPECT_TRUE(EntryExists( | 939 EXPECT_TRUE(EntryExists( |
| 909 base::FilePath(FILE_PATH_LITERAL("drive/Dir1/SubDir2/File3")))); | 940 base::FilePath(FILE_PATH_LITERAL("drive/root/Dir1/SubDir2/File3")))); |
| 910 } | 941 } |
| 911 | 942 |
| 912 TEST_F(DriveFileSystemTest, CachedFeedLoadingThenServerFeedLoading) { | 943 TEST_F(DriveFileSystemTest, CachedFeedLoadingThenServerFeedLoading) { |
| 913 ASSERT_TRUE(SaveTestFileSystem(USE_SERVER_TIMESTAMP)); | 944 ASSERT_TRUE(SaveTestFileSystem(USE_SERVER_TIMESTAMP)); |
| 914 | 945 |
| 915 // Kicks loading of cached file system and query for server update. | 946 // Kicks loading of cached file system and query for server update. |
| 916 EXPECT_TRUE(ReadDirectoryByPathSync(util::GetDriveMyDriveRootPath())); | 947 EXPECT_TRUE(ReadDirectoryByPathSync(util::GetDriveMyDriveRootPath())); |
| 917 | 948 |
| 918 // SaveTestFileSystem and "account_metadata.json" have the same changestamp, | 949 // SaveTestFileSystem and "account_metadata.json" have the same changestamp, |
| 919 // so no request for new feeds (i.e., call to GetResourceList) should happen. | 950 // so no request for new feeds (i.e., call to GetResourceList) should happen. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 956 EXPECT_EQ(1, fake_drive_service_->resource_list_load_count()); | 987 EXPECT_EQ(1, fake_drive_service_->resource_list_load_count()); |
| 957 } | 988 } |
| 958 | 989 |
| 959 TEST_F(DriveFileSystemTest, TransferFileFromLocalToRemote_RegularFile) { | 990 TEST_F(DriveFileSystemTest, TransferFileFromLocalToRemote_RegularFile) { |
| 960 fake_free_disk_space_getter_->set_fake_free_disk_space(kLotsOfSpace); | 991 fake_free_disk_space_getter_->set_fake_free_disk_space(kLotsOfSpace); |
| 961 | 992 |
| 962 ASSERT_TRUE(LoadRootFeedDocument()); | 993 ASSERT_TRUE(LoadRootFeedDocument()); |
| 963 | 994 |
| 964 // We'll add a file to the Drive root directory. | 995 // We'll add a file to the Drive root directory. |
| 965 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( | 996 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| 966 Eq(base::FilePath(FILE_PATH_LITERAL("drive"))))).Times(1); | 997 Eq(base::FilePath(FILE_PATH_LITERAL("drive/root"))))).Times(1); |
| 967 | 998 |
| 968 // Prepare a local file. | 999 // Prepare a local file. |
| 969 base::ScopedTempDir temp_dir; | 1000 base::ScopedTempDir temp_dir; |
| 970 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 1001 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
| 971 const base::FilePath local_src_file_path = | 1002 const base::FilePath local_src_file_path = |
| 972 temp_dir.path().AppendASCII("local.txt"); | 1003 temp_dir.path().AppendASCII("local.txt"); |
| 973 const std::string kContent = "hello"; | 1004 const std::string kContent = "hello"; |
| 974 file_util::WriteFile(local_src_file_path, kContent.data(), kContent.size()); | 1005 file_util::WriteFile(local_src_file_path, kContent.data(), kContent.size()); |
| 975 | 1006 |
| 976 // Confirm that the remote file does not exist. | 1007 // Confirm that the remote file does not exist. |
| 977 const base::FilePath remote_dest_file_path( | 1008 const base::FilePath remote_dest_file_path( |
| 978 FILE_PATH_LITERAL("drive/remote.txt")); | 1009 FILE_PATH_LITERAL("drive/root/remote.txt")); |
| 979 EXPECT_FALSE(EntryExists(remote_dest_file_path)); | 1010 EXPECT_FALSE(EntryExists(remote_dest_file_path)); |
| 980 | 1011 |
| 981 // Transfer the local file to Drive. | 1012 // Transfer the local file to Drive. |
| 982 DriveFileError error = DRIVE_FILE_ERROR_FAILED; | 1013 DriveFileError error = DRIVE_FILE_ERROR_FAILED; |
| 983 file_system_->TransferFileFromLocalToRemote( | 1014 file_system_->TransferFileFromLocalToRemote( |
| 984 local_src_file_path, | 1015 local_src_file_path, |
| 985 remote_dest_file_path, | 1016 remote_dest_file_path, |
| 986 google_apis::test_util::CreateCopyResultCallback(&error)); | 1017 google_apis::test_util::CreateCopyResultCallback(&error)); |
| 987 google_apis::test_util::RunBlockingPoolTask(); | 1018 google_apis::test_util::RunBlockingPoolTask(); |
| 988 | 1019 |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 1004 const std::string kEditUrl = | 1035 const std::string kEditUrl = |
| 1005 "https://3_document_self_link/document:5_document_resource_id"; | 1036 "https://3_document_self_link/document:5_document_resource_id"; |
| 1006 const std::string kResourceId = "document:5_document_resource_id"; | 1037 const std::string kResourceId = "document:5_document_resource_id"; |
| 1007 const std::string kContent = | 1038 const std::string kContent = |
| 1008 base::StringPrintf("{\"url\": \"%s\", \"resource_id\": \"%s\"}", | 1039 base::StringPrintf("{\"url\": \"%s\", \"resource_id\": \"%s\"}", |
| 1009 kEditUrl.c_str(), kResourceId.c_str()); | 1040 kEditUrl.c_str(), kResourceId.c_str()); |
| 1010 file_util::WriteFile(local_src_file_path, kContent.data(), kContent.size()); | 1041 file_util::WriteFile(local_src_file_path, kContent.data(), kContent.size()); |
| 1011 | 1042 |
| 1012 // Confirm that the remote file does not exist. | 1043 // Confirm that the remote file does not exist. |
| 1013 const base::FilePath remote_dest_file_path( | 1044 const base::FilePath remote_dest_file_path( |
| 1014 FILE_PATH_LITERAL("drive/Directory 1/Document 1.gdoc")); | 1045 FILE_PATH_LITERAL("drive/root/Directory 1/Document 1.gdoc")); |
| 1015 EXPECT_FALSE(EntryExists(remote_dest_file_path)); | 1046 EXPECT_FALSE(EntryExists(remote_dest_file_path)); |
| 1016 | 1047 |
| 1017 // We'll add a file to the Drive root and then move to "Directory 1". | 1048 // We'll add a file to the Drive root and then move to "Directory 1". |
| 1018 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( | 1049 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| 1019 Eq(base::FilePath(FILE_PATH_LITERAL("drive"))))).Times(1); | 1050 Eq(base::FilePath(FILE_PATH_LITERAL("drive/root"))))).Times(1); |
| 1020 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( | 1051 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| 1021 Eq(base::FilePath(FILE_PATH_LITERAL("drive/Directory 1"))))).Times(1); | 1052 Eq(base::FilePath(FILE_PATH_LITERAL("drive/root/Directory 1"))))) |
| 1053 .Times(1); | |
| 1022 | 1054 |
| 1023 // We'll copy a hosted document using CopyHostedDocument. | 1055 // We'll copy a hosted document using CopyHostedDocument. |
| 1024 // ".gdoc" suffix should be stripped when copying. | 1056 // ".gdoc" suffix should be stripped when copying. |
| 1025 scoped_ptr<base::Value> value = | 1057 scoped_ptr<base::Value> value = |
| 1026 google_apis::test_util::LoadJSONFile( | 1058 google_apis::test_util::LoadJSONFile( |
| 1027 "chromeos/gdata/uploaded_document.json"); | 1059 "chromeos/gdata/uploaded_document.json"); |
| 1028 scoped_ptr<google_apis::ResourceEntry> resource_entry = | 1060 scoped_ptr<google_apis::ResourceEntry> resource_entry = |
| 1029 google_apis::ResourceEntry::ExtractAndParse(*value); | 1061 google_apis::ResourceEntry::ExtractAndParse(*value); |
| 1030 | 1062 |
| 1031 | 1063 |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 1042 // Now the remote file should exist. | 1074 // Now the remote file should exist. |
| 1043 EXPECT_TRUE(EntryExists(remote_dest_file_path)); | 1075 EXPECT_TRUE(EntryExists(remote_dest_file_path)); |
| 1044 } | 1076 } |
| 1045 | 1077 |
| 1046 TEST_F(DriveFileSystemTest, TransferFileFromRemoteToLocal_RegularFile) { | 1078 TEST_F(DriveFileSystemTest, TransferFileFromRemoteToLocal_RegularFile) { |
| 1047 ASSERT_TRUE(LoadRootFeedDocument()); | 1079 ASSERT_TRUE(LoadRootFeedDocument()); |
| 1048 | 1080 |
| 1049 // The transfered file is cached and the change of "offline available" | 1081 // The transfered file is cached and the change of "offline available" |
| 1050 // attribute is notified. | 1082 // attribute is notified. |
| 1051 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( | 1083 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| 1052 Eq(base::FilePath(FILE_PATH_LITERAL("drive"))))).Times(1); | 1084 Eq(base::FilePath(FILE_PATH_LITERAL("drive/root"))))).Times(1); |
| 1053 | 1085 |
| 1054 base::ScopedTempDir temp_dir; | 1086 base::ScopedTempDir temp_dir; |
| 1055 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 1087 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
| 1056 base::FilePath local_dest_file_path = | 1088 base::FilePath local_dest_file_path = |
| 1057 temp_dir.path().AppendASCII("local_copy.txt"); | 1089 temp_dir.path().AppendASCII("local_copy.txt"); |
| 1058 | 1090 |
| 1059 base::FilePath remote_src_file_path(FILE_PATH_LITERAL("drive/File 1.txt")); | 1091 base::FilePath remote_src_file_path( |
| 1092 FILE_PATH_LITERAL("drive/root/File 1.txt")); | |
| 1060 scoped_ptr<DriveEntryProto> file = GetEntryInfoByPathSync( | 1093 scoped_ptr<DriveEntryProto> file = GetEntryInfoByPathSync( |
| 1061 remote_src_file_path); | 1094 remote_src_file_path); |
| 1062 const int64 file_size = file->file_info().size(); | 1095 const int64 file_size = file->file_info().size(); |
| 1063 | 1096 |
| 1064 // Pretend we have enough space. | 1097 // Pretend we have enough space. |
| 1065 fake_free_disk_space_getter_->set_fake_free_disk_space( | 1098 fake_free_disk_space_getter_->set_fake_free_disk_space( |
| 1066 file_size + kMinFreeSpace); | 1099 file_size + kMinFreeSpace); |
| 1067 | 1100 |
| 1068 DriveFileError error = DRIVE_FILE_ERROR_FAILED; | 1101 DriveFileError error = DRIVE_FILE_ERROR_FAILED; |
| 1069 file_system_->TransferFileFromRemoteToLocal( | 1102 file_system_->TransferFileFromRemoteToLocal( |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 1095 } | 1128 } |
| 1096 | 1129 |
| 1097 TEST_F(DriveFileSystemTest, TransferFileFromRemoteToLocal_HostedDocument) { | 1130 TEST_F(DriveFileSystemTest, TransferFileFromRemoteToLocal_HostedDocument) { |
| 1098 ASSERT_TRUE(LoadRootFeedDocument()); | 1131 ASSERT_TRUE(LoadRootFeedDocument()); |
| 1099 | 1132 |
| 1100 base::ScopedTempDir temp_dir; | 1133 base::ScopedTempDir temp_dir; |
| 1101 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 1134 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
| 1102 base::FilePath local_dest_file_path = | 1135 base::FilePath local_dest_file_path = |
| 1103 temp_dir.path().AppendASCII("local_copy.txt"); | 1136 temp_dir.path().AppendASCII("local_copy.txt"); |
| 1104 base::FilePath remote_src_file_path( | 1137 base::FilePath remote_src_file_path( |
| 1105 FILE_PATH_LITERAL("drive/Document 1.gdoc")); | 1138 FILE_PATH_LITERAL("drive/root/Document 1.gdoc")); |
| 1106 DriveFileError error = DRIVE_FILE_ERROR_FAILED; | 1139 DriveFileError error = DRIVE_FILE_ERROR_FAILED; |
| 1107 file_system_->TransferFileFromRemoteToLocal( | 1140 file_system_->TransferFileFromRemoteToLocal( |
| 1108 remote_src_file_path, | 1141 remote_src_file_path, |
| 1109 local_dest_file_path, | 1142 local_dest_file_path, |
| 1110 google_apis::test_util::CreateCopyResultCallback(&error)); | 1143 google_apis::test_util::CreateCopyResultCallback(&error)); |
| 1111 google_apis::test_util::RunBlockingPoolTask(); | 1144 google_apis::test_util::RunBlockingPoolTask(); |
| 1112 | 1145 |
| 1113 EXPECT_EQ(DRIVE_FILE_OK, error); | 1146 EXPECT_EQ(DRIVE_FILE_OK, error); |
| 1114 | 1147 |
| 1115 scoped_ptr<DriveEntryProto> entry_proto = GetEntryInfoByPathSync( | 1148 scoped_ptr<DriveEntryProto> entry_proto = GetEntryInfoByPathSync( |
| 1116 remote_src_file_path); | 1149 remote_src_file_path); |
| 1117 ASSERT_TRUE(entry_proto.get()); | 1150 ASSERT_TRUE(entry_proto.get()); |
| 1118 VerifyHostedDocumentJSONFile(*entry_proto, local_dest_file_path); | 1151 VerifyHostedDocumentJSONFile(*entry_proto, local_dest_file_path); |
| 1119 } | 1152 } |
| 1120 | 1153 |
| 1121 TEST_F(DriveFileSystemTest, CopyNotExistingFile) { | 1154 TEST_F(DriveFileSystemTest, CopyNotExistingFile) { |
| 1122 base::FilePath src_file_path(FILE_PATH_LITERAL("drive/Dummy file.txt")); | 1155 base::FilePath src_file_path(FILE_PATH_LITERAL("drive/root/Dummy file.txt")); |
| 1123 base::FilePath dest_file_path(FILE_PATH_LITERAL("drive/Test.log")); | 1156 base::FilePath dest_file_path(FILE_PATH_LITERAL("drive/root/Test.log")); |
| 1124 | 1157 |
| 1125 ASSERT_TRUE(LoadRootFeedDocument()); | 1158 ASSERT_TRUE(LoadRootFeedDocument()); |
| 1126 | 1159 |
| 1127 EXPECT_FALSE(EntryExists(src_file_path)); | 1160 EXPECT_FALSE(EntryExists(src_file_path)); |
| 1128 | 1161 |
| 1129 DriveFileError error = DRIVE_FILE_OK; | 1162 DriveFileError error = DRIVE_FILE_OK; |
| 1130 file_system_->Copy( | 1163 file_system_->Copy( |
| 1131 src_file_path, | 1164 src_file_path, |
| 1132 dest_file_path, | 1165 dest_file_path, |
| 1133 google_apis::test_util::CreateCopyResultCallback(&error)); | 1166 google_apis::test_util::CreateCopyResultCallback(&error)); |
| 1134 google_apis::test_util::RunBlockingPoolTask(); | 1167 google_apis::test_util::RunBlockingPoolTask(); |
| 1135 EXPECT_EQ(DRIVE_FILE_ERROR_NOT_FOUND, error); | 1168 EXPECT_EQ(DRIVE_FILE_ERROR_NOT_FOUND, error); |
| 1136 | 1169 |
| 1137 EXPECT_FALSE(EntryExists(src_file_path)); | 1170 EXPECT_FALSE(EntryExists(src_file_path)); |
| 1138 EXPECT_FALSE(EntryExists(dest_file_path)); | 1171 EXPECT_FALSE(EntryExists(dest_file_path)); |
| 1139 } | 1172 } |
| 1140 | 1173 |
| 1141 TEST_F(DriveFileSystemTest, CopyFileToNonExistingDirectory) { | 1174 TEST_F(DriveFileSystemTest, CopyFileToNonExistingDirectory) { |
| 1142 base::FilePath src_file_path(FILE_PATH_LITERAL("drive/File 1.txt")); | 1175 base::FilePath src_file_path(FILE_PATH_LITERAL("drive/root/File 1.txt")); |
| 1143 base::FilePath dest_parent_path(FILE_PATH_LITERAL("drive/Dummy")); | 1176 base::FilePath dest_parent_path(FILE_PATH_LITERAL("drive/root/Dummy")); |
| 1144 base::FilePath dest_file_path(FILE_PATH_LITERAL("drive/Dummy/Test.log")); | 1177 base::FilePath dest_file_path(FILE_PATH_LITERAL("drive/root/Dummy/Test.log")); |
| 1145 | 1178 |
| 1146 ASSERT_TRUE(LoadRootFeedDocument()); | 1179 ASSERT_TRUE(LoadRootFeedDocument()); |
| 1147 | 1180 |
| 1148 ASSERT_TRUE(EntryExists(src_file_path)); | 1181 ASSERT_TRUE(EntryExists(src_file_path)); |
| 1149 scoped_ptr<DriveEntryProto> src_entry_proto = GetEntryInfoByPathSync( | 1182 scoped_ptr<DriveEntryProto> src_entry_proto = GetEntryInfoByPathSync( |
| 1150 src_file_path); | 1183 src_file_path); |
| 1151 ASSERT_TRUE(src_entry_proto.get()); | 1184 ASSERT_TRUE(src_entry_proto.get()); |
| 1152 std::string src_file_path_resource_id = | 1185 std::string src_file_path_resource_id = |
| 1153 src_entry_proto->resource_id(); | 1186 src_entry_proto->resource_id(); |
| 1154 EXPECT_FALSE(src_entry_proto->edit_url().empty()); | 1187 EXPECT_FALSE(src_entry_proto->edit_url().empty()); |
| 1155 | 1188 |
| 1156 EXPECT_FALSE(EntryExists(dest_parent_path)); | 1189 EXPECT_FALSE(EntryExists(dest_parent_path)); |
| 1157 | 1190 |
| 1158 DriveFileError error = DRIVE_FILE_OK; | 1191 DriveFileError error = DRIVE_FILE_OK; |
| 1159 file_system_->Move( | 1192 file_system_->Move( |
| 1160 src_file_path, | 1193 src_file_path, |
| 1161 dest_file_path, | 1194 dest_file_path, |
| 1162 google_apis::test_util::CreateCopyResultCallback(&error)); | 1195 google_apis::test_util::CreateCopyResultCallback(&error)); |
| 1163 google_apis::test_util::RunBlockingPoolTask(); | 1196 google_apis::test_util::RunBlockingPoolTask(); |
| 1164 EXPECT_EQ(DRIVE_FILE_ERROR_NOT_FOUND, error); | 1197 EXPECT_EQ(DRIVE_FILE_ERROR_NOT_FOUND, error); |
| 1165 | 1198 |
| 1166 EXPECT_TRUE(EntryExists(src_file_path)); | 1199 EXPECT_TRUE(EntryExists(src_file_path)); |
| 1167 EXPECT_FALSE(EntryExists(dest_parent_path)); | 1200 EXPECT_FALSE(EntryExists(dest_parent_path)); |
| 1168 EXPECT_FALSE(EntryExists(dest_file_path)); | 1201 EXPECT_FALSE(EntryExists(dest_file_path)); |
| 1169 } | 1202 } |
| 1170 | 1203 |
| 1171 // Test the case where the parent of |dest_file_path| is an existing file, | 1204 // Test the case where the parent of |dest_file_path| is an existing file, |
| 1172 // not a directory. | 1205 // not a directory. |
| 1173 TEST_F(DriveFileSystemTest, CopyFileToInvalidPath) { | 1206 TEST_F(DriveFileSystemTest, CopyFileToInvalidPath) { |
| 1174 base::FilePath src_file_path(FILE_PATH_LITERAL("drive/Document 1.gdoc")); | 1207 base::FilePath src_file_path(FILE_PATH_LITERAL("drive/root/Document 1.gdoc")); |
| 1175 base::FilePath dest_parent_path( | 1208 base::FilePath dest_parent_path( |
| 1176 FILE_PATH_LITERAL("drive/Duplicate Name.txt")); | 1209 FILE_PATH_LITERAL("drive/root/Duplicate Name.txt")); |
| 1177 base::FilePath dest_file_path(FILE_PATH_LITERAL( | 1210 base::FilePath dest_file_path(FILE_PATH_LITERAL( |
| 1178 "drive/Duplicate Name.txt/Document 1.gdoc")); | 1211 "drive/root/Duplicate Name.txt/Document 1.gdoc")); |
| 1179 | 1212 |
| 1180 ASSERT_TRUE(LoadRootFeedDocument()); | 1213 ASSERT_TRUE(LoadRootFeedDocument()); |
| 1181 | 1214 |
| 1182 ASSERT_TRUE(EntryExists(src_file_path)); | 1215 ASSERT_TRUE(EntryExists(src_file_path)); |
| 1183 scoped_ptr<DriveEntryProto> src_entry_proto = GetEntryInfoByPathSync( | 1216 scoped_ptr<DriveEntryProto> src_entry_proto = GetEntryInfoByPathSync( |
| 1184 src_file_path); | 1217 src_file_path); |
| 1185 ASSERT_TRUE(src_entry_proto.get()); | 1218 ASSERT_TRUE(src_entry_proto.get()); |
| 1186 std::string src_file_resource_id = | 1219 std::string src_file_resource_id = |
| 1187 src_entry_proto->resource_id(); | 1220 src_entry_proto->resource_id(); |
| 1188 EXPECT_FALSE(src_entry_proto->edit_url().empty()); | 1221 EXPECT_FALSE(src_entry_proto->edit_url().empty()); |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 1202 | 1235 |
| 1203 EXPECT_TRUE(EntryExists(src_file_path)); | 1236 EXPECT_TRUE(EntryExists(src_file_path)); |
| 1204 EXPECT_TRUE(EntryExists(src_file_path)); | 1237 EXPECT_TRUE(EntryExists(src_file_path)); |
| 1205 EXPECT_TRUE(EntryExists(dest_parent_path)); | 1238 EXPECT_TRUE(EntryExists(dest_parent_path)); |
| 1206 | 1239 |
| 1207 EXPECT_FALSE(EntryExists(dest_file_path)); | 1240 EXPECT_FALSE(EntryExists(dest_file_path)); |
| 1208 } | 1241 } |
| 1209 | 1242 |
| 1210 TEST_F(DriveFileSystemTest, RenameFile) { | 1243 TEST_F(DriveFileSystemTest, RenameFile) { |
| 1211 const base::FilePath src_file_path( | 1244 const base::FilePath src_file_path( |
| 1212 FILE_PATH_LITERAL("drive/Directory 1/SubDirectory File 1.txt")); | 1245 FILE_PATH_LITERAL("drive/root/Directory 1/SubDirectory File 1.txt")); |
| 1213 const base::FilePath src_parent_path(FILE_PATH_LITERAL("drive/Directory 1")); | 1246 const base::FilePath src_parent_path( |
| 1247 FILE_PATH_LITERAL("drive/root/Directory 1")); | |
| 1214 const base::FilePath dest_file_path( | 1248 const base::FilePath dest_file_path( |
| 1215 FILE_PATH_LITERAL("drive/Directory 1/Test.log")); | 1249 FILE_PATH_LITERAL("drive/root/Directory 1/Test.log")); |
| 1216 | 1250 |
| 1217 ASSERT_TRUE(LoadRootFeedDocument()); | 1251 ASSERT_TRUE(LoadRootFeedDocument()); |
| 1218 | 1252 |
| 1219 ASSERT_TRUE(EntryExists(src_file_path)); | 1253 ASSERT_TRUE(EntryExists(src_file_path)); |
| 1220 scoped_ptr<DriveEntryProto> src_entry_proto = GetEntryInfoByPathSync( | 1254 scoped_ptr<DriveEntryProto> src_entry_proto = GetEntryInfoByPathSync( |
| 1221 src_file_path); | 1255 src_file_path); |
| 1222 ASSERT_TRUE(src_entry_proto.get()); | 1256 ASSERT_TRUE(src_entry_proto.get()); |
| 1223 std::string src_file_resource_id = | 1257 std::string src_file_resource_id = |
| 1224 src_entry_proto->resource_id(); | 1258 src_entry_proto->resource_id(); |
| 1225 | 1259 |
| 1226 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( | 1260 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| 1227 Eq(base::FilePath(FILE_PATH_LITERAL("drive/Directory 1"))))).Times(1); | 1261 Eq(base::FilePath(FILE_PATH_LITERAL("drive/root/Directory 1"))))) |
| 1262 .Times(1); | |
| 1228 | 1263 |
| 1229 DriveFileError error = DRIVE_FILE_ERROR_FAILED; | 1264 DriveFileError error = DRIVE_FILE_ERROR_FAILED; |
| 1230 file_system_->Move( | 1265 file_system_->Move( |
| 1231 src_file_path, | 1266 src_file_path, |
| 1232 dest_file_path, | 1267 dest_file_path, |
| 1233 google_apis::test_util::CreateCopyResultCallback(&error)); | 1268 google_apis::test_util::CreateCopyResultCallback(&error)); |
| 1234 google_apis::test_util::RunBlockingPoolTask(); | 1269 google_apis::test_util::RunBlockingPoolTask(); |
| 1235 EXPECT_EQ(DRIVE_FILE_OK, error); | 1270 EXPECT_EQ(DRIVE_FILE_OK, error); |
| 1236 | 1271 |
| 1237 EXPECT_FALSE(EntryExists(src_file_path)); | 1272 EXPECT_FALSE(EntryExists(src_file_path)); |
| 1238 EXPECT_TRUE(EntryExists(dest_file_path)); | 1273 EXPECT_TRUE(EntryExists(dest_file_path)); |
| 1239 EXPECT_EQ(src_file_resource_id, GetResourceIdByPath(dest_file_path)); | 1274 EXPECT_EQ(src_file_resource_id, GetResourceIdByPath(dest_file_path)); |
| 1240 } | 1275 } |
| 1241 | 1276 |
| 1242 TEST_F(DriveFileSystemTest, MoveFileFromRootToSubDirectory) { | 1277 TEST_F(DriveFileSystemTest, MoveFileFromRootToSubDirectory) { |
| 1243 base::FilePath src_file_path(FILE_PATH_LITERAL("drive/File 1.txt")); | 1278 base::FilePath src_file_path(FILE_PATH_LITERAL("drive/root/File 1.txt")); |
| 1244 base::FilePath dest_parent_path(FILE_PATH_LITERAL("drive/Directory 1")); | 1279 base::FilePath dest_parent_path(FILE_PATH_LITERAL("drive/root/Directory 1")); |
| 1245 base::FilePath dest_file_path( | 1280 base::FilePath dest_file_path( |
| 1246 FILE_PATH_LITERAL("drive/Directory 1/Test.log")); | 1281 FILE_PATH_LITERAL("drive/root/Directory 1/Test.log")); |
| 1247 | 1282 |
| 1248 ASSERT_TRUE(LoadRootFeedDocument()); | 1283 ASSERT_TRUE(LoadRootFeedDocument()); |
| 1249 | 1284 |
| 1250 ASSERT_TRUE(EntryExists(src_file_path)); | 1285 ASSERT_TRUE(EntryExists(src_file_path)); |
| 1251 scoped_ptr<DriveEntryProto> src_entry_proto = GetEntryInfoByPathSync( | 1286 scoped_ptr<DriveEntryProto> src_entry_proto = GetEntryInfoByPathSync( |
| 1252 src_file_path); | 1287 src_file_path); |
| 1253 ASSERT_TRUE(src_entry_proto.get()); | 1288 ASSERT_TRUE(src_entry_proto.get()); |
| 1254 std::string src_file_resource_id = | 1289 std::string src_file_resource_id = |
| 1255 src_entry_proto->resource_id(); | 1290 src_entry_proto->resource_id(); |
| 1256 EXPECT_FALSE(src_entry_proto->edit_url().empty()); | 1291 EXPECT_FALSE(src_entry_proto->edit_url().empty()); |
| 1257 | 1292 |
| 1258 ASSERT_TRUE(EntryExists(dest_parent_path)); | 1293 ASSERT_TRUE(EntryExists(dest_parent_path)); |
| 1259 scoped_ptr<DriveEntryProto> dest_parent_proto = GetEntryInfoByPathSync( | 1294 scoped_ptr<DriveEntryProto> dest_parent_proto = GetEntryInfoByPathSync( |
| 1260 dest_parent_path); | 1295 dest_parent_path); |
| 1261 ASSERT_TRUE(dest_parent_proto.get()); | 1296 ASSERT_TRUE(dest_parent_proto.get()); |
| 1262 ASSERT_TRUE(dest_parent_proto->file_info().is_directory()); | 1297 ASSERT_TRUE(dest_parent_proto->file_info().is_directory()); |
| 1263 EXPECT_FALSE(dest_parent_proto->download_url().empty()); | 1298 EXPECT_FALSE(dest_parent_proto->download_url().empty()); |
| 1264 | 1299 |
| 1265 // Expect notification for both source and destination directories. | 1300 // Expect notification for both source and destination directories. |
| 1266 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( | 1301 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| 1267 Eq(base::FilePath(FILE_PATH_LITERAL("drive"))))).Times(1); | 1302 Eq(base::FilePath(FILE_PATH_LITERAL("drive/root"))))).Times(1); |
| 1268 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( | 1303 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| 1269 Eq(base::FilePath(FILE_PATH_LITERAL("drive/Directory 1"))))).Times(1); | 1304 Eq(base::FilePath(FILE_PATH_LITERAL("drive/root/Directory 1"))))) |
| 1305 .Times(1); | |
| 1270 | 1306 |
| 1271 DriveFileError error = DRIVE_FILE_ERROR_FAILED; | 1307 DriveFileError error = DRIVE_FILE_ERROR_FAILED; |
| 1272 file_system_->Move( | 1308 file_system_->Move( |
| 1273 src_file_path, | 1309 src_file_path, |
| 1274 dest_file_path, | 1310 dest_file_path, |
| 1275 google_apis::test_util::CreateCopyResultCallback(&error)); | 1311 google_apis::test_util::CreateCopyResultCallback(&error)); |
| 1276 google_apis::test_util::RunBlockingPoolTask(); | 1312 google_apis::test_util::RunBlockingPoolTask(); |
| 1277 EXPECT_EQ(DRIVE_FILE_OK, error); | 1313 EXPECT_EQ(DRIVE_FILE_OK, error); |
| 1278 | 1314 |
| 1279 EXPECT_FALSE(EntryExists(src_file_path)); | 1315 EXPECT_FALSE(EntryExists(src_file_path)); |
| 1280 EXPECT_TRUE(EntryExists(dest_file_path)); | 1316 EXPECT_TRUE(EntryExists(dest_file_path)); |
| 1281 EXPECT_EQ(src_file_resource_id, GetResourceIdByPath(dest_file_path)); | 1317 EXPECT_EQ(src_file_resource_id, GetResourceIdByPath(dest_file_path)); |
| 1282 } | 1318 } |
| 1283 | 1319 |
| 1284 TEST_F(DriveFileSystemTest, MoveFileFromSubDirectoryToRoot) { | 1320 TEST_F(DriveFileSystemTest, MoveFileFromSubDirectoryToRoot) { |
| 1285 base::FilePath src_parent_path(FILE_PATH_LITERAL("drive/Directory 1")); | 1321 base::FilePath src_parent_path(FILE_PATH_LITERAL("drive/root/Directory 1")); |
| 1286 base::FilePath src_file_path( | 1322 base::FilePath src_file_path( |
| 1287 FILE_PATH_LITERAL("drive/Directory 1/SubDirectory File 1.txt")); | 1323 FILE_PATH_LITERAL("drive/root/Directory 1/SubDirectory File 1.txt")); |
| 1288 base::FilePath dest_file_path(FILE_PATH_LITERAL("drive/Test.log")); | 1324 base::FilePath dest_file_path(FILE_PATH_LITERAL("drive/root/Test.log")); |
| 1289 | 1325 |
| 1290 ASSERT_TRUE(LoadRootFeedDocument()); | 1326 ASSERT_TRUE(LoadRootFeedDocument()); |
| 1291 | 1327 |
| 1292 ASSERT_TRUE(EntryExists(src_file_path)); | 1328 ASSERT_TRUE(EntryExists(src_file_path)); |
| 1293 scoped_ptr<DriveEntryProto> src_entry_proto = GetEntryInfoByPathSync( | 1329 scoped_ptr<DriveEntryProto> src_entry_proto = GetEntryInfoByPathSync( |
| 1294 src_file_path); | 1330 src_file_path); |
| 1295 ASSERT_TRUE(src_entry_proto.get()); | 1331 ASSERT_TRUE(src_entry_proto.get()); |
| 1296 std::string src_file_resource_id = | 1332 std::string src_file_resource_id = |
| 1297 src_entry_proto->resource_id(); | 1333 src_entry_proto->resource_id(); |
| 1298 EXPECT_FALSE(src_entry_proto->edit_url().empty()); | 1334 EXPECT_FALSE(src_entry_proto->edit_url().empty()); |
| 1299 | 1335 |
| 1300 ASSERT_TRUE(EntryExists(src_parent_path)); | 1336 ASSERT_TRUE(EntryExists(src_parent_path)); |
| 1301 scoped_ptr<DriveEntryProto> src_parent_proto = GetEntryInfoByPathSync( | 1337 scoped_ptr<DriveEntryProto> src_parent_proto = GetEntryInfoByPathSync( |
| 1302 src_parent_path); | 1338 src_parent_path); |
| 1303 ASSERT_TRUE(src_parent_proto.get()); | 1339 ASSERT_TRUE(src_parent_proto.get()); |
| 1304 ASSERT_TRUE(src_parent_proto->file_info().is_directory()); | 1340 ASSERT_TRUE(src_parent_proto->file_info().is_directory()); |
| 1305 EXPECT_FALSE(src_parent_proto->download_url().empty()); | 1341 EXPECT_FALSE(src_parent_proto->download_url().empty()); |
| 1306 | 1342 |
| 1307 // Expect notification for both source and destination directories. | 1343 // Expect notification for both source and destination directories. |
| 1308 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( | 1344 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| 1309 Eq(base::FilePath(FILE_PATH_LITERAL("drive"))))).Times(1); | 1345 Eq(base::FilePath(FILE_PATH_LITERAL("drive/root"))))).Times(1); |
| 1310 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( | 1346 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| 1311 Eq(base::FilePath(FILE_PATH_LITERAL("drive/Directory 1"))))).Times(1); | 1347 Eq(base::FilePath(FILE_PATH_LITERAL("drive/root/Directory 1"))))) |
| 1348 .Times(1); | |
| 1312 | 1349 |
| 1313 DriveFileError error = DRIVE_FILE_ERROR_FAILED; | 1350 DriveFileError error = DRIVE_FILE_ERROR_FAILED; |
| 1314 file_system_->Move( | 1351 file_system_->Move( |
| 1315 src_file_path, | 1352 src_file_path, |
| 1316 dest_file_path, | 1353 dest_file_path, |
| 1317 google_apis::test_util::CreateCopyResultCallback(&error)); | 1354 google_apis::test_util::CreateCopyResultCallback(&error)); |
| 1318 google_apis::test_util::RunBlockingPoolTask(); | 1355 google_apis::test_util::RunBlockingPoolTask(); |
| 1319 EXPECT_EQ(DRIVE_FILE_OK, error); | 1356 EXPECT_EQ(DRIVE_FILE_OK, error); |
| 1320 | 1357 |
| 1321 EXPECT_FALSE(EntryExists(src_file_path)); | 1358 EXPECT_FALSE(EntryExists(src_file_path)); |
| 1322 ASSERT_TRUE(EntryExists(dest_file_path)); | 1359 ASSERT_TRUE(EntryExists(dest_file_path)); |
| 1323 EXPECT_EQ(src_file_resource_id, GetResourceIdByPath(dest_file_path)); | 1360 EXPECT_EQ(src_file_resource_id, GetResourceIdByPath(dest_file_path)); |
| 1324 } | 1361 } |
| 1325 | 1362 |
| 1326 TEST_F(DriveFileSystemTest, MoveFileBetweenSubDirectories) { | 1363 TEST_F(DriveFileSystemTest, MoveFileBetweenSubDirectories) { |
| 1327 base::FilePath src_parent_path(FILE_PATH_LITERAL("drive/Directory 1")); | 1364 base::FilePath src_parent_path(FILE_PATH_LITERAL("drive/root/Directory 1")); |
| 1328 base::FilePath src_file_path( | 1365 base::FilePath src_file_path( |
| 1329 FILE_PATH_LITERAL("drive/Directory 1/SubDirectory File 1.txt")); | 1366 FILE_PATH_LITERAL("drive/root/Directory 1/SubDirectory File 1.txt")); |
| 1330 base::FilePath dest_parent_path(FILE_PATH_LITERAL("drive/New Folder 1")); | 1367 base::FilePath dest_parent_path(FILE_PATH_LITERAL("drive/root/New Folder 1")); |
| 1331 base::FilePath dest_file_path( | 1368 base::FilePath dest_file_path( |
| 1332 FILE_PATH_LITERAL("drive/New Folder 1/Test.log")); | 1369 FILE_PATH_LITERAL("drive/root/New Folder 1/Test.log")); |
| 1333 base::FilePath interim_file_path(FILE_PATH_LITERAL("drive/Test.log")); | 1370 base::FilePath interim_file_path(FILE_PATH_LITERAL("drive/root/Test.log")); |
| 1334 | 1371 |
| 1335 ASSERT_TRUE(LoadRootFeedDocument()); | 1372 ASSERT_TRUE(LoadRootFeedDocument()); |
| 1336 | 1373 |
| 1337 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( | 1374 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| 1338 Eq(base::FilePath(FILE_PATH_LITERAL("drive"))))).Times(1); | 1375 Eq(base::FilePath(FILE_PATH_LITERAL("drive/root"))))).Times(1); |
| 1339 | 1376 |
| 1340 AddDirectoryFromFile(dest_parent_path, | 1377 AddDirectoryFromFile(dest_parent_path, |
| 1341 "chromeos/gdata/directory_entry_atom.json"); | 1378 "chromeos/gdata/directory_entry_atom.json"); |
| 1342 | 1379 |
| 1343 ASSERT_TRUE(EntryExists(src_file_path)); | 1380 ASSERT_TRUE(EntryExists(src_file_path)); |
| 1344 scoped_ptr<DriveEntryProto> src_entry_proto = GetEntryInfoByPathSync( | 1381 scoped_ptr<DriveEntryProto> src_entry_proto = GetEntryInfoByPathSync( |
| 1345 src_file_path); | 1382 src_file_path); |
| 1346 ASSERT_TRUE(src_entry_proto.get()); | 1383 ASSERT_TRUE(src_entry_proto.get()); |
| 1347 std::string src_file_resource_id = | 1384 std::string src_file_resource_id = |
| 1348 src_entry_proto->resource_id(); | 1385 src_entry_proto->resource_id(); |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 1359 scoped_ptr<DriveEntryProto> dest_parent_proto = GetEntryInfoByPathSync( | 1396 scoped_ptr<DriveEntryProto> dest_parent_proto = GetEntryInfoByPathSync( |
| 1360 dest_parent_path); | 1397 dest_parent_path); |
| 1361 ASSERT_TRUE(dest_parent_proto.get()); | 1398 ASSERT_TRUE(dest_parent_proto.get()); |
| 1362 ASSERT_TRUE(dest_parent_proto->file_info().is_directory()); | 1399 ASSERT_TRUE(dest_parent_proto->file_info().is_directory()); |
| 1363 EXPECT_FALSE(dest_parent_proto->download_url().empty()); | 1400 EXPECT_FALSE(dest_parent_proto->download_url().empty()); |
| 1364 | 1401 |
| 1365 EXPECT_FALSE(EntryExists(interim_file_path)); | 1402 EXPECT_FALSE(EntryExists(interim_file_path)); |
| 1366 | 1403 |
| 1367 // Expect notification for both source and destination directories. | 1404 // Expect notification for both source and destination directories. |
| 1368 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( | 1405 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| 1369 Eq(base::FilePath(FILE_PATH_LITERAL("drive/Directory 1"))))).Times(1); | 1406 Eq(base::FilePath(FILE_PATH_LITERAL("drive/root/Directory 1"))))) |
| 1407 .Times(1); | |
| 1370 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( | 1408 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| 1371 Eq(base::FilePath(FILE_PATH_LITERAL("drive/New Folder 1"))))).Times(1); | 1409 Eq(base::FilePath(FILE_PATH_LITERAL("drive/root/New Folder 1"))))) |
| 1410 .Times(1); | |
| 1372 | 1411 |
| 1373 DriveFileError error = DRIVE_FILE_ERROR_FAILED; | 1412 DriveFileError error = DRIVE_FILE_ERROR_FAILED; |
| 1374 file_system_->Move( | 1413 file_system_->Move( |
| 1375 src_file_path, | 1414 src_file_path, |
| 1376 dest_file_path, | 1415 dest_file_path, |
| 1377 google_apis::test_util::CreateCopyResultCallback(&error)); | 1416 google_apis::test_util::CreateCopyResultCallback(&error)); |
| 1378 google_apis::test_util::RunBlockingPoolTask(); | 1417 google_apis::test_util::RunBlockingPoolTask(); |
| 1379 EXPECT_EQ(DRIVE_FILE_OK, error); | 1418 EXPECT_EQ(DRIVE_FILE_OK, error); |
| 1380 | 1419 |
| 1381 EXPECT_FALSE(EntryExists(src_file_path)); | 1420 EXPECT_FALSE(EntryExists(src_file_path)); |
| 1382 EXPECT_FALSE(EntryExists(interim_file_path)); | 1421 EXPECT_FALSE(EntryExists(interim_file_path)); |
| 1383 | 1422 |
| 1384 EXPECT_FALSE(EntryExists(src_file_path)); | 1423 EXPECT_FALSE(EntryExists(src_file_path)); |
| 1385 EXPECT_TRUE(EntryExists(dest_file_path)); | 1424 EXPECT_TRUE(EntryExists(dest_file_path)); |
| 1386 EXPECT_EQ(src_file_resource_id, GetResourceIdByPath(dest_file_path)); | 1425 EXPECT_EQ(src_file_resource_id, GetResourceIdByPath(dest_file_path)); |
| 1387 } | 1426 } |
| 1388 | 1427 |
| 1389 TEST_F(DriveFileSystemTest, MoveNotExistingFile) { | 1428 TEST_F(DriveFileSystemTest, MoveNotExistingFile) { |
| 1390 base::FilePath src_file_path(FILE_PATH_LITERAL("drive/Dummy file.txt")); | 1429 base::FilePath src_file_path(FILE_PATH_LITERAL("drive/root/Dummy file.txt")); |
| 1391 base::FilePath dest_file_path(FILE_PATH_LITERAL("drive/Test.log")); | 1430 base::FilePath dest_file_path(FILE_PATH_LITERAL("drive/root/Test.log")); |
| 1392 | 1431 |
| 1393 ASSERT_TRUE(LoadRootFeedDocument()); | 1432 ASSERT_TRUE(LoadRootFeedDocument()); |
| 1394 | 1433 |
| 1395 EXPECT_FALSE(EntryExists(src_file_path)); | 1434 EXPECT_FALSE(EntryExists(src_file_path)); |
| 1396 | 1435 |
| 1397 DriveFileError error = DRIVE_FILE_OK; | 1436 DriveFileError error = DRIVE_FILE_OK; |
| 1398 file_system_->Move( | 1437 file_system_->Move( |
| 1399 src_file_path, | 1438 src_file_path, |
| 1400 dest_file_path, | 1439 dest_file_path, |
| 1401 google_apis::test_util::CreateCopyResultCallback(&error)); | 1440 google_apis::test_util::CreateCopyResultCallback(&error)); |
| 1402 google_apis::test_util::RunBlockingPoolTask(); | 1441 google_apis::test_util::RunBlockingPoolTask(); |
| 1403 EXPECT_EQ(DRIVE_FILE_ERROR_NOT_FOUND, error); | 1442 EXPECT_EQ(DRIVE_FILE_ERROR_NOT_FOUND, error); |
| 1404 | 1443 |
| 1405 EXPECT_FALSE(EntryExists(src_file_path)); | 1444 EXPECT_FALSE(EntryExists(src_file_path)); |
| 1406 EXPECT_FALSE(EntryExists(dest_file_path)); | 1445 EXPECT_FALSE(EntryExists(dest_file_path)); |
| 1407 } | 1446 } |
| 1408 | 1447 |
| 1409 TEST_F(DriveFileSystemTest, MoveFileToNonExistingDirectory) { | 1448 TEST_F(DriveFileSystemTest, MoveFileToNonExistingDirectory) { |
| 1410 base::FilePath src_file_path(FILE_PATH_LITERAL("drive/File 1.txt")); | 1449 base::FilePath src_file_path(FILE_PATH_LITERAL("drive/root/File 1.txt")); |
| 1411 base::FilePath dest_parent_path(FILE_PATH_LITERAL("drive/Dummy")); | 1450 base::FilePath dest_parent_path(FILE_PATH_LITERAL("drive/root/Dummy")); |
| 1412 base::FilePath dest_file_path(FILE_PATH_LITERAL("drive/Dummy/Test.log")); | 1451 base::FilePath dest_file_path(FILE_PATH_LITERAL("drive/root/Dummy/Test.log")); |
| 1413 | 1452 |
| 1414 ASSERT_TRUE(LoadRootFeedDocument()); | 1453 ASSERT_TRUE(LoadRootFeedDocument()); |
| 1415 | 1454 |
| 1416 ASSERT_TRUE(EntryExists(src_file_path)); | 1455 ASSERT_TRUE(EntryExists(src_file_path)); |
| 1417 scoped_ptr<DriveEntryProto> src_entry_proto = GetEntryInfoByPathSync( | 1456 scoped_ptr<DriveEntryProto> src_entry_proto = GetEntryInfoByPathSync( |
| 1418 src_file_path); | 1457 src_file_path); |
| 1419 ASSERT_TRUE(src_entry_proto.get()); | 1458 ASSERT_TRUE(src_entry_proto.get()); |
| 1420 std::string src_file_resource_id = | 1459 std::string src_file_resource_id = |
| 1421 src_entry_proto->resource_id(); | 1460 src_entry_proto->resource_id(); |
| 1422 EXPECT_FALSE(src_entry_proto->edit_url().empty()); | 1461 EXPECT_FALSE(src_entry_proto->edit_url().empty()); |
| 1423 | 1462 |
| 1424 EXPECT_FALSE(EntryExists(dest_parent_path)); | 1463 EXPECT_FALSE(EntryExists(dest_parent_path)); |
| 1425 | 1464 |
| 1426 DriveFileError error = DRIVE_FILE_OK; | 1465 DriveFileError error = DRIVE_FILE_OK; |
| 1427 file_system_->Move( | 1466 file_system_->Move( |
| 1428 src_file_path, | 1467 src_file_path, |
| 1429 dest_file_path, | 1468 dest_file_path, |
| 1430 google_apis::test_util::CreateCopyResultCallback(&error)); | 1469 google_apis::test_util::CreateCopyResultCallback(&error)); |
| 1431 google_apis::test_util::RunBlockingPoolTask(); | 1470 google_apis::test_util::RunBlockingPoolTask(); |
| 1432 EXPECT_EQ(DRIVE_FILE_ERROR_NOT_FOUND, error); | 1471 EXPECT_EQ(DRIVE_FILE_ERROR_NOT_FOUND, error); |
| 1433 | 1472 |
| 1434 EXPECT_FALSE(EntryExists(dest_parent_path)); | 1473 EXPECT_FALSE(EntryExists(dest_parent_path)); |
| 1435 EXPECT_FALSE(EntryExists(dest_file_path)); | 1474 EXPECT_FALSE(EntryExists(dest_file_path)); |
| 1436 } | 1475 } |
| 1437 | 1476 |
| 1438 // Test the case where the parent of |dest_file_path| is a existing file, | 1477 // Test the case where the parent of |dest_file_path| is a existing file, |
| 1439 // not a directory. | 1478 // not a directory. |
| 1440 TEST_F(DriveFileSystemTest, MoveFileToInvalidPath) { | 1479 TEST_F(DriveFileSystemTest, MoveFileToInvalidPath) { |
| 1441 base::FilePath src_file_path(FILE_PATH_LITERAL("drive/File 1.txt")); | 1480 base::FilePath src_file_path(FILE_PATH_LITERAL("drive/root/File 1.txt")); |
| 1442 base::FilePath dest_parent_path( | 1481 base::FilePath dest_parent_path( |
| 1443 FILE_PATH_LITERAL("drive/Duplicate Name.txt")); | 1482 FILE_PATH_LITERAL("drive/root/Duplicate Name.txt")); |
| 1444 base::FilePath dest_file_path(FILE_PATH_LITERAL( | 1483 base::FilePath dest_file_path(FILE_PATH_LITERAL( |
| 1445 "drive/Duplicate Name.txt/Test.log")); | 1484 "drive/root/Duplicate Name.txt/Test.log")); |
| 1446 | 1485 |
| 1447 ASSERT_TRUE(LoadRootFeedDocument()); | 1486 ASSERT_TRUE(LoadRootFeedDocument()); |
| 1448 | 1487 |
| 1449 ASSERT_TRUE(EntryExists(src_file_path)); | 1488 ASSERT_TRUE(EntryExists(src_file_path)); |
| 1450 scoped_ptr<DriveEntryProto> src_entry_proto = GetEntryInfoByPathSync( | 1489 scoped_ptr<DriveEntryProto> src_entry_proto = GetEntryInfoByPathSync( |
| 1451 src_file_path); | 1490 src_file_path); |
| 1452 ASSERT_TRUE(src_entry_proto.get()); | 1491 ASSERT_TRUE(src_entry_proto.get()); |
| 1453 std::string src_file_resource_id = | 1492 std::string src_file_resource_id = |
| 1454 src_entry_proto->resource_id(); | 1493 src_entry_proto->resource_id(); |
| 1455 EXPECT_FALSE(src_entry_proto->edit_url().empty()); | 1494 EXPECT_FALSE(src_entry_proto->edit_url().empty()); |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 1468 EXPECT_EQ(DRIVE_FILE_ERROR_NOT_A_DIRECTORY, error); | 1507 EXPECT_EQ(DRIVE_FILE_ERROR_NOT_A_DIRECTORY, error); |
| 1469 | 1508 |
| 1470 EXPECT_TRUE(EntryExists(src_file_path)); | 1509 EXPECT_TRUE(EntryExists(src_file_path)); |
| 1471 EXPECT_TRUE(EntryExists(dest_parent_path)); | 1510 EXPECT_TRUE(EntryExists(dest_parent_path)); |
| 1472 EXPECT_FALSE(EntryExists(dest_file_path)); | 1511 EXPECT_FALSE(EntryExists(dest_file_path)); |
| 1473 } | 1512 } |
| 1474 | 1513 |
| 1475 TEST_F(DriveFileSystemTest, RemoveEntries) { | 1514 TEST_F(DriveFileSystemTest, RemoveEntries) { |
| 1476 ASSERT_TRUE(LoadRootFeedDocument()); | 1515 ASSERT_TRUE(LoadRootFeedDocument()); |
| 1477 | 1516 |
| 1478 base::FilePath nonexisting_file(FILE_PATH_LITERAL("drive/Dummy file.txt")); | 1517 base::FilePath nonexisting_file( |
| 1479 base::FilePath file_in_root(FILE_PATH_LITERAL("drive/File 1.txt")); | 1518 FILE_PATH_LITERAL("drive/root/Dummy file.txt")); |
| 1480 base::FilePath dir_in_root(FILE_PATH_LITERAL("drive/Directory 1")); | 1519 base::FilePath file_in_root(FILE_PATH_LITERAL("drive/root/File 1.txt")); |
| 1520 base::FilePath dir_in_root(FILE_PATH_LITERAL("drive/root/Directory 1")); | |
| 1481 base::FilePath file_in_subdir( | 1521 base::FilePath file_in_subdir( |
| 1482 FILE_PATH_LITERAL("drive/Directory 1/SubDirectory File 1.txt")); | 1522 FILE_PATH_LITERAL("drive/root/Directory 1/SubDirectory File 1.txt")); |
| 1483 | 1523 |
| 1484 ASSERT_TRUE(EntryExists(file_in_root)); | 1524 ASSERT_TRUE(EntryExists(file_in_root)); |
| 1485 scoped_ptr<DriveEntryProto> file_in_root_proto = GetEntryInfoByPathSync( | 1525 scoped_ptr<DriveEntryProto> file_in_root_proto = GetEntryInfoByPathSync( |
| 1486 file_in_root); | 1526 file_in_root); |
| 1487 ASSERT_TRUE(file_in_root_proto.get()); | 1527 ASSERT_TRUE(file_in_root_proto.get()); |
| 1488 | 1528 |
| 1489 ASSERT_TRUE(EntryExists(dir_in_root)); | 1529 ASSERT_TRUE(EntryExists(dir_in_root)); |
| 1490 scoped_ptr<DriveEntryProto> dir_in_root_proto = GetEntryInfoByPathSync( | 1530 scoped_ptr<DriveEntryProto> dir_in_root_proto = GetEntryInfoByPathSync( |
| 1491 dir_in_root); | 1531 dir_in_root); |
| 1492 ASSERT_TRUE(dir_in_root_proto.get()); | 1532 ASSERT_TRUE(dir_in_root_proto.get()); |
| 1493 ASSERT_TRUE(dir_in_root_proto->file_info().is_directory()); | 1533 ASSERT_TRUE(dir_in_root_proto->file_info().is_directory()); |
| 1494 | 1534 |
| 1495 ASSERT_TRUE(EntryExists(file_in_subdir)); | 1535 ASSERT_TRUE(EntryExists(file_in_subdir)); |
| 1496 scoped_ptr<DriveEntryProto> file_in_subdir_proto = GetEntryInfoByPathSync( | 1536 scoped_ptr<DriveEntryProto> file_in_subdir_proto = GetEntryInfoByPathSync( |
| 1497 file_in_subdir); | 1537 file_in_subdir); |
| 1498 ASSERT_TRUE(file_in_subdir_proto.get()); | 1538 ASSERT_TRUE(file_in_subdir_proto.get()); |
| 1499 | 1539 |
| 1500 // Once for file in root and once for file... | 1540 // Once for file in root and once for file... |
| 1501 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( | 1541 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| 1502 Eq(base::FilePath(FILE_PATH_LITERAL("drive"))))).Times(2); | 1542 Eq(base::FilePath(FILE_PATH_LITERAL("drive/root"))))).Times(2); |
| 1503 | 1543 |
| 1504 // Remove first file in root. | 1544 // Remove first file in root. |
| 1505 EXPECT_TRUE(RemoveEntry(file_in_root)); | 1545 EXPECT_TRUE(RemoveEntry(file_in_root)); |
| 1506 EXPECT_FALSE(EntryExists(file_in_root)); | 1546 EXPECT_FALSE(EntryExists(file_in_root)); |
| 1507 EXPECT_TRUE(EntryExists(dir_in_root)); | 1547 EXPECT_TRUE(EntryExists(dir_in_root)); |
| 1508 EXPECT_TRUE(EntryExists(file_in_subdir)); | 1548 EXPECT_TRUE(EntryExists(file_in_subdir)); |
| 1509 | 1549 |
| 1510 // Remove directory. | 1550 // Remove directory. |
| 1511 EXPECT_TRUE(RemoveEntry(dir_in_root)); | 1551 EXPECT_TRUE(RemoveEntry(dir_in_root)); |
| 1512 EXPECT_FALSE(EntryExists(file_in_root)); | 1552 EXPECT_FALSE(EntryExists(file_in_root)); |
| 1513 EXPECT_FALSE(EntryExists(dir_in_root)); | 1553 EXPECT_FALSE(EntryExists(dir_in_root)); |
| 1514 EXPECT_FALSE(EntryExists(file_in_subdir)); | 1554 EXPECT_FALSE(EntryExists(file_in_subdir)); |
| 1515 | 1555 |
| 1516 // Try removing file in already removed subdirectory. | 1556 // Try removing file in already removed subdirectory. |
| 1517 EXPECT_FALSE(RemoveEntry(file_in_subdir)); | 1557 EXPECT_FALSE(RemoveEntry(file_in_subdir)); |
| 1518 | 1558 |
| 1519 // Try removing non-existing file. | 1559 // Try removing non-existing file. |
| 1520 EXPECT_FALSE(RemoveEntry(nonexisting_file)); | 1560 EXPECT_FALSE(RemoveEntry(nonexisting_file)); |
| 1521 | 1561 |
| 1522 // Try removing root file element. | 1562 // Try removing root file element. |
| 1523 EXPECT_FALSE(RemoveEntry(base::FilePath(FILE_PATH_LITERAL("drive")))); | 1563 EXPECT_FALSE(RemoveEntry(base::FilePath(FILE_PATH_LITERAL("drive/root")))); |
| 1524 | 1564 |
| 1525 // Need this to ensure OnDirectoryChanged() is run. | 1565 // Need this to ensure OnDirectoryChanged() is run. |
| 1526 google_apis::test_util::RunBlockingPoolTask(); | 1566 google_apis::test_util::RunBlockingPoolTask(); |
| 1527 } | 1567 } |
| 1528 | 1568 |
| 1529 TEST_F(DriveFileSystemTest, CreateDirectory) { | 1569 TEST_F(DriveFileSystemTest, CreateDirectory) { |
| 1530 ASSERT_TRUE(LoadRootFeedDocument()); | 1570 ASSERT_TRUE(LoadRootFeedDocument()); |
| 1531 | 1571 |
| 1532 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( | 1572 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| 1533 Eq(base::FilePath(FILE_PATH_LITERAL("drive"))))).Times(1); | 1573 Eq(base::FilePath(FILE_PATH_LITERAL("drive/root"))))).Times(1); |
| 1534 | 1574 |
| 1535 // Create directory in root. | 1575 // Create directory in root. |
| 1536 base::FilePath dir_path(FILE_PATH_LITERAL("drive/New Folder 1")); | 1576 base::FilePath dir_path(FILE_PATH_LITERAL("drive/root/New Folder 1")); |
| 1537 EXPECT_FALSE(EntryExists(dir_path)); | 1577 EXPECT_FALSE(EntryExists(dir_path)); |
| 1538 AddDirectoryFromFile(dir_path, "chromeos/gdata/directory_entry_atom.json"); | 1578 AddDirectoryFromFile(dir_path, "chromeos/gdata/directory_entry_atom.json"); |
| 1539 EXPECT_TRUE(EntryExists(dir_path)); | 1579 EXPECT_TRUE(EntryExists(dir_path)); |
| 1540 | 1580 |
| 1541 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( | 1581 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| 1542 Eq(base::FilePath(FILE_PATH_LITERAL("drive/New Folder 1"))))).Times(1); | 1582 Eq(base::FilePath(FILE_PATH_LITERAL("drive/root/New Folder 1"))))) |
| 1583 .Times(1); | |
| 1543 | 1584 |
| 1544 // Create directory in a sub directory. | 1585 // Create directory in a sub directory. |
| 1545 base::FilePath subdir_path( | 1586 base::FilePath subdir_path( |
| 1546 FILE_PATH_LITERAL("drive/New Folder 1/New Folder 2")); | 1587 FILE_PATH_LITERAL("drive/root/New Folder 1/New Folder 2")); |
| 1547 EXPECT_FALSE(EntryExists(subdir_path)); | 1588 EXPECT_FALSE(EntryExists(subdir_path)); |
| 1548 AddDirectoryFromFile(subdir_path, | 1589 AddDirectoryFromFile(subdir_path, |
| 1549 "chromeos/gdata/directory_entry_atom2.json"); | 1590 "chromeos/gdata/directory_entry_atom2.json"); |
| 1550 EXPECT_TRUE(EntryExists(subdir_path)); | 1591 EXPECT_TRUE(EntryExists(subdir_path)); |
| 1551 } | 1592 } |
| 1552 | 1593 |
| 1553 // Create a directory through the document service | 1594 // Create a directory through the document service |
| 1554 TEST_F(DriveFileSystemTest, CreateDirectoryWithService) { | 1595 TEST_F(DriveFileSystemTest, CreateDirectoryWithService) { |
| 1555 ASSERT_TRUE(LoadRootFeedDocument()); | 1596 ASSERT_TRUE(LoadRootFeedDocument()); |
| 1556 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( | 1597 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| 1557 Eq(base::FilePath(FILE_PATH_LITERAL("drive"))))).Times(1); | 1598 Eq(base::FilePath(FILE_PATH_LITERAL("drive/root"))))).Times(1); |
| 1558 | 1599 |
| 1559 DriveFileError error = DRIVE_FILE_ERROR_FAILED; | 1600 DriveFileError error = DRIVE_FILE_ERROR_FAILED; |
| 1560 file_system_->CreateDirectory( | 1601 file_system_->CreateDirectory( |
| 1561 base::FilePath(FILE_PATH_LITERAL("drive/Sample Directory Title")), | 1602 base::FilePath(FILE_PATH_LITERAL("drive/root/Sample Directory Title")), |
| 1562 false, // is_exclusive | 1603 false, // is_exclusive |
| 1563 true, // is_recursive | 1604 true, // is_recursive |
| 1564 google_apis::test_util::CreateCopyResultCallback(&error)); | 1605 google_apis::test_util::CreateCopyResultCallback(&error)); |
| 1565 google_apis::test_util::RunBlockingPoolTask(); | 1606 google_apis::test_util::RunBlockingPoolTask(); |
| 1566 | 1607 |
| 1567 EXPECT_EQ(DRIVE_FILE_OK, error); | 1608 EXPECT_EQ(DRIVE_FILE_OK, error); |
| 1568 } | 1609 } |
| 1569 | 1610 |
| 1570 TEST_F(DriveFileSystemTest, GetFileByPath_FromGData_EnoughSpace) { | 1611 TEST_F(DriveFileSystemTest, GetFileByPath_FromGData_EnoughSpace) { |
| 1571 ASSERT_TRUE(LoadRootFeedDocument()); | 1612 ASSERT_TRUE(LoadRootFeedDocument()); |
| 1572 | 1613 |
| 1573 // The transfered file is cached and the change of "offline available" | 1614 // The transfered file is cached and the change of "offline available" |
| 1574 // attribute is notified. | 1615 // attribute is notified. |
| 1575 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( | 1616 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| 1576 Eq(base::FilePath(FILE_PATH_LITERAL("drive"))))).Times(1); | 1617 Eq(base::FilePath(FILE_PATH_LITERAL("drive/root"))))).Times(1); |
| 1577 | 1618 |
| 1578 base::FilePath file_in_root(FILE_PATH_LITERAL("drive/File 1.txt")); | 1619 base::FilePath file_in_root(FILE_PATH_LITERAL("drive/root/File 1.txt")); |
| 1579 scoped_ptr<DriveEntryProto> entry_proto(GetEntryInfoByPathSync(file_in_root)); | 1620 scoped_ptr<DriveEntryProto> entry_proto(GetEntryInfoByPathSync(file_in_root)); |
| 1580 const int64 file_size = entry_proto->file_info().size(); | 1621 const int64 file_size = entry_proto->file_info().size(); |
| 1581 | 1622 |
| 1582 // Pretend we have enough space. | 1623 // Pretend we have enough space. |
| 1583 fake_free_disk_space_getter_->set_fake_free_disk_space( | 1624 fake_free_disk_space_getter_->set_fake_free_disk_space( |
| 1584 file_size + kMinFreeSpace); | 1625 file_size + kMinFreeSpace); |
| 1585 | 1626 |
| 1586 DriveFileError error = DRIVE_FILE_ERROR_FAILED; | 1627 DriveFileError error = DRIVE_FILE_ERROR_FAILED; |
| 1587 base::FilePath file_path; | 1628 base::FilePath file_path; |
| 1588 std::string mime_type; | 1629 std::string mime_type; |
| 1589 DriveFileType file_type; | 1630 DriveFileType file_type; |
| 1590 file_system_->GetFileByPath(file_in_root, | 1631 file_system_->GetFileByPath(file_in_root, |
| 1591 google_apis::test_util::CreateCopyResultCallback( | 1632 google_apis::test_util::CreateCopyResultCallback( |
| 1592 &error, &file_path, &mime_type, &file_type)); | 1633 &error, &file_path, &mime_type, &file_type)); |
| 1593 google_apis::test_util::RunBlockingPoolTask(); | 1634 google_apis::test_util::RunBlockingPoolTask(); |
| 1594 | 1635 |
| 1595 EXPECT_EQ(DRIVE_FILE_OK, error); | 1636 EXPECT_EQ(DRIVE_FILE_OK, error); |
| 1596 EXPECT_EQ(REGULAR_FILE, file_type); | 1637 EXPECT_EQ(REGULAR_FILE, file_type); |
| 1597 } | 1638 } |
| 1598 | 1639 |
| 1599 TEST_F(DriveFileSystemTest, GetFileByPath_FromGData_NoSpaceAtAll) { | 1640 TEST_F(DriveFileSystemTest, GetFileByPath_FromGData_NoSpaceAtAll) { |
| 1600 ASSERT_TRUE(LoadRootFeedDocument()); | 1641 ASSERT_TRUE(LoadRootFeedDocument()); |
| 1601 | 1642 |
| 1602 base::FilePath file_in_root(FILE_PATH_LITERAL("drive/File 1.txt")); | 1643 base::FilePath file_in_root(FILE_PATH_LITERAL("drive/root/File 1.txt")); |
| 1603 scoped_ptr<DriveEntryProto> entry_proto(GetEntryInfoByPathSync(file_in_root)); | 1644 scoped_ptr<DriveEntryProto> entry_proto(GetEntryInfoByPathSync(file_in_root)); |
| 1604 | 1645 |
| 1605 // Pretend we have no space at all. | 1646 // Pretend we have no space at all. |
| 1606 fake_free_disk_space_getter_->set_fake_free_disk_space(0); | 1647 fake_free_disk_space_getter_->set_fake_free_disk_space(0); |
| 1607 | 1648 |
| 1608 DriveFileError error = DRIVE_FILE_OK; | 1649 DriveFileError error = DRIVE_FILE_OK; |
| 1609 base::FilePath file_path; | 1650 base::FilePath file_path; |
| 1610 std::string mime_type; | 1651 std::string mime_type; |
| 1611 DriveFileType file_type; | 1652 DriveFileType file_type; |
| 1612 file_system_->GetFileByPath(file_in_root, | 1653 file_system_->GetFileByPath(file_in_root, |
| 1613 google_apis::test_util::CreateCopyResultCallback( | 1654 google_apis::test_util::CreateCopyResultCallback( |
| 1614 &error, &file_path, &mime_type, &file_type)); | 1655 &error, &file_path, &mime_type, &file_type)); |
| 1615 google_apis::test_util::RunBlockingPoolTask(); | 1656 google_apis::test_util::RunBlockingPoolTask(); |
| 1616 | 1657 |
| 1617 EXPECT_EQ(DRIVE_FILE_ERROR_NO_SPACE, error); | 1658 EXPECT_EQ(DRIVE_FILE_ERROR_NO_SPACE, error); |
| 1618 } | 1659 } |
| 1619 | 1660 |
| 1620 TEST_F(DriveFileSystemTest, GetFileByPath_FromGData_NoEnoughSpaceButCanFreeUp) { | 1661 TEST_F(DriveFileSystemTest, GetFileByPath_FromGData_NoEnoughSpaceButCanFreeUp) { |
| 1621 ASSERT_TRUE(LoadRootFeedDocument()); | 1662 ASSERT_TRUE(LoadRootFeedDocument()); |
| 1622 | 1663 |
| 1623 // The transfered file is cached and the change of "offline available" | 1664 // The transfered file is cached and the change of "offline available" |
| 1624 // attribute is notified. | 1665 // attribute is notified. |
| 1625 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( | 1666 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| 1626 Eq(base::FilePath(FILE_PATH_LITERAL("drive"))))).Times(1); | 1667 Eq(base::FilePath(FILE_PATH_LITERAL("drive/root"))))).Times(1); |
| 1627 | 1668 |
| 1628 base::FilePath file_in_root(FILE_PATH_LITERAL("drive/File 1.txt")); | 1669 base::FilePath file_in_root(FILE_PATH_LITERAL("drive/root/File 1.txt")); |
| 1629 scoped_ptr<DriveEntryProto> entry_proto(GetEntryInfoByPathSync(file_in_root)); | 1670 scoped_ptr<DriveEntryProto> entry_proto(GetEntryInfoByPathSync(file_in_root)); |
| 1630 const int64 file_size = entry_proto->file_info().size(); | 1671 const int64 file_size = entry_proto->file_info().size(); |
| 1631 | 1672 |
| 1632 // Pretend we have no space first (checked before downloading a file), | 1673 // Pretend we have no space first (checked before downloading a file), |
| 1633 // but then start reporting we have space. This is to emulate that | 1674 // but then start reporting we have space. This is to emulate that |
| 1634 // the disk space was freed up by removing temporary files. | 1675 // the disk space was freed up by removing temporary files. |
| 1635 fake_free_disk_space_getter_->set_fake_free_disk_space( | 1676 fake_free_disk_space_getter_->set_fake_free_disk_space( |
| 1636 file_size + kMinFreeSpace); | 1677 file_size + kMinFreeSpace); |
| 1637 fake_free_disk_space_getter_->set_fake_free_disk_space(0); | 1678 fake_free_disk_space_getter_->set_fake_free_disk_space(0); |
| 1638 fake_free_disk_space_getter_->set_fake_free_disk_space( | 1679 fake_free_disk_space_getter_->set_fake_free_disk_space( |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 1668 EXPECT_EQ(DRIVE_FILE_OK, error); | 1709 EXPECT_EQ(DRIVE_FILE_OK, error); |
| 1669 EXPECT_EQ(REGULAR_FILE, file_type); | 1710 EXPECT_EQ(REGULAR_FILE, file_type); |
| 1670 | 1711 |
| 1671 // The cache entry should be removed in order to free up space. | 1712 // The cache entry should be removed in order to free up space. |
| 1672 ASSERT_FALSE(CacheEntryExists("<resource_id>", "<md5>")); | 1713 ASSERT_FALSE(CacheEntryExists("<resource_id>", "<md5>")); |
| 1673 } | 1714 } |
| 1674 | 1715 |
| 1675 TEST_F(DriveFileSystemTest, GetFileByPath_FromGData_EnoughSpaceButBecomeFull) { | 1716 TEST_F(DriveFileSystemTest, GetFileByPath_FromGData_EnoughSpaceButBecomeFull) { |
| 1676 ASSERT_TRUE(LoadRootFeedDocument()); | 1717 ASSERT_TRUE(LoadRootFeedDocument()); |
| 1677 | 1718 |
| 1678 base::FilePath file_in_root(FILE_PATH_LITERAL("drive/File 1.txt")); | 1719 base::FilePath file_in_root(FILE_PATH_LITERAL("drive/root/File 1.txt")); |
| 1679 scoped_ptr<DriveEntryProto> entry_proto(GetEntryInfoByPathSync(file_in_root)); | 1720 scoped_ptr<DriveEntryProto> entry_proto(GetEntryInfoByPathSync(file_in_root)); |
| 1680 const int64 file_size = entry_proto->file_info().size(); | 1721 const int64 file_size = entry_proto->file_info().size(); |
| 1681 | 1722 |
| 1682 // Pretend we have enough space first (checked before downloading a file), | 1723 // Pretend we have enough space first (checked before downloading a file), |
| 1683 // but then start reporting we have not enough space. This is to emulate that | 1724 // but then start reporting we have not enough space. This is to emulate that |
| 1684 // the disk space becomes full after the file is downloaded for some reason | 1725 // the disk space becomes full after the file is downloaded for some reason |
| 1685 // (ex. the actual file was larger than the expected size). | 1726 // (ex. the actual file was larger than the expected size). |
| 1686 fake_free_disk_space_getter_->set_fake_free_disk_space( | 1727 fake_free_disk_space_getter_->set_fake_free_disk_space( |
| 1687 file_size + kMinFreeSpace); | 1728 file_size + kMinFreeSpace); |
| 1688 fake_free_disk_space_getter_->set_fake_free_disk_space(kMinFreeSpace - 1); | 1729 fake_free_disk_space_getter_->set_fake_free_disk_space(kMinFreeSpace - 1); |
| 1689 fake_free_disk_space_getter_->set_fake_free_disk_space(kMinFreeSpace - 1); | 1730 fake_free_disk_space_getter_->set_fake_free_disk_space(kMinFreeSpace - 1); |
| 1690 | 1731 |
| 1691 DriveFileError error = DRIVE_FILE_OK; | 1732 DriveFileError error = DRIVE_FILE_OK; |
| 1692 base::FilePath file_path; | 1733 base::FilePath file_path; |
| 1693 std::string mime_type; | 1734 std::string mime_type; |
| 1694 DriveFileType file_type; | 1735 DriveFileType file_type; |
| 1695 file_system_->GetFileByPath(file_in_root, | 1736 file_system_->GetFileByPath(file_in_root, |
| 1696 google_apis::test_util::CreateCopyResultCallback( | 1737 google_apis::test_util::CreateCopyResultCallback( |
| 1697 &error, &file_path, &mime_type, &file_type)); | 1738 &error, &file_path, &mime_type, &file_type)); |
| 1698 google_apis::test_util::RunBlockingPoolTask(); | 1739 google_apis::test_util::RunBlockingPoolTask(); |
| 1699 | 1740 |
| 1700 EXPECT_EQ(DRIVE_FILE_ERROR_NO_SPACE, error); | 1741 EXPECT_EQ(DRIVE_FILE_ERROR_NO_SPACE, error); |
| 1701 } | 1742 } |
| 1702 | 1743 |
| 1703 TEST_F(DriveFileSystemTest, GetFileByPath_FromCache) { | 1744 TEST_F(DriveFileSystemTest, GetFileByPath_FromCache) { |
| 1704 fake_free_disk_space_getter_->set_fake_free_disk_space(kLotsOfSpace); | 1745 fake_free_disk_space_getter_->set_fake_free_disk_space(kLotsOfSpace); |
| 1705 | 1746 |
| 1706 ASSERT_TRUE(LoadRootFeedDocument()); | 1747 ASSERT_TRUE(LoadRootFeedDocument()); |
| 1707 | 1748 |
| 1708 base::FilePath file_in_root(FILE_PATH_LITERAL("drive/File 1.txt")); | 1749 base::FilePath file_in_root(FILE_PATH_LITERAL("drive/root/File 1.txt")); |
| 1709 scoped_ptr<DriveEntryProto> entry_proto(GetEntryInfoByPathSync(file_in_root)); | 1750 scoped_ptr<DriveEntryProto> entry_proto(GetEntryInfoByPathSync(file_in_root)); |
| 1710 | 1751 |
| 1711 // Store something as cached version of this file. | 1752 // Store something as cached version of this file. |
| 1712 DriveFileError error = DRIVE_FILE_OK; | 1753 DriveFileError error = DRIVE_FILE_OK; |
| 1713 cache_->Store(entry_proto->resource_id(), | 1754 cache_->Store(entry_proto->resource_id(), |
| 1714 entry_proto->file_specific_info().file_md5(), | 1755 entry_proto->file_specific_info().file_md5(), |
| 1715 google_apis::test_util::GetTestFilePath( | 1756 google_apis::test_util::GetTestFilePath( |
| 1716 "chromeos/gdata/root_feed.json"), | 1757 "chromeos/gdata/root_feed.json"), |
| 1717 DriveCache::FILE_OPERATION_COPY, | 1758 DriveCache::FILE_OPERATION_COPY, |
| 1718 google_apis::test_util::CreateCopyResultCallback(&error)); | 1759 google_apis::test_util::CreateCopyResultCallback(&error)); |
| 1719 google_apis::test_util::RunBlockingPoolTask(); | 1760 google_apis::test_util::RunBlockingPoolTask(); |
| 1720 EXPECT_EQ(DRIVE_FILE_OK, error); | 1761 EXPECT_EQ(DRIVE_FILE_OK, error); |
| 1721 | 1762 |
| 1722 base::FilePath file_path; | 1763 base::FilePath file_path; |
| 1723 std::string mime_type; | 1764 std::string mime_type; |
| 1724 DriveFileType file_type; | 1765 DriveFileType file_type; |
| 1725 file_system_->GetFileByPath(file_in_root, | 1766 file_system_->GetFileByPath(file_in_root, |
| 1726 google_apis::test_util::CreateCopyResultCallback( | 1767 google_apis::test_util::CreateCopyResultCallback( |
| 1727 &error, &file_path, &mime_type, &file_type)); | 1768 &error, &file_path, &mime_type, &file_type)); |
| 1728 google_apis::test_util::RunBlockingPoolTask(); | 1769 google_apis::test_util::RunBlockingPoolTask(); |
| 1729 | 1770 |
| 1730 EXPECT_EQ(DRIVE_FILE_OK, error); | 1771 EXPECT_EQ(DRIVE_FILE_OK, error); |
| 1731 EXPECT_EQ(REGULAR_FILE, file_type); | 1772 EXPECT_EQ(REGULAR_FILE, file_type); |
| 1732 } | 1773 } |
| 1733 | 1774 |
| 1734 TEST_F(DriveFileSystemTest, GetFileByPath_HostedDocument) { | 1775 TEST_F(DriveFileSystemTest, GetFileByPath_HostedDocument) { |
| 1735 ASSERT_TRUE(LoadRootFeedDocument()); | 1776 ASSERT_TRUE(LoadRootFeedDocument()); |
| 1736 | 1777 |
| 1737 base::FilePath file_in_root(FILE_PATH_LITERAL("drive/Document 1.gdoc")); | 1778 base::FilePath file_in_root(FILE_PATH_LITERAL("drive/root/Document 1.gdoc")); |
| 1738 scoped_ptr<DriveEntryProto> src_entry_proto = | 1779 scoped_ptr<DriveEntryProto> src_entry_proto = |
| 1739 GetEntryInfoByPathSync(file_in_root); | 1780 GetEntryInfoByPathSync(file_in_root); |
| 1740 ASSERT_TRUE(src_entry_proto.get()); | 1781 ASSERT_TRUE(src_entry_proto.get()); |
| 1741 | 1782 |
| 1742 DriveFileError error = DRIVE_FILE_ERROR_FAILED; | 1783 DriveFileError error = DRIVE_FILE_ERROR_FAILED; |
| 1743 base::FilePath file_path; | 1784 base::FilePath file_path; |
| 1744 std::string mime_type; | 1785 std::string mime_type; |
| 1745 DriveFileType file_type; | 1786 DriveFileType file_type; |
| 1746 file_system_->GetFileByPath(file_in_root, | 1787 file_system_->GetFileByPath(file_in_root, |
| 1747 google_apis::test_util::CreateCopyResultCallback( | 1788 google_apis::test_util::CreateCopyResultCallback( |
| 1748 &error, &file_path, &mime_type, &file_type)); | 1789 &error, &file_path, &mime_type, &file_type)); |
| 1749 google_apis::test_util::RunBlockingPoolTask(); | 1790 google_apis::test_util::RunBlockingPoolTask(); |
| 1750 | 1791 |
| 1751 EXPECT_EQ(HOSTED_DOCUMENT, file_type); | 1792 EXPECT_EQ(HOSTED_DOCUMENT, file_type); |
| 1752 EXPECT_FALSE(file_path.empty()); | 1793 EXPECT_FALSE(file_path.empty()); |
| 1753 | 1794 |
| 1754 ASSERT_TRUE(src_entry_proto.get()); | 1795 ASSERT_TRUE(src_entry_proto.get()); |
| 1755 VerifyHostedDocumentJSONFile(*src_entry_proto, file_path); | 1796 VerifyHostedDocumentJSONFile(*src_entry_proto, file_path); |
| 1756 } | 1797 } |
| 1757 | 1798 |
| 1758 TEST_F(DriveFileSystemTest, GetFileByResourceId) { | 1799 TEST_F(DriveFileSystemTest, GetFileByResourceId) { |
| 1759 fake_free_disk_space_getter_->set_fake_free_disk_space(kLotsOfSpace); | 1800 fake_free_disk_space_getter_->set_fake_free_disk_space(kLotsOfSpace); |
| 1760 | 1801 |
| 1761 // The transfered file is cached and the change of "offline available" | 1802 // The transfered file is cached and the change of "offline available" |
| 1762 // attribute is notified. | 1803 // attribute is notified. |
| 1763 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( | 1804 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| 1764 Eq(base::FilePath(FILE_PATH_LITERAL("drive"))))).Times(1); | 1805 Eq(base::FilePath(FILE_PATH_LITERAL("drive/root"))))).Times(1); |
| 1765 | 1806 |
| 1766 ASSERT_TRUE(LoadRootFeedDocument()); | 1807 ASSERT_TRUE(LoadRootFeedDocument()); |
| 1767 | 1808 |
| 1768 base::FilePath file_in_root(FILE_PATH_LITERAL("drive/File 1.txt")); | 1809 base::FilePath file_in_root(FILE_PATH_LITERAL("drive/root/File 1.txt")); |
| 1769 scoped_ptr<DriveEntryProto> entry_proto(GetEntryInfoByPathSync(file_in_root)); | 1810 scoped_ptr<DriveEntryProto> entry_proto(GetEntryInfoByPathSync(file_in_root)); |
| 1770 | 1811 |
| 1771 DriveFileError error = DRIVE_FILE_OK; | 1812 DriveFileError error = DRIVE_FILE_OK; |
| 1772 base::FilePath file_path; | 1813 base::FilePath file_path; |
| 1773 std::string mime_type; | 1814 std::string mime_type; |
| 1774 DriveFileType file_type; | 1815 DriveFileType file_type; |
| 1775 file_system_->GetFileByResourceId( | 1816 file_system_->GetFileByResourceId( |
| 1776 entry_proto->resource_id(), | 1817 entry_proto->resource_id(), |
| 1777 DriveClientContext(USER_INITIATED), | 1818 DriveClientContext(USER_INITIATED), |
| 1778 google_apis::test_util::CreateCopyResultCallback( | 1819 google_apis::test_util::CreateCopyResultCallback( |
| 1779 &error, &file_path, &mime_type, &file_type), | 1820 &error, &file_path, &mime_type, &file_type), |
| 1780 google_apis::GetContentCallback()); | 1821 google_apis::GetContentCallback()); |
| 1781 google_apis::test_util::RunBlockingPoolTask(); | 1822 google_apis::test_util::RunBlockingPoolTask(); |
| 1782 | 1823 |
| 1783 EXPECT_EQ(DRIVE_FILE_OK, error); | 1824 EXPECT_EQ(DRIVE_FILE_OK, error); |
| 1784 EXPECT_EQ(REGULAR_FILE, file_type); | 1825 EXPECT_EQ(REGULAR_FILE, file_type); |
| 1785 } | 1826 } |
| 1786 | 1827 |
| 1787 TEST_F(DriveFileSystemTest, CancelGetFile) { | 1828 TEST_F(DriveFileSystemTest, CancelGetFile) { |
| 1788 base::FilePath cancel_file_path(FILE_PATH_LITERAL("drive/File 1.txt")); | 1829 base::FilePath cancel_file_path(FILE_PATH_LITERAL("drive/root/File 1.txt")); |
| 1789 file_system_->CancelGetFile(cancel_file_path); | 1830 file_system_->CancelGetFile(cancel_file_path); |
| 1790 EXPECT_EQ(cancel_file_path, fake_drive_service_->last_cancelled_file()); | 1831 EXPECT_EQ(cancel_file_path, fake_drive_service_->last_cancelled_file()); |
| 1791 } | 1832 } |
| 1792 | 1833 |
| 1793 TEST_F(DriveFileSystemTest, GetFileByResourceId_FromCache) { | 1834 TEST_F(DriveFileSystemTest, GetFileByResourceId_FromCache) { |
| 1794 fake_free_disk_space_getter_->set_fake_free_disk_space(kLotsOfSpace); | 1835 fake_free_disk_space_getter_->set_fake_free_disk_space(kLotsOfSpace); |
| 1795 | 1836 |
| 1796 ASSERT_TRUE(LoadRootFeedDocument()); | 1837 ASSERT_TRUE(LoadRootFeedDocument()); |
| 1797 | 1838 |
| 1798 base::FilePath file_in_root(FILE_PATH_LITERAL("drive/File 1.txt")); | 1839 base::FilePath file_in_root(FILE_PATH_LITERAL("drive/root/File 1.txt")); |
| 1799 scoped_ptr<DriveEntryProto> entry_proto(GetEntryInfoByPathSync(file_in_root)); | 1840 scoped_ptr<DriveEntryProto> entry_proto(GetEntryInfoByPathSync(file_in_root)); |
| 1800 | 1841 |
| 1801 // Store something as cached version of this file. | 1842 // Store something as cached version of this file. |
| 1802 DriveFileError error = DRIVE_FILE_ERROR_FAILED; | 1843 DriveFileError error = DRIVE_FILE_ERROR_FAILED; |
| 1803 cache_->Store(entry_proto->resource_id(), | 1844 cache_->Store(entry_proto->resource_id(), |
| 1804 entry_proto->file_specific_info().file_md5(), | 1845 entry_proto->file_specific_info().file_md5(), |
| 1805 google_apis::test_util::GetTestFilePath( | 1846 google_apis::test_util::GetTestFilePath( |
| 1806 "chromeos/gdata/root_feed.json"), | 1847 "chromeos/gdata/root_feed.json"), |
| 1807 DriveCache::FILE_OPERATION_COPY, | 1848 DriveCache::FILE_OPERATION_COPY, |
| 1808 google_apis::test_util::CreateCopyResultCallback(&error)); | 1849 google_apis::test_util::CreateCopyResultCallback(&error)); |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 1827 EXPECT_EQ(DRIVE_FILE_OK, error); | 1868 EXPECT_EQ(DRIVE_FILE_OK, error); |
| 1828 EXPECT_EQ(REGULAR_FILE, file_type); | 1869 EXPECT_EQ(REGULAR_FILE, file_type); |
| 1829 } | 1870 } |
| 1830 | 1871 |
| 1831 TEST_F(DriveFileSystemTest, UpdateFileByResourceId_PersistentFile) { | 1872 TEST_F(DriveFileSystemTest, UpdateFileByResourceId_PersistentFile) { |
| 1832 fake_free_disk_space_getter_->set_fake_free_disk_space(kLotsOfSpace); | 1873 fake_free_disk_space_getter_->set_fake_free_disk_space(kLotsOfSpace); |
| 1833 | 1874 |
| 1834 ASSERT_TRUE(LoadRootFeedDocument()); | 1875 ASSERT_TRUE(LoadRootFeedDocument()); |
| 1835 | 1876 |
| 1836 // This is a file defined in root_feed.json. | 1877 // This is a file defined in root_feed.json. |
| 1837 const base::FilePath kFilePath(FILE_PATH_LITERAL("drive/File 1.txt")); | 1878 const base::FilePath kFilePath(FILE_PATH_LITERAL("drive/root/File 1.txt")); |
| 1838 const std::string kResourceId("file:2_file_resource_id"); | 1879 const std::string kResourceId("file:2_file_resource_id"); |
| 1839 const std::string kMd5("3b4382ebefec6e743578c76bbd0575ce"); | 1880 const std::string kMd5("3b4382ebefec6e743578c76bbd0575ce"); |
| 1840 | 1881 |
| 1841 // Pin the file so it'll be store in "persistent" directory. | 1882 // Pin the file so it'll be store in "persistent" directory. |
| 1842 EXPECT_CALL(*mock_cache_observer_, OnCachePinned(kResourceId, kMd5)).Times(1); | 1883 EXPECT_CALL(*mock_cache_observer_, OnCachePinned(kResourceId, kMd5)).Times(1); |
| 1843 DriveFileError error = DRIVE_FILE_OK; | 1884 DriveFileError error = DRIVE_FILE_OK; |
| 1844 cache_->Pin(kResourceId, kMd5, | 1885 cache_->Pin(kResourceId, kMd5, |
| 1845 google_apis::test_util::CreateCopyResultCallback(&error)); | 1886 google_apis::test_util::CreateCopyResultCallback(&error)); |
| 1846 google_apis::test_util::RunBlockingPoolTask(); | 1887 google_apis::test_util::RunBlockingPoolTask(); |
| 1847 EXPECT_EQ(DRIVE_FILE_OK, error); | 1888 EXPECT_EQ(DRIVE_FILE_OK, error); |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 1871 EXPECT_EQ(DRIVE_FILE_OK, error); | 1912 EXPECT_EQ(DRIVE_FILE_OK, error); |
| 1872 | 1913 |
| 1873 // We'll notify the directory change to the observer upon completion. | 1914 // We'll notify the directory change to the observer upon completion. |
| 1874 EXPECT_CALL(*mock_directory_observer_, | 1915 EXPECT_CALL(*mock_directory_observer_, |
| 1875 OnDirectoryChanged(Eq(util::GetDriveMyDriveRootPath()))) | 1916 OnDirectoryChanged(Eq(util::GetDriveMyDriveRootPath()))) |
| 1876 .Times(1); | 1917 .Times(1); |
| 1877 | 1918 |
| 1878 // Check the number of files in the root directory. We'll compare the | 1919 // Check the number of files in the root directory. We'll compare the |
| 1879 // number after updating a file. | 1920 // number after updating a file. |
| 1880 scoped_ptr<DriveEntryProtoVector> root_directory_entries( | 1921 scoped_ptr<DriveEntryProtoVector> root_directory_entries( |
| 1881 ReadDirectoryByPathSync(base::FilePath::FromUTF8Unsafe("drive"))); | 1922 ReadDirectoryByPathSync(base::FilePath::FromUTF8Unsafe("drive/root"))); |
| 1882 ASSERT_TRUE(root_directory_entries.get()); | 1923 ASSERT_TRUE(root_directory_entries.get()); |
| 1883 const int num_files_in_root = CountFiles(*root_directory_entries); | 1924 const int num_files_in_root = CountFiles(*root_directory_entries); |
| 1884 | 1925 |
| 1885 // The callback will be called upon completion of | 1926 // The callback will be called upon completion of |
| 1886 // UpdateFileByResourceId(). | 1927 // UpdateFileByResourceId(). |
| 1887 file_system_->UpdateFileByResourceId( | 1928 file_system_->UpdateFileByResourceId( |
| 1888 kResourceId, | 1929 kResourceId, |
| 1889 DriveClientContext(USER_INITIATED), | 1930 DriveClientContext(USER_INITIATED), |
| 1890 google_apis::test_util::CreateCopyResultCallback(&error)); | 1931 google_apis::test_util::CreateCopyResultCallback(&error)); |
| 1891 google_apis::test_util::RunBlockingPoolTask(); | 1932 google_apis::test_util::RunBlockingPoolTask(); |
| 1892 EXPECT_EQ(DRIVE_FILE_OK, error); | 1933 EXPECT_EQ(DRIVE_FILE_OK, error); |
| 1893 | 1934 |
| 1894 // Make sure that the number of files did not change (i.e. we updated an | 1935 // Make sure that the number of files did not change (i.e. we updated an |
| 1895 // existing file, rather than adding a new file. The number of files | 1936 // existing file, rather than adding a new file. The number of files |
| 1896 // increases if we don't handle the file update right). | 1937 // increases if we don't handle the file update right). |
| 1897 EXPECT_EQ(num_files_in_root, CountFiles(*root_directory_entries)); | 1938 EXPECT_EQ(num_files_in_root, CountFiles(*root_directory_entries)); |
| 1898 } | 1939 } |
| 1899 | 1940 |
| 1900 TEST_F(DriveFileSystemTest, UpdateFileByResourceId_NonexistentFile) { | 1941 TEST_F(DriveFileSystemTest, UpdateFileByResourceId_NonexistentFile) { |
| 1901 ASSERT_TRUE(LoadRootFeedDocument()); | 1942 ASSERT_TRUE(LoadRootFeedDocument()); |
| 1902 | 1943 |
| 1903 // This is nonexistent in root_feed.json. | 1944 // This is nonexistent in root_feed.json. |
| 1904 const base::FilePath kFilePath(FILE_PATH_LITERAL("drive/Nonexistent.txt")); | 1945 const base::FilePath kFilePath( |
| 1946 FILE_PATH_LITERAL("drive/root/Nonexistent.txt")); | |
| 1905 const std::string kResourceId("file:nonexistent_resource_id"); | 1947 const std::string kResourceId("file:nonexistent_resource_id"); |
| 1906 const std::string kMd5("nonexistent_md5"); | 1948 const std::string kMd5("nonexistent_md5"); |
| 1907 | 1949 |
| 1908 // The callback will be called upon completion of | 1950 // The callback will be called upon completion of |
| 1909 // UpdateFileByResourceId(). | 1951 // UpdateFileByResourceId(). |
| 1910 DriveFileError error = DRIVE_FILE_OK; | 1952 DriveFileError error = DRIVE_FILE_OK; |
| 1911 file_system_->UpdateFileByResourceId( | 1953 file_system_->UpdateFileByResourceId( |
| 1912 kResourceId, | 1954 kResourceId, |
| 1913 DriveClientContext(USER_INITIATED), | 1955 DriveClientContext(USER_INITIATED), |
| 1914 google_apis::test_util::CreateCopyResultCallback(&error)); | 1956 google_apis::test_util::CreateCopyResultCallback(&error)); |
| 1915 google_apis::test_util::RunBlockingPoolTask(); | 1957 google_apis::test_util::RunBlockingPoolTask(); |
| 1916 EXPECT_EQ(DRIVE_FILE_ERROR_NOT_FOUND, error); | 1958 EXPECT_EQ(DRIVE_FILE_ERROR_NOT_FOUND, error); |
| 1917 } | 1959 } |
| 1918 | 1960 |
| 1919 TEST_F(DriveFileSystemTest, ContentSearch) { | 1961 TEST_F(DriveFileSystemTest, ContentSearch) { |
| 1920 ASSERT_TRUE(LoadRootFeedDocument()); | 1962 ASSERT_TRUE(LoadRootFeedDocument()); |
| 1921 | 1963 |
| 1922 const SearchResultPair kExpectedResults[] = { | 1964 const SearchResultPair kExpectedResults[] = { |
| 1923 { "drive/Directory 1/Sub Directory Folder/Sub Sub Directory Folder", | 1965 { "drive/root/Directory 1/Sub Directory Folder/Sub Sub Directory Folder", |
| 1924 true }, | 1966 true }, |
| 1925 { "drive/Directory 1/Sub Directory Folder", true }, | 1967 { "drive/root/Directory 1/Sub Directory Folder", true }, |
| 1926 { "drive/Directory 1/SubDirectory File 1.txt", false }, | 1968 { "drive/root/Directory 1/SubDirectory File 1.txt", false }, |
| 1927 { "drive/Directory 1", true }, | 1969 { "drive/root/Directory 1", true }, |
| 1928 { "drive/Directory 2", true }, | 1970 { "drive/root/Directory 2", true }, |
| 1929 }; | 1971 }; |
| 1930 | 1972 |
| 1931 SearchCallback callback = base::Bind(&DriveSearchCallback, | 1973 SearchCallback callback = base::Bind(&DriveSearchCallback, |
| 1932 &message_loop_, | 1974 &message_loop_, |
| 1933 kExpectedResults, ARRAYSIZE_UNSAFE(kExpectedResults), | 1975 kExpectedResults, ARRAYSIZE_UNSAFE(kExpectedResults), |
| 1934 GURL()); | 1976 GURL()); |
| 1935 | 1977 |
| 1936 file_system_->Search("Directory", false, GURL(), callback); | 1978 file_system_->Search("Directory", false, GURL(), callback); |
| 1937 message_loop_.Run(); // Wait to get our result. | 1979 message_loop_.Run(); // Wait to get our result. |
| 1938 } | 1980 } |
| 1939 | 1981 |
| 1940 TEST_F(DriveFileSystemTest, ContentSearchWithNewEntry) { | 1982 TEST_F(DriveFileSystemTest, ContentSearchWithNewEntry) { |
| 1941 ASSERT_TRUE(LoadRootFeedDocument()); | 1983 ASSERT_TRUE(LoadRootFeedDocument()); |
| 1942 | 1984 |
| 1943 // Create a new directory in the drive service. | 1985 // Create a new directory in the drive service. |
| 1944 google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR; | 1986 google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR; |
| 1945 scoped_ptr<google_apis::ResourceEntry> resource_entry; | 1987 scoped_ptr<google_apis::ResourceEntry> resource_entry; |
| 1946 fake_drive_service_->AddNewDirectory( | 1988 fake_drive_service_->AddNewDirectory( |
| 1947 fake_drive_service_->GetRootResourceId(), // Add to the root directory. | 1989 fake_drive_service_->GetRootResourceId(), // Add to the root directory. |
| 1948 "New Directory 1!", | 1990 "New Directory 1!", |
| 1949 google_apis::test_util::CreateCopyResultCallback( | 1991 google_apis::test_util::CreateCopyResultCallback( |
| 1950 &error, &resource_entry)); | 1992 &error, &resource_entry)); |
| 1951 message_loop_.RunUntilIdle(); | 1993 message_loop_.RunUntilIdle(); |
| 1952 | 1994 |
| 1953 // As the result of the first Search(), only entries in the current file | 1995 // As the result of the first Search(), only entries in the current file |
| 1954 // system snapshot are expected to be returned (i.e. "New Directory 1!" | 1996 // system snapshot are expected to be returned (i.e. "New Directory 1!" |
| 1955 // shouldn't be included in the search result even though it matches | 1997 // shouldn't be included in the search result even though it matches |
| 1956 // "Directory 1". | 1998 // "Directory 1". |
| 1957 const SearchResultPair kExpectedResults[] = { | 1999 const SearchResultPair kExpectedResults[] = { |
| 1958 { "drive/Directory 1", true } | 2000 { "drive/root/Directory 1", true } |
| 1959 }; | 2001 }; |
| 1960 | 2002 |
| 1961 // At the same time, unknown entry should trigger delta feed request. | 2003 // At the same time, unknown entry should trigger delta feed request. |
| 1962 // This will cause notification to directory observers (e.g., File Browser) | 2004 // This will cause notification to directory observers (e.g., File Browser) |
| 1963 // so that they can request search again. | 2005 // so that they can request search again. |
| 1964 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged(_)) | 2006 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged(_)) |
| 1965 .Times(AtLeast(1)); | 2007 .Times(AtLeast(1)); |
| 1966 | 2008 |
| 1967 SearchCallback callback = base::Bind(&DriveSearchCallback, | 2009 SearchCallback callback = base::Bind(&DriveSearchCallback, |
| 1968 &message_loop_, | 2010 &message_loop_, |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2013 google_apis::test_util::RunBlockingPoolTask(); | 2055 google_apis::test_util::RunBlockingPoolTask(); |
| 2014 EXPECT_EQ(DRIVE_FILE_OK, error); | 2056 EXPECT_EQ(DRIVE_FILE_OK, error); |
| 2015 } | 2057 } |
| 2016 | 2058 |
| 2017 TEST_F(DriveFileSystemTest, OpenAndCloseFile) { | 2059 TEST_F(DriveFileSystemTest, OpenAndCloseFile) { |
| 2018 ASSERT_TRUE(LoadRootFeedDocument()); | 2060 ASSERT_TRUE(LoadRootFeedDocument()); |
| 2019 | 2061 |
| 2020 // The transfered file is cached and the change of "offline available" | 2062 // The transfered file is cached and the change of "offline available" |
| 2021 // attribute is notified. | 2063 // attribute is notified. |
| 2022 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( | 2064 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| 2023 Eq(base::FilePath(FILE_PATH_LITERAL("drive"))))).Times(1); | 2065 Eq(base::FilePath(FILE_PATH_LITERAL("drive/root"))))).Times(1); |
| 2024 | 2066 |
| 2025 const base::FilePath kFileInRoot(FILE_PATH_LITERAL("drive/File 1.txt")); | 2067 const base::FilePath kFileInRoot(FILE_PATH_LITERAL("drive/root/File 1.txt")); |
| 2026 scoped_ptr<DriveEntryProto> entry_proto(GetEntryInfoByPathSync(kFileInRoot)); | 2068 scoped_ptr<DriveEntryProto> entry_proto(GetEntryInfoByPathSync(kFileInRoot)); |
| 2027 const int64 file_size = entry_proto->file_info().size(); | 2069 const int64 file_size = entry_proto->file_info().size(); |
| 2028 const std::string& file_resource_id = | 2070 const std::string& file_resource_id = |
| 2029 entry_proto->resource_id(); | 2071 entry_proto->resource_id(); |
| 2030 const std::string& file_md5 = entry_proto->file_specific_info().file_md5(); | 2072 const std::string& file_md5 = entry_proto->file_specific_info().file_md5(); |
| 2031 | 2073 |
| 2032 // A dirty file is created on close. | 2074 // A dirty file is created on close. |
| 2033 EXPECT_CALL(*mock_cache_observer_, OnCacheCommitted(file_resource_id)) | 2075 EXPECT_CALL(*mock_cache_observer_, OnCacheCommitted(file_resource_id)) |
| 2034 .Times(1); | 2076 .Times(1); |
| 2035 | 2077 |
| 2036 // Pretend we have enough space. | 2078 // Pretend we have enough space. |
| 2037 fake_free_disk_space_getter_->set_fake_free_disk_space( | 2079 fake_free_disk_space_getter_->set_fake_free_disk_space( |
| 2038 file_size + kMinFreeSpace); | 2080 file_size + kMinFreeSpace); |
| 2039 | 2081 |
| 2040 // Open kFileInRoot ("drive/File 1.txt"). | 2082 // Open kFileInRoot ("drive/root/File 1.txt"). |
| 2041 DriveFileError error = DRIVE_FILE_ERROR_FAILED; | 2083 DriveFileError error = DRIVE_FILE_ERROR_FAILED; |
| 2042 base::FilePath file_path; | 2084 base::FilePath file_path; |
| 2043 file_system_->OpenFile( | 2085 file_system_->OpenFile( |
| 2044 kFileInRoot, | 2086 kFileInRoot, |
| 2045 google_apis::test_util::CreateCopyResultCallback(&error, &file_path)); | 2087 google_apis::test_util::CreateCopyResultCallback(&error, &file_path)); |
| 2046 google_apis::test_util::RunBlockingPoolTask(); | 2088 google_apis::test_util::RunBlockingPoolTask(); |
| 2047 const base::FilePath opened_file_path = file_path; | 2089 const base::FilePath opened_file_path = file_path; |
| 2048 | 2090 |
| 2049 // Verify that the file was properly opened. | 2091 // Verify that the file was properly opened. |
| 2050 EXPECT_EQ(DRIVE_FILE_OK, error); | 2092 EXPECT_EQ(DRIVE_FILE_OK, error); |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 2073 EXPECT_TRUE(cache_entry.is_persistent()); | 2115 EXPECT_TRUE(cache_entry.is_persistent()); |
| 2074 | 2116 |
| 2075 base::FilePath cache_file_path; | 2117 base::FilePath cache_file_path; |
| 2076 cache_->GetFile(file_resource_id, file_md5, | 2118 cache_->GetFile(file_resource_id, file_md5, |
| 2077 google_apis::test_util::CreateCopyResultCallback( | 2119 google_apis::test_util::CreateCopyResultCallback( |
| 2078 &error, &cache_file_path)); | 2120 &error, &cache_file_path)); |
| 2079 google_apis::test_util::RunBlockingPoolTask(); | 2121 google_apis::test_util::RunBlockingPoolTask(); |
| 2080 EXPECT_EQ(DRIVE_FILE_OK, error); | 2122 EXPECT_EQ(DRIVE_FILE_OK, error); |
| 2081 EXPECT_EQ(cache_file_path, opened_file_path); | 2123 EXPECT_EQ(cache_file_path, opened_file_path); |
| 2082 | 2124 |
| 2083 // Close kFileInRoot ("drive/File 1.txt"). | 2125 // Close kFileInRoot ("drive/root/File 1.txt"). |
| 2084 file_system_->CloseFile( | 2126 file_system_->CloseFile( |
| 2085 kFileInRoot, | 2127 kFileInRoot, |
| 2086 google_apis::test_util::CreateCopyResultCallback(&error)); | 2128 google_apis::test_util::CreateCopyResultCallback(&error)); |
| 2087 google_apis::test_util::RunBlockingPoolTask(); | 2129 google_apis::test_util::RunBlockingPoolTask(); |
| 2088 | 2130 |
| 2089 // Verify that the file was properly closed. | 2131 // Verify that the file was properly closed. |
| 2090 EXPECT_EQ(DRIVE_FILE_OK, error); | 2132 EXPECT_EQ(DRIVE_FILE_OK, error); |
| 2091 | 2133 |
| 2092 // Verify that the cache state was changed as expected. | 2134 // Verify that the cache state was changed as expected. |
| 2093 EXPECT_TRUE(GetCacheEntryFromOriginThread(file_resource_id, file_md5, | 2135 EXPECT_TRUE(GetCacheEntryFromOriginThread(file_resource_id, file_md5, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2126 | 2168 |
| 2127 // An app for foo.exe should now be found, as the registry was loaded. | 2169 // An app for foo.exe should now be found, as the registry was loaded. |
| 2128 drive_webapps_registry_->GetWebAppsForFile( | 2170 drive_webapps_registry_->GetWebAppsForFile( |
| 2129 base::FilePath(FILE_PATH_LITERAL("foo.exe")), | 2171 base::FilePath(FILE_PATH_LITERAL("foo.exe")), |
| 2130 "" /* mime_type */, | 2172 "" /* mime_type */, |
| 2131 &apps); | 2173 &apps); |
| 2132 EXPECT_EQ(1U, apps.size()); | 2174 EXPECT_EQ(1U, apps.size()); |
| 2133 } | 2175 } |
| 2134 | 2176 |
| 2135 } // namespace drive | 2177 } // namespace drive |
| OLD | NEW |