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/cronet/android/histogram_manager.h" | |
6 | |
7 #include <string> | |
8 #include <vector> | |
9 | |
10 #include "base/basictypes.h" | |
11 #include "base/metrics/histogram.h" | |
12 #include "testing/gtest/include/gtest/gtest.h" | |
13 | |
14 namespace cronet { | |
15 | |
16 namespace { | |
17 | |
18 class HistogramManagerTest : public testing::Test { | |
Alexei Svitkine (slow)
2014/12/11 15:38:58
If this class doesn't have anything in it, you can
ramant (doing other things)
2014/12/11 20:23:53
Done.
| |
19 public: | |
20 HistogramManagerTest() {} | |
21 | |
22 private: | |
23 DISALLOW_COPY_AND_ASSIGN(HistogramManagerTest); | |
24 }; | |
25 | |
26 } // namespace | |
27 | |
28 using metrics::ChromeUserMetricsExtension; | |
29 using metrics::HistogramEventProto; | |
Alexei Svitkine (slow)
2014/12/11 15:38:58
Nit: I prefer not having using statements and just
ramant (doing other things)
2014/12/11 20:23:53
Done.
| |
30 | |
31 TEST_F(HistogramManagerTest, HistogramBucketFields) { | |
ramant (doing other things)
2014/12/11 02:21:53
Tested this code by moving all HistogramManager.*
mef
2014/12/11 15:35:40
sgtm. I like making Java wrapper as thin as possib
Alexei Svitkine (slow)
2014/12/11 15:38:58
My preference is to keep this in the cronet compon
ramant (doing other things)
2014/12/11 20:23:53
Acknowledged.
ramant (doing other things)
2014/12/11 20:23:53
Done.
| |
32 // kNoFlags filter should record all histograms. | |
33 UMA_HISTOGRAM_ENUMERATION("UmaHistogram", 1, 2); | |
34 | |
35 ChromeUserMetricsExtension uma_proto; | |
36 | |
37 std::vector<uint8> data = HistogramManager::GetInstance()->GetDeltas(); | |
38 uma_proto.ParseFromArray(data.data(), data.size()); | |
39 EXPECT_LT(0u, data.size()); | |
Alexei Svitkine (slow)
2014/12/11 15:38:58
Shouldn't this expect be before ParseFromArray()?
ramant (doing other things)
2014/12/11 20:23:53
Done.
| |
40 | |
41 const HistogramEventProto& histogram_proto = | |
42 uma_proto.histogram_event(uma_proto.histogram_event_size() - 1); | |
43 ASSERT_EQ(1, histogram_proto.bucket_size()); | |
44 EXPECT_FALSE(histogram_proto.bucket(0).has_min()); | |
45 EXPECT_TRUE(histogram_proto.bucket(0).has_max()); | |
46 EXPECT_EQ(0, histogram_proto.bucket(0).min()); | |
47 EXPECT_EQ(2, histogram_proto.bucket(0).max()); | |
48 EXPECT_EQ(1, histogram_proto.bucket(0).count()); | |
49 | |
50 UMA_STABILITY_HISTOGRAM_ENUMERATION("UmaStabilityHistogram", 2, 3); | |
51 std::vector<uint8> data2 = HistogramManager::GetInstance()->GetDeltas(); | |
52 ChromeUserMetricsExtension uma_proto2; | |
53 uma_proto2.ParseFromArray(data2.data(), data2.size()); | |
54 EXPECT_LT(0u, data2.size()); | |
55 | |
56 const HistogramEventProto& histogram_proto2 = | |
57 uma_proto2.histogram_event(uma_proto2.histogram_event_size() - 1); | |
58 ASSERT_EQ(1, histogram_proto2.bucket_size()); | |
59 EXPECT_FALSE(histogram_proto2.bucket(0).has_min()); | |
60 EXPECT_TRUE(histogram_proto2.bucket(0).has_max()); | |
61 EXPECT_EQ(0, histogram_proto2.bucket(0).min()); | |
62 EXPECT_EQ(3, histogram_proto2.bucket(0).max()); | |
63 EXPECT_EQ(1, histogram_proto2.bucket(0).count()); | |
64 } | |
65 | |
66 } // namespace cronet | |
OLD | NEW |