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

Side by Side Diff: ios/web/web_state/crw_pass_kit_downloader_unittest.mm

Issue 2566493003: Remove CRWNetworkActivityIndicatorManager. (Closed)
Patch Set: Remove duplicate file refs. Created 4 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
OLDNEW
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 <UIKit/UIKit.h> 7 #import <UIKit/UIKit.h>
8 8
9 #include <memory> 9 #include <memory>
10 10
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 // 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
74 // expected data. 74 // expected data.
75 bool completion_handler_success_; 75 bool completion_handler_success_;
76 }; 76 };
77 77
78 // Tests case where CRWPassKitDownloader successfully downloads data. 78 // Tests case where CRWPassKitDownloader successfully downloads data.
79 TEST_F(CRWPassKitDownloaderTest, TestDownloadPassKitSuccess) { 79 TEST_F(CRWPassKitDownloaderTest, TestDownloadPassKitSuccess) {
80 GURL test_url(kTestUrlString); 80 GURL test_url(kTestUrlString);
81 [downloader_ downloadPassKitFileWithURL:test_url]; 81 [downloader_ downloadPassKitFileWithURL:test_url];
82 82
83 UIApplication* shared_app = [UIApplication sharedApplication];
84 EXPECT_TRUE([shared_app isNetworkActivityIndicatorVisible]);
85
86 net::TestURLFetcher* fetcher = fetcher_factory_->GetFetcherByID(0); 83 net::TestURLFetcher* fetcher = fetcher_factory_->GetFetcherByID(0);
87 ASSERT_TRUE(fetcher); 84 ASSERT_TRUE(fetcher);
88 ASSERT_EQ(test_url, fetcher->GetOriginalURL()); 85 ASSERT_EQ(test_url, fetcher->GetOriginalURL());
89 SetUpFetcher(fetcher, URLRequestStatus(), 200, kPassKitMimeType); 86 SetUpFetcher(fetcher, URLRequestStatus(), 200, kPassKitMimeType);
90 fetcher->SetResponseString(kExpectedString); 87 fetcher->SetResponseString(kExpectedString);
91 fetcher->delegate()->OnURLFetchComplete(fetcher); 88 fetcher->delegate()->OnURLFetchComplete(fetcher);
92 89
93 EXPECT_FALSE([shared_app isNetworkActivityIndicatorVisible]);
94 EXPECT_TRUE(completion_handler_success_); 90 EXPECT_TRUE(completion_handler_success_);
95 } 91 }
96 92
97 // Tests case where CRWPassKitDownloader fails download due to a bad HTTP 93 // Tests case where CRWPassKitDownloader fails download due to a bad HTTP
98 // response code. |completion_handler_success_| should be false. 94 // response code. |completion_handler_success_| should be false.
99 TEST_F(CRWPassKitDownloaderTest, TestDownloadPassKitBadErrorCodeFailure) { 95 TEST_F(CRWPassKitDownloaderTest, TestDownloadPassKitBadErrorCodeFailure) {
100 GURL test_url(kTestUrlString); 96 GURL test_url(kTestUrlString);
101 [downloader_ downloadPassKitFileWithURL:test_url]; 97 [downloader_ downloadPassKitFileWithURL:test_url];
102 98
103 UIApplication* shared_app = [UIApplication sharedApplication];
104 EXPECT_TRUE([shared_app isNetworkActivityIndicatorVisible]);
105
106 net::TestURLFetcher* fetcher = fetcher_factory_->GetFetcherByID(0); 99 net::TestURLFetcher* fetcher = fetcher_factory_->GetFetcherByID(0);
107 ASSERT_TRUE(fetcher); 100 ASSERT_TRUE(fetcher);
108 ASSERT_EQ(test_url, fetcher->GetOriginalURL()); 101 ASSERT_EQ(test_url, fetcher->GetOriginalURL());
109 SetUpFetcher(fetcher, URLRequestStatus(), 403, kPassKitMimeType); 102 SetUpFetcher(fetcher, URLRequestStatus(), 403, kPassKitMimeType);
110 fetcher->SetResponseString(kExpectedString); 103 fetcher->SetResponseString(kExpectedString);
111 fetcher->delegate()->OnURLFetchComplete(fetcher); 104 fetcher->delegate()->OnURLFetchComplete(fetcher);
112 105
113 EXPECT_FALSE([shared_app isNetworkActivityIndicatorVisible]);
114 EXPECT_FALSE(completion_handler_success_); 106 EXPECT_FALSE(completion_handler_success_);
115 } 107 }
116 108
117 // Tests case where CRWPassKitDownloader fails download with a status set to 109 // Tests case where CRWPassKitDownloader fails download with a status set to
118 // failure. |completion_handler_success_| should be false. 110 // failure. |completion_handler_success_| should be false.
119 TEST_F(CRWPassKitDownloaderTest, TestDownloadPassKitStatusFailedFailure) { 111 TEST_F(CRWPassKitDownloaderTest, TestDownloadPassKitStatusFailedFailure) {
120 GURL test_url(kTestUrlString); 112 GURL test_url(kTestUrlString);
121 [downloader_ downloadPassKitFileWithURL:test_url]; 113 [downloader_ downloadPassKitFileWithURL:test_url];
122 114
123 UIApplication* shared_app = [UIApplication sharedApplication];
124 EXPECT_TRUE([shared_app isNetworkActivityIndicatorVisible]);
125
126 net::TestURLFetcher* fetcher = fetcher_factory_->GetFetcherByID(0); 115 net::TestURLFetcher* fetcher = fetcher_factory_->GetFetcherByID(0);
127 ASSERT_TRUE(fetcher); 116 ASSERT_TRUE(fetcher);
128 ASSERT_EQ(test_url, fetcher->GetOriginalURL()); 117 ASSERT_EQ(test_url, fetcher->GetOriginalURL());
129 SetUpFetcher(fetcher, URLRequestStatus::FromError(net::ERR_ACCESS_DENIED), 118 SetUpFetcher(fetcher, URLRequestStatus::FromError(net::ERR_ACCESS_DENIED),
130 200, kPassKitMimeType); 119 200, kPassKitMimeType);
131 fetcher->SetResponseString(kExpectedString); 120 fetcher->SetResponseString(kExpectedString);
132 fetcher->delegate()->OnURLFetchComplete(fetcher); 121 fetcher->delegate()->OnURLFetchComplete(fetcher);
133 122
134 EXPECT_FALSE([shared_app isNetworkActivityIndicatorVisible]);
135 EXPECT_FALSE(completion_handler_success_); 123 EXPECT_FALSE(completion_handler_success_);
136 } 124 }
137 125
138 // Tests case where CRWPassKitDownloader fails download with no response data. 126 // Tests case where CRWPassKitDownloader fails download with no response data.
139 // |completion_handler_success_| should be false. 127 // |completion_handler_success_| should be false.
140 TEST_F(CRWPassKitDownloaderTest, TestDownloadPassKitNoResponseFailure) { 128 TEST_F(CRWPassKitDownloaderTest, TestDownloadPassKitNoResponseFailure) {
141 GURL test_url(kTestUrlString); 129 GURL test_url(kTestUrlString);
142 [downloader_ downloadPassKitFileWithURL:test_url]; 130 [downloader_ downloadPassKitFileWithURL:test_url];
143 131
144 UIApplication* shared_app = [UIApplication sharedApplication];
145 EXPECT_TRUE([shared_app isNetworkActivityIndicatorVisible]);
146
147 net::TestURLFetcher* fetcher = fetcher_factory_->GetFetcherByID(0); 132 net::TestURLFetcher* fetcher = fetcher_factory_->GetFetcherByID(0);
148 ASSERT_TRUE(fetcher); 133 ASSERT_TRUE(fetcher);
149 ASSERT_EQ(test_url, fetcher->GetOriginalURL()); 134 ASSERT_EQ(test_url, fetcher->GetOriginalURL());
150 SetUpFetcher(fetcher, URLRequestStatus(), 200, kPassKitMimeType); 135 SetUpFetcher(fetcher, URLRequestStatus(), 200, kPassKitMimeType);
151 fetcher->delegate()->OnURLFetchComplete(fetcher); 136 fetcher->delegate()->OnURLFetchComplete(fetcher);
152 137
153 EXPECT_FALSE([shared_app isNetworkActivityIndicatorVisible]);
154 EXPECT_FALSE(completion_handler_success_); 138 EXPECT_FALSE(completion_handler_success_);
155 } 139 }
156 140
157 } // namespace 141 } // namespace
OLDNEW
« no previous file with comments | « ios/web/web_state/crw_pass_kit_downloader.mm ('k') | ios/web/web_state/ui/crw_web_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698