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

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

Issue 10828109: Replace IF_EXPECT* macros with ASSERT* in gdata_wapi_parser_unittest.cc (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Style fix. 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
« no previous file with comments | « no previous file | no next file » | 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 "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"
11 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
12 #include "base/values.h" 12 #include "base/values.h"
13 #include "chrome/browser/chromeos/gdata/gdata_wapi_parser.h" 13 #include "chrome/browser/chromeos/gdata/gdata_wapi_parser.h"
14 #include "chrome/browser/chromeos/gdata/gdata_util.h" 14 #include "chrome/browser/chromeos/gdata/gdata_util.h"
15 #include "chrome/common/chrome_paths.h" 15 #include "chrome/common/chrome_paths.h"
16 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
17 #include "third_party/libxml/chromium/libxml_utils.h" 17 #include "third_party/libxml/chromium/libxml_utils.h"
18 18
19 using base::Value; 19 using base::Value;
20 using base::DictionaryValue; 20 using base::DictionaryValue;
21 using base::ListValue; 21 using base::ListValue;
22 22
23 #define IF_EXPECT_EQ(arg1, arg2) \
24 EXPECT_EQ(arg1, arg2); \
25 if (arg1 == arg2)
26
27 #define IF_EXPECT_TRUE(arg) \
28 EXPECT_TRUE(arg); \
29 if (arg)
30
31 namespace gdata { 23 namespace gdata {
32 24
33 class GDataWAPIParserTest : public testing::Test { 25 class GDataWAPIParserTest : public testing::Test {
34 protected: 26 protected:
35 static Value* LoadJSONFile(const std::string& filename) { 27 static Value* LoadJSONFile(const std::string& filename) {
36 FilePath path; 28 FilePath path;
37 std::string error; 29 std::string error;
38 // Test files for this unit test are located in 30 // Test files for this unit test are located in
39 // src/chrome/test/data/chromeos/gdata/* 31 // src/chrome/test/data/chromeos/gdata/*
40 PathService::Get(chrome::DIR_TEST_DATA, &path); 32 PathService::Get(chrome::DIR_TEST_DATA, &path);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 81
90 base::Time update_time; 82 base::Time update_time;
91 ASSERT_TRUE(gdata::util::GetTimeFromString("2011-12-14T01:03:21.151Z", 83 ASSERT_TRUE(gdata::util::GetTimeFromString("2011-12-14T01:03:21.151Z",
92 &update_time)); 84 &update_time));
93 85
94 EXPECT_EQ(1, feed->start_index()); 86 EXPECT_EQ(1, feed->start_index());
95 EXPECT_EQ(1000, feed->items_per_page()); 87 EXPECT_EQ(1000, feed->items_per_page());
96 EXPECT_EQ(update_time, feed->updated_time()); 88 EXPECT_EQ(update_time, feed->updated_time());
97 89
98 // Check authors. 90 // Check authors.
99 IF_EXPECT_EQ(1U, feed->authors().size()) { 91 ASSERT_EQ(1U, feed->authors().size());
100 EXPECT_EQ(ASCIIToUTF16("tester"), feed->authors()[0]->name()); 92 EXPECT_EQ(ASCIIToUTF16("tester"), feed->authors()[0]->name());
101 EXPECT_EQ("tester@testing.com", feed->authors()[0]->email()); 93 EXPECT_EQ("tester@testing.com", feed->authors()[0]->email());
102 }
103 94
104 // Check links. 95 // Check links.
105 IF_EXPECT_EQ(6U, feed->links().size()) { 96 ASSERT_EQ(6U, feed->links().size());
106 const Link* self_link = feed->GetLinkByType(Link::SELF); 97 const Link* self_link = feed->GetLinkByType(Link::SELF);
107 IF_EXPECT_TRUE(self_link) { 98 ASSERT_TRUE(self_link);
108 EXPECT_EQ("https://self_link/", self_link->href().spec()); 99 EXPECT_EQ("https://self_link/", self_link->href().spec());
109 EXPECT_EQ("application/atom+xml", self_link->mime_type()); 100 EXPECT_EQ("application/atom+xml", self_link->mime_type());
110 } 101
111 }
112 102
113 const Link* resumable_link = 103 const Link* resumable_link =
114 feed->GetLinkByType(Link::RESUMABLE_CREATE_MEDIA); 104 feed->GetLinkByType(Link::RESUMABLE_CREATE_MEDIA);
115 IF_EXPECT_TRUE(resumable_link) { 105 ASSERT_TRUE(resumable_link);
116 EXPECT_EQ("https://resumable_create_media_link/", 106 EXPECT_EQ("https://resumable_create_media_link/",
117 resumable_link->href().spec()); 107 resumable_link->href().spec());
118 EXPECT_EQ("application/atom+xml", resumable_link->mime_type()); 108 EXPECT_EQ("application/atom+xml", resumable_link->mime_type());
119 }
120 109
121 // Check entries. 110 // Check entries.
122 ASSERT_EQ(4U, feed->entries().size()); 111 ASSERT_EQ(4U, feed->entries().size());
123 112
124 // Check a folder entry. 113 // Check a folder entry.
125 const DocumentEntry* folder_entry = feed->entries()[0]; 114 const DocumentEntry* folder_entry = feed->entries()[0];
126 ASSERT_TRUE(folder_entry); 115 ASSERT_TRUE(folder_entry);
127 EXPECT_EQ(DocumentEntry::FOLDER, folder_entry->kind()); 116 EXPECT_EQ(DocumentEntry::FOLDER, folder_entry->kind());
128 EXPECT_EQ("\"HhMOFgcNHSt7ImBr\"", folder_entry->etag()); 117 EXPECT_EQ("\"HhMOFgcNHSt7ImBr\"", folder_entry->etag());
129 EXPECT_EQ("folder:sub_sub_directory_folder_id", folder_entry->resource_id()); 118 EXPECT_EQ("folder:sub_sub_directory_folder_id", folder_entry->resource_id());
130 EXPECT_EQ("https://1_folder_id", folder_entry->id()); 119 EXPECT_EQ("https://1_folder_id", folder_entry->id());
131 EXPECT_EQ(ASCIIToUTF16("Entry 1 Title"), folder_entry->title()); 120 EXPECT_EQ(ASCIIToUTF16("Entry 1 Title"), folder_entry->title());
132 base::Time entry1_update_time; 121 base::Time entry1_update_time;
133 base::Time entry1_publish_time; 122 base::Time entry1_publish_time;
134 ASSERT_TRUE(gdata::util::GetTimeFromString("2011-04-01T18:34:08.234Z", 123 ASSERT_TRUE(gdata::util::GetTimeFromString("2011-04-01T18:34:08.234Z",
135 &entry1_update_time)); 124 &entry1_update_time));
136 ASSERT_TRUE(gdata::util::GetTimeFromString("2010-11-07T05:03:54.719Z", 125 ASSERT_TRUE(gdata::util::GetTimeFromString("2010-11-07T05:03:54.719Z",
137 &entry1_publish_time)); 126 &entry1_publish_time));
138 EXPECT_EQ(entry1_update_time, folder_entry->updated_time()); 127 EXPECT_EQ(entry1_update_time, folder_entry->updated_time());
139 EXPECT_EQ(entry1_publish_time, folder_entry->published_time()); 128 EXPECT_EQ(entry1_publish_time, folder_entry->published_time());
140 129
141 IF_EXPECT_EQ(1U, folder_entry->authors().size()) { 130 ASSERT_EQ(1U, folder_entry->authors().size());
142 EXPECT_EQ(ASCIIToUTF16("entry_tester"), folder_entry->authors()[0]->name()); 131 EXPECT_EQ(ASCIIToUTF16("entry_tester"), folder_entry->authors()[0]->name());
143 EXPECT_EQ("entry_tester@testing.com", folder_entry->authors()[0]->email()); 132 EXPECT_EQ("entry_tester@testing.com", folder_entry->authors()[0]->email());
144 EXPECT_EQ("https://1_folder_content_url/", 133 EXPECT_EQ("https://1_folder_content_url/",
145 folder_entry->content_url().spec()); 134 folder_entry->content_url().spec());
146 EXPECT_EQ("application/atom+xml;type=feed", 135 EXPECT_EQ("application/atom+xml;type=feed",
147 folder_entry->content_mime_type()); 136 folder_entry->content_mime_type());
148 }
149 137
150 ASSERT_EQ(1U, folder_entry->feed_links().size()); 138 ASSERT_EQ(1U, folder_entry->feed_links().size());
151 const FeedLink* feed_link = folder_entry->feed_links()[0]; 139 const FeedLink* feed_link = folder_entry->feed_links()[0];
152 ASSERT_TRUE(feed_link); 140 ASSERT_TRUE(feed_link);
153 ASSERT_EQ(FeedLink::ACL, feed_link->type()); 141 ASSERT_EQ(FeedLink::ACL, feed_link->type());
154 142
155 const Link* entry1_alternate_link = 143 const Link* entry1_alternate_link =
156 folder_entry->GetLinkByType(Link::ALTERNATE); 144 folder_entry->GetLinkByType(Link::ALTERNATE);
157 IF_EXPECT_TRUE(entry1_alternate_link) { 145 ASSERT_TRUE(entry1_alternate_link);
158 EXPECT_EQ("https://1_folder_alternate_link/", 146 EXPECT_EQ("https://1_folder_alternate_link/",
159 entry1_alternate_link->href().spec()); 147 entry1_alternate_link->href().spec());
160 EXPECT_EQ("text/html", entry1_alternate_link->mime_type()); 148 EXPECT_EQ("text/html", entry1_alternate_link->mime_type());
161 }
162 149
163 const Link* entry1_edit_link = folder_entry->GetLinkByType(Link::EDIT); 150 const Link* entry1_edit_link = folder_entry->GetLinkByType(Link::EDIT);
164 IF_EXPECT_TRUE(entry1_edit_link) { 151 ASSERT_TRUE(entry1_edit_link);
165 EXPECT_EQ("https://1_edit_link/", entry1_edit_link->href().spec()); 152 EXPECT_EQ("https://1_edit_link/", entry1_edit_link->href().spec());
166 EXPECT_EQ("application/atom+xml", entry1_edit_link->mime_type()); 153 EXPECT_EQ("application/atom+xml", entry1_edit_link->mime_type());
167 }
168 154
169 // Check a file entry. 155 // Check a file entry.
170 const DocumentEntry* file_entry = feed->entries()[1]; 156 const DocumentEntry* file_entry = feed->entries()[1];
171 IF_EXPECT_TRUE(file_entry) { 157 ASSERT_TRUE(file_entry);
172 EXPECT_EQ(DocumentEntry::FILE, file_entry->kind()); 158 EXPECT_EQ(DocumentEntry::FILE, file_entry->kind());
173 EXPECT_EQ(ASCIIToUTF16("filename.m4a"), file_entry->filename()); 159 EXPECT_EQ(ASCIIToUTF16("filename.m4a"), file_entry->filename());
174 EXPECT_EQ(ASCIIToUTF16("sugg_file_name.m4a"), 160 EXPECT_EQ(ASCIIToUTF16("sugg_file_name.m4a"),
175 file_entry->suggested_filename()); 161 file_entry->suggested_filename());
176 EXPECT_EQ("3b4382ebefec6e743578c76bbd0575ce", file_entry->file_md5()); 162 EXPECT_EQ("3b4382ebefec6e743578c76bbd0575ce", file_entry->file_md5());
177 EXPECT_EQ(892721, file_entry->file_size()); 163 EXPECT_EQ(892721, file_entry->file_size());
178 const Link* file_parent_link = file_entry->GetLinkByType(Link::PARENT); 164 const Link* file_parent_link = file_entry->GetLinkByType(Link::PARENT);
179 IF_EXPECT_TRUE(file_parent_link) { 165 ASSERT_TRUE(file_parent_link);
180 EXPECT_EQ("https://file_link_parent/", file_parent_link->href().spec()); 166 EXPECT_EQ("https://file_link_parent/", file_parent_link->href().spec());
181 EXPECT_EQ("application/atom+xml", file_parent_link->mime_type()); 167 EXPECT_EQ("application/atom+xml", file_parent_link->mime_type());
182 EXPECT_EQ(ASCIIToUTF16("Medical"), file_parent_link->title()); 168 EXPECT_EQ(ASCIIToUTF16("Medical"), file_parent_link->title());
183 } 169 const Link* file_open_with_link =
184 const Link* file_open_with_link = 170 file_entry->GetLinkByType(Link::OPEN_WITH);
185 file_entry->GetLinkByType(Link::OPEN_WITH); 171 ASSERT_TRUE(file_open_with_link);
186 IF_EXPECT_TRUE(file_open_with_link) { 172 EXPECT_EQ("https://xml_file_entry_open_with_link/",
187 EXPECT_EQ("https://xml_file_entry_open_with_link/", 173 file_open_with_link->href().spec());
188 file_open_with_link->href().spec()); 174 EXPECT_EQ("application/atom+xml", file_open_with_link->mime_type());
189 EXPECT_EQ("application/atom+xml", file_open_with_link->mime_type()); 175 EXPECT_EQ("the_app_id", file_open_with_link->app_id());
190 EXPECT_EQ("the_app_id", file_open_with_link->app_id());
191 }
192 176
193 const Link* file_unknown_link = file_entry->GetLinkByType(Link::UNKNOWN); 177 const Link* file_unknown_link = file_entry->GetLinkByType(Link::UNKNOWN);
194 IF_EXPECT_TRUE(file_unknown_link) { 178 ASSERT_TRUE(file_unknown_link);
195 EXPECT_EQ("https://xml_file_fake_entry_open_with_link/", 179 EXPECT_EQ("https://xml_file_fake_entry_open_with_link/",
196 file_unknown_link->href().spec()); 180 file_unknown_link->href().spec());
197 EXPECT_EQ("application/atom+xml", file_unknown_link->mime_type()); 181 EXPECT_EQ("application/atom+xml", file_unknown_link->mime_type());
198 EXPECT_EQ("", file_unknown_link->app_id()); 182 EXPECT_EQ("", file_unknown_link->app_id());
199 }
200
201 }
202 183
203 // Check a file entry. 184 // Check a file entry.
204 const DocumentEntry* document_entry = feed->entries()[2]; 185 const DocumentEntry* document_entry = feed->entries()[2];
205 IF_EXPECT_TRUE(document_entry) { 186 ASSERT_TRUE(document_entry);
206 EXPECT_EQ(DocumentEntry::DOCUMENT, document_entry->kind()); 187 EXPECT_EQ(DocumentEntry::DOCUMENT, document_entry->kind());
207 EXPECT_TRUE(document_entry->is_hosted_document()); 188 EXPECT_TRUE(document_entry->is_hosted_document());
208 EXPECT_TRUE(document_entry->is_google_document()); 189 EXPECT_TRUE(document_entry->is_google_document());
209 EXPECT_FALSE(document_entry->is_external_document()); 190 EXPECT_FALSE(document_entry->is_external_document());
210 }
211 191
212 // Check an external document entry. 192 // Check an external document entry.
213 const DocumentEntry* app_entry = feed->entries()[3]; 193 const DocumentEntry* app_entry = feed->entries()[3];
214 IF_EXPECT_TRUE(app_entry) { 194 ASSERT_TRUE(app_entry);
215 EXPECT_EQ(DocumentEntry::EXTERNAL_APP, app_entry->kind()); 195 EXPECT_EQ(DocumentEntry::EXTERNAL_APP, app_entry->kind());
216 EXPECT_TRUE(app_entry->is_hosted_document()); 196 EXPECT_TRUE(app_entry->is_hosted_document());
217 EXPECT_TRUE(app_entry->is_external_document()); 197 EXPECT_TRUE(app_entry->is_external_document());
218 EXPECT_FALSE(app_entry->is_google_document()); 198 EXPECT_FALSE(app_entry->is_google_document());
219 }
220 } 199 }
221 200
222 201
223 // Test document feed parsing. 202 // Test document feed parsing.
224 TEST_F(GDataWAPIParserTest, DocumentEntryXmlParser) { 203 TEST_F(GDataWAPIParserTest, DocumentEntryXmlParser) {
225 scoped_ptr<DocumentEntry> entry(LoadDocumentEntryFromXml("entry.xml")); 204 scoped_ptr<DocumentEntry> entry(LoadDocumentEntryFromXml("entry.xml"));
226 ASSERT_TRUE(entry.get()); 205 ASSERT_TRUE(entry.get());
227 206
228 EXPECT_EQ(DocumentEntry::FILE, entry->kind()); 207 EXPECT_EQ(DocumentEntry::FILE, entry->kind());
229 EXPECT_EQ("\"HhMOFgcNHSt7ImBr\"", entry->etag()); 208 EXPECT_EQ("\"HhMOFgcNHSt7ImBr\"", entry->etag());
(...skipping 11 matching lines...) Expand all
241 220
242 EXPECT_EQ(1U, entry->authors().size()); 221 EXPECT_EQ(1U, entry->authors().size());
243 EXPECT_EQ(ASCIIToUTF16("entry_tester"), entry->authors()[0]->name()); 222 EXPECT_EQ(ASCIIToUTF16("entry_tester"), entry->authors()[0]->name());
244 EXPECT_EQ("entry_tester@testing.com", entry->authors()[0]->email()); 223 EXPECT_EQ("entry_tester@testing.com", entry->authors()[0]->email());
245 EXPECT_EQ("https://1_xml_file_entry_content_url/", 224 EXPECT_EQ("https://1_xml_file_entry_content_url/",
246 entry->content_url().spec()); 225 entry->content_url().spec());
247 EXPECT_EQ("application/x-tar", 226 EXPECT_EQ("application/x-tar",
248 entry->content_mime_type()); 227 entry->content_mime_type());
249 228
250 // Check feed links. 229 // Check feed links.
251 IF_EXPECT_EQ(2U, entry->feed_links().size()) { 230 ASSERT_EQ(2U, entry->feed_links().size());
252 const FeedLink* feed_link_1 = entry->feed_links()[0]; 231 const FeedLink* feed_link_1 = entry->feed_links()[0];
253 IF_EXPECT_TRUE(feed_link_1) { 232 ASSERT_TRUE(feed_link_1);
254 EXPECT_EQ(FeedLink::ACL, feed_link_1->type()); 233 EXPECT_EQ(FeedLink::ACL, feed_link_1->type());
255 } 234
256 const FeedLink* feed_link_2 = entry->feed_links()[1]; 235 const FeedLink* feed_link_2 = entry->feed_links()[1];
257 IF_EXPECT_TRUE(feed_link_2) { 236 ASSERT_TRUE(feed_link_2);
258 EXPECT_EQ(FeedLink::REVISIONS, feed_link_2->type()); 237 EXPECT_EQ(FeedLink::REVISIONS, feed_link_2->type());
259 }
260 }
261 238
262 // Check links. 239 // Check links.
263 IF_EXPECT_EQ(9U, entry->links().size()) { 240 ASSERT_EQ(9U, entry->links().size());
264 const Link* entry1_alternate_link = entry->GetLinkByType(Link::ALTERNATE); 241 const Link* entry1_alternate_link = entry->GetLinkByType(Link::ALTERNATE);
265 IF_EXPECT_TRUE(entry1_alternate_link) { 242 ASSERT_TRUE(entry1_alternate_link);
266 EXPECT_EQ("https://xml_file_entry_id_alternate_link/", 243 EXPECT_EQ("https://xml_file_entry_id_alternate_link/",
267 entry1_alternate_link->href().spec()); 244 entry1_alternate_link->href().spec());
268 EXPECT_EQ("text/html", entry1_alternate_link->mime_type()); 245 EXPECT_EQ("text/html", entry1_alternate_link->mime_type());
269 }
270 246
271 const Link* entry1_edit_link = entry->GetLinkByType(Link::EDIT_MEDIA); 247 const Link* entry1_edit_link = entry->GetLinkByType(Link::EDIT_MEDIA);
272 IF_EXPECT_TRUE(entry1_edit_link) { 248 ASSERT_TRUE(entry1_edit_link);
273 EXPECT_EQ("https://xml_file_entry_id_edit_media_link/", 249 EXPECT_EQ("https://xml_file_entry_id_edit_media_link/",
274 entry1_edit_link->href().spec()); 250 entry1_edit_link->href().spec());
275 EXPECT_EQ("application/x-tar", entry1_edit_link->mime_type()); 251 EXPECT_EQ("application/x-tar", entry1_edit_link->mime_type());
276 }
277 252
278 const Link* entry1_self_link = entry->GetLinkByType(Link::SELF); 253 const Link* entry1_self_link = entry->GetLinkByType(Link::SELF);
279 IF_EXPECT_TRUE(entry1_self_link) { 254 ASSERT_TRUE(entry1_self_link);
280 EXPECT_EQ("https://xml_file_entry_id_self_link/", 255 EXPECT_EQ("https://xml_file_entry_id_self_link/",
281 entry1_self_link->href().spec()); 256 entry1_self_link->href().spec());
282 EXPECT_EQ("application/atom+xml", entry1_self_link->mime_type()); 257 EXPECT_EQ("application/atom+xml", entry1_self_link->mime_type());
283 EXPECT_EQ("", entry1_self_link->app_id()); 258 EXPECT_EQ("", entry1_self_link->app_id());
284 }
285 259
286 const Link* entry1_open_with_link = entry->GetLinkByType(Link::OPEN_WITH); 260 const Link* entry1_open_with_link = entry->GetLinkByType(Link::OPEN_WITH);
287 IF_EXPECT_TRUE(entry1_open_with_link) { 261 ASSERT_TRUE(entry1_open_with_link);
288 EXPECT_EQ("https://xml_file_entry_open_with_link/", 262 EXPECT_EQ("https://xml_file_entry_open_with_link/",
289 entry1_open_with_link->href().spec()); 263 entry1_open_with_link->href().spec());
290 EXPECT_EQ("application/atom+xml", entry1_open_with_link->mime_type()); 264 EXPECT_EQ("application/atom+xml", entry1_open_with_link->mime_type());
291 EXPECT_EQ("the_app_id", entry1_open_with_link->app_id()); 265 EXPECT_EQ("the_app_id", entry1_open_with_link->app_id());
292 }
293 266
294 const Link* entry1_unknown_link = entry->GetLinkByType(Link::UNKNOWN); 267 const Link* entry1_unknown_link = entry->GetLinkByType(Link::UNKNOWN);
295 IF_EXPECT_TRUE(entry1_unknown_link) { 268 ASSERT_TRUE(entry1_unknown_link);
296 EXPECT_EQ("https://xml_file_fake_entry_open_with_link/", 269 EXPECT_EQ("https://xml_file_fake_entry_open_with_link/",
297 entry1_unknown_link->href().spec()); 270 entry1_unknown_link->href().spec());
298 EXPECT_EQ("application/atom+xml", entry1_unknown_link->mime_type()); 271 EXPECT_EQ("application/atom+xml", entry1_unknown_link->mime_type());
299 EXPECT_EQ("", entry1_unknown_link->app_id()); 272 EXPECT_EQ("", entry1_unknown_link->app_id());
300 }
301 }
302 273
303 // Check a file properties. 274 // Check a file properties.
304 EXPECT_EQ(DocumentEntry::FILE, entry->kind()); 275 EXPECT_EQ(DocumentEntry::FILE, entry->kind());
305 EXPECT_EQ(ASCIIToUTF16("Xml Entry File Name.tar"), entry->filename()); 276 EXPECT_EQ(ASCIIToUTF16("Xml Entry File Name.tar"), entry->filename());
306 EXPECT_EQ(ASCIIToUTF16("Xml Entry Suggested File Name.tar"), 277 EXPECT_EQ(ASCIIToUTF16("Xml Entry Suggested File Name.tar"),
307 entry->suggested_filename()); 278 entry->suggested_filename());
308 EXPECT_EQ("e48f4d5c46a778de263e0e3f4b3d2a7d", entry->file_md5()); 279 EXPECT_EQ("e48f4d5c46a778de263e0e3f4b3d2a7d", entry->file_md5());
309 EXPECT_EQ(26562560, entry->file_size()); 280 EXPECT_EQ(26562560, entry->file_size());
310 } 281 }
311 282
312 TEST_F(GDataWAPIParserTest, AccountMetadataFeedParser) { 283 TEST_F(GDataWAPIParserTest, AccountMetadataFeedParser) {
313 scoped_ptr<Value> document(LoadJSONFile("account_metadata.json")); 284 scoped_ptr<Value> document(LoadJSONFile("account_metadata.json"));
314 ASSERT_TRUE(document.get()); 285 ASSERT_TRUE(document.get());
315 ASSERT_EQ(Value::TYPE_DICTIONARY, document->GetType()); 286 ASSERT_EQ(Value::TYPE_DICTIONARY, document->GetType());
316 DictionaryValue* entry_value = NULL; 287 DictionaryValue* entry_value = NULL;
317 ASSERT_TRUE(reinterpret_cast<DictionaryValue*>(document.get())->GetDictionary( 288 ASSERT_TRUE(reinterpret_cast<DictionaryValue*>(document.get())->GetDictionary(
318 std::string("entry"), &entry_value)); 289 std::string("entry"), &entry_value));
319 ASSERT_TRUE(entry_value); 290 ASSERT_TRUE(entry_value);
320 291
321 scoped_ptr<AccountMetadataFeed> feed( 292 scoped_ptr<AccountMetadataFeed> feed(
322 AccountMetadataFeed::CreateFrom(*document)); 293 AccountMetadataFeed::CreateFrom(*document));
323 ASSERT_TRUE(feed.get()); 294 ASSERT_TRUE(feed.get());
324 EXPECT_EQ(GG_LONGLONG(6789012345), feed->quota_bytes_used()); 295 EXPECT_EQ(GG_LONGLONG(6789012345), feed->quota_bytes_used());
325 EXPECT_EQ(GG_LONGLONG(9876543210), feed->quota_bytes_total()); 296 EXPECT_EQ(GG_LONGLONG(9876543210), feed->quota_bytes_total());
326 EXPECT_EQ(654321, feed->largest_changestamp()); 297 EXPECT_EQ(654321, feed->largest_changestamp());
327 EXPECT_EQ(2U, feed->installed_apps().size()); 298 EXPECT_EQ(2U, feed->installed_apps().size());
328 const InstalledApp* first_app = feed->installed_apps()[0]; 299 const InstalledApp* first_app = feed->installed_apps()[0];
329 const InstalledApp* second_app = feed->installed_apps()[1]; 300 const InstalledApp* second_app = feed->installed_apps()[1];
330 301
331 IF_EXPECT_TRUE(first_app) { 302 ASSERT_TRUE(first_app);
332 EXPECT_EQ("Drive App 1", UTF16ToUTF8(first_app->app_name())); 303 EXPECT_EQ("Drive App 1", UTF16ToUTF8(first_app->app_name()));
333 EXPECT_EQ("Drive App Object 1", UTF16ToUTF8(first_app->object_type())); 304 EXPECT_EQ("Drive App Object 1", UTF16ToUTF8(first_app->object_type()));
334 EXPECT_TRUE(first_app->supports_create()); 305 EXPECT_TRUE(first_app->supports_create());
335 EXPECT_EQ("https://chrome.google.com/webstore/detail/abcdefabcdef", 306 EXPECT_EQ("https://chrome.google.com/webstore/detail/abcdefabcdef",
336 first_app->GetProductUrl().spec()); 307 first_app->GetProductUrl().spec());
337 IF_EXPECT_EQ(2U, first_app->primary_mimetypes().size()) {
338 EXPECT_EQ("application/test_type_1",
339 *first_app->primary_mimetypes()[0]);
340 EXPECT_EQ("application/vnd.google-apps.drive-sdk.11111111",
341 *first_app->primary_mimetypes()[1]);
342 }
343 IF_EXPECT_EQ(1U, first_app->secondary_mimetypes().size()) {
344 EXPECT_EQ("image/jpeg", *first_app->secondary_mimetypes()[0]);
345 }
346 IF_EXPECT_EQ(2U, first_app->primary_extensions().size()) {
347 EXPECT_EQ("ext_1", *first_app->primary_extensions()[0]);
348 EXPECT_EQ("ext_2", *first_app->primary_extensions()[1]);
349 }
350 IF_EXPECT_EQ(1U, first_app->secondary_extensions().size()) {
351 EXPECT_EQ("ext_3", *first_app->secondary_extensions()[0]);
352 }
353 IF_EXPECT_EQ(1U, first_app->app_icons().size()) {
354 EXPECT_EQ(AppIcon::DOCUMENT, first_app->app_icons()[0]->category());
355 EXPECT_EQ(16, first_app->app_icons()[0]->icon_side_length());
356 GURL icon_url = first_app->app_icons()[0]->GetIconURL();
357 EXPECT_EQ("https://www.google.com/images/srpr/logo3w.png",
358 icon_url.spec());
359 InstalledApp::IconList icons =
360 first_app->GetIconsForCategory(AppIcon::DOCUMENT);
361 EXPECT_EQ("https://www.google.com/images/srpr/logo3w.png",
362 icons[0].second.spec());
363 icons = first_app->GetIconsForCategory(AppIcon::SHARED_DOCUMENT);
364 EXPECT_TRUE(icons.empty());
365 }
366 }
367 308
368 IF_EXPECT_TRUE(second_app) { 309 ASSERT_EQ(2U, first_app->primary_mimetypes().size());
369 EXPECT_EQ("Drive App 2", UTF16ToUTF8(second_app->app_name())); 310 EXPECT_EQ("application/test_type_1",
370 EXPECT_EQ("Drive App Object 2", UTF16ToUTF8(second_app->object_type())); 311 *first_app->primary_mimetypes()[0]);
371 EXPECT_EQ("https://chrome.google.com/webstore/detail/deadbeefdeadbeef", 312 EXPECT_EQ("application/vnd.google-apps.drive-sdk.11111111",
372 second_app->GetProductUrl().spec()); 313 *first_app->primary_mimetypes()[1]);
373 EXPECT_FALSE(second_app->supports_create()); 314
374 EXPECT_EQ(2U, second_app->primary_mimetypes().size()); 315 ASSERT_EQ(1U, first_app->secondary_mimetypes().size());
375 EXPECT_EQ(0U, second_app->secondary_mimetypes().size()); 316 EXPECT_EQ("image/jpeg", *first_app->secondary_mimetypes()[0]);
376 EXPECT_EQ(1U, second_app->primary_extensions().size()); 317
377 EXPECT_EQ(0U, second_app->secondary_extensions().size()); 318 ASSERT_EQ(2U, first_app->primary_extensions().size());
378 } 319 EXPECT_EQ("ext_1", *first_app->primary_extensions()[0]);
320 EXPECT_EQ("ext_2", *first_app->primary_extensions()[1]);
321
322 ASSERT_EQ(1U, first_app->secondary_extensions().size());
323 EXPECT_EQ("ext_3", *first_app->secondary_extensions()[0]);
324
325 ASSERT_EQ(1U, first_app->app_icons().size());
326 EXPECT_EQ(AppIcon::DOCUMENT, first_app->app_icons()[0]->category());
327 EXPECT_EQ(16, first_app->app_icons()[0]->icon_side_length());
328 GURL icon_url = first_app->app_icons()[0]->GetIconURL();
329 EXPECT_EQ("https://www.google.com/images/srpr/logo3w.png", icon_url.spec());
330 InstalledApp::IconList icons =
331 first_app->GetIconsForCategory(AppIcon::DOCUMENT);
332 EXPECT_EQ("https://www.google.com/images/srpr/logo3w.png",
333 icons[0].second.spec());
334 icons = first_app->GetIconsForCategory(AppIcon::SHARED_DOCUMENT);
335 EXPECT_TRUE(icons.empty());
336
337 ASSERT_TRUE(second_app);
338 EXPECT_EQ("Drive App 2", UTF16ToUTF8(second_app->app_name()));
339 EXPECT_EQ("Drive App Object 2", UTF16ToUTF8(second_app->object_type()));
340 EXPECT_EQ("https://chrome.google.com/webstore/detail/deadbeefdeadbeef",
341 second_app->GetProductUrl().spec());
342 EXPECT_FALSE(second_app->supports_create());
343 EXPECT_EQ(2U, second_app->primary_mimetypes().size());
344 EXPECT_EQ(0U, second_app->secondary_mimetypes().size());
345 EXPECT_EQ(1U, second_app->primary_extensions().size());
346 EXPECT_EQ(0U, second_app->secondary_extensions().size());
379 } 347 }
380 348
381 // Test file extension checking in DocumentEntry::HasDocumentExtension(). 349 // Test file extension checking in DocumentEntry::HasDocumentExtension().
382 TEST_F(GDataWAPIParserTest, DocumentEntryHasDocumentExtension) { 350 TEST_F(GDataWAPIParserTest, DocumentEntryHasDocumentExtension) {
383 EXPECT_TRUE(DocumentEntry::HasHostedDocumentExtension( 351 EXPECT_TRUE(DocumentEntry::HasHostedDocumentExtension(
384 FilePath(FILE_PATH_LITERAL("Test.gdoc")))); 352 FilePath(FILE_PATH_LITERAL("Test.gdoc"))));
385 EXPECT_TRUE(DocumentEntry::HasHostedDocumentExtension( 353 EXPECT_TRUE(DocumentEntry::HasHostedDocumentExtension(
386 FilePath(FILE_PATH_LITERAL("Test.gsheet")))); 354 FilePath(FILE_PATH_LITERAL("Test.gsheet"))));
387 EXPECT_TRUE(DocumentEntry::HasHostedDocumentExtension( 355 EXPECT_TRUE(DocumentEntry::HasHostedDocumentExtension(
388 FilePath(FILE_PATH_LITERAL("Test.gslides")))); 356 FilePath(FILE_PATH_LITERAL("Test.gslides"))));
389 EXPECT_TRUE(DocumentEntry::HasHostedDocumentExtension( 357 EXPECT_TRUE(DocumentEntry::HasHostedDocumentExtension(
390 FilePath(FILE_PATH_LITERAL("Test.gdraw")))); 358 FilePath(FILE_PATH_LITERAL("Test.gdraw"))));
391 EXPECT_TRUE(DocumentEntry::HasHostedDocumentExtension( 359 EXPECT_TRUE(DocumentEntry::HasHostedDocumentExtension(
392 FilePath(FILE_PATH_LITERAL("Test.gtable")))); 360 FilePath(FILE_PATH_LITERAL("Test.gtable"))));
393 EXPECT_FALSE(DocumentEntry::HasHostedDocumentExtension( 361 EXPECT_FALSE(DocumentEntry::HasHostedDocumentExtension(
394 FilePath(FILE_PATH_LITERAL("Test.tar.gz")))); 362 FilePath(FILE_PATH_LITERAL("Test.tar.gz"))));
395 EXPECT_FALSE(DocumentEntry::HasHostedDocumentExtension( 363 EXPECT_FALSE(DocumentEntry::HasHostedDocumentExtension(
396 FilePath(FILE_PATH_LITERAL("Test.txt")))); 364 FilePath(FILE_PATH_LITERAL("Test.txt"))));
397 EXPECT_FALSE(DocumentEntry::HasHostedDocumentExtension( 365 EXPECT_FALSE(DocumentEntry::HasHostedDocumentExtension(
398 FilePath(FILE_PATH_LITERAL("Test")))); 366 FilePath(FILE_PATH_LITERAL("Test"))));
399 EXPECT_FALSE(DocumentEntry::HasHostedDocumentExtension( 367 EXPECT_FALSE(DocumentEntry::HasHostedDocumentExtension(
400 FilePath(FILE_PATH_LITERAL("")))); 368 FilePath(FILE_PATH_LITERAL(""))));
401 } 369 }
402 370
403 } // namespace gdata 371 } // namespace gdata
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698