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 "components/rappor/rappor_recorder.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 |
| 12 namespace rappor { |
| 13 |
| 14 class RapporServiceTest : public testing::Test { |
| 15 public: |
| 16 RapporMetricsProto* GetProto(RapporService* log) { |
| 17 return &(log->rappor_metrics_proto_); |
| 18 } |
| 19 void RecordRapporMetrics(RapporService* log) { log->RecordRapporMetrics(); } |
| 20 }; |
| 21 |
| 22 TEST_F(RapporServiceTest, RapporMetrics) { |
| 23 RapporService log; |
| 24 std::vector<std::string> samples; |
| 25 samples.push_back("foo"); |
| 26 RAPPOR_SAMPLES("MyRappor", samples); |
| 27 |
| 28 RecordRapporMetrics(&log); |
| 29 |
| 30 RapporMetricsProto* proto = GetProto(&log); |
| 31 EXPECT_EQ(1, proto->rappor_size()); |
| 32 |
| 33 const RapporMetricsProto::RapporMetricProto& rappor_proto = proto->rappor(0); |
| 34 EXPECT_TRUE(rappor_proto.name_hash()); |
| 35 EXPECT_EQ(16u, rappor_proto.bits().size()); |
| 36 } |
| 37 |
| 38 } // namespace rappor |
OLD | NEW |