OLD | NEW |
(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_); |
| 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 |
| 36 RapporMetricsProto* proto = LogRapporMetrics(&rappor_service); |
| 37 EXPECT_EQ(1, proto->rappor_size()); |
| 38 |
| 39 const RapporMetricsProto::RapporMetric& rappor_proto = proto->rappor(0); |
| 40 EXPECT_TRUE(rappor_proto.name_hash()); |
| 41 EXPECT_EQ(16u, rappor_proto.bits().size()); |
| 42 } |
| 43 |
| 44 } // namespace rappor |
OLD | NEW |