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 "components/data_reduction_proxy/browser/data_reduction_proxy_params.h" | 5 #include "components/data_reduction_proxy/browser/data_reduction_proxy_params.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 TestDataReductionProxyParams::FlagAltOrigin(), | 112 TestDataReductionProxyParams::FlagAltOrigin(), |
113 TestDataReductionProxyParams::FlagAltFallbackOrigin(), | 113 TestDataReductionProxyParams::FlagAltFallbackOrigin(), |
114 TestDataReductionProxyParams::FlagProbeURL()); | 114 TestDataReductionProxyParams::FlagProbeURL()); |
115 } | 115 } |
116 | 116 |
117 TEST_F(DataReductionProxyParamsTest, InvalidConfigurations) { | 117 TEST_F(DataReductionProxyParamsTest, InvalidConfigurations) { |
118 const struct { | 118 const struct { |
119 bool allowed; | 119 bool allowed; |
120 bool fallback_allowed; | 120 bool fallback_allowed; |
121 bool alternative_allowed; | 121 bool alternative_allowed; |
| 122 bool alternative_fallback_allowed; |
122 bool promo_allowed; | 123 bool promo_allowed; |
123 unsigned int missing_definitions; | 124 unsigned int missing_definitions; |
124 bool expected_result; | 125 bool expected_result; |
125 } tests[] = { | 126 } tests[] = { |
126 { | 127 { |
127 true, | 128 true, |
128 true, | 129 true, |
129 true, | 130 true, |
| 131 false, |
130 true, | 132 true, |
131 TestDataReductionProxyParams::HAS_NOTHING, | 133 TestDataReductionProxyParams::HAS_NOTHING, |
132 true | 134 true |
133 }, | 135 }, |
134 { | 136 { |
135 true, | 137 true, |
136 true, | 138 true, |
137 true, | 139 true, |
| 140 false, |
138 true, | 141 true, |
139 TestDataReductionProxyParams::HAS_DEV_ORIGIN | | 142 TestDataReductionProxyParams::HAS_DEV_ORIGIN | |
140 TestDataReductionProxyParams::HAS_DEV_FALLBACK_ORIGIN, | 143 TestDataReductionProxyParams::HAS_DEV_FALLBACK_ORIGIN, |
141 true | 144 true |
142 }, | 145 }, |
143 { | 146 { |
144 true, | 147 true, |
145 true, | 148 true, |
146 true, | 149 true, |
| 150 false, |
147 true, | 151 true, |
148 TestDataReductionProxyParams::HAS_ORIGIN, | 152 TestDataReductionProxyParams::HAS_ORIGIN, |
149 true | 153 true |
150 }, | 154 }, |
151 { | 155 { |
152 true, | 156 true, |
153 true, | 157 true, |
154 true, | 158 true, |
| 159 false, |
155 true, | 160 true, |
156 TestDataReductionProxyParams::HAS_ORIGIN | | 161 TestDataReductionProxyParams::HAS_ORIGIN | |
157 TestDataReductionProxyParams::HAS_DEV_ORIGIN | | 162 TestDataReductionProxyParams::HAS_DEV_ORIGIN | |
158 TestDataReductionProxyParams::HAS_DEV_FALLBACK_ORIGIN, | 163 TestDataReductionProxyParams::HAS_DEV_FALLBACK_ORIGIN, |
159 false | 164 false |
160 }, | 165 }, |
161 { true, | 166 { |
162 true, | 167 true, |
163 true, | 168 true, |
164 true, | 169 true, |
| 170 false, |
| 171 true, |
165 TestDataReductionProxyParams::HAS_FALLBACK_ORIGIN | | 172 TestDataReductionProxyParams::HAS_FALLBACK_ORIGIN | |
166 TestDataReductionProxyParams::HAS_DEV_FALLBACK_ORIGIN, | 173 TestDataReductionProxyParams::HAS_DEV_FALLBACK_ORIGIN, |
167 false | 174 false |
168 }, | 175 }, |
169 { true, | 176 { |
170 true, | 177 true, |
171 true, | 178 true, |
172 true, | 179 true, |
| 180 false, |
| 181 true, |
173 TestDataReductionProxyParams::HAS_SSL_ORIGIN, | 182 TestDataReductionProxyParams::HAS_SSL_ORIGIN, |
174 false | 183 false |
175 }, | 184 }, |
176 { true, | 185 { |
177 true, | 186 true, |
178 true, | 187 true, |
179 true, | 188 true, |
| 189 false, |
| 190 true, |
180 TestDataReductionProxyParams::HAS_ALT_ORIGIN, | 191 TestDataReductionProxyParams::HAS_ALT_ORIGIN, |
181 false | 192 false |
182 }, | 193 }, |
183 { true, | 194 { |
| 195 true, |
| 196 true, |
| 197 true, |
| 198 false, |
| 199 true, |
| 200 TestDataReductionProxyParams::HAS_ALT_FALLBACK_ORIGIN, |
| 201 true |
| 202 }, |
| 203 { |
| 204 true, |
| 205 true, |
184 true, | 206 true, |
185 true, | 207 true, |
186 true, | 208 true, |
187 TestDataReductionProxyParams::HAS_ALT_FALLBACK_ORIGIN, | 209 TestDataReductionProxyParams::HAS_ALT_FALLBACK_ORIGIN, |
188 false | 210 false |
189 }, | 211 }, |
190 { true, | 212 { |
191 true, | 213 true, |
192 true, | 214 true, |
193 true, | 215 true, |
| 216 false, |
| 217 true, |
194 TestDataReductionProxyParams::HAS_PROBE_URL, | 218 TestDataReductionProxyParams::HAS_PROBE_URL, |
195 false | 219 false |
196 }, | 220 }, |
197 { | 221 { |
198 true, | 222 true, |
199 false, | 223 false, |
200 true, | 224 true, |
| 225 false, |
201 true, | 226 true, |
202 TestDataReductionProxyParams::HAS_NOTHING, | 227 TestDataReductionProxyParams::HAS_NOTHING, |
203 true | 228 true |
204 }, | 229 }, |
205 { | 230 { |
206 true, | 231 true, |
207 false, | 232 false, |
208 true, | 233 true, |
| 234 false, |
209 true, | 235 true, |
210 TestDataReductionProxyParams::HAS_ORIGIN | | 236 TestDataReductionProxyParams::HAS_ORIGIN | |
211 TestDataReductionProxyParams::HAS_DEV_ORIGIN | | 237 TestDataReductionProxyParams::HAS_DEV_ORIGIN | |
212 TestDataReductionProxyParams::HAS_DEV_FALLBACK_ORIGIN, | 238 TestDataReductionProxyParams::HAS_DEV_FALLBACK_ORIGIN, |
213 false | 239 false |
214 }, | 240 }, |
215 { | 241 { |
216 true, | 242 true, |
217 false, | 243 false, |
218 true, | 244 true, |
| 245 false, |
219 true, | 246 true, |
220 TestDataReductionProxyParams::HAS_FALLBACK_ORIGIN, | 247 TestDataReductionProxyParams::HAS_FALLBACK_ORIGIN, |
221 true | 248 true |
222 }, | 249 }, |
223 { | 250 { |
224 true, | 251 true, |
225 false, | 252 false, |
226 true, | 253 true, |
| 254 false, |
227 true, | 255 true, |
228 TestDataReductionProxyParams::HAS_SSL_ORIGIN, | 256 TestDataReductionProxyParams::HAS_SSL_ORIGIN, |
229 false | 257 false |
230 }, | 258 }, |
231 { | 259 { |
232 true, | 260 true, |
233 false, | 261 false, |
234 true, | 262 true, |
| 263 false, |
235 true, | 264 true, |
236 TestDataReductionProxyParams::HAS_ALT_ORIGIN, | 265 TestDataReductionProxyParams::HAS_ALT_ORIGIN, |
237 false | 266 false |
238 }, | 267 }, |
239 { | 268 { |
240 true, | 269 true, |
241 false, | 270 false, |
242 true, | 271 true, |
| 272 false, |
243 true, | 273 true, |
244 TestDataReductionProxyParams::HAS_ALT_FALLBACK_ORIGIN, | 274 TestDataReductionProxyParams::HAS_ALT_FALLBACK_ORIGIN, |
245 true | 275 true |
246 }, | 276 }, |
247 { | 277 { |
248 true, | 278 true, |
249 false, | 279 false, |
250 true, | 280 true, |
251 true, | 281 true, |
| 282 true, |
| 283 TestDataReductionProxyParams::HAS_ALT_FALLBACK_ORIGIN, |
| 284 false |
| 285 }, |
| 286 { |
| 287 true, |
| 288 false, |
| 289 true, |
| 290 false, |
| 291 true, |
252 TestDataReductionProxyParams::HAS_PROBE_URL, | 292 TestDataReductionProxyParams::HAS_PROBE_URL, |
253 false | 293 false |
254 }, | 294 }, |
255 | |
256 { | 295 { |
257 true, | 296 true, |
258 true, | 297 true, |
259 false, | 298 false, |
| 299 false, |
260 true, | 300 true, |
261 TestDataReductionProxyParams::HAS_NOTHING, | 301 TestDataReductionProxyParams::HAS_NOTHING, |
262 true | 302 true |
263 }, | 303 }, |
264 { | 304 { |
265 true, | 305 true, |
266 true, | 306 true, |
267 false, | 307 false, |
| 308 false, |
268 true, | 309 true, |
269 TestDataReductionProxyParams::HAS_ORIGIN | | 310 TestDataReductionProxyParams::HAS_ORIGIN | |
270 TestDataReductionProxyParams::HAS_DEV_ORIGIN | | 311 TestDataReductionProxyParams::HAS_DEV_ORIGIN | |
271 TestDataReductionProxyParams::HAS_DEV_FALLBACK_ORIGIN, | 312 TestDataReductionProxyParams::HAS_DEV_FALLBACK_ORIGIN, |
272 false | 313 false |
273 }, | 314 }, |
274 { | 315 { |
275 true, | 316 true, |
276 true, | 317 true, |
277 false, | 318 false, |
| 319 false, |
278 true, | 320 true, |
279 TestDataReductionProxyParams::HAS_FALLBACK_ORIGIN | | 321 TestDataReductionProxyParams::HAS_FALLBACK_ORIGIN | |
280 TestDataReductionProxyParams::HAS_DEV_FALLBACK_ORIGIN, | 322 TestDataReductionProxyParams::HAS_DEV_FALLBACK_ORIGIN, |
281 false | 323 false |
282 }, | 324 }, |
283 { | 325 { |
284 true, | 326 true, |
285 true, | 327 true, |
286 false, | 328 false, |
| 329 false, |
287 true, | 330 true, |
288 TestDataReductionProxyParams::HAS_SSL_ORIGIN, | 331 TestDataReductionProxyParams::HAS_SSL_ORIGIN, |
289 true | 332 true |
290 }, | 333 }, |
291 { | 334 { |
292 true, | 335 true, |
293 true, | 336 true, |
294 false, | 337 false, |
| 338 false, |
295 true, | 339 true, |
296 TestDataReductionProxyParams::HAS_ALT_ORIGIN, | 340 TestDataReductionProxyParams::HAS_ALT_ORIGIN, |
297 true | 341 true |
298 }, | 342 }, |
299 { | 343 { |
300 true, | 344 true, |
301 true, | 345 true, |
302 false, | 346 false, |
| 347 false, |
303 true, | 348 true, |
304 TestDataReductionProxyParams::HAS_ALT_FALLBACK_ORIGIN, | 349 TestDataReductionProxyParams::HAS_ALT_FALLBACK_ORIGIN, |
305 true | 350 true |
306 }, | 351 }, |
307 { | 352 { |
308 true, | 353 true, |
309 true, | 354 true, |
310 false, | 355 false, |
311 true, | 356 true, |
| 357 true, |
| 358 TestDataReductionProxyParams::HAS_ALT_FALLBACK_ORIGIN, |
| 359 false |
| 360 }, |
| 361 { |
| 362 true, |
| 363 true, |
| 364 false, |
| 365 false, |
| 366 true, |
312 TestDataReductionProxyParams::HAS_PROBE_URL, | 367 TestDataReductionProxyParams::HAS_PROBE_URL, |
313 false | 368 false |
314 }, | 369 }, |
315 { | 370 { |
316 true, | 371 true, |
317 false, | 372 false, |
318 false, | 373 false, |
| 374 false, |
319 true, | 375 true, |
320 TestDataReductionProxyParams::HAS_ORIGIN | | 376 TestDataReductionProxyParams::HAS_ORIGIN | |
321 TestDataReductionProxyParams::HAS_DEV_ORIGIN | | 377 TestDataReductionProxyParams::HAS_DEV_ORIGIN | |
322 TestDataReductionProxyParams::HAS_DEV_FALLBACK_ORIGIN, | 378 TestDataReductionProxyParams::HAS_DEV_FALLBACK_ORIGIN, |
323 false | 379 false |
324 }, | 380 }, |
325 { | 381 { |
326 true, | 382 true, |
327 false, | 383 false, |
328 false, | 384 false, |
| 385 false, |
329 true, | 386 true, |
330 TestDataReductionProxyParams::HAS_FALLBACK_ORIGIN, | 387 TestDataReductionProxyParams::HAS_FALLBACK_ORIGIN, |
331 true | 388 true |
332 }, | 389 }, |
333 { | 390 { |
334 true, | 391 true, |
335 false, | 392 false, |
336 false, | 393 false, |
| 394 false, |
337 true, | 395 true, |
338 TestDataReductionProxyParams::HAS_SSL_ORIGIN, | 396 TestDataReductionProxyParams::HAS_SSL_ORIGIN, |
339 true | 397 true |
340 }, | 398 }, |
341 { | 399 { |
342 true, | 400 true, |
343 false, | 401 false, |
344 false, | 402 false, |
| 403 false, |
345 true, | 404 true, |
346 TestDataReductionProxyParams::HAS_ALT_ORIGIN, | 405 TestDataReductionProxyParams::HAS_ALT_ORIGIN, |
347 true | 406 true |
348 }, | 407 }, |
349 { | 408 { |
350 true, | 409 true, |
351 false, | 410 false, |
352 false, | 411 false, |
| 412 false, |
353 true, | 413 true, |
354 TestDataReductionProxyParams::HAS_ALT_FALLBACK_ORIGIN, | 414 TestDataReductionProxyParams::HAS_ALT_FALLBACK_ORIGIN, |
355 true | 415 true |
356 }, | 416 }, |
357 { | 417 { |
358 true, | 418 true, |
359 false, | 419 false, |
360 false, | 420 false, |
361 true, | 421 true, |
| 422 true, |
| 423 TestDataReductionProxyParams::HAS_ALT_FALLBACK_ORIGIN, |
| 424 false |
| 425 }, |
| 426 { |
| 427 true, |
| 428 false, |
| 429 false, |
| 430 false, |
| 431 true, |
362 TestDataReductionProxyParams::HAS_PROBE_URL, | 432 TestDataReductionProxyParams::HAS_PROBE_URL, |
363 false | 433 false |
364 }, | 434 }, |
365 { | 435 { |
366 false, | 436 false, |
367 true, | 437 true, |
368 true, | 438 true, |
| 439 false, |
369 true, | 440 true, |
370 TestDataReductionProxyParams::HAS_NOTHING, | 441 TestDataReductionProxyParams::HAS_NOTHING, |
371 false | 442 false |
372 }, | 443 }, |
373 { | 444 { |
374 false, | 445 false, |
375 true, | 446 true, |
376 true, | 447 true, |
| 448 false, |
377 true, | 449 true, |
378 TestDataReductionProxyParams::HAS_ORIGIN | | 450 TestDataReductionProxyParams::HAS_ORIGIN | |
379 TestDataReductionProxyParams::HAS_DEV_ORIGIN | | 451 TestDataReductionProxyParams::HAS_DEV_ORIGIN | |
380 TestDataReductionProxyParams::HAS_DEV_FALLBACK_ORIGIN, | 452 TestDataReductionProxyParams::HAS_DEV_FALLBACK_ORIGIN, |
381 false | 453 false |
382 }, | 454 }, |
383 { | 455 { |
384 false, | 456 false, |
385 true, | 457 true, |
386 true, | 458 true, |
| 459 false, |
387 true, | 460 true, |
388 TestDataReductionProxyParams::HAS_FALLBACK_ORIGIN, | 461 TestDataReductionProxyParams::HAS_FALLBACK_ORIGIN, |
389 false | 462 false |
390 }, | 463 }, |
391 { | 464 { |
392 false, | 465 false, |
393 true, | 466 true, |
394 true, | 467 true, |
| 468 false, |
395 true, | 469 true, |
396 TestDataReductionProxyParams::HAS_SSL_ORIGIN, | 470 TestDataReductionProxyParams::HAS_SSL_ORIGIN, |
397 false | 471 false |
398 }, | 472 }, |
399 { | 473 { |
400 false, | 474 false, |
401 true, | 475 true, |
402 true, | 476 true, |
| 477 false, |
403 true, | 478 true, |
404 TestDataReductionProxyParams::HAS_ALT_ORIGIN, | 479 TestDataReductionProxyParams::HAS_ALT_ORIGIN, |
405 false | 480 false |
406 }, | 481 }, |
407 { | 482 { |
408 false, | 483 false, |
409 true, | 484 true, |
410 true, | 485 true, |
| 486 false, |
| 487 true, |
| 488 TestDataReductionProxyParams::HAS_ALT_FALLBACK_ORIGIN, |
| 489 false |
| 490 }, |
| 491 { |
| 492 false, |
| 493 true, |
| 494 true, |
| 495 true, |
411 true, | 496 true, |
412 TestDataReductionProxyParams::HAS_ALT_FALLBACK_ORIGIN, | 497 TestDataReductionProxyParams::HAS_ALT_FALLBACK_ORIGIN, |
413 false | 498 false |
414 }, | 499 }, |
415 { | 500 { |
416 false, | 501 false, |
417 true, | 502 true, |
418 true, | 503 true, |
| 504 false, |
419 true, | 505 true, |
420 TestDataReductionProxyParams::HAS_PROBE_URL, | 506 TestDataReductionProxyParams::HAS_PROBE_URL, |
421 false | 507 false |
422 }, | 508 }, |
423 }; | 509 }; |
424 | 510 |
425 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { | 511 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { |
426 int flags = 0; | 512 int flags = 0; |
427 if (tests[i].allowed) | 513 if (tests[i].allowed) |
428 flags |= DataReductionProxyParams::kAllowed; | 514 flags |= DataReductionProxyParams::kAllowed; |
429 if (tests[i].fallback_allowed) | 515 if (tests[i].fallback_allowed) |
430 flags |= DataReductionProxyParams::kFallbackAllowed; | 516 flags |= DataReductionProxyParams::kFallbackAllowed; |
431 if (tests[i].alternative_allowed) | 517 if (tests[i].alternative_allowed) |
432 flags |= DataReductionProxyParams::kAlternativeAllowed; | 518 flags |= DataReductionProxyParams::kAlternativeAllowed; |
| 519 if (tests[i].alternative_fallback_allowed) |
| 520 flags |= DataReductionProxyParams::kAlternativeFallbackAllowed; |
433 if (tests[i].promo_allowed) | 521 if (tests[i].promo_allowed) |
434 flags |= DataReductionProxyParams::kPromoAllowed; | 522 flags |= DataReductionProxyParams::kPromoAllowed; |
435 TestDataReductionProxyParams params( | 523 TestDataReductionProxyParams params( |
436 flags, | 524 flags, |
437 TestDataReductionProxyParams::HAS_EVERYTHING & | 525 TestDataReductionProxyParams::HAS_EVERYTHING & |
438 ~(tests[i].missing_definitions)); | 526 ~(tests[i].missing_definitions)); |
439 EXPECT_EQ(tests[i].expected_result, params.init_result()) << i; | 527 EXPECT_EQ(tests[i].expected_result, params.init_result()) << i; |
440 } | 528 } |
441 } | 529 } |
442 | 530 |
443 TEST_F(DataReductionProxyParamsTest, IsDataReductionProxy) { | 531 TEST_F(DataReductionProxyParamsTest, IsDataReductionProxy) { |
444 const struct { | 532 const struct { |
445 net::HostPortPair host_port_pair; | 533 net::HostPortPair host_port_pair; |
446 bool fallback_allowed; | 534 bool fallback_allowed; |
| 535 bool alt_fallback_allowed; |
447 bool set_dev_origin; | 536 bool set_dev_origin; |
448 bool expected_result; | 537 bool expected_result; |
449 net::HostPortPair expected_first; | 538 net::HostPortPair expected_first; |
450 net::HostPortPair expected_second; | 539 net::HostPortPair expected_second; |
451 bool expected_is_fallback; | 540 bool expected_is_fallback; |
452 bool expected_is_alternative; | 541 bool expected_is_alternative; |
453 bool expected_is_ssl; | 542 bool expected_is_ssl; |
454 } tests[] = { | 543 } tests[] = { |
455 { net::HostPortPair::FromURL(GURL( | 544 { |
| 545 net::HostPortPair::FromURL(GURL( |
456 TestDataReductionProxyParams::DefaultOrigin())), | 546 TestDataReductionProxyParams::DefaultOrigin())), |
457 true, | 547 true, |
| 548 true, |
458 false, | 549 false, |
459 true, | 550 true, |
460 net::HostPortPair::FromURL(GURL( | 551 net::HostPortPair::FromURL(GURL( |
461 TestDataReductionProxyParams::DefaultOrigin())), | 552 TestDataReductionProxyParams::DefaultOrigin())), |
462 net::HostPortPair::FromURL(GURL( | 553 net::HostPortPair::FromURL(GURL( |
463 TestDataReductionProxyParams::DefaultFallbackOrigin())), | 554 TestDataReductionProxyParams::DefaultFallbackOrigin())), |
464 false, | 555 false, |
465 false, | 556 false, |
466 false | 557 false |
467 }, | 558 }, |
468 { net::HostPortPair::FromURL(GURL( | 559 { |
| 560 net::HostPortPair::FromURL(GURL( |
469 TestDataReductionProxyParams::DefaultOrigin())), | 561 TestDataReductionProxyParams::DefaultOrigin())), |
470 false, | 562 false, |
471 false, | 563 false, |
| 564 false, |
472 true, | 565 true, |
473 net::HostPortPair::FromURL(GURL( | 566 net::HostPortPair::FromURL(GURL( |
474 TestDataReductionProxyParams::DefaultOrigin())), | 567 TestDataReductionProxyParams::DefaultOrigin())), |
475 net::HostPortPair::FromURL(GURL()), | 568 net::HostPortPair::FromURL(GURL()), |
476 false, | 569 false, |
477 false, | 570 false, |
478 false | 571 false |
479 }, | 572 }, |
480 { net::HostPortPair::FromURL(GURL( | 573 { |
| 574 net::HostPortPair::FromURL(GURL( |
481 TestDataReductionProxyParams::DefaultFallbackOrigin())), | 575 TestDataReductionProxyParams::DefaultFallbackOrigin())), |
482 true, | 576 true, |
| 577 true, |
483 false, | 578 false, |
484 true, | 579 true, |
485 net::HostPortPair::FromURL(GURL( | 580 net::HostPortPair::FromURL(GURL( |
486 TestDataReductionProxyParams::DefaultFallbackOrigin())), | 581 TestDataReductionProxyParams::DefaultFallbackOrigin())), |
487 net::HostPortPair::FromURL(GURL()), | 582 net::HostPortPair::FromURL(GURL()), |
488 true, | 583 true, |
489 false, | 584 false, |
490 false | 585 false |
491 }, | 586 }, |
492 { net::HostPortPair::FromURL(GURL( | 587 { |
| 588 net::HostPortPair::FromURL(GURL( |
493 TestDataReductionProxyParams::DefaultFallbackOrigin())), | 589 TestDataReductionProxyParams::DefaultFallbackOrigin())), |
494 false, | 590 false, |
495 false, | 591 false, |
496 false, | 592 false, |
| 593 false, |
497 net::HostPortPair::FromURL(GURL()), | 594 net::HostPortPair::FromURL(GURL()), |
498 net::HostPortPair::FromURL(GURL()), | 595 net::HostPortPair::FromURL(GURL()), |
499 false, | 596 false, |
500 false, | 597 false, |
501 false | 598 false |
502 }, | 599 }, |
503 { net::HostPortPair::FromURL(GURL( | 600 { |
| 601 net::HostPortPair::FromURL(GURL( |
504 TestDataReductionProxyParams::DefaultAltOrigin())), | 602 TestDataReductionProxyParams::DefaultAltOrigin())), |
505 true, | 603 true, |
| 604 true, |
506 false, | 605 false, |
507 true, | 606 true, |
508 net::HostPortPair::FromURL(GURL( | 607 net::HostPortPair::FromURL(GURL( |
509 TestDataReductionProxyParams::DefaultAltOrigin())), | 608 TestDataReductionProxyParams::DefaultAltOrigin())), |
510 net::HostPortPair::FromURL(GURL( | 609 net::HostPortPair::FromURL(GURL( |
511 TestDataReductionProxyParams::DefaultAltFallbackOrigin())), | 610 TestDataReductionProxyParams::DefaultAltFallbackOrigin())), |
512 false, | 611 false, |
513 true, | 612 true, |
514 false | 613 false |
515 }, | 614 }, |
516 { net::HostPortPair::FromURL(GURL( | 615 { |
| 616 net::HostPortPair::FromURL(GURL( |
517 TestDataReductionProxyParams::DefaultAltOrigin())), | 617 TestDataReductionProxyParams::DefaultAltOrigin())), |
518 false, | 618 false, |
519 false, | 619 false, |
| 620 false, |
520 true, | 621 true, |
521 net::HostPortPair::FromURL(GURL( | 622 net::HostPortPair::FromURL(GURL( |
522 TestDataReductionProxyParams::DefaultAltOrigin())), | 623 TestDataReductionProxyParams::DefaultAltOrigin())), |
523 net::HostPortPair::FromURL(GURL()), | 624 net::HostPortPair::FromURL(GURL()), |
524 false, | 625 false, |
525 true, | 626 true, |
526 false | 627 false |
527 }, | 628 }, |
528 { net::HostPortPair::FromURL( | 629 { |
| 630 net::HostPortPair::FromURL( |
529 GURL(TestDataReductionProxyParams::DefaultAltFallbackOrigin())), | 631 GURL(TestDataReductionProxyParams::DefaultAltFallbackOrigin())), |
530 true, | 632 true, |
| 633 true, |
531 false, | 634 false, |
532 true, | 635 true, |
533 net::HostPortPair::FromURL(GURL( | 636 net::HostPortPair::FromURL(GURL( |
534 TestDataReductionProxyParams::DefaultAltFallbackOrigin())), | 637 TestDataReductionProxyParams::DefaultAltFallbackOrigin())), |
535 net::HostPortPair::FromURL(GURL()), | 638 net::HostPortPair::FromURL(GURL()), |
536 true, | 639 true, |
537 true, | 640 true, |
538 false | 641 false |
539 }, | 642 }, |
540 { net::HostPortPair::FromURL(GURL( | 643 { |
| 644 net::HostPortPair::FromURL(GURL( |
541 TestDataReductionProxyParams::DefaultAltFallbackOrigin())), | 645 TestDataReductionProxyParams::DefaultAltFallbackOrigin())), |
542 false, | 646 false, |
543 false, | 647 false, |
544 false, | 648 false, |
| 649 false, |
545 net::HostPortPair::FromURL(GURL()), | 650 net::HostPortPair::FromURL(GURL()), |
546 net::HostPortPair::FromURL(GURL()), | 651 net::HostPortPair::FromURL(GURL()), |
547 false, | 652 false, |
548 false, | 653 false, |
549 false | 654 false |
550 }, | 655 }, |
551 { net::HostPortPair::FromURL(GURL( | 656 { |
| 657 net::HostPortPair::FromURL(GURL( |
552 TestDataReductionProxyParams::DefaultSSLOrigin())), | 658 TestDataReductionProxyParams::DefaultSSLOrigin())), |
553 true, | 659 true, |
| 660 true, |
554 false, | 661 false, |
555 true, | 662 true, |
556 net::HostPortPair::FromURL(GURL( | 663 net::HostPortPair::FromURL(GURL( |
557 TestDataReductionProxyParams::DefaultSSLOrigin())), | 664 TestDataReductionProxyParams::DefaultSSLOrigin())), |
558 net::HostPortPair::FromURL(GURL()), | 665 net::HostPortPair::FromURL(GURL()), |
559 false, | 666 false, |
560 false, | 667 false, |
561 true | 668 true |
562 }, | 669 }, |
563 { net::HostPortPair::FromURL(GURL( | 670 { |
| 671 net::HostPortPair::FromURL(GURL( |
564 TestDataReductionProxyParams::DefaultDevOrigin())), | 672 TestDataReductionProxyParams::DefaultDevOrigin())), |
565 true, | 673 true, |
566 true, | 674 true, |
567 true, | 675 true, |
| 676 true, |
568 net::HostPortPair::FromURL(GURL( | 677 net::HostPortPair::FromURL(GURL( |
569 TestDataReductionProxyParams::DefaultDevOrigin())), | 678 TestDataReductionProxyParams::DefaultDevOrigin())), |
570 net::HostPortPair::FromURL(GURL( | 679 net::HostPortPair::FromURL(GURL( |
571 TestDataReductionProxyParams::DefaultDevFallbackOrigin())), | 680 TestDataReductionProxyParams::DefaultDevFallbackOrigin())), |
572 false, | 681 false, |
573 false, | 682 false, |
574 false | 683 false |
575 }, | 684 }, |
576 { net::HostPortPair::FromURL(GURL( | 685 { |
| 686 net::HostPortPair::FromURL(GURL( |
577 TestDataReductionProxyParams::DefaultOrigin())), | 687 TestDataReductionProxyParams::DefaultOrigin())), |
578 true, | 688 true, |
579 true, | 689 true, |
| 690 true, |
580 false, | 691 false, |
581 net::HostPortPair::FromURL(GURL()), | 692 net::HostPortPair::FromURL(GURL()), |
582 net::HostPortPair::FromURL(GURL()), | 693 net::HostPortPair::FromURL(GURL()), |
583 false, | 694 false, |
584 false, | 695 false, |
585 false | 696 false |
586 }, | 697 }, |
587 }; | 698 }; |
588 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { | 699 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { |
589 int flags = DataReductionProxyParams::kAllowed | | 700 int flags = DataReductionProxyParams::kAllowed | |
590 DataReductionProxyParams::kAlternativeAllowed; | 701 DataReductionProxyParams::kAlternativeAllowed; |
591 if (tests[i].fallback_allowed) | 702 if (tests[i].fallback_allowed) |
592 flags |= DataReductionProxyParams::kFallbackAllowed; | 703 flags |= DataReductionProxyParams::kFallbackAllowed; |
| 704 if (tests[i].alt_fallback_allowed) |
| 705 flags |= DataReductionProxyParams::kAlternativeFallbackAllowed; |
593 unsigned int has_definitions = TestDataReductionProxyParams::HAS_EVERYTHING; | 706 unsigned int has_definitions = TestDataReductionProxyParams::HAS_EVERYTHING; |
594 if (!tests[i].set_dev_origin) { | 707 if (!tests[i].set_dev_origin) { |
595 has_definitions &= ~TestDataReductionProxyParams::HAS_DEV_ORIGIN; | 708 has_definitions &= ~TestDataReductionProxyParams::HAS_DEV_ORIGIN; |
596 has_definitions &= ~TestDataReductionProxyParams::HAS_DEV_FALLBACK_ORIGIN; | 709 has_definitions &= ~TestDataReductionProxyParams::HAS_DEV_FALLBACK_ORIGIN; |
597 } | 710 } |
598 TestDataReductionProxyParams params(flags, has_definitions); | 711 TestDataReductionProxyParams params(flags, has_definitions); |
599 DataReductionProxyTypeInfo proxy_type_info; | 712 DataReductionProxyTypeInfo proxy_type_info; |
600 EXPECT_EQ(tests[i].expected_result, | 713 EXPECT_EQ(tests[i].expected_result, |
601 params.IsDataReductionProxy( | 714 params.IsDataReductionProxy( |
602 tests[i].host_port_pair, &proxy_type_info)) << i; | 715 tests[i].host_port_pair, &proxy_type_info)) << i; |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
993 retry_map[ssl_origin] = retry_info; | 1106 retry_map[ssl_origin] = retry_info; |
994 | 1107 |
995 bool was_bypassed = params.AreProxiesBypassed(retry_map, | 1108 bool was_bypassed = params.AreProxiesBypassed(retry_map, |
996 tests[i].is_https, | 1109 tests[i].is_https, |
997 NULL); | 1110 NULL); |
998 | 1111 |
999 EXPECT_EQ(tests[i].expected_result, was_bypassed); | 1112 EXPECT_EQ(tests[i].expected_result, was_bypassed); |
1000 } | 1113 } |
1001 } | 1114 } |
1002 } // namespace data_reduction_proxy | 1115 } // namespace data_reduction_proxy |
OLD | NEW |