| Index: chrome/browser/previews/previews_infobar_delegate_unittest.cc
|
| diff --git a/chrome/browser/previews/previews_infobar_delegate_unittest.cc b/chrome/browser/previews/previews_infobar_delegate_unittest.cc
|
| index 15fad9d5523ccf7dd3ed7211342c53ba06081613..a21a52d39385258b3e2f59a88d71f52f2e18d270 100644
|
| --- a/chrome/browser/previews/previews_infobar_delegate_unittest.cc
|
| +++ b/chrome/browser/previews/previews_infobar_delegate_unittest.cc
|
| @@ -10,6 +10,7 @@
|
| #include "base/bind.h"
|
| #include "base/bind_helpers.h"
|
| #include "base/memory/ptr_util.h"
|
| +#include "base/metrics/field_trial.h"
|
| #include "base/optional.h"
|
| #include "base/test/histogram_tester.h"
|
| #include "base/threading/thread_task_runner_handle.h"
|
| @@ -21,6 +22,7 @@
|
| #include "chrome/browser/previews/previews_infobar_tab_helper.h"
|
| #include "chrome/grit/generated_resources.h"
|
| #include "chrome/test/base/chrome_render_view_host_test_harness.h"
|
| +#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_config_test_utils.h"
|
| #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_data.h"
|
| #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_pingback_client.h"
|
| #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_service.h"
|
| @@ -34,6 +36,7 @@
|
| #include "components/proxy_config/proxy_config_pref_names.h"
|
| #include "content/public/browser/navigation_entry.h"
|
| #include "content/public/browser/navigation_handle.h"
|
| +#include "content/public/browser/reload_type.h"
|
| #include "content/public/browser/web_contents.h"
|
| #include "content/public/browser/web_contents_observer.h"
|
| #include "content/public/browser/web_contents_user_data.h"
|
| @@ -267,32 +270,47 @@ TEST_F(PreviewsInfoBarDelegateUnitTest, InfobarTestTabClosedDismissal) {
|
| }
|
|
|
| TEST_F(PreviewsInfoBarDelegateUnitTest, InfobarTestClickLinkLoFi) {
|
| - base::HistogramTester tester;
|
| -
|
| NavigateAndCommit(GURL(kTestUrl));
|
| + const struct {
|
| + bool using_previews_blacklist;
|
| + } tests[] = {
|
| + {true}, {false},
|
| + };
|
| + for (const auto test : tests) {
|
| + drp_test_context_->config()->ResetLoFiStatusForTest();
|
| + base::FieldTrialList field_trial_list(nullptr);
|
| + if (test.using_previews_blacklist) {
|
| + base::FieldTrialList::CreateFieldTrial(
|
| + "DataReductionProxyPreviewsBlackListTransition", "Enabled_");
|
| + }
|
| + base::HistogramTester tester;
|
| + // Call Reload and CommitPendingNavigation to force DidFinishNavigation.
|
| + web_contents()->GetController().Reload(content::ReloadType::NORMAL, true);
|
| + content::WebContentsTester::For(web_contents())->CommitPendingNavigation();
|
| +
|
| + ConfirmInfoBarDelegate* infobar = CreateInfoBar(
|
| + PreviewsInfoBarDelegate::LOFI, true /* is_data_saver_user */);
|
| +
|
| + // Simulate clicking the infobar link.
|
| + if (infobar->LinkClicked(WindowOpenDisposition::CURRENT_TAB))
|
| + infobar_service()->infobar_at(0)->RemoveSelf();
|
| + EXPECT_EQ(0U, infobar_service()->infobar_count());
|
| +
|
| + tester.ExpectBucketCount(
|
| + kUMAPreviewsInfoBarActionLoFi,
|
| + PreviewsInfoBarDelegate::INFOBAR_LOAD_ORIGINAL_CLICKED, 1);
|
| + EXPECT_EQ(test.using_previews_blacklist ? 0 : 1,
|
| + drp_test_context_->pref_service()->GetInteger(
|
| + data_reduction_proxy::prefs::kLoFiLoadImagesPerSession));
|
| + EXPECT_TRUE(user_opt_out_.value());
|
|
|
| - ConfirmInfoBarDelegate* infobar = CreateInfoBar(
|
| - PreviewsInfoBarDelegate::LOFI, true /* is_data_saver_user */);
|
| -
|
| - // Simulate clicking the infobar link.
|
| - if (infobar->LinkClicked(WindowOpenDisposition::CURRENT_TAB))
|
| - infobar_service()->infobar_at(0)->RemoveSelf();
|
| - EXPECT_EQ(0U, infobar_service()->infobar_count());
|
| -
|
| - tester.ExpectBucketCount(
|
| - kUMAPreviewsInfoBarActionLoFi,
|
| - PreviewsInfoBarDelegate::INFOBAR_LOAD_ORIGINAL_CLICKED, 1);
|
| - EXPECT_EQ(1, drp_test_context_->pref_service()->GetInteger(
|
| - data_reduction_proxy::prefs::kLoFiLoadImagesPerSession));
|
| - EXPECT_TRUE(user_opt_out_.value());
|
| -
|
| - auto* data_reduction_proxy_settings =
|
| - DataReductionProxyChromeSettingsFactory::GetForBrowserContext(
|
| - web_contents()->GetBrowserContext());
|
| -
|
| - EXPECT_EQ(1u, data_reduction_proxy_settings->data_reduction_proxy_service()
|
| - ->pingback_client()
|
| - ->OptOutsSizeForTesting());
|
| + auto* data_reduction_proxy_settings =
|
| + DataReductionProxyChromeSettingsFactory::GetForBrowserContext(
|
| + web_contents()->GetBrowserContext());
|
| + EXPECT_EQ(1u, data_reduction_proxy_settings->data_reduction_proxy_service()
|
| + ->pingback_client()
|
| + ->OptOutsSizeForTesting());
|
| + }
|
| }
|
|
|
| TEST_F(PreviewsInfoBarDelegateUnitTest, InfobarTestClickLinkLitePage) {
|
|
|