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

Side by Side Diff: chrome/browser/sync_file_system/drive/api_util_unittest.cc

Issue 18355004: google_apis: Move data files out of chrome/test/data/chromeos (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix extension tests Created 7 years, 5 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 #include "chrome/browser/sync_file_system/drive/api_util.h" 5 #include "chrome/browser/sync_file_system/drive/api_util.h"
6 6
7 #include "base/location.h" 7 #include "base/location.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/message_loop/message_loop_proxy.h" 9 #include "base/message_loop/message_loop_proxy.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 virtual void SetUp() OVERRIDE { 258 virtual void SetUp() OVERRIDE {
259 fake_drive_service_ = new FakeDriveServiceWrapper; 259 fake_drive_service_ = new FakeDriveServiceWrapper;
260 fake_drive_uploader_ = new FakeDriveUploader(fake_drive_service_); 260 fake_drive_uploader_ = new FakeDriveUploader(fake_drive_service_);
261 261
262 api_util_ = APIUtil::CreateForTesting( 262 api_util_ = APIUtil::CreateForTesting(
263 &profile_, 263 &profile_,
264 scoped_ptr<DriveServiceInterface>(fake_drive_service_), 264 scoped_ptr<DriveServiceInterface>(fake_drive_service_),
265 scoped_ptr<DriveUploaderInterface>(fake_drive_uploader_)); 265 scoped_ptr<DriveUploaderInterface>(fake_drive_uploader_));
266 266
267 fake_drive_service_->LoadResourceListForWapi( 267 fake_drive_service_->LoadResourceListForWapi(
268 "chromeos/sync_file_system/initialize.json"); 268 "sync_file_system/initialize.json");
269 } 269 }
270 270
271 virtual void TearDown() OVERRIDE { 271 virtual void TearDown() OVERRIDE {
272 api_util_.reset(); 272 api_util_.reset();
273 } 273 }
274 274
275 protected: 275 protected:
276 void SetUpSyncRootDirectory() { 276 void SetUpSyncRootDirectory() {
277 fake_drive_service()->AddNewDirectory( 277 fake_drive_service()->AddNewDirectory(
278 fake_drive_service_->GetRootResourceId(), 278 fake_drive_service_->GetRootResourceId(),
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 void DidDeleteFile(bool* done_out, 430 void DidDeleteFile(bool* done_out,
431 GDataErrorCode* error_out, 431 GDataErrorCode* error_out,
432 GDataErrorCode error) { 432 GDataErrorCode error) {
433 EXPECT_FALSE(*done_out); 433 EXPECT_FALSE(*done_out);
434 *done_out = true; 434 *done_out = true;
435 *error_out = error; 435 *error_out = error;
436 } 436 }
437 437
438 void APIUtilTest::TestGetSyncRoot() { 438 void APIUtilTest::TestGetSyncRoot() {
439 fake_drive_service()->LoadAccountMetadataForWapi( 439 fake_drive_service()->LoadAccountMetadataForWapi(
440 "chromeos/sync_file_system/account_metadata.json"); 440 "sync_file_system/account_metadata.json");
441 SetUpSyncRootDirectory(); 441 SetUpSyncRootDirectory();
442 442
443 bool done = false; 443 bool done = false;
444 GDataErrorCode error = google_apis::GDATA_OTHER_ERROR; 444 GDataErrorCode error = google_apis::GDATA_OTHER_ERROR;
445 std::string resource_id; 445 std::string resource_id;
446 api_util()->GetDriveDirectoryForSyncRoot( 446 api_util()->GetDriveDirectoryForSyncRoot(
447 base::Bind(&DidGetResourceID, &done, &error, &resource_id)); 447 base::Bind(&DidGetResourceID, &done, &error, &resource_id));
448 base::MessageLoop::current()->RunUntilIdle(); 448 base::MessageLoop::current()->RunUntilIdle();
449 449
450 EXPECT_TRUE(done); 450 EXPECT_TRUE(done);
451 EXPECT_EQ(google_apis::HTTP_SUCCESS, error); 451 EXPECT_EQ(google_apis::HTTP_SUCCESS, error);
452 EXPECT_EQ(GetSyncRootResourceId(), resource_id); 452 EXPECT_EQ(GetSyncRootResourceId(), resource_id);
453 } 453 }
454 454
455 void APIUtilTest::TestCreateSyncRoot() { 455 void APIUtilTest::TestCreateSyncRoot() {
456 fake_drive_service()->LoadAccountMetadataForWapi( 456 fake_drive_service()->LoadAccountMetadataForWapi(
457 "chromeos/sync_file_system/account_metadata.json"); 457 "sync_file_system/account_metadata.json");
458 bool done = false; 458 bool done = false;
459 GDataErrorCode error = google_apis::GDATA_OTHER_ERROR; 459 GDataErrorCode error = google_apis::GDATA_OTHER_ERROR;
460 std::string resource_id; 460 std::string resource_id;
461 api_util()->GetDriveDirectoryForSyncRoot( 461 api_util()->GetDriveDirectoryForSyncRoot(
462 base::Bind(&DidGetResourceID, &done, &error, &resource_id)); 462 base::Bind(&DidGetResourceID, &done, &error, &resource_id));
463 base::MessageLoop::current()->RunUntilIdle(); 463 base::MessageLoop::current()->RunUntilIdle();
464 464
465 EXPECT_TRUE(done); 465 EXPECT_TRUE(done);
466 EXPECT_EQ(google_apis::HTTP_CREATED, error); 466 EXPECT_EQ(google_apis::HTTP_CREATED, error);
467 EXPECT_FALSE(resource_id.empty()); 467 EXPECT_FALSE(resource_id.empty());
468 468
469 fake_drive_service()->SearchByTitle( 469 fake_drive_service()->SearchByTitle(
470 APIUtil::GetSyncRootDirectoryName(), 470 APIUtil::GetSyncRootDirectoryName(),
471 std::string(), // directory_resource_id 471 std::string(), // directory_resource_id
472 base::Bind(&VerifyTitleUniqueness, 472 base::Bind(&VerifyTitleUniqueness,
473 FROM_HERE, 473 FROM_HERE,
474 resource_id, 474 resource_id,
475 google_apis::ENTRY_KIND_FOLDER)); 475 google_apis::ENTRY_KIND_FOLDER));
476 base::MessageLoop::current()->RunUntilIdle(); 476 base::MessageLoop::current()->RunUntilIdle();
477 } 477 }
478 478
479 void APIUtilTest::TestCreateSyncRoot_Conflict() { 479 void APIUtilTest::TestCreateSyncRoot_Conflict() {
480 fake_drive_service()->LoadAccountMetadataForWapi( 480 fake_drive_service()->LoadAccountMetadataForWapi(
481 "chromeos/sync_file_system/account_metadata.json"); 481 "sync_file_system/account_metadata.json");
482 fake_drive_service()->set_make_directory_conflict(true); 482 fake_drive_service()->set_make_directory_conflict(true);
483 483
484 bool done = false; 484 bool done = false;
485 GDataErrorCode error = google_apis::GDATA_OTHER_ERROR; 485 GDataErrorCode error = google_apis::GDATA_OTHER_ERROR;
486 std::string resource_id; 486 std::string resource_id;
487 api_util()->GetDriveDirectoryForSyncRoot( 487 api_util()->GetDriveDirectoryForSyncRoot(
488 base::Bind(&DidGetResourceID, &done, &error, &resource_id)); 488 base::Bind(&DidGetResourceID, &done, &error, &resource_id));
489 base::MessageLoop::current()->RunUntilIdle(); 489 base::MessageLoop::current()->RunUntilIdle();
490 490
491 EXPECT_TRUE(done); 491 EXPECT_TRUE(done);
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 GetSyncRootResourceId(), 570 GetSyncRootResourceId(),
571 base::Bind(&VerifyTitleUniqueness, 571 base::Bind(&VerifyTitleUniqueness,
572 FROM_HERE, 572 FROM_HERE,
573 resource_id, 573 resource_id,
574 google_apis::ENTRY_KIND_FOLDER)); 574 google_apis::ENTRY_KIND_FOLDER));
575 base::MessageLoop::current()->RunUntilIdle(); 575 base::MessageLoop::current()->RunUntilIdle();
576 } 576 }
577 577
578 void APIUtilTest::TestGetLargestChangeStamp() { 578 void APIUtilTest::TestGetLargestChangeStamp() {
579 fake_drive_service()->LoadAccountMetadataForWapi( 579 fake_drive_service()->LoadAccountMetadataForWapi(
580 "chromeos/sync_file_system/account_metadata.json"); 580 "sync_file_system/account_metadata.json");
581 581
582 bool done = false; 582 bool done = false;
583 GDataErrorCode error = google_apis::GDATA_OTHER_ERROR; 583 GDataErrorCode error = google_apis::GDATA_OTHER_ERROR;
584 int64 largest_changestamp = -1; 584 int64 largest_changestamp = -1;
585 api_util()->GetLargestChangeStamp(base::Bind( 585 api_util()->GetLargestChangeStamp(base::Bind(
586 &DidGetLargestChangeStamp, &done, &error, &largest_changestamp)); 586 &DidGetLargestChangeStamp, &done, &error, &largest_changestamp));
587 base::MessageLoop::current()->RunUntilIdle(); 587 base::MessageLoop::current()->RunUntilIdle();
588 588
589 EXPECT_TRUE(done); 589 EXPECT_TRUE(done);
590 EXPECT_EQ(google_apis::HTTP_SUCCESS, error); 590 EXPECT_EQ(google_apis::HTTP_SUCCESS, error);
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after
1152 1152
1153 TEST_F(APIUtilTest, CreateDirectory_WAPI) { 1153 TEST_F(APIUtilTest, CreateDirectory_WAPI) {
1154 ScopedDisableDriveAPI disable_drive_api; 1154 ScopedDisableDriveAPI disable_drive_api;
1155 TestCreateDirectory(); 1155 TestCreateDirectory();
1156 } 1156 }
1157 1157
1158 #endif // !defined(OS_ANDROID) 1158 #endif // !defined(OS_ANDROID)
1159 1159
1160 } // namespace drive 1160 } // namespace drive
1161 } // namespace sync_file_system 1161 } // namespace sync_file_system
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698