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

Side by Side Diff: components/drive/resource_entry_conversion_unittest.cc

Issue 2799603002: Process TeamDrive change in change list. (Closed)
Patch Set: Remove unnecessary return value, as the TeamDriveResource conversion always succeeds. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/drive/resource_entry_conversion.cc ('k') | google_apis/drive/drive_api_parser.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/drive/resource_entry_conversion.h" 5 #include "components/drive/resource_entry_conversion.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "base/time/time.h" 8 #include "base/time/time.h"
9 #include "components/drive/drive.pb.h" 9 #include "components/drive/drive.pb.h"
10 #include "components/drive/drive_api_util.h" 10 #include "components/drive/drive_api_util.h"
11 #include "components/drive/file_system_core_util.h"
11 #include "google_apis/drive/drive_api_parser.h" 12 #include "google_apis/drive/drive_api_parser.h"
12 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
13 14
14 namespace drive { 15 namespace drive {
15 16
16 namespace { 17 namespace {
17 18
18 base::Time GetTestTime() { 19 base::Time GetTestTime() {
19 // 2011-12-14-T00:40:47.330Z 20 // 2011-12-14-T00:40:47.330Z
20 base::Time::Exploded exploded; 21 base::Time::Exploded exploded;
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 ResourceEntry entry; 387 ResourceEntry entry;
387 std::string parent_resource_id; 388 std::string parent_resource_id;
388 EXPECT_TRUE(ConvertFileResourceToResourceEntry( 389 EXPECT_TRUE(ConvertFileResourceToResourceEntry(
389 entry_no_fields, &entry, &parent_resource_id)); 390 entry_no_fields, &entry, &parent_resource_id));
390 EXPECT_FALSE(entry.file_specific_info().has_image_width()); 391 EXPECT_FALSE(entry.file_specific_info().has_image_width());
391 EXPECT_FALSE(entry.file_specific_info().has_image_height()); 392 EXPECT_FALSE(entry.file_specific_info().has_image_height());
392 EXPECT_FALSE(entry.file_specific_info().has_image_rotation()); 393 EXPECT_FALSE(entry.file_specific_info().has_image_rotation());
393 } 394 }
394 } 395 }
395 396
397 TEST(ResourceEntryConversionTest,
398 ConvertTeamDriveChangeResourceToResourceEntry) {
399 google_apis::ChangeResource change_resource;
400 change_resource.set_type(google_apis::ChangeResource::TEAM_DRIVE);
401 change_resource.set_team_drive(
402 base::WrapUnique(new google_apis::TeamDriveResource));
403 change_resource.set_team_drive_id("team_drive_id");
404 change_resource.set_modification_date(GetTestTime());
405 change_resource.set_deleted(false);
406
407 google_apis::TeamDriveResource* team_drive_resource =
408 change_resource.mutable_team_drive();
409 team_drive_resource->set_name("ABC Team Drive");
410 team_drive_resource->set_id("team_drive_id");
411
412 ResourceEntry entry;
413 std::string parent_resource_id;
414 EXPECT_TRUE(ConvertChangeResourceToResourceEntry(change_resource, &entry,
415 &parent_resource_id));
416
417 EXPECT_EQ(change_resource.team_drive_id(), entry.resource_id());
418 EXPECT_EQ(team_drive_resource->name(), entry.title());
419 EXPECT_EQ(team_drive_resource->name(), entry.base_name());
420 EXPECT_EQ(change_resource.modification_date().ToInternalValue(),
421 entry.modification_date());
422 EXPECT_EQ(util::kDriveTeamDrivesDirLocalId, entry.parent_local_id());
423 EXPECT_EQ("", parent_resource_id);
424 EXPECT_FALSE(entry.deleted());
425 }
426
427 TEST(ResourceEntryConversionTest,
428 ConvertTeamDriveRemovalChangeResourceToResourceEntry) {
429 google_apis::ChangeResource change_resource;
430 change_resource.set_type(google_apis::ChangeResource::TEAM_DRIVE);
431 change_resource.set_team_drive_id("team_drive_id");
432 change_resource.set_modification_date(GetTestTime());
433 change_resource.set_deleted(true);
434 // team_drive field is not filled for a deleted change resource.
435
436 ResourceEntry entry;
437 std::string parent_resource_id;
438 EXPECT_TRUE(ConvertChangeResourceToResourceEntry(change_resource, &entry,
439 &parent_resource_id));
440
441 EXPECT_EQ(change_resource.team_drive_id(), entry.resource_id());
442 EXPECT_EQ(change_resource.modification_date().ToInternalValue(),
443 entry.modification_date());
444 EXPECT_EQ(util::kDriveTeamDrivesDirLocalId, entry.parent_local_id());
445 EXPECT_EQ("", parent_resource_id);
446 EXPECT_TRUE(entry.deleted());
447 }
448
396 } // namespace drive 449 } // namespace drive
OLDNEW
« no previous file with comments | « components/drive/resource_entry_conversion.cc ('k') | google_apis/drive/drive_api_parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698