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

Side by Side Diff: components/ntp_snippets/content_suggestions_metrics_unittest.cc

Issue 2619203007: Log suggestion scores in 10 discrete buckets. (Closed)
Patch Set: Created 3 years, 11 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "components/ntp_snippets/content_suggestions_metrics.h"
6
7 #include "base/test/histogram_tester.h"
8 #include "base/time/time.h"
9 #include "components/ntp_snippets/category.h"
10 #include "testing/gmock/include/gmock/gmock.h"
11 #include "testing/gtest/include/gtest/gtest.h"
12
13 namespace ntp_snippets {
14 namespace metrics {
15 namespace {
16
17 using testing::ElementsAre;
18
19 TEST(ContentSuggestionsMetricsTest, ShouldLogOnSuggestionsShown) {
20 base::HistogramTester histogram_tester;
jkrcal 2017/01/10 19:31:47 Yay for increasing test coverage! And thanks for l
21 OnSuggestionShown(/*global_position=*/1,
22 Category::FromKnownCategory(KnownCategories::ARTICLES),
23 /*category_position=*/3,
24 base::Time::Now(),
25 base::Time::Now() - base::TimeDelta::FromHours(2),
26 0.01);
27 // Test corner cases for score.
28 OnSuggestionShown(/*global_position=*/1,
29 Category::FromKnownCategory(KnownCategories::ARTICLES),
30 /*category_position=*/3, base::Time::Now(),
31 base::Time::Now() - base::TimeDelta::FromHours(2), 1.0);
32 OnSuggestionShown(/*global_position=*/1,
33 Category::FromKnownCategory(KnownCategories::ARTICLES),
34 /*category_position=*/3, base::Time::Now(),
35 base::Time::Now() - base::TimeDelta::FromHours(2), 8.0);
36
37 EXPECT_THAT(histogram_tester.GetAllSamples(
38 "NewTabPage.ContentSuggestions.ShownScore.Articles"),
39 ElementsAre(base::Bucket(/*min=*/1, /*count=*/1),
40 base::Bucket(/*min=*/10, /*count=*/1),
41 base::Bucket(/*min=*/11, /*count=*/1)));
42 }
43
44 } // namespace
45 } // namespace metrics
46 } // namespace ntp_snippets
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698