| OLD | NEW |
| 1 // Copyright (c) 2011 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 <stack> | 5 #include <stack> |
| 6 #include <utility> | 6 #include <utility> |
| 7 | 7 |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/pickle.h" | 9 #include "base/pickle.h" |
| 10 #include "base/synchronization/waitable_event.h" |
| 10 #include "base/threading/thread.h" | 11 #include "base/threading/thread.h" |
| 11 #include "base/synchronization/waitable_event.h" | 12 #include "net/base/io_buffer.h" |
| 12 #include "net/base/net_errors.h" | 13 #include "net/base/net_errors.h" |
| 13 #include "net/http/http_response_headers.h" | 14 #include "net/http/http_response_headers.h" |
| 14 #include "net/url_request/url_request.h" | 15 #include "net/url_request/url_request.h" |
| 15 #include "net/url_request/url_request_error_job.h" | 16 #include "net/url_request/url_request_error_job.h" |
| 16 #include "net/base/io_buffer.h" | |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 18 #include "webkit/appcache/appcache_response.h" | 18 #include "webkit/appcache/appcache_response.h" |
| 19 #include "webkit/appcache/appcache_url_request_job.h" | 19 #include "webkit/appcache/appcache_url_request_job.h" |
| 20 #include "webkit/appcache/mock_appcache_service.h" | 20 #include "webkit/appcache/mock_appcache_service.h" |
| 21 | 21 |
| 22 using net::IOBuffer; | 22 using net::IOBuffer; |
| 23 using net::WrappedIOBuffer; | 23 using net::WrappedIOBuffer; |
| 24 | 24 |
| 25 namespace appcache { | 25 namespace appcache { |
| 26 | 26 |
| (...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 469 | 469 |
| 470 // Start the request. | 470 // Start the request. |
| 471 request_->Start(); | 471 request_->Start(); |
| 472 | 472 |
| 473 // The job should have been picked up. | 473 // The job should have been picked up. |
| 474 EXPECT_FALSE(mock_factory_job_); | 474 EXPECT_FALSE(mock_factory_job_); |
| 475 // Completion is async. | 475 // Completion is async. |
| 476 } | 476 } |
| 477 | 477 |
| 478 void VerifyDeliverNetworkResponse() { | 478 void VerifyDeliverNetworkResponse() { |
| 479 EXPECT_EQ(request_->status().os_error(), | 479 EXPECT_EQ(request_->status().error(), |
| 480 net::ERR_INTERNET_DISCONNECTED); | 480 net::ERR_INTERNET_DISCONNECTED); |
| 481 TestFinished(); | 481 TestFinished(); |
| 482 } | 482 } |
| 483 | 483 |
| 484 // DeliverErrorResponse -------------------------------------------------- | 484 // DeliverErrorResponse -------------------------------------------------- |
| 485 | 485 |
| 486 void DeliverErrorResponse() { | 486 void DeliverErrorResponse() { |
| 487 // This test has async steps. | 487 // This test has async steps. |
| 488 PushNextTask(NewRunnableMethod( | 488 PushNextTask(NewRunnableMethod( |
| 489 this, &AppCacheURLRequestJobTest::VerifyDeliverErrorResponse)); | 489 this, &AppCacheURLRequestJobTest::VerifyDeliverErrorResponse)); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 501 | 501 |
| 502 // Start the request. | 502 // Start the request. |
| 503 request_->Start(); | 503 request_->Start(); |
| 504 | 504 |
| 505 // The job should have been picked up. | 505 // The job should have been picked up. |
| 506 EXPECT_FALSE(mock_factory_job_); | 506 EXPECT_FALSE(mock_factory_job_); |
| 507 // Completion is async. | 507 // Completion is async. |
| 508 } | 508 } |
| 509 | 509 |
| 510 void VerifyDeliverErrorResponse() { | 510 void VerifyDeliverErrorResponse() { |
| 511 EXPECT_EQ(request_->status().os_error(), net::ERR_FAILED); | 511 EXPECT_EQ(request_->status().error(), net::ERR_FAILED); |
| 512 TestFinished(); | 512 TestFinished(); |
| 513 } | 513 } |
| 514 | 514 |
| 515 // DeliverSmallAppCachedResponse -------------------------------------- | 515 // DeliverSmallAppCachedResponse -------------------------------------- |
| 516 // "Small" being small enough to read completely in a single | 516 // "Small" being small enough to read completely in a single |
| 517 // request->Read call. | 517 // request->Read call. |
| 518 | 518 |
| 519 void DeliverSmallAppCachedResponse() { | 519 void DeliverSmallAppCachedResponse() { |
| 520 // This test has several async steps. | 520 // This test has several async steps. |
| 521 // 1. Write a small response to response storage. | 521 // 1. Write a small response to response storage. |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 814 | 814 |
| 815 TEST_F(AppCacheURLRequestJobTest, CancelRequestWithIOPending) { | 815 TEST_F(AppCacheURLRequestJobTest, CancelRequestWithIOPending) { |
| 816 RunTestOnIOThread(&AppCacheURLRequestJobTest::CancelRequestWithIOPending); | 816 RunTestOnIOThread(&AppCacheURLRequestJobTest::CancelRequestWithIOPending); |
| 817 } | 817 } |
| 818 | 818 |
| 819 } // namespace appcache | 819 } // namespace appcache |
| 820 | 820 |
| 821 // AppCacheURLRequestJobTest is expected to always live longer than the | 821 // AppCacheURLRequestJobTest is expected to always live longer than the |
| 822 // runnable methods. This lets us call NewRunnableMethod on its instances. | 822 // runnable methods. This lets us call NewRunnableMethod on its instances. |
| 823 DISABLE_RUNNABLE_METHOD_REFCOUNT(appcache::AppCacheURLRequestJobTest); | 823 DISABLE_RUNNABLE_METHOD_REFCOUNT(appcache::AppCacheURLRequestJobTest); |
| OLD | NEW |