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

Side by Side Diff: components/sync/base/data_type_histogram_unittest.cc

Issue 2130453004: [Sync] Move //sync to //components/sync. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 4 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
« no previous file with comments | « components/sync/base/data_type_histogram.cc ('k') | components/sync/base/encryptor.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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 "sync/util/data_type_histogram.h" 5 #include "components/sync/base/data_type_histogram.h"
6 6
7 #include "base/metrics/statistics_recorder.h" 7 #include "base/metrics/statistics_recorder.h"
8 #include "base/time/time.h" 8 #include "base/time/time.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
11 namespace syncer { 11 namespace syncer {
12 namespace { 12 namespace {
13 13
14 class DataTypeHistogramTest : public testing::Test { 14 class DataTypeHistogramTest : public testing::Test {
15 public: 15 public:
16 void SetUp() override { 16 void SetUp() override { base::StatisticsRecorder::Initialize(); }
17 base::StatisticsRecorder::Initialize();
18 }
19 }; 17 };
20 18
21 // Create a histogram of type LOCAL_HISTOGRAM_COUNTS for each model type. 19 // Create a histogram of type LOCAL_HISTOGRAM_COUNTS for each model type.
22 // Nothing should break. 20 // Nothing should break.
23 TEST(DataTypeHistogramTest, BasicCount) { 21 TEST(DataTypeHistogramTest, BasicCount) {
24 for (int i = FIRST_REAL_MODEL_TYPE; i <= LAST_REAL_MODEL_TYPE; ++i) { 22 for (int i = FIRST_REAL_MODEL_TYPE; i <= LAST_REAL_MODEL_TYPE; ++i) {
25 ModelType type = ModelTypeFromInt(i); 23 ModelType type = ModelTypeFromInt(i);
26 #define PER_DATA_TYPE_MACRO(type_str) \ 24 #define PER_DATA_TYPE_MACRO(type_str) \
27 LOCAL_HISTOGRAM_COUNTS("BasicCountPrefix" type_str "Suffix", 1); 25 LOCAL_HISTOGRAM_COUNTS("BasicCountPrefix" type_str "Suffix", 1);
28 SYNC_DATA_TYPE_HISTOGRAM(type); 26 SYNC_DATA_TYPE_HISTOGRAM(type);
29 #undef PER_DATA_TYPE_MACRO 27 #undef PER_DATA_TYPE_MACRO
30 } 28 }
31 } 29 }
32 30
33 // Create a histogram of type SYNC_FREQ_HISTOGRAM for each model type. Nothing 31 // Create a histogram of type SYNC_FREQ_HISTOGRAM for each model type. Nothing
34 // should break. 32 // should break.
35 TEST(DataTypeHistogramTest, BasicFreq) { 33 TEST(DataTypeHistogramTest, BasicFreq) {
36 for (int i = FIRST_REAL_MODEL_TYPE; i <= LAST_REAL_MODEL_TYPE; ++i) { 34 for (int i = FIRST_REAL_MODEL_TYPE; i <= LAST_REAL_MODEL_TYPE; ++i) {
37 ModelType type = ModelTypeFromInt(i); 35 ModelType type = ModelTypeFromInt(i);
38 #define PER_DATA_TYPE_MACRO(type_str) \ 36 #define PER_DATA_TYPE_MACRO(type_str) \
39 SYNC_FREQ_HISTOGRAM("BasicFreqPrefix" type_str "Suffix", \ 37 SYNC_FREQ_HISTOGRAM("BasicFreqPrefix" type_str "Suffix", \
40 base::TimeDelta::FromSeconds(1)); 38 base::TimeDelta::FromSeconds(1));
41 SYNC_DATA_TYPE_HISTOGRAM(type); 39 SYNC_DATA_TYPE_HISTOGRAM(type);
42 #undef PER_DATA_TYPE_MACRO 40 #undef PER_DATA_TYPE_MACRO
43 } 41 }
44 } 42 }
45 43
46 // Create a histogram of type UMA_HISTOGRAM_ENUMERATION for each model type. 44 // Create a histogram of type UMA_HISTOGRAM_ENUMERATION for each model type.
47 // Nothing should break. 45 // Nothing should break.
48 TEST(DataTypeHistogramTest, BasicEnum) { 46 TEST(DataTypeHistogramTest, BasicEnum) {
49 enum HistTypes { 47 enum HistTypes {
50 TYPE_1, 48 TYPE_1,
51 TYPE_2, 49 TYPE_2,
52 TYPE_COUNT, 50 TYPE_COUNT,
53 }; 51 };
54 for (int i = FIRST_REAL_MODEL_TYPE; i <= LAST_REAL_MODEL_TYPE; ++i) { 52 for (int i = FIRST_REAL_MODEL_TYPE; i <= LAST_REAL_MODEL_TYPE; ++i) {
55 ModelType type = ModelTypeFromInt(i); 53 ModelType type = ModelTypeFromInt(i);
56 #define PER_DATA_TYPE_MACRO(type_str) \ 54 #define PER_DATA_TYPE_MACRO(type_str) \
57 UMA_HISTOGRAM_ENUMERATION("BasicEnumPrefix" type_str "Suffix", \ 55 UMA_HISTOGRAM_ENUMERATION("BasicEnumPrefix" type_str "Suffix", \
58 (i % 2 ? TYPE_1 : TYPE_2), TYPE_COUNT); 56 (i % 2 ? TYPE_1 : TYPE_2), TYPE_COUNT);
59 SYNC_DATA_TYPE_HISTOGRAM(type); 57 SYNC_DATA_TYPE_HISTOGRAM(type);
60 #undef PER_DATA_TYPE_MACRO 58 #undef PER_DATA_TYPE_MACRO
61 } 59 }
62 } 60 }
63 61
64 } // namespace 62 } // namespace
65 } // namespace syncer 63 } // namespace syncer
OLDNEW
« no previous file with comments | « components/sync/base/data_type_histogram.cc ('k') | components/sync/base/encryptor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698