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

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

Issue 9147060: Rewrite the gdata_parser by using JSONValueConverter. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Put names for internal structs because arraysize may not work with anonymous types Created 8 years, 11 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 | « chrome/browser/chromeos/gdata/gdata_parser.cc ('k') | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_value_serializer.h" 7 #include "base/json/json_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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 57
58 base::Time update_time; 58 base::Time update_time;
59 ASSERT_TRUE(GDataEntry::GetTimeFromString("2011-12-14T01:03:21.151Z", 59 ASSERT_TRUE(GDataEntry::GetTimeFromString("2011-12-14T01:03:21.151Z",
60 &update_time)); 60 &update_time));
61 61
62 EXPECT_EQ(1, feed->start_index()); 62 EXPECT_EQ(1, feed->start_index());
63 EXPECT_EQ(1000, feed->items_per_page()); 63 EXPECT_EQ(1000, feed->items_per_page());
64 EXPECT_EQ(update_time, feed->updated_time()); 64 EXPECT_EQ(update_time, feed->updated_time());
65 65
66 // Check authors. 66 // Check authors.
67 ASSERT_EQ(1U, feed->authors()->size()); 67 ASSERT_EQ(1U, feed->authors().size());
68 EXPECT_EQ(ASCIIToUTF16("tester"), feed->authors()[0]->name()); 68 EXPECT_EQ(ASCIIToUTF16("tester"), feed->authors()[0]->name());
69 EXPECT_STREQ("tester@testing.com", feed->authors()[0]->email().c_str()); 69 EXPECT_EQ("tester@testing.com", feed->authors()[0]->email());
70 70
71 // Check links. 71 // Check links.
72 ASSERT_EQ(feed->links()->size(), 6U); 72 ASSERT_EQ(feed->links().size(), 6U);
73 const Link* self_link = feed->GetLinkByType(gdata::Link::SELF); 73 const Link* self_link = feed->GetLinkByType(gdata::Link::SELF);
74 ASSERT_TRUE(self_link); 74 ASSERT_TRUE(self_link);
75 EXPECT_STREQ("https://self_link/", self_link->href().spec().c_str()); 75 EXPECT_EQ("https://self_link/", self_link->href().spec());
76 EXPECT_STREQ("application/atom+xml", self_link->mime_type().c_str()); 76 EXPECT_EQ("application/atom+xml", self_link->mime_type());
77 77
78 const Link* resumable_link = 78 const Link* resumable_link =
79 feed->GetLinkByType(gdata::Link::RESUMABLE_CREATE_MEDIA); 79 feed->GetLinkByType(gdata::Link::RESUMABLE_CREATE_MEDIA);
80 ASSERT_TRUE(resumable_link); 80 ASSERT_TRUE(resumable_link);
81 EXPECT_STREQ("https://resumable_create_media_link/", 81 EXPECT_EQ("https://resumable_create_media_link/",
82 resumable_link->href().spec().c_str()); 82 resumable_link->href().spec());
83 EXPECT_STREQ("application/atom+xml", 83 EXPECT_EQ("application/atom+xml", resumable_link->mime_type());
84 resumable_link->mime_type().c_str());
85 84
86 // Check entries. 85 // Check entries.
87 ASSERT_EQ(3U, feed->entries()->size()); 86 ASSERT_EQ(3U, feed->entries().size());
88 87
89 // Check a folder entry. 88 // Check a folder entry.
90 const DocumentEntry* folder_entry = feed->entries()[0]; 89 const DocumentEntry* folder_entry = feed->entries()[0];
91 ASSERT_TRUE(folder_entry); 90 ASSERT_TRUE(folder_entry);
92 EXPECT_EQ(gdata::DocumentEntry::FOLDER, folder_entry->kind()); 91 EXPECT_EQ(gdata::DocumentEntry::FOLDER, folder_entry->kind());
93 EXPECT_STREQ("\"HhMOFgcNHSt7ImBr\"", folder_entry->etag().c_str()); 92 EXPECT_EQ("\"HhMOFgcNHSt7ImBr\"", folder_entry->etag());
94 EXPECT_STREQ("folder:1_folder_resouce_id", 93 EXPECT_EQ("folder:1_folder_resouce_id", folder_entry->resource_id());
95 folder_entry->resource_id().c_str()); 94 EXPECT_EQ("https://1_folder_id", folder_entry->id());
96 EXPECT_STREQ("https://1_folder_id", folder_entry->id().c_str());
97 EXPECT_EQ(ASCIIToUTF16("Entry 1 Title"), folder_entry->title()); 95 EXPECT_EQ(ASCIIToUTF16("Entry 1 Title"), folder_entry->title());
98 base::Time entry1_update_time; 96 base::Time entry1_update_time;
99 base::Time entry1_publish_time; 97 base::Time entry1_publish_time;
100 ASSERT_TRUE(GDataEntry::GetTimeFromString("2011-04-01T18:34:08.234Z", 98 ASSERT_TRUE(GDataEntry::GetTimeFromString("2011-04-01T18:34:08.234Z",
101 &entry1_update_time)); 99 &entry1_update_time));
102 ASSERT_TRUE(GDataEntry::GetTimeFromString("2010-11-07T05:03:54.719Z", 100 ASSERT_TRUE(GDataEntry::GetTimeFromString("2010-11-07T05:03:54.719Z",
103 &entry1_publish_time)); 101 &entry1_publish_time));
104 ASSERT_EQ(entry1_update_time, folder_entry->updated_time()); 102 ASSERT_EQ(entry1_update_time, folder_entry->updated_time());
105 ASSERT_EQ(entry1_publish_time, folder_entry->published_time()); 103 ASSERT_EQ(entry1_publish_time, folder_entry->published_time());
106 104
107 ASSERT_EQ(1U, folder_entry->authors()->size()); 105 ASSERT_EQ(1U, folder_entry->authors().size());
108 EXPECT_EQ(ASCIIToUTF16("entry_tester"), folder_entry->authors()[0]->name()); 106 EXPECT_EQ(ASCIIToUTF16("entry_tester"), folder_entry->authors()[0]->name());
109 EXPECT_STREQ("entry_tester@testing.com", 107 EXPECT_EQ("entry_tester@testing.com", folder_entry->authors()[0]->email());
110 folder_entry->authors()[0]->email().c_str()); 108 EXPECT_EQ("https://1_folder_content_url/",
111 EXPECT_STREQ("https://1_folder_content_url/", 109 folder_entry->content_url().spec());
112 folder_entry->content_url().spec().c_str()); 110 EXPECT_EQ("application/atom+xml;type=feed",
113 EXPECT_STREQ("application/atom+xml;type=feed", 111 folder_entry->content_mime_type());
114 folder_entry->content_mime_type().c_str());
115 112
116 ASSERT_EQ(1U, folder_entry->feed_links()->size()); 113 ASSERT_EQ(1U, folder_entry->feed_links().size());
117 const FeedLink* feed_link = folder_entry->feed_links()[0]; 114 const FeedLink* feed_link = folder_entry->feed_links()[0];
118 ASSERT_TRUE(feed_link); 115 ASSERT_TRUE(feed_link);
119 ASSERT_EQ(gdata::FeedLink::ACL, feed_link->type()); 116 ASSERT_EQ(gdata::FeedLink::ACL, feed_link->type());
120 117
121 const Link* entry1_alternate_link = 118 const Link* entry1_alternate_link =
122 folder_entry->GetLinkByType(gdata::Link::ALTERNATE); 119 folder_entry->GetLinkByType(gdata::Link::ALTERNATE);
123 ASSERT_TRUE(entry1_alternate_link); 120 ASSERT_TRUE(entry1_alternate_link);
124 EXPECT_STREQ("https://1_folder_alternate_link/", 121 EXPECT_EQ("https://1_folder_alternate_link/",
125 entry1_alternate_link->href().spec().c_str()); 122 entry1_alternate_link->href().spec());
126 EXPECT_STREQ("text/html", entry1_alternate_link->mime_type().c_str()); 123 EXPECT_EQ("text/html", entry1_alternate_link->mime_type());
127 124
128 const Link* entry1_edit_link = 125 const Link* entry1_edit_link =
129 folder_entry->GetLinkByType(gdata::Link::EDIT); 126 folder_entry->GetLinkByType(gdata::Link::EDIT);
130 ASSERT_TRUE(entry1_edit_link); 127 ASSERT_TRUE(entry1_edit_link);
131 EXPECT_STREQ("https://1_edit_link/", 128 EXPECT_EQ("https://1_edit_link/", entry1_edit_link->href().spec());
132 entry1_edit_link->href().spec().c_str()); 129 EXPECT_EQ("application/atom+xml", entry1_edit_link->mime_type());
133 EXPECT_STREQ("application/atom+xml",
134 entry1_edit_link->mime_type().c_str());
135 130
136 // Check a file entry. 131 // Check a file entry.
137 const DocumentEntry* file_entry = feed->entries()[1]; 132 const DocumentEntry* file_entry = feed->entries()[1];
138 ASSERT_TRUE(file_entry); 133 ASSERT_TRUE(file_entry);
139 EXPECT_EQ(gdata::DocumentEntry::FILE, file_entry->kind()); 134 EXPECT_EQ(gdata::DocumentEntry::FILE, file_entry->kind());
140 EXPECT_EQ(ASCIIToUTF16("filename.m4a"), file_entry->filename()); 135 EXPECT_EQ(ASCIIToUTF16("filename.m4a"), file_entry->filename());
141 EXPECT_EQ(ASCIIToUTF16("sugg_file_name.m4a"), 136 EXPECT_EQ(ASCIIToUTF16("sugg_file_name.m4a"),
142 file_entry->suggested_filename()); 137 file_entry->suggested_filename());
143 EXPECT_STREQ("3b4382ebefec6e743578c76bbd0575ce", 138 EXPECT_EQ("3b4382ebefec6e743578c76bbd0575ce", file_entry->file_md5());
144 file_entry->file_md5().c_str());
145 EXPECT_EQ(892721, file_entry->file_size()); 139 EXPECT_EQ(892721, file_entry->file_size());
146 const Link* file_parent_link = 140 const Link* file_parent_link =
147 file_entry->GetLinkByType(gdata::Link::PARENT); 141 file_entry->GetLinkByType(gdata::Link::PARENT);
148 ASSERT_TRUE(file_parent_link); 142 ASSERT_TRUE(file_parent_link);
149 EXPECT_STREQ("https://file_link_parent/", 143 EXPECT_EQ("https://file_link_parent/", file_parent_link->href().spec());
150 file_parent_link->href().spec().c_str()); 144 EXPECT_EQ("application/atom+xml", file_parent_link->mime_type());
151 EXPECT_STREQ("application/atom+xml", file_parent_link->mime_type().c_str());
152 EXPECT_EQ(ASCIIToUTF16("Medical"), file_parent_link->title()); 145 EXPECT_EQ(ASCIIToUTF16("Medical"), file_parent_link->title());
153 146
154 // Check a file entry. 147 // Check a file entry.
155 const DocumentEntry* document_entry = feed->entries()[2]; 148 const DocumentEntry* document_entry = feed->entries()[2];
156 ASSERT_TRUE(document_entry); 149 ASSERT_TRUE(document_entry);
157 EXPECT_EQ(gdata::DocumentEntry::DOCUMENT, document_entry->kind()); 150 EXPECT_EQ(gdata::DocumentEntry::DOCUMENT, document_entry->kind());
158 } 151 }
159
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/gdata/gdata_parser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698