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 "google_apis/drive/drive_api_requests.h" | 5 #include "google_apis/drive/drive_api_requests.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 request_context_getter_ = new net::TestURLRequestContextGetter( | 132 request_context_getter_ = new net::TestURLRequestContextGetter( |
133 message_loop_.task_runner()); | 133 message_loop_.task_runner()); |
134 | 134 |
135 request_sender_.reset(new RequestSender(new DummyAuthService, | 135 request_sender_.reset(new RequestSender(new DummyAuthService, |
136 request_context_getter_.get(), | 136 request_context_getter_.get(), |
137 message_loop_.task_runner(), | 137 message_loop_.task_runner(), |
138 kTestUserAgent)); | 138 kTestUserAgent)); |
139 | 139 |
140 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 140 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
141 | 141 |
142 ASSERT_TRUE(test_server_.Start()); | |
143 test_server_.RegisterRequestHandler( | 142 test_server_.RegisterRequestHandler( |
144 base::Bind(&DriveApiRequestsTest::HandleChildrenDeleteRequest, | 143 base::Bind(&DriveApiRequestsTest::HandleChildrenDeleteRequest, |
145 base::Unretained(this))); | 144 base::Unretained(this))); |
146 test_server_.RegisterRequestHandler( | 145 test_server_.RegisterRequestHandler( |
147 base::Bind(&DriveApiRequestsTest::HandleDataFileRequest, | 146 base::Bind(&DriveApiRequestsTest::HandleDataFileRequest, |
148 base::Unretained(this))); | 147 base::Unretained(this))); |
149 test_server_.RegisterRequestHandler( | 148 test_server_.RegisterRequestHandler( |
150 base::Bind(&DriveApiRequestsTest::HandleDeleteRequest, | 149 base::Bind(&DriveApiRequestsTest::HandleDeleteRequest, |
151 base::Unretained(this))); | 150 base::Unretained(this))); |
152 test_server_.RegisterRequestHandler( | 151 test_server_.RegisterRequestHandler( |
153 base::Bind(&DriveApiRequestsTest::HandlePreconditionFailedRequest, | 152 base::Bind(&DriveApiRequestsTest::HandlePreconditionFailedRequest, |
154 base::Unretained(this))); | 153 base::Unretained(this))); |
155 test_server_.RegisterRequestHandler( | 154 test_server_.RegisterRequestHandler( |
156 base::Bind(&DriveApiRequestsTest::HandleResumeUploadRequest, | 155 base::Bind(&DriveApiRequestsTest::HandleResumeUploadRequest, |
157 base::Unretained(this))); | 156 base::Unretained(this))); |
158 test_server_.RegisterRequestHandler( | 157 test_server_.RegisterRequestHandler( |
159 base::Bind(&DriveApiRequestsTest::HandleInitiateUploadRequest, | 158 base::Bind(&DriveApiRequestsTest::HandleInitiateUploadRequest, |
160 base::Unretained(this))); | 159 base::Unretained(this))); |
161 test_server_.RegisterRequestHandler( | 160 test_server_.RegisterRequestHandler( |
162 base::Bind(&DriveApiRequestsTest::HandleContentResponse, | 161 base::Bind(&DriveApiRequestsTest::HandleContentResponse, |
163 base::Unretained(this))); | 162 base::Unretained(this))); |
164 test_server_.RegisterRequestHandler( | 163 test_server_.RegisterRequestHandler( |
165 base::Bind(&DriveApiRequestsTest::HandleDownloadRequest, | 164 base::Bind(&DriveApiRequestsTest::HandleDownloadRequest, |
166 base::Unretained(this))); | 165 base::Unretained(this))); |
167 test_server_.RegisterRequestHandler( | 166 test_server_.RegisterRequestHandler( |
168 base::Bind(&DriveApiRequestsTest::HandleBatchUploadRequest, | 167 base::Bind(&DriveApiRequestsTest::HandleBatchUploadRequest, |
169 base::Unretained(this))); | 168 base::Unretained(this))); |
| 169 ASSERT_TRUE(test_server_.Start()); |
170 | 170 |
171 GURL test_base_url = test_util::GetBaseUrlForTesting(test_server_.port()); | 171 GURL test_base_url = test_util::GetBaseUrlForTesting(test_server_.port()); |
172 url_generator_.reset( | 172 url_generator_.reset( |
173 new DriveApiUrlGenerator(test_base_url, test_base_url)); | 173 new DriveApiUrlGenerator(test_base_url, test_base_url)); |
174 | 174 |
175 // Reset the server's expected behavior just in case. | 175 // Reset the server's expected behavior just in case. |
176 ResetExpectedResponse(); | 176 ResetExpectedResponse(); |
177 received_bytes_ = 0; | 177 received_bytes_ = 0; |
178 content_length_ = 0; | 178 content_length_ = 0; |
179 | 179 |
(...skipping 2061 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2241 "Header: value\r\n" | 2241 "Header: value\r\n" |
2242 "\r\n" | 2242 "\r\n" |
2243 "BODY\r\n" | 2243 "BODY\r\n" |
2244 "--BOUNDARY-- \t", | 2244 "--BOUNDARY-- \t", |
2245 &parts)); | 2245 &parts)); |
2246 ASSERT_EQ(1u, parts.size()); | 2246 ASSERT_EQ(1u, parts.size()); |
2247 EXPECT_EQ(HTTP_SUCCESS, parts[0].code); | 2247 EXPECT_EQ(HTTP_SUCCESS, parts[0].code); |
2248 EXPECT_EQ("BODY", parts[0].body); | 2248 EXPECT_EQ("BODY", parts[0].body); |
2249 } | 2249 } |
2250 } // namespace google_apis | 2250 } // namespace google_apis |
OLD | NEW |