| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 // Browser test for basic Chrome OS file manager functionality: | 5 // Browser test for basic Chrome OS file manager functionality: |
| 6 // - The file list is updated when a file is added externally to the Downloads | 6 // - The file list is updated when a file is added externally to the Downloads |
| 7 // folder. | 7 // folder. |
| 8 // - Selecting a file and copy-pasting it with the keyboard copies the file. | 8 // - Selecting a file and copy-pasting it with the keyboard copies the file. |
| 9 // - Selecting a file and pressing delete deletes it. | 9 // - Selecting a file and pressing delete deletes it. |
| 10 | 10 |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 // Creates an empty directory with the given |name| and |modification_time|. | 367 // Creates an empty directory with the given |name| and |modification_time|. |
| 368 void CreateDirectory(const std::string& name, | 368 void CreateDirectory(const std::string& name, |
| 369 const std::string& modification_time) { | 369 const std::string& modification_time) { |
| 370 google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR; | 370 google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR; |
| 371 scoped_ptr<google_apis::ResourceEntry> resource_entry; | 371 scoped_ptr<google_apis::ResourceEntry> resource_entry; |
| 372 fake_drive_service_->AddNewDirectory( | 372 fake_drive_service_->AddNewDirectory( |
| 373 fake_drive_service_->GetRootResourceId(), | 373 fake_drive_service_->GetRootResourceId(), |
| 374 name, | 374 name, |
| 375 google_apis::test_util::CreateCopyResultCallback(&error, | 375 google_apis::test_util::CreateCopyResultCallback(&error, |
| 376 &resource_entry)); | 376 &resource_entry)); |
| 377 MessageLoop::current()->RunUntilIdle(); | 377 base::MessageLoop::current()->RunUntilIdle(); |
| 378 ASSERT_TRUE(error == google_apis::HTTP_CREATED); | 378 ASSERT_TRUE(error == google_apis::HTTP_CREATED); |
| 379 ASSERT_TRUE(resource_entry); | 379 ASSERT_TRUE(resource_entry); |
| 380 | 380 |
| 381 base::Time time; | 381 base::Time time; |
| 382 ASSERT_TRUE(base::Time::FromString(modification_time.c_str(), &time)); | 382 ASSERT_TRUE(base::Time::FromString(modification_time.c_str(), &time)); |
| 383 fake_drive_service_->SetLastModifiedTime( | 383 fake_drive_service_->SetLastModifiedTime( |
| 384 resource_entry->resource_id(), | 384 resource_entry->resource_id(), |
| 385 time, | 385 time, |
| 386 google_apis::test_util::CreateCopyResultCallback(&error, | 386 google_apis::test_util::CreateCopyResultCallback(&error, |
| 387 &resource_entry)); | 387 &resource_entry)); |
| 388 MessageLoop::current()->RunUntilIdle(); | 388 base::MessageLoop::current()->RunUntilIdle(); |
| 389 ASSERT_TRUE(error == google_apis::HTTP_SUCCESS); | 389 ASSERT_TRUE(error == google_apis::HTTP_SUCCESS); |
| 390 ASSERT_TRUE(resource_entry); | 390 ASSERT_TRUE(resource_entry); |
| 391 CheckForUpdates(); | 391 CheckForUpdates(); |
| 392 } | 392 } |
| 393 | 393 |
| 394 virtual std::string GetName() const OVERRIDE { | 394 virtual std::string GetName() const OVERRIDE { |
| 395 return "Drive"; | 395 return "Drive"; |
| 396 } | 396 } |
| 397 | 397 |
| 398 // Creates a test file with the given spec. | 398 // Creates a test file with the given spec. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 414 | 414 |
| 415 scoped_ptr<google_apis::ResourceEntry> resource_entry; | 415 scoped_ptr<google_apis::ResourceEntry> resource_entry; |
| 416 fake_drive_service_->AddNewFile( | 416 fake_drive_service_->AddNewFile( |
| 417 mime_type, | 417 mime_type, |
| 418 content_data, | 418 content_data, |
| 419 fake_drive_service_->GetRootResourceId(), | 419 fake_drive_service_->GetRootResourceId(), |
| 420 target_file_name, | 420 target_file_name, |
| 421 shared_with_me, | 421 shared_with_me, |
| 422 google_apis::test_util::CreateCopyResultCallback(&error, | 422 google_apis::test_util::CreateCopyResultCallback(&error, |
| 423 &resource_entry)); | 423 &resource_entry)); |
| 424 MessageLoop::current()->RunUntilIdle(); | 424 base::MessageLoop::current()->RunUntilIdle(); |
| 425 ASSERT_EQ(google_apis::HTTP_CREATED, error); | 425 ASSERT_EQ(google_apis::HTTP_CREATED, error); |
| 426 ASSERT_TRUE(resource_entry); | 426 ASSERT_TRUE(resource_entry); |
| 427 | 427 |
| 428 base::Time time; | 428 base::Time time; |
| 429 ASSERT_TRUE(base::Time::FromString(modification_time.c_str(), &time)); | 429 ASSERT_TRUE(base::Time::FromString(modification_time.c_str(), &time)); |
| 430 fake_drive_service_->SetLastModifiedTime( | 430 fake_drive_service_->SetLastModifiedTime( |
| 431 resource_entry->resource_id(), | 431 resource_entry->resource_id(), |
| 432 time, | 432 time, |
| 433 google_apis::test_util::CreateCopyResultCallback(&error, | 433 google_apis::test_util::CreateCopyResultCallback(&error, |
| 434 &resource_entry)); | 434 &resource_entry)); |
| 435 MessageLoop::current()->RunUntilIdle(); | 435 base::MessageLoop::current()->RunUntilIdle(); |
| 436 ASSERT_EQ(google_apis::HTTP_SUCCESS, error); | 436 ASSERT_EQ(google_apis::HTTP_SUCCESS, error); |
| 437 ASSERT_TRUE(resource_entry); | 437 ASSERT_TRUE(resource_entry); |
| 438 | 438 |
| 439 CheckForUpdates(); | 439 CheckForUpdates(); |
| 440 } | 440 } |
| 441 | 441 |
| 442 virtual base::FilePath GetRootPath() const OVERRIDE { | 442 virtual base::FilePath GetRootPath() const OVERRIDE { |
| 443 return base::FilePath(drive::util::kDriveMyDriveRootPath); | 443 return base::FilePath(drive::util::kDriveMyDriveRootPath); |
| 444 } | 444 } |
| 445 | 445 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 476 return true; | 476 return true; |
| 477 WaitUntilDirectoryChanged(); | 477 WaitUntilDirectoryChanged(); |
| 478 } | 478 } |
| 479 NOTREACHED(); | 479 NOTREACHED(); |
| 480 return false; | 480 return false; |
| 481 } | 481 } |
| 482 | 482 |
| 483 virtual void OnDirectoryChanged( | 483 virtual void OnDirectoryChanged( |
| 484 const base::FilePath& directory_path) OVERRIDE { | 484 const base::FilePath& directory_path) OVERRIDE { |
| 485 if (waiting_for_directory_change_) | 485 if (waiting_for_directory_change_) |
| 486 MessageLoop::current()->Quit(); | 486 base::MessageLoop::current()->Quit(); |
| 487 } | 487 } |
| 488 | 488 |
| 489 // Notifies FileSystem that the contents in FakeDriveService are | 489 // Notifies FileSystem that the contents in FakeDriveService are |
| 490 // changed, hence the new contents should be fetched. | 490 // changed, hence the new contents should be fetched. |
| 491 void CheckForUpdates() { | 491 void CheckForUpdates() { |
| 492 if (integration_service_ && integration_service_->file_system()) { | 492 if (integration_service_ && integration_service_->file_system()) { |
| 493 integration_service_->file_system()->CheckForUpdates(); | 493 integration_service_->file_system()->CheckForUpdates(); |
| 494 } | 494 } |
| 495 } | 495 } |
| 496 | 496 |
| 497 // Waits until a notification for a directory change is received. | 497 // Waits until a notification for a directory change is received. |
| 498 void WaitUntilDirectoryChanged() { | 498 void WaitUntilDirectoryChanged() { |
| 499 waiting_for_directory_change_ = true; | 499 waiting_for_directory_change_ = true; |
| 500 MessageLoop::current()->Run(); | 500 base::MessageLoop::current()->Run(); |
| 501 waiting_for_directory_change_ = false; | 501 waiting_for_directory_change_ = false; |
| 502 } | 502 } |
| 503 | 503 |
| 504 // Returns true if a file of the size |file_size| is present at |file_path|. | 504 // Returns true if a file of the size |file_size| is present at |file_path|. |
| 505 bool FileIsPresentWithSize( | 505 bool FileIsPresentWithSize( |
| 506 const base::FilePath& file_path, | 506 const base::FilePath& file_path, |
| 507 int64 file_size) { | 507 int64 file_size) { |
| 508 DCHECK(integration_service_); | 508 DCHECK(integration_service_); |
| 509 DCHECK(integration_service_->file_system()); | 509 DCHECK(integration_service_->file_system()); |
| 510 | 510 |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 867 | 867 |
| 868 // TODO(hirono): Bring back the offline feature. http://crbug.com/238545 | 868 // TODO(hirono): Bring back the offline feature. http://crbug.com/238545 |
| 869 IN_PROC_BROWSER_TEST_P(FileManagerBrowserTransferTest, | 869 IN_PROC_BROWSER_TEST_P(FileManagerBrowserTransferTest, |
| 870 DISABLED_TransferFromOfflineToDrive) { | 870 DISABLED_TransferFromOfflineToDrive) { |
| 871 ResultCatcher catcher; | 871 ResultCatcher catcher; |
| 872 ASSERT_NO_FATAL_FAILURE(StartTest("transferFromOfflineToDrive")); | 872 ASSERT_NO_FATAL_FAILURE(StartTest("transferFromOfflineToDrive")); |
| 873 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); | 873 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); |
| 874 } | 874 } |
| 875 | 875 |
| 876 } // namespace | 876 } // namespace |
| OLD | NEW |