Cast: Stop logging kVideoFrameSentToEncoder and rename a couple events.
[chromium-blink-merge.git] / chrome / browser / sync_file_system / drive_backend_v1 / api_util_unittest.cc
blob8a7e3adf1f7c5409e2420b648df797847070d037
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
3 // found in the LICENSE file.
5 #include "chrome/browser/sync_file_system/drive_backend_v1/api_util.h"
7 #include "base/file_util.h"
8 #include "base/location.h"
9 #include "base/message_loop/message_loop.h"
10 #include "base/message_loop/message_loop_proxy.h"
11 #include "base/strings/stringprintf.h"
12 #include "base/values.h"
13 #include "chrome/browser/drive/drive_uploader.h"
14 #include "chrome/browser/drive/fake_drive_service.h"
15 #include "chrome/browser/sync_file_system/drive_backend/fake_drive_service_helper.h"
16 #include "chrome/browser/sync_file_system/drive_backend/fake_drive_uploader.h"
17 #include "chrome/browser/sync_file_system/drive_backend_v1/drive_file_sync_util.h"
18 #include "content/public/test/test_browser_thread.h"
19 #include "content/public/test/test_browser_thread_bundle.h"
20 #include "google_apis/drive/drive_api_parser.h"
21 #include "google_apis/drive/gdata_errorcode.h"
22 #include "google_apis/drive/test_util.h"
23 #include "net/base/escape.h"
24 #include "testing/gtest/include/gtest/gtest.h"
26 #define FPL(x) FILE_PATH_LITERAL(x)
28 using drive::DriveServiceInterface;
29 using drive::DriveUploaderInterface;
30 using google_apis::GDataErrorCode;
31 using google_apis::ResourceEntry;
32 using google_apis::ResourceList;
34 namespace sync_file_system {
35 namespace drive_backend {
37 namespace {
39 const char kOrigin[] = "chrome-extension://example";
40 const char kOriginDirectoryName[] = "example";
42 struct Output {
43 GDataErrorCode error;
44 std::string resource_id;
45 std::string file_md5;
46 int64 largest_changestamp;
48 Output() : error(google_apis::GDATA_OTHER_ERROR),
49 largest_changestamp(-1) {
53 } // namespace
55 class APIUtilTest : public testing::Test {
56 public:
57 APIUtilTest() : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP),
58 fake_drive_service_(NULL),
59 fake_drive_uploader_(NULL) {}
61 virtual void SetUp() OVERRIDE {
62 fake_drive_service_ = new FakeDriveServiceWrapper;
63 fake_drive_uploader_ = new FakeDriveUploader(fake_drive_service_);
65 fake_drive_helper_.reset(new FakeDriveServiceHelper(
66 fake_drive_service_, fake_drive_uploader_,
67 APIUtil::GetSyncRootDirectoryName()));
69 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
70 api_util_ = APIUtil::CreateForTesting(
71 temp_dir_.path(),
72 scoped_ptr<DriveServiceInterface>(fake_drive_service_),
73 scoped_ptr<DriveUploaderInterface>(fake_drive_uploader_));
76 virtual void TearDown() OVERRIDE {
77 api_util_.reset();
80 protected:
81 std::string SetUpSyncRootDirectory() {
82 std::string sync_root_id;
83 EXPECT_EQ(google_apis::HTTP_CREATED,
84 fake_drive_helper_->AddOrphanedFolder(
85 APIUtil::GetSyncRootDirectoryName(),
86 &sync_root_id));
87 return sync_root_id;
90 std::string SetUpOriginRootDirectory(const std::string& sync_root_id) {
91 std::string origin_root_id;
92 EXPECT_EQ(google_apis::HTTP_CREATED,
93 fake_drive_helper_->AddFolder(
94 sync_root_id,
95 kOriginDirectoryName,
96 &origin_root_id));
97 return origin_root_id;
100 void SetUpFile(const std::string& origin_root_id,
101 const std::string& content_data,
102 const std::string& title,
103 scoped_ptr<ResourceEntry>* entry) {
104 ASSERT_TRUE(entry);
105 std::string file_resource_id;
106 EXPECT_EQ(google_apis::HTTP_SUCCESS,
107 fake_drive_helper_->AddFile(
108 origin_root_id,
109 title,
110 content_data,
111 &file_resource_id));
112 EXPECT_EQ(google_apis::HTTP_SUCCESS,
113 fake_drive_helper_->GetResourceEntry(
114 file_resource_id,
115 entry));
118 void VerifyTitleUniqueness(const std::string& parent_resource_id,
119 const std::string& title,
120 const std::string& resource_id,
121 google_apis::DriveEntryKind kind) {
122 ScopedVector<ResourceEntry> entries;
123 EXPECT_EQ(google_apis::HTTP_SUCCESS,
124 fake_drive_helper_->SearchByTitle(
125 parent_resource_id, title, &entries));
126 ASSERT_EQ(1u, entries.size());
127 EXPECT_EQ(resource_id, entries[0]->resource_id());
128 EXPECT_EQ(kind, entries[0]->kind());
131 void VerifyFileDeletion(const std::string& parent_resource_id,
132 const std::string& title) {
133 ScopedVector<ResourceEntry> entries;
134 EXPECT_EQ(google_apis::HTTP_SUCCESS,
135 fake_drive_helper_->SearchByTitle(
136 parent_resource_id, title, &entries));
137 EXPECT_TRUE(entries.empty());
140 APIUtil* api_util() { return api_util_.get(); }
142 FakeDriveServiceWrapper* fake_drive_service() {
143 return fake_drive_service_;
146 FakeDriveUploader* fake_drive_uploader() {
147 return fake_drive_uploader_;
150 void TestGetSyncRoot();
151 void TestCreateSyncRoot();
152 void TestCreateSyncRoot_Conflict();
153 void TestGetOriginDirectory();
154 void TestCreateOriginDirectory();
155 void TestCreateOriginDirectory_Conflict();
156 void TestGetLargestChangeStamp();
157 void TestListFiles();
158 void TestListChanges();
159 void TestDownloadFile();
160 void TestDownloadFileInNotModified();
161 void TestUploadNewFile();
162 void TestUploadNewFile_ConflictWithFile();
163 void TestUploadExistingFile();
164 void TestUploadExistingFileInConflict();
165 void TestDeleteFile();
166 void TestDeleteFileInConflict();
167 void TestCreateDirectory();
169 private:
170 content::TestBrowserThreadBundle thread_bundle_;
172 base::ScopedTempDir temp_dir_;
173 scoped_ptr<APIUtil> api_util_;
174 FakeDriveServiceWrapper* fake_drive_service_;
175 FakeDriveUploader* fake_drive_uploader_;
176 scoped_ptr<FakeDriveServiceHelper> fake_drive_helper_;
178 DISALLOW_COPY_AND_ASSIGN(APIUtilTest);
181 void DidGetResourceID(Output* output,
182 GDataErrorCode error,
183 const std::string& resource_id) {
184 ASSERT_TRUE(output);
185 output->error = error;
186 output->resource_id = resource_id;
189 void DidGetLargestChangeStamp(Output* output,
190 GDataErrorCode error,
191 int64 largest_changestamp) {
192 ASSERT_TRUE(output);
193 output->error = error;
194 output->largest_changestamp = largest_changestamp;
197 void DidGetResourceList(GDataErrorCode* error_out,
198 scoped_ptr<ResourceList>* document_feed_out,
199 GDataErrorCode error,
200 scoped_ptr<ResourceList> document_feed) {
201 ASSERT_TRUE(error_out);
202 ASSERT_TRUE(document_feed_out);
203 *error_out = error;
204 *document_feed_out = document_feed.Pass();
207 void DidDownloadFile(Output* output,
208 GDataErrorCode error,
209 const std::string& file_md5,
210 int64 file_size,
211 const base::Time& updated_time,
212 webkit_blob::ScopedFile file) {
213 ASSERT_TRUE(output);
214 ASSERT_TRUE(base::PathExists(file.path()));
215 output->error = error;
216 output->file_md5 = file_md5;
219 void DidUploadFile(Output* output,
220 GDataErrorCode error,
221 const std::string& resource_id,
222 const std::string& file_md5) {
223 ASSERT_TRUE(output);
224 output->error = error;
225 output->resource_id = resource_id;
226 output->file_md5 = file_md5;
229 void DidDeleteFile(GDataErrorCode* error_out,
230 GDataErrorCode error) {
231 ASSERT_TRUE(error);
232 *error_out = error;
235 void APIUtilTest::TestGetSyncRoot() {
236 const std::string sync_root_id = SetUpSyncRootDirectory();
238 Output output;
239 api_util()->GetDriveDirectoryForSyncRoot(
240 base::Bind(&DidGetResourceID, &output));
241 base::MessageLoop::current()->RunUntilIdle();
243 EXPECT_EQ(google_apis::HTTP_SUCCESS, output.error);
244 EXPECT_EQ(sync_root_id, output.resource_id);
247 void APIUtilTest::TestCreateSyncRoot() {
248 Output output;
249 api_util()->GetDriveDirectoryForSyncRoot(
250 base::Bind(&DidGetResourceID, &output));
251 base::MessageLoop::current()->RunUntilIdle();
253 EXPECT_EQ(google_apis::HTTP_CREATED, output.error);
254 EXPECT_FALSE(output.resource_id.empty());
256 VerifyTitleUniqueness(std::string(), // directory_resource_id
257 APIUtil::GetSyncRootDirectoryName(),
258 output.resource_id,
259 google_apis::ENTRY_KIND_FOLDER);
262 void APIUtilTest::TestCreateSyncRoot_Conflict() {
263 fake_drive_service()->set_make_directory_conflict(true);
265 Output output;
266 api_util()->GetDriveDirectoryForSyncRoot(
267 base::Bind(&DidGetResourceID, &output));
268 base::MessageLoop::current()->RunUntilIdle();
270 EXPECT_EQ(google_apis::HTTP_SUCCESS, output.error);
271 EXPECT_FALSE(output.resource_id.empty());
273 // Verify that there is no duplicated directory on the remote side.
274 VerifyTitleUniqueness(std::string(), // directory_resource_id
275 APIUtil::GetSyncRootDirectoryName(),
276 output.resource_id,
277 google_apis::ENTRY_KIND_FOLDER);
280 void APIUtilTest::TestGetOriginDirectory() {
281 const std::string sync_root_id = SetUpSyncRootDirectory();
282 const std::string origin_root_id = SetUpOriginRootDirectory(sync_root_id);
284 Output output;
285 api_util()->GetDriveDirectoryForOrigin(
286 sync_root_id,
287 GURL(kOrigin),
288 base::Bind(&DidGetResourceID, &output));
289 base::MessageLoop::current()->RunUntilIdle();
291 EXPECT_EQ(google_apis::HTTP_SUCCESS, output.error);
292 EXPECT_EQ(origin_root_id, output.resource_id);
295 void APIUtilTest::TestCreateOriginDirectory() {
296 const std::string& sync_root_id = SetUpSyncRootDirectory();
298 Output output;
299 api_util()->GetDriveDirectoryForOrigin(
300 sync_root_id,
301 GURL(kOrigin),
302 base::Bind(&DidGetResourceID, &output));
303 base::MessageLoop::current()->RunUntilIdle();
305 EXPECT_EQ(google_apis::HTTP_CREATED, output.error);
306 EXPECT_FALSE(output.resource_id.empty());
308 VerifyTitleUniqueness(sync_root_id,
309 kOriginDirectoryName,
310 output.resource_id,
311 google_apis::ENTRY_KIND_FOLDER);
314 void APIUtilTest::TestCreateOriginDirectory_Conflict() {
315 fake_drive_service()->set_make_directory_conflict(true);
316 const std::string sync_root_id = SetUpSyncRootDirectory();
318 Output output;
319 api_util()->GetDriveDirectoryForOrigin(
320 sync_root_id,
321 GURL(kOrigin),
322 base::Bind(&DidGetResourceID, &output));
323 base::MessageLoop::current()->RunUntilIdle();
325 EXPECT_EQ(google_apis::HTTP_SUCCESS, output.error);
326 EXPECT_FALSE(output.resource_id.empty());
328 // Verify that there is no duplicated directory on the remote side.
329 VerifyTitleUniqueness(sync_root_id,
330 kOriginDirectoryName,
331 output.resource_id,
332 google_apis::ENTRY_KIND_FOLDER);
335 void APIUtilTest::TestGetLargestChangeStamp() {
336 Output output;
337 api_util()->GetLargestChangeStamp(
338 base::Bind(&DidGetLargestChangeStamp, &output));
339 base::MessageLoop::current()->RunUntilIdle();
341 EXPECT_EQ(google_apis::HTTP_SUCCESS, output.error);
342 EXPECT_EQ(fake_drive_service()->about_resource().largest_change_id(),
343 output.largest_changestamp);
346 void APIUtilTest::TestListFiles() {
347 fake_drive_service()->set_default_max_results(3);
348 const std::string sync_root_id = SetUpSyncRootDirectory();
349 const std::string origin_root_id = SetUpOriginRootDirectory(sync_root_id);
351 int kNumberOfFiles = 5;
352 for (int i = 0; i < kNumberOfFiles; ++i) {
353 scoped_ptr<ResourceEntry> file;
354 std::string file_content = base::StringPrintf("test content %d", i);
355 std::string file_title = base::StringPrintf("test_%d.txt", i);
356 SetUpFile(origin_root_id, file_content, file_title, &file);
359 GDataErrorCode error = google_apis::GDATA_OTHER_ERROR;
360 scoped_ptr<ResourceList> document_feed;
361 api_util()->ListFiles(
362 origin_root_id,
363 base::Bind(&DidGetResourceList, &error, &document_feed));
364 base::MessageLoop::current()->RunUntilIdle();
366 EXPECT_EQ(google_apis::HTTP_SUCCESS, error);
367 EXPECT_EQ(3U, document_feed->entries().size());
369 GURL feed_url;
370 ASSERT_TRUE(document_feed->GetNextFeedURL(&feed_url));
372 error = google_apis::GDATA_OTHER_ERROR;
373 document_feed.reset();
375 api_util()->ContinueListing(
376 feed_url,
377 base::Bind(&DidGetResourceList, &error, &document_feed));
378 base::MessageLoop::current()->RunUntilIdle();
380 EXPECT_EQ(google_apis::HTTP_SUCCESS, error);
381 EXPECT_EQ(2U, document_feed->entries().size());
384 void APIUtilTest::TestListChanges() {
385 const int64 old_changestamp =
386 fake_drive_service()->about_resource().largest_change_id();
387 const std::string sync_root_id = SetUpSyncRootDirectory();
388 const std::string origin_root_id = SetUpOriginRootDirectory(sync_root_id);
390 // Files should have changestamp #4+ since creating the sync root directory is
391 // #1, moving it out of 'My Drive' is #2, and creating the origin root
392 // directory is #3.
393 const int kNumberOfFiles = 5;
394 for (int i = 0; i < kNumberOfFiles; ++i) {
395 scoped_ptr<ResourceEntry> file;
396 std::string file_content = base::StringPrintf("test content %d", i);
397 std::string file_title = base::StringPrintf("test_%d.txt", i);
398 SetUpFile(origin_root_id, file_content, file_title, &file);
401 GDataErrorCode error = google_apis::GDATA_OTHER_ERROR;
402 scoped_ptr<ResourceList> document_feed;
403 api_util()->ListFiles(
404 origin_root_id,
405 base::Bind(&DidGetResourceList, &error, &document_feed));
406 base::MessageLoop::current()->RunUntilIdle();
408 EXPECT_EQ(google_apis::HTTP_SUCCESS, error);
409 EXPECT_EQ(5U, document_feed->entries().size());
411 error = google_apis::GDATA_OTHER_ERROR;
412 document_feed.reset();
413 api_util()->ListChanges(
414 old_changestamp + 6,
415 base::Bind(&DidGetResourceList, &error, &document_feed));
416 base::MessageLoop::current()->RunUntilIdle();
418 // There should be 3 files which have changestamp #6+.
419 EXPECT_EQ(google_apis::HTTP_SUCCESS, error);
420 EXPECT_EQ(3U, document_feed->entries().size());
423 void APIUtilTest::TestDownloadFile() {
424 const std::string kFileContent = "test content";
425 const std::string kFileTitle = "test.txt";
426 const std::string sync_root_id = SetUpSyncRootDirectory();
427 const std::string origin_root_id = SetUpOriginRootDirectory(sync_root_id);
429 scoped_ptr<ResourceEntry> file;
430 SetUpFile(origin_root_id, kFileContent, kFileTitle, &file);
432 Output output;
433 api_util()->DownloadFile(
434 file->resource_id(),
435 "", // local_file_md5
436 base::Bind(&DidDownloadFile, &output));
437 base::MessageLoop::current()->RunUntilIdle();
439 EXPECT_EQ(file->file_md5(), output.file_md5);
440 EXPECT_EQ(google_apis::HTTP_SUCCESS, output.error);
443 void APIUtilTest::TestDownloadFileInNotModified() {
444 const std::string kFileContent = "test content";
445 const std::string kFileTitle = "test.txt";
446 const std::string sync_root_id = SetUpSyncRootDirectory();
447 const std::string origin_root_id = SetUpOriginRootDirectory(sync_root_id);
449 scoped_ptr<ResourceEntry> file;
450 SetUpFile(origin_root_id, kFileContent, kFileTitle, &file);
452 // Since local file's hash value is equal to remote file's one, it is expected
453 // to cancel download the file and to return NOT_MODIFIED status code.
454 Output output;
455 api_util()->DownloadFile(
456 file->resource_id(),
457 file->file_md5(),
458 base::Bind(&DidDownloadFile, &output));
459 base::MessageLoop::current()->RunUntilIdle();
461 EXPECT_EQ(file->file_md5(), output.file_md5);
462 EXPECT_EQ(google_apis::HTTP_NOT_MODIFIED, output.error);
465 void APIUtilTest::TestUploadNewFile() {
466 const std::string kFileTitle = "test.txt";
467 const base::FilePath kLocalFilePath(FPL("/tmp/dir/file"));
468 const std::string sync_root_id = SetUpSyncRootDirectory();
469 const std::string origin_root_id = SetUpOriginRootDirectory(sync_root_id);
471 Output output;
472 api_util()->UploadNewFile(
473 origin_root_id,
474 kLocalFilePath,
475 kFileTitle,
476 base::Bind(&DidUploadFile, &output));
477 base::MessageLoop::current()->RunUntilIdle();
479 EXPECT_EQ(google_apis::HTTP_CREATED, output.error);
480 EXPECT_TRUE(!output.resource_id.empty());
482 VerifyTitleUniqueness(origin_root_id,
483 kFileTitle,
484 output.resource_id,
485 google_apis::ENTRY_KIND_FILE);
488 void APIUtilTest::TestUploadNewFile_ConflictWithFile() {
489 const std::string kFileTitle = "test.txt";
490 const base::FilePath kLocalFilePath(FPL("/tmp/dir/file"));
491 const std::string sync_root_id = SetUpSyncRootDirectory();
492 const std::string origin_root_id = SetUpOriginRootDirectory(sync_root_id);
494 fake_drive_uploader()->set_make_file_conflict(true);
496 Output output;
497 api_util()->UploadNewFile(
498 origin_root_id,
499 kLocalFilePath,
500 kFileTitle,
501 base::Bind(&DidUploadFile, &output));
502 base::MessageLoop::current()->RunUntilIdle();
504 // HTTP_CONFLICT error must be returned with empty resource_id.
505 EXPECT_EQ(google_apis::HTTP_CONFLICT, output.error);
506 EXPECT_TRUE(!output.resource_id.empty());
508 // Verify that there is no duplicated file on the remote side.
509 VerifyTitleUniqueness(origin_root_id,
510 kFileTitle,
511 output.resource_id,
512 google_apis::ENTRY_KIND_FILE);
515 void APIUtilTest::TestUploadExistingFile() {
516 const base::FilePath kLocalFilePath(FPL("/tmp/dir/file"));
517 const std::string kFileContent = "test content";
518 const std::string kFileTitle = "test.txt";
519 const std::string sync_root_id = SetUpSyncRootDirectory();
520 const std::string origin_root_id = SetUpOriginRootDirectory(sync_root_id);
522 scoped_ptr<ResourceEntry> file;
523 SetUpFile(origin_root_id, kFileContent, kFileTitle, &file);
525 Output output;
526 api_util()->UploadExistingFile(
527 file->resource_id(),
528 file->file_md5(),
529 kLocalFilePath,
530 base::Bind(&DidUploadFile, &output));
531 base::MessageLoop::current()->RunUntilIdle();
533 EXPECT_EQ(google_apis::HTTP_SUCCESS, output.error);
534 EXPECT_EQ(file->resource_id(), output.resource_id);
536 VerifyTitleUniqueness(origin_root_id,
537 file->title(),
538 file->resource_id(),
539 file->kind());
542 void APIUtilTest::TestUploadExistingFileInConflict() {
543 const base::FilePath kLocalFilePath(FPL("/tmp/dir/file"));
544 const std::string kFileContent = "test content";
545 const std::string kFileTitle = "test.txt";
546 const std::string sync_root_id = SetUpSyncRootDirectory();
547 const std::string origin_root_id = SetUpOriginRootDirectory(sync_root_id);
549 scoped_ptr<ResourceEntry> file;
550 SetUpFile(origin_root_id, kFileContent, kFileTitle, &file);
552 // Since remote file's hash value is different from the expected one, it is
553 // expected to cancel upload the file and to return CONFLICT status code.
554 const std::string kExpectedRemoteFileMD5 = "123456";
556 Output output;
557 api_util()->UploadExistingFile(
558 file->resource_id(),
559 kExpectedRemoteFileMD5,
560 kLocalFilePath,
561 base::Bind(&DidUploadFile, &output));
562 base::MessageLoop::current()->RunUntilIdle();
564 EXPECT_EQ(google_apis::HTTP_CONFLICT, output.error);
565 EXPECT_TRUE(output.resource_id.empty());
567 // Verify that there is no duplicated file on the remote side.
568 VerifyTitleUniqueness(origin_root_id,
569 file->title(),
570 file->resource_id(),
571 file->kind());
574 void APIUtilTest::TestDeleteFile() {
575 const std::string kFileContent = "test content";
576 const std::string kFileTitle = "test.txt";
577 const std::string sync_root_id = SetUpSyncRootDirectory();
578 const std::string origin_root_id = SetUpOriginRootDirectory(sync_root_id);
580 scoped_ptr<ResourceEntry> file;
581 SetUpFile(origin_root_id, kFileContent, kFileTitle, &file);
583 GDataErrorCode error = google_apis::GDATA_OTHER_ERROR;
584 api_util()->DeleteFile(file->resource_id(),
585 file->file_md5(),
586 base::Bind(&DidDeleteFile, &error));
587 base::MessageLoop::current()->RunUntilIdle();
589 EXPECT_EQ(google_apis::HTTP_SUCCESS, error);
591 VerifyFileDeletion(origin_root_id, kFileTitle);
594 void APIUtilTest::TestDeleteFileInConflict() {
595 const std::string kFileContent = "test content";
596 const std::string kFileTitle = "test.txt";
597 const std::string sync_root_id = SetUpSyncRootDirectory();
598 const std::string origin_root_id = SetUpOriginRootDirectory(sync_root_id);
600 scoped_ptr<ResourceEntry> file;
601 SetUpFile(origin_root_id, kFileContent, kFileTitle, &file);
603 // Since remote file's hash value is different from the expected one, it is
604 // expected to cancel delete the file and to return CONFLICT status code.
605 const std::string kExpectedRemoteFileMD5 = "123456";
607 GDataErrorCode error = google_apis::GDATA_OTHER_ERROR;
608 api_util()->DeleteFile(file->resource_id(),
609 kExpectedRemoteFileMD5,
610 base::Bind(&DidDeleteFile, &error));
611 base::MessageLoop::current()->RunUntilIdle();
613 EXPECT_EQ(google_apis::HTTP_CONFLICT, error);
615 // Verify that the conflict file was not deleted on the remote side.
616 VerifyTitleUniqueness(origin_root_id,
617 file->title(),
618 file->resource_id(),
619 file->kind());
622 void APIUtilTest::TestCreateDirectory() {
623 const std::string kDirectoryTitle("directory");
624 const std::string sync_root_id = SetUpSyncRootDirectory();
625 const std::string origin_root_id = SetUpOriginRootDirectory(sync_root_id);
627 Output output;
628 api_util()->CreateDirectory(
629 origin_root_id,
630 kDirectoryTitle,
631 base::Bind(&DidGetResourceID, &output));
632 base::MessageLoop::current()->RunUntilIdle();
634 EXPECT_EQ(google_apis::HTTP_CREATED, output.error);
635 EXPECT_FALSE(output.resource_id.empty());
637 VerifyTitleUniqueness(origin_root_id,
638 kDirectoryTitle,
639 output.resource_id,
640 google_apis::ENTRY_KIND_FOLDER);
643 TEST_F(APIUtilTest, GetSyncRoot) {
644 ASSERT_FALSE(IsDriveAPIDisabled());
645 TestGetSyncRoot();
648 TEST_F(APIUtilTest, GetSyncRoot_WAPI) {
649 ScopedDisableDriveAPI disable_drive_api;
650 TestGetSyncRoot();
653 TEST_F(APIUtilTest, CreateSyncRoot) {
654 ASSERT_FALSE(IsDriveAPIDisabled());
655 TestCreateSyncRoot();
658 TEST_F(APIUtilTest, CreateSyncRoot_WAPI) {
659 ScopedDisableDriveAPI disable_drive_api;
660 TestCreateSyncRoot();
663 TEST_F(APIUtilTest, CreateSyncRoot_Conflict) {
664 ASSERT_FALSE(IsDriveAPIDisabled());
665 TestCreateSyncRoot_Conflict();
668 TEST_F(APIUtilTest, CreateSyncRoot_Conflict_WAPI) {
669 ScopedDisableDriveAPI disable_drive_api;
670 TestCreateSyncRoot_Conflict();
673 TEST_F(APIUtilTest, GetOriginDirectory) {
674 ASSERT_FALSE(IsDriveAPIDisabled());
675 TestGetOriginDirectory();
678 TEST_F(APIUtilTest, GetOriginDirectory_WAPI) {
679 ScopedDisableDriveAPI disable_drive_api;
680 TestGetOriginDirectory();
683 TEST_F(APIUtilTest, CreateOriginDirectory) {
684 ASSERT_FALSE(IsDriveAPIDisabled());
685 TestCreateOriginDirectory();
688 TEST_F(APIUtilTest, CreateOriginDirectory_WAPI) {
689 ScopedDisableDriveAPI disable_drive_api;
690 TestCreateOriginDirectory();
693 TEST_F(APIUtilTest, CreateOriginDirectory_Conflict) {
694 ASSERT_FALSE(IsDriveAPIDisabled());
695 TestCreateOriginDirectory_Conflict();
698 TEST_F(APIUtilTest, CreateOriginDirectory_Conflict_WAPI) {
699 ScopedDisableDriveAPI disable_drive_api;
700 TestCreateOriginDirectory_Conflict();
703 TEST_F(APIUtilTest, GetLargestChangeStamp) {
704 ASSERT_FALSE(IsDriveAPIDisabled());
705 TestGetLargestChangeStamp();
708 TEST_F(APIUtilTest, GetLargestChangeStamp_WAPI) {
709 ScopedDisableDriveAPI disable_drive_api;
710 TestGetLargestChangeStamp();
713 TEST_F(APIUtilTest, ListFiles) {
714 ASSERT_FALSE(IsDriveAPIDisabled());
715 TestListFiles();
718 TEST_F(APIUtilTest, ListFiles_WAPI) {
719 ScopedDisableDriveAPI disable_drive_api;
720 TestListFiles();
723 TEST_F(APIUtilTest, ListChanges) {
724 ASSERT_FALSE(IsDriveAPIDisabled());
725 TestListChanges();
728 TEST_F(APIUtilTest, ListChanges_WAPI) {
729 ScopedDisableDriveAPI disable_drive_api;
730 TestListChanges();
733 TEST_F(APIUtilTest, DownloadFile) {
734 ASSERT_FALSE(IsDriveAPIDisabled());
735 TestDownloadFile();
738 TEST_F(APIUtilTest, DownloadFile_WAPI) {
739 ScopedDisableDriveAPI disable_drive_api;
740 TestDownloadFile();
743 TEST_F(APIUtilTest, DownloadFileInNotModified) {
744 ASSERT_FALSE(IsDriveAPIDisabled());
745 TestDownloadFileInNotModified();
748 TEST_F(APIUtilTest, DownloadFileInNotModified_WAPI) {
749 ScopedDisableDriveAPI disable_drive_api;
750 TestDownloadFileInNotModified();
753 TEST_F(APIUtilTest, UploadNewFile) {
754 ASSERT_FALSE(IsDriveAPIDisabled());
755 TestUploadNewFile();
758 TEST_F(APIUtilTest, UploadNewFile_WAPI) {
759 ScopedDisableDriveAPI disable_drive_api;
760 TestUploadNewFile();
763 TEST_F(APIUtilTest, UploadNewFile_ConflictWithFile) {
764 ASSERT_FALSE(IsDriveAPIDisabled());
765 TestUploadNewFile_ConflictWithFile();
768 TEST_F(APIUtilTest, UploadNewFile_ConflictWithFile_WAPI) {
769 ScopedDisableDriveAPI disable_drive_api;
770 TestUploadNewFile_ConflictWithFile();
773 TEST_F(APIUtilTest, UploadExistingFile) {
774 ASSERT_FALSE(IsDriveAPIDisabled());
775 TestUploadExistingFile();
778 TEST_F(APIUtilTest, UploadExistingFile_WAPI) {
779 ScopedDisableDriveAPI disable_drive_api;
780 TestUploadExistingFile();
783 TEST_F(APIUtilTest, UploadExistingFileInConflict) {
784 ASSERT_FALSE(IsDriveAPIDisabled());
785 TestUploadExistingFileInConflict();
788 TEST_F(APIUtilTest, UploadExistingFileInConflict_WAPI) {
789 ScopedDisableDriveAPI disable_drive_api;
790 TestUploadExistingFileInConflict();
793 TEST_F(APIUtilTest, DeleteFile) {
794 ASSERT_FALSE(IsDriveAPIDisabled());
795 TestDeleteFile();
798 TEST_F(APIUtilTest, DeleteFile_WAPI) {
799 ScopedDisableDriveAPI disable_drive_api;
800 TestDeleteFile();
803 TEST_F(APIUtilTest, DeleteFileInConflict) {
804 ASSERT_FALSE(IsDriveAPIDisabled());
805 TestDeleteFileInConflict();
808 TEST_F(APIUtilTest, DeleteFileInConflict_WAPI) {
809 ScopedDisableDriveAPI disable_drive_api;
810 TestDeleteFileInConflict();
813 TEST_F(APIUtilTest, CreateDirectory) {
814 ASSERT_FALSE(IsDriveAPIDisabled());
815 TestCreateDirectory();
818 TEST_F(APIUtilTest, CreateDirectory_WAPI) {
819 ScopedDisableDriveAPI disable_drive_api;
820 TestCreateDirectory();
823 } // namespace drive_backend
824 } // namespace sync_file_system