Chromium Code Reviews| 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; | |
| 21 EXPECT_TRUE(HistogramManager::GetInstance()->GetDeltas(&data)); | |
| 22 EXPECT_LT(0u, data.size()); | |
|
Alexei Svitkine (slow)
2014/12/12 16:57:00
I thought I mention this in a previous comment, bu
ramant (doing other things)
2014/12/12 19:01:26
Sorry missed the above change.
Done.
| |
| 23 ChromeUserMetricsExtension uma_proto; | |
| 24 EXPECT_TRUE(uma_proto.ParseFromArray( | |
| 25 reinterpret_cast<const char*>(&data[0]), data.size())); | |
| 26 EXPECT_LT(0u, data.size()); | |
| 27 | |
| 28 const HistogramEventProto& histogram_proto = | |
| 29 uma_proto.histogram_event(uma_proto.histogram_event_size() - 1); | |
| 30 ASSERT_EQ(1, histogram_proto.bucket_size()); | |
|
Alexei Svitkine (slow)
2014/12/12 16:57:00
I got a test failure here:
[----------] 1 test f
ramant (doing other things)
2014/12/12 19:01:26
Awesome. Many many thanks for the above idea. Remo
| |
| 31 EXPECT_LE(0, histogram_proto.bucket(0).min()); | |
| 32 EXPECT_LE(2, histogram_proto.bucket(0).max()); | |
| 33 EXPECT_EQ(1, histogram_proto.bucket(0).count()); | |
| 34 | |
| 35 UMA_STABILITY_HISTOGRAM_ENUMERATION("UmaStabilityHistogram", 2, 3); | |
| 36 std::vector<uint8> data2; | |
| 37 EXPECT_TRUE(HistogramManager::GetInstance()->GetDeltas(&data2)); | |
| 38 EXPECT_LT(0u, data2.size()); | |
| 39 ChromeUserMetricsExtension uma_proto2; | |
| 40 EXPECT_TRUE(uma_proto2.ParseFromArray( | |
| 41 reinterpret_cast<const char*>(&data2[0]), data2.size())); | |
| 42 EXPECT_LT(0u, data2.size()); | |
| 43 | |
| 44 const HistogramEventProto& histogram_proto2 = | |
| 45 uma_proto2.histogram_event(uma_proto2.histogram_event_size() - 1); | |
| 46 ASSERT_EQ(1, histogram_proto2.bucket_size()); | |
| 47 EXPECT_LE(0, histogram_proto2.bucket(0).min()); | |
| 48 EXPECT_LE(3, histogram_proto2.bucket(0).max()); | |
| 49 EXPECT_EQ(1, histogram_proto2.bucket(0).count()); | |
| 50 } | |
| 51 | |
| 52 } // namespace metrics | |
| OLD | NEW |