Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
|
Alexei Svitkine (slow)
2017/01/16 17:37:10
It's 2017 now!
tschumann
2017/01/16 17:58:37
Done. Happy new year ;-)
| |
| 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 { | |
|
Alexei Svitkine (slow)
2017/01/16 17:37:10
Nit: I don't think tests are usually put in an ano
tschumann
2017/01/16 17:58:37
interesting. It's actually considered good practic
| |
| 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 | |
| OLD | NEW |