Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(574)

Side by Side Diff: chrome/browser/chromeos/extensions/file_manager/file_manager_browsertest.cc

Issue 14113053: chrome: Use base::MessageLoop. (Part 3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 // Creates an empty directory with the given |name| and |modification_time|. 388 // Creates an empty directory with the given |name| and |modification_time|.
389 bool CreateDirectory(const std::string& name, 389 bool CreateDirectory(const std::string& name,
390 const std::string& modification_time) { 390 const std::string& modification_time) {
391 google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR; 391 google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR;
392 scoped_ptr<google_apis::ResourceEntry> resource_entry; 392 scoped_ptr<google_apis::ResourceEntry> resource_entry;
393 fake_drive_service_->AddNewDirectory( 393 fake_drive_service_->AddNewDirectory(
394 fake_drive_service_->GetRootResourceId(), 394 fake_drive_service_->GetRootResourceId(),
395 name, 395 name,
396 google_apis::test_util::CreateCopyResultCallback(&error, 396 google_apis::test_util::CreateCopyResultCallback(&error,
397 &resource_entry)); 397 &resource_entry));
398 MessageLoop::current()->RunUntilIdle(); 398 base::MessageLoop::current()->RunUntilIdle();
399 if (error != google_apis::HTTP_CREATED) 399 if (error != google_apis::HTTP_CREATED)
400 return false; 400 return false;
401 if (!resource_entry) 401 if (!resource_entry)
402 return false; 402 return false;
403 403
404 base::Time time; 404 base::Time time;
405 if (!base::Time::FromString(modification_time.c_str(), &time)) 405 if (!base::Time::FromString(modification_time.c_str(), &time))
406 return false; 406 return false;
407 fake_drive_service_->SetLastModifiedTime( 407 fake_drive_service_->SetLastModifiedTime(
408 resource_entry->resource_id(), 408 resource_entry->resource_id(),
409 time, 409 time,
410 google_apis::test_util::CreateCopyResultCallback(&error, 410 google_apis::test_util::CreateCopyResultCallback(&error,
411 &resource_entry)); 411 &resource_entry));
412 MessageLoop::current()->RunUntilIdle(); 412 base::MessageLoop::current()->RunUntilIdle();
413 if (error != google_apis::HTTP_SUCCESS) 413 if (error != google_apis::HTTP_SUCCESS)
414 return false; 414 return false;
415 if (!resource_entry) 415 if (!resource_entry)
416 return false; 416 return false;
417 CheckForUpdates(); 417 CheckForUpdates();
418 return true; 418 return true;
419 } 419 }
420 420
421 virtual std::string GetName() const OVERRIDE { 421 virtual std::string GetName() const OVERRIDE {
422 return "Drive"; 422 return "Drive";
423 } 423 }
424 424
425 // Creates a test file with the given spec. Returns true on success. 425 // Creates a test file with the given spec. Returns true on success.
426 bool CreateFile(const std::string& name, 426 bool CreateFile(const std::string& name,
427 const std::string& mime_type, 427 const std::string& mime_type,
428 int64 length, 428 int64 length,
429 bool shared_with_me, 429 bool shared_with_me,
430 const std::string& modification_time) { 430 const std::string& modification_time) {
431 google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR; 431 google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR;
432 scoped_ptr<google_apis::ResourceEntry> resource_entry; 432 scoped_ptr<google_apis::ResourceEntry> resource_entry;
433 fake_drive_service_->AddNewFile( 433 fake_drive_service_->AddNewFile(
434 mime_type, 434 mime_type,
435 length, 435 length,
436 fake_drive_service_->GetRootResourceId(), 436 fake_drive_service_->GetRootResourceId(),
437 name, 437 name,
438 shared_with_me, 438 shared_with_me,
439 google_apis::test_util::CreateCopyResultCallback(&error, 439 google_apis::test_util::CreateCopyResultCallback(&error,
440 &resource_entry)); 440 &resource_entry));
441 MessageLoop::current()->RunUntilIdle(); 441 base::MessageLoop::current()->RunUntilIdle();
442 if (error != google_apis::HTTP_CREATED) 442 if (error != google_apis::HTTP_CREATED)
443 return false; 443 return false;
444 if (!resource_entry) 444 if (!resource_entry)
445 return false; 445 return false;
446 446
447 base::Time time; 447 base::Time time;
448 if (!base::Time::FromString(modification_time.c_str(), &time)) 448 if (!base::Time::FromString(modification_time.c_str(), &time))
449 return false; 449 return false;
450 fake_drive_service_->SetLastModifiedTime( 450 fake_drive_service_->SetLastModifiedTime(
451 resource_entry->resource_id(), 451 resource_entry->resource_id(),
452 time, 452 time,
453 google_apis::test_util::CreateCopyResultCallback(&error, 453 google_apis::test_util::CreateCopyResultCallback(&error,
454 &resource_entry)); 454 &resource_entry));
455 MessageLoop::current()->RunUntilIdle(); 455 base::MessageLoop::current()->RunUntilIdle();
456 if (error != google_apis::HTTP_SUCCESS) 456 if (error != google_apis::HTTP_SUCCESS)
457 return false; 457 return false;
458 if (!resource_entry) 458 if (!resource_entry)
459 return false; 459 return false;
460 460
461 CheckForUpdates(); 461 CheckForUpdates();
462 return true; 462 return true;
463 } 463 }
464 464
465 virtual base::FilePath GetRootPath() const OVERRIDE { 465 virtual base::FilePath GetRootPath() const OVERRIDE {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 return true; 499 return true;
500 WaitUntilDirectoryChanged(); 500 WaitUntilDirectoryChanged();
501 } 501 }
502 NOTREACHED(); 502 NOTREACHED();
503 return false; 503 return false;
504 } 504 }
505 505
506 virtual void OnDirectoryChanged( 506 virtual void OnDirectoryChanged(
507 const base::FilePath& directory_path) OVERRIDE { 507 const base::FilePath& directory_path) OVERRIDE {
508 if (waiting_for_directory_change_) 508 if (waiting_for_directory_change_)
509 MessageLoop::current()->Quit(); 509 base::MessageLoop::current()->Quit();
510 } 510 }
511 511
512 // Notifies DriveFileSystem that the contents in FakeDriveService are 512 // Notifies DriveFileSystem that the contents in FakeDriveService are
513 // changed, hence the new contents should be fetched. 513 // changed, hence the new contents should be fetched.
514 void CheckForUpdates() { 514 void CheckForUpdates() {
515 if (system_service_ && system_service_->file_system()) { 515 if (system_service_ && system_service_->file_system()) {
516 system_service_->file_system()->CheckForUpdates(); 516 system_service_->file_system()->CheckForUpdates();
517 } 517 }
518 } 518 }
519 519
520 // Waits until a notification for a directory change is received. 520 // Waits until a notification for a directory change is received.
521 void WaitUntilDirectoryChanged() { 521 void WaitUntilDirectoryChanged() {
522 waiting_for_directory_change_ = true; 522 waiting_for_directory_change_ = true;
523 MessageLoop::current()->Run(); 523 base::MessageLoop::current()->Run();
524 waiting_for_directory_change_ = false; 524 waiting_for_directory_change_ = false;
525 } 525 }
526 526
527 // Returns true if a file of the size |file_size| is present at |file_path|. 527 // Returns true if a file of the size |file_size| is present at |file_path|.
528 bool FileIsPresentWithSize( 528 bool FileIsPresentWithSize(
529 const base::FilePath& file_path, 529 const base::FilePath& file_path,
530 int64 file_size) { 530 int64 file_size) {
531 DCHECK(system_service_); 531 DCHECK(system_service_);
532 DCHECK(system_service_->file_system()); 532 DCHECK(system_service_->file_system());
533 533
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
847 } 847 }
848 848
849 IN_PROC_BROWSER_TEST_P(FileManagerBrowserTransferTest, 849 IN_PROC_BROWSER_TEST_P(FileManagerBrowserTransferTest,
850 TransferFromDriveToDownloads) { 850 TransferFromDriveToDownloads) {
851 ASSERT_TRUE(PrepareVolume()); 851 ASSERT_TRUE(PrepareVolume());
852 ResultCatcher catcher; 852 ResultCatcher catcher;
853 StartTest("transferFromDriveToDownloads"); 853 StartTest("transferFromDriveToDownloads");
854 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); 854 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
855 } 855 }
856 } // namespace 856 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698