| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/previews/previews_infobar_delegate.h" | 5 #include "chrome/browser/previews/previews_infobar_delegate.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 EXPECT_EQ(0U, infobar_service()->infobar_count()); | 216 EXPECT_EQ(0U, infobar_service()->infobar_count()); |
| 217 | 217 |
| 218 tester.ExpectBucketCount(kUMAPreviewsInfoBarActionLoFi, | 218 tester.ExpectBucketCount(kUMAPreviewsInfoBarActionLoFi, |
| 219 PreviewsInfoBarDelegate::INFOBAR_DISMISSED_BY_USER, | 219 PreviewsInfoBarDelegate::INFOBAR_DISMISSED_BY_USER, |
| 220 1); | 220 1); |
| 221 EXPECT_EQ(0, drp_test_context_->pref_service()->GetInteger( | 221 EXPECT_EQ(0, drp_test_context_->pref_service()->GetInteger( |
| 222 data_reduction_proxy::prefs::kLoFiLoadImagesPerSession)); | 222 data_reduction_proxy::prefs::kLoFiLoadImagesPerSession)); |
| 223 EXPECT_FALSE(user_opt_out_.value()); | 223 EXPECT_FALSE(user_opt_out_.value()); |
| 224 } | 224 } |
| 225 | 225 |
| 226 TEST_F(PreviewsInfoBarDelegateUnitTest, InfobarTestTabClosedDismissal) { |
| 227 base::HistogramTester tester; |
| 228 |
| 229 CreateInfoBar(PreviewsInfoBarDelegate::LOFI, true /* is_data_saver_user */); |
| 230 |
| 231 // Delete the infobar without any other infobar actions. |
| 232 infobar_service()->infobar_at(0)->RemoveSelf(); |
| 233 EXPECT_EQ(0U, infobar_service()->infobar_count()); |
| 234 |
| 235 tester.ExpectBucketCount( |
| 236 kUMAPreviewsInfoBarActionLoFi, |
| 237 PreviewsInfoBarDelegate::INFOBAR_DISMISSED_BY_TAB_CLOSURE, 1); |
| 238 EXPECT_EQ(0, drp_test_context_->pref_service()->GetInteger( |
| 239 data_reduction_proxy::prefs::kLoFiLoadImagesPerSession)); |
| 240 EXPECT_FALSE(user_opt_out_.value()); |
| 241 } |
| 242 |
| 226 TEST_F(PreviewsInfoBarDelegateUnitTest, InfobarTestClickLinkLoFi) { | 243 TEST_F(PreviewsInfoBarDelegateUnitTest, InfobarTestClickLinkLoFi) { |
| 227 base::HistogramTester tester; | 244 base::HistogramTester tester; |
| 228 | 245 |
| 229 ConfirmInfoBarDelegate* infobar = CreateInfoBar( | 246 ConfirmInfoBarDelegate* infobar = CreateInfoBar( |
| 230 PreviewsInfoBarDelegate::LOFI, true /* is_data_saver_user */); | 247 PreviewsInfoBarDelegate::LOFI, true /* is_data_saver_user */); |
| 231 | 248 |
| 232 // Simulate clicking the infobar link. | 249 // Simulate clicking the infobar link. |
| 233 if (infobar->LinkClicked(WindowOpenDisposition::CURRENT_TAB)) | 250 if (infobar->LinkClicked(WindowOpenDisposition::CURRENT_TAB)) |
| 234 infobar_service()->infobar_at(0)->RemoveSelf(); | 251 infobar_service()->infobar_at(0)->RemoveSelf(); |
| 235 EXPECT_EQ(0U, infobar_service()->infobar_count()); | 252 EXPECT_EQ(0U, infobar_service()->infobar_count()); |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 if (infobar->LinkClicked(WindowOpenDisposition::CURRENT_TAB)) | 415 if (infobar->LinkClicked(WindowOpenDisposition::CURRENT_TAB)) |
| 399 infobar_service()->infobar_at(0)->RemoveSelf(); | 416 infobar_service()->infobar_at(0)->RemoveSelf(); |
| 400 EXPECT_EQ(0U, infobar_service()->infobar_count()); | 417 EXPECT_EQ(0U, infobar_service()->infobar_count()); |
| 401 | 418 |
| 402 content::WebContentsTester::For(web_contents())->CommitPendingNavigation(); | 419 content::WebContentsTester::For(web_contents())->CommitPendingNavigation(); |
| 403 | 420 |
| 404 EXPECT_EQ(content::ReloadType::DISABLE_LOFI_MODE, | 421 EXPECT_EQ(content::ReloadType::DISABLE_LOFI_MODE, |
| 405 TestPreviewsWebContentsObserver::FromWebContents(web_contents()) | 422 TestPreviewsWebContentsObserver::FromWebContents(web_contents()) |
| 406 ->last_navigation_reload_type()); | 423 ->last_navigation_reload_type()); |
| 407 } | 424 } |
| OLD | NEW |