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

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

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

Powered by Google App Engine
This is Rietveld 408576698