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

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

Issue 188103004: C++ Readability review for holte (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix struct/class declaration Created 6 years, 9 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') | no next file » | 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 "components/rappor/byte_vector_utils.h"
8 #include "components/rappor/proto/rappor_metric.pb.h"
9 #include "components/rappor/rappor_parameters.h"
7 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
8 11
9 namespace rappor { 12 namespace rappor {
10 13
11 class TestRapporService : public RapporService { 14 class TestRapporService : public RapporService {
12 public: 15 public:
13 void GetReports(RapporReports* reports) { 16 void GetReports(RapporReports* reports) {
14 ExportMetrics(reports); 17 ExportMetrics(reports);
15 } 18 }
16 void TestRecordSample(const std::string& metric_name, 19 void TestRecordSample(const std::string& metric_name,
17 const RapporParameters& parameters, 20 const RapporParameters& parameters,
18 const std::string& sample) { 21 const std::string& sample) {
19 RecordSampleInternal(metric_name, parameters, sample); 22 RecordSampleInternal(metric_name, parameters, sample);
20 } 23 }
21 }; 24 };
22 25
23 TEST(RapporServiceTest, RecordAndExportMetrics) { 26 TEST(RapporServiceTest, RecordAndExportMetrics) {
24 const RapporParameters kTestRapporParameters = { 27 const RapporParameters kTestRapporParameters = {
25 16 /* Bloom filter size bytes */, 28 16 /* Bloom filter size bytes */,
26 4 /* Bloom filter hash count */, 29 4 /* Bloom filter hash count */,
27 PROBABILITY_75 /* Fake data probability */, 30 PROBABILITY_75 /* Fake data probability */,
28 PROBABILITY_50 /* Fake one probability */, 31 PROBABILITY_50 /* Fake one probability */,
29 PROBABILITY_75 /* One coin probability */, 32 PROBABILITY_75 /* One coin probability */,
30 PROBABILITY_50 /* Zero coin probability */ 33 PROBABILITY_50 /* Zero coin probability */};
31 };
32 34
33 TestRapporService rappor_service; 35 TestRapporService rappor_service;
34 rappor_service.SetCohortForTesting(0); 36 rappor_service.SetCohortForTesting(0);
35 rappor_service.SetSecretForTesting( 37 rappor_service.SetSecretForTesting(
36 HmacByteVectorGenerator::GenerateEntropyInput()); 38 HmacByteVectorGenerator::GenerateEntropyInput());
37 39
38 rappor_service.TestRecordSample("MyMetric", kTestRapporParameters, "foo"); 40 rappor_service.TestRecordSample("MyMetric", kTestRapporParameters, "foo");
39 rappor_service.TestRecordSample("MyMetric", kTestRapporParameters, "bar"); 41 rappor_service.TestRecordSample("MyMetric", kTestRapporParameters, "bar");
40 42
41 RapporReports reports; 43 RapporReports reports;
42 rappor_service.GetReports(&reports); 44 rappor_service.GetReports(&reports);
43 EXPECT_EQ(1, reports.report_size()); 45 EXPECT_EQ(1, reports.report_size());
44 46
45 const RapporReports::Report& report = reports.report(0); 47 const RapporReports::Report& report = reports.report(0);
46 EXPECT_TRUE(report.name_hash()); 48 EXPECT_TRUE(report.name_hash());
47 EXPECT_EQ(16u, report.bits().size()); 49 EXPECT_EQ(16u, report.bits().size());
48 } 50 }
49 51
50 } // namespace rappor 52 } // namespace rappor
OLDNEW
« no previous file with comments | « components/rappor/rappor_service.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698