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

Side by Side Diff: chrome/browser/autofill/autofill_download_unittest.cc

Issue 6166010: net: Remove typedef net::URLRequestStatus URLRequestStatus; (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 11 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <list> 5 #include <list>
6 6
7 #include "base/string_util.h" 7 #include "base/string_util.h"
8 #include "base/test/test_timeouts.h" 8 #include "base/test/test_timeouts.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/autofill/autofill_download.h" 10 #include "chrome/browser/autofill/autofill_download.h"
11 #include "chrome/browser/autofill/autofill_metrics.h" 11 #include "chrome/browser/autofill/autofill_metrics.h"
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 "<field autofilltype=\"33\" />" 212 "<field autofilltype=\"33\" />"
213 "</autofillqueryresponse>", 213 "</autofillqueryresponse>",
214 "<autofilluploadresponse positiveuploadrate=\"0.5\" " 214 "<autofilluploadresponse positiveuploadrate=\"0.5\" "
215 "negativeuploadrate=\"0.3\"/>", 215 "negativeuploadrate=\"0.3\"/>",
216 "<html></html>", 216 "<html></html>",
217 }; 217 };
218 218
219 // Return them out of sequence. 219 // Return them out of sequence.
220 TestURLFetcher* fetcher = factory.GetFetcherByID(1); 220 TestURLFetcher* fetcher = factory.GetFetcherByID(1);
221 ASSERT_TRUE(fetcher); 221 ASSERT_TRUE(fetcher);
222 fetcher->delegate()->OnURLFetchComplete(fetcher, GURL(), URLRequestStatus(), 222 fetcher->delegate()->OnURLFetchComplete(fetcher, GURL(),
223 net::URLRequestStatus(),
223 200, ResponseCookies(), 224 200, ResponseCookies(),
224 std::string(responses[1])); 225 std::string(responses[1]));
225 // After that upload rates would be adjusted to 0.5/0.3 226 // After that upload rates would be adjusted to 0.5/0.3
226 EXPECT_DOUBLE_EQ(0.5, helper.download_manager.GetPositiveUploadRate()); 227 EXPECT_DOUBLE_EQ(0.5, helper.download_manager.GetPositiveUploadRate());
227 EXPECT_DOUBLE_EQ(0.3, helper.download_manager.GetNegativeUploadRate()); 228 EXPECT_DOUBLE_EQ(0.3, helper.download_manager.GetNegativeUploadRate());
228 229
229 fetcher = factory.GetFetcherByID(2); 230 fetcher = factory.GetFetcherByID(2);
230 ASSERT_TRUE(fetcher); 231 ASSERT_TRUE(fetcher);
231 fetcher->delegate()->OnURLFetchComplete(fetcher, GURL(), URLRequestStatus(), 232 fetcher->delegate()->OnURLFetchComplete(fetcher, GURL(),
233 net::URLRequestStatus(),
232 404, ResponseCookies(), 234 404, ResponseCookies(),
233 std::string(responses[2])); 235 std::string(responses[2]));
234 fetcher = factory.GetFetcherByID(0); 236 fetcher = factory.GetFetcherByID(0);
235 ASSERT_TRUE(fetcher); 237 ASSERT_TRUE(fetcher);
236 fetcher->delegate()->OnURLFetchComplete(fetcher, GURL(), URLRequestStatus(), 238 fetcher->delegate()->OnURLFetchComplete(fetcher, GURL(),
239 net::URLRequestStatus(),
237 200, ResponseCookies(), 240 200, ResponseCookies(),
238 std::string(responses[0])); 241 std::string(responses[0]));
239 EXPECT_EQ(static_cast<size_t>(3), helper.responses_.size()); 242 EXPECT_EQ(static_cast<size_t>(3), helper.responses_.size());
240 243
241 EXPECT_EQ(AutoFillDownloadTestHelper::UPLOAD_SUCCESSFULL, 244 EXPECT_EQ(AutoFillDownloadTestHelper::UPLOAD_SUCCESSFULL,
242 helper.responses_.front().type_of_response); 245 helper.responses_.front().type_of_response);
243 EXPECT_EQ(0, helper.responses_.front().error); 246 EXPECT_EQ(0, helper.responses_.front().error);
244 EXPECT_EQ(std::string(), helper.responses_.front().signature); 247 EXPECT_EQ(std::string(), helper.responses_.front().signature);
245 // Expected response on non-query request is an empty string. 248 // Expected response on non-query request is an empty string.
246 EXPECT_EQ(std::string(), helper.responses_.front().response); 249 EXPECT_EQ(std::string(), helper.responses_.front().response);
(...skipping 27 matching lines...) Expand all
274 EXPECT_EQ(NULL, fetcher); 277 EXPECT_EQ(NULL, fetcher);
275 278
276 // Request with id 3. 279 // Request with id 3.
277 EXPECT_CALL(mock_metric_logger, Log(AutoFillMetrics::QUERY_SENT)).Times(1); 280 EXPECT_CALL(mock_metric_logger, Log(AutoFillMetrics::QUERY_SENT)).Times(1);
278 EXPECT_TRUE(helper.download_manager.StartQueryRequest(form_structures, 281 EXPECT_TRUE(helper.download_manager.StartQueryRequest(form_structures,
279 mock_metric_logger)); 282 mock_metric_logger));
280 fetcher = factory.GetFetcherByID(3); 283 fetcher = factory.GetFetcherByID(3);
281 ASSERT_TRUE(fetcher); 284 ASSERT_TRUE(fetcher);
282 fetcher->set_backoff_delay( 285 fetcher->set_backoff_delay(
283 base::TimeDelta::FromMilliseconds(TestTimeouts::action_max_timeout_ms())); 286 base::TimeDelta::FromMilliseconds(TestTimeouts::action_max_timeout_ms()));
284 fetcher->delegate()->OnURLFetchComplete(fetcher, GURL(), URLRequestStatus(), 287 fetcher->delegate()->OnURLFetchComplete(fetcher, GURL(),
288 net::URLRequestStatus(),
285 500, ResponseCookies(), 289 500, ResponseCookies(),
286 std::string(responses[0])); 290 std::string(responses[0]));
287 EXPECT_EQ(AutoFillDownloadTestHelper::REQUEST_QUERY_FAILED, 291 EXPECT_EQ(AutoFillDownloadTestHelper::REQUEST_QUERY_FAILED,
288 helper.responses_.front().type_of_response); 292 helper.responses_.front().type_of_response);
289 EXPECT_EQ(500, helper.responses_.front().error); 293 EXPECT_EQ(500, helper.responses_.front().error);
290 // Expected response on non-query request is an empty string. 294 // Expected response on non-query request is an empty string.
291 EXPECT_EQ(std::string(), helper.responses_.front().response); 295 EXPECT_EQ(std::string(), helper.responses_.front().response);
292 helper.responses_.pop_front(); 296 helper.responses_.pop_front();
293 297
294 // Query requests should be ignored for the next 10 seconds. 298 // Query requests should be ignored for the next 10 seconds.
295 EXPECT_CALL(mock_metric_logger, Log(AutoFillMetrics::QUERY_SENT)).Times(0); 299 EXPECT_CALL(mock_metric_logger, Log(AutoFillMetrics::QUERY_SENT)).Times(0);
296 EXPECT_FALSE(helper.download_manager.StartQueryRequest(form_structures, 300 EXPECT_FALSE(helper.download_manager.StartQueryRequest(form_structures,
297 mock_metric_logger)); 301 mock_metric_logger));
298 fetcher = factory.GetFetcherByID(4); 302 fetcher = factory.GetFetcherByID(4);
299 EXPECT_EQ(NULL, fetcher); 303 EXPECT_EQ(NULL, fetcher);
300 304
301 // Set upload to 100% so requests happen. 305 // Set upload to 100% so requests happen.
302 helper.download_manager.SetPositiveUploadRate(1.0); 306 helper.download_manager.SetPositiveUploadRate(1.0);
303 // Request with id 4. 307 // Request with id 4.
304 EXPECT_TRUE(helper.download_manager.StartUploadRequest(*(form_structures[0]), 308 EXPECT_TRUE(helper.download_manager.StartUploadRequest(*(form_structures[0]),
305 true)); 309 true));
306 fetcher = factory.GetFetcherByID(4); 310 fetcher = factory.GetFetcherByID(4);
307 ASSERT_TRUE(fetcher); 311 ASSERT_TRUE(fetcher);
308 fetcher->set_backoff_delay( 312 fetcher->set_backoff_delay(
309 base::TimeDelta::FromMilliseconds(TestTimeouts::action_max_timeout_ms())); 313 base::TimeDelta::FromMilliseconds(TestTimeouts::action_max_timeout_ms()));
310 fetcher->delegate()->OnURLFetchComplete(fetcher, GURL(), URLRequestStatus(), 314 fetcher->delegate()->OnURLFetchComplete(fetcher, GURL(),
315 net::URLRequestStatus(),
311 503, ResponseCookies(), 316 503, ResponseCookies(),
312 std::string(responses[2])); 317 std::string(responses[2]));
313 EXPECT_EQ(AutoFillDownloadTestHelper::REQUEST_UPLOAD_FAILED, 318 EXPECT_EQ(AutoFillDownloadTestHelper::REQUEST_UPLOAD_FAILED,
314 helper.responses_.front().type_of_response); 319 helper.responses_.front().type_of_response);
315 EXPECT_EQ(503, helper.responses_.front().error); 320 EXPECT_EQ(503, helper.responses_.front().error);
316 helper.responses_.pop_front(); 321 helper.responses_.pop_front();
317 322
318 // Upload requests should be ignored for the next 10 seconds. 323 // Upload requests should be ignored for the next 10 seconds.
319 EXPECT_FALSE(helper.download_manager.StartUploadRequest(*(form_structures[0]), 324 EXPECT_FALSE(helper.download_manager.StartUploadRequest(*(form_structures[0]),
320 true)); 325 true));
321 fetcher = factory.GetFetcherByID(5); 326 fetcher = factory.GetFetcherByID(5);
322 EXPECT_EQ(NULL, fetcher); 327 EXPECT_EQ(NULL, fetcher);
323 328
324 // Make sure consumer of URLFetcher does the right thing. 329 // Make sure consumer of URLFetcher does the right thing.
325 URLFetcher::set_factory(NULL); 330 URLFetcher::set_factory(NULL);
326 } 331 }
OLDNEW
« no previous file with comments | « chrome/browser/autofill/autofill_browsertest.cc ('k') | chrome/browser/automation/url_request_automation_job.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698