OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 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_recorder.h" |
| 6 #include "components/rappor/rappor.h" |
| 7 |
| 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 |
| 10 namespace rappor { |
| 11 |
| 12 const RapporParameters kTestRapporParameters = { |
| 13 "MyRappor", 16 /* Bloom filter size bytes */, |
| 14 4 /* Bloom filter hash count */, PROBABILITY_75 /* Fake data probability */, |
| 15 PROBABILITY_50 /* Fake one probability */, |
| 16 PROBABILITY_75 /* One coin probability */, |
| 17 PROBABILITY_50 /* Zero coin probability */ |
| 18 }; |
| 19 |
| 20 const RapporParameters kTestRappor2Parameters = { |
| 21 "MyRappor2", 16 /* Bloom filter size bytes */, |
| 22 4 /* Bloom filter hash count */, PROBABILITY_75 /* Fake data probability */, |
| 23 PROBABILITY_50 /* Fake one probability */, |
| 24 PROBABILITY_75 /* One coin probability */, |
| 25 PROBABILITY_50 /* Zero coin probability */ |
| 26 }; |
| 27 |
| 28 TEST(RapporRecorderTest, TestRecorder) { |
| 29 RapporRecorder recorder; |
| 30 |
| 31 // Recording an empty list of samples. |
| 32 std::vector<std::string> samples; |
| 33 recorder.RecordSamples(&kTestRapporParameters, samples); |
| 34 recorder.RecordSamples(&kTestRappor2Parameters, samples); |
| 35 recorder.RecordSamples(&kTestRapporParameters, samples); |
| 36 |
| 37 RapporRecorder::Rappors rappors; |
| 38 recorder.CollectRappors(&rappors); |
| 39 ASSERT_EQ(rappors.size(), 2u); |
| 40 |
| 41 // Collecting rappors should clear the recorder. |
| 42 RapporRecorder::Rappors rappors_cleared; |
| 43 recorder.CollectRappors(&rappors_cleared); |
| 44 ASSERT_EQ(rappors_cleared.size(), 0u); |
| 45 |
| 46 RapporRecorder::DeleteRappors(&rappors); |
| 47 RapporRecorder::DeleteRappors(&rappors_cleared); |
| 48 } |
| 49 |
| 50 } // namespace rappor |
OLD | NEW |