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

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

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

Powered by Google App Engine
This is Rietveld 408576698