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

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

Issue 2875993002: Converging the two previews type enums (Closed)
Patch Set: megjablon nit Created 3 years, 7 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_delegate_unittest.cc
diff --git a/chrome/browser/previews/previews_infobar_delegate_unittest.cc b/chrome/browser/previews/previews_infobar_delegate_unittest.cc
index a21a52d39385258b3e2f59a88d71f52f2e18d270..d18bee15841fef558567358cf141515c517c853c 100644
--- a/chrome/browser/previews/previews_infobar_delegate_unittest.cc
+++ b/chrome/browser/previews/previews_infobar_delegate_unittest.cc
@@ -33,6 +33,7 @@
#include "components/infobars/core/infobar.h"
#include "components/infobars/core/infobar_delegate.h"
#include "components/prefs/pref_registry_simple.h"
+#include "components/previews/core/previews_experiments.h"
#include "components/proxy_config/proxy_config_pref_names.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/navigation_handle.h"
@@ -68,7 +69,8 @@ class TestPreviewsWebContentsObserver
public:
explicit TestPreviewsWebContentsObserver(content::WebContents* web_contents)
: content::WebContentsObserver(web_contents),
- last_navigation_reload_type_(content::ReloadType::NONE) {}
+ last_navigation_reload_type_(content::ReloadType::NONE),
+ should_have_page_id_(true) {}
~TestPreviewsWebContentsObserver() override {}
content::ReloadType last_navigation_reload_type() {
@@ -85,7 +87,8 @@ class TestPreviewsWebContentsObserver
new data_reduction_proxy::DataReductionProxyData();
chrome_navigation_data->SetDataReductionProxyData(base::WrapUnique(data));
data->set_used_data_reduction_proxy(true);
- data->set_page_id(1u);
+ if (should_have_page_id_)
+ data->set_page_id(1u);
}
void DidFinishNavigation(
@@ -93,8 +96,13 @@ class TestPreviewsWebContentsObserver
last_navigation_reload_type_ = navigation_handle->GetReloadType();
}
+ void set_should_have_page_id(bool should_have_page_id) {
+ should_have_page_id_ = should_have_page_id;
+ }
+
private:
content::ReloadType last_navigation_reload_type_;
+ bool should_have_page_id_;
};
} // namespace
@@ -138,9 +146,8 @@ class PreviewsInfoBarDelegateUnitTest : public ChromeRenderViewHostTestHarness {
ChromeRenderViewHostTestHarness::TearDown();
}
- ConfirmInfoBarDelegate* CreateInfoBar(
- PreviewsInfoBarDelegate::PreviewsInfoBarType type,
- bool is_data_saver_user) {
+ ConfirmInfoBarDelegate* CreateInfoBar(previews::PreviewsType type,
+ bool is_data_saver_user) {
PreviewsInfoBarDelegate::Create(
web_contents(), type, is_data_saver_user,
base::Bind(&PreviewsInfoBarDelegateUnitTest::OnDismissPreviewsInfobar,
@@ -172,12 +179,12 @@ class PreviewsInfoBarDelegateUnitTest : public ChromeRenderViewHostTestHarness {
TEST_F(PreviewsInfoBarDelegateUnitTest, InfobarTestNavigationDismissal) {
base::HistogramTester tester;
- CreateInfoBar(PreviewsInfoBarDelegate::LOFI, true /* is_data_saver_user */);
+ CreateInfoBar(previews::PreviewsType::LOFI, true /* is_data_saver_user */);
// Try showing a second infobar. Another should not be shown since the page
// has not navigated.
PreviewsInfoBarDelegate::Create(
- web_contents(), PreviewsInfoBarDelegate::LOFI,
+ web_contents(), previews::PreviewsType::LOFI,
true /* is_data_saver_user */,
PreviewsInfoBarDelegate::OnDismissPreviewsInfobarCallback());
EXPECT_EQ(1U, infobar_service()->infobar_count());
@@ -200,12 +207,12 @@ TEST_F(PreviewsInfoBarDelegateUnitTest, InfobarTestReloadDismissal) {
// Navigate to test URL, so we can reload later.
NavigateAndCommit(GURL(kTestUrl));
- CreateInfoBar(PreviewsInfoBarDelegate::LOFI, true /* is_data_saver_user */);
+ CreateInfoBar(previews::PreviewsType::LOFI, true /* is_data_saver_user */);
// Try showing a second infobar. Another should not be shown since the page
// has not navigated.
PreviewsInfoBarDelegate::Create(
- web_contents(), PreviewsInfoBarDelegate::LOFI,
+ web_contents(), previews::PreviewsType::LOFI,
true /* is_data_saver_user */,
PreviewsInfoBarDelegate::OnDismissPreviewsInfobarCallback());
EXPECT_EQ(1U, infobar_service()->infobar_count());
@@ -237,7 +244,7 @@ TEST_F(PreviewsInfoBarDelegateUnitTest, InfobarTestUserDismissal) {
base::HistogramTester tester;
ConfirmInfoBarDelegate* infobar = CreateInfoBar(
- PreviewsInfoBarDelegate::LOFI, true /* is_data_saver_user */);
+ previews::PreviewsType::LOFI, true /* is_data_saver_user */);
// Simulate dismissing the infobar.
infobar->InfoBarDismissed();
@@ -255,7 +262,7 @@ TEST_F(PreviewsInfoBarDelegateUnitTest, InfobarTestUserDismissal) {
TEST_F(PreviewsInfoBarDelegateUnitTest, InfobarTestTabClosedDismissal) {
base::HistogramTester tester;
- CreateInfoBar(PreviewsInfoBarDelegate::LOFI, true /* is_data_saver_user */);
+ CreateInfoBar(previews::PreviewsType::LOFI, true /* is_data_saver_user */);
// Delete the infobar without any other infobar actions.
infobar_service()->infobar_at(0)->RemoveSelf();
@@ -289,7 +296,7 @@ TEST_F(PreviewsInfoBarDelegateUnitTest, InfobarTestClickLinkLoFi) {
content::WebContentsTester::For(web_contents())->CommitPendingNavigation();
ConfirmInfoBarDelegate* infobar = CreateInfoBar(
- PreviewsInfoBarDelegate::LOFI, true /* is_data_saver_user */);
+ previews::PreviewsType::LOFI, true /* is_data_saver_user */);
// Simulate clicking the infobar link.
if (infobar->LinkClicked(WindowOpenDisposition::CURRENT_TAB))
@@ -319,7 +326,7 @@ TEST_F(PreviewsInfoBarDelegateUnitTest, InfobarTestClickLinkLitePage) {
NavigateAndCommit(GURL(kTestUrl));
ConfirmInfoBarDelegate* infobar = CreateInfoBar(
- PreviewsInfoBarDelegate::LITE_PAGE, true /* is_data_saver_user */);
+ previews::PreviewsType::LITE_PAGE, true /* is_data_saver_user */);
// Simulate clicking the infobar link.
if (infobar->LinkClicked(WindowOpenDisposition::CURRENT_TAB))
@@ -347,7 +354,7 @@ TEST_F(PreviewsInfoBarDelegateUnitTest, InfobarTestClickLinkLitePage) {
TEST_F(PreviewsInfoBarDelegateUnitTest, InfobarTestShownOncePerNavigation) {
ConfirmInfoBarDelegate* infobar = CreateInfoBar(
- PreviewsInfoBarDelegate::LOFI, true /* is_data_saver_user */);
+ previews::PreviewsType::LOFI, true /* is_data_saver_user */);
// Simulate dismissing the infobar.
infobar->InfoBarDismissed();
@@ -355,7 +362,7 @@ TEST_F(PreviewsInfoBarDelegateUnitTest, InfobarTestShownOncePerNavigation) {
EXPECT_EQ(0U, infobar_service()->infobar_count());
PreviewsInfoBarDelegate::Create(
- web_contents(), PreviewsInfoBarDelegate::LOFI,
+ web_contents(), previews::PreviewsType::LOFI,
true /* is_data_saver_user */,
PreviewsInfoBarDelegate::OnDismissPreviewsInfobarCallback());
@@ -364,14 +371,14 @@ TEST_F(PreviewsInfoBarDelegateUnitTest, InfobarTestShownOncePerNavigation) {
// Navigate and show infobar again.
NavigateAndCommit(GURL(kTestUrl));
- CreateInfoBar(PreviewsInfoBarDelegate::LOFI, true /* is_data_saver_user */);
+ CreateInfoBar(previews::PreviewsType::LOFI, true /* is_data_saver_user */);
}
TEST_F(PreviewsInfoBarDelegateUnitTest, LoFiInfobarTest) {
base::HistogramTester tester;
ConfirmInfoBarDelegate* infobar = CreateInfoBar(
- PreviewsInfoBarDelegate::LOFI, true /* is_data_saver_user */);
+ previews::PreviewsType::LOFI, true /* is_data_saver_user */);
tester.ExpectUniqueSample(kUMAPreviewsInfoBarActionLoFi,
PreviewsInfoBarDelegate::INFOBAR_SHOWN, 1);
@@ -394,7 +401,7 @@ TEST_F(PreviewsInfoBarDelegateUnitTest, PreviewInfobarTest) {
base::HistogramTester tester;
ConfirmInfoBarDelegate* infobar = CreateInfoBar(
- PreviewsInfoBarDelegate::LITE_PAGE, true /* is_data_saver_user */);
+ previews::PreviewsType::LITE_PAGE, true /* is_data_saver_user */);
tester.ExpectUniqueSample(kUMAPreviewsInfoBarActionLitePage,
PreviewsInfoBarDelegate::INFOBAR_SHOWN, 1);
@@ -418,7 +425,7 @@ TEST_F(PreviewsInfoBarDelegateUnitTest, OfflineInfobarNonDataSaverUserTest) {
base::HistogramTester tester;
ConfirmInfoBarDelegate* infobar = CreateInfoBar(
- PreviewsInfoBarDelegate::OFFLINE, false /* is_data_saver_user */);
+ previews::PreviewsType::OFFLINE, false /* is_data_saver_user */);
tester.ExpectUniqueSample(kUMAPreviewsInfoBarActionOffline,
PreviewsInfoBarDelegate::INFOBAR_SHOWN, 1);
@@ -442,7 +449,7 @@ TEST_F(PreviewsInfoBarDelegateUnitTest, OfflineInfobarDataSaverUserTest) {
base::HistogramTester tester;
ConfirmInfoBarDelegate* infobar = CreateInfoBar(
- PreviewsInfoBarDelegate::OFFLINE, true /* is_data_saver_user */);
+ previews::PreviewsType::OFFLINE, true /* is_data_saver_user */);
tester.ExpectUniqueSample(kUMAPreviewsInfoBarActionOffline,
PreviewsInfoBarDelegate::INFOBAR_SHOWN, 1);
@@ -465,10 +472,13 @@ TEST_F(PreviewsInfoBarDelegateUnitTest, OfflineInfobarDataSaverUserTest) {
TEST_F(PreviewsInfoBarDelegateUnitTest, OfflineInfobarDisablesLoFi) {
base::HistogramTester tester;
+ TestPreviewsWebContentsObserver::FromWebContents(web_contents())
+ ->set_should_have_page_id(false);
+
NavigateAndCommit(GURL(kTestUrl));
ConfirmInfoBarDelegate* infobar = CreateInfoBar(
- PreviewsInfoBarDelegate::OFFLINE, true /* is_data_saver_user */);
+ previews::PreviewsType::OFFLINE, true /* is_data_saver_user */);
tester.ExpectUniqueSample(kUMAPreviewsInfoBarActionOffline,
PreviewsInfoBarDelegate::INFOBAR_SHOWN, 1);
@@ -499,7 +509,7 @@ TEST_F(PreviewsInfoBarDelegateUnitTest, PingbackClientClearedTabClosed) {
NavigateAndCommit(GURL(kTestUrl));
ConfirmInfoBarDelegate* infobar = CreateInfoBar(
- PreviewsInfoBarDelegate::LITE_PAGE, true /* is_data_saver_user */);
+ previews::PreviewsType::LITE_PAGE, true /* is_data_saver_user */);
// Simulate clicking the infobar link.
if (infobar->LinkClicked(WindowOpenDisposition::CURRENT_TAB))
« no previous file with comments | « chrome/browser/previews/previews_infobar_delegate.cc ('k') | chrome/browser/previews/previews_infobar_tab_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698