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

Unified Diff: chrome/browser/chromeos/gdata/drive_api_parser_unittest.cc

Issue 10829056: Add FileResource/FileList parser. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix for comments. Created 8 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/chromeos/gdata/drive_api_parser.cc ('k') | chrome/test/data/chromeos/drive/filelist.json » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/gdata/drive_api_parser_unittest.cc
diff --git a/chrome/browser/chromeos/gdata/drive_api_parser_unittest.cc b/chrome/browser/chromeos/gdata/drive_api_parser_unittest.cc
index aafbcfe54931c4b4b11c598ef6c694d31fbbeffa..0ac5f80106807f17aada41826d93a26d4ba090c5 100644
--- a/chrome/browser/chromeos/gdata/drive_api_parser_unittest.cc
+++ b/chrome/browser/chromeos/gdata/drive_api_parser_unittest.cc
@@ -11,6 +11,7 @@
#include "base/utf_string_conversions.h"
#include "base/values.h"
#include "chrome/browser/chromeos/gdata/drive_api_parser.h"
+#include "chrome/browser/chromeos/gdata/gdata_util.h"
#include "chrome/common/chrome_paths.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -155,4 +156,59 @@ TEST_F(DriveAPIParserTest, AppListParser) {
}
}
+// Test file list parsing.
+TEST_F(DriveAPIParserTest, FileListParser) {
+ std::string error;
+ scoped_ptr<Value> document(LoadJSONFile("filelist.json"));
+ ASSERT_TRUE(document.get());
+
+ ASSERT_EQ(Value::TYPE_DICTIONARY, document->GetType());
+ scoped_ptr<FileList> filelist(new FileList);
+ EXPECT_TRUE(filelist->Parse(*document));
+
+ EXPECT_EQ("\"WtRjAPZWbDA7_fkFjc5ojsEvDEF/zyHTfoHpnRHovyi8bWpwK0DXABC\"",
+ filelist->etag());
+ EXPECT_EQ("EAIaggELEgA6egpi96It9mH_____f_8AAP__AAD_okhU-cHLz83KzszMxsjMzs_Ry"
+ "NGJnridyrbHs7u9tv8AAP__AP7__n__AP8AokhU-cHLz83KzszMxsjMzs_RyNGJnr"
+ "idyrbHs7u9tv8A__4QZCEiXPTi_wtIgTkAAAAAngnSXUgCDEAAIgsJPgart10AAAA"
+ "ABC", filelist->next_page_token());
+ EXPECT_EQ(GURL("https://www.googleapis.com/drive/v2/files?pageToken=EAIaggEL"
+ "EgA6egpi96It9mH_____f_8AAP__AAD_okhU-cHLz83KzszMxsjMzs_RyNGJ"
+ "nridyrbHs7u9tv8AAP__AP7__n__AP8AokhU-cHLz83KzszMxsjMzs_RyNGJ"
+ "nridyrbHs7u9tv8A__4QZCEiXPTi_wtIgTkAAAAAngnSXUgCDEAAIgsJPgar"
+ "t10AAAAABC"), filelist->next_link());
+
+ IF_EXPECT_EQ(3U, filelist->items().size()) {
satorux1 2012/07/30 16:34:33 ASSERT_EQ(3U, filelist->items().size()); IF_EXPEC
kochi 2012/07/31 08:07:58 Done. I copied the macro from gdata_wapi_parser_u
satorux1 2012/08/01 04:35:45 Could you also remove these IF_ macros from gdata
+ // Check file 1 (a file)
+ const FileResource& file1 = *filelist->items()[0];
+ EXPECT_EQ("0B4v7G8yEYAWHUmRrU2lMS2hLABC", file1.id());
+ EXPECT_EQ("\"WtRjAPZWbDA7_fkFjc5ojsEvDEF/MTM0MzM2NzgwMDIXYZ\"",
+ file1.etag());
+ EXPECT_EQ("My first file data", file1.title());
+ EXPECT_EQ("application/octet-stream", file1.mime_type());
+
+ base::Time modified_time;
+ ASSERT_TRUE(gdata::util::GetTimeFromString("2012-07-27T05:43:20.269Z",
+ &modified_time));
+ EXPECT_EQ(modified_time, file1.modified_by_me_date());
+ EXPECT_EQ(GURL("https://www.example.com/download"), file1.download_url());
+ EXPECT_EQ("ext", file1.file_extension());
+ EXPECT_EQ("d41d8cd98f00b204e9800998ecf8427e", file1.md5_checksum());
+ EXPECT_EQ(1000U, file1.file_size());
+
+ // Check file 2 (a Google Document)
+ const FileResource& file2 = *filelist->items()[1];
+ EXPECT_EQ("Test Google Document", file2.title());
+ EXPECT_EQ("application/vnd.google-apps.document", file2.mime_type());
+ EXPECT_EQ(0U, file2.file_size());
+
+ // Check file 3 (a folder)
+ const FileResource& file3 = *filelist->items()[2];
+ EXPECT_EQ(0U, file3.file_size());
+ EXPECT_EQ("TestFolder", file3.title());
+ EXPECT_EQ("application/vnd.google-apps.folder", file3.mime_type());
+ ASSERT_TRUE(file3.IsFolder());
+ }
+}
+
} // namespace gdata
« no previous file with comments | « chrome/browser/chromeos/gdata/drive_api_parser.cc ('k') | chrome/test/data/chromeos/drive/filelist.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698