OLD | NEW |
| (Empty) |
1 // Copyright (c) 2012 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 "chrome/browser/sync/util/data_type_histogram.h" | |
6 | |
7 #include "base/time.h" | |
8 #include "testing/gtest/include/gtest/gtest.h" | |
9 | |
10 namespace browser_sync { | |
11 namespace { | |
12 | |
13 class DataTypeHistogramTest : public testing::Test { | |
14 }; | |
15 | |
16 // Create a histogram of type HISTOGRAM_COUNTS for each model type. Nothing | |
17 // should break. | |
18 TEST(DataTypeHistogramTest, BasicCount) { | |
19 for (int i = syncable::FIRST_REAL_MODEL_TYPE; | |
20 i <= syncable::LAST_REAL_MODEL_TYPE; ++i) { | |
21 syncable::ModelType type = syncable::ModelTypeFromInt(i); | |
22 #define PER_DATA_TYPE_MACRO(type_str) \ | |
23 HISTOGRAM_COUNTS("Prefix" type_str "Suffix", 1); | |
24 SYNC_DATA_TYPE_HISTOGRAM(type); | |
25 #undef PER_DATA_TYPE_MACRO | |
26 } | |
27 } | |
28 | |
29 // Create a histogram of type SYNC_FREQ_HISTOGRAM for each model type. Nothing | |
30 // should break. | |
31 TEST(DataTypeHistogramTest, BasicFreq) { | |
32 for (int i = syncable::FIRST_REAL_MODEL_TYPE; | |
33 i <= syncable::LAST_REAL_MODEL_TYPE; ++i) { | |
34 syncable::ModelType type = syncable::ModelTypeFromInt(i); | |
35 #define PER_DATA_TYPE_MACRO(type_str) \ | |
36 SYNC_FREQ_HISTOGRAM("Prefix" type_str "Suffix", \ | |
37 base::TimeDelta::FromSeconds(1)); | |
38 SYNC_DATA_TYPE_HISTOGRAM(type); | |
39 #undef PER_DATA_TYPE_MACRO | |
40 } | |
41 } | |
42 | |
43 // Create a histogram of type UMA_HISTOGRAM_ENUMERATION for each model type. | |
44 // Nothing should break. | |
45 TEST(DataTypeHistogramTest, BasicEnum) { | |
46 enum HistTypes { | |
47 TYPE_1, | |
48 TYPE_2, | |
49 TYPE_COUNT, | |
50 }; | |
51 for (int i = syncable::FIRST_REAL_MODEL_TYPE; | |
52 i <= syncable::LAST_REAL_MODEL_TYPE; ++i) { | |
53 syncable::ModelType type = syncable::ModelTypeFromInt(i); | |
54 #define PER_DATA_TYPE_MACRO(type_str) \ | |
55 UMA_HISTOGRAM_ENUMERATION("Prefix" type_str "Suffix", \ | |
56 (i % 2 ? TYPE_1 : TYPE_2), TYPE_COUNT); | |
57 SYNC_DATA_TYPE_HISTOGRAM(type); | |
58 #undef PER_DATA_TYPE_MACRO | |
59 } | |
60 } | |
61 | |
62 } // namespace | |
63 } // namespace browser_sync | |
OLD | NEW |