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

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 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 (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 "testing/gtest/include/gtest/gtest.h"
10
11 namespace rappor {
12
13 class RapporServiceTest : public testing::Test {
14 public:
15 RapporMetricsProto* LogRapporMetrics(RapporService* rappor_service) {
16 rappor_service->LogRapporMetrics();
17 return &(rappor_service->rappor_metrics_proto_);
Alexei Svitkine (slow) 2014/01/09 19:23:09 Nit: No need for ()'s.
Steven Holte 2014/01/09 22:03:01 Done.
18 }
19 };
20
21 TEST_F(RapporServiceTest, RapporMetrics) {
22 const RapporParameters kTestRapporParameters = {
23 "MyRappor", 16 /* Bloom filter size bytes */,
24 4 /* Bloom filter hash count */,
25 PROBABILITY_75 /* Fake data probability */,
26 PROBABILITY_50 /* Fake one probability */,
27 PROBABILITY_75 /* One coin probability */,
28 PROBABILITY_50 /* Zero coin probability */
29 };
30
31 RapporService rappor_service;
32 std::vector<std::string> samples;
33 samples.push_back("foo");
34 rappor_service.RecordSamples(kTestRapporParameters, samples);
35 std::vector<std::string> samples2;
36 samples2.push_back("bar");
37 rappor_service.RecordSamples(kTestRapporParameters, samples2);
38
39 RapporMetricsProto* proto = LogRapporMetrics(&rappor_service);
40 EXPECT_EQ(1, proto->rappor_size());
41
42 const RapporMetricsProto::RapporMetric& rappor_proto = proto->rappor(0);
43 EXPECT_TRUE(rappor_proto.name_hash());
44 EXPECT_EQ(16u, rappor_proto.bits().size());
45 }
46
47 } // namespace rappor
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698