Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/service/fake_drive_service.h" | 5 #include "components/drive/service/fake_drive_service.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| (...skipping 1048 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1059 const base::Time::Exploded kModifiedDate = {2012, 7, 0, 19, 15, 59, 13, 123}; | 1059 const base::Time::Exploded kModifiedDate = {2012, 7, 0, 19, 15, 59, 13, 123}; |
| 1060 | 1060 |
| 1061 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); | 1061 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
| 1062 | 1062 |
| 1063 int64_t old_largest_change_id = GetLargestChangeByAboutResource(); | 1063 int64_t old_largest_change_id = GetLargestChangeByAboutResource(); |
| 1064 | 1064 |
| 1065 const std::string kResourceId = "2_file_resource_id"; | 1065 const std::string kResourceId = "2_file_resource_id"; |
| 1066 const std::string kParentResourceId = "2_folder_resource_id"; | 1066 const std::string kParentResourceId = "2_folder_resource_id"; |
| 1067 DriveApiErrorCode error = DRIVE_OTHER_ERROR; | 1067 DriveApiErrorCode error = DRIVE_OTHER_ERROR; |
| 1068 std::unique_ptr<FileResource> entry; | 1068 std::unique_ptr<FileResource> entry; |
| 1069 base::Time ModifiedDateUTC; | |
|
fukino
2016/07/06 11:14:23
base::Time modified_date_utc;
to follow the style
maksims (do not use this acc)
2016/07/06 12:00:20
Done.
| |
| 1070 EXPECT_TRUE(base::Time::FromUTCExploded(kModifiedDate, &ModifiedDateUTC)); | |
| 1069 fake_service_.CopyResource( | 1071 fake_service_.CopyResource( |
| 1070 kResourceId, | 1072 kResourceId, kParentResourceId, "new title", ModifiedDateUTC, |
| 1071 kParentResourceId, | |
| 1072 "new title", | |
| 1073 base::Time::FromUTCExploded(kModifiedDate), | |
| 1074 test_util::CreateCopyResultCallback(&error, &entry)); | 1073 test_util::CreateCopyResultCallback(&error, &entry)); |
| 1075 base::RunLoop().RunUntilIdle(); | 1074 base::RunLoop().RunUntilIdle(); |
| 1076 | 1075 |
| 1077 EXPECT_EQ(HTTP_SUCCESS, error); | 1076 EXPECT_EQ(HTTP_SUCCESS, error); |
| 1078 ASSERT_TRUE(entry); | 1077 ASSERT_TRUE(entry); |
| 1079 // The copied entry should have the new resource ID and the title. | 1078 // The copied entry should have the new resource ID and the title. |
| 1080 EXPECT_NE(kResourceId, entry->file_id()); | 1079 EXPECT_NE(kResourceId, entry->file_id()); |
| 1081 EXPECT_EQ("new title", entry->title()); | 1080 EXPECT_EQ("new title", entry->title()); |
| 1082 EXPECT_EQ(base::Time::FromUTCExploded(kModifiedDate), entry->modified_date()); | 1081 EXPECT_EQ(ModifiedDateUTC, entry->modified_date()); |
| 1083 EXPECT_TRUE(HasParent(entry->file_id(), kParentResourceId)); | 1082 EXPECT_TRUE(HasParent(entry->file_id(), kParentResourceId)); |
| 1084 // Should be incremented as a new hosted document was created. | 1083 // Should be incremented as a new hosted document was created. |
| 1085 EXPECT_EQ(old_largest_change_id + 1, | 1084 EXPECT_EQ(old_largest_change_id + 1, |
| 1086 fake_service_.about_resource().largest_change_id()); | 1085 fake_service_.about_resource().largest_change_id()); |
| 1087 EXPECT_EQ(old_largest_change_id + 1, GetLargestChangeByAboutResource()); | 1086 EXPECT_EQ(old_largest_change_id + 1, GetLargestChangeByAboutResource()); |
| 1088 } | 1087 } |
| 1089 | 1088 |
| 1090 TEST_F(FakeDriveServiceTest, CopyResource_NonExisting) { | 1089 TEST_F(FakeDriveServiceTest, CopyResource_NonExisting) { |
| 1091 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); | 1090 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
| 1092 | 1091 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1156 const base::Time::Exploded kViewedDate = {2013, 8, 1, 20, 16, 00, 14, 234}; | 1155 const base::Time::Exploded kViewedDate = {2013, 8, 1, 20, 16, 00, 14, 234}; |
| 1157 | 1156 |
| 1158 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); | 1157 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
| 1159 | 1158 |
| 1160 int64_t old_largest_change_id = GetLargestChangeByAboutResource(); | 1159 int64_t old_largest_change_id = GetLargestChangeByAboutResource(); |
| 1161 | 1160 |
| 1162 const std::string kResourceId = "2_file_resource_id"; | 1161 const std::string kResourceId = "2_file_resource_id"; |
| 1163 const std::string kParentResourceId = "2_folder_resource_id"; | 1162 const std::string kParentResourceId = "2_folder_resource_id"; |
| 1164 DriveApiErrorCode error = DRIVE_OTHER_ERROR; | 1163 DriveApiErrorCode error = DRIVE_OTHER_ERROR; |
| 1165 std::unique_ptr<FileResource> entry; | 1164 std::unique_ptr<FileResource> entry; |
| 1165 base::Time ModifiedDateUTC; | |
|
fukino
2016/07/06 11:14:23
ditto
maksims (do not use this acc)
2016/07/06 12:00:20
Done.
| |
| 1166 base::Time ViewedDateUTC; | |
|
fukino
2016/07/06 11:14:23
ditto
maksims (do not use this acc)
2016/07/06 12:00:20
Done.
| |
| 1167 EXPECT_TRUE(base::Time::FromUTCExploded(kModifiedDate, &ModifiedDateUTC)); | |
| 1168 EXPECT_TRUE(base::Time::FromUTCExploded(kViewedDate, &ViewedDateUTC)); | |
| 1169 | |
| 1166 fake_service_.UpdateResource( | 1170 fake_service_.UpdateResource( |
| 1167 kResourceId, kParentResourceId, "new title", | 1171 kResourceId, kParentResourceId, "new title", ModifiedDateUTC, |
| 1168 base::Time::FromUTCExploded(kModifiedDate), | 1172 ViewedDateUTC, google_apis::drive::Properties(), |
| 1169 base::Time::FromUTCExploded(kViewedDate), | |
| 1170 google_apis::drive::Properties(), | |
| 1171 test_util::CreateCopyResultCallback(&error, &entry)); | 1173 test_util::CreateCopyResultCallback(&error, &entry)); |
| 1172 base::RunLoop().RunUntilIdle(); | 1174 base::RunLoop().RunUntilIdle(); |
| 1173 | 1175 |
| 1174 EXPECT_EQ(HTTP_SUCCESS, error); | 1176 EXPECT_EQ(HTTP_SUCCESS, error); |
| 1175 ASSERT_TRUE(entry); | 1177 ASSERT_TRUE(entry); |
| 1176 // The updated entry should have the new title. | 1178 // The updated entry should have the new title. |
| 1177 EXPECT_EQ(kResourceId, entry->file_id()); | 1179 EXPECT_EQ(kResourceId, entry->file_id()); |
| 1178 EXPECT_EQ("new title", entry->title()); | 1180 EXPECT_EQ("new title", entry->title()); |
| 1179 EXPECT_EQ(base::Time::FromUTCExploded(kModifiedDate), | 1181 EXPECT_EQ(ModifiedDateUTC, entry->modified_date()); |
| 1180 entry->modified_date()); | 1182 EXPECT_EQ(ViewedDateUTC, entry->last_viewed_by_me_date()); |
| 1181 EXPECT_EQ(base::Time::FromUTCExploded(kViewedDate), | |
| 1182 entry->last_viewed_by_me_date()); | |
| 1183 EXPECT_TRUE(HasParent(kResourceId, kParentResourceId)); | 1183 EXPECT_TRUE(HasParent(kResourceId, kParentResourceId)); |
| 1184 // Should be incremented as a new hosted document was created. | 1184 // Should be incremented as a new hosted document was created. |
| 1185 EXPECT_EQ(old_largest_change_id + 1, | 1185 EXPECT_EQ(old_largest_change_id + 1, |
| 1186 fake_service_.about_resource().largest_change_id()); | 1186 fake_service_.about_resource().largest_change_id()); |
| 1187 EXPECT_EQ(old_largest_change_id + 1, GetLargestChangeByAboutResource()); | 1187 EXPECT_EQ(old_largest_change_id + 1, GetLargestChangeByAboutResource()); |
| 1188 } | 1188 } |
| 1189 | 1189 |
| 1190 TEST_F(FakeDriveServiceTest, UpdateResource_NonExisting) { | 1190 TEST_F(FakeDriveServiceTest, UpdateResource_NonExisting) { |
| 1191 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); | 1191 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
| 1192 | 1192 |
| (...skipping 978 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2171 test_util::CreateCopyResultCallback(&error, &entry)); | 2171 test_util::CreateCopyResultCallback(&error, &entry)); |
| 2172 base::RunLoop().RunUntilIdle(); | 2172 base::RunLoop().RunUntilIdle(); |
| 2173 | 2173 |
| 2174 EXPECT_EQ(DRIVE_NO_CONNECTION, error); | 2174 EXPECT_EQ(DRIVE_NO_CONNECTION, error); |
| 2175 EXPECT_FALSE(entry); | 2175 EXPECT_FALSE(entry); |
| 2176 } | 2176 } |
| 2177 | 2177 |
| 2178 } // namespace | 2178 } // namespace |
| 2179 | 2179 |
| 2180 } // namespace drive | 2180 } // namespace drive |
| OLD | NEW |