OLD | NEW |
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/files/file_path.h" | 6 #include "base/files/file_path.h" |
7 #include "base/message_loop_proxy.h" | 7 #include "base/message_loop_proxy.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "chrome/browser/google_apis/drive_api_operations.h" | 10 #include "chrome/browser/google_apis/drive_api_operations.h" |
11 #include "chrome/browser/google_apis/drive_api_parser.h" | 11 #include "chrome/browser/google_apis/drive_api_parser.h" |
12 #include "chrome/browser/google_apis/drive_api_url_generator.h" | 12 #include "chrome/browser/google_apis/drive_api_url_generator.h" |
13 #include "chrome/browser/google_apis/operation_registry.h" | 13 #include "chrome/browser/google_apis/operation_registry.h" |
14 #include "chrome/browser/google_apis/task_util.h" | 14 #include "chrome/browser/google_apis/task_util.h" |
15 #include "chrome/browser/google_apis/test_util.h" | 15 #include "chrome/browser/google_apis/test_util.h" |
16 #include "content/public/test/test_browser_thread.h" | 16 #include "content/public/test/test_browser_thread.h" |
| 17 #include "net/test/embedded_test_server/embedded_test_server.h" |
17 #include "net/test/embedded_test_server/http_request.h" | 18 #include "net/test/embedded_test_server/http_request.h" |
18 #include "net/test/embedded_test_server/http_response.h" | 19 #include "net/test/embedded_test_server/http_response.h" |
19 #include "net/test/embedded_test_server/http_server.h" | |
20 #include "net/url_request/url_request_test_util.h" | 20 #include "net/url_request/url_request_test_util.h" |
21 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
22 | 22 |
23 namespace google_apis { | 23 namespace google_apis { |
24 | 24 |
25 namespace { | 25 namespace { |
26 | 26 |
27 const char kTestDriveApiAuthToken[] = "testtoken"; | 27 const char kTestDriveApiAuthToken[] = "testtoken"; |
28 const char kTestETag[] = "test_etag"; | 28 const char kTestETag[] = "test_etag"; |
29 const char kTestUserAgent[] = "test-user-agent"; | 29 const char kTestUserAgent[] = "test-user-agent"; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 virtual void TearDown() OVERRIDE { | 88 virtual void TearDown() OVERRIDE { |
89 EXPECT_TRUE(test_server_.ShutdownAndWaitUntilComplete()); | 89 EXPECT_TRUE(test_server_.ShutdownAndWaitUntilComplete()); |
90 request_context_getter_ = NULL; | 90 request_context_getter_ = NULL; |
91 ResetExpectedResponse(); | 91 ResetExpectedResponse(); |
92 } | 92 } |
93 | 93 |
94 MessageLoopForUI message_loop_; | 94 MessageLoopForUI message_loop_; |
95 content::TestBrowserThread ui_thread_; | 95 content::TestBrowserThread ui_thread_; |
96 content::TestBrowserThread file_thread_; | 96 content::TestBrowserThread file_thread_; |
97 content::TestBrowserThread io_thread_; | 97 content::TestBrowserThread io_thread_; |
98 test_server::HttpServer test_server_; | 98 net::test_server::EmbeddedTestServer test_server_; |
99 OperationRegistry operation_registry_; | 99 OperationRegistry operation_registry_; |
100 scoped_ptr<DriveApiUrlGenerator> url_generator_; | 100 scoped_ptr<DriveApiUrlGenerator> url_generator_; |
101 scoped_refptr<net::TestURLRequestContextGetter> request_context_getter_; | 101 scoped_refptr<net::TestURLRequestContextGetter> request_context_getter_; |
102 | 102 |
103 // This is a path to the file which contains expected response from | 103 // This is a path to the file which contains expected response from |
104 // the server. See also HandleDataFileRequest below. | 104 // the server. See also HandleDataFileRequest below. |
105 base::FilePath expected_data_file_path_; | 105 base::FilePath expected_data_file_path_; |
106 | 106 |
107 // This is a path string in the expected response header from the server | 107 // This is a path string in the expected response header from the server |
108 // for initiating file uploading. | 108 // for initiating file uploading. |
109 std::string expected_upload_path_; | 109 std::string expected_upload_path_; |
110 | 110 |
111 // These are content and its type in the expected response from the server. | 111 // These are content and its type in the expected response from the server. |
112 // See also HandleContentResponse below. | 112 // See also HandleContentResponse below. |
113 std::string expected_content_type_; | 113 std::string expected_content_type_; |
114 std::string expected_content_; | 114 std::string expected_content_; |
115 | 115 |
116 // The incoming HTTP request is saved so tests can verify the request | 116 // The incoming HTTP request is saved so tests can verify the request |
117 // parameters like HTTP method (ex. some operations should use DELETE | 117 // parameters like HTTP method (ex. some operations should use DELETE |
118 // instead of GET). | 118 // instead of GET). |
119 test_server::HttpRequest http_request_; | 119 net::test_server::HttpRequest http_request_; |
120 | 120 |
121 private: | 121 private: |
122 void ResetExpectedResponse() { | 122 void ResetExpectedResponse() { |
123 expected_data_file_path_.clear(); | 123 expected_data_file_path_.clear(); |
124 expected_upload_path_.clear(); | 124 expected_upload_path_.clear(); |
125 expected_content_type_.clear(); | 125 expected_content_type_.clear(); |
126 expected_content_.clear(); | 126 expected_content_.clear(); |
127 } | 127 } |
128 | 128 |
129 // For "Children: delete" request, the server will return "204 No Content" | 129 // For "Children: delete" request, the server will return "204 No Content" |
130 // response meaning "success". | 130 // response meaning "success". |
131 scoped_ptr<test_server::HttpResponse> HandleChildrenDeleteRequest( | 131 scoped_ptr<net::test_server::HttpResponse> HandleChildrenDeleteRequest( |
132 const test_server::HttpRequest& request) { | 132 const net::test_server::HttpRequest& request) { |
133 if (request.method != test_server::METHOD_DELETE || | 133 if (request.method != net::test_server::METHOD_DELETE || |
134 request.relative_url.find("/children/") == string::npos) { | 134 request.relative_url.find("/children/") == string::npos) { |
135 // The request is not the "Children: delete" operation. Delegate the | 135 // The request is not the "Children: delete" operation. Delegate the |
136 // processing to the next handler. | 136 // processing to the next handler. |
137 return scoped_ptr<test_server::HttpResponse>(); | 137 return scoped_ptr<net::test_server::HttpResponse>(); |
138 } | 138 } |
139 | 139 |
140 http_request_ = request; | 140 http_request_ = request; |
141 | 141 |
142 // Return the response with just "204 No Content" status code. | 142 // Return the response with just "204 No Content" status code. |
143 scoped_ptr<test_server::HttpResponse> http_response( | 143 scoped_ptr<net::test_server::HttpResponse> http_response( |
144 new test_server::HttpResponse); | 144 new net::test_server::HttpResponse); |
145 http_response->set_code(test_server::NO_CONTENT); | 145 http_response->set_code(net::test_server::NO_CONTENT); |
146 return http_response.Pass(); | 146 return http_response.Pass(); |
147 } | 147 } |
148 | 148 |
149 // Reads the data file of |expected_data_file_path_| and returns its content | 149 // Reads the data file of |expected_data_file_path_| and returns its content |
150 // for the request. | 150 // for the request. |
151 // To use this method, it is necessary to set |expected_data_file_path_| | 151 // To use this method, it is necessary to set |expected_data_file_path_| |
152 // to the appropriate file path before sending the request to the server. | 152 // to the appropriate file path before sending the request to the server. |
153 scoped_ptr<test_server::HttpResponse> HandleDataFileRequest( | 153 scoped_ptr<net::test_server::HttpResponse> HandleDataFileRequest( |
154 const test_server::HttpRequest& request) { | 154 const net::test_server::HttpRequest& request) { |
155 if (expected_data_file_path_.empty()) { | 155 if (expected_data_file_path_.empty()) { |
156 // The file is not specified. Delegate the processing to the next | 156 // The file is not specified. Delegate the processing to the next |
157 // handler. | 157 // handler. |
158 return scoped_ptr<test_server::HttpResponse>(); | 158 return scoped_ptr<net::test_server::HttpResponse>(); |
159 } | 159 } |
160 | 160 |
161 http_request_ = request; | 161 http_request_ = request; |
162 | 162 |
163 // Return the response from the data file. | 163 // Return the response from the data file. |
164 return test_util::CreateHttpResponseFromFile(expected_data_file_path_); | 164 return test_util::CreateHttpResponseFromFile(expected_data_file_path_); |
165 } | 165 } |
166 | 166 |
167 // Returns the response based on set expected upload url. | 167 // Returns the response based on set expected upload url. |
168 // The response contains the url in its "Location: " header. Also, it doesn't | 168 // The response contains the url in its "Location: " header. Also, it doesn't |
169 // have any content. | 169 // have any content. |
170 // To use this method, it is necessary to set |expected_upload_path_| | 170 // To use this method, it is necessary to set |expected_upload_path_| |
171 // to the string representation of the url to be returned. | 171 // to the string representation of the url to be returned. |
172 scoped_ptr<test_server::HttpResponse> HandleInitiateUploadRequest( | 172 scoped_ptr<net::test_server::HttpResponse> HandleInitiateUploadRequest( |
173 const test_server::HttpRequest& request) { | 173 const net::test_server::HttpRequest& request) { |
174 if (request.relative_url == expected_upload_path_ || | 174 if (request.relative_url == expected_upload_path_ || |
175 expected_upload_path_.empty()) { | 175 expected_upload_path_.empty()) { |
176 // The request is for resume uploading or the expected upload url is not | 176 // The request is for resume uploading or the expected upload url is not |
177 // set. Delegate the processing to the next handler. | 177 // set. Delegate the processing to the next handler. |
178 return scoped_ptr<test_server::HttpResponse>(); | 178 return scoped_ptr<net::test_server::HttpResponse>(); |
179 } | 179 } |
180 | 180 |
181 http_request_ = request; | 181 http_request_ = request; |
182 | 182 |
183 scoped_ptr<test_server::HttpResponse> response( | 183 scoped_ptr<net::test_server::HttpResponse> response( |
184 new test_server::HttpResponse); | 184 new net::test_server::HttpResponse); |
185 | 185 |
186 // Check an ETag. | 186 // Check an ETag. |
187 std::map<std::string, std::string>::const_iterator found = | 187 std::map<std::string, std::string>::const_iterator found = |
188 request.headers.find("If-Match"); | 188 request.headers.find("If-Match"); |
189 if (found != request.headers.end() && | 189 if (found != request.headers.end() && |
190 found->second != "*" && | 190 found->second != "*" && |
191 found->second != kTestETag) { | 191 found->second != kTestETag) { |
192 response->set_code(test_server::PRECONDITION); | 192 response->set_code(net::test_server::PRECONDITION); |
193 return response.Pass(); | 193 return response.Pass(); |
194 } | 194 } |
195 | 195 |
196 // Check if the X-Upload-Content-Length is present. If yes, store the | 196 // Check if the X-Upload-Content-Length is present. If yes, store the |
197 // length of the file. | 197 // length of the file. |
198 found = request.headers.find("X-Upload-Content-Length"); | 198 found = request.headers.find("X-Upload-Content-Length"); |
199 if (found == request.headers.end() || | 199 if (found == request.headers.end() || |
200 !base::StringToInt64(found->second, &content_length_)) { | 200 !base::StringToInt64(found->second, &content_length_)) { |
201 return scoped_ptr<test_server::HttpResponse>(); | 201 return scoped_ptr<net::test_server::HttpResponse>(); |
202 } | 202 } |
203 received_bytes_ = 0; | 203 received_bytes_ = 0; |
204 | 204 |
205 response->set_code(test_server::SUCCESS); | 205 response->set_code(net::test_server::SUCCESS); |
206 response->AddCustomHeader( | 206 response->AddCustomHeader( |
207 "Location", | 207 "Location", |
208 test_server_.base_url().Resolve(expected_upload_path_).spec()); | 208 test_server_.base_url().Resolve(expected_upload_path_).spec()); |
209 return response.Pass(); | 209 return response.Pass(); |
210 } | 210 } |
211 | 211 |
212 scoped_ptr<test_server::HttpResponse> HandleResumeUploadRequest( | 212 scoped_ptr<net::test_server::HttpResponse> HandleResumeUploadRequest( |
213 const test_server::HttpRequest& request) { | 213 const net::test_server::HttpRequest& request) { |
214 if (request.relative_url != expected_upload_path_) { | 214 if (request.relative_url != expected_upload_path_) { |
215 // The request path is different from the expected path for uploading. | 215 // The request path is different from the expected path for uploading. |
216 // Delegate the processing to the next handler. | 216 // Delegate the processing to the next handler. |
217 return scoped_ptr<test_server::HttpResponse>(); | 217 return scoped_ptr<net::test_server::HttpResponse>(); |
218 } | 218 } |
219 | 219 |
220 http_request_ = request; | 220 http_request_ = request; |
221 | 221 |
222 if (!request.content.empty()) { | 222 if (!request.content.empty()) { |
223 std::map<std::string, std::string>::const_iterator iter = | 223 std::map<std::string, std::string>::const_iterator iter = |
224 request.headers.find("Content-Range"); | 224 request.headers.find("Content-Range"); |
225 if (iter == request.headers.end()) { | 225 if (iter == request.headers.end()) { |
226 // The range must be set. | 226 // The range must be set. |
227 return scoped_ptr<test_server::HttpResponse>(); | 227 return scoped_ptr<net::test_server::HttpResponse>(); |
228 } | 228 } |
229 | 229 |
230 int64 length = 0; | 230 int64 length = 0; |
231 int64 start_position = 0; | 231 int64 start_position = 0; |
232 int64 end_position = 0; | 232 int64 end_position = 0; |
233 if (!test_util::ParseContentRangeHeader( | 233 if (!test_util::ParseContentRangeHeader( |
234 iter->second, &start_position, &end_position, &length)) { | 234 iter->second, &start_position, &end_position, &length)) { |
235 // Invalid "Content-Range" value. | 235 // Invalid "Content-Range" value. |
236 return scoped_ptr<test_server::HttpResponse>(); | 236 return scoped_ptr<net::test_server::HttpResponse>(); |
237 } | 237 } |
238 | 238 |
239 EXPECT_EQ(start_position, received_bytes_); | 239 EXPECT_EQ(start_position, received_bytes_); |
240 EXPECT_EQ(length, content_length_); | 240 EXPECT_EQ(length, content_length_); |
241 | 241 |
242 // end_position is inclusive, but so +1 to change the range to byte size. | 242 // end_position is inclusive, but so +1 to change the range to byte size. |
243 received_bytes_ = end_position + 1; | 243 received_bytes_ = end_position + 1; |
244 } | 244 } |
245 | 245 |
246 if (received_bytes_ < content_length_) { | 246 if (received_bytes_ < content_length_) { |
247 scoped_ptr<test_server::HttpResponse> response( | 247 scoped_ptr<net::test_server::HttpResponse> response( |
248 new test_server::HttpResponse); | 248 new net::test_server::HttpResponse); |
249 // Set RESUME INCOMPLETE (308) status code. | 249 // Set RESUME INCOMPLETE (308) status code. |
250 response->set_code(test_server::RESUME_INCOMPLETE); | 250 response->set_code(net::test_server::RESUME_INCOMPLETE); |
251 | 251 |
252 // Add Range header to the response, based on the values of | 252 // Add Range header to the response, based on the values of |
253 // Content-Range header in the request. | 253 // Content-Range header in the request. |
254 // The header is annotated only when at least one byte is received. | 254 // The header is annotated only when at least one byte is received. |
255 if (received_bytes_ > 0) { | 255 if (received_bytes_ > 0) { |
256 response->AddCustomHeader( | 256 response->AddCustomHeader( |
257 "Range", "bytes=0-" + base::Int64ToString(received_bytes_ - 1)); | 257 "Range", "bytes=0-" + base::Int64ToString(received_bytes_ - 1)); |
258 } | 258 } |
259 | 259 |
260 return response.Pass(); | 260 return response.Pass(); |
261 } | 261 } |
262 | 262 |
263 // All bytes are received. Return the "success" response with the file's | 263 // All bytes are received. Return the "success" response with the file's |
264 // (dummy) metadata. | 264 // (dummy) metadata. |
265 scoped_ptr<test_server::HttpResponse> response = | 265 scoped_ptr<net::test_server::HttpResponse> response = |
266 test_util::CreateHttpResponseFromFile( | 266 test_util::CreateHttpResponseFromFile( |
267 test_util::GetTestFilePath("chromeos/drive/file_entry.json")); | 267 test_util::GetTestFilePath("chromeos/drive/file_entry.json")); |
268 | 268 |
269 // The response code is CREATED if it is new file uploading. | 269 // The response code is CREATED if it is new file uploading. |
270 if (http_request_.relative_url == kTestUploadNewFilePath) { | 270 if (http_request_.relative_url == kTestUploadNewFilePath) { |
271 response->set_code(test_server::CREATED); | 271 response->set_code(net::test_server::CREATED); |
272 } | 272 } |
273 | 273 |
274 return response.Pass(); | 274 return response.Pass(); |
275 } | 275 } |
276 | 276 |
277 // Returns the response based on set expected content and its type. | 277 // Returns the response based on set expected content and its type. |
278 // To use this method, both |expected_content_type_| and |expected_content_| | 278 // To use this method, both |expected_content_type_| and |expected_content_| |
279 // must be set in advance. | 279 // must be set in advance. |
280 scoped_ptr<test_server::HttpResponse> HandleContentResponse( | 280 scoped_ptr<net::test_server::HttpResponse> HandleContentResponse( |
281 const test_server::HttpRequest& request) { | 281 const net::test_server::HttpRequest& request) { |
282 if (expected_content_type_.empty() || expected_content_.empty()) { | 282 if (expected_content_type_.empty() || expected_content_.empty()) { |
283 // Expected content is not set. Delegate the processing to the next | 283 // Expected content is not set. Delegate the processing to the next |
284 // handler. | 284 // handler. |
285 return scoped_ptr<test_server::HttpResponse>(); | 285 return scoped_ptr<net::test_server::HttpResponse>(); |
286 } | 286 } |
287 | 287 |
288 http_request_ = request; | 288 http_request_ = request; |
289 | 289 |
290 scoped_ptr<test_server::HttpResponse> response( | 290 scoped_ptr<net::test_server::HttpResponse> response( |
291 new test_server::HttpResponse); | 291 new net::test_server::HttpResponse); |
292 response->set_code(test_server::SUCCESS); | 292 response->set_code(net::test_server::SUCCESS); |
293 response->set_content_type(expected_content_type_); | 293 response->set_content_type(expected_content_type_); |
294 response->set_content(expected_content_); | 294 response->set_content(expected_content_); |
295 return response.Pass(); | 295 return response.Pass(); |
296 } | 296 } |
297 | 297 |
298 // These are for the current upload file status. | 298 // These are for the current upload file status. |
299 int64 received_bytes_; | 299 int64 received_bytes_; |
300 int64 content_length_; | 300 int64 content_length_; |
301 }; | 301 }; |
302 | 302 |
(...skipping 10 matching lines...) Expand all Loading... |
313 request_context_getter_.get(), | 313 request_context_getter_.get(), |
314 *url_generator_, | 314 *url_generator_, |
315 CreateComposedCallback( | 315 CreateComposedCallback( |
316 base::Bind(&test_util::RunAndQuit), | 316 base::Bind(&test_util::RunAndQuit), |
317 test_util::CreateCopyResultCallback(&error, &about_resource))); | 317 test_util::CreateCopyResultCallback(&error, &about_resource))); |
318 operation->Start(kTestDriveApiAuthToken, kTestUserAgent, | 318 operation->Start(kTestDriveApiAuthToken, kTestUserAgent, |
319 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 319 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
320 MessageLoop::current()->Run(); | 320 MessageLoop::current()->Run(); |
321 | 321 |
322 EXPECT_EQ(HTTP_SUCCESS, error); | 322 EXPECT_EQ(HTTP_SUCCESS, error); |
323 EXPECT_EQ(test_server::METHOD_GET, http_request_.method); | 323 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); |
324 EXPECT_EQ("/drive/v2/about", http_request_.relative_url); | 324 EXPECT_EQ("/drive/v2/about", http_request_.relative_url); |
325 | 325 |
326 scoped_ptr<AboutResource> expected( | 326 scoped_ptr<AboutResource> expected( |
327 AboutResource::CreateFrom( | 327 AboutResource::CreateFrom( |
328 *test_util::LoadJSONFile("chromeos/drive/about.json"))); | 328 *test_util::LoadJSONFile("chromeos/drive/about.json"))); |
329 ASSERT_TRUE(about_resource.get()); | 329 ASSERT_TRUE(about_resource.get()); |
330 EXPECT_EQ(expected->largest_change_id(), about_resource->largest_change_id()); | 330 EXPECT_EQ(expected->largest_change_id(), about_resource->largest_change_id()); |
331 EXPECT_EQ(expected->quota_bytes_total(), about_resource->quota_bytes_total()); | 331 EXPECT_EQ(expected->quota_bytes_total(), about_resource->quota_bytes_total()); |
332 EXPECT_EQ(expected->quota_bytes_used(), about_resource->quota_bytes_used()); | 332 EXPECT_EQ(expected->quota_bytes_used(), about_resource->quota_bytes_used()); |
333 EXPECT_EQ(expected->root_folder_id(), about_resource->root_folder_id()); | 333 EXPECT_EQ(expected->root_folder_id(), about_resource->root_folder_id()); |
(...skipping 13 matching lines...) Expand all Loading... |
347 *url_generator_, | 347 *url_generator_, |
348 CreateComposedCallback( | 348 CreateComposedCallback( |
349 base::Bind(&test_util::RunAndQuit), | 349 base::Bind(&test_util::RunAndQuit), |
350 test_util::CreateCopyResultCallback(&error, &about_resource))); | 350 test_util::CreateCopyResultCallback(&error, &about_resource))); |
351 operation->Start(kTestDriveApiAuthToken, kTestUserAgent, | 351 operation->Start(kTestDriveApiAuthToken, kTestUserAgent, |
352 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 352 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
353 MessageLoop::current()->Run(); | 353 MessageLoop::current()->Run(); |
354 | 354 |
355 // "parse error" should be returned, and the about resource should be NULL. | 355 // "parse error" should be returned, and the about resource should be NULL. |
356 EXPECT_EQ(GDATA_PARSE_ERROR, error); | 356 EXPECT_EQ(GDATA_PARSE_ERROR, error); |
357 EXPECT_EQ(test_server::METHOD_GET, http_request_.method); | 357 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); |
358 EXPECT_EQ("/drive/v2/about", http_request_.relative_url); | 358 EXPECT_EQ("/drive/v2/about", http_request_.relative_url); |
359 EXPECT_FALSE(about_resource.get()); | 359 EXPECT_FALSE(about_resource.get()); |
360 } | 360 } |
361 | 361 |
362 TEST_F(DriveApiOperationsTest, GetApplistOperation) { | 362 TEST_F(DriveApiOperationsTest, GetApplistOperation) { |
363 // Set an expected data file containing valid result. | 363 // Set an expected data file containing valid result. |
364 expected_data_file_path_ = test_util::GetTestFilePath( | 364 expected_data_file_path_ = test_util::GetTestFilePath( |
365 "chromeos/drive/applist.json"); | 365 "chromeos/drive/applist.json"); |
366 | 366 |
367 GDataErrorCode error = GDATA_OTHER_ERROR; | 367 GDataErrorCode error = GDATA_OTHER_ERROR; |
368 scoped_ptr<base::Value> result; | 368 scoped_ptr<base::Value> result; |
369 | 369 |
370 GetApplistOperation* operation = new GetApplistOperation( | 370 GetApplistOperation* operation = new GetApplistOperation( |
371 &operation_registry_, | 371 &operation_registry_, |
372 request_context_getter_.get(), | 372 request_context_getter_.get(), |
373 *url_generator_, | 373 *url_generator_, |
374 CreateComposedCallback( | 374 CreateComposedCallback( |
375 base::Bind(&test_util::RunAndQuit), | 375 base::Bind(&test_util::RunAndQuit), |
376 test_util::CreateCopyResultCallback(&error, &result))); | 376 test_util::CreateCopyResultCallback(&error, &result))); |
377 operation->Start(kTestDriveApiAuthToken, kTestUserAgent, | 377 operation->Start(kTestDriveApiAuthToken, kTestUserAgent, |
378 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 378 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
379 MessageLoop::current()->Run(); | 379 MessageLoop::current()->Run(); |
380 | 380 |
381 EXPECT_EQ(HTTP_SUCCESS, error); | 381 EXPECT_EQ(HTTP_SUCCESS, error); |
382 EXPECT_EQ(test_server::METHOD_GET, http_request_.method); | 382 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); |
383 EXPECT_EQ("/drive/v2/apps", http_request_.relative_url); | 383 EXPECT_EQ("/drive/v2/apps", http_request_.relative_url); |
384 EXPECT_TRUE(result); | 384 EXPECT_TRUE(result); |
385 } | 385 } |
386 | 386 |
387 TEST_F(DriveApiOperationsTest, GetChangelistOperation) { | 387 TEST_F(DriveApiOperationsTest, GetChangelistOperation) { |
388 // Set an expected data file containing valid result. | 388 // Set an expected data file containing valid result. |
389 expected_data_file_path_ = test_util::GetTestFilePath( | 389 expected_data_file_path_ = test_util::GetTestFilePath( |
390 "chromeos/drive/changelist.json"); | 390 "chromeos/drive/changelist.json"); |
391 | 391 |
392 GDataErrorCode error = GDATA_OTHER_ERROR; | 392 GDataErrorCode error = GDATA_OTHER_ERROR; |
393 scoped_ptr<base::Value> result; | 393 scoped_ptr<base::Value> result; |
394 | 394 |
395 GetChangelistOperation* operation = new GetChangelistOperation( | 395 GetChangelistOperation* operation = new GetChangelistOperation( |
396 &operation_registry_, | 396 &operation_registry_, |
397 request_context_getter_.get(), | 397 request_context_getter_.get(), |
398 *url_generator_, | 398 *url_generator_, |
399 true, // include deleted | 399 true, // include deleted |
400 100, // start changestamp | 400 100, // start changestamp |
401 500, // max results | 401 500, // max results |
402 CreateComposedCallback( | 402 CreateComposedCallback( |
403 base::Bind(&test_util::RunAndQuit), | 403 base::Bind(&test_util::RunAndQuit), |
404 test_util::CreateCopyResultCallback(&error, &result))); | 404 test_util::CreateCopyResultCallback(&error, &result))); |
405 operation->Start(kTestDriveApiAuthToken, kTestUserAgent, | 405 operation->Start(kTestDriveApiAuthToken, kTestUserAgent, |
406 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 406 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
407 MessageLoop::current()->Run(); | 407 MessageLoop::current()->Run(); |
408 | 408 |
409 EXPECT_EQ(HTTP_SUCCESS, error); | 409 EXPECT_EQ(HTTP_SUCCESS, error); |
410 EXPECT_EQ(test_server::METHOD_GET, http_request_.method); | 410 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); |
411 EXPECT_EQ("/drive/v2/changes?startChangeId=100&maxResults=500", | 411 EXPECT_EQ("/drive/v2/changes?startChangeId=100&maxResults=500", |
412 http_request_.relative_url); | 412 http_request_.relative_url); |
413 EXPECT_TRUE(result); | 413 EXPECT_TRUE(result); |
414 } | 414 } |
415 | 415 |
416 TEST_F(DriveApiOperationsTest, GetFilelistOperation) { | 416 TEST_F(DriveApiOperationsTest, GetFilelistOperation) { |
417 // Set an expected data file containing valid result. | 417 // Set an expected data file containing valid result. |
418 expected_data_file_path_ = test_util::GetTestFilePath( | 418 expected_data_file_path_ = test_util::GetTestFilePath( |
419 "chromeos/drive/filelist.json"); | 419 "chromeos/drive/filelist.json"); |
420 | 420 |
421 GDataErrorCode error = GDATA_OTHER_ERROR; | 421 GDataErrorCode error = GDATA_OTHER_ERROR; |
422 scoped_ptr<base::Value> result; | 422 scoped_ptr<base::Value> result; |
423 | 423 |
424 GetFilelistOperation* operation = new GetFilelistOperation( | 424 GetFilelistOperation* operation = new GetFilelistOperation( |
425 &operation_registry_, | 425 &operation_registry_, |
426 request_context_getter_.get(), | 426 request_context_getter_.get(), |
427 *url_generator_, | 427 *url_generator_, |
428 "\"abcde\" in parents", | 428 "\"abcde\" in parents", |
429 50, // max results | 429 50, // max results |
430 CreateComposedCallback( | 430 CreateComposedCallback( |
431 base::Bind(&test_util::RunAndQuit), | 431 base::Bind(&test_util::RunAndQuit), |
432 test_util::CreateCopyResultCallback(&error, &result))); | 432 test_util::CreateCopyResultCallback(&error, &result))); |
433 operation->Start(kTestDriveApiAuthToken, kTestUserAgent, | 433 operation->Start(kTestDriveApiAuthToken, kTestUserAgent, |
434 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 434 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
435 MessageLoop::current()->Run(); | 435 MessageLoop::current()->Run(); |
436 | 436 |
437 EXPECT_EQ(HTTP_SUCCESS, error); | 437 EXPECT_EQ(HTTP_SUCCESS, error); |
438 EXPECT_EQ(test_server::METHOD_GET, http_request_.method); | 438 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); |
439 EXPECT_EQ("/drive/v2/files?maxResults=50&q=%22abcde%22+in+parents", | 439 EXPECT_EQ("/drive/v2/files?maxResults=50&q=%22abcde%22+in+parents", |
440 http_request_.relative_url); | 440 http_request_.relative_url); |
441 EXPECT_TRUE(result); | 441 EXPECT_TRUE(result); |
442 } | 442 } |
443 | 443 |
444 TEST_F(DriveApiOperationsTest, ContinueGetFileListOperation) { | 444 TEST_F(DriveApiOperationsTest, ContinueGetFileListOperation) { |
445 // Set an expected data file containing valid result. | 445 // Set an expected data file containing valid result. |
446 expected_data_file_path_ = test_util::GetTestFilePath( | 446 expected_data_file_path_ = test_util::GetTestFilePath( |
447 "chromeos/drive/filelist.json"); | 447 "chromeos/drive/filelist.json"); |
448 | 448 |
449 GDataErrorCode error = GDATA_OTHER_ERROR; | 449 GDataErrorCode error = GDATA_OTHER_ERROR; |
450 scoped_ptr<base::Value> result; | 450 scoped_ptr<base::Value> result; |
451 | 451 |
452 drive::ContinueGetFileListOperation* operation = | 452 drive::ContinueGetFileListOperation* operation = |
453 new drive::ContinueGetFileListOperation( | 453 new drive::ContinueGetFileListOperation( |
454 &operation_registry_, | 454 &operation_registry_, |
455 request_context_getter_.get(), | 455 request_context_getter_.get(), |
456 test_server_.GetURL("/continue/get/file/list"), | 456 test_server_.GetURL("/continue/get/file/list"), |
457 CreateComposedCallback( | 457 CreateComposedCallback( |
458 base::Bind(&test_util::RunAndQuit), | 458 base::Bind(&test_util::RunAndQuit), |
459 test_util::CreateCopyResultCallback(&error, &result))); | 459 test_util::CreateCopyResultCallback(&error, &result))); |
460 operation->Start(kTestDriveApiAuthToken, kTestUserAgent, | 460 operation->Start(kTestDriveApiAuthToken, kTestUserAgent, |
461 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 461 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
462 MessageLoop::current()->Run(); | 462 MessageLoop::current()->Run(); |
463 | 463 |
464 EXPECT_EQ(HTTP_SUCCESS, error); | 464 EXPECT_EQ(HTTP_SUCCESS, error); |
465 EXPECT_EQ(test_server::METHOD_GET, http_request_.method); | 465 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); |
466 EXPECT_EQ("/continue/get/file/list", http_request_.relative_url); | 466 EXPECT_EQ("/continue/get/file/list", http_request_.relative_url); |
467 EXPECT_TRUE(result); | 467 EXPECT_TRUE(result); |
468 } | 468 } |
469 | 469 |
470 TEST_F(DriveApiOperationsTest, CreateDirectoryOperation) { | 470 TEST_F(DriveApiOperationsTest, CreateDirectoryOperation) { |
471 // Set an expected data file containing the directory's entry data. | 471 // Set an expected data file containing the directory's entry data. |
472 expected_data_file_path_ = | 472 expected_data_file_path_ = |
473 test_util::GetTestFilePath("chromeos/drive/directory_entry.json"); | 473 test_util::GetTestFilePath("chromeos/drive/directory_entry.json"); |
474 | 474 |
475 GDataErrorCode error = GDATA_OTHER_ERROR; | 475 GDataErrorCode error = GDATA_OTHER_ERROR; |
476 scoped_ptr<FileResource> file_resource; | 476 scoped_ptr<FileResource> file_resource; |
477 | 477 |
478 // Create "new directory" in the root directory. | 478 // Create "new directory" in the root directory. |
479 drive::CreateDirectoryOperation* operation = | 479 drive::CreateDirectoryOperation* operation = |
480 new drive::CreateDirectoryOperation( | 480 new drive::CreateDirectoryOperation( |
481 &operation_registry_, | 481 &operation_registry_, |
482 request_context_getter_.get(), | 482 request_context_getter_.get(), |
483 *url_generator_, | 483 *url_generator_, |
484 "root", | 484 "root", |
485 "new directory", | 485 "new directory", |
486 CreateComposedCallback( | 486 CreateComposedCallback( |
487 base::Bind(&test_util::RunAndQuit), | 487 base::Bind(&test_util::RunAndQuit), |
488 test_util::CreateCopyResultCallback(&error, &file_resource))); | 488 test_util::CreateCopyResultCallback(&error, &file_resource))); |
489 operation->Start(kTestDriveApiAuthToken, kTestUserAgent, | 489 operation->Start(kTestDriveApiAuthToken, kTestUserAgent, |
490 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 490 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
491 MessageLoop::current()->Run(); | 491 MessageLoop::current()->Run(); |
492 | 492 |
493 EXPECT_EQ(HTTP_SUCCESS, error); | 493 EXPECT_EQ(HTTP_SUCCESS, error); |
494 EXPECT_EQ(test_server::METHOD_POST, http_request_.method); | 494 EXPECT_EQ(net::test_server::METHOD_POST, http_request_.method); |
495 EXPECT_EQ("/drive/v2/files", http_request_.relative_url); | 495 EXPECT_EQ("/drive/v2/files", http_request_.relative_url); |
496 EXPECT_EQ("application/json", http_request_.headers["Content-Type"]); | 496 EXPECT_EQ("application/json", http_request_.headers["Content-Type"]); |
497 | 497 |
498 EXPECT_TRUE(http_request_.has_content); | 498 EXPECT_TRUE(http_request_.has_content); |
499 | 499 |
500 scoped_ptr<FileResource> expected( | 500 scoped_ptr<FileResource> expected( |
501 FileResource::CreateFrom( | 501 FileResource::CreateFrom( |
502 *test_util::LoadJSONFile("chromeos/drive/directory_entry.json"))); | 502 *test_util::LoadJSONFile("chromeos/drive/directory_entry.json"))); |
503 | 503 |
504 // Sanity check. | 504 // Sanity check. |
(...skipping 22 matching lines...) Expand all Loading... |
527 "resource_id", | 527 "resource_id", |
528 "new name", | 528 "new name", |
529 CreateComposedCallback( | 529 CreateComposedCallback( |
530 base::Bind(&test_util::RunAndQuit), | 530 base::Bind(&test_util::RunAndQuit), |
531 test_util::CreateCopyResultCallback(&error))); | 531 test_util::CreateCopyResultCallback(&error))); |
532 operation->Start(kTestDriveApiAuthToken, kTestUserAgent, | 532 operation->Start(kTestDriveApiAuthToken, kTestUserAgent, |
533 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 533 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
534 MessageLoop::current()->Run(); | 534 MessageLoop::current()->Run(); |
535 | 535 |
536 EXPECT_EQ(HTTP_SUCCESS, error); | 536 EXPECT_EQ(HTTP_SUCCESS, error); |
537 EXPECT_EQ(test_server::METHOD_PATCH, http_request_.method); | 537 EXPECT_EQ(net::test_server::METHOD_PATCH, http_request_.method); |
538 EXPECT_EQ("/drive/v2/files/resource_id", http_request_.relative_url); | 538 EXPECT_EQ("/drive/v2/files/resource_id", http_request_.relative_url); |
539 EXPECT_EQ("application/json", http_request_.headers["Content-Type"]); | 539 EXPECT_EQ("application/json", http_request_.headers["Content-Type"]); |
540 | 540 |
541 EXPECT_TRUE(http_request_.has_content); | 541 EXPECT_TRUE(http_request_.has_content); |
542 EXPECT_EQ("{\"title\":\"new name\"}", http_request_.content); | 542 EXPECT_EQ("{\"title\":\"new name\"}", http_request_.content); |
543 } | 543 } |
544 | 544 |
545 TEST_F(DriveApiOperationsTest, CopyResourceOperation) { | 545 TEST_F(DriveApiOperationsTest, CopyResourceOperation) { |
546 // Set an expected data file containing the dummy file entry data. | 546 // Set an expected data file containing the dummy file entry data. |
547 // It'd be returned if we copy a file. | 547 // It'd be returned if we copy a file. |
(...skipping 12 matching lines...) Expand all Loading... |
560 "resource_id", | 560 "resource_id", |
561 "new name", | 561 "new name", |
562 CreateComposedCallback( | 562 CreateComposedCallback( |
563 base::Bind(&test_util::RunAndQuit), | 563 base::Bind(&test_util::RunAndQuit), |
564 test_util::CreateCopyResultCallback(&error, &file_resource))); | 564 test_util::CreateCopyResultCallback(&error, &file_resource))); |
565 operation->Start(kTestDriveApiAuthToken, kTestUserAgent, | 565 operation->Start(kTestDriveApiAuthToken, kTestUserAgent, |
566 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 566 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
567 MessageLoop::current()->Run(); | 567 MessageLoop::current()->Run(); |
568 | 568 |
569 EXPECT_EQ(HTTP_SUCCESS, error); | 569 EXPECT_EQ(HTTP_SUCCESS, error); |
570 EXPECT_EQ(test_server::METHOD_POST, http_request_.method); | 570 EXPECT_EQ(net::test_server::METHOD_POST, http_request_.method); |
571 EXPECT_EQ("/drive/v2/files/resource_id/copy", http_request_.relative_url); | 571 EXPECT_EQ("/drive/v2/files/resource_id/copy", http_request_.relative_url); |
572 EXPECT_EQ("application/json", http_request_.headers["Content-Type"]); | 572 EXPECT_EQ("application/json", http_request_.headers["Content-Type"]); |
573 | 573 |
574 EXPECT_TRUE(http_request_.has_content); | 574 EXPECT_TRUE(http_request_.has_content); |
575 EXPECT_EQ("{\"title\":\"new name\"}", http_request_.content); | 575 EXPECT_EQ("{\"title\":\"new name\"}", http_request_.content); |
576 EXPECT_TRUE(file_resource); | 576 EXPECT_TRUE(file_resource); |
577 } | 577 } |
578 | 578 |
579 TEST_F(DriveApiOperationsTest, TrashResourceOperation) { | 579 TEST_F(DriveApiOperationsTest, TrashResourceOperation) { |
580 // Set data for the expected result. Directory entry should be returned | 580 // Set data for the expected result. Directory entry should be returned |
(...skipping 11 matching lines...) Expand all Loading... |
592 *url_generator_, | 592 *url_generator_, |
593 "resource_id", | 593 "resource_id", |
594 CreateComposedCallback( | 594 CreateComposedCallback( |
595 base::Bind(&test_util::RunAndQuit), | 595 base::Bind(&test_util::RunAndQuit), |
596 test_util::CreateCopyResultCallback(&error))); | 596 test_util::CreateCopyResultCallback(&error))); |
597 operation->Start(kTestDriveApiAuthToken, kTestUserAgent, | 597 operation->Start(kTestDriveApiAuthToken, kTestUserAgent, |
598 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 598 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
599 MessageLoop::current()->Run(); | 599 MessageLoop::current()->Run(); |
600 | 600 |
601 EXPECT_EQ(HTTP_SUCCESS, error); | 601 EXPECT_EQ(HTTP_SUCCESS, error); |
602 EXPECT_EQ(test_server::METHOD_POST, http_request_.method); | 602 EXPECT_EQ(net::test_server::METHOD_POST, http_request_.method); |
603 EXPECT_EQ("/drive/v2/files/resource_id/trash", http_request_.relative_url); | 603 EXPECT_EQ("/drive/v2/files/resource_id/trash", http_request_.relative_url); |
604 EXPECT_TRUE(http_request_.has_content); | 604 EXPECT_TRUE(http_request_.has_content); |
605 EXPECT_TRUE(http_request_.content.empty()); | 605 EXPECT_TRUE(http_request_.content.empty()); |
606 } | 606 } |
607 | 607 |
608 TEST_F(DriveApiOperationsTest, InsertResourceOperation) { | 608 TEST_F(DriveApiOperationsTest, InsertResourceOperation) { |
609 // Set an expected data file containing the children entry. | 609 // Set an expected data file containing the children entry. |
610 expected_content_type_ = "application/json"; | 610 expected_content_type_ = "application/json"; |
611 expected_content_ = kTestChildrenResponse; | 611 expected_content_ = kTestChildrenResponse; |
612 | 612 |
613 GDataErrorCode error = GDATA_OTHER_ERROR; | 613 GDataErrorCode error = GDATA_OTHER_ERROR; |
614 | 614 |
615 // Add a resource with "resource_id" to a directory with | 615 // Add a resource with "resource_id" to a directory with |
616 // "parent_resource_id". | 616 // "parent_resource_id". |
617 drive::InsertResourceOperation* operation = | 617 drive::InsertResourceOperation* operation = |
618 new drive::InsertResourceOperation( | 618 new drive::InsertResourceOperation( |
619 &operation_registry_, | 619 &operation_registry_, |
620 request_context_getter_.get(), | 620 request_context_getter_.get(), |
621 *url_generator_, | 621 *url_generator_, |
622 "parent_resource_id", | 622 "parent_resource_id", |
623 "resource_id", | 623 "resource_id", |
624 CreateComposedCallback( | 624 CreateComposedCallback( |
625 base::Bind(&test_util::RunAndQuit), | 625 base::Bind(&test_util::RunAndQuit), |
626 test_util::CreateCopyResultCallback(&error))); | 626 test_util::CreateCopyResultCallback(&error))); |
627 operation->Start(kTestDriveApiAuthToken, kTestUserAgent, | 627 operation->Start(kTestDriveApiAuthToken, kTestUserAgent, |
628 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 628 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
629 MessageLoop::current()->Run(); | 629 MessageLoop::current()->Run(); |
630 | 630 |
631 EXPECT_EQ(HTTP_SUCCESS, error); | 631 EXPECT_EQ(HTTP_SUCCESS, error); |
632 EXPECT_EQ(test_server::METHOD_POST, http_request_.method); | 632 EXPECT_EQ(net::test_server::METHOD_POST, http_request_.method); |
633 EXPECT_EQ("/drive/v2/files/parent_resource_id/children", | 633 EXPECT_EQ("/drive/v2/files/parent_resource_id/children", |
634 http_request_.relative_url); | 634 http_request_.relative_url); |
635 EXPECT_EQ("application/json", http_request_.headers["Content-Type"]); | 635 EXPECT_EQ("application/json", http_request_.headers["Content-Type"]); |
636 | 636 |
637 EXPECT_TRUE(http_request_.has_content); | 637 EXPECT_TRUE(http_request_.has_content); |
638 EXPECT_EQ("{\"id\":\"resource_id\"}", http_request_.content); | 638 EXPECT_EQ("{\"id\":\"resource_id\"}", http_request_.content); |
639 } | 639 } |
640 | 640 |
641 TEST_F(DriveApiOperationsTest, DeleteResourceOperation) { | 641 TEST_F(DriveApiOperationsTest, DeleteResourceOperation) { |
642 GDataErrorCode error = GDATA_OTHER_ERROR; | 642 GDataErrorCode error = GDATA_OTHER_ERROR; |
643 | 643 |
644 // Remove a resource with "resource_id" from a directory with | 644 // Remove a resource with "resource_id" from a directory with |
645 // "parent_resource_id". | 645 // "parent_resource_id". |
646 drive::DeleteResourceOperation* operation = | 646 drive::DeleteResourceOperation* operation = |
647 new drive::DeleteResourceOperation( | 647 new drive::DeleteResourceOperation( |
648 &operation_registry_, | 648 &operation_registry_, |
649 request_context_getter_.get(), | 649 request_context_getter_.get(), |
650 *url_generator_, | 650 *url_generator_, |
651 "parent_resource_id", | 651 "parent_resource_id", |
652 "resource_id", | 652 "resource_id", |
653 CreateComposedCallback( | 653 CreateComposedCallback( |
654 base::Bind(&test_util::RunAndQuit), | 654 base::Bind(&test_util::RunAndQuit), |
655 test_util::CreateCopyResultCallback(&error))); | 655 test_util::CreateCopyResultCallback(&error))); |
656 operation->Start(kTestDriveApiAuthToken, kTestUserAgent, | 656 operation->Start(kTestDriveApiAuthToken, kTestUserAgent, |
657 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 657 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
658 MessageLoop::current()->Run(); | 658 MessageLoop::current()->Run(); |
659 | 659 |
660 EXPECT_EQ(HTTP_NO_CONTENT, error); | 660 EXPECT_EQ(HTTP_NO_CONTENT, error); |
661 EXPECT_EQ(test_server::METHOD_DELETE, http_request_.method); | 661 EXPECT_EQ(net::test_server::METHOD_DELETE, http_request_.method); |
662 EXPECT_EQ("/drive/v2/files/parent_resource_id/children/resource_id", | 662 EXPECT_EQ("/drive/v2/files/parent_resource_id/children/resource_id", |
663 http_request_.relative_url); | 663 http_request_.relative_url); |
664 EXPECT_FALSE(http_request_.has_content); | 664 EXPECT_FALSE(http_request_.has_content); |
665 } | 665 } |
666 | 666 |
667 TEST_F(DriveApiOperationsTest, UploadNewFileOperation) { | 667 TEST_F(DriveApiOperationsTest, UploadNewFileOperation) { |
668 // Set an expected url for uploading. | 668 // Set an expected url for uploading. |
669 expected_upload_path_ = kTestUploadNewFilePath; | 669 expected_upload_path_ = kTestUploadNewFilePath; |
670 | 670 |
671 const char kTestContentType[] = "text/plain"; | 671 const char kTestContentType[] = "text/plain"; |
(...skipping 20 matching lines...) Expand all Loading... |
692 operation->Start(kTestDriveApiAuthToken, kTestUserAgent, | 692 operation->Start(kTestDriveApiAuthToken, kTestUserAgent, |
693 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 693 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
694 MessageLoop::current()->Run(); | 694 MessageLoop::current()->Run(); |
695 | 695 |
696 EXPECT_EQ(HTTP_SUCCESS, error); | 696 EXPECT_EQ(HTTP_SUCCESS, error); |
697 EXPECT_EQ(kTestUploadNewFilePath, upload_url.path()); | 697 EXPECT_EQ(kTestUploadNewFilePath, upload_url.path()); |
698 EXPECT_EQ(kTestContentType, http_request_.headers["X-Upload-Content-Type"]); | 698 EXPECT_EQ(kTestContentType, http_request_.headers["X-Upload-Content-Type"]); |
699 EXPECT_EQ(base::Int64ToString(kTestContent.size()), | 699 EXPECT_EQ(base::Int64ToString(kTestContent.size()), |
700 http_request_.headers["X-Upload-Content-Length"]); | 700 http_request_.headers["X-Upload-Content-Length"]); |
701 | 701 |
702 EXPECT_EQ(test_server::METHOD_POST, http_request_.method); | 702 EXPECT_EQ(net::test_server::METHOD_POST, http_request_.method); |
703 EXPECT_EQ("/upload/drive/v2/files?uploadType=resumable", | 703 EXPECT_EQ("/upload/drive/v2/files?uploadType=resumable", |
704 http_request_.relative_url); | 704 http_request_.relative_url); |
705 EXPECT_EQ("application/json", http_request_.headers["Content-Type"]); | 705 EXPECT_EQ("application/json", http_request_.headers["Content-Type"]); |
706 EXPECT_TRUE(http_request_.has_content); | 706 EXPECT_TRUE(http_request_.has_content); |
707 EXPECT_EQ("{\"parents\":[{" | 707 EXPECT_EQ("{\"parents\":[{" |
708 "\"id\":\"parent_resource_id\"," | 708 "\"id\":\"parent_resource_id\"," |
709 "\"kind\":\"drive#fileLink\"" | 709 "\"kind\":\"drive#fileLink\"" |
710 "}]," | 710 "}]," |
711 "\"title\":\"new file title\"}", | 711 "\"title\":\"new file title\"}", |
712 http_request_.content); | 712 http_request_.content); |
(...skipping 19 matching lines...) Expand all Loading... |
732 CreateComposedCallback( | 732 CreateComposedCallback( |
733 base::Bind(&test_util::RunAndQuit), | 733 base::Bind(&test_util::RunAndQuit), |
734 test_util::CreateCopyResultCallback(&response, &new_entry)), | 734 test_util::CreateCopyResultCallback(&response, &new_entry)), |
735 ProgressCallback()); | 735 ProgressCallback()); |
736 resume_operation->Start( | 736 resume_operation->Start( |
737 kTestDriveApiAuthToken, kTestUserAgent, | 737 kTestDriveApiAuthToken, kTestUserAgent, |
738 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 738 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
739 MessageLoop::current()->Run(); | 739 MessageLoop::current()->Run(); |
740 | 740 |
741 // METHOD_PUT should be used to upload data. | 741 // METHOD_PUT should be used to upload data. |
742 EXPECT_EQ(test_server::METHOD_PUT, http_request_.method); | 742 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); |
743 // Request should go to the upload URL. | 743 // Request should go to the upload URL. |
744 EXPECT_EQ(upload_url.path(), http_request_.relative_url); | 744 EXPECT_EQ(upload_url.path(), http_request_.relative_url); |
745 // Content-Range header should be added. | 745 // Content-Range header should be added. |
746 EXPECT_EQ("bytes 0-" + | 746 EXPECT_EQ("bytes 0-" + |
747 base::Int64ToString(kTestContent.size() - 1) + "/" + | 747 base::Int64ToString(kTestContent.size() - 1) + "/" + |
748 base::Int64ToString(kTestContent.size()), | 748 base::Int64ToString(kTestContent.size()), |
749 http_request_.headers["Content-Range"]); | 749 http_request_.headers["Content-Range"]); |
750 // The upload content should be set in the HTTP request. | 750 // The upload content should be set in the HTTP request. |
751 EXPECT_TRUE(http_request_.has_content); | 751 EXPECT_TRUE(http_request_.has_content); |
752 EXPECT_EQ(kTestContent, http_request_.content); | 752 EXPECT_EQ(kTestContent, http_request_.content); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
785 test_util::CreateCopyResultCallback(&error, &upload_url))); | 785 test_util::CreateCopyResultCallback(&error, &upload_url))); |
786 operation->Start(kTestDriveApiAuthToken, kTestUserAgent, | 786 operation->Start(kTestDriveApiAuthToken, kTestUserAgent, |
787 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 787 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
788 MessageLoop::current()->Run(); | 788 MessageLoop::current()->Run(); |
789 | 789 |
790 EXPECT_EQ(HTTP_SUCCESS, error); | 790 EXPECT_EQ(HTTP_SUCCESS, error); |
791 EXPECT_EQ(kTestUploadNewFilePath, upload_url.path()); | 791 EXPECT_EQ(kTestUploadNewFilePath, upload_url.path()); |
792 EXPECT_EQ(kTestContentType, http_request_.headers["X-Upload-Content-Type"]); | 792 EXPECT_EQ(kTestContentType, http_request_.headers["X-Upload-Content-Type"]); |
793 EXPECT_EQ("0", http_request_.headers["X-Upload-Content-Length"]); | 793 EXPECT_EQ("0", http_request_.headers["X-Upload-Content-Length"]); |
794 | 794 |
795 EXPECT_EQ(test_server::METHOD_POST, http_request_.method); | 795 EXPECT_EQ(net::test_server::METHOD_POST, http_request_.method); |
796 EXPECT_EQ("/upload/drive/v2/files?uploadType=resumable", | 796 EXPECT_EQ("/upload/drive/v2/files?uploadType=resumable", |
797 http_request_.relative_url); | 797 http_request_.relative_url); |
798 EXPECT_EQ("application/json", http_request_.headers["Content-Type"]); | 798 EXPECT_EQ("application/json", http_request_.headers["Content-Type"]); |
799 EXPECT_TRUE(http_request_.has_content); | 799 EXPECT_TRUE(http_request_.has_content); |
800 EXPECT_EQ("{\"parents\":[{" | 800 EXPECT_EQ("{\"parents\":[{" |
801 "\"id\":\"parent_resource_id\"," | 801 "\"id\":\"parent_resource_id\"," |
802 "\"kind\":\"drive#fileLink\"" | 802 "\"kind\":\"drive#fileLink\"" |
803 "}]," | 803 "}]," |
804 "\"title\":\"new file title\"}", | 804 "\"title\":\"new file title\"}", |
805 http_request_.content); | 805 http_request_.content); |
(...skipping 19 matching lines...) Expand all Loading... |
825 CreateComposedCallback( | 825 CreateComposedCallback( |
826 base::Bind(&test_util::RunAndQuit), | 826 base::Bind(&test_util::RunAndQuit), |
827 test_util::CreateCopyResultCallback(&response, &new_entry)), | 827 test_util::CreateCopyResultCallback(&response, &new_entry)), |
828 ProgressCallback()); | 828 ProgressCallback()); |
829 resume_operation->Start( | 829 resume_operation->Start( |
830 kTestDriveApiAuthToken, kTestUserAgent, | 830 kTestDriveApiAuthToken, kTestUserAgent, |
831 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 831 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
832 MessageLoop::current()->Run(); | 832 MessageLoop::current()->Run(); |
833 | 833 |
834 // METHOD_PUT should be used to upload data. | 834 // METHOD_PUT should be used to upload data. |
835 EXPECT_EQ(test_server::METHOD_PUT, http_request_.method); | 835 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); |
836 // Request should go to the upload URL. | 836 // Request should go to the upload URL. |
837 EXPECT_EQ(upload_url.path(), http_request_.relative_url); | 837 EXPECT_EQ(upload_url.path(), http_request_.relative_url); |
838 // Content-Range header should NOT be added. | 838 // Content-Range header should NOT be added. |
839 EXPECT_EQ(0U, http_request_.headers.count("Content-Range")); | 839 EXPECT_EQ(0U, http_request_.headers.count("Content-Range")); |
840 // The upload content should be set in the HTTP request. | 840 // The upload content should be set in the HTTP request. |
841 EXPECT_TRUE(http_request_.has_content); | 841 EXPECT_TRUE(http_request_.has_content); |
842 EXPECT_EQ(kTestContent, http_request_.content); | 842 EXPECT_EQ(kTestContent, http_request_.content); |
843 | 843 |
844 // Check the response. | 844 // Check the response. |
845 EXPECT_EQ(HTTP_CREATED, response.code); // Because it's a new file | 845 EXPECT_EQ(HTTP_CREATED, response.code); // Because it's a new file |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
877 operation->Start(kTestDriveApiAuthToken, kTestUserAgent, | 877 operation->Start(kTestDriveApiAuthToken, kTestUserAgent, |
878 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 878 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
879 MessageLoop::current()->Run(); | 879 MessageLoop::current()->Run(); |
880 | 880 |
881 EXPECT_EQ(HTTP_SUCCESS, error); | 881 EXPECT_EQ(HTTP_SUCCESS, error); |
882 EXPECT_EQ(kTestUploadNewFilePath, upload_url.path()); | 882 EXPECT_EQ(kTestUploadNewFilePath, upload_url.path()); |
883 EXPECT_EQ(kTestContentType, http_request_.headers["X-Upload-Content-Type"]); | 883 EXPECT_EQ(kTestContentType, http_request_.headers["X-Upload-Content-Type"]); |
884 EXPECT_EQ(base::Int64ToString(kTestContent.size()), | 884 EXPECT_EQ(base::Int64ToString(kTestContent.size()), |
885 http_request_.headers["X-Upload-Content-Length"]); | 885 http_request_.headers["X-Upload-Content-Length"]); |
886 | 886 |
887 EXPECT_EQ(test_server::METHOD_POST, http_request_.method); | 887 EXPECT_EQ(net::test_server::METHOD_POST, http_request_.method); |
888 EXPECT_EQ("/upload/drive/v2/files?uploadType=resumable", | 888 EXPECT_EQ("/upload/drive/v2/files?uploadType=resumable", |
889 http_request_.relative_url); | 889 http_request_.relative_url); |
890 EXPECT_EQ("application/json", http_request_.headers["Content-Type"]); | 890 EXPECT_EQ("application/json", http_request_.headers["Content-Type"]); |
891 EXPECT_TRUE(http_request_.has_content); | 891 EXPECT_TRUE(http_request_.has_content); |
892 EXPECT_EQ("{\"parents\":[{" | 892 EXPECT_EQ("{\"parents\":[{" |
893 "\"id\":\"parent_resource_id\"," | 893 "\"id\":\"parent_resource_id\"," |
894 "\"kind\":\"drive#fileLink\"" | 894 "\"kind\":\"drive#fileLink\"" |
895 "}]," | 895 "}]," |
896 "\"title\":\"new file title\"}", | 896 "\"title\":\"new file title\"}", |
897 http_request_.content); | 897 http_request_.content); |
(...skipping 25 matching lines...) Expand all Loading... |
923 CreateComposedCallback( | 923 CreateComposedCallback( |
924 base::Bind(&test_util::RunAndQuit), | 924 base::Bind(&test_util::RunAndQuit), |
925 test_util::CreateCopyResultCallback(&response, &new_entry)), | 925 test_util::CreateCopyResultCallback(&response, &new_entry)), |
926 ProgressCallback()); | 926 ProgressCallback()); |
927 resume_operation->Start( | 927 resume_operation->Start( |
928 kTestDriveApiAuthToken, kTestUserAgent, | 928 kTestDriveApiAuthToken, kTestUserAgent, |
929 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 929 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
930 MessageLoop::current()->Run(); | 930 MessageLoop::current()->Run(); |
931 | 931 |
932 // METHOD_PUT should be used to upload data. | 932 // METHOD_PUT should be used to upload data. |
933 EXPECT_EQ(test_server::METHOD_PUT, http_request_.method); | 933 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); |
934 // Request should go to the upload URL. | 934 // Request should go to the upload URL. |
935 EXPECT_EQ(upload_url.path(), http_request_.relative_url); | 935 EXPECT_EQ(upload_url.path(), http_request_.relative_url); |
936 // Content-Range header should be added. | 936 // Content-Range header should be added. |
937 EXPECT_EQ("bytes " + | 937 EXPECT_EQ("bytes " + |
938 base::Int64ToString(start_position) + "-" + | 938 base::Int64ToString(start_position) + "-" + |
939 base::Int64ToString(end_position - 1) + "/" + | 939 base::Int64ToString(end_position - 1) + "/" + |
940 base::Int64ToString(kTestContent.size()), | 940 base::Int64ToString(kTestContent.size()), |
941 http_request_.headers["Content-Range"]); | 941 http_request_.headers["Content-Range"]); |
942 // The upload content should be set in the HTTP request. | 942 // The upload content should be set in the HTTP request. |
943 EXPECT_TRUE(http_request_.has_content); | 943 EXPECT_TRUE(http_request_.has_content); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
988 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 988 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
989 MessageLoop::current()->Run(); | 989 MessageLoop::current()->Run(); |
990 | 990 |
991 EXPECT_EQ(HTTP_SUCCESS, error); | 991 EXPECT_EQ(HTTP_SUCCESS, error); |
992 EXPECT_EQ(kTestUploadExistingFilePath, upload_url.path()); | 992 EXPECT_EQ(kTestUploadExistingFilePath, upload_url.path()); |
993 EXPECT_EQ(kTestContentType, http_request_.headers["X-Upload-Content-Type"]); | 993 EXPECT_EQ(kTestContentType, http_request_.headers["X-Upload-Content-Type"]); |
994 EXPECT_EQ(base::Int64ToString(kTestContent.size()), | 994 EXPECT_EQ(base::Int64ToString(kTestContent.size()), |
995 http_request_.headers["X-Upload-Content-Length"]); | 995 http_request_.headers["X-Upload-Content-Length"]); |
996 EXPECT_EQ("*", http_request_.headers["If-Match"]); | 996 EXPECT_EQ("*", http_request_.headers["If-Match"]); |
997 | 997 |
998 EXPECT_EQ(test_server::METHOD_PUT, http_request_.method); | 998 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); |
999 EXPECT_EQ("/upload/drive/v2/files/resource_id?uploadType=resumable", | 999 EXPECT_EQ("/upload/drive/v2/files/resource_id?uploadType=resumable", |
1000 http_request_.relative_url); | 1000 http_request_.relative_url); |
1001 EXPECT_TRUE(http_request_.has_content); | 1001 EXPECT_TRUE(http_request_.has_content); |
1002 EXPECT_TRUE(http_request_.content.empty()); | 1002 EXPECT_TRUE(http_request_.content.empty()); |
1003 | 1003 |
1004 // 2) Upload the content to the upload URL. | 1004 // 2) Upload the content to the upload URL. |
1005 scoped_refptr<net::IOBuffer> buffer = new net::StringIOBuffer(kTestContent); | 1005 scoped_refptr<net::IOBuffer> buffer = new net::StringIOBuffer(kTestContent); |
1006 | 1006 |
1007 UploadRangeResponse response; | 1007 UploadRangeResponse response; |
1008 scoped_ptr<FileResource> new_entry; | 1008 scoped_ptr<FileResource> new_entry; |
(...skipping 13 matching lines...) Expand all Loading... |
1022 CreateComposedCallback( | 1022 CreateComposedCallback( |
1023 base::Bind(&test_util::RunAndQuit), | 1023 base::Bind(&test_util::RunAndQuit), |
1024 test_util::CreateCopyResultCallback(&response, &new_entry)), | 1024 test_util::CreateCopyResultCallback(&response, &new_entry)), |
1025 ProgressCallback()); | 1025 ProgressCallback()); |
1026 resume_operation->Start( | 1026 resume_operation->Start( |
1027 kTestDriveApiAuthToken, kTestUserAgent, | 1027 kTestDriveApiAuthToken, kTestUserAgent, |
1028 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 1028 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
1029 MessageLoop::current()->Run(); | 1029 MessageLoop::current()->Run(); |
1030 | 1030 |
1031 // METHOD_PUT should be used to upload data. | 1031 // METHOD_PUT should be used to upload data. |
1032 EXPECT_EQ(test_server::METHOD_PUT, http_request_.method); | 1032 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); |
1033 // Request should go to the upload URL. | 1033 // Request should go to the upload URL. |
1034 EXPECT_EQ(upload_url.path(), http_request_.relative_url); | 1034 EXPECT_EQ(upload_url.path(), http_request_.relative_url); |
1035 // Content-Range header should be added. | 1035 // Content-Range header should be added. |
1036 EXPECT_EQ("bytes 0-" + | 1036 EXPECT_EQ("bytes 0-" + |
1037 base::Int64ToString(kTestContent.size() - 1) + "/" + | 1037 base::Int64ToString(kTestContent.size() - 1) + "/" + |
1038 base::Int64ToString(kTestContent.size()), | 1038 base::Int64ToString(kTestContent.size()), |
1039 http_request_.headers["Content-Range"]); | 1039 http_request_.headers["Content-Range"]); |
1040 // The upload content should be set in the HTTP request. | 1040 // The upload content should be set in the HTTP request. |
1041 EXPECT_TRUE(http_request_.has_content); | 1041 EXPECT_TRUE(http_request_.has_content); |
1042 EXPECT_EQ(kTestContent, http_request_.content); | 1042 EXPECT_EQ(kTestContent, http_request_.content); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1076 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 1076 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
1077 MessageLoop::current()->Run(); | 1077 MessageLoop::current()->Run(); |
1078 | 1078 |
1079 EXPECT_EQ(HTTP_SUCCESS, error); | 1079 EXPECT_EQ(HTTP_SUCCESS, error); |
1080 EXPECT_EQ(kTestUploadExistingFilePath, upload_url.path()); | 1080 EXPECT_EQ(kTestUploadExistingFilePath, upload_url.path()); |
1081 EXPECT_EQ(kTestContentType, http_request_.headers["X-Upload-Content-Type"]); | 1081 EXPECT_EQ(kTestContentType, http_request_.headers["X-Upload-Content-Type"]); |
1082 EXPECT_EQ(base::Int64ToString(kTestContent.size()), | 1082 EXPECT_EQ(base::Int64ToString(kTestContent.size()), |
1083 http_request_.headers["X-Upload-Content-Length"]); | 1083 http_request_.headers["X-Upload-Content-Length"]); |
1084 EXPECT_EQ(kTestETag, http_request_.headers["If-Match"]); | 1084 EXPECT_EQ(kTestETag, http_request_.headers["If-Match"]); |
1085 | 1085 |
1086 EXPECT_EQ(test_server::METHOD_PUT, http_request_.method); | 1086 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); |
1087 EXPECT_EQ("/upload/drive/v2/files/resource_id?uploadType=resumable", | 1087 EXPECT_EQ("/upload/drive/v2/files/resource_id?uploadType=resumable", |
1088 http_request_.relative_url); | 1088 http_request_.relative_url); |
1089 EXPECT_TRUE(http_request_.has_content); | 1089 EXPECT_TRUE(http_request_.has_content); |
1090 EXPECT_TRUE(http_request_.content.empty()); | 1090 EXPECT_TRUE(http_request_.content.empty()); |
1091 | 1091 |
1092 // 2) Upload the content to the upload URL. | 1092 // 2) Upload the content to the upload URL. |
1093 scoped_refptr<net::IOBuffer> buffer = new net::StringIOBuffer(kTestContent); | 1093 scoped_refptr<net::IOBuffer> buffer = new net::StringIOBuffer(kTestContent); |
1094 | 1094 |
1095 UploadRangeResponse response; | 1095 UploadRangeResponse response; |
1096 scoped_ptr<FileResource> new_entry; | 1096 scoped_ptr<FileResource> new_entry; |
(...skipping 13 matching lines...) Expand all Loading... |
1110 CreateComposedCallback( | 1110 CreateComposedCallback( |
1111 base::Bind(&test_util::RunAndQuit), | 1111 base::Bind(&test_util::RunAndQuit), |
1112 test_util::CreateCopyResultCallback(&response, &new_entry)), | 1112 test_util::CreateCopyResultCallback(&response, &new_entry)), |
1113 ProgressCallback()); | 1113 ProgressCallback()); |
1114 resume_operation->Start( | 1114 resume_operation->Start( |
1115 kTestDriveApiAuthToken, kTestUserAgent, | 1115 kTestDriveApiAuthToken, kTestUserAgent, |
1116 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 1116 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
1117 MessageLoop::current()->Run(); | 1117 MessageLoop::current()->Run(); |
1118 | 1118 |
1119 // METHOD_PUT should be used to upload data. | 1119 // METHOD_PUT should be used to upload data. |
1120 EXPECT_EQ(test_server::METHOD_PUT, http_request_.method); | 1120 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); |
1121 // Request should go to the upload URL. | 1121 // Request should go to the upload URL. |
1122 EXPECT_EQ(upload_url.path(), http_request_.relative_url); | 1122 EXPECT_EQ(upload_url.path(), http_request_.relative_url); |
1123 // Content-Range header should be added. | 1123 // Content-Range header should be added. |
1124 EXPECT_EQ("bytes 0-" + | 1124 EXPECT_EQ("bytes 0-" + |
1125 base::Int64ToString(kTestContent.size() - 1) + "/" + | 1125 base::Int64ToString(kTestContent.size() - 1) + "/" + |
1126 base::Int64ToString(kTestContent.size()), | 1126 base::Int64ToString(kTestContent.size()), |
1127 http_request_.headers["Content-Range"]); | 1127 http_request_.headers["Content-Range"]); |
1128 // The upload content should be set in the HTTP request. | 1128 // The upload content should be set in the HTTP request. |
1129 EXPECT_TRUE(http_request_.has_content); | 1129 EXPECT_TRUE(http_request_.has_content); |
1130 EXPECT_EQ(kTestContent, http_request_.content); | 1130 EXPECT_EQ(kTestContent, http_request_.content); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1163 operation->Start(kTestDriveApiAuthToken, kTestUserAgent, | 1163 operation->Start(kTestDriveApiAuthToken, kTestUserAgent, |
1164 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 1164 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
1165 MessageLoop::current()->Run(); | 1165 MessageLoop::current()->Run(); |
1166 | 1166 |
1167 EXPECT_EQ(HTTP_PRECONDITION, error); | 1167 EXPECT_EQ(HTTP_PRECONDITION, error); |
1168 EXPECT_EQ(kTestContentType, http_request_.headers["X-Upload-Content-Type"]); | 1168 EXPECT_EQ(kTestContentType, http_request_.headers["X-Upload-Content-Type"]); |
1169 EXPECT_EQ(base::Int64ToString(kTestContent.size()), | 1169 EXPECT_EQ(base::Int64ToString(kTestContent.size()), |
1170 http_request_.headers["X-Upload-Content-Length"]); | 1170 http_request_.headers["X-Upload-Content-Length"]); |
1171 EXPECT_EQ("Conflicting-etag", http_request_.headers["If-Match"]); | 1171 EXPECT_EQ("Conflicting-etag", http_request_.headers["If-Match"]); |
1172 | 1172 |
1173 EXPECT_EQ(test_server::METHOD_PUT, http_request_.method); | 1173 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); |
1174 EXPECT_EQ("/upload/drive/v2/files/resource_id?uploadType=resumable", | 1174 EXPECT_EQ("/upload/drive/v2/files/resource_id?uploadType=resumable", |
1175 http_request_.relative_url); | 1175 http_request_.relative_url); |
1176 EXPECT_TRUE(http_request_.has_content); | 1176 EXPECT_TRUE(http_request_.has_content); |
1177 EXPECT_TRUE(http_request_.content.empty()); | 1177 EXPECT_TRUE(http_request_.content.empty()); |
1178 } | 1178 } |
1179 | 1179 |
1180 } // namespace google_apis | 1180 } // namespace google_apis |
OLD | NEW |