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

Side by Side Diff: net/base/sdch_manager_unittest.cc

Issue 509563003: Remove implicit conversions from scoped_refptr to T* in net/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months 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
« no previous file with comments | « net/base/file_stream_unittest.cc ('k') | net/base/upload_file_element_reader.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include <limits.h> 5 #include <limits.h>
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 // enabled. 190 // enabled.
191 sdch_manager()->GetAvailDictionaryList(target_url, &dictionary_list); 191 sdch_manager()->GetAvailDictionaryList(target_url, &dictionary_list);
192 EXPECT_FALSE(dictionary_list.empty()); 192 EXPECT_FALSE(dictionary_list.empty());
193 193
194 // Dictionary should be available. 194 // Dictionary should be available.
195 scoped_refptr<SdchManager::Dictionary> dictionary; 195 scoped_refptr<SdchManager::Dictionary> dictionary;
196 std::string client_hash; 196 std::string client_hash;
197 std::string server_hash; 197 std::string server_hash;
198 sdch_manager()->GenerateHash(dictionary_text, &client_hash, &server_hash); 198 sdch_manager()->GenerateHash(dictionary_text, &client_hash, &server_hash);
199 sdch_manager()->GetVcdiffDictionary(server_hash, target_url, &dictionary); 199 sdch_manager()->GetVcdiffDictionary(server_hash, target_url, &dictionary);
200 EXPECT_TRUE(dictionary != NULL); 200 EXPECT_TRUE(dictionary.get() != NULL);
201 } 201 }
202 202
203 TEST_F(SdchManagerTest, CanNotUseHTTPDictionaryOverHTTPS) { 203 TEST_F(SdchManagerTest, CanNotUseHTTPDictionaryOverHTTPS) {
204 std::string dictionary_domain("x.y.z.google.com"); 204 std::string dictionary_domain("x.y.z.google.com");
205 std::string dictionary_text(NewSdchDictionary(dictionary_domain)); 205 std::string dictionary_text(NewSdchDictionary(dictionary_domain));
206 206
207 EXPECT_TRUE(sdch_manager()->AddSdchDictionary(dictionary_text, 207 EXPECT_TRUE(sdch_manager()->AddSdchDictionary(dictionary_text,
208 GURL("http://" + dictionary_domain))); 208 GURL("http://" + dictionary_domain)));
209 209
210 GURL target_url("https://" + dictionary_domain + "/test"); 210 GURL target_url("https://" + dictionary_domain + "/test");
211 std::string dictionary_list; 211 std::string dictionary_list;
212 // HTTPS target URL should not advertise dictionary acquired over HTTP even if 212 // HTTPS target URL should not advertise dictionary acquired over HTTP even if
213 // secure scheme support is enabled. 213 // secure scheme support is enabled.
214 SdchManager::EnableSecureSchemeSupport(true); 214 SdchManager::EnableSecureSchemeSupport(true);
215 sdch_manager()->GetAvailDictionaryList(target_url, &dictionary_list); 215 sdch_manager()->GetAvailDictionaryList(target_url, &dictionary_list);
216 EXPECT_TRUE(dictionary_list.empty()); 216 EXPECT_TRUE(dictionary_list.empty());
217 217
218 scoped_refptr<SdchManager::Dictionary> dictionary; 218 scoped_refptr<SdchManager::Dictionary> dictionary;
219 std::string client_hash; 219 std::string client_hash;
220 std::string server_hash; 220 std::string server_hash;
221 sdch_manager()->GenerateHash(dictionary_text, &client_hash, &server_hash); 221 sdch_manager()->GenerateHash(dictionary_text, &client_hash, &server_hash);
222 sdch_manager()->GetVcdiffDictionary(server_hash, target_url, &dictionary); 222 sdch_manager()->GetVcdiffDictionary(server_hash, target_url, &dictionary);
223 EXPECT_TRUE(dictionary == NULL); 223 EXPECT_TRUE(dictionary.get() == NULL);
224 } 224 }
225 225
226 TEST_F(SdchManagerTest, CanNotUseHTTPSDictionaryOverHTTP) { 226 TEST_F(SdchManagerTest, CanNotUseHTTPSDictionaryOverHTTP) {
227 std::string dictionary_domain("x.y.z.google.com"); 227 std::string dictionary_domain("x.y.z.google.com");
228 std::string dictionary_text(NewSdchDictionary(dictionary_domain)); 228 std::string dictionary_text(NewSdchDictionary(dictionary_domain));
229 229
230 SdchManager::EnableSecureSchemeSupport(true); 230 SdchManager::EnableSecureSchemeSupport(true);
231 EXPECT_TRUE(sdch_manager()->AddSdchDictionary(dictionary_text, 231 EXPECT_TRUE(sdch_manager()->AddSdchDictionary(dictionary_text,
232 GURL("https://" + dictionary_domain))); 232 GURL("https://" + dictionary_domain)));
233 233
234 GURL target_url("http://" + dictionary_domain + "/test"); 234 GURL target_url("http://" + dictionary_domain + "/test");
235 std::string dictionary_list; 235 std::string dictionary_list;
236 // HTTP target URL should not advertise dictionary acquired over HTTPS even if 236 // HTTP target URL should not advertise dictionary acquired over HTTPS even if
237 // secure scheme support is enabled. 237 // secure scheme support is enabled.
238 sdch_manager()->GetAvailDictionaryList(target_url, &dictionary_list); 238 sdch_manager()->GetAvailDictionaryList(target_url, &dictionary_list);
239 EXPECT_TRUE(dictionary_list.empty()); 239 EXPECT_TRUE(dictionary_list.empty());
240 240
241 scoped_refptr<SdchManager::Dictionary> dictionary; 241 scoped_refptr<SdchManager::Dictionary> dictionary;
242 std::string client_hash; 242 std::string client_hash;
243 std::string server_hash; 243 std::string server_hash;
244 sdch_manager()->GenerateHash(dictionary_text, &client_hash, &server_hash); 244 sdch_manager()->GenerateHash(dictionary_text, &client_hash, &server_hash);
245 sdch_manager()->GetVcdiffDictionary(server_hash, target_url, &dictionary); 245 sdch_manager()->GetVcdiffDictionary(server_hash, target_url, &dictionary);
246 EXPECT_TRUE(dictionary == NULL); 246 EXPECT_TRUE(dictionary.get() == NULL);
247 } 247 }
248 248
249 TEST_F(SdchManagerTest, FailToSetDomainMismatchDictionary) { 249 TEST_F(SdchManagerTest, FailToSetDomainMismatchDictionary) {
250 std::string dictionary_domain("x.y.z.google.com"); 250 std::string dictionary_domain("x.y.z.google.com");
251 std::string dictionary_text(NewSdchDictionary(dictionary_domain)); 251 std::string dictionary_text(NewSdchDictionary(dictionary_domain));
252 252
253 // Fail the "domain match" requirement. 253 // Fail the "domain match" requirement.
254 EXPECT_FALSE(sdch_manager()->AddSdchDictionary(dictionary_text, 254 EXPECT_FALSE(sdch_manager()->AddSdchDictionary(dictionary_text,
255 GURL("http://y.z.google.com"))); 255 GURL("http://y.z.google.com")));
256 } 256 }
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 422
423 // Confirm that if you add directories to one manager, you 423 // Confirm that if you add directories to one manager, you
424 // can't get them from the other. 424 // can't get them from the other.
425 EXPECT_TRUE(sdch_manager()->AddSdchDictionary( 425 EXPECT_TRUE(sdch_manager()->AddSdchDictionary(
426 dictionary_text_1, GURL("http://" + dictionary_domain_1))); 426 dictionary_text_1, GURL("http://" + dictionary_domain_1)));
427 scoped_refptr<SdchManager::Dictionary> dictionary; 427 scoped_refptr<SdchManager::Dictionary> dictionary;
428 sdch_manager()->GetVcdiffDictionary( 428 sdch_manager()->GetVcdiffDictionary(
429 server_hash_1, 429 server_hash_1,
430 GURL("http://" + dictionary_domain_1 + "/random_url"), 430 GURL("http://" + dictionary_domain_1 + "/random_url"),
431 &dictionary); 431 &dictionary);
432 EXPECT_TRUE(dictionary); 432 EXPECT_TRUE(dictionary.get());
433 433
434 EXPECT_TRUE(second_manager.AddSdchDictionary( 434 EXPECT_TRUE(second_manager.AddSdchDictionary(
435 dictionary_text_2, GURL("http://" + dictionary_domain_2))); 435 dictionary_text_2, GURL("http://" + dictionary_domain_2)));
436 second_manager.GetVcdiffDictionary( 436 second_manager.GetVcdiffDictionary(
437 server_hash_2, 437 server_hash_2,
438 GURL("http://" + dictionary_domain_2 + "/random_url"), 438 GURL("http://" + dictionary_domain_2 + "/random_url"),
439 &dictionary); 439 &dictionary);
440 EXPECT_TRUE(dictionary); 440 EXPECT_TRUE(dictionary.get());
441 441
442 sdch_manager()->GetVcdiffDictionary( 442 sdch_manager()->GetVcdiffDictionary(
443 server_hash_2, 443 server_hash_2,
444 GURL("http://" + dictionary_domain_2 + "/random_url"), 444 GURL("http://" + dictionary_domain_2 + "/random_url"),
445 &dictionary); 445 &dictionary);
446 EXPECT_FALSE(dictionary); 446 EXPECT_FALSE(dictionary.get());
447 447
448 second_manager.GetVcdiffDictionary( 448 second_manager.GetVcdiffDictionary(
449 server_hash_1, 449 server_hash_1,
450 GURL("http://" + dictionary_domain_1 + "/random_url"), 450 GURL("http://" + dictionary_domain_1 + "/random_url"),
451 &dictionary); 451 &dictionary);
452 EXPECT_FALSE(dictionary); 452 EXPECT_FALSE(dictionary.get());
453 } 453 }
454 454
455 TEST_F(SdchManagerTest, HttpsCorrectlySupported) { 455 TEST_F(SdchManagerTest, HttpsCorrectlySupported) {
456 GURL url("http://www.google.com"); 456 GURL url("http://www.google.com");
457 GURL secure_url("https://www.google.com"); 457 GURL secure_url("https://www.google.com");
458 458
459 EXPECT_TRUE(sdch_manager()->IsInSupportedDomain(url)); 459 EXPECT_TRUE(sdch_manager()->IsInSupportedDomain(url));
460 EXPECT_FALSE(sdch_manager()->IsInSupportedDomain(secure_url)); 460 EXPECT_FALSE(sdch_manager()->IsInSupportedDomain(secure_url));
461 461
462 SdchManager::EnableSecureSchemeSupport(true); 462 SdchManager::EnableSecureSchemeSupport(true);
(...skipping 11 matching lines...) Expand all
474 474
475 SdchManager::GenerateHash(dictionary_text, &tmp_hash, &server_hash); 475 SdchManager::GenerateHash(dictionary_text, &tmp_hash, &server_hash);
476 476
477 EXPECT_TRUE(sdch_manager()->AddSdchDictionary( 477 EXPECT_TRUE(sdch_manager()->AddSdchDictionary(
478 dictionary_text, GURL("http://" + dictionary_domain))); 478 dictionary_text, GURL("http://" + dictionary_domain)));
479 scoped_refptr<SdchManager::Dictionary> dictionary; 479 scoped_refptr<SdchManager::Dictionary> dictionary;
480 sdch_manager()->GetVcdiffDictionary( 480 sdch_manager()->GetVcdiffDictionary(
481 server_hash, 481 server_hash,
482 GURL("http://" + dictionary_domain + "/random_url"), 482 GURL("http://" + dictionary_domain + "/random_url"),
483 &dictionary); 483 &dictionary);
484 EXPECT_TRUE(dictionary); 484 EXPECT_TRUE(dictionary.get());
485 485
486 sdch_manager()->BlacklistDomain(GURL(blacklist_url), 486 sdch_manager()->BlacklistDomain(GURL(blacklist_url),
487 SdchManager::MIN_PROBLEM_CODE); 487 SdchManager::MIN_PROBLEM_CODE);
488 EXPECT_FALSE(sdch_manager()->IsInSupportedDomain(blacklist_url)); 488 EXPECT_FALSE(sdch_manager()->IsInSupportedDomain(blacklist_url));
489 489
490 sdch_manager()->ClearData(); 490 sdch_manager()->ClearData();
491 491
492 dictionary = NULL; 492 dictionary = NULL;
493 sdch_manager()->GetVcdiffDictionary( 493 sdch_manager()->GetVcdiffDictionary(
494 server_hash, 494 server_hash,
495 GURL("http://" + dictionary_domain + "/random_url"), 495 GURL("http://" + dictionary_domain + "/random_url"),
496 &dictionary); 496 &dictionary);
497 EXPECT_FALSE(dictionary); 497 EXPECT_FALSE(dictionary.get());
498 EXPECT_TRUE(sdch_manager()->IsInSupportedDomain(blacklist_url)); 498 EXPECT_TRUE(sdch_manager()->IsInSupportedDomain(blacklist_url));
499 } 499 }
500 500
501 } // namespace net 501 } // namespace net
502 502
OLDNEW
« no previous file with comments | « net/base/file_stream_unittest.cc ('k') | net/base/upload_file_element_reader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698