| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/data_reduction_proxy/core/browser/data_reduction_proxy_sett
ings.h" | 5 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_sett
ings.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 642 kUMAEnabledState, DATA_REDUCTION_SETTINGS_ACTION_ON_TO_OFF, 1); | 642 kUMAEnabledState, DATA_REDUCTION_SETTINGS_ACTION_ON_TO_OFF, 1); |
| 643 } | 643 } |
| 644 | 644 |
| 645 // Verify that the UMA metric and the pref is recorded correctly when the user | 645 // Verify that the UMA metric and the pref is recorded correctly when the user |
| 646 // enables the data reduction proxy. | 646 // enables the data reduction proxy. |
| 647 TEST_F(DataReductionProxySettingsTest, TestDaysSinceEnabledWithTestClock) { | 647 TEST_F(DataReductionProxySettingsTest, TestDaysSinceEnabledWithTestClock) { |
| 648 const char kUMAEnabledState[] = "DataReductionProxy.DaysSinceEnabled"; | 648 const char kUMAEnabledState[] = "DataReductionProxy.DaysSinceEnabled"; |
| 649 std::unique_ptr<base::SimpleTestClock> clock(new base::SimpleTestClock()); | 649 std::unique_ptr<base::SimpleTestClock> clock(new base::SimpleTestClock()); |
| 650 base::SimpleTestClock* clock_ptr = clock.get(); | 650 base::SimpleTestClock* clock_ptr = clock.get(); |
| 651 clock_ptr->Advance(base::TimeDelta::FromDays(1)); | 651 clock_ptr->Advance(base::TimeDelta::FromDays(1)); |
| 652 ResetSettings(std::move(clock), false, false); | 652 ResetSettings(std::move(clock)); |
| 653 | 653 |
| 654 base::Time last_enabled_time = clock_ptr->Now(); | 654 base::Time last_enabled_time = clock_ptr->Now(); |
| 655 | 655 |
| 656 InitPrefMembers(); | 656 InitPrefMembers(); |
| 657 { | 657 { |
| 658 base::HistogramTester histogram_tester; | 658 base::HistogramTester histogram_tester; |
| 659 settings_->data_reduction_proxy_service_->SetIOData( | 659 settings_->data_reduction_proxy_service_->SetIOData( |
| 660 test_context_->io_data()->GetWeakPtr()); | 660 test_context_->io_data()->GetWeakPtr()); |
| 661 | 661 |
| 662 test_context_->RunUntilIdle(); | 662 test_context_->RunUntilIdle(); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 726 test_context_->RunUntilIdle(); | 726 test_context_->RunUntilIdle(); |
| 727 histogram_tester.ExpectTotalCount("DataReductionProxy.DaysSinceEnabled", 0); | 727 histogram_tester.ExpectTotalCount("DataReductionProxy.DaysSinceEnabled", 0); |
| 728 EXPECT_EQ(0, test_context_->pref_service()->GetInt64( | 728 EXPECT_EQ(0, test_context_->pref_service()->GetInt64( |
| 729 prefs::kDataReductionProxyLastEnabledTime)); | 729 prefs::kDataReductionProxyLastEnabledTime)); |
| 730 } | 730 } |
| 731 | 731 |
| 732 TEST_F(DataReductionProxySettingsTest, TestDaysSinceSavingsCleared) { | 732 TEST_F(DataReductionProxySettingsTest, TestDaysSinceSavingsCleared) { |
| 733 std::unique_ptr<base::SimpleTestClock> clock(new base::SimpleTestClock()); | 733 std::unique_ptr<base::SimpleTestClock> clock(new base::SimpleTestClock()); |
| 734 base::SimpleTestClock* clock_ptr = clock.get(); | 734 base::SimpleTestClock* clock_ptr = clock.get(); |
| 735 clock_ptr->Advance(base::TimeDelta::FromDays(1)); | 735 clock_ptr->Advance(base::TimeDelta::FromDays(1)); |
| 736 ResetSettings(std::move(clock), false, false); | 736 ResetSettings(std::move(clock)); |
| 737 | 737 |
| 738 InitPrefMembers(); | 738 InitPrefMembers(); |
| 739 base::HistogramTester histogram_tester; | 739 base::HistogramTester histogram_tester; |
| 740 test_context_->pref_service()->SetInt64( | 740 test_context_->pref_service()->SetInt64( |
| 741 prefs::kDataReductionProxySavingsClearedNegativeSystemClock, | 741 prefs::kDataReductionProxySavingsClearedNegativeSystemClock, |
| 742 clock_ptr->Now().ToInternalValue()); | 742 clock_ptr->Now().ToInternalValue()); |
| 743 | 743 |
| 744 settings_->data_reduction_proxy_service_->SetIOData( | 744 settings_->data_reduction_proxy_service_->SetIOData( |
| 745 test_context_->io_data()->GetWeakPtr()); | 745 test_context_->io_data()->GetWeakPtr()); |
| 746 test_context_->RunUntilIdle(); | 746 test_context_->RunUntilIdle(); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 763 ASSERT_EQ(kNumDaysInHistory, result.size()); | 763 ASSERT_EQ(kNumDaysInHistory, result.size()); |
| 764 | 764 |
| 765 for (size_t i = 0; i < kNumDaysInHistory; ++i) { | 765 for (size_t i = 0; i < kNumDaysInHistory; ++i) { |
| 766 long expected_length = | 766 long expected_length = |
| 767 static_cast<long>((kNumDaysInHistory - 1 - i) * 2); | 767 static_cast<long>((kNumDaysInHistory - 1 - i) * 2); |
| 768 ASSERT_EQ(expected_length, result[i]); | 768 ASSERT_EQ(expected_length, result[i]); |
| 769 } | 769 } |
| 770 } | 770 } |
| 771 | 771 |
| 772 } // namespace data_reduction_proxy | 772 } // namespace data_reduction_proxy |
| OLD | NEW |