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

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

Issue 1548203002: Convert Pass()→std::move() in //components/[n-z]* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix bad headers Created 4 years, 12 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.cc » ('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 #include <utility>
9 10
10 #include "base/base64.h" 11 #include "base/base64.h"
11 #include "base/metrics/metrics_hashes.h" 12 #include "base/metrics/metrics_hashes.h"
12 #include "base/prefs/testing_pref_service.h" 13 #include "base/prefs/testing_pref_service.h"
13 #include "components/rappor/byte_vector_utils.h" 14 #include "components/rappor/byte_vector_utils.h"
14 #include "components/rappor/proto/rappor_metric.pb.h" 15 #include "components/rappor/proto/rappor_metric.pb.h"
15 #include "components/rappor/rappor_parameters.h" 16 #include "components/rappor/rappor_parameters.h"
16 #include "components/rappor/rappor_pref_names.h" 17 #include "components/rappor/rappor_pref_names.h"
17 #include "components/rappor/test_log_uploader.h" 18 #include "components/rappor/test_log_uploader.h"
18 #include "components/rappor/test_rappor_service.h" 19 #include "components/rappor/test_rappor_service.h"
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 EXPECT_EQ(0, reports.report_size()); 118 EXPECT_EQ(0, reports.report_size());
118 } 119 }
119 120
120 // Check that Sample objects record correctly. 121 // Check that Sample objects record correctly.
121 TEST(RapporServiceTest, RecordSample) { 122 TEST(RapporServiceTest, RecordSample) {
122 TestRapporService rappor_service; 123 TestRapporService rappor_service;
123 scoped_ptr<Sample> sample = 124 scoped_ptr<Sample> sample =
124 rappor_service.CreateSample(SAFEBROWSING_RAPPOR_TYPE); 125 rappor_service.CreateSample(SAFEBROWSING_RAPPOR_TYPE);
125 sample->SetStringField("Url", "example.com"); 126 sample->SetStringField("Url", "example.com");
126 sample->SetFlagsField("Flags1", 0xbcd, 12); 127 sample->SetFlagsField("Flags1", 0xbcd, 12);
127 rappor_service.RecordSampleObj("ObjMetric", sample.Pass()); 128 rappor_service.RecordSampleObj("ObjMetric", std::move(sample));
128 uint64_t url_hash = base::HashMetricName("ObjMetric.Url"); 129 uint64_t url_hash = base::HashMetricName("ObjMetric.Url");
129 uint64_t flags_hash = base::HashMetricName("ObjMetric.Flags1"); 130 uint64_t flags_hash = base::HashMetricName("ObjMetric.Flags1");
130 RapporReports reports; 131 RapporReports reports;
131 rappor_service.GetReports(&reports); 132 rappor_service.GetReports(&reports);
132 EXPECT_EQ(2, reports.report_size()); 133 EXPECT_EQ(2, reports.report_size());
133 size_t url_index = reports.report(0).name_hash() == url_hash ? 0 : 1; 134 size_t url_index = reports.report(0).name_hash() == url_hash ? 0 : 1;
134 size_t flags_index = url_index == 0 ? 1 : 0; 135 size_t flags_index = url_index == 0 ? 1 : 0;
135 EXPECT_EQ(url_hash, reports.report(url_index).name_hash()); 136 EXPECT_EQ(url_hash, reports.report(url_index).name_hash());
136 EXPECT_EQ(1u, reports.report(url_index).bits().size()); 137 EXPECT_EQ(1u, reports.report(url_index).bits().size());
137 EXPECT_EQ(flags_hash, reports.report(flags_index).name_hash()); 138 EXPECT_EQ(flags_hash, reports.report(flags_index).name_hash());
138 EXPECT_EQ(2u, reports.report(flags_index).bits().size()); 139 EXPECT_EQ(2u, reports.report(flags_index).bits().size());
139 } 140 }
140 141
141 } // namespace rappor 142 } // namespace rappor
OLDNEW
« no previous file with comments | « components/rappor/rappor_service.cc ('k') | components/rappor/sampler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698