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

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: Created 7 years 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 (c) 2013 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 "components/rappor/rappor_recorder.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11
12 namespace rappor {
13
14 const RapporParameters kTestRapporParameters = {
Alexei Svitkine (slow) 2013/12/19 19:47:02 Nit: Inline this into the test function, unless th
Steven Holte 2013/12/20 03:03:55 Done.
15 "MyRappor", 16 /* Bloom filter size bytes */,
16 4 /* Bloom filter hash count */, PROBABILITY_75 /* Fake data probability */,
17 PROBABILITY_50 /* Fake one probability */,
18 PROBABILITY_75 /* One coin probability */,
19 PROBABILITY_50 /* Zero coin probability */
20 };
21
22 class RapporServiceTest : public testing::Test {
23 public:
24 RapporMetricsProto* GetProto(RapporService* log) {
25 return &(log->rappor_metrics_proto_);
26 }
27 void RecordRapporMetrics(RapporService* log) { log->RecordRapporMetrics(); }
28 };
29
30 TEST_F(RapporServiceTest, RapporMetrics) {
31 RapporService log;
32 std::vector<std::string> samples;
33 samples.push_back("foo");
34 RAPPOR_SAMPLES(&kTestRapporParameters, samples);
35
36 RecordRapporMetrics(&log);
37
38 RapporMetricsProto* proto = GetProto(&log);
39 EXPECT_EQ(1, proto->rappor_size());
40
41 const RapporMetricsProto::RapporMetric& rappor_proto = proto->rappor(0);
42 EXPECT_TRUE(rappor_proto.name_hash());
43 EXPECT_EQ(16u, rappor_proto.bits().size());
44 }
45
46 } // namespace rappor
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698