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

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

Issue 2748053005: Parse TeamDrive resource inside ChangeList. (Closed)
Patch Set: Default the type field to UNKNOWN as it's not causing new test failures. Created 3 years, 9 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
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"
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 EXPECT_TRUE(entry.file_specific_info().is_hosted_document()); 212 EXPECT_TRUE(entry.file_specific_info().is_hosted_document());
213 EXPECT_EQ(file_resource.alternate_link().spec(), 213 EXPECT_EQ(file_resource.alternate_link().spec(),
214 entry.file_specific_info().alternate_url()); 214 entry.file_specific_info().alternate_url());
215 215
216 // The size should be 0 for a hosted document. 216 // The size should be 0 for a hosted document.
217 EXPECT_EQ(0, entry.file_info().size()); 217 EXPECT_EQ(0, entry.file_info().size());
218 } 218 }
219 219
220 TEST(ResourceEntryConversionTest, ConvertChangeResourceToResourceEntry) { 220 TEST(ResourceEntryConversionTest, ConvertChangeResourceToResourceEntry) {
221 google_apis::ChangeResource change_resource; 221 google_apis::ChangeResource change_resource;
222 change_resource.set_type(google_apis::ChangeResource::FILE);
222 change_resource.set_file(base::WrapUnique(new google_apis::FileResource)); 223 change_resource.set_file(base::WrapUnique(new google_apis::FileResource));
223 change_resource.set_file_id("resource_id"); 224 change_resource.set_file_id("resource_id");
224 change_resource.set_modification_date(GetTestTime()); 225 change_resource.set_modification_date(GetTestTime());
225 226
226 google_apis::FileResource* file_resource = change_resource.mutable_file(); 227 google_apis::FileResource* file_resource = change_resource.mutable_file();
227 file_resource->set_title("File 1.mp3"); 228 file_resource->set_title("File 1.mp3");
228 file_resource->set_file_id("resource_id"); 229 file_resource->set_file_id("resource_id");
229 // Set dummy file size to declare that this is a regular file. 230 // Set dummy file size to declare that this is a regular file.
230 file_resource->set_file_size(12345); 231 file_resource->set_file_size(12345);
231 232
232 ResourceEntry entry; 233 ResourceEntry entry;
233 std::string parent_resource_id; 234 std::string parent_resource_id;
234 EXPECT_TRUE(ConvertChangeResourceToResourceEntry( 235 EXPECT_TRUE(ConvertChangeResourceToResourceEntry(
235 change_resource, &entry, &parent_resource_id)); 236 change_resource, &entry, &parent_resource_id));
236 237
237 EXPECT_EQ(change_resource.file_id(), entry.resource_id()); 238 EXPECT_EQ(change_resource.file_id(), entry.resource_id());
238 EXPECT_EQ(change_resource.modification_date().ToInternalValue(), 239 EXPECT_EQ(change_resource.modification_date().ToInternalValue(),
239 entry.modification_date()); 240 entry.modification_date());
240 241
241 EXPECT_EQ(file_resource->title(), entry.title()); 242 EXPECT_EQ(file_resource->title(), entry.title());
242 EXPECT_EQ(file_resource->title(), entry.base_name()); 243 EXPECT_EQ(file_resource->title(), entry.base_name());
243 EXPECT_EQ("", parent_resource_id); 244 EXPECT_EQ("", parent_resource_id);
244 245
245 EXPECT_FALSE(entry.deleted()); 246 EXPECT_FALSE(entry.deleted());
246 } 247 }
247 248
248 TEST(ResourceEntryConversionTest, 249 TEST(ResourceEntryConversionTest,
249 ConvertChangeResourceToResourceEntry_Trashed) { 250 ConvertChangeResourceToResourceEntry_Trashed) {
250 google_apis::ChangeResource change_resource; 251 google_apis::ChangeResource change_resource;
252 change_resource.set_type(google_apis::ChangeResource::FILE);
251 change_resource.set_file(base::WrapUnique(new google_apis::FileResource)); 253 change_resource.set_file(base::WrapUnique(new google_apis::FileResource));
252 change_resource.set_file_id("resource_id"); 254 change_resource.set_file_id("resource_id");
253 change_resource.set_modification_date(GetTestTime()); 255 change_resource.set_modification_date(GetTestTime());
254 256
255 google_apis::FileResource* file_resource = change_resource.mutable_file(); 257 google_apis::FileResource* file_resource = change_resource.mutable_file();
256 file_resource->set_title("File 1.mp3"); 258 file_resource->set_title("File 1.mp3");
257 file_resource->set_file_id("resource_id"); 259 file_resource->set_file_id("resource_id");
258 // Set dummy file size to declare that this is a regular file. 260 // Set dummy file size to declare that this is a regular file.
259 file_resource->set_file_size(12345); 261 file_resource->set_file_size(12345);
260 file_resource->mutable_labels()->set_trashed(true); 262 file_resource->mutable_labels()->set_trashed(true);
(...skipping 10 matching lines...) Expand all
271 EXPECT_EQ(file_resource->title(), entry.title()); 273 EXPECT_EQ(file_resource->title(), entry.title());
272 EXPECT_EQ(file_resource->title(), entry.base_name()); 274 EXPECT_EQ(file_resource->title(), entry.base_name());
273 EXPECT_EQ("", parent_resource_id); 275 EXPECT_EQ("", parent_resource_id);
274 276
275 EXPECT_TRUE(entry.deleted()); 277 EXPECT_TRUE(entry.deleted());
276 } 278 }
277 279
278 TEST(ResourceEntryConversionTest, 280 TEST(ResourceEntryConversionTest,
279 ConvertChangeResourceToResourceEntry_Deleted) { 281 ConvertChangeResourceToResourceEntry_Deleted) {
280 google_apis::ChangeResource change_resource; 282 google_apis::ChangeResource change_resource;
283 change_resource.set_type(google_apis::ChangeResource::FILE);
281 change_resource.set_deleted(true); 284 change_resource.set_deleted(true);
282 change_resource.set_file_id("resource_id"); 285 change_resource.set_file_id("resource_id");
283 change_resource.set_modification_date(GetTestTime()); 286 change_resource.set_modification_date(GetTestTime());
284 287
285 ResourceEntry entry; 288 ResourceEntry entry;
286 std::string parent_resource_id; 289 std::string parent_resource_id;
287 EXPECT_TRUE(ConvertChangeResourceToResourceEntry( 290 EXPECT_TRUE(ConvertChangeResourceToResourceEntry(
288 change_resource, &entry, &parent_resource_id)); 291 change_resource, &entry, &parent_resource_id));
289 292
290 EXPECT_EQ(change_resource.file_id(), entry.resource_id()); 293 EXPECT_EQ(change_resource.file_id(), entry.resource_id());
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 std::string parent_resource_id; 387 std::string parent_resource_id;
385 EXPECT_TRUE(ConvertFileResourceToResourceEntry( 388 EXPECT_TRUE(ConvertFileResourceToResourceEntry(
386 entry_no_fields, &entry, &parent_resource_id)); 389 entry_no_fields, &entry, &parent_resource_id));
387 EXPECT_FALSE(entry.file_specific_info().has_image_width()); 390 EXPECT_FALSE(entry.file_specific_info().has_image_width());
388 EXPECT_FALSE(entry.file_specific_info().has_image_height()); 391 EXPECT_FALSE(entry.file_specific_info().has_image_height());
389 EXPECT_FALSE(entry.file_specific_info().has_image_rotation()); 392 EXPECT_FALSE(entry.file_specific_info().has_image_rotation());
390 } 393 }
391 } 394 }
392 395
393 } // namespace drive 396 } // namespace drive
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698