Chromium Code Reviews| 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..e011bfc755aa2f1a9e8fcf2f0cf99c995bf0814c 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" |
| @@ -295,6 +296,40 @@ TEST_F(PreviewsInfoBarDelegateUnitTest, InfobarTestClickLinkLoFi) { |
| ->OptOutsSizeForTesting()); |
| } |
| +TEST_F(PreviewsInfoBarDelegateUnitTest, |
| + InfobarTestClickLinkLoFiBlackListExperiment) { |
|
megjablon
2017/05/09 19:58:33
Instead of duplicating all this code can we just a
RyanSturm
2017/05/09 22:35:18
Done.
RyanSturm
2017/05/10 16:01:45
NavigateAndCommit doesn't really do the right thin
|
| + base::HistogramTester tester; |
| + |
| + base::FieldTrialList field_trial_list(nullptr); |
| + base::FieldTrialList::CreateFieldTrial( |
| + "DataReductionProxyPreviewsBlacklistTransition", "Enabled_"); |
| + |
| + NavigateAndCommit(GURL(kTestUrl)); |
| + |
| + 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(0, 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()); |
| +} |
| + |
| TEST_F(PreviewsInfoBarDelegateUnitTest, InfobarTestClickLinkLitePage) { |
| base::HistogramTester tester; |