| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/metrics/single_sample_metrics_factory_impl.h" | 5 #include "components/metrics/single_sample_metrics_factory_impl.h" |
| 6 | 6 |
| 7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "base/test/gtest_util.h" | 9 #include "base/test/gtest_util.h" |
| 10 #include "base/test/histogram_tester.h" | 10 #include "base/test/histogram_tester.h" |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 // Verify construction implicitly by requesting a histogram with the same | 124 // Verify construction implicitly by requesting a histogram with the same |
| 125 // parameters; this test relies on the fact that histogram objects are unique | 125 // parameters; this test relies on the fact that histogram objects are unique |
| 126 // per name. Different parameters will result in a nullptr being returned. | 126 // per name. Different parameters will result in a nullptr being returned. |
| 127 EXPECT_FALSE(base::Histogram::FactoryGet(kMetricName, 1, 3, 3, | 127 EXPECT_FALSE(base::Histogram::FactoryGet(kMetricName, 1, 3, 3, |
| 128 base::HistogramBase::kNoFlags)); | 128 base::HistogramBase::kNoFlags)); |
| 129 EXPECT_TRUE(base::Histogram::FactoryGet( | 129 EXPECT_TRUE(base::Histogram::FactoryGet( |
| 130 kMetricName, kMin, kMax, kBucketCount, | 130 kMetricName, kMin, kMax, kBucketCount, |
| 131 base::HistogramBase::kUmaTargetedHistogramFlag)); | 131 base::HistogramBase::kUmaTargetedHistogramFlag)); |
| 132 } | 132 } |
| 133 | 133 |
| 134 TEST_F(SingleSampleMetricsFactoryImplTest, MultithreadedMetrics) { | 134 // Flaky on Android N5X builders. https://crbug.com/719497 |
| 135 #if defined(OS_ANDROID) |
| 136 #define MAYBE_MultithreadedMetrics DISABLED_MultithreadedMetrics |
| 137 #else |
| 138 #define MAYBE_MultithreadedMetrics MultithreadedMetrics |
| 139 #endif |
| 140 TEST_F(SingleSampleMetricsFactoryImplTest, MAYBE_MultithreadedMetrics) { |
| 135 base::HistogramTester tester; | 141 base::HistogramTester tester; |
| 136 std::unique_ptr<base::SingleSampleMetric> metric = | 142 std::unique_ptr<base::SingleSampleMetric> metric = |
| 137 factory_->CreateCustomCountsMetric(kMetricName, kMin, kMax, kBucketCount); | 143 factory_->CreateCustomCountsMetric(kMetricName, kMin, kMax, kBucketCount); |
| 138 EXPECT_EQ(1u, provider_count_); | 144 EXPECT_EQ(1u, provider_count_); |
| 139 | 145 |
| 140 StartThread(); | 146 StartThread(); |
| 141 | 147 |
| 142 std::unique_ptr<base::SingleSampleMetric> threaded_metric = | 148 std::unique_ptr<base::SingleSampleMetric> threaded_metric = |
| 143 CreateMetricOnThread(); | 149 CreateMetricOnThread(); |
| 144 ASSERT_TRUE(threaded_metric); | 150 ASSERT_TRUE(threaded_metric); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 174 FROM_HERE, base::Bind(&base::DoNothing), run_loop.QuitClosure()); | 180 FROM_HERE, base::Bind(&base::DoNothing), run_loop.QuitClosure()); |
| 175 run_loop.Run(); | 181 run_loop.Run(); |
| 176 } | 182 } |
| 177 | 183 |
| 178 metric.reset(); | 184 metric.reset(); |
| 179 base::RunLoop().RunUntilIdle(); | 185 base::RunLoop().RunUntilIdle(); |
| 180 tester.ExpectUniqueSample(kMetricName, kSample, 2); | 186 tester.ExpectUniqueSample(kMetricName, kSample, 2); |
| 181 } | 187 } |
| 182 | 188 |
| 183 } // namespace metrics | 189 } // namespace metrics |
| OLD | NEW |