| 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 dfcc45d39d0c6637904d2fed6362d69c31652c13..734d897eed005312b791ab5e8a49479316c312c2 100644
|
| --- a/chrome/browser/previews/previews_infobar_delegate_unittest.cc
|
| +++ b/chrome/browser/previews/previews_infobar_delegate_unittest.cc
|
| @@ -15,11 +15,16 @@
|
| #include "base/threading/thread_task_runner_handle.h"
|
| #include "chrome/browser/android/android_theme_resources.h"
|
| #include "chrome/browser/infobars/infobar_service.h"
|
| +#include "chrome/browser/loader/chrome_navigation_data.h"
|
| #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h"
|
| #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings_factory.h"
|
| #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_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"
|
| +#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_settings.h"
|
| #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_test_utils.h"
|
| #include "components/data_reduction_proxy/core/common/data_reduction_proxy_pref_names.h"
|
| #include "components/infobars/core/confirm_infobar_delegate.h"
|
| @@ -67,6 +72,19 @@ class TestPreviewsWebContentsObserver
|
| return last_navigation_reload_type_;
|
| }
|
|
|
| + void DidStartNavigation(
|
| + content::NavigationHandle* navigation_handle) override {
|
| + ChromeNavigationData* chrome_navigation_data = new ChromeNavigationData();
|
| + content::WebContentsTester::For(web_contents())
|
| + ->SetNavigationData(navigation_handle,
|
| + base::WrapUnique(chrome_navigation_data));
|
| + data_reduction_proxy::DataReductionProxyData* data =
|
| + new data_reduction_proxy::DataReductionProxyData();
|
| + chrome_navigation_data->SetDataReductionProxyData(base::WrapUnique(data));
|
| + data->set_used_data_reduction_proxy(true);
|
| + data->set_page_id(1u);
|
| + }
|
| +
|
| void DidFinishNavigation(
|
| content::NavigationHandle* navigation_handle) override {
|
| last_navigation_reload_type_ = navigation_handle->GetReloadType();
|
| @@ -202,6 +220,14 @@ TEST_F(PreviewsInfoBarDelegateUnitTest, InfobarTestReloadDismissal) {
|
| 1);
|
| EXPECT_EQ(0, drp_test_context_->pref_service()->GetInteger(
|
| data_reduction_proxy::prefs::kLoFiLoadImagesPerSession));
|
| +
|
| + auto* data_reduction_proxy_settings =
|
| + DataReductionProxyChromeSettingsFactory::GetForBrowserContext(
|
| + web_contents()->GetBrowserContext());
|
| +
|
| + EXPECT_EQ(0u, data_reduction_proxy_settings->data_reduction_proxy_service()
|
| + ->pingback_client()
|
| + ->PendingTabLoadsForTesting());
|
| }
|
|
|
| TEST_F(PreviewsInfoBarDelegateUnitTest, InfobarTestUserDismissal) {
|
| @@ -226,6 +252,8 @@ TEST_F(PreviewsInfoBarDelegateUnitTest, InfobarTestUserDismissal) {
|
| TEST_F(PreviewsInfoBarDelegateUnitTest, InfobarTestClickLinkLoFi) {
|
| base::HistogramTester tester;
|
|
|
| + NavigateAndCommit(GURL(kTestUrl));
|
| +
|
| ConfirmInfoBarDelegate* infobar = CreateInfoBar(
|
| PreviewsInfoBarDelegate::LOFI, true /* is_data_saver_user */);
|
|
|
| @@ -240,6 +268,14 @@ TEST_F(PreviewsInfoBarDelegateUnitTest, InfobarTestClickLinkLoFi) {
|
| 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()
|
| + ->PendingTabLoadsForTesting());
|
| }
|
|
|
| TEST_F(PreviewsInfoBarDelegateUnitTest, InfobarTestClickLinkLitePage) {
|
| @@ -264,6 +300,14 @@ TEST_F(PreviewsInfoBarDelegateUnitTest, InfobarTestClickLinkLitePage) {
|
| EXPECT_EQ(content::ReloadType::DISABLE_LOFI_MODE,
|
| TestPreviewsWebContentsObserver::FromWebContents(web_contents())
|
| ->last_navigation_reload_type());
|
| +
|
| + auto* data_reduction_proxy_settings =
|
| + DataReductionProxyChromeSettingsFactory::GetForBrowserContext(
|
| + web_contents()->GetBrowserContext());
|
| +
|
| + EXPECT_EQ(1u, data_reduction_proxy_settings->data_reduction_proxy_service()
|
| + ->pingback_client()
|
| + ->PendingTabLoadsForTesting());
|
| }
|
|
|
| TEST_F(PreviewsInfoBarDelegateUnitTest, InfobarTestShownOncePerNavigation) {
|
| @@ -404,4 +448,12 @@ TEST_F(PreviewsInfoBarDelegateUnitTest, OfflineInfobarDisablesLoFi) {
|
| EXPECT_EQ(content::ReloadType::DISABLE_LOFI_MODE,
|
| TestPreviewsWebContentsObserver::FromWebContents(web_contents())
|
| ->last_navigation_reload_type());
|
| +
|
| + auto* data_reduction_proxy_settings =
|
| + DataReductionProxyChromeSettingsFactory::GetForBrowserContext(
|
| + web_contents()->GetBrowserContext());
|
| +
|
| + EXPECT_EQ(0u, data_reduction_proxy_settings->data_reduction_proxy_service()
|
| + ->pingback_client()
|
| + ->PendingTabLoadsForTesting());
|
| }
|
|
|