OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #include "components/metrics/histogram_manager.h" |
| 6 |
| 7 #include <string> |
| 8 |
| 9 #include "base/basictypes.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 |
| 12 namespace metrics { |
| 13 |
| 14 // TODO(mef): crbug.com/441441. Move components/metrics/histogram_manager.* |
| 15 // files into components/android/cronet. |
| 16 TEST(HistogramManager, HistogramBucketFields) { |
| 17 // kNoFlags filter should record all histograms. |
| 18 UMA_HISTOGRAM_ENUMERATION("UmaHistogram", 1, 2); |
| 19 |
| 20 std::vector<uint8> data = HistogramManager::GetInstance()->GetDeltas(); |
| 21 EXPECT_LT(0u, data.size()); |
| 22 ChromeUserMetricsExtension uma_proto; |
| 23 EXPECT_TRUE(uma_proto.ParseFromArray( |
| 24 reinterpret_cast<const char*>(&data[0]), data.size())); |
| 25 EXPECT_LT(0u, data.size()); |
| 26 |
| 27 const HistogramEventProto& histogram_proto = |
| 28 uma_proto.histogram_event(uma_proto.histogram_event_size() - 1); |
| 29 ASSERT_EQ(1, histogram_proto.bucket_size()); |
| 30 EXPECT_LE(0, histogram_proto.bucket(0).min()); |
| 31 EXPECT_LE(2, histogram_proto.bucket(0).max()); |
| 32 EXPECT_EQ(1, histogram_proto.bucket(0).count()); |
| 33 |
| 34 UMA_STABILITY_HISTOGRAM_ENUMERATION("UmaStabilityHistogram", 2, 3); |
| 35 std::vector<uint8> data2 = HistogramManager::GetInstance()->GetDeltas(); |
| 36 EXPECT_LT(0u, data2.size()); |
| 37 ChromeUserMetricsExtension uma_proto2; |
| 38 EXPECT_TRUE(uma_proto2.ParseFromArray( |
| 39 reinterpret_cast<const char*>(&data2[0]), data2.size())); |
| 40 EXPECT_LT(0u, data2.size()); |
| 41 |
| 42 const HistogramEventProto& histogram_proto2 = |
| 43 uma_proto2.histogram_event(uma_proto2.histogram_event_size() - 1); |
| 44 ASSERT_EQ(1, histogram_proto2.bucket_size()); |
| 45 EXPECT_LE(0, histogram_proto2.bucket(0).min()); |
| 46 EXPECT_LE(3, histogram_proto2.bucket(0).max()); |
| 47 EXPECT_EQ(1, histogram_proto2.bucket(0).count()); |
| 48 } |
| 49 |
| 50 } // namespace metrics |
OLD | NEW |