OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #import "ios/chrome/browser/net/retryable_url_fetcher.h" | 5 #import "ios/chrome/browser/net/retryable_url_fetcher.h" |
6 | 6 |
7 #import "base/mac/scoped_nsobject.h" | 7 #import "base/mac/scoped_nsobject.h" |
8 #include "ios/web/public/test/test_web_thread.h" | 8 #include "ios/web/public/test/test_web_thread.h" |
9 #include "net/url_request/test_url_fetcher_factory.h" | 9 #include "net/url_request/test_url_fetcher_factory.h" |
10 #include "net/url_request/url_fetcher_delegate.h" | 10 #include "net/url_request/url_fetcher_delegate.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 class RetryableURLFetcherTest : public PlatformTest { | 46 class RetryableURLFetcherTest : public PlatformTest { |
47 protected: | 47 protected: |
48 void SetUp() override { | 48 void SetUp() override { |
49 PlatformTest::SetUp(); | 49 PlatformTest::SetUp(); |
50 test_delegate_.reset([[TestRetryableURLFetcherDelegate alloc] init]); | 50 test_delegate_.reset([[TestRetryableURLFetcherDelegate alloc] init]); |
51 io_thread_.reset( | 51 io_thread_.reset( |
52 new web::TestWebThread(web::WebThread::IO, &message_loop_)); | 52 new web::TestWebThread(web::WebThread::IO, &message_loop_)); |
53 } | 53 } |
54 | 54 |
55 net::TestURLFetcherFactory factory_; | 55 net::TestURLFetcherFactory factory_; |
56 scoped_ptr<web::TestWebThread> io_thread_; | 56 std::unique_ptr<web::TestWebThread> io_thread_; |
57 base::MessageLoop message_loop_; | 57 base::MessageLoop message_loop_; |
58 base::scoped_nsobject<TestRetryableURLFetcherDelegate> test_delegate_; | 58 base::scoped_nsobject<TestRetryableURLFetcherDelegate> test_delegate_; |
59 }; | 59 }; |
60 | 60 |
61 TEST_F(RetryableURLFetcherTest, TestResponse200) { | 61 TEST_F(RetryableURLFetcherTest, TestResponse200) { |
62 scoped_refptr<net::URLRequestContextGetter> request_context_getter = | 62 scoped_refptr<net::URLRequestContextGetter> request_context_getter = |
63 new net::TestURLRequestContextGetter(message_loop_.task_runner()); | 63 new net::TestURLRequestContextGetter(message_loop_.task_runner()); |
64 base::scoped_nsobject<RetryableURLFetcher> retryableFetcher( | 64 base::scoped_nsobject<RetryableURLFetcher> retryableFetcher( |
65 [[RetryableURLFetcher alloc] | 65 [[RetryableURLFetcher alloc] |
66 initWithRequestContextGetter:request_context_getter.get() | 66 initWithRequestContextGetter:request_context_getter.get() |
(...skipping 27 matching lines...) Expand all Loading... |
94 DCHECK(fetcher); | 94 DCHECK(fetcher); |
95 DCHECK(fetcher->delegate()); | 95 DCHECK(fetcher->delegate()); |
96 [test_delegate_ setResponsesProcessed:0U]; | 96 [test_delegate_ setResponsesProcessed:0U]; |
97 fetcher->set_response_code(404); | 97 fetcher->set_response_code(404); |
98 fetcher->SetResponseString(""); | 98 fetcher->SetResponseString(""); |
99 fetcher->delegate()->OnURLFetchComplete(fetcher); | 99 fetcher->delegate()->OnURLFetchComplete(fetcher); |
100 EXPECT_EQ(0U, [test_delegate_ responsesProcessed]); | 100 EXPECT_EQ(0U, [test_delegate_ responsesProcessed]); |
101 } | 101 } |
102 | 102 |
103 } // namespace | 103 } // namespace |
OLD | NEW |