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

Side by Side Diff: components/ntp_tiles/metrics_unittest.cc

Issue 2671983002: ntp_tiles: Add UMA histograms to correlate icon type to position (Closed)
Patch Set: Adopted histogram suffixes. Created 3 years, 10 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/ntp_tiles/metrics.cc ('k') | tools/metrics/histograms/histograms.xml » ('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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/ntp_tiles/metrics.h" 5 #include "components/ntp_tiles/metrics.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 ElementsAre(base::Bucket(/*min=*/ICON_REAL, /*count=*/3), 71 ElementsAre(base::Bucket(/*min=*/ICON_REAL, /*count=*/3),
72 base::Bucket(/*min=*/ICON_COLOR, /*count=*/2))); 72 base::Bucket(/*min=*/ICON_COLOR, /*count=*/2)));
73 EXPECT_THAT(histogram_tester.GetAllSamples("NewTabPage.TileType.popular"), 73 EXPECT_THAT(histogram_tester.GetAllSamples("NewTabPage.TileType.popular"),
74 ElementsAre(base::Bucket(/*min=*/ICON_COLOR, /*count=*/1))); 74 ElementsAre(base::Bucket(/*min=*/ICON_COLOR, /*count=*/1)));
75 EXPECT_THAT(histogram_tester.GetAllSamples("NewTabPage.IconsReal"), 75 EXPECT_THAT(histogram_tester.GetAllSamples("NewTabPage.IconsReal"),
76 ElementsAre(base::Bucket(/*min=*/4, /*count=*/1))); 76 ElementsAre(base::Bucket(/*min=*/4, /*count=*/1)));
77 EXPECT_THAT(histogram_tester.GetAllSamples("NewTabPage.IconsColor"), 77 EXPECT_THAT(histogram_tester.GetAllSamples("NewTabPage.IconsColor"),
78 ElementsAre(base::Bucket(/*min=*/3, /*count=*/1))); 78 ElementsAre(base::Bucket(/*min=*/3, /*count=*/1)));
79 EXPECT_THAT(histogram_tester.GetAllSamples("NewTabPage.IconsGray"), 79 EXPECT_THAT(histogram_tester.GetAllSamples("NewTabPage.IconsGray"),
80 ElementsAre(base::Bucket(/*min=*/1, /*count=*/1))); 80 ElementsAre(base::Bucket(/*min=*/1, /*count=*/1)));
81 EXPECT_THAT(histogram_tester.GetAllSamples(
82 "NewTabPage.SuggestionsImpression.IconsReal"),
83 ElementsAre(base::Bucket(/*min=*/0, /*count=*/1),
84 base::Bucket(/*min=*/1, /*count=*/1),
85 base::Bucket(/*min=*/2, /*count=*/1),
86 base::Bucket(/*min=*/5, /*count=*/1)));
87 EXPECT_THAT(histogram_tester.GetAllSamples(
88 "NewTabPage.SuggestionsImpression.IconsColor"),
89 ElementsAre(base::Bucket(/*min=*/3, /*count=*/1),
90 base::Bucket(/*min=*/4, /*count=*/1),
91 base::Bucket(/*min=*/7, /*count=*/1)));
92 EXPECT_THAT(histogram_tester.GetAllSamples(
93 "NewTabPage.SuggestionsImpression.IconsGray"),
94 ElementsAre(base::Bucket(/*min=*/6, /*count=*/1)));
81 } 95 }
82 96
83 TEST(RecordPageImpressionTest, ShouldRecordUmaForThumbnails) { 97 TEST(RecordPageImpressionTest, ShouldRecordUmaForThumbnails) {
84 base::HistogramTester histogram_tester; 98 base::HistogramTester histogram_tester;
85 RecordPageImpression({{NTPTileSource::TOP_SITES, THUMBNAIL, GURL()}, 99 RecordPageImpression({{NTPTileSource::TOP_SITES, THUMBNAIL, GURL()},
86 {NTPTileSource::SUGGESTIONS_SERVICE, THUMBNAIL, GURL()}, 100 {NTPTileSource::SUGGESTIONS_SERVICE, THUMBNAIL, GURL()},
87 {NTPTileSource::POPULAR, THUMBNAIL, GURL()}}, 101 {NTPTileSource::POPULAR, THUMBNAIL, GURL()}},
88 /*rappor_service=*/nullptr); 102 /*rappor_service=*/nullptr);
89 EXPECT_THAT(histogram_tester.GetAllSamples("NewTabPage.NumberOfTiles"), 103 EXPECT_THAT(histogram_tester.GetAllSamples("NewTabPage.NumberOfTiles"),
90 ElementsAre(base::Bucket(/*min=*/3, /*count=*/1))); 104 ElementsAre(base::Bucket(/*min=*/3, /*count=*/1)));
(...skipping 17 matching lines...) Expand all
108 EXPECT_THAT(histogram_tester.GetAllSamples("NewTabPage.TileType.client"), 122 EXPECT_THAT(histogram_tester.GetAllSamples("NewTabPage.TileType.client"),
109 IsEmpty()); 123 IsEmpty());
110 EXPECT_THAT(histogram_tester.GetAllSamples("NewTabPage.TileType.popular"), 124 EXPECT_THAT(histogram_tester.GetAllSamples("NewTabPage.TileType.popular"),
111 IsEmpty()); 125 IsEmpty());
112 EXPECT_THAT(histogram_tester.GetAllSamples("NewTabPage.IconsReal"), 126 EXPECT_THAT(histogram_tester.GetAllSamples("NewTabPage.IconsReal"),
113 IsEmpty()); 127 IsEmpty());
114 EXPECT_THAT(histogram_tester.GetAllSamples("NewTabPage.IconsColor"), 128 EXPECT_THAT(histogram_tester.GetAllSamples("NewTabPage.IconsColor"),
115 IsEmpty()); 129 IsEmpty());
116 EXPECT_THAT(histogram_tester.GetAllSamples("NewTabPage.IconsGray"), 130 EXPECT_THAT(histogram_tester.GetAllSamples("NewTabPage.IconsGray"),
117 IsEmpty()); 131 IsEmpty());
132 EXPECT_THAT(histogram_tester.GetAllSamples(
133 "NewTabPage.SuggestionsImpression.IconsReal"),
134 IsEmpty());
135 EXPECT_THAT(histogram_tester.GetAllSamples(
136 "NewTabPage.SuggestionsImpression.IconsColor"),
137 IsEmpty());
138 EXPECT_THAT(histogram_tester.GetAllSamples(
139 "NewTabPage.SuggestionsImpression.IconsGray"),
140 IsEmpty());
141 }
142
143 TEST(RecordTileClickTest, ShouldRecordUma) {
144 base::HistogramTester histogram_tester;
145 RecordTileClick(3, NTPTileSource::TOP_SITES, ICON_REAL);
146 EXPECT_THAT(histogram_tester.GetAllSamples("NewTabPage.MostVisited.client"),
147 ElementsAre(base::Bucket(/*min=*/3, /*count=*/1)));
148 EXPECT_THAT(histogram_tester.GetAllSamples("NewTabPage.MostVisited.server"),
149 IsEmpty());
150 EXPECT_THAT(histogram_tester.GetAllSamples("NewTabPage.MostVisited.popular"),
151 IsEmpty());
152 EXPECT_THAT(
153 histogram_tester.GetAllSamples("NewTabPage.MostVisited.IconsReal"),
154 ElementsAre(base::Bucket(/*min=*/3, /*count=*/1)));
155 EXPECT_THAT(
156 histogram_tester.GetAllSamples("NewTabPage.MostVisited.IconsColor"),
157 IsEmpty());
158 EXPECT_THAT(
159 histogram_tester.GetAllSamples("NewTabPage.MostVisited.IconsGray"),
160 IsEmpty());
161 }
162
163 TEST(RecordTileClickTest, ShouldIgnoreThumbnails) {
164 base::HistogramTester histogram_tester;
165 RecordTileClick(3, NTPTileSource::TOP_SITES, THUMBNAIL);
166 EXPECT_THAT(
167 histogram_tester.GetAllSamples("NewTabPage.MostVisited.IconsReal"),
168 IsEmpty());
169 EXPECT_THAT(
170 histogram_tester.GetAllSamples("NewTabPage.MostVisited.IconsColor"),
171 IsEmpty());
172 EXPECT_THAT(
173 histogram_tester.GetAllSamples("NewTabPage.MostVisited.IconsGray"),
174 IsEmpty());
118 } 175 }
119 176
120 TEST(RecordPageImpressionTest, ShouldRecordRappor) { 177 TEST(RecordPageImpressionTest, ShouldRecordRappor) {
121 rappor::TestRapporServiceImpl rappor_service; 178 rappor::TestRapporServiceImpl rappor_service;
122 179
123 RecordPageImpression( 180 RecordPageImpression(
124 {{NTPTileSource::TOP_SITES, ICON_REAL, GURL("http://www.site1.com/")}, 181 {{NTPTileSource::TOP_SITES, ICON_REAL, GURL("http://www.site1.com/")},
125 {NTPTileSource::TOP_SITES, ICON_COLOR, GURL("http://www.site2.com/")}, 182 {NTPTileSource::TOP_SITES, ICON_COLOR, GURL("http://www.site2.com/")},
126 {NTPTileSource::TOP_SITES, ICON_DEFAULT, GURL("http://www.site3.com/")}, 183 {NTPTileSource::TOP_SITES, ICON_DEFAULT, GURL("http://www.site3.com/")},
127 {NTPTileSource::TOP_SITES, THUMBNAIL, GURL("http://www.site4.com/")}}, 184 {NTPTileSource::TOP_SITES, THUMBNAIL, GURL("http://www.site4.com/")}},
(...skipping 26 matching lines...) Expand all
154 EXPECT_TRUE(rappor_service.GetRecordedSampleForMetric( 211 EXPECT_TRUE(rappor_service.GetRecordedSampleForMetric(
155 "NTP.SuggestionsImpressions.IconsGray", &sample, &type)); 212 "NTP.SuggestionsImpressions.IconsGray", &sample, &type));
156 EXPECT_EQ("site3.com", sample); 213 EXPECT_EQ("site3.com", sample);
157 EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type); 214 EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type);
158 } 215 }
159 } 216 }
160 217
161 } // namespace 218 } // namespace
162 } // namespace metrics 219 } // namespace metrics
163 } // namespace ntp_tiles 220 } // namespace ntp_tiles
OLDNEW
« no previous file with comments | « components/ntp_tiles/metrics.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698