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

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

Issue 1075503002: Move histogram_manager from components/metrics to components/cronet (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Enable HistogramManager test. Created 5 years, 8 months 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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/histogram_manager.h" 5 #include "components/cronet/histogram_manager.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/metrics/statistics_recorder.h"
10 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
11 12
12 namespace metrics { 13 namespace metrics {
13 14
14 // TODO(mef): crbug.com/441441. Move components/metrics/histogram_manager.*
15 // files into components/android/cronet.
16 // TODO(rtenneti): enable flaky HistogramBucketFields unit test. 15 // TODO(rtenneti): enable flaky HistogramBucketFields unit test.
17 TEST(HistogramManager, DISABLED_HistogramBucketFields) { 16 TEST(HistogramManager, HistogramBucketFields) {
17 base::StatisticsRecorder::Initialize();
mef 2015/04/08 19:51:28 I've added StatisticsRecorder::Initialize() and re
18 // Capture histograms at the start of the test to avoid later GetDeltas() 18 // Capture histograms at the start of the test to avoid later GetDeltas()
19 // calls picking them up. 19 // calls picking them up.
20 std::vector<uint8> data_init; 20 std::vector<uint8> data_init;
21 HistogramManager::GetInstance()->GetDeltas(&data_init); 21 HistogramManager::GetInstance()->GetDeltas(&data_init);
22 22
23 // kNoFlags filter should record all histograms. 23 // kNoFlags filter should record all histograms.
24 UMA_HISTOGRAM_ENUMERATION("UmaHistogramManager", 1, 2); 24 UMA_HISTOGRAM_ENUMERATION("UmaHistogramManager", 1, 2);
mef 2015/04/08 19:51:27 using LOCAL_HISTOGRAM_ENUMERATION results in empty
25 25
26 std::vector<uint8> data; 26 std::vector<uint8> data;
27 EXPECT_TRUE(HistogramManager::GetInstance()->GetDeltas(&data)); 27 EXPECT_TRUE(HistogramManager::GetInstance()->GetDeltas(&data));
28 EXPECT_FALSE(data.empty()); 28 EXPECT_FALSE(data.empty());
29 ChromeUserMetricsExtension uma_proto; 29 ChromeUserMetricsExtension uma_proto;
30 EXPECT_TRUE(uma_proto.ParseFromArray( 30 EXPECT_TRUE(uma_proto.ParseFromArray(
31 reinterpret_cast<const char*>(&data[0]), data.size())); 31 reinterpret_cast<const char*>(&data[0]), data.size()));
32 EXPECT_FALSE(data.empty()); 32 EXPECT_FALSE(data.empty());
33 33
34 const HistogramEventProto& histogram_proto = 34 const HistogramEventProto& histogram_proto =
(...skipping 14 matching lines...) Expand all
49 49
50 const HistogramEventProto& histogram_proto2 = 50 const HistogramEventProto& histogram_proto2 =
51 uma_proto2.histogram_event(uma_proto2.histogram_event_size() - 1); 51 uma_proto2.histogram_event(uma_proto2.histogram_event_size() - 1);
52 ASSERT_EQ(1, histogram_proto2.bucket_size()); 52 ASSERT_EQ(1, histogram_proto2.bucket_size());
53 EXPECT_LE(0, histogram_proto2.bucket(0).min()); 53 EXPECT_LE(0, histogram_proto2.bucket(0).min());
54 EXPECT_LE(3, histogram_proto2.bucket(0).max()); 54 EXPECT_LE(3, histogram_proto2.bucket(0).max());
55 EXPECT_EQ(1, histogram_proto2.bucket(0).count()); 55 EXPECT_EQ(1, histogram_proto2.bucket(0).count());
56 } 56 }
57 57
58 } // namespace metrics 58 } // namespace metrics
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698