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

Side by Side Diff: components/data_reduction_proxy/core/browser/data_reduction_proxy_compression_stats_unittest.cc

Issue 2336863003: Change more base::ListValue methods to use std::unique_ptr. (Closed)
Patch Set: . Created 4 years, 3 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 unified diff | Download patch
OLDNEW
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>
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 received_daily_content_length_list->Set( 172 received_daily_content_length_list->Set(
173 i, new base::StringValue(base::SizeTToString(i))); 173 i, new base::StringValue(base::SizeTToString(i)));
174 } 174 }
175 } 175 }
176 176
177 // Create daily pref list of |kNumDaysInHistory| zero values. 177 // Create daily pref list of |kNumDaysInHistory| zero values.
178 void CreatePrefList(const char* pref) { 178 void CreatePrefList(const char* pref) {
179 base::ListValue* update = compression_stats_->GetList(pref); 179 base::ListValue* update = compression_stats_->GetList(pref);
180 update->Clear(); 180 update->Clear();
181 for (size_t i = 0; i < kNumDaysInHistory; ++i) { 181 for (size_t i = 0; i < kNumDaysInHistory; ++i) {
182 update->Insert(0, new base::StringValue(base::Int64ToString(0))); 182 update->Insert(
183 0, base::MakeUnique<base::StringValue>(base::Int64ToString(0)));
183 } 184 }
184 } 185 }
185 186
186 // Verify the pref list values in |pref_service_| are equal to those in 187 // Verify the pref list values in |pref_service_| are equal to those in
187 // |simple_pref_service| for |pref|. 188 // |simple_pref_service| for |pref|.
188 void VerifyPrefListWasWritten(const char* pref) { 189 void VerifyPrefListWasWritten(const char* pref) {
189 const base::ListValue* delayed_list = compression_stats_->GetList(pref); 190 const base::ListValue* delayed_list = compression_stats_->GetList(pref);
190 const base::ListValue* written_list = pref_service()->GetList(pref); 191 const base::ListValue* written_list = pref_service()->GetList(pref);
191 ASSERT_EQ(delayed_list->GetSize(), written_list->GetSize()); 192 ASSERT_EQ(delayed_list->GetSize(), written_list->GetSize());
192 size_t count = delayed_list->GetSize(); 193 size_t count = delayed_list->GetSize();
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 VerifyPrefs(dict); 543 VerifyPrefs(dict);
543 } 544 }
544 545
545 TEST_F(DataReductionProxyCompressionStatsTest, 546 TEST_F(DataReductionProxyCompressionStatsTest,
546 ClearPrefsOnRestartEnabled) { 547 ClearPrefsOnRestartEnabled) {
547 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 548 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
548 command_line->AppendSwitch( 549 command_line->AppendSwitch(
549 data_reduction_proxy::switches::kClearDataReductionProxyDataSavings); 550 data_reduction_proxy::switches::kClearDataReductionProxyDataSavings);
550 551
551 base::ListValue list_value; 552 base::ListValue list_value;
552 list_value.Insert(0, new base::StringValue(base::Int64ToString(1234))); 553 list_value.Insert(
554 0, base::MakeUnique<base::StringValue>(base::Int64ToString(1234)));
553 pref_service()->Set(prefs::kDailyHttpOriginalContentLength, list_value); 555 pref_service()->Set(prefs::kDailyHttpOriginalContentLength, list_value);
554 556
555 ResetCompressionStatsWithDelay( 557 ResetCompressionStatsWithDelay(
556 base::TimeDelta::FromMinutes(kWriteDelayMinutes)); 558 base::TimeDelta::FromMinutes(kWriteDelayMinutes));
557 559
558 const base::ListValue* value = pref_service()->GetList( 560 const base::ListValue* value = pref_service()->GetList(
559 prefs::kDailyHttpOriginalContentLength); 561 prefs::kDailyHttpOriginalContentLength);
560 EXPECT_EQ(0u, value->GetSize()); 562 EXPECT_EQ(0u, value->GetSize());
561 } 563 }
562 564
563 TEST_F(DataReductionProxyCompressionStatsTest, 565 TEST_F(DataReductionProxyCompressionStatsTest,
564 ClearPrefsOnRestartDisabled) { 566 ClearPrefsOnRestartDisabled) {
565 base::ListValue list_value; 567 base::ListValue list_value;
566 list_value.Insert(0, new base::StringValue(base::Int64ToString(1234))); 568 list_value.Insert(
569 0, base::MakeUnique<base::StringValue>(base::Int64ToString(1234)));
567 pref_service()->Set(prefs::kDailyHttpOriginalContentLength, list_value); 570 pref_service()->Set(prefs::kDailyHttpOriginalContentLength, list_value);
568 571
569 ResetCompressionStatsWithDelay( 572 ResetCompressionStatsWithDelay(
570 base::TimeDelta::FromMinutes(kWriteDelayMinutes)); 573 base::TimeDelta::FromMinutes(kWriteDelayMinutes));
571 574
572 const base::ListValue* value = pref_service()->GetList( 575 const base::ListValue* value = pref_service()->GetList(
573 prefs::kDailyHttpOriginalContentLength); 576 prefs::kDailyHttpOriginalContentLength);
574 std::string string_value; 577 std::string string_value;
575 value->GetString(0, &string_value); 578 value->GetString(0, &string_value);
576 EXPECT_EQ("1234", string_value); 579 EXPECT_EQ("1234", string_value);
(...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after
1307 expected_data_usage = 1310 expected_data_usage =
1308 base::MakeUnique<std::vector<data_reduction_proxy::DataUsageBucket>>( 1311 base::MakeUnique<std::vector<data_reduction_proxy::DataUsageBucket>>(
1309 kNumExpectedBuckets); 1312 kNumExpectedBuckets);
1310 DataUsageLoadVerifier verifier2(std::move(expected_data_usage)); 1313 DataUsageLoadVerifier verifier2(std::move(expected_data_usage));
1311 LoadHistoricalDataUsage(base::Bind(&DataUsageLoadVerifier::OnLoadDataUsage, 1314 LoadHistoricalDataUsage(base::Bind(&DataUsageLoadVerifier::OnLoadDataUsage,
1312 base::Unretained(&verifier2))); 1315 base::Unretained(&verifier2)));
1313 base::RunLoop().RunUntilIdle(); 1316 base::RunLoop().RunUntilIdle();
1314 } 1317 }
1315 1318
1316 } // namespace data_reduction_proxy 1319 } // namespace data_reduction_proxy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698