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

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: . 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
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..70489397c516a7a7287745c10137839e04d3f332 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,53 @@ 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());
+
+ // TODO(kochi): Test next_page_token() and next_link() after figuring out
+ // how they look like.
+
+ IF_EXPECT_EQ(3U, filelist->items().size()) {
+ // 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

Powered by Google App Engine
This is Rietveld 408576698