Remove "if (WallpaperManager::Get())" from MultiUserWindowManagerChromeOS::Transition...
[chromium-blink-merge.git] / components / rappor / rappor_service_unittest.cc
blob790eae7dff7b8024119995a3038d8c6099d1afb8
1 // Copyright 2014 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.
5 #include "components/rappor/rappor_service.h"
7 #include "testing/gtest/include/gtest/gtest.h"
9 namespace rappor {
11 class TestRapporService : public RapporService {
12 public:
13 void GetReports(RapporReports* reports) {
14 ExportMetrics(reports);
16 void TestRecordSample(const std::string& metric_name,
17 const RapporParameters& parameters,
18 const std::string& sample) {
19 RecordSampleInternal(metric_name, parameters, sample);
23 TEST(RapporServiceTest, RecordAndExportMetrics) {
24 const RapporParameters kTestRapporParameters = {
25 16 /* Bloom filter size bytes */,
26 4 /* Bloom filter hash count */,
27 PROBABILITY_75 /* Fake data probability */,
28 PROBABILITY_50 /* Fake one probability */,
29 PROBABILITY_75 /* One coin probability */,
30 PROBABILITY_50 /* Zero coin probability */
33 TestRapporService rappor_service;
34 rappor_service.SetCohortForTesting(0);
35 rappor_service.SetSecretForTesting(
36 HmacByteVectorGenerator::GenerateEntropyInput());
38 rappor_service.TestRecordSample("MyMetric", kTestRapporParameters, "foo");
39 rappor_service.TestRecordSample("MyMetric", kTestRapporParameters, "bar");
41 RapporReports reports;
42 rappor_service.GetReports(&reports);
43 EXPECT_EQ(1, reports.report_size());
45 const RapporReports::Report& report = reports.report(0);
46 EXPECT_TRUE(report.name_hash());
47 EXPECT_EQ(16u, report.bits().size());
50 } // namespace rappor