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

Side by Side Diff: google_apis/drive/drive_api_parser_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
« no previous file with comments | « google_apis/drive/drive_api_parser.cc ('k') | google_apis/test/data/drive/changelist.json » ('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 "google_apis/drive/drive_api_parser.h" 5 #include "google_apis/drive/drive_api_parser.h"
6 6
7 #include "base/time/time.h" 7 #include "base/time/time.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "google_apis/drive/test_util.h" 9 #include "google_apis/drive/test_util.h"
10 #include "google_apis/drive/time_util.h" 10 #include "google_apis/drive/time_util.h"
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 ASSERT_TRUE(document.get()); 245 ASSERT_TRUE(document.get());
246 246
247 ASSERT_EQ(base::Value::Type::DICTIONARY, document->GetType()); 247 ASSERT_EQ(base::Value::Type::DICTIONARY, document->GetType());
248 std::unique_ptr<ChangeList> changelist(new ChangeList); 248 std::unique_ptr<ChangeList> changelist(new ChangeList);
249 EXPECT_TRUE(changelist->Parse(*document)); 249 EXPECT_TRUE(changelist->Parse(*document));
250 250
251 EXPECT_EQ("https://www.googleapis.com/drive/v2/changes?pageToken=8929", 251 EXPECT_EQ("https://www.googleapis.com/drive/v2/changes?pageToken=8929",
252 changelist->next_link().spec()); 252 changelist->next_link().spec());
253 EXPECT_EQ(13664, changelist->largest_change_id()); 253 EXPECT_EQ(13664, changelist->largest_change_id());
254 254
255 ASSERT_EQ(4U, changelist->items().size()); 255 ASSERT_EQ(5U, changelist->items().size());
256 256
257 const ChangeResource& change1 = *changelist->items()[0]; 257 const ChangeResource& change1 = *changelist->items()[0];
258 EXPECT_EQ(8421, change1.change_id()); 258 EXPECT_EQ(8421, change1.change_id());
259 EXPECT_EQ(ChangeResource::FILE, change1.type());
259 EXPECT_FALSE(change1.is_deleted()); 260 EXPECT_FALSE(change1.is_deleted());
260 EXPECT_EQ("1Pc8jzfU1ErbN_eucMMqdqzY3eBm0v8sxXm_1CtLxABC", change1.file_id()); 261 EXPECT_EQ("1Pc8jzfU1ErbN_eucMMqdqzY3eBm0v8sxXm_1CtLxABC", change1.file_id());
261 EXPECT_EQ(change1.file_id(), change1.file()->file_id()); 262 EXPECT_EQ(change1.file_id(), change1.file()->file_id());
262 EXPECT_FALSE(change1.file()->shared()); 263 EXPECT_FALSE(change1.file()->shared());
263 EXPECT_EQ(change1.file()->modified_date(), change1.modification_date()); 264 EXPECT_EQ(change1.file()->modified_date(), change1.modification_date());
264 265
265 const ChangeResource& change2 = *changelist->items()[1]; 266 const ChangeResource& change2 = *changelist->items()[1];
266 EXPECT_EQ(8424, change2.change_id()); 267 EXPECT_EQ(8424, change2.change_id());
268 EXPECT_EQ(ChangeResource::FILE, change2.type());
267 EXPECT_FALSE(change2.is_deleted()); 269 EXPECT_FALSE(change2.is_deleted());
268 EXPECT_EQ("0B4v7G8yEYAWHUmRrU2lMS2hLABC", change2.file_id()); 270 EXPECT_EQ("0B4v7G8yEYAWHUmRrU2lMS2hLABC", change2.file_id());
269 EXPECT_EQ(change2.file_id(), change2.file()->file_id()); 271 EXPECT_EQ(change2.file_id(), change2.file()->file_id());
270 EXPECT_TRUE(change2.file()->shared()); 272 EXPECT_TRUE(change2.file()->shared());
271 EXPECT_EQ(change2.file()->modified_date(), change2.modification_date()); 273 EXPECT_EQ(change2.file()->modified_date(), change2.modification_date());
272 274
273 const ChangeResource& change3 = *changelist->items()[2]; 275 const ChangeResource& change3 = *changelist->items()[2];
274 EXPECT_EQ(8429, change3.change_id()); 276 EXPECT_EQ(8429, change3.change_id());
277 EXPECT_EQ(ChangeResource::FILE, change3.type());
275 EXPECT_FALSE(change3.is_deleted()); 278 EXPECT_FALSE(change3.is_deleted());
276 EXPECT_EQ("0B4v7G8yEYAWHYW1OcExsUVZLABC", change3.file_id()); 279 EXPECT_EQ("0B4v7G8yEYAWHYW1OcExsUVZLABC", change3.file_id());
277 EXPECT_EQ(change3.file_id(), change3.file()->file_id()); 280 EXPECT_EQ(change3.file_id(), change3.file()->file_id());
278 EXPECT_FALSE(change3.file()->shared()); 281 EXPECT_FALSE(change3.file()->shared());
279 EXPECT_EQ(change3.file()->modified_date(), change3.modification_date()); 282 EXPECT_EQ(change3.file()->modified_date(), change3.modification_date());
280 283
281 // Deleted entry. 284 // Deleted entry.
282 const ChangeResource& change4 = *changelist->items()[3]; 285 const ChangeResource& change4 = *changelist->items()[3];
283 EXPECT_EQ(8430, change4.change_id()); 286 EXPECT_EQ(8430, change4.change_id());
287 EXPECT_EQ(ChangeResource::FILE, change4.type());
284 EXPECT_EQ("ABCv7G8yEYAWHc3Y5X0hMSkJYXYZ", change4.file_id()); 288 EXPECT_EQ("ABCv7G8yEYAWHc3Y5X0hMSkJYXYZ", change4.file_id());
285 EXPECT_TRUE(change4.is_deleted()); 289 EXPECT_TRUE(change4.is_deleted());
286 base::Time modification_time; 290 base::Time modification_time;
287 ASSERT_TRUE(util::GetTimeFromString("2012-07-27T12:34:56.789Z", 291 ASSERT_TRUE(util::GetTimeFromString("2012-07-27T12:34:56.789Z",
288 &modification_time)); 292 &modification_time));
289 EXPECT_EQ(modification_time, change4.modification_date()); 293 EXPECT_EQ(modification_time, change4.modification_date());
294
295 // Team Drive entry.
296 const ChangeResource& change5 = *changelist->items()[4];
297 EXPECT_EQ(8431, change5.change_id());
298 EXPECT_EQ(ChangeResource::TEAM_DRIVE, change5.type());
299 EXPECT_EQ("id-of-team-drive-test-data", change5.team_drive()->id());
300 EXPECT_EQ("id-of-team-drive-test-data", change5.team_drive_id());
301 EXPECT_FALSE(change5.is_deleted());
302 ASSERT_TRUE(
303 util::GetTimeFromString("2017-07-27T12:34:56.789Z", &modification_time));
304 EXPECT_EQ(modification_time, change5.modification_date());
305 // capabilities resource inside team_drive should be parsed
306 EXPECT_TRUE(change5.team_drive()->capabilities().can_share());
290 } 307 }
291 308
292 TEST(DriveAPIParserTest, HasKind) { 309 TEST(DriveAPIParserTest, HasKind) {
293 std::unique_ptr<base::Value> change_list_json( 310 std::unique_ptr<base::Value> change_list_json(
294 test_util::LoadJSONFile("drive/changelist.json")); 311 test_util::LoadJSONFile("drive/changelist.json"));
295 std::unique_ptr<base::Value> file_list_json( 312 std::unique_ptr<base::Value> file_list_json(
296 test_util::LoadJSONFile("drive/filelist.json")); 313 test_util::LoadJSONFile("drive/filelist.json"));
297 314
298 EXPECT_TRUE(ChangeList::HasChangeListKind(*change_list_json)); 315 EXPECT_TRUE(ChangeList::HasChangeListKind(*change_list_json));
299 EXPECT_FALSE(ChangeList::HasChangeListKind(*file_list_json)); 316 EXPECT_FALSE(ChangeList::HasChangeListKind(*file_list_json));
300 317
301 EXPECT_FALSE(FileList::HasFileListKind(*change_list_json)); 318 EXPECT_FALSE(FileList::HasFileListKind(*change_list_json));
302 EXPECT_TRUE(FileList::HasFileListKind(*file_list_json)); 319 EXPECT_TRUE(FileList::HasFileListKind(*file_list_json));
303 } 320 }
304 321
305 } // namespace google_apis 322 } // namespace google_apis
OLDNEW
« no previous file with comments | « google_apis/drive/drive_api_parser.cc ('k') | google_apis/test/data/drive/changelist.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698