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

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

Issue 2619203007: Log suggestion scores in 10 discrete buckets. (Closed)
Patch Set: fixed enum values 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 2017 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;
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.01f);
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), 0.0f);
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), 1.0f);
36 OnSuggestionShown(/*global_position=*/1,
37 Category::FromKnownCategory(KnownCategories::ARTICLES),
38 /*category_position=*/3, base::Time::Now(),
39 base::Time::Now() - base::TimeDelta::FromHours(2), 8.0f);
40
41 EXPECT_THAT(
42 histogram_tester.GetAllSamples(
43 "NewTabPage.ContentSuggestions.ShownScoreNormalized.Articles"),
44 ElementsAre(base::Bucket(/*min=*/0, /*count=*/1),
45 base::Bucket(/*min=*/1, /*count=*/1),
46 base::Bucket(/*min=*/10, /*count=*/1),
47 base::Bucket(/*min=*/11, /*count=*/1)));
48 }
49
50 } // namespace
51 } // namespace metrics
52 } // namespace ntp_snippets
OLDNEW
« no previous file with comments | « components/ntp_snippets/content_suggestions_metrics.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698