Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(523)

Unified Diff: chrome/browser/previews/previews_infobar_tab_helper_unittest.cc

Issue 2833523002: Adding opt out and previews type information to DRP pingback (Closed)
Patch Set: moved definition up Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/previews/previews_infobar_tab_helper_unittest.cc
diff --git a/chrome/browser/previews/previews_infobar_tab_helper_unittest.cc b/chrome/browser/previews/previews_infobar_tab_helper_unittest.cc
index 9d2a3a00f2e98600e14ebd60c8690424b979312a..70a7a557dae3e9ab0a75fd6158b130e7565bea90 100644
--- a/chrome/browser/previews/previews_infobar_tab_helper_unittest.cc
+++ b/chrome/browser/previews/previews_infobar_tab_helper_unittest.cc
@@ -8,6 +8,7 @@
#include <string>
#include "base/memory/ptr_util.h"
+#include "base/run_loop.h"
#include "base/strings/stringprintf.h"
#include "base/threading/thread_task_runner_handle.h"
#include "chrome/browser/infobars/infobar_service.h"
@@ -15,6 +16,9 @@
#include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings_factory.h"
#include "chrome/browser/previews/previews_infobar_tab_helper.h"
#include "chrome/test/base/chrome_render_view_host_test_harness.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_headers.h"
#include "components/data_reduction_proxy/core/common/data_reduction_proxy_pref_names.h"
@@ -122,6 +126,36 @@ TEST_F(PreviewsInfoBarTabHelperUnitTest, CreateLitePageInfoBar) {
EXPECT_FALSE(infobar_tab_helper->displayed_preview_infobar());
}
+TEST_F(PreviewsInfoBarTabHelperUnitTest, PingbackClientCleared) {
+ auto* data_reduction_proxy_settings =
+ DataReductionProxyChromeSettingsFactory::GetForBrowserContext(
+ web_contents()->GetBrowserContext());
+
+ EXPECT_EQ(0u, data_reduction_proxy_settings->data_reduction_proxy_service()
+ ->pingback_client()
+ ->PendingTabLoadsForTesting());
+
+ data_reduction_proxy_settings->data_reduction_proxy_service()
+ ->pingback_client()
+ ->AddOptOut(web_contents(), 0u);
+
+ EXPECT_EQ(1u, data_reduction_proxy_settings->data_reduction_proxy_service()
+ ->pingback_client()
+ ->PendingTabLoadsForTesting());
+ CallDidFinishNavigation();
+ SetContents(nullptr);
+
+ EXPECT_EQ(1u, data_reduction_proxy_settings->data_reduction_proxy_service()
+ ->pingback_client()
+ ->PendingTabLoadsForTesting());
+
+ base::RunLoop().RunUntilIdle();
+
+ EXPECT_EQ(0u, data_reduction_proxy_settings->data_reduction_proxy_service()
+ ->pingback_client()
+ ->PendingTabLoadsForTesting());
+}
+
#if defined(OS_ANDROID)
TEST_F(PreviewsInfoBarTabHelperUnitTest, CreateOfflineInfoBar) {
PreviewsInfoBarTabHelper* infobar_tab_helper =

Powered by Google App Engine
This is Rietveld 408576698