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

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

Issue 49753002: RAPPOR implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: RapporMetrics StatsTest Created 6 years, 11 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "components/rappor/rappor_service.h"
6
7 #include <string>
8
9 #include "testing/gtest/include/gtest/gtest.h"
10
11 namespace rappor {
12
13 class TestRapporService : public RapporService {
14 public:
15 void GetReports(RapporReports* reports) {
16 LogMetrics(reports);
17 }
18 void TestRecordSamples(const RapporParameters& parameters,
19 const std::vector<std::string>& samples) {
20 RecordSamplesInternal(parameters, samples);
21 }
22 };
23
24 TEST(RapporServiceTest, RapporMetrics) {
25 const RapporParameters kTestRapporParameters = {
26 "MyRappor", 16 /* Bloom filter size bytes */,
27 4 /* Bloom filter hash count */,
28 PROBABILITY_75 /* Fake data probability */,
29 PROBABILITY_50 /* Fake one probability */,
30 PROBABILITY_75 /* One coin probability */,
31 PROBABILITY_50 /* Zero coin probability */
32 };
33
34 TestRapporService rappor_service;
35 std::vector<std::string> samples;
36 samples.push_back("foo");
37 rappor_service.TestRecordSamples(kTestRapporParameters, samples);
38 std::vector<std::string> samples2;
39 samples2.push_back("bar");
40 rappor_service.TestRecordSamples(kTestRapporParameters, samples2);
41
42 RapporReports reports;
43 rappor_service.GetReports(&reports);
44 EXPECT_EQ(1, reports.report_size());
45
46 const RapporReports::Report& report = reports.report(0);
47 EXPECT_TRUE(report.name_hash());
48 EXPECT_EQ(16u, report.bits().size());
49 }
50
51 } // namespace rappor
OLDNEW
« components/rappor/rappor_service.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