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

Side by Side Diff: webkit/appcache/appcache_update_job_unittest.cc

Issue 5607004: net: Remove typedef net::URLRequestJob URLRequestJob; (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased 2 Created 10 years 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) 2010 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 "testing/gtest/include/gtest/gtest.h" 5 #include "testing/gtest/include/gtest/gtest.h"
6 6
7 #include "base/stl_util-inl.h" 7 #include "base/stl_util-inl.h"
8 #include "base/thread.h" 8 #include "base/thread.h"
9 #include "base/waitable_event.h" 9 #include "base/waitable_event.h"
10 #include "net/base/net_errors.h" 10 #include "net/base/net_errors.h"
(...skipping 23 matching lines...) Expand all
34 34
35 // There are a handful of http accessible resources that we need to conduct 35 // There are a handful of http accessible resources that we need to conduct
36 // these tests. Instead of running a seperate server to host these resources, 36 // these tests. Instead of running a seperate server to host these resources,
37 // we mock them up. 37 // we mock them up.
38 class MockHttpServer { 38 class MockHttpServer {
39 public: 39 public:
40 static GURL GetMockUrl(const std::string& path) { 40 static GURL GetMockUrl(const std::string& path) {
41 return GURL("http://mockhost/" + path); 41 return GURL("http://mockhost/" + path);
42 } 42 }
43 43
44 static URLRequestJob* JobFactory(net::URLRequest* request, 44 static net::URLRequestJob* JobFactory(net::URLRequest* request,
45 const std::string& scheme) { 45 const std::string& scheme) {
46 if (request->url().host() != "mockhost") 46 if (request->url().host() != "mockhost")
47 return new URLRequestErrorJob(request, -1); 47 return new URLRequestErrorJob(request, -1);
48 48
49 std::string headers, body; 49 std::string headers, body;
50 GetMockResponse(request->url().path(), &headers, &body); 50 GetMockResponse(request->url().path(), &headers, &body);
51 return new URLRequestTestJob(request, headers, body, true); 51 return new URLRequestTestJob(request, headers, body, true);
52 } 52 }
53 53
54 private: 54 private:
55 static void GetMockResponse(const std::string& path, 55 static void GetMockResponse(const std::string& path,
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 int last_progress_total_; 280 int last_progress_total_;
281 int last_progress_complete_; 281 int last_progress_complete_;
282 282
283 // Add ability for frontend to add master entries to an inprogress update. 283 // Add ability for frontend to add master entries to an inprogress update.
284 EventID start_update_trigger_; 284 EventID start_update_trigger_;
285 AppCacheUpdateJob* update_; 285 AppCacheUpdateJob* update_;
286 std::vector<AppCacheHost*> update_hosts_; 286 std::vector<AppCacheHost*> update_hosts_;
287 }; 287 };
288 288
289 // Helper factories to simulate redirected URL responses for tests. 289 // Helper factories to simulate redirected URL responses for tests.
290 static URLRequestJob* RedirectFactory(net::URLRequest* request, 290 static net::URLRequestJob* RedirectFactory(net::URLRequest* request,
291 const std::string& scheme) { 291 const std::string& scheme) {
292 return new URLRequestTestJob(request, 292 return new URLRequestTestJob(request,
293 URLRequestTestJob::test_redirect_headers(), 293 URLRequestTestJob::test_redirect_headers(),
294 URLRequestTestJob::test_data_1(), 294 URLRequestTestJob::test_data_1(),
295 true); 295 true);
296 } 296 }
297 297
298 // Helper class to simulate a URL that returns retry or success. 298 // Helper class to simulate a URL that returns retry or success.
299 class RetryRequestTestJob : public URLRequestTestJob { 299 class RetryRequestTestJob : public URLRequestTestJob {
300 public: 300 public:
301 enum RetryHeader { 301 enum RetryHeader {
(...skipping 13 matching lines...) Expand all
315 expected_requests_ = expected_requests; 315 expected_requests_ = expected_requests;
316 } 316 }
317 317
318 // Verifies results at end of test and resets counters. 318 // Verifies results at end of test and resets counters.
319 static void Verify() { 319 static void Verify() {
320 EXPECT_EQ(expected_requests_, num_requests_); 320 EXPECT_EQ(expected_requests_, num_requests_);
321 num_requests_ = 0; 321 num_requests_ = 0;
322 expected_requests_ = 0; 322 expected_requests_ = 0;
323 } 323 }
324 324
325 static URLRequestJob* RetryFactory(net::URLRequest* request, 325 static net::URLRequestJob* RetryFactory(net::URLRequest* request,
326 const std::string& scheme) { 326 const std::string& scheme) {
327 ++num_requests_; 327 ++num_requests_;
328 if (num_retries_ > 0 && request->original_url() == kRetryUrl) { 328 if (num_retries_ > 0 && request->original_url() == kRetryUrl) {
329 --num_retries_; 329 --num_retries_;
330 return new RetryRequestTestJob( 330 return new RetryRequestTestJob(
331 request, RetryRequestTestJob::retry_headers(), 503); 331 request, RetryRequestTestJob::retry_headers(), 503);
332 } else { 332 } else {
333 return new RetryRequestTestJob( 333 return new RetryRequestTestJob(
334 request, RetryRequestTestJob::manifest_headers(), 200); 334 request, RetryRequestTestJob::manifest_headers(), 200);
335 } 335 }
336 } 336 }
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 EXPECT_TRUE(saw_if_none_match_); 417 EXPECT_TRUE(saw_if_none_match_);
418 418
419 // Reset. 419 // Reset.
420 expect_if_modified_since_.clear(); 420 expect_if_modified_since_.clear();
421 saw_if_modified_since_ = false; 421 saw_if_modified_since_ = false;
422 expect_if_none_match_.clear(); 422 expect_if_none_match_.clear();
423 saw_if_none_match_ = false; 423 saw_if_none_match_ = false;
424 already_checked_ = false; 424 already_checked_ = false;
425 } 425 }
426 426
427 static URLRequestJob* IfModifiedSinceFactory(net::URLRequest* request, 427 static net::URLRequestJob* IfModifiedSinceFactory(net::URLRequest* request,
428 const std::string& scheme) { 428 const std::string& scheme) {
429 if (!already_checked_) { 429 if (!already_checked_) {
430 already_checked_ = true; // only check once for a test 430 already_checked_ = true; // only check once for a test
431 const net::HttpRequestHeaders& extra_headers = 431 const net::HttpRequestHeaders& extra_headers =
432 request->extra_request_headers(); 432 request->extra_request_headers();
433 std::string header_value; 433 std::string header_value;
434 saw_if_modified_since_ = 434 saw_if_modified_since_ =
435 extra_headers.GetHeader( 435 extra_headers.GetHeader(
436 net::HttpRequestHeaders::kIfModifiedSince, &header_value) && 436 net::HttpRequestHeaders::kIfModifiedSince, &header_value) &&
437 header_value == expect_if_modified_since_; 437 header_value == expect_if_modified_since_;
438 438
(...skipping 3018 matching lines...) Expand 10 before | Expand all | Expand 10 after
3457 RunTestOnIOThread(&AppCacheUpdateJobTest::MultipleHeadersRefetchTest); 3457 RunTestOnIOThread(&AppCacheUpdateJobTest::MultipleHeadersRefetchTest);
3458 } 3458 }
3459 3459
3460 } // namespace appcache 3460 } // namespace appcache
3461 3461
3462 // AppCacheUpdateJobTest is expected to always live longer than the 3462 // AppCacheUpdateJobTest is expected to always live longer than the
3463 // runnable methods. This lets us call NewRunnableMethod on its instances. 3463 // runnable methods. This lets us call NewRunnableMethod on its instances.
3464 DISABLE_RUNNABLE_METHOD_REFCOUNT(appcache::AppCacheUpdateJobTest); 3464 DISABLE_RUNNABLE_METHOD_REFCOUNT(appcache::AppCacheUpdateJobTest);
3465 DISABLE_RUNNABLE_METHOD_REFCOUNT( 3465 DISABLE_RUNNABLE_METHOD_REFCOUNT(
3466 appcache::AppCacheUpdateJobTest::MockAppCachePolicy); 3466 appcache::AppCacheUpdateJobTest::MockAppCachePolicy);
OLDNEW
« no previous file with comments | « webkit/appcache/appcache_request_handler_unittest.cc ('k') | webkit/appcache/appcache_url_request_job.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698