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_comp
ression_stats.h" | 5 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_comp
ression_stats.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
11 #include <utility> | 11 #include <utility> |
12 | 12 |
13 #include "base/memory/ptr_util.h" | 13 #include "base/memory/ptr_util.h" |
14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
15 #include "base/run_loop.h" | 15 #include "base/run_loop.h" |
16 #include "base/strings/string_number_conversions.h" | 16 #include "base/strings/string_number_conversions.h" |
17 #include "base/test/histogram_tester.h" | 17 #include "base/test/histogram_tester.h" |
| 18 #include "base/test/scoped_task_environment.h" |
18 #include "base/time/time.h" | 19 #include "base/time/time.h" |
19 #include "base/values.h" | 20 #include "base/values.h" |
20 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_pref
s.h" | 21 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_pref
s.h" |
21 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_test
_utils.h" | 22 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_test
_utils.h" |
22 #include "components/data_reduction_proxy/core/browser/data_use_group.h" | 23 #include "components/data_reduction_proxy/core/browser/data_use_group.h" |
23 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_pref_
names.h" | 24 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_pref_
names.h" |
24 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_switc
hes.h" | 25 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_switc
hes.h" |
25 #include "components/data_reduction_proxy/proto/data_store.pb.h" | 26 #include "components/data_reduction_proxy/proto/data_store.pb.h" |
26 #include "components/prefs/pref_registry_simple.h" | 27 #include "components/prefs/pref_registry_simple.h" |
27 #include "components/prefs/pref_service.h" | 28 #include "components/prefs/pref_service.h" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 namespace data_reduction_proxy { | 106 namespace data_reduction_proxy { |
106 | 107 |
107 // The initial last update time used in test. There is no leap second a few | 108 // The initial last update time used in test. There is no leap second a few |
108 // days around this time used in the test. | 109 // days around this time used in the test. |
109 // Note: No time zone is specified. Local time will be assumed by | 110 // Note: No time zone is specified. Local time will be assumed by |
110 // base::Time::FromString below. | 111 // base::Time::FromString below. |
111 const char kLastUpdateTime[] = "Wed, 18 Sep 2013 03:45:26"; | 112 const char kLastUpdateTime[] = "Wed, 18 Sep 2013 03:45:26"; |
112 | 113 |
113 class DataReductionProxyCompressionStatsTest : public testing::Test { | 114 class DataReductionProxyCompressionStatsTest : public testing::Test { |
114 protected: | 115 protected: |
115 DataReductionProxyCompressionStatsTest() { | 116 DataReductionProxyCompressionStatsTest() |
| 117 : scoped_task_environment_( |
| 118 base::test::ScopedTaskEnvironment::MainThreadType::UI) { |
116 EXPECT_TRUE(base::Time::FromString(kLastUpdateTime, &now_)); | 119 EXPECT_TRUE(base::Time::FromString(kLastUpdateTime, &now_)); |
117 } | 120 } |
118 | 121 |
119 void SetUp() override { | 122 void SetUp() override { |
120 drp_test_context_ = DataReductionProxyTestContext::Builder().Build(); | 123 drp_test_context_ = DataReductionProxyTestContext::Builder().Build(); |
121 | 124 |
122 compression_stats_.reset(new DataReductionProxyCompressionStats( | 125 compression_stats_.reset(new DataReductionProxyCompressionStats( |
123 data_reduction_proxy_service(), pref_service(), base::TimeDelta())); | 126 data_reduction_proxy_service(), pref_service(), base::TimeDelta())); |
124 } | 127 } |
125 | 128 |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 | 469 |
467 DataReductionProxyService* data_reduction_proxy_service() { | 470 DataReductionProxyService* data_reduction_proxy_service() { |
468 return drp_test_context_->data_reduction_proxy_service(); | 471 return drp_test_context_->data_reduction_proxy_service(); |
469 } | 472 } |
470 | 473 |
471 bool IsDataReductionProxyEnabled() { | 474 bool IsDataReductionProxyEnabled() { |
472 return drp_test_context_->IsDataReductionProxyEnabled(); | 475 return drp_test_context_->IsDataReductionProxyEnabled(); |
473 } | 476 } |
474 | 477 |
475 private: | 478 private: |
476 base::MessageLoopForUI loop_; | 479 base::test::ScopedTaskEnvironment scoped_task_environment_; |
477 std::unique_ptr<DataReductionProxyTestContext> drp_test_context_; | 480 std::unique_ptr<DataReductionProxyTestContext> drp_test_context_; |
478 std::unique_ptr<DataReductionProxyCompressionStats> compression_stats_; | 481 std::unique_ptr<DataReductionProxyCompressionStats> compression_stats_; |
479 base::Time now_; | 482 base::Time now_; |
480 base::TimeDelta now_delta_; | 483 base::TimeDelta now_delta_; |
481 }; | 484 }; |
482 | 485 |
483 TEST_F(DataReductionProxyCompressionStatsTest, WritePrefsDirect) { | 486 TEST_F(DataReductionProxyCompressionStatsTest, WritePrefsDirect) { |
484 SetUpPrefs(); | 487 SetUpPrefs(); |
485 | 488 |
486 VerifyPrefWasWritten(prefs::kHttpOriginalContentLength); | 489 VerifyPrefWasWritten(prefs::kHttpOriginalContentLength); |
(...skipping 875 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1362 base::Unretained(&verifier)), | 1365 base::Unretained(&verifier)), |
1363 now); | 1366 now); |
1364 base::RunLoop().RunUntilIdle(); | 1367 base::RunLoop().RunUntilIdle(); |
1365 | 1368 |
1366 VerifyDailyDataSavingContentLengthPrefLists(nullptr, 0, nullptr, 0, nullptr, | 1369 VerifyDailyDataSavingContentLengthPrefLists(nullptr, 0, nullptr, 0, nullptr, |
1367 0, nullptr, 0, nullptr, 0, | 1370 0, nullptr, 0, nullptr, 0, |
1368 nullptr, 0, 0); | 1371 nullptr, 0, 0); |
1369 } | 1372 } |
1370 | 1373 |
1371 } // namespace data_reduction_proxy | 1374 } // namespace data_reduction_proxy |
OLD | NEW |