Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(965)

Side by Side Diff: components/metrics/histogram_manager_unittest.cc

Issue 794493002: Add UMA Histogram Manager to Cronet. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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(data.data(), data.size()));
24 EXPECT_LT(0u, data.size());
25
26 const HistogramEventProto& histogram_proto =
27 uma_proto.histogram_event(uma_proto.histogram_event_size() - 1);
28 ASSERT_EQ(1, histogram_proto.bucket_size());
29 EXPECT_FALSE(histogram_proto.bucket(0).has_min());
30 EXPECT_TRUE(histogram_proto.bucket(0).has_max());
31 EXPECT_EQ(0, histogram_proto.bucket(0).min());
32 EXPECT_EQ(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 = HistogramManager::GetInstance()->GetDeltas();
37 EXPECT_LT(0u, data2.size());
38 ChromeUserMetricsExtension uma_proto2;
39 EXPECT_TRUE(uma_proto2.ParseFromArray(data2.data(), 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_FALSE(histogram_proto2.bucket(0).has_min());
46 EXPECT_TRUE(histogram_proto2.bucket(0).has_max());
47 EXPECT_EQ(0, histogram_proto2.bucket(0).min());
48 EXPECT_EQ(3, histogram_proto2.bucket(0).max());
49 EXPECT_EQ(1, histogram_proto2.bucket(0).count());
50 }
51
52 } // namespace metrics
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698