OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/web/web_state/crw_pass_kit_downloader.h" | 5 #import "ios/web/web_state/crw_pass_kit_downloader.h" |
6 | 6 |
7 #import <Foundation/Foundation.h> | 7 #import <Foundation/Foundation.h> |
8 | 8 |
| 9 #include <memory> |
| 10 |
9 #import "base/mac/scoped_nsobject.h" | 11 #import "base/mac/scoped_nsobject.h" |
10 #include "base/memory/scoped_ptr.h" | |
11 #import "ios/web/test/web_test.h" | 12 #import "ios/web/test/web_test.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/test_url_fetcher_factory.h" | 15 #include "net/url_request/test_url_fetcher_factory.h" |
15 #include "net/url_request/url_fetcher_delegate.h" | 16 #include "net/url_request/url_fetcher_delegate.h" |
16 #include "net/url_request/url_request_test_util.h" | 17 #include "net/url_request/url_request_test_util.h" |
17 #include "testing/gtest_mac.h" | 18 #include "testing/gtest_mac.h" |
18 #include "url/gurl.h" | 19 #include "url/gurl.h" |
19 | 20 |
20 using net::HttpResponseHeaders; | 21 using net::HttpResponseHeaders; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 fetcher->set_status(status); | 57 fetcher->set_status(status); |
57 fetcher->set_response_code(response_code); | 58 fetcher->set_response_code(response_code); |
58 scoped_refptr<HttpResponseHeaders> headers; | 59 scoped_refptr<HttpResponseHeaders> headers; |
59 headers = new HttpResponseHeaders("HTTP/1.x 200 OK\0"); | 60 headers = new HttpResponseHeaders("HTTP/1.x 200 OK\0"); |
60 headers->AddHeader("Content-Type: " + mime_type); | 61 headers->AddHeader("Content-Type: " + mime_type); |
61 fetcher->set_response_headers(headers); | 62 fetcher->set_response_headers(headers); |
62 } | 63 } |
63 | 64 |
64 // Test fetcher factory from which we access and control the URLFetcher | 65 // Test fetcher factory from which we access and control the URLFetcher |
65 // used in CRWPassKitDownloader. | 66 // used in CRWPassKitDownloader. |
66 scoped_ptr<net::TestURLFetcherFactory> fetcher_factory_; | 67 std::unique_ptr<net::TestURLFetcherFactory> fetcher_factory_; |
67 | 68 |
68 // The CRWPassKitDownloader that is being tested. | 69 // The CRWPassKitDownloader that is being tested. |
69 base::scoped_nsobject<CRWPassKitDownloader> downloader_; | 70 base::scoped_nsobject<CRWPassKitDownloader> downloader_; |
70 | 71 |
71 // Indicates whether or not the downloader successfully downloaded data. It is | 72 // Indicates whether or not the downloader successfully downloaded data. It is |
72 // set from the completion handler based on whether actual data is equal to | 73 // set from the completion handler based on whether actual data is equal to |
73 // expected data. | 74 // expected data. |
74 bool completion_handler_success_; | 75 bool completion_handler_success_; |
75 }; | 76 }; |
76 | 77 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 ASSERT_TRUE(fetcher); | 148 ASSERT_TRUE(fetcher); |
148 ASSERT_EQ(test_url, fetcher->GetOriginalURL()); | 149 ASSERT_EQ(test_url, fetcher->GetOriginalURL()); |
149 SetUpFetcher(fetcher, URLRequestStatus(), 200, kPassKitMimeType); | 150 SetUpFetcher(fetcher, URLRequestStatus(), 200, kPassKitMimeType); |
150 fetcher->delegate()->OnURLFetchComplete(fetcher); | 151 fetcher->delegate()->OnURLFetchComplete(fetcher); |
151 | 152 |
152 EXPECT_FALSE([shared_app isNetworkActivityIndicatorVisible]); | 153 EXPECT_FALSE([shared_app isNetworkActivityIndicatorVisible]); |
153 EXPECT_FALSE(completion_handler_success_); | 154 EXPECT_FALSE(completion_handler_success_); |
154 } | 155 } |
155 | 156 |
156 } // namespace | 157 } // namespace |
OLD | NEW |