OLD | NEW |
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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 if (exponential < 0) | 133 if (exponential < 0) |
134 exponential = INT_MAX; // We don't wrap. | 134 exponential = INT_MAX; // We don't wrap. |
135 } | 135 } |
136 } | 136 } |
137 | 137 |
138 TEST_F(SdchManagerTest, CanSetExactMatchDictionary) { | 138 TEST_F(SdchManagerTest, CanSetExactMatchDictionary) { |
139 std::string dictionary_domain("x.y.z.google.com"); | 139 std::string dictionary_domain("x.y.z.google.com"); |
140 std::string dictionary_text(NewSdchDictionary(dictionary_domain)); | 140 std::string dictionary_text(NewSdchDictionary(dictionary_domain)); |
141 | 141 |
142 // Perfect match should work. | 142 // Perfect match should work. |
143 EXPECT_TRUE(sdch_manager()->AddSdchDictionary(dictionary_text, | 143 SdchManager::ProblemCodes problem; |
144 GURL("http://" + dictionary_domain))); | 144 EXPECT_TRUE(sdch_manager()->AddSdchDictionary( |
| 145 dictionary_text, GURL("http://" + dictionary_domain), &problem)); |
145 } | 146 } |
146 | 147 |
147 TEST_F(SdchManagerTest, CanAdvertiseDictionaryOverHTTP) { | 148 TEST_F(SdchManagerTest, CanAdvertiseDictionaryOverHTTP) { |
148 std::string dictionary_domain("x.y.z.google.com"); | 149 std::string dictionary_domain("x.y.z.google.com"); |
149 std::string dictionary_text(NewSdchDictionary(dictionary_domain)); | 150 std::string dictionary_text(NewSdchDictionary(dictionary_domain)); |
150 | 151 |
151 EXPECT_TRUE(sdch_manager()->AddSdchDictionary(dictionary_text, | 152 SdchManager::ProblemCodes problem; |
152 GURL("http://" + dictionary_domain))); | 153 EXPECT_TRUE(sdch_manager()->AddSdchDictionary( |
| 154 dictionary_text, GURL("http://" + dictionary_domain), &problem)); |
153 | 155 |
154 std::string dictionary_list; | 156 std::string dictionary_list; |
155 // HTTP target URL can advertise dictionary. | 157 // HTTP target URL can advertise dictionary. |
156 sdch_manager()->GetAvailDictionaryList( | 158 sdch_manager()->GetAvailDictionaryList( |
157 GURL("http://" + dictionary_domain + "/test"), | 159 GURL("http://" + dictionary_domain + "/test"), |
158 &dictionary_list); | 160 &dictionary_list); |
159 EXPECT_FALSE(dictionary_list.empty()); | 161 EXPECT_FALSE(dictionary_list.empty()); |
160 } | 162 } |
161 | 163 |
162 TEST_F(SdchManagerTest, CanNotAdvertiseDictionaryOverHTTPS) { | 164 TEST_F(SdchManagerTest, CanNotAdvertiseDictionaryOverHTTPS) { |
163 std::string dictionary_domain("x.y.z.google.com"); | 165 std::string dictionary_domain("x.y.z.google.com"); |
164 std::string dictionary_text(NewSdchDictionary(dictionary_domain)); | 166 std::string dictionary_text(NewSdchDictionary(dictionary_domain)); |
165 | 167 |
166 EXPECT_TRUE(sdch_manager()->AddSdchDictionary(dictionary_text, | 168 SdchManager::ProblemCodes problem; |
167 GURL("http://" + dictionary_domain))); | 169 EXPECT_TRUE(sdch_manager()->AddSdchDictionary( |
| 170 dictionary_text, GURL("http://" + dictionary_domain), &problem)); |
168 | 171 |
169 std::string dictionary_list; | 172 std::string dictionary_list; |
170 // HTTPS target URL should NOT advertise dictionary. | 173 // HTTPS target URL should NOT advertise dictionary. |
171 sdch_manager()->GetAvailDictionaryList( | 174 sdch_manager()->GetAvailDictionaryList( |
172 GURL("https://" + dictionary_domain + "/test"), | 175 GURL("https://" + dictionary_domain + "/test"), |
173 &dictionary_list); | 176 &dictionary_list); |
174 EXPECT_TRUE(dictionary_list.empty()); | 177 EXPECT_TRUE(dictionary_list.empty()); |
175 } | 178 } |
176 | 179 |
177 TEST_F(SdchManagerTest, CanUseHTTPSDictionaryOverHTTPSIfEnabled) { | 180 TEST_F(SdchManagerTest, CanUseHTTPSDictionaryOverHTTPSIfEnabled) { |
178 std::string dictionary_domain("x.y.z.google.com"); | 181 std::string dictionary_domain("x.y.z.google.com"); |
179 std::string dictionary_text(NewSdchDictionary(dictionary_domain)); | 182 std::string dictionary_text(NewSdchDictionary(dictionary_domain)); |
180 | 183 |
| 184 SdchManager::ProblemCodes problem; |
181 EXPECT_FALSE(sdch_manager()->AddSdchDictionary( | 185 EXPECT_FALSE(sdch_manager()->AddSdchDictionary( |
182 dictionary_text, GURL("https://" + dictionary_domain))); | 186 dictionary_text, GURL("https://" + dictionary_domain), &problem)); |
183 SdchManager::EnableSecureSchemeSupport(true); | 187 SdchManager::EnableSecureSchemeSupport(true); |
184 EXPECT_TRUE(sdch_manager()->AddSdchDictionary( | 188 EXPECT_TRUE(sdch_manager()->AddSdchDictionary( |
185 dictionary_text, GURL("https://" + dictionary_domain))); | 189 dictionary_text, GURL("https://" + dictionary_domain), &problem)); |
186 | 190 |
187 GURL target_url("https://" + dictionary_domain + "/test"); | 191 GURL target_url("https://" + dictionary_domain + "/test"); |
188 std::string dictionary_list; | 192 std::string dictionary_list; |
189 // HTTPS target URL should advertise dictionary if secure scheme support is | 193 // HTTPS target URL should advertise dictionary if secure scheme support is |
190 // enabled. | 194 // enabled. |
191 sdch_manager()->GetAvailDictionaryList(target_url, &dictionary_list); | 195 sdch_manager()->GetAvailDictionaryList(target_url, &dictionary_list); |
192 EXPECT_FALSE(dictionary_list.empty()); | 196 EXPECT_FALSE(dictionary_list.empty()); |
193 | 197 |
194 // Dictionary should be available. | 198 // Dictionary should be available. |
195 scoped_refptr<SdchManager::Dictionary> dictionary; | 199 scoped_refptr<SdchManager::Dictionary> dictionary; |
196 std::string client_hash; | 200 std::string client_hash; |
197 std::string server_hash; | 201 std::string server_hash; |
198 sdch_manager()->GenerateHash(dictionary_text, &client_hash, &server_hash); | 202 sdch_manager()->GenerateHash(dictionary_text, &client_hash, &server_hash); |
199 sdch_manager()->GetVcdiffDictionary(server_hash, target_url, &dictionary); | 203 sdch_manager()->GetVcdiffDictionary(server_hash, target_url, &dictionary); |
200 EXPECT_TRUE(dictionary != NULL); | 204 EXPECT_TRUE(dictionary != NULL); |
201 } | 205 } |
202 | 206 |
203 TEST_F(SdchManagerTest, CanNotUseHTTPDictionaryOverHTTPS) { | 207 TEST_F(SdchManagerTest, CanNotUseHTTPDictionaryOverHTTPS) { |
204 std::string dictionary_domain("x.y.z.google.com"); | 208 std::string dictionary_domain("x.y.z.google.com"); |
205 std::string dictionary_text(NewSdchDictionary(dictionary_domain)); | 209 std::string dictionary_text(NewSdchDictionary(dictionary_domain)); |
206 | 210 |
207 EXPECT_TRUE(sdch_manager()->AddSdchDictionary(dictionary_text, | 211 SdchManager::ProblemCodes problem; |
208 GURL("http://" + dictionary_domain))); | 212 EXPECT_TRUE(sdch_manager()->AddSdchDictionary( |
| 213 dictionary_text, GURL("http://" + dictionary_domain), &problem)); |
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 SdchManager::ProblemCodes problem; |
232 GURL("https://" + dictionary_domain))); | 237 EXPECT_TRUE(sdch_manager()->AddSdchDictionary( |
| 238 dictionary_text, GURL("https://" + dictionary_domain), &problem)); |
233 | 239 |
234 GURL target_url("http://" + dictionary_domain + "/test"); | 240 GURL target_url("http://" + dictionary_domain + "/test"); |
235 std::string dictionary_list; | 241 std::string dictionary_list; |
236 // HTTP target URL should not advertise dictionary acquired over HTTPS even if | 242 // HTTP target URL should not advertise dictionary acquired over HTTPS even if |
237 // secure scheme support is enabled. | 243 // secure scheme support is enabled. |
238 sdch_manager()->GetAvailDictionaryList(target_url, &dictionary_list); | 244 sdch_manager()->GetAvailDictionaryList(target_url, &dictionary_list); |
239 EXPECT_TRUE(dictionary_list.empty()); | 245 EXPECT_TRUE(dictionary_list.empty()); |
240 | 246 |
241 scoped_refptr<SdchManager::Dictionary> dictionary; | 247 scoped_refptr<SdchManager::Dictionary> dictionary; |
242 std::string client_hash; | 248 std::string client_hash; |
243 std::string server_hash; | 249 std::string server_hash; |
244 sdch_manager()->GenerateHash(dictionary_text, &client_hash, &server_hash); | 250 sdch_manager()->GenerateHash(dictionary_text, &client_hash, &server_hash); |
245 sdch_manager()->GetVcdiffDictionary(server_hash, target_url, &dictionary); | 251 sdch_manager()->GetVcdiffDictionary(server_hash, target_url, &dictionary); |
246 EXPECT_TRUE(dictionary == NULL); | 252 EXPECT_TRUE(dictionary == NULL); |
247 } | 253 } |
248 | 254 |
249 TEST_F(SdchManagerTest, FailToSetDomainMismatchDictionary) { | 255 TEST_F(SdchManagerTest, FailToSetDomainMismatchDictionary) { |
250 std::string dictionary_domain("x.y.z.google.com"); | 256 std::string dictionary_domain("x.y.z.google.com"); |
251 std::string dictionary_text(NewSdchDictionary(dictionary_domain)); | 257 std::string dictionary_text(NewSdchDictionary(dictionary_domain)); |
252 | 258 |
253 // Fail the "domain match" requirement. | 259 // Fail the "domain match" requirement. |
254 EXPECT_FALSE(sdch_manager()->AddSdchDictionary(dictionary_text, | 260 SdchManager::ProblemCodes problem; |
255 GURL("http://y.z.google.com"))); | 261 EXPECT_FALSE(sdch_manager()->AddSdchDictionary( |
| 262 dictionary_text, GURL("http://y.z.google.com"), &problem)); |
| 263 EXPECT_EQ(SdchManager::DICTIONARY_DOMAIN_NOT_MATCHING_SOURCE_URL, problem); |
256 } | 264 } |
257 | 265 |
258 TEST_F(SdchManagerTest, FailToSetDotHostPrefixDomainDictionary) { | 266 TEST_F(SdchManagerTest, FailToSetDotHostPrefixDomainDictionary) { |
259 std::string dictionary_domain("x.y.z.google.com"); | 267 std::string dictionary_domain("x.y.z.google.com"); |
260 std::string dictionary_text(NewSdchDictionary(dictionary_domain)); | 268 std::string dictionary_text(NewSdchDictionary(dictionary_domain)); |
261 | 269 |
262 // Fail the HD with D being the domain and H having a dot requirement. | 270 // Fail the HD with D being the domain and H having a dot requirement. |
263 EXPECT_FALSE(sdch_manager()->AddSdchDictionary(dictionary_text, | 271 SdchManager::ProblemCodes problem; |
264 GURL("http://w.x.y.z.google.com"))); | 272 EXPECT_FALSE(sdch_manager()->AddSdchDictionary( |
| 273 dictionary_text, GURL("http://w.x.y.z.google.com"), &problem)); |
| 274 EXPECT_EQ(SdchManager::DICTIONARY_REFERER_URL_HAS_DOT_IN_PREFIX, problem); |
265 } | 275 } |
266 | 276 |
267 TEST_F(SdchManagerTest, FailToSetRepeatPrefixWithDotDictionary) { | 277 TEST_F(SdchManagerTest, FailToSetRepeatPrefixWithDotDictionary) { |
268 // Make sure that a prefix that matches the domain postfix won't confuse | 278 // Make sure that a prefix that matches the domain postfix won't confuse |
269 // the validation checks. | 279 // the validation checks. |
270 std::string dictionary_domain("www.google.com"); | 280 std::string dictionary_domain("www.google.com"); |
271 std::string dictionary_text(NewSdchDictionary(dictionary_domain)); | 281 std::string dictionary_text(NewSdchDictionary(dictionary_domain)); |
272 | 282 |
273 // Fail the HD with D being the domain and H having a dot requirement. | 283 // Fail the HD with D being the domain and H having a dot requirement. |
274 EXPECT_FALSE(sdch_manager()->AddSdchDictionary(dictionary_text, | 284 SdchManager::ProblemCodes problem; |
275 GURL("http://www.google.com.www.google.com"))); | 285 EXPECT_FALSE(sdch_manager()->AddSdchDictionary( |
| 286 dictionary_text, GURL("http://www.google.com.www.google.com"), &problem)); |
| 287 EXPECT_EQ(SdchManager::DICTIONARY_REFERER_URL_HAS_DOT_IN_PREFIX, problem); |
276 } | 288 } |
277 | 289 |
278 TEST_F(SdchManagerTest, CanSetLeadingDotDomainDictionary) { | 290 TEST_F(SdchManagerTest, CanSetLeadingDotDomainDictionary) { |
279 // Make sure that a prefix that matches the domain postfix won't confuse | 291 // Make sure that a prefix that matches the domain postfix won't confuse |
280 // the validation checks. | 292 // the validation checks. |
281 std::string dictionary_domain(".google.com"); | 293 std::string dictionary_domain(".google.com"); |
282 std::string dictionary_text(NewSdchDictionary(dictionary_domain)); | 294 std::string dictionary_text(NewSdchDictionary(dictionary_domain)); |
283 | 295 |
284 // Verify that a leading dot in the domain is acceptable, as long as the host | 296 // 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. | 297 // name does not contain any dots preceding the matched domain name. |
286 EXPECT_TRUE(sdch_manager()->AddSdchDictionary(dictionary_text, | 298 SdchManager::ProblemCodes problem; |
287 GURL("http://www.google.com"))); | 299 EXPECT_TRUE(sdch_manager()->AddSdchDictionary( |
| 300 dictionary_text, GURL("http://www.google.com"), &problem)); |
288 } | 301 } |
289 | 302 |
290 // Make sure the order of the tests is not helping us or confusing things. | 303 // Make sure the order of the tests is not helping us or confusing things. |
291 // See test CanSetExactMatchDictionary above for first try. | 304 // See test CanSetExactMatchDictionary above for first try. |
292 TEST_F(SdchManagerTest, CanStillSetExactMatchDictionary) { | 305 TEST_F(SdchManagerTest, CanStillSetExactMatchDictionary) { |
293 std::string dictionary_domain("x.y.z.google.com"); | 306 std::string dictionary_domain("x.y.z.google.com"); |
294 std::string dictionary_text(NewSdchDictionary(dictionary_domain)); | 307 std::string dictionary_text(NewSdchDictionary(dictionary_domain)); |
295 | 308 |
296 // Perfect match should *STILL* work. | 309 // Perfect match should *STILL* work. |
297 EXPECT_TRUE(sdch_manager()->AddSdchDictionary(dictionary_text, | 310 SdchManager::ProblemCodes problem; |
298 GURL("http://" + dictionary_domain))); | 311 EXPECT_TRUE(sdch_manager()->AddSdchDictionary( |
| 312 dictionary_text, GURL("http://" + dictionary_domain), &problem)); |
299 } | 313 } |
300 | 314 |
301 // Make sure the DOS protection precludes the addition of too many dictionaries. | 315 // Make sure the DOS protection precludes the addition of too many dictionaries. |
302 TEST_F(SdchManagerTest, TooManyDictionaries) { | 316 TEST_F(SdchManagerTest, TooManyDictionaries) { |
303 std::string dictionary_domain(".google.com"); | 317 std::string dictionary_domain(".google.com"); |
304 std::string dictionary_text(NewSdchDictionary(dictionary_domain)); | 318 std::string dictionary_text(NewSdchDictionary(dictionary_domain)); |
305 | 319 |
| 320 SdchManager::ProblemCodes problem; |
306 size_t count = 0; | 321 size_t count = 0; |
307 while (count <= SdchManager::kMaxDictionaryCount + 1) { | 322 while (count <= SdchManager::kMaxDictionaryCount + 1) { |
308 if (!sdch_manager()->AddSdchDictionary(dictionary_text, | 323 if (!sdch_manager()->AddSdchDictionary( |
309 GURL("http://www.google.com"))) | 324 dictionary_text, GURL("http://www.google.com"), &problem)) |
310 break; | 325 break; |
311 | 326 |
312 dictionary_text += " "; // Create dictionary with different SHA signature. | 327 dictionary_text += " "; // Create dictionary with different SHA signature. |
313 ++count; | 328 ++count; |
314 } | 329 } |
315 EXPECT_EQ(SdchManager::kMaxDictionaryCount, count); | 330 EXPECT_EQ(SdchManager::kMaxDictionaryCount, count); |
316 } | 331 } |
317 | 332 |
318 TEST_F(SdchManagerTest, DictionaryNotTooLarge) { | 333 TEST_F(SdchManagerTest, DictionaryNotTooLarge) { |
319 std::string dictionary_domain(".google.com"); | 334 std::string dictionary_domain(".google.com"); |
320 std::string dictionary_text(NewSdchDictionary(dictionary_domain)); | 335 std::string dictionary_text(NewSdchDictionary(dictionary_domain)); |
321 | 336 |
322 dictionary_text.append( | 337 dictionary_text.append( |
323 SdchManager::kMaxDictionarySize - dictionary_text.size(), ' '); | 338 SdchManager::kMaxDictionarySize - dictionary_text.size(), ' '); |
324 EXPECT_TRUE(sdch_manager()->AddSdchDictionary(dictionary_text, | 339 SdchManager::ProblemCodes problem; |
325 GURL("http://" + dictionary_domain))); | 340 EXPECT_TRUE(sdch_manager()->AddSdchDictionary( |
| 341 dictionary_text, GURL("http://" + dictionary_domain), &problem)); |
326 } | 342 } |
327 | 343 |
328 TEST_F(SdchManagerTest, DictionaryTooLarge) { | 344 TEST_F(SdchManagerTest, DictionaryTooLarge) { |
329 std::string dictionary_domain(".google.com"); | 345 std::string dictionary_domain(".google.com"); |
330 std::string dictionary_text(NewSdchDictionary(dictionary_domain)); | 346 std::string dictionary_text(NewSdchDictionary(dictionary_domain)); |
331 | 347 |
332 dictionary_text.append( | 348 dictionary_text.append( |
333 SdchManager::kMaxDictionarySize + 1 - dictionary_text.size(), ' '); | 349 SdchManager::kMaxDictionarySize + 1 - dictionary_text.size(), ' '); |
334 EXPECT_FALSE(sdch_manager()->AddSdchDictionary(dictionary_text, | 350 SdchManager::ProblemCodes problem; |
335 GURL("http://" + dictionary_domain))); | 351 EXPECT_FALSE(sdch_manager()->AddSdchDictionary( |
| 352 dictionary_text, GURL("http://" + dictionary_domain), &problem)); |
| 353 EXPECT_EQ(SdchManager::DICTIONARY_IS_TOO_LARGE, problem); |
336 } | 354 } |
337 | 355 |
338 TEST_F(SdchManagerTest, PathMatch) { | 356 TEST_F(SdchManagerTest, PathMatch) { |
339 bool (*PathMatch)(const std::string& path, const std::string& restriction) = | 357 bool (*PathMatch)(const std::string& path, const std::string& restriction) = |
340 SdchManager::Dictionary::PathMatch; | 358 SdchManager::Dictionary::PathMatch; |
341 // Perfect match is supported. | 359 // Perfect match is supported. |
342 EXPECT_TRUE(PathMatch("/search", "/search")); | 360 EXPECT_TRUE(PathMatch("/search", "/search")); |
343 EXPECT_TRUE(PathMatch("/search/", "/search/")); | 361 EXPECT_TRUE(PathMatch("/search/", "/search/")); |
344 | 362 |
345 // Prefix only works if last character of restriction is a slash, or first | 363 // 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 Loading... |
415 | 433 |
416 std::string tmp_hash; | 434 std::string tmp_hash; |
417 std::string server_hash_1; | 435 std::string server_hash_1; |
418 std::string server_hash_2; | 436 std::string server_hash_2; |
419 | 437 |
420 SdchManager::GenerateHash(dictionary_text_1, &tmp_hash, &server_hash_1); | 438 SdchManager::GenerateHash(dictionary_text_1, &tmp_hash, &server_hash_1); |
421 SdchManager::GenerateHash(dictionary_text_2, &tmp_hash, &server_hash_2); | 439 SdchManager::GenerateHash(dictionary_text_2, &tmp_hash, &server_hash_2); |
422 | 440 |
423 // Confirm that if you add directories to one manager, you | 441 // Confirm that if you add directories to one manager, you |
424 // can't get them from the other. | 442 // can't get them from the other. |
| 443 SdchManager::ProblemCodes problem; |
425 EXPECT_TRUE(sdch_manager()->AddSdchDictionary( | 444 EXPECT_TRUE(sdch_manager()->AddSdchDictionary( |
426 dictionary_text_1, GURL("http://" + dictionary_domain_1))); | 445 dictionary_text_1, GURL("http://" + dictionary_domain_1), &problem)); |
427 scoped_refptr<SdchManager::Dictionary> dictionary; | 446 scoped_refptr<SdchManager::Dictionary> dictionary; |
428 sdch_manager()->GetVcdiffDictionary( | 447 sdch_manager()->GetVcdiffDictionary( |
429 server_hash_1, | 448 server_hash_1, |
430 GURL("http://" + dictionary_domain_1 + "/random_url"), | 449 GURL("http://" + dictionary_domain_1 + "/random_url"), |
431 &dictionary); | 450 &dictionary); |
432 EXPECT_TRUE(dictionary); | 451 EXPECT_TRUE(dictionary); |
433 | 452 |
434 EXPECT_TRUE(second_manager.AddSdchDictionary( | 453 EXPECT_TRUE(second_manager.AddSdchDictionary( |
435 dictionary_text_2, GURL("http://" + dictionary_domain_2))); | 454 dictionary_text_2, GURL("http://" + dictionary_domain_2), &problem)); |
436 second_manager.GetVcdiffDictionary( | 455 second_manager.GetVcdiffDictionary( |
437 server_hash_2, | 456 server_hash_2, |
438 GURL("http://" + dictionary_domain_2 + "/random_url"), | 457 GURL("http://" + dictionary_domain_2 + "/random_url"), |
439 &dictionary); | 458 &dictionary); |
440 EXPECT_TRUE(dictionary); | 459 EXPECT_TRUE(dictionary); |
441 | 460 |
442 sdch_manager()->GetVcdiffDictionary( | 461 sdch_manager()->GetVcdiffDictionary( |
443 server_hash_2, | 462 server_hash_2, |
444 GURL("http://" + dictionary_domain_2 + "/random_url"), | 463 GURL("http://" + dictionary_domain_2 + "/random_url"), |
445 &dictionary); | 464 &dictionary); |
(...skipping 21 matching lines...) Expand all Loading... |
467 TEST_F(SdchManagerTest, ClearDictionaryData) { | 486 TEST_F(SdchManagerTest, ClearDictionaryData) { |
468 std::string dictionary_domain("x.y.z.google.com"); | 487 std::string dictionary_domain("x.y.z.google.com"); |
469 GURL blacklist_url("http://bad.chromium.org"); | 488 GURL blacklist_url("http://bad.chromium.org"); |
470 | 489 |
471 std::string dictionary_text(NewSdchDictionary(dictionary_domain)); | 490 std::string dictionary_text(NewSdchDictionary(dictionary_domain)); |
472 std::string tmp_hash; | 491 std::string tmp_hash; |
473 std::string server_hash; | 492 std::string server_hash; |
474 | 493 |
475 SdchManager::GenerateHash(dictionary_text, &tmp_hash, &server_hash); | 494 SdchManager::GenerateHash(dictionary_text, &tmp_hash, &server_hash); |
476 | 495 |
| 496 SdchManager::ProblemCodes problem; |
477 EXPECT_TRUE(sdch_manager()->AddSdchDictionary( | 497 EXPECT_TRUE(sdch_manager()->AddSdchDictionary( |
478 dictionary_text, GURL("http://" + dictionary_domain))); | 498 dictionary_text, GURL("http://" + dictionary_domain), &problem)); |
479 scoped_refptr<SdchManager::Dictionary> dictionary; | 499 scoped_refptr<SdchManager::Dictionary> dictionary; |
480 sdch_manager()->GetVcdiffDictionary( | 500 sdch_manager()->GetVcdiffDictionary( |
481 server_hash, | 501 server_hash, |
482 GURL("http://" + dictionary_domain + "/random_url"), | 502 GURL("http://" + dictionary_domain + "/random_url"), |
483 &dictionary); | 503 &dictionary); |
484 EXPECT_TRUE(dictionary); | 504 EXPECT_TRUE(dictionary); |
485 | 505 |
486 sdch_manager()->BlacklistDomain(GURL(blacklist_url)); | 506 sdch_manager()->BlacklistDomain(GURL(blacklist_url)); |
487 EXPECT_FALSE(sdch_manager()->IsInSupportedDomain(blacklist_url)); | 507 EXPECT_FALSE(sdch_manager()->IsInSupportedDomain(blacklist_url)); |
488 | 508 |
489 sdch_manager()->ClearData(); | 509 sdch_manager()->ClearData(); |
490 | 510 |
491 dictionary = NULL; | 511 dictionary = NULL; |
492 sdch_manager()->GetVcdiffDictionary( | 512 sdch_manager()->GetVcdiffDictionary( |
493 server_hash, | 513 server_hash, |
494 GURL("http://" + dictionary_domain + "/random_url"), | 514 GURL("http://" + dictionary_domain + "/random_url"), |
495 &dictionary); | 515 &dictionary); |
496 EXPECT_FALSE(dictionary); | 516 EXPECT_FALSE(dictionary); |
497 EXPECT_TRUE(sdch_manager()->IsInSupportedDomain(blacklist_url)); | 517 EXPECT_TRUE(sdch_manager()->IsInSupportedDomain(blacklist_url)); |
498 } | 518 } |
499 | 519 |
500 } // namespace net | 520 } // namespace net |
501 | 521 |
OLD | NEW |