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

Unified Diff: chrome/browser/google_apis/drive_api_operations_unittest.cc

Issue 12387021: Move the responsibility to convert from JSON to FileResource into drive_api_operations. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Minor fix to address review comments. Created 7 years, 10 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/google_apis/drive_api_operations.cc ('k') | chrome/browser/google_apis/drive_api_service.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/google_apis/drive_api_operations_unittest.cc
diff --git a/chrome/browser/google_apis/drive_api_operations_unittest.cc b/chrome/browser/google_apis/drive_api_operations_unittest.cc
index 1c644bb3d7f29b0c72b34fec8414e6e51c857936..c504848b0bca0ddf3168965a643dc270378b1b3d 100644
--- a/chrome/browser/google_apis/drive_api_operations_unittest.cc
+++ b/chrome/browser/google_apis/drive_api_operations_unittest.cc
@@ -43,6 +43,16 @@ void CopyResultsFromGetAboutResourceCallbackAndQuit(
MessageLoop::current()->Quit();
}
+void CopyResultsFromFileResourceCallbackAndQuit(
+ GDataErrorCode* error_out,
+ scoped_ptr<FileResource>* file_resource_out,
+ const GDataErrorCode error_in,
+ scoped_ptr<FileResource> file_resource_in) {
+ *error_out = error_in;
+ *file_resource_out = file_resource_in.Pass();
+ MessageLoop::current()->Quit();
+}
+
} // namespace
class DriveApiOperationsTest : public testing::Test {
@@ -229,7 +239,7 @@ TEST_F(DriveApiOperationsTest, CreateDirectoryOperation) {
test_util::GetTestFilePath("drive/directory_entry.json");
GDataErrorCode error = GDATA_OTHER_ERROR;
- scoped_ptr<base::Value> feed_data;
+ scoped_ptr<FileResource> feed_data;
// Create "new directory" in the root directory.
drive::CreateDirectoryOperation* operation =
@@ -239,7 +249,7 @@ TEST_F(DriveApiOperationsTest, CreateDirectoryOperation) {
*url_generator_,
"root",
"new directory",
- base::Bind(&test_util::CopyResultsFromGetDataCallbackAndQuit,
+ base::Bind(&CopyResultsFromFileResourceCallbackAndQuit,
&error, &feed_data));
operation->Start(kTestDriveApiAuthToken, kTestUserAgent,
base::Bind(&test_util::DoNothingForReAuthenticateCallback));
@@ -252,10 +262,17 @@ TEST_F(DriveApiOperationsTest, CreateDirectoryOperation) {
EXPECT_TRUE(http_request_.has_content);
- EXPECT_EQ("{\"mimeType\":\"application/vnd.google-apps.folder\","
- "\"parents\":[{\"id\":\"root\"}],"
- "\"title\":\"new directory\"}",
- http_request_.content);
+ scoped_ptr<FileResource> expected(
+ FileResource::CreateFrom(
+ *test_util::LoadJSONFile("drive/directory_entry.json")));
+
+ // Sanity check.
+ ASSERT_TRUE(feed_data.get());
+
+ EXPECT_EQ(expected->file_id(), feed_data->file_id());
+ EXPECT_EQ(expected->title(), feed_data->title());
+ EXPECT_EQ(expected->mime_type(), feed_data->mime_type());
+ EXPECT_EQ(expected->parents().size(), feed_data->parents().size());
}
TEST_F(DriveApiOperationsTest, RenameResourceOperation) {
« no previous file with comments | « chrome/browser/google_apis/drive_api_operations.cc ('k') | chrome/browser/google_apis/drive_api_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698