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

Side by Side Diff: chrome/browser/google_apis/drive_api_operations_unittest.cc

Issue 12090015: Implement CreateDirectoryOperation on Drive API v2. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Add an empty line. 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/bind.h" 5 #include "base/bind.h"
6 #include "base/file_path.h" 6 #include "base/file_path.h"
7 #include "base/message_loop_proxy.h" 7 #include "base/message_loop_proxy.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "chrome/browser/google_apis/drive_api_operations.h" 9 #include "chrome/browser/google_apis/drive_api_operations.h"
10 #include "chrome/browser/google_apis/drive_api_url_generator.h" 10 #include "chrome/browser/google_apis/drive_api_url_generator.h"
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); 136 base::Bind(&test_util::DoNothingForReAuthenticateCallback));
137 MessageLoop::current()->Run(); 137 MessageLoop::current()->Run();
138 138
139 // "parse error" should be returned, and the feed should be NULL. 139 // "parse error" should be returned, and the feed should be NULL.
140 EXPECT_EQ(GDATA_PARSE_ERROR, error); 140 EXPECT_EQ(GDATA_PARSE_ERROR, error);
141 EXPECT_EQ(test_server::METHOD_GET, http_request_.method); 141 EXPECT_EQ(test_server::METHOD_GET, http_request_.method);
142 EXPECT_EQ("/drive/v2/about", http_request_.relative_url); 142 EXPECT_EQ("/drive/v2/about", http_request_.relative_url);
143 EXPECT_FALSE(feed_data.get()); 143 EXPECT_FALSE(feed_data.get());
144 } 144 }
145 145
146 TEST_F(DriveApiOperationsTest, CreateDirectoryOperation) {
147 // Set an expected data file containing the directory's entry data.
148 expected_data_file_path_ =
149 test_util::GetTestFilePath("drive/directory_entry.json");
150
151 GDataErrorCode error = GDATA_OTHER_ERROR;
152 scoped_ptr<base::Value> feed_data;
153
154 // Create "new directory" in the root directory.
155 drive::CreateDirectoryOperation* operation =
156 new drive::CreateDirectoryOperation(
157 &operation_registry_,
158 request_context_getter_.get(),
159 *url_generator_,
160 "root",
161 "new directory",
162 base::Bind(&test_util::CopyResultsFromGetDataCallbackAndQuit,
163 &error, &feed_data));
164 operation->Start(kTestDriveApiAuthToken, kTestUserAgent,
165 base::Bind(&test_util::DoNothingForReAuthenticateCallback));
166 MessageLoop::current()->Run();
167
168 EXPECT_EQ(HTTP_SUCCESS, error);
169 EXPECT_EQ(test_server::METHOD_POST, http_request_.method);
170 EXPECT_EQ("/drive/v2/files", http_request_.relative_url);
171 EXPECT_EQ("application/json", http_request_.headers["Content-Type"]);
172
173 EXPECT_TRUE(http_request_.has_content);
174
175 EXPECT_EQ("{\"mimeType\":\"application/vnd.google-apps.folder\","
176 "\"parents\":[{\"id\":\"root\"}],"
177 "\"title\":\"new directory\"}",
178 http_request_.content);
179 }
180
146 } // namespace google_apis 181 } // namespace google_apis
OLDNEW
« 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