| Index: components/ntp_snippets/content_suggestions_metrics_unittest.cc
|
| diff --git a/components/ntp_snippets/content_suggestions_metrics_unittest.cc b/components/ntp_snippets/content_suggestions_metrics_unittest.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..65963c9d6eef5aa4541c99bb302c6ae2e26d339e
|
| --- /dev/null
|
| +++ b/components/ntp_snippets/content_suggestions_metrics_unittest.cc
|
| @@ -0,0 +1,52 @@
|
| +// Copyright 2016 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "components/ntp_snippets/content_suggestions_metrics.h"
|
| +
|
| +#include "base/test/histogram_tester.h"
|
| +#include "base/time/time.h"
|
| +#include "components/ntp_snippets/category.h"
|
| +#include "testing/gmock/include/gmock/gmock.h"
|
| +#include "testing/gtest/include/gtest/gtest.h"
|
| +
|
| +namespace ntp_snippets {
|
| +namespace metrics {
|
| +namespace {
|
| +
|
| +using testing::ElementsAre;
|
| +
|
| +TEST(ContentSuggestionsMetricsTest, ShouldLogOnSuggestionsShown) {
|
| + base::HistogramTester histogram_tester;
|
| + OnSuggestionShown(/*global_position=*/1,
|
| + Category::FromKnownCategory(KnownCategories::ARTICLES),
|
| + /*category_position=*/3,
|
| + base::Time::Now(),
|
| + base::Time::Now() - base::TimeDelta::FromHours(2),
|
| + 0.01);
|
| + // Test corner cases for score.
|
| + OnSuggestionShown(/*global_position=*/1,
|
| + Category::FromKnownCategory(KnownCategories::ARTICLES),
|
| + /*category_position=*/3, base::Time::Now(),
|
| + base::Time::Now() - base::TimeDelta::FromHours(2), 0.0);
|
| + OnSuggestionShown(/*global_position=*/1,
|
| + Category::FromKnownCategory(KnownCategories::ARTICLES),
|
| + /*category_position=*/3, base::Time::Now(),
|
| + base::Time::Now() - base::TimeDelta::FromHours(2), 1.0);
|
| + OnSuggestionShown(/*global_position=*/1,
|
| + Category::FromKnownCategory(KnownCategories::ARTICLES),
|
| + /*category_position=*/3, base::Time::Now(),
|
| + base::Time::Now() - base::TimeDelta::FromHours(2), 8.0);
|
| +
|
| + EXPECT_THAT(
|
| + histogram_tester.GetAllSamples(
|
| + "NewTabPage.ContentSuggestions.ShownScoreNormalized.Articles"),
|
| + ElementsAre(base::Bucket(/*min=*/0, /*count=*/1),
|
| + base::Bucket(/*min=*/1, /*count=*/1),
|
| + base::Bucket(/*min=*/10, /*count=*/1),
|
| + base::Bucket(/*min=*/11, /*count=*/1)));
|
| +}
|
| +
|
| +} // namespace
|
| +} // namespace metrics
|
| +} // namespace ntp_snippets
|
|
|