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

Side by Side Diff: components/precache/core/precache_fetcher_unittest.cc

Issue 818103002: Make callers of CommandLine use it via the base:: namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "components/precache/core/precache_fetcher.h" 5 #include "components/precache/core/precache_fetcher.h"
6 6
7 #include <list> 7 #include <list>
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 10
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 "http://manifest-url-prefix.com/http%253A%252F%252Fbad-manifest.com%252F"; 95 "http://manifest-url-prefix.com/http%253A%252F%252Fbad-manifest.com%252F";
96 const char kGoodManifestURL[] = 96 const char kGoodManifestURL[] =
97 "http://manifest-url-prefix.com/http%253A%252F%252Fgood-manifest.com%252F"; 97 "http://manifest-url-prefix.com/http%253A%252F%252Fgood-manifest.com%252F";
98 const char kResourceFetchFailureURL[] = "http://resource-fetch-failure.com"; 98 const char kResourceFetchFailureURL[] = "http://resource-fetch-failure.com";
99 const char kGoodResourceURL[] = "http://good-resource.com"; 99 const char kGoodResourceURL[] = "http://good-resource.com";
100 const char kForcedStartingURLManifestURL[] = 100 const char kForcedStartingURLManifestURL[] =
101 "http://manifest-url-prefix.com/" 101 "http://manifest-url-prefix.com/"
102 "http%253A%252F%252Fforced-starting-url.com%252F"; 102 "http%253A%252F%252Fforced-starting-url.com%252F";
103 103
104 TEST_F(PrecacheFetcherTest, FullPrecache) { 104 TEST_F(PrecacheFetcherTest, FullPrecache) {
105 CommandLine::ForCurrentProcess()->AppendSwitchASCII( 105 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
106 switches::kPrecacheConfigSettingsURL, kConfigURL); 106 switches::kPrecacheConfigSettingsURL, kConfigURL);
107 CommandLine::ForCurrentProcess()->AppendSwitchASCII( 107 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
108 switches::kPrecacheManifestURLPrefix, kManfiestURLPrefix); 108 switches::kPrecacheManifestURLPrefix, kManfiestURLPrefix);
109 109
110 std::list<GURL> starting_urls; 110 std::list<GURL> starting_urls;
111 starting_urls.push_back(GURL("http://manifest-fetch-failure.com")); 111 starting_urls.push_back(GURL("http://manifest-fetch-failure.com"));
112 starting_urls.push_back(GURL("http://bad-manifest.com")); 112 starting_urls.push_back(GURL("http://bad-manifest.com"));
113 starting_urls.push_back(GURL("http://good-manifest.com")); 113 starting_urls.push_back(GURL("http://good-manifest.com"));
114 starting_urls.push_back(GURL("http://not-in-top-3.com")); 114 starting_urls.push_back(GURL("http://not-in-top-3.com"));
115 115
116 PrecacheConfigurationSettings config; 116 PrecacheConfigurationSettings config;
117 config.set_top_sites_count(3); 117 config.set_top_sites_count(3);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 expected_requested_urls.insert(GURL(kResourceFetchFailureURL)); 157 expected_requested_urls.insert(GURL(kResourceFetchFailureURL));
158 expected_requested_urls.insert(GURL(kGoodResourceURL)); 158 expected_requested_urls.insert(GURL(kGoodResourceURL));
159 expected_requested_urls.insert(GURL(kForcedStartingURLManifestURL)); 159 expected_requested_urls.insert(GURL(kForcedStartingURLManifestURL));
160 160
161 EXPECT_EQ(expected_requested_urls, url_callback_.requested_urls()); 161 EXPECT_EQ(expected_requested_urls, url_callback_.requested_urls());
162 162
163 EXPECT_TRUE(precache_delegate_.was_on_done_called()); 163 EXPECT_TRUE(precache_delegate_.was_on_done_called());
164 } 164 }
165 165
166 TEST_F(PrecacheFetcherTest, ConfigFetchFailure) { 166 TEST_F(PrecacheFetcherTest, ConfigFetchFailure) {
167 CommandLine::ForCurrentProcess()->AppendSwitchASCII( 167 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
168 switches::kPrecacheConfigSettingsURL, kConfigURL); 168 switches::kPrecacheConfigSettingsURL, kConfigURL);
169 169
170 std::list<GURL> starting_urls(1, GURL("http://starting-url.com")); 170 std::list<GURL> starting_urls(1, GURL("http://starting-url.com"));
171 171
172 factory_.SetFakeResponse(GURL(kConfigURL), "", 172 factory_.SetFakeResponse(GURL(kConfigURL), "",
173 net::HTTP_INTERNAL_SERVER_ERROR, 173 net::HTTP_INTERNAL_SERVER_ERROR,
174 net::URLRequestStatus::FAILED); 174 net::URLRequestStatus::FAILED);
175 175
176 PrecacheFetcher precache_fetcher(starting_urls, request_context_.get(), 176 PrecacheFetcher precache_fetcher(starting_urls, request_context_.get(),
177 &precache_delegate_); 177 &precache_delegate_);
178 precache_fetcher.Start(); 178 precache_fetcher.Start();
179 179
180 base::MessageLoop::current()->RunUntilIdle(); 180 base::MessageLoop::current()->RunUntilIdle();
181 181
182 std::multiset<GURL> expected_requested_urls; 182 std::multiset<GURL> expected_requested_urls;
183 expected_requested_urls.insert(GURL(kConfigURL)); 183 expected_requested_urls.insert(GURL(kConfigURL));
184 EXPECT_EQ(expected_requested_urls, url_callback_.requested_urls()); 184 EXPECT_EQ(expected_requested_urls, url_callback_.requested_urls());
185 185
186 EXPECT_TRUE(precache_delegate_.was_on_done_called()); 186 EXPECT_TRUE(precache_delegate_.was_on_done_called());
187 } 187 }
188 188
189 TEST_F(PrecacheFetcherTest, BadConfig) { 189 TEST_F(PrecacheFetcherTest, BadConfig) {
190 CommandLine::ForCurrentProcess()->AppendSwitchASCII( 190 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
191 switches::kPrecacheConfigSettingsURL, kConfigURL); 191 switches::kPrecacheConfigSettingsURL, kConfigURL);
192 192
193 std::list<GURL> starting_urls(1, GURL("http://starting-url.com")); 193 std::list<GURL> starting_urls(1, GURL("http://starting-url.com"));
194 194
195 factory_.SetFakeResponse(GURL(kConfigURL), "bad protobuf", net::HTTP_OK, 195 factory_.SetFakeResponse(GURL(kConfigURL), "bad protobuf", net::HTTP_OK,
196 net::URLRequestStatus::SUCCESS); 196 net::URLRequestStatus::SUCCESS);
197 197
198 PrecacheFetcher precache_fetcher(starting_urls, request_context_.get(), 198 PrecacheFetcher precache_fetcher(starting_urls, request_context_.get(),
199 &precache_delegate_); 199 &precache_delegate_);
200 precache_fetcher.Start(); 200 precache_fetcher.Start();
201 201
202 base::MessageLoop::current()->RunUntilIdle(); 202 base::MessageLoop::current()->RunUntilIdle();
203 203
204 std::multiset<GURL> expected_requested_urls; 204 std::multiset<GURL> expected_requested_urls;
205 expected_requested_urls.insert(GURL(kConfigURL)); 205 expected_requested_urls.insert(GURL(kConfigURL));
206 EXPECT_EQ(expected_requested_urls, url_callback_.requested_urls()); 206 EXPECT_EQ(expected_requested_urls, url_callback_.requested_urls());
207 207
208 EXPECT_TRUE(precache_delegate_.was_on_done_called()); 208 EXPECT_TRUE(precache_delegate_.was_on_done_called());
209 } 209 }
210 210
211 TEST_F(PrecacheFetcherTest, Cancel) { 211 TEST_F(PrecacheFetcherTest, Cancel) {
212 CommandLine::ForCurrentProcess()->AppendSwitchASCII( 212 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
213 switches::kPrecacheConfigSettingsURL, kConfigURL); 213 switches::kPrecacheConfigSettingsURL, kConfigURL);
214 214
215 std::list<GURL> starting_urls(1, GURL("http://starting-url.com")); 215 std::list<GURL> starting_urls(1, GURL("http://starting-url.com"));
216 216
217 PrecacheConfigurationSettings config; 217 PrecacheConfigurationSettings config;
218 config.set_top_sites_count(1); 218 config.set_top_sites_count(1);
219 219
220 factory_.SetFakeResponse(GURL(kConfigURL), config.SerializeAsString(), 220 factory_.SetFakeResponse(GURL(kConfigURL), config.SerializeAsString(),
221 net::HTTP_OK, net::URLRequestStatus::SUCCESS); 221 net::HTTP_OK, net::URLRequestStatus::SUCCESS);
222 222
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 EXPECT_TRUE(precache_delegate_.was_on_done_called()); 264 EXPECT_TRUE(precache_delegate_.was_on_done_called());
265 } 265 }
266 266
267 #endif // PRECACHE_CONFIG_SETTINGS_URL 267 #endif // PRECACHE_CONFIG_SETTINGS_URL
268 268
269 #if defined(PRECACHE_MANIFEST_URL_PREFIX) 269 #if defined(PRECACHE_MANIFEST_URL_PREFIX)
270 270
271 // If the default precache manifest URL prefix is defined, then test that it 271 // If the default precache manifest URL prefix is defined, then test that it
272 // works with the PrecacheFetcher. 272 // works with the PrecacheFetcher.
273 TEST_F(PrecacheFetcherTest, PrecacheUsingDefaultManifestURLPrefix) { 273 TEST_F(PrecacheFetcherTest, PrecacheUsingDefaultManifestURLPrefix) {
274 CommandLine::ForCurrentProcess()->AppendSwitchASCII( 274 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
275 switches::kPrecacheConfigSettingsURL, kConfigURL); 275 switches::kPrecacheConfigSettingsURL, kConfigURL);
276 276
277 std::list<GURL> starting_urls(1, GURL("http://starting-url.com")); 277 std::list<GURL> starting_urls(1, GURL("http://starting-url.com"));
278 278
279 PrecacheConfigurationSettings config; 279 PrecacheConfigurationSettings config;
280 config.set_top_sites_count(1); 280 config.set_top_sites_count(1);
281 281
282 GURL manifest_url(PRECACHE_MANIFEST_URL_PREFIX 282 GURL manifest_url(PRECACHE_MANIFEST_URL_PREFIX
283 "http%253A%252F%252Fstarting-url.com%252F"); 283 "http%253A%252F%252Fstarting-url.com%252F");
284 284
(...skipping 14 matching lines...) Expand all
299 EXPECT_EQ(expected_requested_urls, url_callback_.requested_urls()); 299 EXPECT_EQ(expected_requested_urls, url_callback_.requested_urls());
300 300
301 EXPECT_TRUE(precache_delegate_.was_on_done_called()); 301 EXPECT_TRUE(precache_delegate_.was_on_done_called());
302 } 302 }
303 303
304 #endif // PRECACHE_MANIFEST_URL_PREFIX 304 #endif // PRECACHE_MANIFEST_URL_PREFIX
305 305
306 } // namespace 306 } // namespace
307 307
308 } // namespace precache 308 } // namespace precache
OLDNEW
« no previous file with comments | « components/precache/core/precache_fetcher.cc ('k') | components/proximity_auth/cryptauth/cryptauth_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698