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

Side by Side Diff: chrome/browser/chromeos/gdata/drive_api_parser_unittest.cc

Issue 10829139: Add parsers for Drive v2 Change/ChangeList/Parents (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added class comments. Created 8 years, 4 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 | Annotate | Revision Log
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 "base/file_path.h" 5 #include "base/file_path.h"
6 #include "base/file_util.h" 6 #include "base/file_util.h"
7 #include "base/json/json_file_value_serializer.h" 7 #include "base/json/json_file_value_serializer.h"
8 #include "base/path_service.h" 8 #include "base/path_service.h"
9 #include "base/string16.h" 9 #include "base/string16.h"
10 #include "base/time.h" 10 #include "base/time.h"
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 EXPECT_EQ("0B4v7G8yEYAWHUmRrU2lMS2hLABC", file1.file_id()); 167 EXPECT_EQ("0B4v7G8yEYAWHUmRrU2lMS2hLABC", file1.file_id());
168 EXPECT_EQ("\"WtRjAPZWbDA7_fkFjc5ojsEvDEF/MTM0MzM2NzgwMDIXYZ\"", 168 EXPECT_EQ("\"WtRjAPZWbDA7_fkFjc5ojsEvDEF/MTM0MzM2NzgwMDIXYZ\"",
169 file1.etag()); 169 file1.etag());
170 EXPECT_EQ("My first file data", file1.title()); 170 EXPECT_EQ("My first file data", file1.title());
171 EXPECT_EQ("application/octet-stream", file1.mime_type()); 171 EXPECT_EQ("application/octet-stream", file1.mime_type());
172 172
173 base::Time modified_time; 173 base::Time modified_time;
174 ASSERT_TRUE(gdata::util::GetTimeFromString("2012-07-27T05:43:20.269Z", 174 ASSERT_TRUE(gdata::util::GetTimeFromString("2012-07-27T05:43:20.269Z",
175 &modified_time)); 175 &modified_time));
176 EXPECT_EQ(modified_time, file1.modified_by_me_date()); 176 EXPECT_EQ(modified_time, file1.modified_by_me_date());
177
178 ASSERT_EQ(1U, file1.parents().size());
179 EXPECT_EQ("0B4v7G8yEYAWHYW1OcExsUVZLABC", file1.parents()[0]->file_id());
180 EXPECT_FALSE(file1.parents()[0]->is_root());
181
177 EXPECT_EQ(GURL("https://www.example.com/download"), file1.download_url()); 182 EXPECT_EQ(GURL("https://www.example.com/download"), file1.download_url());
178 EXPECT_EQ("ext", file1.file_extension()); 183 EXPECT_EQ("ext", file1.file_extension());
179 EXPECT_EQ("d41d8cd98f00b204e9800998ecf8427e", file1.md5_checksum()); 184 EXPECT_EQ("d41d8cd98f00b204e9800998ecf8427e", file1.md5_checksum());
180 EXPECT_EQ(1000U, file1.file_size()); 185 EXPECT_EQ(1000U, file1.file_size());
181 186
182 // Check file 2 (a Google Document) 187 // Check file 2 (a Google Document)
183 const FileResource& file2 = *filelist->items()[1]; 188 const FileResource& file2 = *filelist->items()[1];
184 EXPECT_EQ("Test Google Document", file2.title()); 189 EXPECT_EQ("Test Google Document", file2.title());
185 EXPECT_EQ("application/vnd.google-apps.document", file2.mime_type()); 190 EXPECT_EQ("application/vnd.google-apps.document", file2.mime_type());
186 EXPECT_EQ(0U, file2.file_size()); 191 EXPECT_EQ(0U, file2.file_size());
187 192
193 ASSERT_EQ(0U, file2.parents().size());
194
188 // Check file 3 (a folder) 195 // Check file 3 (a folder)
189 const FileResource& file3 = *filelist->items()[2]; 196 const FileResource& file3 = *filelist->items()[2];
190 EXPECT_EQ(0U, file3.file_size()); 197 EXPECT_EQ(0U, file3.file_size());
191 EXPECT_EQ("TestFolder", file3.title()); 198 EXPECT_EQ("TestFolder", file3.title());
192 EXPECT_EQ("application/vnd.google-apps.folder", file3.mime_type()); 199 EXPECT_EQ("application/vnd.google-apps.folder", file3.mime_type());
193 ASSERT_TRUE(file3.IsDirectory()); 200 ASSERT_TRUE(file3.IsDirectory());
201
202 ASSERT_EQ(1U, file3.parents().size());
203 EXPECT_EQ("0AIv7G8yEYAWHUk9ABC", file3.parents()[0]->file_id());
204 EXPECT_TRUE(file3.parents()[0]->is_root());
205 }
206
207 // Test change list parsing.
208 TEST_F(DriveAPIParserTest, ChangeListParser) {
209 std::string error;
210 scoped_ptr<Value> document(LoadJSONFile("changelist.json"));
211 ASSERT_TRUE(document.get());
212
213 ASSERT_EQ(Value::TYPE_DICTIONARY, document->GetType());
214 scoped_ptr<ChangeList> changelist(new ChangeList);
215 EXPECT_TRUE(changelist->Parse(*document));
216
217 EXPECT_EQ("\"Lp2bjAtLP341hvGmYHhxjYyBPJ8/BWbu_eylt5f_aGtCN6mGRv9hABC\"",
218 changelist->etag());
219 EXPECT_EQ("8929", changelist->next_page_token());
220 EXPECT_EQ("https://www.googleapis.com/drive/v2/changes?pageToken=8929",
221 changelist->next_link().spec());
222 EXPECT_EQ(13664, changelist->largest_change_id());
223
224 ASSERT_EQ(3U, changelist->items().size());
225 const ChangeResource& change1 = *changelist->items()[0];
226 EXPECT_EQ(8421, change1.change_id());
227 EXPECT_FALSE(change1.is_deleted());
228 EXPECT_EQ(change1.file_id(), change1.file().file_id());
229
230 const ChangeResource& change2 = *changelist->items()[1];
231 EXPECT_EQ(8424, change2.change_id());
232 EXPECT_FALSE(change2.is_deleted());
233 EXPECT_EQ(change2.file_id(), change2.file().file_id());
234
235 const ChangeResource& change3 = *changelist->items()[2];
236 EXPECT_EQ(8429, change3.change_id());
237 EXPECT_FALSE(change3.is_deleted());
238 EXPECT_EQ(change3.file_id(), change3.file().file_id());
194 } 239 }
195 240
196 } // namespace gdata 241 } // namespace gdata
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698