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
3 // found in the LICENSE file.
5 #include "chrome/browser/drive/fake_drive_service.h"
10 #include "base/files/file_util.h"
11 #include "base/files/scoped_temp_dir.h"
13 #include "base/message_loop/message_loop.h"
14 #include "base/run_loop.h"
15 #include "base/stl_util.h"
16 #include "base/strings/stringprintf.h"
17 #include "base/strings/utf_string_conversions.h"
18 #include "chrome/browser/drive/test_util.h"
19 #include "google_apis/drive/drive_api_parser.h"
20 #include "google_apis/drive/test_util.h"
21 #include "testing/gtest/include/gtest/gtest.h"
23 using google_apis::AboutResource
;
24 using google_apis::AppList
;
25 using google_apis::ChangeList
;
26 using google_apis::ChangeResource
;
27 using google_apis::FileList
;
28 using google_apis::FileResource
;
29 using google_apis::DRIVE_NO_CONNECTION
;
30 using google_apis::DRIVE_OTHER_ERROR
;
31 using google_apis::DriveApiErrorCode
;
32 using google_apis::GetContentCallback
;
33 using google_apis::HTTP_CREATED
;
34 using google_apis::HTTP_FORBIDDEN
;
35 using google_apis::HTTP_NOT_FOUND
;
36 using google_apis::HTTP_NO_CONTENT
;
37 using google_apis::HTTP_PRECONDITION
;
38 using google_apis::HTTP_RESUME_INCOMPLETE
;
39 using google_apis::HTTP_SUCCESS
;
40 using google_apis::ProgressCallback
;
41 using google_apis::UploadRangeResponse
;
47 using google_apis::test_util::AppendProgressCallbackResult
;
48 using google_apis::test_util::CreateCopyResultCallback
;
49 using google_apis::test_util::ProgressInfo
;
50 using google_apis::test_util::TestGetContentCallback
;
51 using google_apis::test_util::WriteStringToFile
;
53 } // namespace test_util
57 class FakeDriveServiceTest
: public testing::Test
{
59 // Returns the resource entry that matches |resource_id|.
60 scoped_ptr
<FileResource
> FindEntry(const std::string
& resource_id
) {
61 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
62 scoped_ptr
<FileResource
> entry
;
63 fake_service_
.GetFileResource(
64 resource_id
, test_util::CreateCopyResultCallback(&error
, &entry
));
65 base::RunLoop().RunUntilIdle();
69 // Returns true if the resource identified by |resource_id| exists.
70 bool Exists(const std::string
& resource_id
) {
71 scoped_ptr
<FileResource
> entry
= FindEntry(resource_id
);
72 return entry
&& !entry
->labels().is_trashed();
75 // Adds a new directory at |parent_resource_id| with the given name.
76 // Returns true on success.
77 bool AddNewDirectory(const std::string
& parent_resource_id
,
78 const std::string
& directory_title
) {
79 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
80 scoped_ptr
<FileResource
> entry
;
81 fake_service_
.AddNewDirectory(
84 DriveServiceInterface::AddNewDirectoryOptions(),
85 test_util::CreateCopyResultCallback(&error
, &entry
));
86 base::RunLoop().RunUntilIdle();
87 return error
== HTTP_CREATED
;
90 // Returns true if the resource identified by |resource_id| has a parent
91 // identified by |parent_id|.
92 bool HasParent(const std::string
& resource_id
, const std::string
& parent_id
) {
93 scoped_ptr
<FileResource
> entry
= FindEntry(resource_id
);
95 for (size_t i
= 0; i
< entry
->parents().size(); ++i
) {
96 if (entry
->parents()[i
].file_id() == parent_id
)
103 int64
GetLargestChangeByAboutResource() {
104 DriveApiErrorCode error
;
105 scoped_ptr
<AboutResource
> about_resource
;
106 fake_service_
.GetAboutResource(
107 test_util::CreateCopyResultCallback(&error
, &about_resource
));
108 base::RunLoop().RunUntilIdle();
109 return about_resource
->largest_change_id();
112 base::MessageLoop message_loop_
;
113 FakeDriveService fake_service_
;
116 TEST_F(FakeDriveServiceTest
, GetAllFileList
) {
117 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
119 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
120 scoped_ptr
<FileList
> file_list
;
121 fake_service_
.GetAllFileList(
122 test_util::CreateCopyResultCallback(&error
, &file_list
));
123 base::RunLoop().RunUntilIdle();
125 EXPECT_EQ(HTTP_SUCCESS
, error
);
126 ASSERT_TRUE(file_list
);
127 // Do some sanity check.
128 EXPECT_EQ(15U, file_list
->items().size());
129 EXPECT_EQ(1, fake_service_
.file_list_load_count());
132 TEST_F(FakeDriveServiceTest
, GetAllFileList_Offline
) {
133 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
134 fake_service_
.set_offline(true);
136 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
137 scoped_ptr
<FileList
> file_list
;
138 fake_service_
.GetAllFileList(
139 test_util::CreateCopyResultCallback(&error
, &file_list
));
140 base::RunLoop().RunUntilIdle();
142 EXPECT_EQ(DRIVE_NO_CONNECTION
, error
);
143 EXPECT_FALSE(file_list
);
146 TEST_F(FakeDriveServiceTest
, GetFileListInDirectory_InRootDirectory
) {
147 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
149 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
150 scoped_ptr
<FileList
> file_list
;
151 fake_service_
.GetFileListInDirectory(
152 fake_service_
.GetRootResourceId(),
153 test_util::CreateCopyResultCallback(&error
, &file_list
));
154 base::RunLoop().RunUntilIdle();
156 EXPECT_EQ(HTTP_SUCCESS
, error
);
157 ASSERT_TRUE(file_list
);
158 // Do some sanity check. There are 8 entries in the root directory.
159 EXPECT_EQ(8U, file_list
->items().size());
160 EXPECT_EQ(1, fake_service_
.directory_load_count());
163 TEST_F(FakeDriveServiceTest
, GetFileListInDirectory_InNonRootDirectory
) {
164 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
166 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
167 scoped_ptr
<FileList
> file_list
;
168 fake_service_
.GetFileListInDirectory(
169 "1_folder_resource_id",
170 test_util::CreateCopyResultCallback(&error
, &file_list
));
171 base::RunLoop().RunUntilIdle();
173 EXPECT_EQ(HTTP_SUCCESS
, error
);
174 ASSERT_TRUE(file_list
);
175 // Do some sanity check. There is three entries in 1_folder_resource_id
177 EXPECT_EQ(3U, file_list
->items().size());
178 EXPECT_EQ(1, fake_service_
.directory_load_count());
181 TEST_F(FakeDriveServiceTest
, GetFileListInDirectory_Offline
) {
182 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
183 fake_service_
.set_offline(true);
185 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
186 scoped_ptr
<FileList
> file_list
;
187 fake_service_
.GetFileListInDirectory(
188 fake_service_
.GetRootResourceId(),
189 test_util::CreateCopyResultCallback(&error
, &file_list
));
190 base::RunLoop().RunUntilIdle();
192 EXPECT_EQ(DRIVE_NO_CONNECTION
, error
);
193 EXPECT_FALSE(file_list
);
196 TEST_F(FakeDriveServiceTest
, Search
) {
197 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
199 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
200 scoped_ptr
<FileList
> file_list
;
201 fake_service_
.Search(
202 "File", // search_query
203 test_util::CreateCopyResultCallback(&error
, &file_list
));
204 base::RunLoop().RunUntilIdle();
206 EXPECT_EQ(HTTP_SUCCESS
, error
);
207 ASSERT_TRUE(file_list
);
208 // Do some sanity check. There are 4 entries that contain "File" in their
210 EXPECT_EQ(4U, file_list
->items().size());
213 TEST_F(FakeDriveServiceTest
, Search_WithAttribute
) {
214 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
216 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
217 scoped_ptr
<FileList
> file_list
;
218 fake_service_
.Search(
219 "title:1.txt", // search_query
220 test_util::CreateCopyResultCallback(&error
, &file_list
));
221 base::RunLoop().RunUntilIdle();
223 EXPECT_EQ(HTTP_SUCCESS
, error
);
224 ASSERT_TRUE(file_list
);
225 // Do some sanity check. There are 4 entries that contain "1.txt" in their
227 EXPECT_EQ(4U, file_list
->items().size());
230 TEST_F(FakeDriveServiceTest
, Search_MultipleQueries
) {
231 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
233 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
234 scoped_ptr
<FileList
> file_list
;
235 fake_service_
.Search(
236 "Directory 1", // search_query
237 test_util::CreateCopyResultCallback(&error
, &file_list
));
238 base::RunLoop().RunUntilIdle();
240 EXPECT_EQ(HTTP_SUCCESS
, error
);
241 ASSERT_TRUE(file_list
);
242 // There are 2 entries that contain both "Directory" and "1" in their titles.
243 EXPECT_EQ(2U, file_list
->items().size());
245 fake_service_
.Search(
246 "\"Directory 1\"", // search_query
247 test_util::CreateCopyResultCallback(&error
, &file_list
));
248 base::RunLoop().RunUntilIdle();
250 EXPECT_EQ(HTTP_SUCCESS
, error
);
251 ASSERT_TRUE(file_list
);
252 // There is 1 entry that contain "Directory 1" in its title.
253 EXPECT_EQ(1U, file_list
->items().size());
256 TEST_F(FakeDriveServiceTest
, Search_Offline
) {
257 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
258 fake_service_
.set_offline(true);
260 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
261 scoped_ptr
<FileList
> file_list
;
262 fake_service_
.Search(
263 "Directory 1", // search_query
264 test_util::CreateCopyResultCallback(&error
, &file_list
));
265 base::RunLoop().RunUntilIdle();
267 EXPECT_EQ(DRIVE_NO_CONNECTION
, error
);
268 EXPECT_FALSE(file_list
);
271 TEST_F(FakeDriveServiceTest
, Search_Deleted
) {
272 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
274 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
275 fake_service_
.DeleteResource("2_file_resource_id",
276 std::string(), // etag
277 test_util::CreateCopyResultCallback(&error
));
278 base::RunLoop().RunUntilIdle();
279 EXPECT_EQ(HTTP_NO_CONTENT
, error
);
281 error
= DRIVE_OTHER_ERROR
;
282 scoped_ptr
<FileList
> file_list
;
283 fake_service_
.Search(
284 "File", // search_query
285 test_util::CreateCopyResultCallback(&error
, &file_list
));
286 base::RunLoop().RunUntilIdle();
288 EXPECT_EQ(HTTP_SUCCESS
, error
);
289 ASSERT_TRUE(file_list
);
290 // Do some sanity check. There are 4 entries that contain "File" in their
291 // titles and one of them is deleted.
292 EXPECT_EQ(3U, file_list
->items().size());
295 TEST_F(FakeDriveServiceTest
, Search_Trashed
) {
296 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
298 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
299 fake_service_
.TrashResource("2_file_resource_id",
300 test_util::CreateCopyResultCallback(&error
));
301 base::RunLoop().RunUntilIdle();
302 EXPECT_EQ(HTTP_SUCCESS
, error
);
304 error
= DRIVE_OTHER_ERROR
;
305 scoped_ptr
<FileList
> file_list
;
306 fake_service_
.Search(
307 "File", // search_query
308 test_util::CreateCopyResultCallback(&error
, &file_list
));
309 base::RunLoop().RunUntilIdle();
311 EXPECT_EQ(HTTP_SUCCESS
, error
);
312 ASSERT_TRUE(file_list
);
313 // Do some sanity check. There are 4 entries that contain "File" in their
314 // titles and one of them is deleted.
315 EXPECT_EQ(3U, file_list
->items().size());
318 TEST_F(FakeDriveServiceTest
, SearchByTitle
) {
319 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
321 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
322 scoped_ptr
<FileList
> file_list
;
323 fake_service_
.SearchByTitle(
325 fake_service_
.GetRootResourceId(), // directory_resource_id
326 test_util::CreateCopyResultCallback(&error
, &file_list
));
327 base::RunLoop().RunUntilIdle();
329 EXPECT_EQ(HTTP_SUCCESS
, error
);
330 ASSERT_TRUE(file_list
);
331 // Do some sanity check. There are 2 entries that contain "1.txt" in their
332 // titles directly under the root directory.
333 EXPECT_EQ(2U, file_list
->items().size());
336 TEST_F(FakeDriveServiceTest
, SearchByTitle_EmptyDirectoryResourceId
) {
337 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
339 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
340 scoped_ptr
<FileList
> file_list
;
341 fake_service_
.SearchByTitle(
343 "", // directory resource id
344 test_util::CreateCopyResultCallback(&error
, &file_list
));
345 base::RunLoop().RunUntilIdle();
347 EXPECT_EQ(HTTP_SUCCESS
, error
);
348 ASSERT_TRUE(file_list
);
349 // Do some sanity check. There are 4 entries that contain "1.txt" in their
351 EXPECT_EQ(4U, file_list
->items().size());
354 TEST_F(FakeDriveServiceTest
, SearchByTitle_Offline
) {
355 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
356 fake_service_
.set_offline(true);
358 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
359 scoped_ptr
<FileList
> file_list
;
360 fake_service_
.SearchByTitle(
361 "Directory 1", // title
362 fake_service_
.GetRootResourceId(), // directory_resource_id
363 test_util::CreateCopyResultCallback(&error
, &file_list
));
364 base::RunLoop().RunUntilIdle();
366 EXPECT_EQ(DRIVE_NO_CONNECTION
, error
);
367 EXPECT_FALSE(file_list
);
370 TEST_F(FakeDriveServiceTest
, GetChangeList_NoNewEntries
) {
371 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
373 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
374 scoped_ptr
<ChangeList
> change_list
;
375 fake_service_
.GetChangeList(
376 fake_service_
.about_resource().largest_change_id() + 1,
377 test_util::CreateCopyResultCallback(&error
, &change_list
));
378 base::RunLoop().RunUntilIdle();
380 EXPECT_EQ(HTTP_SUCCESS
, error
);
381 ASSERT_TRUE(change_list
);
382 EXPECT_EQ(fake_service_
.about_resource().largest_change_id(),
383 change_list
->largest_change_id());
384 // This should be empty as the latest changestamp was passed to
385 // GetChangeList(), hence there should be no new entries.
386 EXPECT_EQ(0U, change_list
->items().size());
387 // It's considered loaded even if the result is empty.
388 EXPECT_EQ(1, fake_service_
.change_list_load_count());
391 TEST_F(FakeDriveServiceTest
, GetChangeList_WithNewEntry
) {
392 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
393 const int64 old_largest_change_id
=
394 fake_service_
.about_resource().largest_change_id();
396 // Add a new directory in the root directory.
397 ASSERT_TRUE(AddNewDirectory(
398 fake_service_
.GetRootResourceId(), "new directory"));
400 // Get the resource list newer than old_largest_change_id.
401 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
402 scoped_ptr
<ChangeList
> change_list
;
403 fake_service_
.GetChangeList(
404 old_largest_change_id
+ 1,
405 test_util::CreateCopyResultCallback(&error
, &change_list
));
406 base::RunLoop().RunUntilIdle();
408 EXPECT_EQ(HTTP_SUCCESS
, error
);
409 ASSERT_TRUE(change_list
);
410 EXPECT_EQ(fake_service_
.about_resource().largest_change_id(),
411 change_list
->largest_change_id());
412 // The result should only contain the newly created directory.
413 ASSERT_EQ(1U, change_list
->items().size());
414 ASSERT_TRUE(change_list
->items()[0]->file());
415 EXPECT_EQ("new directory", change_list
->items()[0]->file()->title());
416 EXPECT_EQ(1, fake_service_
.change_list_load_count());
419 TEST_F(FakeDriveServiceTest
, GetChangeList_Offline
) {
420 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
421 fake_service_
.set_offline(true);
423 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
424 scoped_ptr
<ChangeList
> change_list
;
425 fake_service_
.GetChangeList(
426 654321, // start_changestamp
427 test_util::CreateCopyResultCallback(&error
, &change_list
));
428 base::RunLoop().RunUntilIdle();
430 EXPECT_EQ(DRIVE_NO_CONNECTION
, error
);
431 EXPECT_FALSE(change_list
);
434 TEST_F(FakeDriveServiceTest
, GetChangeList_DeletedEntry
) {
435 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
436 ASSERT_TRUE(Exists("2_file_resource_id"));
437 const int64 old_largest_change_id
=
438 fake_service_
.about_resource().largest_change_id();
440 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
441 fake_service_
.DeleteResource("2_file_resource_id",
442 std::string(), // etag
443 test_util::CreateCopyResultCallback(&error
));
444 base::RunLoop().RunUntilIdle();
445 ASSERT_EQ(HTTP_NO_CONTENT
, error
);
446 ASSERT_FALSE(Exists("2_file_resource_id"));
448 // Get the resource list newer than old_largest_change_id.
449 error
= DRIVE_OTHER_ERROR
;
450 scoped_ptr
<ChangeList
> change_list
;
451 fake_service_
.GetChangeList(
452 old_largest_change_id
+ 1,
453 test_util::CreateCopyResultCallback(&error
, &change_list
));
454 base::RunLoop().RunUntilIdle();
456 EXPECT_EQ(HTTP_SUCCESS
, error
);
457 ASSERT_TRUE(change_list
);
458 EXPECT_EQ(fake_service_
.about_resource().largest_change_id(),
459 change_list
->largest_change_id());
460 // The result should only contain the deleted file.
461 ASSERT_EQ(1U, change_list
->items().size());
462 const ChangeResource
& item
= *change_list
->items()[0];
463 EXPECT_EQ("2_file_resource_id", item
.file_id());
464 EXPECT_FALSE(item
.file());
465 EXPECT_TRUE(item
.is_deleted());
466 EXPECT_EQ(1, fake_service_
.change_list_load_count());
469 TEST_F(FakeDriveServiceTest
, GetChangeList_TrashedEntry
) {
470 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
471 ASSERT_TRUE(Exists("2_file_resource_id"));
472 const int64 old_largest_change_id
=
473 fake_service_
.about_resource().largest_change_id();
475 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
476 fake_service_
.TrashResource("2_file_resource_id",
477 test_util::CreateCopyResultCallback(&error
));
478 base::RunLoop().RunUntilIdle();
479 ASSERT_EQ(HTTP_SUCCESS
, error
);
480 ASSERT_FALSE(Exists("2_file_resource_id"));
482 // Get the resource list newer than old_largest_change_id.
483 error
= DRIVE_OTHER_ERROR
;
484 scoped_ptr
<ChangeList
> change_list
;
485 fake_service_
.GetChangeList(
486 old_largest_change_id
+ 1,
487 test_util::CreateCopyResultCallback(&error
, &change_list
));
488 base::RunLoop().RunUntilIdle();
490 EXPECT_EQ(HTTP_SUCCESS
, error
);
491 ASSERT_TRUE(change_list
);
492 EXPECT_EQ(fake_service_
.about_resource().largest_change_id(),
493 change_list
->largest_change_id());
494 // The result should only contain the trashed file.
495 ASSERT_EQ(1U, change_list
->items().size());
496 const ChangeResource
& item
= *change_list
->items()[0];
497 EXPECT_EQ("2_file_resource_id", item
.file_id());
498 ASSERT_TRUE(item
.file());
499 EXPECT_TRUE(item
.file()->labels().is_trashed());
500 EXPECT_EQ(1, fake_service_
.change_list_load_count());
503 TEST_F(FakeDriveServiceTest
, GetRemainingFileList_GetAllFileList
) {
504 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
505 fake_service_
.set_default_max_results(6);
507 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
508 scoped_ptr
<FileList
> file_list
;
509 fake_service_
.GetAllFileList(
510 test_util::CreateCopyResultCallback(&error
, &file_list
));
511 base::RunLoop().RunUntilIdle();
512 EXPECT_EQ(HTTP_SUCCESS
, error
);
513 ASSERT_TRUE(file_list
);
515 // Do some sanity check.
516 // The number of results is 14 entries. Thus, it should split into three
517 // chunks: 6, 6, and then 2.
518 EXPECT_EQ(6U, file_list
->items().size());
519 EXPECT_EQ(1, fake_service_
.file_list_load_count());
521 // Second page loading.
522 // Keep the next url before releasing the |file_list|.
523 GURL
next_url(file_list
->next_link());
525 error
= DRIVE_OTHER_ERROR
;
527 fake_service_
.GetRemainingFileList(
529 test_util::CreateCopyResultCallback(&error
, &file_list
));
530 base::RunLoop().RunUntilIdle();
532 EXPECT_EQ(HTTP_SUCCESS
, error
);
533 ASSERT_TRUE(file_list
);
535 EXPECT_EQ(6U, file_list
->items().size());
536 EXPECT_EQ(1, fake_service_
.file_list_load_count());
538 // Third page loading.
539 next_url
= file_list
->next_link();
541 error
= DRIVE_OTHER_ERROR
;
543 fake_service_
.GetRemainingFileList(
545 test_util::CreateCopyResultCallback(&error
, &file_list
));
546 base::RunLoop().RunUntilIdle();
548 EXPECT_EQ(HTTP_SUCCESS
, error
);
549 ASSERT_TRUE(file_list
);
551 EXPECT_EQ(3U, file_list
->items().size());
552 EXPECT_EQ(1, fake_service_
.file_list_load_count());
555 TEST_F(FakeDriveServiceTest
, GetRemainingFileList_GetFileListInDirectory
) {
556 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
557 fake_service_
.set_default_max_results(3);
559 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
560 scoped_ptr
<FileList
> file_list
;
561 fake_service_
.GetFileListInDirectory(
562 fake_service_
.GetRootResourceId(),
563 test_util::CreateCopyResultCallback(&error
, &file_list
));
564 base::RunLoop().RunUntilIdle();
565 EXPECT_EQ(HTTP_SUCCESS
, error
);
566 ASSERT_TRUE(file_list
);
568 // Do some sanity check.
569 // The number of results is 8 entries. Thus, it should split into three
570 // chunks: 3, 3, and then 2.
571 EXPECT_EQ(3U, file_list
->items().size());
572 EXPECT_EQ(1, fake_service_
.directory_load_count());
574 // Second page loading.
575 // Keep the next url before releasing the |file_list|.
576 GURL next_url
= file_list
->next_link();
578 error
= DRIVE_OTHER_ERROR
;
580 fake_service_
.GetRemainingFileList(
582 test_util::CreateCopyResultCallback(&error
, &file_list
));
583 base::RunLoop().RunUntilIdle();
585 EXPECT_EQ(HTTP_SUCCESS
, error
);
586 ASSERT_TRUE(file_list
);
588 EXPECT_EQ(3U, file_list
->items().size());
589 EXPECT_EQ(1, fake_service_
.directory_load_count());
591 // Third page loading.
592 next_url
= file_list
->next_link();
594 error
= DRIVE_OTHER_ERROR
;
596 fake_service_
.GetRemainingFileList(
598 test_util::CreateCopyResultCallback(&error
, &file_list
));
599 base::RunLoop().RunUntilIdle();
601 EXPECT_EQ(HTTP_SUCCESS
, error
);
602 ASSERT_TRUE(file_list
);
604 EXPECT_EQ(2U, file_list
->items().size());
605 EXPECT_EQ(1, fake_service_
.directory_load_count());
608 TEST_F(FakeDriveServiceTest
, GetRemainingFileList_Search
) {
609 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
610 fake_service_
.set_default_max_results(2);
612 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
613 scoped_ptr
<FileList
> file_list
;
614 fake_service_
.Search(
615 "File", // search_query
616 test_util::CreateCopyResultCallback(&error
, &file_list
));
617 base::RunLoop().RunUntilIdle();
618 EXPECT_EQ(HTTP_SUCCESS
, error
);
619 ASSERT_TRUE(file_list
);
621 // Do some sanity check.
622 // The number of results is 4 entries. Thus, it should split into two
623 // chunks: 2, and then 2
624 EXPECT_EQ(2U, file_list
->items().size());
626 // Second page loading.
627 // Keep the next url before releasing the |file_list|.
628 GURL next_url
= file_list
->next_link();
630 error
= DRIVE_OTHER_ERROR
;
632 fake_service_
.GetRemainingFileList(
634 test_util::CreateCopyResultCallback(&error
, &file_list
));
635 base::RunLoop().RunUntilIdle();
637 EXPECT_EQ(HTTP_SUCCESS
, error
);
638 ASSERT_TRUE(file_list
);
640 EXPECT_EQ(2U, file_list
->items().size());
643 TEST_F(FakeDriveServiceTest
, GetRemainingChangeList_GetChangeList
) {
644 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
645 fake_service_
.set_default_max_results(2);
646 const int64 old_largest_change_id
=
647 fake_service_
.about_resource().largest_change_id();
649 // Add 5 new directory in the root directory.
650 for (int i
= 0; i
< 5; ++i
) {
651 ASSERT_TRUE(AddNewDirectory(
652 fake_service_
.GetRootResourceId(),
653 base::StringPrintf("new directory %d", i
)));
656 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
657 scoped_ptr
<ChangeList
> change_list
;
658 fake_service_
.GetChangeList(
659 old_largest_change_id
+ 1, // start_changestamp
660 test_util::CreateCopyResultCallback(&error
, &change_list
));
661 base::RunLoop().RunUntilIdle();
662 EXPECT_EQ(HTTP_SUCCESS
, error
);
663 ASSERT_TRUE(change_list
);
665 // Do some sanity check.
666 // The number of results is 5 entries. Thus, it should split into three
667 // chunks: 2, 2 and then 1.
668 EXPECT_EQ(2U, change_list
->items().size());
669 EXPECT_EQ(1, fake_service_
.change_list_load_count());
671 // Second page loading.
672 // Keep the next url before releasing the |change_list|.
673 GURL next_url
= change_list
->next_link();
675 error
= DRIVE_OTHER_ERROR
;
677 fake_service_
.GetRemainingChangeList(
679 test_util::CreateCopyResultCallback(&error
, &change_list
));
680 base::RunLoop().RunUntilIdle();
682 EXPECT_EQ(HTTP_SUCCESS
, error
);
683 ASSERT_TRUE(change_list
);
685 EXPECT_EQ(2U, change_list
->items().size());
686 EXPECT_EQ(1, fake_service_
.change_list_load_count());
688 // Third page loading.
689 next_url
= change_list
->next_link();
691 error
= DRIVE_OTHER_ERROR
;
693 fake_service_
.GetRemainingChangeList(
695 test_util::CreateCopyResultCallback(&error
, &change_list
));
696 base::RunLoop().RunUntilIdle();
698 EXPECT_EQ(HTTP_SUCCESS
, error
);
699 ASSERT_TRUE(change_list
);
701 EXPECT_EQ(1U, change_list
->items().size());
702 EXPECT_EQ(1, fake_service_
.change_list_load_count());
705 TEST_F(FakeDriveServiceTest
, GetAboutResource
) {
706 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
707 scoped_ptr
<AboutResource
> about_resource
;
708 fake_service_
.GetAboutResource(
709 test_util::CreateCopyResultCallback(&error
, &about_resource
));
710 base::RunLoop().RunUntilIdle();
712 EXPECT_EQ(HTTP_SUCCESS
, error
);
714 ASSERT_TRUE(about_resource
);
715 // Do some sanity check.
716 EXPECT_EQ(fake_service_
.GetRootResourceId(),
717 about_resource
->root_folder_id());
718 EXPECT_EQ(1, fake_service_
.about_resource_load_count());
721 TEST_F(FakeDriveServiceTest
, GetAboutResource_Offline
) {
722 fake_service_
.set_offline(true);
724 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
725 scoped_ptr
<AboutResource
> about_resource
;
726 fake_service_
.GetAboutResource(
727 test_util::CreateCopyResultCallback(&error
, &about_resource
));
728 base::RunLoop().RunUntilIdle();
730 EXPECT_EQ(DRIVE_NO_CONNECTION
, error
);
731 EXPECT_FALSE(about_resource
);
734 TEST_F(FakeDriveServiceTest
, GetAppList
) {
735 ASSERT_TRUE(fake_service_
.LoadAppListForDriveApi(
736 "drive/applist.json"));
738 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
739 scoped_ptr
<AppList
> app_list
;
740 fake_service_
.GetAppList(
741 test_util::CreateCopyResultCallback(&error
, &app_list
));
742 base::RunLoop().RunUntilIdle();
744 EXPECT_EQ(HTTP_SUCCESS
, error
);
746 ASSERT_TRUE(app_list
);
747 EXPECT_EQ(1, fake_service_
.app_list_load_count());
750 TEST_F(FakeDriveServiceTest
, GetAppList_Offline
) {
751 ASSERT_TRUE(fake_service_
.LoadAppListForDriveApi(
752 "drive/applist.json"));
753 fake_service_
.set_offline(true);
755 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
756 scoped_ptr
<AppList
> app_list
;
757 fake_service_
.GetAppList(
758 test_util::CreateCopyResultCallback(&error
, &app_list
));
759 base::RunLoop().RunUntilIdle();
761 EXPECT_EQ(DRIVE_NO_CONNECTION
, error
);
762 EXPECT_FALSE(app_list
);
765 TEST_F(FakeDriveServiceTest
, GetFileResource_ExistingFile
) {
766 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
768 const std::string kResourceId
= "2_file_resource_id";
769 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
770 scoped_ptr
<FileResource
> entry
;
771 fake_service_
.GetFileResource(
772 kResourceId
, test_util::CreateCopyResultCallback(&error
, &entry
));
773 base::RunLoop().RunUntilIdle();
775 EXPECT_EQ(HTTP_SUCCESS
, error
);
777 // Do some sanity check.
778 EXPECT_EQ(kResourceId
, entry
->file_id());
781 TEST_F(FakeDriveServiceTest
, GetFileResource_NonexistingFile
) {
782 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
784 const std::string kResourceId
= "nonexisting_resource_id";
785 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
786 scoped_ptr
<FileResource
> entry
;
787 fake_service_
.GetFileResource(
788 kResourceId
, test_util::CreateCopyResultCallback(&error
, &entry
));
789 base::RunLoop().RunUntilIdle();
791 EXPECT_EQ(HTTP_NOT_FOUND
, error
);
795 TEST_F(FakeDriveServiceTest
, GetFileResource_Offline
) {
796 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
797 fake_service_
.set_offline(true);
799 const std::string kResourceId
= "2_file_resource_id";
800 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
801 scoped_ptr
<FileResource
> entry
;
802 fake_service_
.GetFileResource(
803 kResourceId
, test_util::CreateCopyResultCallback(&error
, &entry
));
804 base::RunLoop().RunUntilIdle();
806 EXPECT_EQ(DRIVE_NO_CONNECTION
, error
);
810 TEST_F(FakeDriveServiceTest
, GetShareUrl
) {
811 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
813 const std::string kResourceId
= "2_file_resource_id";
814 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
816 fake_service_
.GetShareUrl(
818 GURL(), // embed origin
819 test_util::CreateCopyResultCallback(&error
, &share_url
));
820 base::RunLoop().RunUntilIdle();
822 EXPECT_EQ(HTTP_SUCCESS
, error
);
823 EXPECT_FALSE(share_url
.is_empty());
826 TEST_F(FakeDriveServiceTest
, DeleteResource_ExistingFile
) {
827 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
829 // Resource "2_file_resource_id" should now exist.
830 ASSERT_TRUE(Exists("2_file_resource_id"));
832 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
833 fake_service_
.DeleteResource("2_file_resource_id",
834 std::string(), // etag
835 test_util::CreateCopyResultCallback(&error
));
836 base::RunLoop().RunUntilIdle();
838 EXPECT_EQ(HTTP_NO_CONTENT
, error
);
839 // Resource "2_file_resource_id" should be gone now.
840 EXPECT_FALSE(Exists("2_file_resource_id"));
842 error
= DRIVE_OTHER_ERROR
;
843 fake_service_
.DeleteResource("2_file_resource_id",
844 std::string(), // etag
845 test_util::CreateCopyResultCallback(&error
));
846 base::RunLoop().RunUntilIdle();
847 EXPECT_EQ(HTTP_NOT_FOUND
, error
);
848 EXPECT_FALSE(Exists("2_file_resource_id"));
851 TEST_F(FakeDriveServiceTest
, DeleteResource_NonexistingFile
) {
852 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
854 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
855 fake_service_
.DeleteResource("nonexisting_resource_id",
856 std::string(), // etag
857 test_util::CreateCopyResultCallback(&error
));
858 base::RunLoop().RunUntilIdle();
860 EXPECT_EQ(HTTP_NOT_FOUND
, error
);
863 TEST_F(FakeDriveServiceTest
, DeleteResource_ETagMatch
) {
864 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
866 // Resource "2_file_resource_id" should now exist.
867 scoped_ptr
<FileResource
> entry
= FindEntry("2_file_resource_id");
869 ASSERT_FALSE(entry
->labels().is_trashed());
870 ASSERT_FALSE(entry
->etag().empty());
872 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
873 fake_service_
.DeleteResource("2_file_resource_id",
874 entry
->etag() + "_mismatch",
875 test_util::CreateCopyResultCallback(&error
));
876 base::RunLoop().RunUntilIdle();
878 EXPECT_EQ(HTTP_PRECONDITION
, error
);
879 // Resource "2_file_resource_id" should still exist.
880 EXPECT_TRUE(Exists("2_file_resource_id"));
882 error
= DRIVE_OTHER_ERROR
;
883 fake_service_
.DeleteResource("2_file_resource_id",
885 test_util::CreateCopyResultCallback(&error
));
886 base::RunLoop().RunUntilIdle();
887 EXPECT_EQ(HTTP_NO_CONTENT
, error
);
888 // Resource "2_file_resource_id" should be gone now.
889 EXPECT_FALSE(Exists("2_file_resource_id"));
892 TEST_F(FakeDriveServiceTest
, DeleteResource_Offline
) {
893 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
894 fake_service_
.set_offline(true);
896 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
897 fake_service_
.DeleteResource("2_file_resource_id",
898 std::string(), // etag
899 test_util::CreateCopyResultCallback(&error
));
900 base::RunLoop().RunUntilIdle();
902 EXPECT_EQ(DRIVE_NO_CONNECTION
, error
);
905 TEST_F(FakeDriveServiceTest
, DeleteResource_Forbidden
) {
906 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
908 EXPECT_EQ(HTTP_SUCCESS
, fake_service_
.SetUserPermission(
909 "2_file_resource_id", google_apis::drive::PERMISSION_ROLE_READER
));
911 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
912 fake_service_
.DeleteResource("2_file_resource_id",
913 std::string(), // etag
914 test_util::CreateCopyResultCallback(&error
));
915 base::RunLoop().RunUntilIdle();
917 EXPECT_EQ(HTTP_FORBIDDEN
, error
);
920 TEST_F(FakeDriveServiceTest
, TrashResource_ExistingFile
) {
921 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
923 // Resource "2_file_resource_id" should now exist.
924 ASSERT_TRUE(Exists("2_file_resource_id"));
926 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
927 fake_service_
.TrashResource("2_file_resource_id",
928 test_util::CreateCopyResultCallback(&error
));
929 base::RunLoop().RunUntilIdle();
931 EXPECT_EQ(HTTP_SUCCESS
, error
);
932 // Resource "2_file_resource_id" should be gone now.
933 EXPECT_FALSE(Exists("2_file_resource_id"));
935 error
= DRIVE_OTHER_ERROR
;
936 fake_service_
.TrashResource("2_file_resource_id",
937 test_util::CreateCopyResultCallback(&error
));
938 base::RunLoop().RunUntilIdle();
939 EXPECT_EQ(HTTP_NOT_FOUND
, error
);
940 EXPECT_FALSE(Exists("2_file_resource_id"));
943 TEST_F(FakeDriveServiceTest
, TrashResource_NonexistingFile
) {
944 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
946 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
947 fake_service_
.TrashResource("nonexisting_resource_id",
948 test_util::CreateCopyResultCallback(&error
));
949 base::RunLoop().RunUntilIdle();
951 EXPECT_EQ(HTTP_NOT_FOUND
, error
);
954 TEST_F(FakeDriveServiceTest
, TrashResource_Offline
) {
955 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
956 fake_service_
.set_offline(true);
958 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
959 fake_service_
.TrashResource("2_file_resource_id",
960 test_util::CreateCopyResultCallback(&error
));
961 base::RunLoop().RunUntilIdle();
963 EXPECT_EQ(DRIVE_NO_CONNECTION
, error
);
966 TEST_F(FakeDriveServiceTest
, TrashResource_Forbidden
) {
967 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
969 EXPECT_EQ(HTTP_SUCCESS
, fake_service_
.SetUserPermission(
970 "2_file_resource_id", google_apis::drive::PERMISSION_ROLE_READER
));
972 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
973 fake_service_
.TrashResource("2_file_resource_id",
974 test_util::CreateCopyResultCallback(&error
));
975 base::RunLoop().RunUntilIdle();
977 EXPECT_EQ(HTTP_FORBIDDEN
, error
);
980 TEST_F(FakeDriveServiceTest
, DownloadFile_ExistingFile
) {
981 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
983 base::ScopedTempDir temp_dir
;
984 ASSERT_TRUE(temp_dir
.CreateUniqueTempDir());
986 std::vector
<test_util::ProgressInfo
> download_progress_values
;
988 const base::FilePath kOutputFilePath
=
989 temp_dir
.path().AppendASCII("whatever.txt");
990 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
991 base::FilePath output_file_path
;
992 test_util::TestGetContentCallback get_content_callback
;
993 fake_service_
.DownloadFile(
995 "2_file_resource_id",
996 test_util::CreateCopyResultCallback(&error
, &output_file_path
),
997 get_content_callback
.callback(),
998 base::Bind(&test_util::AppendProgressCallbackResult
,
999 &download_progress_values
));
1000 base::RunLoop().RunUntilIdle();
1002 EXPECT_EQ(HTTP_SUCCESS
, error
);
1003 EXPECT_EQ(output_file_path
, kOutputFilePath
);
1004 std::string content
;
1005 ASSERT_TRUE(base::ReadFileToString(output_file_path
, &content
));
1006 EXPECT_EQ("This is some test content.", content
);
1007 ASSERT_TRUE(!download_progress_values
.empty());
1008 EXPECT_TRUE(base::STLIsSorted(download_progress_values
));
1009 EXPECT_LE(0, download_progress_values
.front().first
);
1010 EXPECT_GE(26, download_progress_values
.back().first
);
1011 EXPECT_EQ(content
, get_content_callback
.GetConcatenatedData());
1014 TEST_F(FakeDriveServiceTest
, DownloadFile_NonexistingFile
) {
1015 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
1017 base::ScopedTempDir temp_dir
;
1018 ASSERT_TRUE(temp_dir
.CreateUniqueTempDir());
1020 const base::FilePath kOutputFilePath
=
1021 temp_dir
.path().AppendASCII("whatever.txt");
1022 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
1023 base::FilePath output_file_path
;
1024 fake_service_
.DownloadFile(
1026 "non_existent_file_resource_id",
1027 test_util::CreateCopyResultCallback(&error
, &output_file_path
),
1028 GetContentCallback(),
1029 ProgressCallback());
1030 base::RunLoop().RunUntilIdle();
1032 EXPECT_EQ(HTTP_NOT_FOUND
, error
);
1035 TEST_F(FakeDriveServiceTest
, DownloadFile_Offline
) {
1036 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
1037 fake_service_
.set_offline(true);
1039 base::ScopedTempDir temp_dir
;
1040 ASSERT_TRUE(temp_dir
.CreateUniqueTempDir());
1042 const base::FilePath kOutputFilePath
=
1043 temp_dir
.path().AppendASCII("whatever.txt");
1044 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
1045 base::FilePath output_file_path
;
1046 fake_service_
.DownloadFile(
1048 "2_file_resource_id",
1049 test_util::CreateCopyResultCallback(&error
, &output_file_path
),
1050 GetContentCallback(),
1051 ProgressCallback());
1052 base::RunLoop().RunUntilIdle();
1054 EXPECT_EQ(DRIVE_NO_CONNECTION
, error
);
1057 TEST_F(FakeDriveServiceTest
, CopyResource
) {
1058 const base::Time::Exploded kModifiedDate
= {2012, 7, 0, 19, 15, 59, 13, 123};
1060 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
1062 int64 old_largest_change_id
= GetLargestChangeByAboutResource();
1064 const std::string kResourceId
= "2_file_resource_id";
1065 const std::string kParentResourceId
= "2_folder_resource_id";
1066 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
1067 scoped_ptr
<FileResource
> entry
;
1068 fake_service_
.CopyResource(
1072 base::Time::FromUTCExploded(kModifiedDate
),
1073 test_util::CreateCopyResultCallback(&error
, &entry
));
1074 base::RunLoop().RunUntilIdle();
1076 EXPECT_EQ(HTTP_SUCCESS
, error
);
1078 // The copied entry should have the new resource ID and the title.
1079 EXPECT_NE(kResourceId
, entry
->file_id());
1080 EXPECT_EQ("new title", entry
->title());
1081 EXPECT_EQ(base::Time::FromUTCExploded(kModifiedDate
), entry
->modified_date());
1082 EXPECT_TRUE(HasParent(entry
->file_id(), kParentResourceId
));
1083 // Should be incremented as a new hosted document was created.
1084 EXPECT_EQ(old_largest_change_id
+ 1,
1085 fake_service_
.about_resource().largest_change_id());
1086 EXPECT_EQ(old_largest_change_id
+ 1, GetLargestChangeByAboutResource());
1089 TEST_F(FakeDriveServiceTest
, CopyResource_NonExisting
) {
1090 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
1092 const std::string kResourceId
= "nonexisting_resource_id";
1093 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
1094 scoped_ptr
<FileResource
> entry
;
1095 fake_service_
.CopyResource(
1097 "1_folder_resource_id",
1100 test_util::CreateCopyResultCallback(&error
, &entry
));
1101 base::RunLoop().RunUntilIdle();
1103 EXPECT_EQ(HTTP_NOT_FOUND
, error
);
1106 TEST_F(FakeDriveServiceTest
, CopyResource_EmptyParentResourceId
) {
1107 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
1109 int64 old_largest_change_id
= GetLargestChangeByAboutResource();
1111 const std::string kResourceId
= "2_file_resource_id";
1112 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
1113 scoped_ptr
<FileResource
> entry
;
1114 fake_service_
.CopyResource(
1119 test_util::CreateCopyResultCallback(&error
, &entry
));
1120 base::RunLoop().RunUntilIdle();
1122 EXPECT_EQ(HTTP_SUCCESS
, error
);
1124 // The copied entry should have the new resource ID and the title.
1125 EXPECT_NE(kResourceId
, entry
->file_id());
1126 EXPECT_EQ("new title", entry
->title());
1127 EXPECT_TRUE(HasParent(kResourceId
, fake_service_
.GetRootResourceId()));
1128 // Should be incremented as a new hosted document was created.
1129 EXPECT_EQ(old_largest_change_id
+ 1,
1130 fake_service_
.about_resource().largest_change_id());
1131 EXPECT_EQ(old_largest_change_id
+ 1, GetLargestChangeByAboutResource());
1134 TEST_F(FakeDriveServiceTest
, CopyResource_Offline
) {
1135 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
1136 fake_service_
.set_offline(true);
1138 const std::string kResourceId
= "2_file_resource_id";
1139 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
1140 scoped_ptr
<FileResource
> entry
;
1141 fake_service_
.CopyResource(
1143 "1_folder_resource_id",
1146 test_util::CreateCopyResultCallback(&error
, &entry
));
1147 base::RunLoop().RunUntilIdle();
1149 EXPECT_EQ(DRIVE_NO_CONNECTION
, error
);
1150 EXPECT_FALSE(entry
);
1153 TEST_F(FakeDriveServiceTest
, UpdateResource
) {
1154 const base::Time::Exploded kModifiedDate
= {2012, 7, 0, 19, 15, 59, 13, 123};
1155 const base::Time::Exploded kViewedDate
= {2013, 8, 1, 20, 16, 00, 14, 234};
1157 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
1159 int64 old_largest_change_id
= GetLargestChangeByAboutResource();
1161 const std::string kResourceId
= "2_file_resource_id";
1162 const std::string kParentResourceId
= "2_folder_resource_id";
1163 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
1164 scoped_ptr
<FileResource
> entry
;
1165 fake_service_
.UpdateResource(
1166 kResourceId
, kParentResourceId
, "new title",
1167 base::Time::FromUTCExploded(kModifiedDate
),
1168 base::Time::FromUTCExploded(kViewedDate
),
1169 google_apis::drive::Properties(),
1170 test_util::CreateCopyResultCallback(&error
, &entry
));
1171 base::RunLoop().RunUntilIdle();
1173 EXPECT_EQ(HTTP_SUCCESS
, error
);
1175 // The updated entry should have the new title.
1176 EXPECT_EQ(kResourceId
, entry
->file_id());
1177 EXPECT_EQ("new title", entry
->title());
1178 EXPECT_EQ(base::Time::FromUTCExploded(kModifiedDate
),
1179 entry
->modified_date());
1180 EXPECT_EQ(base::Time::FromUTCExploded(kViewedDate
),
1181 entry
->last_viewed_by_me_date());
1182 EXPECT_TRUE(HasParent(kResourceId
, kParentResourceId
));
1183 // Should be incremented as a new hosted document was created.
1184 EXPECT_EQ(old_largest_change_id
+ 1,
1185 fake_service_
.about_resource().largest_change_id());
1186 EXPECT_EQ(old_largest_change_id
+ 1, GetLargestChangeByAboutResource());
1189 TEST_F(FakeDriveServiceTest
, UpdateResource_NonExisting
) {
1190 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
1192 const std::string kResourceId
= "nonexisting_resource_id";
1193 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
1194 scoped_ptr
<FileResource
> entry
;
1195 fake_service_
.UpdateResource(
1196 kResourceId
, "1_folder_resource_id", "new title", base::Time(),
1197 base::Time(), google_apis::drive::Properties(),
1198 test_util::CreateCopyResultCallback(&error
, &entry
));
1199 base::RunLoop().RunUntilIdle();
1201 EXPECT_EQ(HTTP_NOT_FOUND
, error
);
1204 TEST_F(FakeDriveServiceTest
, UpdateResource_EmptyParentResourceId
) {
1205 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
1207 int64 old_largest_change_id
= GetLargestChangeByAboutResource();
1209 const std::string kResourceId
= "2_file_resource_id";
1211 // Just make sure that the resource is under root.
1212 ASSERT_TRUE(HasParent(kResourceId
, "fake_root"));
1214 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
1215 scoped_ptr
<FileResource
> entry
;
1216 fake_service_
.UpdateResource(
1217 kResourceId
, std::string(), "new title", base::Time(), base::Time(),
1218 google_apis::drive::Properties(),
1219 test_util::CreateCopyResultCallback(&error
, &entry
));
1220 base::RunLoop().RunUntilIdle();
1222 EXPECT_EQ(HTTP_SUCCESS
, error
);
1224 // The updated entry should have the new title.
1225 EXPECT_EQ(kResourceId
, entry
->file_id());
1226 EXPECT_EQ("new title", entry
->title());
1227 EXPECT_TRUE(HasParent(kResourceId
, "fake_root"));
1228 // Should be incremented as a new hosted document was created.
1229 EXPECT_EQ(old_largest_change_id
+ 1,
1230 fake_service_
.about_resource().largest_change_id());
1231 EXPECT_EQ(old_largest_change_id
+ 1, GetLargestChangeByAboutResource());
1234 TEST_F(FakeDriveServiceTest
, UpdateResource_Offline
) {
1235 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
1236 fake_service_
.set_offline(true);
1238 const std::string kResourceId
= "2_file_resource_id";
1239 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
1240 scoped_ptr
<FileResource
> entry
;
1241 fake_service_
.UpdateResource(
1242 kResourceId
, std::string(), "new title", base::Time(), base::Time(),
1243 google_apis::drive::Properties(),
1244 test_util::CreateCopyResultCallback(&error
, &entry
));
1245 base::RunLoop().RunUntilIdle();
1247 EXPECT_EQ(DRIVE_NO_CONNECTION
, error
);
1248 EXPECT_FALSE(entry
);
1251 TEST_F(FakeDriveServiceTest
, UpdateResource_Forbidden
) {
1252 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
1254 const std::string kResourceId
= "2_file_resource_id";
1255 EXPECT_EQ(HTTP_SUCCESS
, fake_service_
.SetUserPermission(
1256 kResourceId
, google_apis::drive::PERMISSION_ROLE_READER
));
1258 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
1259 scoped_ptr
<FileResource
> entry
;
1260 fake_service_
.UpdateResource(
1261 kResourceId
, std::string(), "new title", base::Time(), base::Time(),
1262 google_apis::drive::Properties(),
1263 test_util::CreateCopyResultCallback(&error
, &entry
));
1264 base::RunLoop().RunUntilIdle();
1266 EXPECT_EQ(HTTP_FORBIDDEN
, error
);
1267 EXPECT_FALSE(entry
);
1270 TEST_F(FakeDriveServiceTest
, AddResourceToDirectory_FileInRootDirectory
) {
1271 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
1273 int64 old_largest_change_id
= GetLargestChangeByAboutResource();
1275 const std::string kResourceId
= "2_file_resource_id";
1276 const std::string kOldParentResourceId
= fake_service_
.GetRootResourceId();
1277 const std::string kNewParentResourceId
= "1_folder_resource_id";
1279 // Here's the original parent link.
1280 EXPECT_TRUE(HasParent(kResourceId
, kOldParentResourceId
));
1281 EXPECT_FALSE(HasParent(kResourceId
, kNewParentResourceId
));
1283 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
1284 fake_service_
.AddResourceToDirectory(
1285 kNewParentResourceId
,
1287 test_util::CreateCopyResultCallback(&error
));
1288 base::RunLoop().RunUntilIdle();
1290 EXPECT_EQ(HTTP_SUCCESS
, error
);
1292 // The parent link should now be changed.
1293 EXPECT_TRUE(HasParent(kResourceId
, kOldParentResourceId
));
1294 EXPECT_TRUE(HasParent(kResourceId
, kNewParentResourceId
));
1295 // Should be incremented as a file was moved.
1296 EXPECT_EQ(old_largest_change_id
+ 1,
1297 fake_service_
.about_resource().largest_change_id());
1298 EXPECT_EQ(old_largest_change_id
+ 1, GetLargestChangeByAboutResource());
1301 TEST_F(FakeDriveServiceTest
, AddResourceToDirectory_FileInNonRootDirectory
) {
1302 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
1304 int64 old_largest_change_id
= GetLargestChangeByAboutResource();
1306 const std::string kResourceId
= "subdirectory_file_1_id";
1307 const std::string kOldParentResourceId
= "1_folder_resource_id";
1308 const std::string kNewParentResourceId
= "2_folder_resource_id";
1310 // Here's the original parent link.
1311 EXPECT_TRUE(HasParent(kResourceId
, kOldParentResourceId
));
1312 EXPECT_FALSE(HasParent(kResourceId
, kNewParentResourceId
));
1314 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
1315 fake_service_
.AddResourceToDirectory(
1316 kNewParentResourceId
,
1318 test_util::CreateCopyResultCallback(&error
));
1319 base::RunLoop().RunUntilIdle();
1321 EXPECT_EQ(HTTP_SUCCESS
, error
);
1323 // The parent link should now be changed.
1324 EXPECT_TRUE(HasParent(kResourceId
, kOldParentResourceId
));
1325 EXPECT_TRUE(HasParent(kResourceId
, kNewParentResourceId
));
1326 // Should be incremented as a file was moved.
1327 EXPECT_EQ(old_largest_change_id
+ 1,
1328 fake_service_
.about_resource().largest_change_id());
1329 EXPECT_EQ(old_largest_change_id
+ 1, GetLargestChangeByAboutResource());
1332 TEST_F(FakeDriveServiceTest
, AddResourceToDirectory_NonexistingFile
) {
1333 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
1335 const std::string kResourceId
= "nonexisting_file";
1336 const std::string kNewParentResourceId
= "1_folder_resource_id";
1338 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
1339 fake_service_
.AddResourceToDirectory(
1340 kNewParentResourceId
,
1342 test_util::CreateCopyResultCallback(&error
));
1343 base::RunLoop().RunUntilIdle();
1345 EXPECT_EQ(HTTP_NOT_FOUND
, error
);
1348 TEST_F(FakeDriveServiceTest
, AddResourceToDirectory_OrphanFile
) {
1349 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
1351 int64 old_largest_change_id
= GetLargestChangeByAboutResource();
1353 const std::string kResourceId
= "1_orphanfile_resource_id";
1354 const std::string kNewParentResourceId
= "1_folder_resource_id";
1356 // The file does not belong to any directory, even to the root.
1357 EXPECT_FALSE(HasParent(kResourceId
, kNewParentResourceId
));
1358 EXPECT_FALSE(HasParent(kResourceId
, fake_service_
.GetRootResourceId()));
1360 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
1361 fake_service_
.AddResourceToDirectory(
1362 kNewParentResourceId
,
1364 test_util::CreateCopyResultCallback(&error
));
1365 base::RunLoop().RunUntilIdle();
1367 EXPECT_EQ(HTTP_SUCCESS
, error
);
1369 // The parent link should now be changed.
1370 EXPECT_TRUE(HasParent(kResourceId
, kNewParentResourceId
));
1371 EXPECT_FALSE(HasParent(kResourceId
, fake_service_
.GetRootResourceId()));
1372 // Should be incremented as a file was moved.
1373 EXPECT_EQ(old_largest_change_id
+ 1,
1374 fake_service_
.about_resource().largest_change_id());
1375 EXPECT_EQ(old_largest_change_id
+ 1, GetLargestChangeByAboutResource());
1378 TEST_F(FakeDriveServiceTest
, AddResourceToDirectory_Offline
) {
1379 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
1380 fake_service_
.set_offline(true);
1382 const std::string kResourceId
= "2_file_resource_id";
1383 const std::string kNewParentResourceId
= "1_folder_resource_id";
1385 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
1386 fake_service_
.AddResourceToDirectory(
1387 kNewParentResourceId
,
1389 test_util::CreateCopyResultCallback(&error
));
1390 base::RunLoop().RunUntilIdle();
1392 EXPECT_EQ(DRIVE_NO_CONNECTION
, error
);
1395 TEST_F(FakeDriveServiceTest
, RemoveResourceFromDirectory_ExistingFile
) {
1396 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
1398 int64 old_largest_change_id
= GetLargestChangeByAboutResource();
1400 const std::string kResourceId
= "subdirectory_file_1_id";
1401 const std::string kParentResourceId
= "1_folder_resource_id";
1403 scoped_ptr
<FileResource
> entry
= FindEntry(kResourceId
);
1405 // The entry should have a parent now.
1406 ASSERT_FALSE(entry
->parents().empty());
1408 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
1409 fake_service_
.RemoveResourceFromDirectory(
1412 test_util::CreateCopyResultCallback(&error
));
1413 base::RunLoop().RunUntilIdle();
1415 EXPECT_EQ(HTTP_NO_CONTENT
, error
);
1417 entry
= FindEntry(kResourceId
);
1419 // The entry should have no parent now.
1420 ASSERT_TRUE(entry
->parents().empty());
1421 // Should be incremented as a file was moved to the root directory.
1422 EXPECT_EQ(old_largest_change_id
+ 1,
1423 fake_service_
.about_resource().largest_change_id());
1424 EXPECT_EQ(old_largest_change_id
+ 1, GetLargestChangeByAboutResource());
1427 TEST_F(FakeDriveServiceTest
, RemoveResourceFromDirectory_NonexistingFile
) {
1428 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
1430 const std::string kResourceId
= "nonexisting_file";
1431 const std::string kParentResourceId
= "1_folder_resource_id";
1433 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
1434 fake_service_
.RemoveResourceFromDirectory(
1437 test_util::CreateCopyResultCallback(&error
));
1438 base::RunLoop().RunUntilIdle();
1440 EXPECT_EQ(HTTP_NOT_FOUND
, error
);
1443 TEST_F(FakeDriveServiceTest
, RemoveResourceFromDirectory_OrphanFile
) {
1444 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
1446 const std::string kResourceId
= "1_orphanfile_resource_id";
1447 const std::string kParentResourceId
= fake_service_
.GetRootResourceId();
1449 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
1450 fake_service_
.RemoveResourceFromDirectory(
1453 test_util::CreateCopyResultCallback(&error
));
1454 base::RunLoop().RunUntilIdle();
1456 EXPECT_EQ(HTTP_NOT_FOUND
, error
);
1459 TEST_F(FakeDriveServiceTest
, RemoveResourceFromDirectory_Offline
) {
1460 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
1461 fake_service_
.set_offline(true);
1463 const std::string kResourceId
= "subdirectory_file_1_id";
1464 const std::string kParentResourceId
= "1_folder_resource_id";
1466 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
1467 fake_service_
.RemoveResourceFromDirectory(
1470 test_util::CreateCopyResultCallback(&error
));
1471 base::RunLoop().RunUntilIdle();
1473 EXPECT_EQ(DRIVE_NO_CONNECTION
, error
);
1476 TEST_F(FakeDriveServiceTest
, AddNewDirectory_EmptyParent
) {
1477 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
1479 int64 old_largest_change_id
= GetLargestChangeByAboutResource();
1481 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
1482 scoped_ptr
<FileResource
> entry
;
1483 fake_service_
.AddNewDirectory(
1486 DriveServiceInterface::AddNewDirectoryOptions(),
1487 test_util::CreateCopyResultCallback(&error
, &entry
));
1488 base::RunLoop().RunUntilIdle();
1490 EXPECT_EQ(HTTP_CREATED
, error
);
1492 EXPECT_TRUE(entry
->IsDirectory());
1493 EXPECT_EQ("resource_id_1", entry
->file_id());
1494 EXPECT_EQ("new directory", entry
->title());
1495 EXPECT_TRUE(HasParent(entry
->file_id(), fake_service_
.GetRootResourceId()));
1496 // Should be incremented as a new directory was created.
1497 EXPECT_EQ(old_largest_change_id
+ 1,
1498 fake_service_
.about_resource().largest_change_id());
1499 EXPECT_EQ(old_largest_change_id
+ 1, GetLargestChangeByAboutResource());
1502 TEST_F(FakeDriveServiceTest
, AddNewDirectory_ToRootDirectory
) {
1503 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
1505 int64 old_largest_change_id
= GetLargestChangeByAboutResource();
1507 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
1508 scoped_ptr
<FileResource
> entry
;
1509 fake_service_
.AddNewDirectory(
1510 fake_service_
.GetRootResourceId(),
1512 DriveServiceInterface::AddNewDirectoryOptions(),
1513 test_util::CreateCopyResultCallback(&error
, &entry
));
1514 base::RunLoop().RunUntilIdle();
1516 EXPECT_EQ(HTTP_CREATED
, error
);
1518 EXPECT_TRUE(entry
->IsDirectory());
1519 EXPECT_EQ("resource_id_1", entry
->file_id());
1520 EXPECT_EQ("new directory", entry
->title());
1521 EXPECT_TRUE(HasParent(entry
->file_id(), fake_service_
.GetRootResourceId()));
1522 // Should be incremented as a new directory was created.
1523 EXPECT_EQ(old_largest_change_id
+ 1,
1524 fake_service_
.about_resource().largest_change_id());
1525 EXPECT_EQ(old_largest_change_id
+ 1, GetLargestChangeByAboutResource());
1528 TEST_F(FakeDriveServiceTest
, AddNewDirectory_ToRootDirectoryOnEmptyFileSystem
) {
1529 int64 old_largest_change_id
= GetLargestChangeByAboutResource();
1531 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
1532 scoped_ptr
<FileResource
> entry
;
1533 fake_service_
.AddNewDirectory(
1534 fake_service_
.GetRootResourceId(),
1536 DriveServiceInterface::AddNewDirectoryOptions(),
1537 test_util::CreateCopyResultCallback(&error
, &entry
));
1538 base::RunLoop().RunUntilIdle();
1540 EXPECT_EQ(HTTP_CREATED
, error
);
1542 EXPECT_TRUE(entry
->IsDirectory());
1543 EXPECT_EQ("resource_id_1", entry
->file_id());
1544 EXPECT_EQ("new directory", entry
->title());
1545 EXPECT_TRUE(HasParent(entry
->file_id(), fake_service_
.GetRootResourceId()));
1546 // Should be incremented as a new directory was created.
1547 EXPECT_EQ(old_largest_change_id
+ 1,
1548 fake_service_
.about_resource().largest_change_id());
1549 EXPECT_EQ(old_largest_change_id
+ 1, GetLargestChangeByAboutResource());
1552 TEST_F(FakeDriveServiceTest
, AddNewDirectory_ToNonRootDirectory
) {
1553 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
1555 int64 old_largest_change_id
= GetLargestChangeByAboutResource();
1557 const std::string kParentResourceId
= "1_folder_resource_id";
1559 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
1560 scoped_ptr
<FileResource
> entry
;
1561 fake_service_
.AddNewDirectory(
1564 DriveServiceInterface::AddNewDirectoryOptions(),
1565 test_util::CreateCopyResultCallback(&error
, &entry
));
1566 base::RunLoop().RunUntilIdle();
1568 EXPECT_EQ(HTTP_CREATED
, error
);
1570 EXPECT_TRUE(entry
->IsDirectory());
1571 EXPECT_EQ("resource_id_1", entry
->file_id());
1572 EXPECT_EQ("new directory", entry
->title());
1573 EXPECT_TRUE(HasParent(entry
->file_id(), kParentResourceId
));
1574 // Should be incremented as a new directory was created.
1575 EXPECT_EQ(old_largest_change_id
+ 1,
1576 fake_service_
.about_resource().largest_change_id());
1577 EXPECT_EQ(old_largest_change_id
+ 1, GetLargestChangeByAboutResource());
1580 TEST_F(FakeDriveServiceTest
, AddNewDirectory_ToNonexistingDirectory
) {
1581 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
1583 const std::string kParentResourceId
= "nonexisting_resource_id";
1585 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
1586 scoped_ptr
<FileResource
> entry
;
1587 fake_service_
.AddNewDirectory(
1590 DriveServiceInterface::AddNewDirectoryOptions(),
1591 test_util::CreateCopyResultCallback(&error
, &entry
));
1592 base::RunLoop().RunUntilIdle();
1594 EXPECT_EQ(HTTP_NOT_FOUND
, error
);
1595 EXPECT_FALSE(entry
);
1598 TEST_F(FakeDriveServiceTest
, AddNewDirectory_Offline
) {
1599 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
1600 fake_service_
.set_offline(true);
1602 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
1603 scoped_ptr
<FileResource
> entry
;
1604 fake_service_
.AddNewDirectory(
1605 fake_service_
.GetRootResourceId(),
1607 DriveServiceInterface::AddNewDirectoryOptions(),
1608 test_util::CreateCopyResultCallback(&error
, &entry
));
1609 base::RunLoop().RunUntilIdle();
1611 EXPECT_EQ(DRIVE_NO_CONNECTION
, error
);
1612 EXPECT_FALSE(entry
);
1615 TEST_F(FakeDriveServiceTest
, InitiateUploadNewFile_Offline
) {
1616 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
1617 fake_service_
.set_offline(true);
1619 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
1620 GURL upload_location
;
1621 fake_service_
.InitiateUploadNewFile(
1622 "test/foo", 13, "1_folder_resource_id", "new file.foo",
1623 FakeDriveService::UploadNewFileOptions(),
1624 test_util::CreateCopyResultCallback(&error
, &upload_location
));
1625 base::RunLoop().RunUntilIdle();
1627 EXPECT_EQ(DRIVE_NO_CONNECTION
, error
);
1628 EXPECT_TRUE(upload_location
.is_empty());
1631 TEST_F(FakeDriveServiceTest
, InitiateUploadNewFile_NotFound
) {
1632 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
1634 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
1635 GURL upload_location
;
1636 fake_service_
.InitiateUploadNewFile(
1637 "test/foo", 13, "non_existent", "new file.foo",
1638 FakeDriveService::UploadNewFileOptions(),
1639 test_util::CreateCopyResultCallback(&error
, &upload_location
));
1640 base::RunLoop().RunUntilIdle();
1642 EXPECT_EQ(HTTP_NOT_FOUND
, error
);
1643 EXPECT_TRUE(upload_location
.is_empty());
1646 TEST_F(FakeDriveServiceTest
, InitiateUploadNewFile
) {
1647 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
1649 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
1650 GURL upload_location
;
1651 fake_service_
.InitiateUploadNewFile(
1652 "test/foo", 13, "1_folder_resource_id", "new file.foo",
1653 FakeDriveService::UploadNewFileOptions(),
1654 test_util::CreateCopyResultCallback(&error
, &upload_location
));
1655 base::RunLoop().RunUntilIdle();
1657 EXPECT_EQ(HTTP_SUCCESS
, error
);
1658 EXPECT_FALSE(upload_location
.is_empty());
1659 EXPECT_NE(GURL("https://1_folder_resumable_create_media_link?mode=newfile"),
1663 TEST_F(FakeDriveServiceTest
, InitiateUploadExistingFile_Offline
) {
1664 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
1665 fake_service_
.set_offline(true);
1667 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
1668 GURL upload_location
;
1669 fake_service_
.InitiateUploadExistingFile(
1670 "test/foo", 13, "2_file_resource_id",
1671 FakeDriveService::UploadExistingFileOptions(),
1672 test_util::CreateCopyResultCallback(&error
, &upload_location
));
1673 base::RunLoop().RunUntilIdle();
1675 EXPECT_EQ(DRIVE_NO_CONNECTION
, error
);
1676 EXPECT_TRUE(upload_location
.is_empty());
1679 TEST_F(FakeDriveServiceTest
, InitiateUploadExistingFile_Forbidden
) {
1680 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
1682 EXPECT_EQ(HTTP_SUCCESS
, fake_service_
.SetUserPermission(
1683 "2_file_resource_id", google_apis::drive::PERMISSION_ROLE_READER
));
1685 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
1686 GURL upload_location
;
1687 fake_service_
.InitiateUploadExistingFile(
1688 "test/foo", 13, "2_file_resource_id",
1689 FakeDriveService::UploadExistingFileOptions(),
1690 test_util::CreateCopyResultCallback(&error
, &upload_location
));
1691 base::RunLoop().RunUntilIdle();
1693 EXPECT_EQ(HTTP_FORBIDDEN
, error
);
1694 EXPECT_TRUE(upload_location
.is_empty());
1697 TEST_F(FakeDriveServiceTest
, InitiateUploadExistingFile_NotFound
) {
1698 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
1700 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
1701 GURL upload_location
;
1702 fake_service_
.InitiateUploadExistingFile(
1703 "test/foo", 13, "non_existent",
1704 FakeDriveService::UploadExistingFileOptions(),
1705 test_util::CreateCopyResultCallback(&error
, &upload_location
));
1706 base::RunLoop().RunUntilIdle();
1708 EXPECT_EQ(HTTP_NOT_FOUND
, error
);
1709 EXPECT_TRUE(upload_location
.is_empty());
1712 TEST_F(FakeDriveServiceTest
, InitiateUploadExistingFile_WrongETag
) {
1713 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
1715 FakeDriveService::UploadExistingFileOptions options
;
1716 options
.etag
= "invalid_etag";
1718 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
1719 GURL upload_location
;
1720 fake_service_
.InitiateUploadExistingFile(
1723 "2_file_resource_id",
1725 test_util::CreateCopyResultCallback(&error
, &upload_location
));
1726 base::RunLoop().RunUntilIdle();
1728 EXPECT_EQ(HTTP_PRECONDITION
, error
);
1729 EXPECT_TRUE(upload_location
.is_empty());
1732 TEST_F(FakeDriveServiceTest
, InitiateUpload_ExistingFile
) {
1733 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
1735 scoped_ptr
<FileResource
> entry
= FindEntry("2_file_resource_id");
1738 FakeDriveService::UploadExistingFileOptions options
;
1739 options
.etag
= entry
->etag();
1741 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
1742 GURL upload_location
;
1743 fake_service_
.InitiateUploadExistingFile(
1746 "2_file_resource_id",
1748 test_util::CreateCopyResultCallback(&error
, &upload_location
));
1749 base::RunLoop().RunUntilIdle();
1751 EXPECT_EQ(HTTP_SUCCESS
, error
);
1752 EXPECT_TRUE(upload_location
.is_valid());
1755 TEST_F(FakeDriveServiceTest
, ResumeUpload_Offline
) {
1756 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
1758 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
1759 GURL upload_location
;
1760 fake_service_
.InitiateUploadNewFile(
1761 "test/foo", 15, "1_folder_resource_id", "new file.foo",
1762 FakeDriveService::UploadNewFileOptions(),
1763 test_util::CreateCopyResultCallback(&error
, &upload_location
));
1764 base::RunLoop().RunUntilIdle();
1766 EXPECT_EQ(HTTP_SUCCESS
, error
);
1767 EXPECT_FALSE(upload_location
.is_empty());
1768 EXPECT_NE(GURL("https://1_folder_resumable_create_media_link"),
1771 fake_service_
.set_offline(true);
1773 UploadRangeResponse response
;
1774 scoped_ptr
<FileResource
> entry
;
1775 fake_service_
.ResumeUpload(
1777 0, 13, 15, "test/foo",
1779 test_util::CreateCopyResultCallback(&response
, &entry
),
1780 ProgressCallback());
1781 base::RunLoop().RunUntilIdle();
1783 EXPECT_EQ(DRIVE_NO_CONNECTION
, response
.code
);
1784 EXPECT_FALSE(entry
.get());
1787 TEST_F(FakeDriveServiceTest
, ResumeUpload_NotFound
) {
1788 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
1790 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
1791 GURL upload_location
;
1792 fake_service_
.InitiateUploadNewFile(
1793 "test/foo", 15, "1_folder_resource_id", "new file.foo",
1794 FakeDriveService::UploadNewFileOptions(),
1795 test_util::CreateCopyResultCallback(&error
, &upload_location
));
1796 base::RunLoop().RunUntilIdle();
1798 ASSERT_EQ(HTTP_SUCCESS
, error
);
1800 UploadRangeResponse response
;
1801 scoped_ptr
<FileResource
> entry
;
1802 fake_service_
.ResumeUpload(
1803 GURL("https://foo.com/"),
1804 0, 13, 15, "test/foo",
1806 test_util::CreateCopyResultCallback(&response
, &entry
),
1807 ProgressCallback());
1808 base::RunLoop().RunUntilIdle();
1810 EXPECT_EQ(HTTP_NOT_FOUND
, response
.code
);
1811 EXPECT_FALSE(entry
.get());
1814 TEST_F(FakeDriveServiceTest
, ResumeUpload_ExistingFile
) {
1815 base::ScopedTempDir temp_dir
;
1816 ASSERT_TRUE(temp_dir
.CreateUniqueTempDir());
1817 base::FilePath local_file_path
=
1818 temp_dir
.path().Append(FILE_PATH_LITERAL("File 1.txt"));
1819 std::string
contents("hogefugapiyo");
1820 ASSERT_TRUE(test_util::WriteStringToFile(local_file_path
, contents
));
1822 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
1824 scoped_ptr
<FileResource
> entry
= FindEntry("2_file_resource_id");
1827 FakeDriveService::UploadExistingFileOptions options
;
1828 options
.etag
= entry
->etag();
1830 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
1831 GURL upload_location
;
1832 fake_service_
.InitiateUploadExistingFile(
1835 "2_file_resource_id",
1837 test_util::CreateCopyResultCallback(&error
, &upload_location
));
1838 base::RunLoop().RunUntilIdle();
1840 ASSERT_EQ(HTTP_SUCCESS
, error
);
1842 UploadRangeResponse response
;
1844 std::vector
<test_util::ProgressInfo
> upload_progress_values
;
1845 fake_service_
.ResumeUpload(
1847 0, contents
.size() / 2, contents
.size(), "text/plain",
1849 test_util::CreateCopyResultCallback(&response
, &entry
),
1850 base::Bind(&test_util::AppendProgressCallbackResult
,
1851 &upload_progress_values
));
1852 base::RunLoop().RunUntilIdle();
1854 EXPECT_EQ(HTTP_RESUME_INCOMPLETE
, response
.code
);
1855 EXPECT_FALSE(entry
.get());
1856 ASSERT_TRUE(!upload_progress_values
.empty());
1857 EXPECT_TRUE(base::STLIsSorted(upload_progress_values
));
1858 EXPECT_LE(0, upload_progress_values
.front().first
);
1859 EXPECT_GE(static_cast<int64
>(contents
.size() / 2),
1860 upload_progress_values
.back().first
);
1862 upload_progress_values
.clear();
1863 fake_service_
.ResumeUpload(
1865 contents
.size() / 2, contents
.size(), contents
.size(), "text/plain",
1867 test_util::CreateCopyResultCallback(&response
, &entry
),
1868 base::Bind(&test_util::AppendProgressCallbackResult
,
1869 &upload_progress_values
));
1870 base::RunLoop().RunUntilIdle();
1872 EXPECT_EQ(HTTP_SUCCESS
, response
.code
);
1873 EXPECT_TRUE(entry
.get());
1874 EXPECT_EQ(static_cast<int64
>(contents
.size()), entry
->file_size());
1875 EXPECT_TRUE(Exists(entry
->file_id()));
1876 ASSERT_TRUE(!upload_progress_values
.empty());
1877 EXPECT_TRUE(base::STLIsSorted(upload_progress_values
));
1878 EXPECT_LE(0, upload_progress_values
.front().first
);
1879 EXPECT_GE(static_cast<int64
>(contents
.size() - contents
.size() / 2),
1880 upload_progress_values
.back().first
);
1881 EXPECT_EQ(base::MD5String(contents
), entry
->md5_checksum());
1884 TEST_F(FakeDriveServiceTest
, ResumeUpload_NewFile
) {
1885 base::ScopedTempDir temp_dir
;
1886 ASSERT_TRUE(temp_dir
.CreateUniqueTempDir());
1887 base::FilePath local_file_path
=
1888 temp_dir
.path().Append(FILE_PATH_LITERAL("new file.foo"));
1889 std::string
contents("hogefugapiyo");
1890 ASSERT_TRUE(test_util::WriteStringToFile(local_file_path
, contents
));
1892 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
1894 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
1895 GURL upload_location
;
1896 fake_service_
.InitiateUploadNewFile(
1897 "test/foo", contents
.size(), "1_folder_resource_id", "new file.foo",
1898 FakeDriveService::UploadNewFileOptions(),
1899 test_util::CreateCopyResultCallback(&error
, &upload_location
));
1900 base::RunLoop().RunUntilIdle();
1902 EXPECT_EQ(HTTP_SUCCESS
, error
);
1903 EXPECT_FALSE(upload_location
.is_empty());
1904 EXPECT_NE(GURL("https://1_folder_resumable_create_media_link"),
1907 UploadRangeResponse response
;
1908 scoped_ptr
<FileResource
> entry
;
1909 std::vector
<test_util::ProgressInfo
> upload_progress_values
;
1910 fake_service_
.ResumeUpload(
1912 0, contents
.size() / 2, contents
.size(), "test/foo",
1914 test_util::CreateCopyResultCallback(&response
, &entry
),
1915 base::Bind(&test_util::AppendProgressCallbackResult
,
1916 &upload_progress_values
));
1917 base::RunLoop().RunUntilIdle();
1919 EXPECT_EQ(HTTP_RESUME_INCOMPLETE
, response
.code
);
1920 EXPECT_FALSE(entry
.get());
1921 ASSERT_TRUE(!upload_progress_values
.empty());
1922 EXPECT_TRUE(base::STLIsSorted(upload_progress_values
));
1923 EXPECT_LE(0, upload_progress_values
.front().first
);
1924 EXPECT_GE(static_cast<int64
>(contents
.size() / 2),
1925 upload_progress_values
.back().first
);
1927 upload_progress_values
.clear();
1928 fake_service_
.ResumeUpload(
1930 contents
.size() / 2, contents
.size(), contents
.size(), "test/foo",
1932 test_util::CreateCopyResultCallback(&response
, &entry
),
1933 base::Bind(&test_util::AppendProgressCallbackResult
,
1934 &upload_progress_values
));
1935 base::RunLoop().RunUntilIdle();
1937 EXPECT_EQ(HTTP_CREATED
, response
.code
);
1938 EXPECT_TRUE(entry
.get());
1939 EXPECT_EQ(static_cast<int64
>(contents
.size()), entry
->file_size());
1940 EXPECT_TRUE(Exists(entry
->file_id()));
1941 ASSERT_TRUE(!upload_progress_values
.empty());
1942 EXPECT_TRUE(base::STLIsSorted(upload_progress_values
));
1943 EXPECT_LE(0, upload_progress_values
.front().first
);
1944 EXPECT_GE(static_cast<int64
>(contents
.size() - contents
.size() / 2),
1945 upload_progress_values
.back().first
);
1946 EXPECT_EQ(base::MD5String(contents
), entry
->md5_checksum());
1949 TEST_F(FakeDriveServiceTest
, AddNewFile_ToRootDirectory
) {
1950 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
1952 int64 old_largest_change_id
= GetLargestChangeByAboutResource();
1954 const std::string kContentType
= "text/plain";
1955 const std::string kContentData
= "This is some test content.";
1956 const std::string kTitle
= "new file";
1958 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
1959 scoped_ptr
<FileResource
> entry
;
1960 fake_service_
.AddNewFile(
1963 fake_service_
.GetRootResourceId(),
1965 false, // shared_with_me
1966 test_util::CreateCopyResultCallback(&error
, &entry
));
1967 base::RunLoop().RunUntilIdle();
1969 EXPECT_EQ(HTTP_CREATED
, error
);
1971 EXPECT_EQ(kContentType
, entry
->mime_type());
1972 EXPECT_EQ(static_cast<int64
>(kContentData
.size()), entry
->file_size());
1973 EXPECT_EQ("resource_id_1", entry
->file_id());
1974 EXPECT_EQ(kTitle
, entry
->title());
1975 EXPECT_TRUE(HasParent(entry
->file_id(), fake_service_
.GetRootResourceId()));
1976 // Should be incremented as a new directory was created.
1977 EXPECT_EQ(old_largest_change_id
+ 1,
1978 fake_service_
.about_resource().largest_change_id());
1979 EXPECT_EQ(old_largest_change_id
+ 1, GetLargestChangeByAboutResource());
1980 EXPECT_EQ(base::MD5String(kContentData
), entry
->md5_checksum());
1983 TEST_F(FakeDriveServiceTest
, AddNewFile_ToRootDirectoryOnEmptyFileSystem
) {
1984 int64 old_largest_change_id
= GetLargestChangeByAboutResource();
1986 const std::string kContentType
= "text/plain";
1987 const std::string kContentData
= "This is some test content.";
1988 const std::string kTitle
= "new file";
1990 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
1991 scoped_ptr
<FileResource
> entry
;
1992 fake_service_
.AddNewFile(
1995 fake_service_
.GetRootResourceId(),
1997 false, // shared_with_me
1998 test_util::CreateCopyResultCallback(&error
, &entry
));
1999 base::RunLoop().RunUntilIdle();
2001 EXPECT_EQ(HTTP_CREATED
, error
);
2003 EXPECT_EQ(kContentType
, entry
->mime_type());
2004 EXPECT_EQ(static_cast<int64
>(kContentData
.size()), entry
->file_size());
2005 EXPECT_EQ("resource_id_1", entry
->file_id());
2006 EXPECT_EQ(kTitle
, entry
->title());
2007 EXPECT_TRUE(HasParent(entry
->file_id(), fake_service_
.GetRootResourceId()));
2008 // Should be incremented as a new directory was created.
2009 EXPECT_EQ(old_largest_change_id
+ 1,
2010 fake_service_
.about_resource().largest_change_id());
2011 EXPECT_EQ(old_largest_change_id
+ 1, GetLargestChangeByAboutResource());
2012 EXPECT_EQ(base::MD5String(kContentData
), entry
->md5_checksum());
2015 TEST_F(FakeDriveServiceTest
, AddNewFile_ToNonRootDirectory
) {
2016 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
2018 int64 old_largest_change_id
= GetLargestChangeByAboutResource();
2020 const std::string kContentType
= "text/plain";
2021 const std::string kContentData
= "This is some test content.";
2022 const std::string kTitle
= "new file";
2023 const std::string kParentResourceId
= "1_folder_resource_id";
2025 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
2026 scoped_ptr
<FileResource
> entry
;
2027 fake_service_
.AddNewFile(
2032 false, // shared_with_me
2033 test_util::CreateCopyResultCallback(&error
, &entry
));
2034 base::RunLoop().RunUntilIdle();
2036 EXPECT_EQ(HTTP_CREATED
, error
);
2038 EXPECT_EQ(kContentType
, entry
->mime_type());
2039 EXPECT_EQ(static_cast<int64
>(kContentData
.size()), entry
->file_size());
2040 EXPECT_EQ("resource_id_1", entry
->file_id());
2041 EXPECT_EQ(kTitle
, entry
->title());
2042 EXPECT_TRUE(HasParent(entry
->file_id(), kParentResourceId
));
2043 // Should be incremented as a new directory was created.
2044 EXPECT_EQ(old_largest_change_id
+ 1,
2045 fake_service_
.about_resource().largest_change_id());
2046 EXPECT_EQ(old_largest_change_id
+ 1, GetLargestChangeByAboutResource());
2047 EXPECT_EQ(base::MD5String(kContentData
), entry
->md5_checksum());
2050 TEST_F(FakeDriveServiceTest
, AddNewFile_ToNonexistingDirectory
) {
2051 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
2053 const std::string kContentType
= "text/plain";
2054 const std::string kContentData
= "This is some test content.";
2055 const std::string kTitle
= "new file";
2056 const std::string kParentResourceId
= "nonexisting_resource_id";
2058 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
2059 scoped_ptr
<FileResource
> entry
;
2060 fake_service_
.AddNewFile(
2065 false, // shared_with_me
2066 test_util::CreateCopyResultCallback(&error
, &entry
));
2067 base::RunLoop().RunUntilIdle();
2069 EXPECT_EQ(HTTP_NOT_FOUND
, error
);
2070 EXPECT_FALSE(entry
);
2073 TEST_F(FakeDriveServiceTest
, AddNewFile_Offline
) {
2074 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
2075 fake_service_
.set_offline(true);
2077 const std::string kContentType
= "text/plain";
2078 const std::string kContentData
= "This is some test content.";
2079 const std::string kTitle
= "new file";
2081 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
2082 scoped_ptr
<FileResource
> entry
;
2083 fake_service_
.AddNewFile(
2086 fake_service_
.GetRootResourceId(),
2088 false, // shared_with_me
2089 test_util::CreateCopyResultCallback(&error
, &entry
));
2090 base::RunLoop().RunUntilIdle();
2092 EXPECT_EQ(DRIVE_NO_CONNECTION
, error
);
2093 EXPECT_FALSE(entry
);
2096 TEST_F(FakeDriveServiceTest
, AddNewFile_SharedWithMeLabel
) {
2097 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
2099 const std::string kContentType
= "text/plain";
2100 const std::string kContentData
= "This is some test content.";
2101 const std::string kTitle
= "new file";
2103 int64 old_largest_change_id
= GetLargestChangeByAboutResource();
2105 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
2106 scoped_ptr
<FileResource
> entry
;
2107 fake_service_
.AddNewFile(
2110 fake_service_
.GetRootResourceId(),
2112 true, // shared_with_me
2113 test_util::CreateCopyResultCallback(&error
, &entry
));
2114 base::RunLoop().RunUntilIdle();
2116 EXPECT_EQ(HTTP_CREATED
, error
);
2118 EXPECT_EQ(kContentType
, entry
->mime_type());
2119 EXPECT_EQ(static_cast<int64
>(kContentData
.size()), entry
->file_size());
2120 EXPECT_EQ("resource_id_1", entry
->file_id());
2121 EXPECT_EQ(kTitle
, entry
->title());
2122 EXPECT_TRUE(HasParent(entry
->file_id(), fake_service_
.GetRootResourceId()));
2123 EXPECT_FALSE(entry
->shared_with_me_date().is_null());
2124 // Should be incremented as a new directory was created.
2125 EXPECT_EQ(old_largest_change_id
+ 1,
2126 fake_service_
.about_resource().largest_change_id());
2127 EXPECT_EQ(old_largest_change_id
+ 1, GetLargestChangeByAboutResource());
2128 EXPECT_EQ(base::MD5String(kContentData
), entry
->md5_checksum());
2131 TEST_F(FakeDriveServiceTest
, SetLastModifiedTime_ExistingFile
) {
2132 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
2134 const std::string kResourceId
= "2_file_resource_id";
2136 ASSERT_TRUE(base::Time::FromString("1 April 2013 12:34:56", &time
));
2138 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
2139 scoped_ptr
<FileResource
> entry
;
2140 fake_service_
.SetLastModifiedTime(
2143 test_util::CreateCopyResultCallback(&error
, &entry
));
2144 base::RunLoop().RunUntilIdle();
2146 EXPECT_EQ(HTTP_SUCCESS
, error
);
2148 EXPECT_EQ(time
, entry
->modified_date());
2151 TEST_F(FakeDriveServiceTest
, SetLastModifiedTime_NonexistingFile
) {
2152 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
2154 const std::string kResourceId
= "nonexisting_resource_id";
2156 ASSERT_TRUE(base::Time::FromString("1 April 2013 12:34:56", &time
));
2158 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
2159 scoped_ptr
<FileResource
> entry
;
2160 fake_service_
.SetLastModifiedTime(
2163 test_util::CreateCopyResultCallback(&error
, &entry
));
2164 base::RunLoop().RunUntilIdle();
2166 EXPECT_EQ(HTTP_NOT_FOUND
, error
);
2167 EXPECT_FALSE(entry
);
2170 TEST_F(FakeDriveServiceTest
, SetLastModifiedTime_Offline
) {
2171 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_
));
2172 fake_service_
.set_offline(true);
2174 const std::string kResourceId
= "2_file_resource_id";
2176 ASSERT_TRUE(base::Time::FromString("1 April 2013 12:34:56", &time
));
2178 DriveApiErrorCode error
= DRIVE_OTHER_ERROR
;
2179 scoped_ptr
<FileResource
> entry
;
2180 fake_service_
.SetLastModifiedTime(
2183 test_util::CreateCopyResultCallback(&error
, &entry
));
2184 base::RunLoop().RunUntilIdle();
2186 EXPECT_EQ(DRIVE_NO_CONNECTION
, error
);
2187 EXPECT_FALSE(entry
);
2192 } // namespace drive