Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/content/browser/content_lofi_decider.h " | 5 #include "components/data_reduction_proxy/content/browser/content_lofi_decider.h " |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| 11 | 11 |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
| 15 #include "base/metrics/field_trial.h" | 15 #include "base/metrics/field_trial.h" |
| 16 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
| 17 #include "base/strings/stringprintf.h" | 17 #include "base/strings/stringprintf.h" |
| 18 #include "base/test/scoped_feature_list.h" | |
| 18 #include "build/build_config.h" | 19 #include "build/build_config.h" |
| 19 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf ig_test_utils.h" | 20 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf ig_test_utils.h" |
| 20 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_data .h" | 21 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_data .h" |
| 21 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_netw ork_delegate.h" | 22 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_netw ork_delegate.h" |
| 22 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_requ est_options.h" | 23 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_requ est_options.h" |
| 23 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_test _utils.h" | 24 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_test _utils.h" |
| 25 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_featu res.h" | |
| 24 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_heade rs.h" | 26 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_heade rs.h" |
| 25 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param s.h" | 27 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param s.h" |
| 26 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param s_test_utils.h" | 28 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param s_test_utils.h" |
| 27 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_switc hes.h" | 29 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_switc hes.h" |
| 28 #include "content/public/browser/resource_request_info.h" | 30 #include "content/public/browser/resource_request_info.h" |
| 29 #include "content/public/common/previews_state.h" | 31 #include "content/public/common/previews_state.h" |
| 30 #include "net/base/load_flags.h" | 32 #include "net/base/load_flags.h" |
| 31 #include "net/base/network_delegate_impl.h" | 33 #include "net/base/network_delegate_impl.h" |
| 32 #include "net/http/http_request_headers.h" | 34 #include "net/http/http_request_headers.h" |
| 33 #include "net/proxy/proxy_info.h" | 35 #include "net/proxy/proxy_info.h" |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 299 VerifyLoFiHeader(!tests[i].is_using_lite_page, !tests[i].is_using_lofi, | 301 VerifyLoFiHeader(!tests[i].is_using_lite_page, !tests[i].is_using_lofi, |
| 300 headers); | 302 headers); |
| 301 VerifyLitePageHeader(false, false, headers); | 303 VerifyLitePageHeader(false, false, headers); |
| 302 data = DataReductionProxyData::GetData(*request); | 304 data = DataReductionProxyData::GetData(*request); |
| 303 // |lofi_requested| should be set to false when Lo-Fi is enabled using | 305 // |lofi_requested| should be set to false when Lo-Fi is enabled using |
| 304 // flags. | 306 // flags. |
| 305 EXPECT_FALSE(data->lofi_requested()); | 307 EXPECT_FALSE(data->lofi_requested()); |
| 306 } | 308 } |
| 307 } | 309 } |
| 308 | 310 |
| 311 TEST_F(ContentLoFiDeciderTest, MaybeSetAcceptTransformHeaderProxyDecides) { | |
|
megjablon
2017/05/30 18:38:53
It looks like there's a lot of repeated code in th
dougarnett
2017/05/30 22:15:48
In my previous mondo CL, I had used the struct app
bengr
2017/05/31 18:48:28
I don't like the pattern of using an array of stru
dougarnett
2017/05/31 23:05:21
Ok, broke up into 4 difference tests with simplifi
| |
| 312 // Turn on proxy-decides-transform feature for these unit tests. | |
| 313 base::test::ScopedFeatureList scoped_feature_list; | |
| 314 scoped_feature_list.InitAndEnableFeature( | |
| 315 features::kDataReductionProxyDecidesTransform); | |
| 316 | |
| 317 std::unique_ptr<data_reduction_proxy::ContentLoFiDecider> lofi_decider( | |
| 318 new data_reduction_proxy::ContentLoFiDecider()); | |
| 319 | |
| 320 content::PreviewsState lite_page_enabled = content::SERVER_LITE_PAGE_ON; | |
| 321 content::PreviewsState lofi_enabled = content::SERVER_LOFI_ON; | |
| 322 content::PreviewsState both_previews_enabled = | |
| 323 lite_page_enabled | lofi_enabled; | |
| 324 | |
| 325 // Verify no accept header for HTTPS. | |
| 326 { | |
| 327 std::unique_ptr<net::URLRequest> request = | |
| 328 CreateRequestByType(content::RESOURCE_TYPE_MAIN_FRAME, true /* https */, | |
| 329 both_previews_enabled); | |
| 330 net::HttpRequestHeaders headers; | |
| 331 lofi_decider->MaybeSetAcceptTransformHeader(*request.get(), false, | |
| 332 &headers); | |
| 333 VerifyLitePageHeader(false /* lite-page */, false /*if-heavy */, headers); | |
| 334 VerifyLoFiHeader(false /* empty-image */, false /*if-heavy */, headers); | |
| 335 | |
| 336 request = CreateRequestByType(content::RESOURCE_TYPE_IMAGE, | |
| 337 true /* https */, both_previews_enabled); | |
| 338 lofi_decider->MaybeSetAcceptTransformHeader(*request.get(), false, | |
| 339 &headers); | |
| 340 VerifyLitePageHeader(false /* lite-page */, false /*if-heavy */, headers); | |
| 341 VerifyLoFiHeader(false /* empty-image */, false /*if-heavy */, headers); | |
| 342 } | |
| 343 | |
| 344 // Verify no accept header if previews state indicates to not accept. | |
| 345 { | |
| 346 content::PreviewsState previews_off = | |
| 347 content::PREVIEWS_OFF & both_previews_enabled; | |
| 348 std::unique_ptr<net::URLRequest> request = | |
| 349 CreateRequest(true /* is main */, previews_off); | |
| 350 net::HttpRequestHeaders headers; | |
| 351 lofi_decider->MaybeSetAcceptTransformHeader(*request.get(), false, | |
| 352 &headers); | |
| 353 VerifyLitePageHeader(false /* lite-page */, false /*if-heavy */, headers); | |
| 354 VerifyLoFiHeader(false /* empty-image */, false /*if-heavy */, headers); | |
| 355 | |
| 356 content::PreviewsState previews_no_transform = | |
| 357 content::PREVIEWS_NO_TRANSFORM & both_previews_enabled; | |
| 358 request = CreateRequest(true /* is main */, previews_no_transform); | |
| 359 lofi_decider->MaybeSetAcceptTransformHeader(*request.get(), false, | |
| 360 &headers); | |
| 361 VerifyLitePageHeader(false /* lite-page */, false /*if-heavy */, headers); | |
| 362 VerifyLoFiHeader(false /* empty-image */, false /*if-heavy */, headers); | |
| 363 } | |
| 364 | |
| 365 // Verify accepting lite-page per resource type. | |
| 366 { | |
| 367 std::unique_ptr<net::URLRequest> request = | |
| 368 CreateRequest(true /* is main */, lite_page_enabled); | |
| 369 net::HttpRequestHeaders headers1; | |
| 370 lofi_decider->MaybeSetAcceptTransformHeader(*request.get(), false, | |
| 371 &headers1); | |
| 372 VerifyLitePageHeader(true /* lite-page */, false /*if-heavy */, headers1); | |
| 373 VerifyLoFiHeader(false /* empty-image */, false /*if-heavy */, headers1); | |
| 374 | |
| 375 net::HttpRequestHeaders headers2; | |
| 376 request = CreateRequest(false /* is main */, lite_page_enabled); | |
| 377 lofi_decider->MaybeSetAcceptTransformHeader(*request.get(), false, | |
| 378 &headers2); | |
| 379 VerifyLitePageHeader(false /* lite-page */, false /*if-heavy */, headers2); | |
| 380 VerifyLoFiHeader(false /* empty-image */, false /*if-heavy */, headers2); | |
| 381 } | |
| 382 | |
| 383 // Verify accepting empty-image per resource type. | |
| 384 { | |
| 385 std::unique_ptr<net::URLRequest> request = CreateRequestByType( | |
| 386 content::RESOURCE_TYPE_MAIN_FRAME, false /* https */, lofi_enabled); | |
| 387 net::HttpRequestHeaders headers1; | |
| 388 lofi_decider->MaybeSetAcceptTransformHeader(*request.get(), false, | |
| 389 &headers1); | |
| 390 VerifyLitePageHeader(false /* lite-page */, false /*if-heavy */, headers1); | |
| 391 VerifyLoFiHeader(false /* empty-image */, false /*if-heavy */, headers1); | |
| 392 | |
| 393 net::HttpRequestHeaders headers2; | |
| 394 request = CreateRequestByType(content::RESOURCE_TYPE_IMAGE, | |
| 395 false /* https */, lofi_enabled); | |
| 396 lofi_decider->MaybeSetAcceptTransformHeader(*request.get(), false, | |
| 397 &headers2); | |
| 398 VerifyLitePageHeader(false /* lite-page */, false /*if-heavy */, headers2); | |
| 399 VerifyLoFiHeader(true /* empty-image */, false /*if-heavy */, headers2); | |
| 400 | |
| 401 net::HttpRequestHeaders headers3; | |
| 402 request = CreateRequestByType(content::RESOURCE_TYPE_FAVICON, | |
| 403 false /* https */, lofi_enabled); | |
| 404 lofi_decider->MaybeSetAcceptTransformHeader(*request.get(), false, | |
| 405 &headers3); | |
| 406 VerifyLoFiHeader(true /* empty-image */, false /*if-heavy */, headers3); | |
| 407 | |
| 408 net::HttpRequestHeaders headers4; | |
| 409 request = CreateRequestByType(content::RESOURCE_TYPE_SCRIPT, | |
| 410 false /* https */, lofi_enabled); | |
| 411 lofi_decider->MaybeSetAcceptTransformHeader(*request.get(), false, | |
| 412 &headers4); | |
| 413 VerifyLoFiHeader(false /* empty-image */, false /*if-heavy */, headers4); | |
| 414 | |
| 415 net::HttpRequestHeaders headers5; | |
| 416 request = CreateRequestByType(content::RESOURCE_TYPE_STYLESHEET, | |
| 417 false /* https */, lofi_enabled); | |
| 418 lofi_decider->MaybeSetAcceptTransformHeader(*request.get(), false, | |
| 419 &headers5); | |
| 420 VerifyLoFiHeader(false /* empty-image */, false /*if-heavy */, headers5); | |
| 421 } | |
| 422 } | |
| 423 | |
| 309 TEST_F(ContentLoFiDeciderTest, LoFiEnabledFieldTrial) { | 424 TEST_F(ContentLoFiDeciderTest, LoFiEnabledFieldTrial) { |
| 310 base::FieldTrialList field_trial_list(nullptr); | 425 base::FieldTrialList field_trial_list(nullptr); |
| 311 base::FieldTrialList::CreateFieldTrial(params::GetLoFiFieldTrialName(), | 426 base::FieldTrialList::CreateFieldTrial(params::GetLoFiFieldTrialName(), |
| 312 "Enabled"); | 427 "Enabled"); |
| 313 // Add the Lite Page fallback field trial. Having this enabled when not in the | 428 // Add the Lite Page fallback field trial. Having this enabled when not in the |
| 314 // Enabled_Previews group should not affect how Lo-Fi works. | 429 // Enabled_Previews group should not affect how Lo-Fi works. |
| 315 base::FieldTrialList::CreateFieldTrial( | 430 base::FieldTrialList::CreateFieldTrial( |
| 316 params::GetLitePageFallbackFieldTrialName(), "Enabled"); | 431 params::GetLitePageFallbackFieldTrialName(), "Enabled"); |
| 317 | 432 |
| 318 // Enable Lo-Fi. | 433 // Enable Lo-Fi. |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 396 net::HttpRequestHeaders headers; | 511 net::HttpRequestHeaders headers; |
| 397 NotifyBeforeSendHeaders(&headers, request.get(), true); | 512 NotifyBeforeSendHeaders(&headers, request.get(), true); |
| 398 VerifyLoFiHeader(false, false, headers); | 513 VerifyLoFiHeader(false, false, headers); |
| 399 VerifyLitePageHeader(false, false, headers); | 514 VerifyLitePageHeader(false, false, headers); |
| 400 DataReductionProxyData* data = DataReductionProxyData::GetData(*request); | 515 DataReductionProxyData* data = DataReductionProxyData::GetData(*request); |
| 401 EXPECT_EQ(tests[i].is_using_lofi, data->lofi_requested()) << i; | 516 EXPECT_EQ(tests[i].is_using_lofi, data->lofi_requested()) << i; |
| 402 } | 517 } |
| 403 } | 518 } |
| 404 | 519 |
| 405 TEST_F(ContentLoFiDeciderTest, LitePageFieldTrial) { | 520 TEST_F(ContentLoFiDeciderTest, LitePageFieldTrial) { |
| 521 // Turn off proxy-decides-transform feature for these unit tests. | |
| 522 base::test::ScopedFeatureList scoped_feature_list; | |
| 523 scoped_feature_list.InitAndDisableFeature( | |
| 524 features::kDataReductionProxyDecidesTransform); | |
| 525 | |
| 406 base::FieldTrialList field_trial_list(nullptr); | 526 base::FieldTrialList field_trial_list(nullptr); |
| 407 base::FieldTrialList::CreateFieldTrial(params::GetLoFiFieldTrialName(), | 527 base::FieldTrialList::CreateFieldTrial(params::GetLoFiFieldTrialName(), |
| 408 "Enabled_Preview"); | 528 "Enabled_Preview"); |
| 409 // Enable Lo-Fi. | 529 // Enable Lo-Fi. |
| 410 const struct { | 530 const struct { |
| 411 bool is_using_lite_page; | 531 bool is_using_lite_page; |
| 412 bool is_main_frame; | 532 bool is_main_frame; |
| 413 } tests[] = { | 533 } tests[] = { |
| 414 {false, false}, {true, false}, {false, true}, {true, true}, | 534 {false, false}, {true, false}, {false, true}, {true, true}, |
| 415 }; | 535 }; |
| 416 | 536 |
| 417 for (size_t i = 0; i < arraysize(tests); ++i) { | 537 for (size_t i = 0; i < arraysize(tests); ++i) { |
| 418 std::unique_ptr<net::URLRequest> request = | 538 std::unique_ptr<net::URLRequest> request = |
| 419 CreateRequest(tests[i].is_main_frame, tests[i].is_using_lite_page | 539 CreateRequest(tests[i].is_main_frame, tests[i].is_using_lite_page |
| 420 ? content::SERVER_LITE_PAGE_ON | 540 ? content::SERVER_LITE_PAGE_ON |
| 421 : content::PREVIEWS_OFF); | 541 : content::PREVIEWS_OFF); |
| 422 net::HttpRequestHeaders headers; | 542 net::HttpRequestHeaders headers; |
| 423 NotifyBeforeSendHeaders(&headers, request.get(), true); | 543 NotifyBeforeSendHeaders(&headers, request.get(), true); |
| 424 VerifyLoFiHeader(false, false, headers); | 544 VerifyLoFiHeader(false, false, headers); |
| 425 VerifyLitePageHeader(tests[i].is_main_frame, !tests[i].is_using_lite_page, | 545 VerifyLitePageHeader(tests[i].is_main_frame, !tests[i].is_using_lite_page, |
| 426 headers); | 546 headers); |
| 427 DataReductionProxyData* data = DataReductionProxyData::GetData(*request); | 547 DataReductionProxyData* data = DataReductionProxyData::GetData(*request); |
| 428 EXPECT_EQ(tests[i].is_using_lite_page, data->lofi_requested()) << i; | 548 EXPECT_EQ(tests[i].is_using_lite_page, data->lofi_requested()) << i; |
| 429 } | 549 } |
| 430 } | 550 } |
| 431 | 551 |
| 432 TEST_F(ContentLoFiDeciderTest, LitePageFieldTrialFallbackEnabled) { | 552 TEST_F(ContentLoFiDeciderTest, LitePageFieldTrialFallbackEnabled) { |
| 553 // Turn off proxy-decides-transform feature for these unit tests. | |
| 554 base::test::ScopedFeatureList scoped_feature_list; | |
| 555 scoped_feature_list.InitAndDisableFeature( | |
| 556 features::kDataReductionProxyDecidesTransform); | |
| 557 | |
| 433 base::FieldTrialList field_trial_list(nullptr); | 558 base::FieldTrialList field_trial_list(nullptr); |
| 434 base::FieldTrialList::CreateFieldTrial(params::GetLoFiFieldTrialName(), | 559 base::FieldTrialList::CreateFieldTrial(params::GetLoFiFieldTrialName(), |
| 435 "Enabled_Preview"); | 560 "Enabled_Preview"); |
| 436 base::FieldTrialList::CreateFieldTrial( | 561 base::FieldTrialList::CreateFieldTrial( |
| 437 params::GetLitePageFallbackFieldTrialName(), "Enabled"); | 562 params::GetLitePageFallbackFieldTrialName(), "Enabled"); |
| 438 | 563 |
| 439 // Enable Lo-Fi. | 564 // Enable Lo-Fi. |
| 440 const struct { | 565 const struct { |
| 441 bool is_using_lofi; | 566 bool is_using_lofi; |
| 442 bool is_using_lite_page; | 567 bool is_using_lite_page; |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 468 tests[i].is_main_frame && !tests[i].is_using_lite_page, | 593 tests[i].is_main_frame && !tests[i].is_using_lite_page, |
| 469 headers); | 594 headers); |
| 470 DataReductionProxyData* data = DataReductionProxyData::GetData(*request); | 595 DataReductionProxyData* data = DataReductionProxyData::GetData(*request); |
| 471 EXPECT_EQ(tests[i].is_using_lofi || tests[i].is_using_lite_page, | 596 EXPECT_EQ(tests[i].is_using_lofi || tests[i].is_using_lite_page, |
| 472 data->lofi_requested()) | 597 data->lofi_requested()) |
| 473 << i; | 598 << i; |
| 474 } | 599 } |
| 475 } | 600 } |
| 476 | 601 |
| 477 TEST_F(ContentLoFiDeciderTest, LitePageFieldTrialFallbackDisabled) { | 602 TEST_F(ContentLoFiDeciderTest, LitePageFieldTrialFallbackDisabled) { |
| 603 // Turn off proxy-decides-transform feature for these unit tests. | |
| 604 base::test::ScopedFeatureList scoped_feature_list; | |
| 605 scoped_feature_list.InitAndDisableFeature( | |
| 606 features::kDataReductionProxyDecidesTransform); | |
| 607 | |
| 478 base::FieldTrialList field_trial_list(nullptr); | 608 base::FieldTrialList field_trial_list(nullptr); |
| 479 base::FieldTrialList::CreateFieldTrial(params::GetLoFiFieldTrialName(), | 609 base::FieldTrialList::CreateFieldTrial(params::GetLoFiFieldTrialName(), |
| 480 "Enabled_Preview"); | 610 "Enabled_Preview"); |
| 481 // Enable Lo-Fi. | 611 // Enable Lo-Fi. |
| 482 const struct { | 612 const struct { |
| 483 bool is_using_lofi; | 613 bool is_using_lofi; |
| 484 bool is_using_lite_page; | 614 bool is_using_lite_page; |
| 485 bool is_main_frame; | 615 bool is_main_frame; |
| 486 } tests[] = { | 616 } tests[] = { |
| 487 {false, false, false}, {false, false, true}, {true, false, true}, | 617 {false, false, false}, {false, false, true}, {true, false, true}, |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 507 tests[i].is_main_frame && !tests[i].is_using_lite_page, | 637 tests[i].is_main_frame && !tests[i].is_using_lite_page, |
| 508 headers); | 638 headers); |
| 509 DataReductionProxyData* data = DataReductionProxyData::GetData(*request); | 639 DataReductionProxyData* data = DataReductionProxyData::GetData(*request); |
| 510 EXPECT_EQ(tests[i].is_using_lofi || tests[i].is_using_lite_page, | 640 EXPECT_EQ(tests[i].is_using_lofi || tests[i].is_using_lite_page, |
| 511 data->lofi_requested()) | 641 data->lofi_requested()) |
| 512 << i; | 642 << i; |
| 513 } | 643 } |
| 514 } | 644 } |
| 515 | 645 |
| 516 TEST_F(ContentLoFiDeciderTest, AutoLoFi) { | 646 TEST_F(ContentLoFiDeciderTest, AutoLoFi) { |
| 647 // Turn off proxy-decides-transform feature for these unit tests. | |
| 648 base::test::ScopedFeatureList scoped_feature_list; | |
| 649 scoped_feature_list.InitAndDisableFeature( | |
| 650 features::kDataReductionProxyDecidesTransform); | |
| 651 | |
| 517 const struct { | 652 const struct { |
| 518 bool auto_lofi_enabled_group; | 653 bool auto_lofi_enabled_group; |
| 519 bool auto_lofi_control_group; | 654 bool auto_lofi_control_group; |
| 520 bool network_prohibitively_slow; | 655 bool network_prohibitively_slow; |
| 521 bool is_main_frame; | 656 bool is_main_frame; |
| 522 } tests[] = { | 657 } tests[] = { |
| 523 {false, false, false, false}, | 658 {false, false, false, false}, |
| 524 {false, false, true, false}, | 659 {false, false, true, false}, |
| 525 {true, false, false, false}, | 660 {true, false, false, false}, |
| 526 {true, false, true, false}, | 661 {true, false, true, false}, |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 555 tests[i].is_main_frame, tests[i].network_prohibitively_slow); | 690 tests[i].is_main_frame, tests[i].network_prohibitively_slow); |
| 556 net::HttpRequestHeaders headers; | 691 net::HttpRequestHeaders headers; |
| 557 NotifyBeforeSendHeaders(&headers, request.get(), true); | 692 NotifyBeforeSendHeaders(&headers, request.get(), true); |
| 558 | 693 |
| 559 VerifyLoFiHeader(expect_lofi_header, !tests[i].network_prohibitively_slow, | 694 VerifyLoFiHeader(expect_lofi_header, !tests[i].network_prohibitively_slow, |
| 560 headers); | 695 headers); |
| 561 } | 696 } |
| 562 } | 697 } |
| 563 | 698 |
| 564 TEST_F(ContentLoFiDeciderTest, SlowConnectionsFlag) { | 699 TEST_F(ContentLoFiDeciderTest, SlowConnectionsFlag) { |
| 700 // Turn off proxy-decides-transform feature for these unit tests. | |
| 701 base::test::ScopedFeatureList scoped_feature_list; | |
| 702 scoped_feature_list.InitAndDisableFeature( | |
| 703 features::kDataReductionProxyDecidesTransform); | |
| 704 | |
| 565 const struct { | 705 const struct { |
| 566 bool slow_connections_flag_enabled; | 706 bool slow_connections_flag_enabled; |
| 567 bool network_prohibitively_slow; | 707 bool network_prohibitively_slow; |
| 568 bool auto_lofi_enabled_group; | 708 bool auto_lofi_enabled_group; |
| 569 bool is_main_frame; | 709 bool is_main_frame; |
| 570 } tests[] = { | 710 } tests[] = { |
| 571 {false, false, false, false}, {false, true, false, false}, | 711 {false, false, false, false}, {false, true, false, false}, |
| 572 {true, false, false, false}, {true, true, false, false}, | 712 {true, false, false, false}, {true, true, false, false}, |
| 573 {true, true, false, true}, {false, false, true, false}, | 713 {true, true, false, true}, {false, false, true, false}, |
| 574 {false, false, true, true}, {false, true, true, false}, | 714 {false, false, true, true}, {false, true, true, false}, |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 782 content::CLIENT_LOFI_AUTO_RELOAD))); | 922 content::CLIENT_LOFI_AUTO_RELOAD))); |
| 783 | 923 |
| 784 // IsClientLoFiAutoReloadRequest() should return false for any request without | 924 // IsClientLoFiAutoReloadRequest() should return false for any request without |
| 785 // the CLIENT_LOFI_AUTO_RELOAD bit set. | 925 // the CLIENT_LOFI_AUTO_RELOAD bit set. |
| 786 EXPECT_FALSE(ContentLoFiDecider().IsClientLoFiAutoReloadRequest( | 926 EXPECT_FALSE(ContentLoFiDecider().IsClientLoFiAutoReloadRequest( |
| 787 *CreateRequestByType(content::RESOURCE_TYPE_IMAGE, false, | 927 *CreateRequestByType(content::RESOURCE_TYPE_IMAGE, false, |
| 788 content::PREVIEWS_NO_TRANSFORM))); | 928 content::PREVIEWS_NO_TRANSFORM))); |
| 789 } | 929 } |
| 790 | 930 |
| 791 } // namespace data_reduction_proxy | 931 } // namespace data_reduction_proxy |
| OLD | NEW |