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

Side by Side Diff: components/rappor/rappor_service_unittest.cc

Issue 1921923002: Convert //components/[o-t]* from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 8 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
« no previous file with comments | « components/rappor/rappor_service.cc ('k') | components/rappor/sampler.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/rappor/rappor_service.h" 5 #include "components/rappor/rappor_service.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9
10 #include <memory>
9 #include <utility> 11 #include <utility>
10 12
11 #include "base/base64.h" 13 #include "base/base64.h"
12 #include "base/metrics/metrics_hashes.h" 14 #include "base/metrics/metrics_hashes.h"
13 #include "components/prefs/testing_pref_service.h" 15 #include "components/prefs/testing_pref_service.h"
14 #include "components/rappor/byte_vector_utils.h" 16 #include "components/rappor/byte_vector_utils.h"
15 #include "components/rappor/proto/rappor_metric.pb.h" 17 #include "components/rappor/proto/rappor_metric.pb.h"
16 #include "components/rappor/rappor_parameters.h" 18 #include "components/rappor/rappor_parameters.h"
17 #include "components/rappor/rappor_pref_names.h" 19 #include "components/rappor/rappor_pref_names.h"
18 #include "components/rappor/test_log_uploader.h" 20 #include "components/rappor/test_log_uploader.h"
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 rappor_service.RecordSample("MyMetric", SAFEBROWSING_RAPPOR_TYPE, "foo"); 116 rappor_service.RecordSample("MyMetric", SAFEBROWSING_RAPPOR_TYPE, "foo");
115 117
116 RapporReports reports; 118 RapporReports reports;
117 rappor_service.GetReports(&reports); 119 rappor_service.GetReports(&reports);
118 EXPECT_EQ(0, reports.report_size()); 120 EXPECT_EQ(0, reports.report_size());
119 } 121 }
120 122
121 // Check that Sample objects record correctly. 123 // Check that Sample objects record correctly.
122 TEST(RapporServiceTest, RecordSample) { 124 TEST(RapporServiceTest, RecordSample) {
123 TestRapporService rappor_service; 125 TestRapporService rappor_service;
124 scoped_ptr<Sample> sample = 126 std::unique_ptr<Sample> sample =
125 rappor_service.CreateSample(SAFEBROWSING_RAPPOR_TYPE); 127 rappor_service.CreateSample(SAFEBROWSING_RAPPOR_TYPE);
126 sample->SetStringField("Url", "example.com"); 128 sample->SetStringField("Url", "example.com");
127 sample->SetFlagsField("Flags1", 0xbcd, 12); 129 sample->SetFlagsField("Flags1", 0xbcd, 12);
128 rappor_service.RecordSampleObj("ObjMetric", std::move(sample)); 130 rappor_service.RecordSampleObj("ObjMetric", std::move(sample));
129 uint64_t url_hash = base::HashMetricName("ObjMetric.Url"); 131 uint64_t url_hash = base::HashMetricName("ObjMetric.Url");
130 uint64_t flags_hash = base::HashMetricName("ObjMetric.Flags1"); 132 uint64_t flags_hash = base::HashMetricName("ObjMetric.Flags1");
131 RapporReports reports; 133 RapporReports reports;
132 rappor_service.GetReports(&reports); 134 rappor_service.GetReports(&reports);
133 EXPECT_EQ(2, reports.report_size()); 135 EXPECT_EQ(2, reports.report_size());
134 size_t url_index = reports.report(0).name_hash() == url_hash ? 0 : 1; 136 size_t url_index = reports.report(0).name_hash() == url_hash ? 0 : 1;
135 size_t flags_index = url_index == 0 ? 1 : 0; 137 size_t flags_index = url_index == 0 ? 1 : 0;
136 EXPECT_EQ(url_hash, reports.report(url_index).name_hash()); 138 EXPECT_EQ(url_hash, reports.report(url_index).name_hash());
137 EXPECT_EQ(1u, reports.report(url_index).bits().size()); 139 EXPECT_EQ(1u, reports.report(url_index).bits().size());
138 EXPECT_EQ(flags_hash, reports.report(flags_index).name_hash()); 140 EXPECT_EQ(flags_hash, reports.report(flags_index).name_hash());
139 EXPECT_EQ(2u, reports.report(flags_index).bits().size()); 141 EXPECT_EQ(2u, reports.report(flags_index).bits().size());
140 } 142 }
141 143
142 } // namespace rappor 144 } // namespace rappor
OLDNEW
« no previous file with comments | « components/rappor/rappor_service.cc ('k') | components/rappor/sampler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698