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

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

Issue 423813002: Sdch view for net-internals (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Change comments and netlog field name Created 6 years, 4 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
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 17 matching lines...) Expand all
28 } 28 }
29 29
30 SdchManager* sdch_manager() { return sdch_manager_.get(); } 30 SdchManager* sdch_manager() { return sdch_manager_.get(); }
31 31
32 // Reset globals back to default state. 32 // Reset globals back to default state.
33 virtual void TearDown() { 33 virtual void TearDown() {
34 SdchManager::EnableSdchSupport(true); 34 SdchManager::EnableSdchSupport(true);
35 SdchManager::EnableSecureSchemeSupport(false); 35 SdchManager::EnableSecureSchemeSupport(false);
36 } 36 }
37 37
38 bool AddDictionary(const std::string& text, const GURL& url) {
39 SdchManager::AddResult rv = sdch_manager_->AddSdchDictionary(text, url);
40 return rv.added;
41 }
42
38 private: 43 private:
39 scoped_ptr<SdchManager> sdch_manager_; 44 scoped_ptr<SdchManager> sdch_manager_;
40 }; 45 };
41 46
42 //------------------------------------------------------------------------------ 47 //------------------------------------------------------------------------------
43 static std::string NewSdchDictionary(const std::string& domain) { 48 static std::string NewSdchDictionary(const std::string& domain) {
44 std::string dictionary; 49 std::string dictionary;
45 if (!domain.empty()) { 50 if (!domain.empty()) {
46 dictionary.append("Domain: "); 51 dictionary.append("Domain: ");
47 dictionary.append(domain); 52 dictionary.append(domain);
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 if (exponential < 0) 138 if (exponential < 0)
134 exponential = INT_MAX; // We don't wrap. 139 exponential = INT_MAX; // We don't wrap.
135 } 140 }
136 } 141 }
137 142
138 TEST_F(SdchManagerTest, CanSetExactMatchDictionary) { 143 TEST_F(SdchManagerTest, CanSetExactMatchDictionary) {
139 std::string dictionary_domain("x.y.z.google.com"); 144 std::string dictionary_domain("x.y.z.google.com");
140 std::string dictionary_text(NewSdchDictionary(dictionary_domain)); 145 std::string dictionary_text(NewSdchDictionary(dictionary_domain));
141 146
142 // Perfect match should work. 147 // Perfect match should work.
143 EXPECT_TRUE(sdch_manager()->AddSdchDictionary(dictionary_text, 148 EXPECT_TRUE(
144 GURL("http://" + dictionary_domain))); 149 AddDictionary(dictionary_text, GURL("http://" + dictionary_domain)));
145 } 150 }
146 151
147 TEST_F(SdchManagerTest, CanAdvertiseDictionaryOverHTTP) { 152 TEST_F(SdchManagerTest, CanAdvertiseDictionaryOverHTTP) {
148 std::string dictionary_domain("x.y.z.google.com"); 153 std::string dictionary_domain("x.y.z.google.com");
149 std::string dictionary_text(NewSdchDictionary(dictionary_domain)); 154 std::string dictionary_text(NewSdchDictionary(dictionary_domain));
150 155
151 EXPECT_TRUE(sdch_manager()->AddSdchDictionary(dictionary_text, 156 EXPECT_TRUE(
152 GURL("http://" + dictionary_domain))); 157 AddDictionary(dictionary_text, GURL("http://" + dictionary_domain)));
153 158
154 std::string dictionary_list; 159 std::string dictionary_list;
155 // HTTP target URL can advertise dictionary. 160 // HTTP target URL can advertise dictionary.
156 sdch_manager()->GetAvailDictionaryList( 161 sdch_manager()->GetAvailDictionaryList(
157 GURL("http://" + dictionary_domain + "/test"), 162 GURL("http://" + dictionary_domain + "/test"),
158 &dictionary_list); 163 &dictionary_list);
159 EXPECT_FALSE(dictionary_list.empty()); 164 EXPECT_FALSE(dictionary_list.empty());
160 } 165 }
161 166
162 TEST_F(SdchManagerTest, CanNotAdvertiseDictionaryOverHTTPS) { 167 TEST_F(SdchManagerTest, CanNotAdvertiseDictionaryOverHTTPS) {
163 std::string dictionary_domain("x.y.z.google.com"); 168 std::string dictionary_domain("x.y.z.google.com");
164 std::string dictionary_text(NewSdchDictionary(dictionary_domain)); 169 std::string dictionary_text(NewSdchDictionary(dictionary_domain));
165 170
166 EXPECT_TRUE(sdch_manager()->AddSdchDictionary(dictionary_text, 171 EXPECT_TRUE(
167 GURL("http://" + dictionary_domain))); 172 AddDictionary(dictionary_text, GURL("http://" + dictionary_domain)));
168 173
169 std::string dictionary_list; 174 std::string dictionary_list;
170 // HTTPS target URL should NOT advertise dictionary. 175 // HTTPS target URL should NOT advertise dictionary.
171 sdch_manager()->GetAvailDictionaryList( 176 sdch_manager()->GetAvailDictionaryList(
172 GURL("https://" + dictionary_domain + "/test"), 177 GURL("https://" + dictionary_domain + "/test"),
173 &dictionary_list); 178 &dictionary_list);
174 EXPECT_TRUE(dictionary_list.empty()); 179 EXPECT_TRUE(dictionary_list.empty());
175 } 180 }
176 181
177 TEST_F(SdchManagerTest, CanUseHTTPSDictionaryOverHTTPSIfEnabled) { 182 TEST_F(SdchManagerTest, CanUseHTTPSDictionaryOverHTTPSIfEnabled) {
178 std::string dictionary_domain("x.y.z.google.com"); 183 std::string dictionary_domain("x.y.z.google.com");
179 std::string dictionary_text(NewSdchDictionary(dictionary_domain)); 184 std::string dictionary_text(NewSdchDictionary(dictionary_domain));
180 185
181 EXPECT_FALSE(sdch_manager()->AddSdchDictionary( 186 EXPECT_FALSE(
182 dictionary_text, GURL("https://" + dictionary_domain))); 187 AddDictionary(dictionary_text, GURL("https://" + dictionary_domain)));
183 SdchManager::EnableSecureSchemeSupport(true); 188 SdchManager::EnableSecureSchemeSupport(true);
184 EXPECT_TRUE(sdch_manager()->AddSdchDictionary( 189 EXPECT_TRUE(
185 dictionary_text, GURL("https://" + dictionary_domain))); 190 AddDictionary(dictionary_text, GURL("https://" + dictionary_domain)));
186 191
187 GURL target_url("https://" + dictionary_domain + "/test"); 192 GURL target_url("https://" + dictionary_domain + "/test");
188 std::string dictionary_list; 193 std::string dictionary_list;
189 // HTTPS target URL should advertise dictionary if secure scheme support is 194 // HTTPS target URL should advertise dictionary if secure scheme support is
190 // enabled. 195 // enabled.
191 sdch_manager()->GetAvailDictionaryList(target_url, &dictionary_list); 196 sdch_manager()->GetAvailDictionaryList(target_url, &dictionary_list);
192 EXPECT_FALSE(dictionary_list.empty()); 197 EXPECT_FALSE(dictionary_list.empty());
193 198
194 // Dictionary should be available. 199 // Dictionary should be available.
195 scoped_refptr<SdchManager::Dictionary> dictionary; 200 scoped_refptr<SdchManager::Dictionary> dictionary;
196 std::string client_hash; 201 std::string client_hash;
197 std::string server_hash; 202 std::string server_hash;
198 sdch_manager()->GenerateHash(dictionary_text, &client_hash, &server_hash); 203 sdch_manager()->GenerateHash(dictionary_text, &client_hash, &server_hash);
199 sdch_manager()->GetVcdiffDictionary(server_hash, target_url, &dictionary); 204 sdch_manager()->GetVcdiffDictionary(server_hash, target_url, &dictionary);
200 EXPECT_TRUE(dictionary != NULL); 205 EXPECT_TRUE(dictionary != NULL);
201 } 206 }
202 207
203 TEST_F(SdchManagerTest, CanNotUseHTTPDictionaryOverHTTPS) { 208 TEST_F(SdchManagerTest, CanNotUseHTTPDictionaryOverHTTPS) {
204 std::string dictionary_domain("x.y.z.google.com"); 209 std::string dictionary_domain("x.y.z.google.com");
205 std::string dictionary_text(NewSdchDictionary(dictionary_domain)); 210 std::string dictionary_text(NewSdchDictionary(dictionary_domain));
206 211
207 EXPECT_TRUE(sdch_manager()->AddSdchDictionary(dictionary_text, 212 EXPECT_TRUE(
208 GURL("http://" + dictionary_domain))); 213 AddDictionary(dictionary_text, GURL("http://" + dictionary_domain)));
209 214
210 GURL target_url("https://" + dictionary_domain + "/test"); 215 GURL target_url("https://" + dictionary_domain + "/test");
211 std::string dictionary_list; 216 std::string dictionary_list;
212 // HTTPS target URL should not advertise dictionary acquired over HTTP even if 217 // HTTPS target URL should not advertise dictionary acquired over HTTP even if
213 // secure scheme support is enabled. 218 // secure scheme support is enabled.
214 SdchManager::EnableSecureSchemeSupport(true); 219 SdchManager::EnableSecureSchemeSupport(true);
215 sdch_manager()->GetAvailDictionaryList(target_url, &dictionary_list); 220 sdch_manager()->GetAvailDictionaryList(target_url, &dictionary_list);
216 EXPECT_TRUE(dictionary_list.empty()); 221 EXPECT_TRUE(dictionary_list.empty());
217 222
218 scoped_refptr<SdchManager::Dictionary> dictionary; 223 scoped_refptr<SdchManager::Dictionary> dictionary;
219 std::string client_hash; 224 std::string client_hash;
220 std::string server_hash; 225 std::string server_hash;
221 sdch_manager()->GenerateHash(dictionary_text, &client_hash, &server_hash); 226 sdch_manager()->GenerateHash(dictionary_text, &client_hash, &server_hash);
222 sdch_manager()->GetVcdiffDictionary(server_hash, target_url, &dictionary); 227 sdch_manager()->GetVcdiffDictionary(server_hash, target_url, &dictionary);
223 EXPECT_TRUE(dictionary == NULL); 228 EXPECT_TRUE(dictionary == NULL);
224 } 229 }
225 230
226 TEST_F(SdchManagerTest, CanNotUseHTTPSDictionaryOverHTTP) { 231 TEST_F(SdchManagerTest, CanNotUseHTTPSDictionaryOverHTTP) {
227 std::string dictionary_domain("x.y.z.google.com"); 232 std::string dictionary_domain("x.y.z.google.com");
228 std::string dictionary_text(NewSdchDictionary(dictionary_domain)); 233 std::string dictionary_text(NewSdchDictionary(dictionary_domain));
229 234
230 SdchManager::EnableSecureSchemeSupport(true); 235 SdchManager::EnableSecureSchemeSupport(true);
231 EXPECT_TRUE(sdch_manager()->AddSdchDictionary(dictionary_text, 236 EXPECT_TRUE(
232 GURL("https://" + dictionary_domain))); 237 AddDictionary(dictionary_text, GURL("https://" + dictionary_domain)));
233 238
234 GURL target_url("http://" + dictionary_domain + "/test"); 239 GURL target_url("http://" + dictionary_domain + "/test");
235 std::string dictionary_list; 240 std::string dictionary_list;
236 // HTTP target URL should not advertise dictionary acquired over HTTPS even if 241 // HTTP target URL should not advertise dictionary acquired over HTTPS even if
237 // secure scheme support is enabled. 242 // secure scheme support is enabled.
238 sdch_manager()->GetAvailDictionaryList(target_url, &dictionary_list); 243 sdch_manager()->GetAvailDictionaryList(target_url, &dictionary_list);
239 EXPECT_TRUE(dictionary_list.empty()); 244 EXPECT_TRUE(dictionary_list.empty());
240 245
241 scoped_refptr<SdchManager::Dictionary> dictionary; 246 scoped_refptr<SdchManager::Dictionary> dictionary;
242 std::string client_hash; 247 std::string client_hash;
243 std::string server_hash; 248 std::string server_hash;
244 sdch_manager()->GenerateHash(dictionary_text, &client_hash, &server_hash); 249 sdch_manager()->GenerateHash(dictionary_text, &client_hash, &server_hash);
245 sdch_manager()->GetVcdiffDictionary(server_hash, target_url, &dictionary); 250 sdch_manager()->GetVcdiffDictionary(server_hash, target_url, &dictionary);
246 EXPECT_TRUE(dictionary == NULL); 251 EXPECT_TRUE(dictionary == NULL);
247 } 252 }
248 253
249 TEST_F(SdchManagerTest, FailToSetDomainMismatchDictionary) { 254 TEST_F(SdchManagerTest, FailToSetDomainMismatchDictionary) {
250 std::string dictionary_domain("x.y.z.google.com"); 255 std::string dictionary_domain("x.y.z.google.com");
251 std::string dictionary_text(NewSdchDictionary(dictionary_domain)); 256 std::string dictionary_text(NewSdchDictionary(dictionary_domain));
252 257
253 // Fail the "domain match" requirement. 258 // Fail the "domain match" requirement.
254 EXPECT_FALSE(sdch_manager()->AddSdchDictionary(dictionary_text, 259 EXPECT_FALSE(AddDictionary(dictionary_text, GURL("http://y.z.google.com")));
255 GURL("http://y.z.google.com")));
256 } 260 }
257 261
258 TEST_F(SdchManagerTest, FailToSetDotHostPrefixDomainDictionary) { 262 TEST_F(SdchManagerTest, FailToSetDotHostPrefixDomainDictionary) {
259 std::string dictionary_domain("x.y.z.google.com"); 263 std::string dictionary_domain("x.y.z.google.com");
260 std::string dictionary_text(NewSdchDictionary(dictionary_domain)); 264 std::string dictionary_text(NewSdchDictionary(dictionary_domain));
261 265
262 // Fail the HD with D being the domain and H having a dot requirement. 266 // Fail the HD with D being the domain and H having a dot requirement.
263 EXPECT_FALSE(sdch_manager()->AddSdchDictionary(dictionary_text, 267 EXPECT_FALSE(
264 GURL("http://w.x.y.z.google.com"))); 268 AddDictionary(dictionary_text, GURL("http://w.x.y.z.google.com")));
265 } 269 }
266 270
267 TEST_F(SdchManagerTest, FailToSetRepeatPrefixWithDotDictionary) { 271 TEST_F(SdchManagerTest, FailToSetRepeatPrefixWithDotDictionary) {
268 // Make sure that a prefix that matches the domain postfix won't confuse 272 // Make sure that a prefix that matches the domain postfix won't confuse
269 // the validation checks. 273 // the validation checks.
270 std::string dictionary_domain("www.google.com"); 274 std::string dictionary_domain("www.google.com");
271 std::string dictionary_text(NewSdchDictionary(dictionary_domain)); 275 std::string dictionary_text(NewSdchDictionary(dictionary_domain));
272 276
273 // Fail the HD with D being the domain and H having a dot requirement. 277 // Fail the HD with D being the domain and H having a dot requirement.
274 EXPECT_FALSE(sdch_manager()->AddSdchDictionary(dictionary_text, 278 EXPECT_FALSE(AddDictionary(dictionary_text,
275 GURL("http://www.google.com.www.google.com"))); 279 GURL("http://www.google.com.www.google.com")));
276 } 280 }
277 281
278 TEST_F(SdchManagerTest, CanSetLeadingDotDomainDictionary) { 282 TEST_F(SdchManagerTest, CanSetLeadingDotDomainDictionary) {
279 // Make sure that a prefix that matches the domain postfix won't confuse 283 // Make sure that a prefix that matches the domain postfix won't confuse
280 // the validation checks. 284 // the validation checks.
281 std::string dictionary_domain(".google.com"); 285 std::string dictionary_domain(".google.com");
282 std::string dictionary_text(NewSdchDictionary(dictionary_domain)); 286 std::string dictionary_text(NewSdchDictionary(dictionary_domain));
283 287
284 // Verify that a leading dot in the domain is acceptable, as long as the host 288 // Verify that a leading dot in the domain is acceptable, as long as the host
285 // name does not contain any dots preceding the matched domain name. 289 // name does not contain any dots preceding the matched domain name.
286 EXPECT_TRUE(sdch_manager()->AddSdchDictionary(dictionary_text, 290 EXPECT_TRUE(AddDictionary(dictionary_text, GURL("http://www.google.com")));
287 GURL("http://www.google.com")));
288 } 291 }
289 292
290 // Make sure the order of the tests is not helping us or confusing things. 293 // Make sure the order of the tests is not helping us or confusing things.
291 // See test CanSetExactMatchDictionary above for first try. 294 // See test CanSetExactMatchDictionary above for first try.
292 TEST_F(SdchManagerTest, CanStillSetExactMatchDictionary) { 295 TEST_F(SdchManagerTest, CanStillSetExactMatchDictionary) {
293 std::string dictionary_domain("x.y.z.google.com"); 296 std::string dictionary_domain("x.y.z.google.com");
294 std::string dictionary_text(NewSdchDictionary(dictionary_domain)); 297 std::string dictionary_text(NewSdchDictionary(dictionary_domain));
295 298
296 // Perfect match should *STILL* work. 299 // Perfect match should *STILL* work.
297 EXPECT_TRUE(sdch_manager()->AddSdchDictionary(dictionary_text, 300 EXPECT_TRUE(
298 GURL("http://" + dictionary_domain))); 301 AddDictionary(dictionary_text, GURL("http://" + dictionary_domain)));
299 } 302 }
300 303
301 // Make sure the DOS protection precludes the addition of too many dictionaries. 304 // Make sure the DOS protection precludes the addition of too many dictionaries.
302 TEST_F(SdchManagerTest, TooManyDictionaries) { 305 TEST_F(SdchManagerTest, TooManyDictionaries) {
303 std::string dictionary_domain(".google.com"); 306 std::string dictionary_domain(".google.com");
304 std::string dictionary_text(NewSdchDictionary(dictionary_domain)); 307 std::string dictionary_text(NewSdchDictionary(dictionary_domain));
305 308
306 size_t count = 0; 309 size_t count = 0;
307 while (count <= SdchManager::kMaxDictionaryCount + 1) { 310 while (count <= SdchManager::kMaxDictionaryCount + 1) {
308 if (!sdch_manager()->AddSdchDictionary(dictionary_text, 311 if (!AddDictionary(dictionary_text, GURL("http://www.google.com")))
309 GURL("http://www.google.com")))
310 break; 312 break;
311 313
312 dictionary_text += " "; // Create dictionary with different SHA signature. 314 dictionary_text += " "; // Create dictionary with different SHA signature.
313 ++count; 315 ++count;
314 } 316 }
315 EXPECT_EQ(SdchManager::kMaxDictionaryCount, count); 317 EXPECT_EQ(SdchManager::kMaxDictionaryCount, count);
316 } 318 }
317 319
318 TEST_F(SdchManagerTest, DictionaryNotTooLarge) { 320 TEST_F(SdchManagerTest, DictionaryNotTooLarge) {
319 std::string dictionary_domain(".google.com"); 321 std::string dictionary_domain(".google.com");
320 std::string dictionary_text(NewSdchDictionary(dictionary_domain)); 322 std::string dictionary_text(NewSdchDictionary(dictionary_domain));
321 323
322 dictionary_text.append( 324 dictionary_text.append(
323 SdchManager::kMaxDictionarySize - dictionary_text.size(), ' '); 325 SdchManager::kMaxDictionarySize - dictionary_text.size(), ' ');
324 EXPECT_TRUE(sdch_manager()->AddSdchDictionary(dictionary_text, 326 EXPECT_TRUE(
325 GURL("http://" + dictionary_domain))); 327 AddDictionary(dictionary_text, GURL("http://" + dictionary_domain)));
326 } 328 }
327 329
328 TEST_F(SdchManagerTest, DictionaryTooLarge) { 330 TEST_F(SdchManagerTest, DictionaryTooLarge) {
329 std::string dictionary_domain(".google.com"); 331 std::string dictionary_domain(".google.com");
330 std::string dictionary_text(NewSdchDictionary(dictionary_domain)); 332 std::string dictionary_text(NewSdchDictionary(dictionary_domain));
331 333
332 dictionary_text.append( 334 dictionary_text.append(
333 SdchManager::kMaxDictionarySize + 1 - dictionary_text.size(), ' '); 335 SdchManager::kMaxDictionarySize + 1 - dictionary_text.size(), ' ');
334 EXPECT_FALSE(sdch_manager()->AddSdchDictionary(dictionary_text, 336 EXPECT_FALSE(
335 GURL("http://" + dictionary_domain))); 337 AddDictionary(dictionary_text, GURL("http://" + dictionary_domain)));
336 } 338 }
337 339
338 TEST_F(SdchManagerTest, PathMatch) { 340 TEST_F(SdchManagerTest, PathMatch) {
339 bool (*PathMatch)(const std::string& path, const std::string& restriction) = 341 bool (*PathMatch)(const std::string& path, const std::string& restriction) =
340 SdchManager::Dictionary::PathMatch; 342 SdchManager::Dictionary::PathMatch;
341 // Perfect match is supported. 343 // Perfect match is supported.
342 EXPECT_TRUE(PathMatch("/search", "/search")); 344 EXPECT_TRUE(PathMatch("/search", "/search"));
343 EXPECT_TRUE(PathMatch("/search/", "/search/")); 345 EXPECT_TRUE(PathMatch("/search/", "/search/"));
344 346
345 // Prefix only works if last character of restriction is a slash, or first 347 // Prefix only works if last character of restriction is a slash, or first
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 417
416 std::string tmp_hash; 418 std::string tmp_hash;
417 std::string server_hash_1; 419 std::string server_hash_1;
418 std::string server_hash_2; 420 std::string server_hash_2;
419 421
420 SdchManager::GenerateHash(dictionary_text_1, &tmp_hash, &server_hash_1); 422 SdchManager::GenerateHash(dictionary_text_1, &tmp_hash, &server_hash_1);
421 SdchManager::GenerateHash(dictionary_text_2, &tmp_hash, &server_hash_2); 423 SdchManager::GenerateHash(dictionary_text_2, &tmp_hash, &server_hash_2);
422 424
423 // Confirm that if you add directories to one manager, you 425 // Confirm that if you add directories to one manager, you
424 // can't get them from the other. 426 // can't get them from the other.
425 EXPECT_TRUE(sdch_manager()->AddSdchDictionary( 427 EXPECT_TRUE(
426 dictionary_text_1, GURL("http://" + dictionary_domain_1))); 428 AddDictionary(dictionary_text_1, GURL("http://" + dictionary_domain_1)));
427 scoped_refptr<SdchManager::Dictionary> dictionary; 429 scoped_refptr<SdchManager::Dictionary> dictionary;
428 sdch_manager()->GetVcdiffDictionary( 430 sdch_manager()->GetVcdiffDictionary(
429 server_hash_1, 431 server_hash_1,
430 GURL("http://" + dictionary_domain_1 + "/random_url"), 432 GURL("http://" + dictionary_domain_1 + "/random_url"),
431 &dictionary); 433 &dictionary);
432 EXPECT_TRUE(dictionary); 434 EXPECT_TRUE(dictionary);
433 435
434 EXPECT_TRUE(second_manager.AddSdchDictionary( 436 SdchManager::AddResult rv = second_manager.AddSdchDictionary(
435 dictionary_text_2, GURL("http://" + dictionary_domain_2))); 437 dictionary_text_2, GURL("http://" + dictionary_domain_2));
438 EXPECT_TRUE(rv.added);
436 second_manager.GetVcdiffDictionary( 439 second_manager.GetVcdiffDictionary(
437 server_hash_2, 440 server_hash_2,
438 GURL("http://" + dictionary_domain_2 + "/random_url"), 441 GURL("http://" + dictionary_domain_2 + "/random_url"),
439 &dictionary); 442 &dictionary);
440 EXPECT_TRUE(dictionary); 443 EXPECT_TRUE(dictionary);
441 444
442 sdch_manager()->GetVcdiffDictionary( 445 sdch_manager()->GetVcdiffDictionary(
443 server_hash_2, 446 server_hash_2,
444 GURL("http://" + dictionary_domain_2 + "/random_url"), 447 GURL("http://" + dictionary_domain_2 + "/random_url"),
445 &dictionary); 448 &dictionary);
(...skipping 21 matching lines...) Expand all
467 TEST_F(SdchManagerTest, ClearDictionaryData) { 470 TEST_F(SdchManagerTest, ClearDictionaryData) {
468 std::string dictionary_domain("x.y.z.google.com"); 471 std::string dictionary_domain("x.y.z.google.com");
469 GURL blacklist_url("http://bad.chromium.org"); 472 GURL blacklist_url("http://bad.chromium.org");
470 473
471 std::string dictionary_text(NewSdchDictionary(dictionary_domain)); 474 std::string dictionary_text(NewSdchDictionary(dictionary_domain));
472 std::string tmp_hash; 475 std::string tmp_hash;
473 std::string server_hash; 476 std::string server_hash;
474 477
475 SdchManager::GenerateHash(dictionary_text, &tmp_hash, &server_hash); 478 SdchManager::GenerateHash(dictionary_text, &tmp_hash, &server_hash);
476 479
477 EXPECT_TRUE(sdch_manager()->AddSdchDictionary( 480 EXPECT_TRUE(
478 dictionary_text, GURL("http://" + dictionary_domain))); 481 AddDictionary(dictionary_text, GURL("http://" + dictionary_domain)));
479 scoped_refptr<SdchManager::Dictionary> dictionary; 482 scoped_refptr<SdchManager::Dictionary> dictionary;
480 sdch_manager()->GetVcdiffDictionary( 483 sdch_manager()->GetVcdiffDictionary(
481 server_hash, 484 server_hash,
482 GURL("http://" + dictionary_domain + "/random_url"), 485 GURL("http://" + dictionary_domain + "/random_url"),
483 &dictionary); 486 &dictionary);
484 EXPECT_TRUE(dictionary); 487 EXPECT_TRUE(dictionary);
485 488
486 sdch_manager()->BlacklistDomain(GURL(blacklist_url)); 489 sdch_manager()->BlacklistDomain(GURL(blacklist_url));
487 EXPECT_FALSE(sdch_manager()->IsInSupportedDomain(blacklist_url)); 490 EXPECT_FALSE(sdch_manager()->IsInSupportedDomain(blacklist_url));
488 491
489 sdch_manager()->ClearData(); 492 sdch_manager()->ClearData();
490 493
491 dictionary = NULL; 494 dictionary = NULL;
492 sdch_manager()->GetVcdiffDictionary( 495 sdch_manager()->GetVcdiffDictionary(
493 server_hash, 496 server_hash,
494 GURL("http://" + dictionary_domain + "/random_url"), 497 GURL("http://" + dictionary_domain + "/random_url"),
495 &dictionary); 498 &dictionary);
496 EXPECT_FALSE(dictionary); 499 EXPECT_FALSE(dictionary);
497 EXPECT_TRUE(sdch_manager()->IsInSupportedDomain(blacklist_url)); 500 EXPECT_TRUE(sdch_manager()->IsInSupportedDomain(blacklist_url));
498 } 501 }
499 502
500 } // namespace net 503 } // namespace net
501 504
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698