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

Side by Side Diff: chrome/browser/ui/webui/ntp/ntp_user_data_logger_unittest.cc

Issue 2429523002: Cleanup desktop NTP metrics recording (Closed)
Patch Set: . Created 4 years, 2 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
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/browser/ui/webui/ntp/ntp_user_data_logger.h" 5 #include "chrome/browser/ui/webui/ntp/ntp_user_data_logger.h"
6 6
7 #include "base/metrics/histogram_macros.h" 7 #include "base/metrics/histogram_macros.h"
8 #include "base/metrics/statistics_recorder.h" 8 #include "base/metrics/statistics_recorder.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/common/search/ntp_logging_events.h" 10 #include "chrome/common/search/ntp_logging_events.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 74
75 } // namespace 75 } // namespace
76 76
77 class NTPUserDataLoggerTest : public testing::Test { 77 class NTPUserDataLoggerTest : public testing::Test {
78 content::TestBrowserThreadBundle thread_bundle_; 78 content::TestBrowserThreadBundle thread_bundle_;
79 }; 79 };
80 80
81 TEST_F(NTPUserDataLoggerTest, TestNumberOfTiles) { 81 TEST_F(NTPUserDataLoggerTest, TestNumberOfTiles) {
82 base::StatisticsRecorder::Initialize(); 82 base::StatisticsRecorder::Initialize();
83 83
84 // Enusure non-zero statistics. 84 // Ensure non-zero statistics.
85 TestNTPUserDataLogger logger; 85 TestNTPUserDataLogger logger;
86 logger.ntp_url_ = GURL("chrome://newtab/"); 86 logger.ntp_url_ = GURL("chrome://newtab/");
87 87
88 base::TimeDelta delta = base::TimeDelta::FromMilliseconds(0); 88 base::TimeDelta delta = base::TimeDelta::FromMilliseconds(0);
89 89
90 for (int i = 0; i < 8; ++i) 90 for (int i = 0; i < 8; ++i)
91 logger.LogEvent(NTP_TILE, delta); 91 logger.LogEvent(NTP_SERVER_SIDE_SUGGESTION, delta);
92 logger.LogEvent(NTP_SERVER_SIDE_SUGGESTION, delta);
93 92
94 logger.LogEvent(NTP_ALL_TILES_LOADED, delta); 93 logger.LogEvent(NTP_ALL_TILES_LOADED, delta);
95 94
96 EXPECT_EQ(1, GetTotalCount("NewTabPage.NumberOfTiles")); 95 EXPECT_EQ(1, GetTotalCount("NewTabPage.NumberOfTiles"));
97 EXPECT_EQ(1, GetBinCount("NewTabPage.NumberOfTiles", 8)); 96 EXPECT_EQ(1, GetBinCount("NewTabPage.NumberOfTiles", 8));
98 97
99 // Statistics should be reset to 0, so we should not log anything else. 98 // Statistics should be reset to 0, so we should not log anything else.
100 logger.LogEvent(NTP_ALL_TILES_LOADED, delta); 99 logger.LogEvent(NTP_ALL_TILES_LOADED, delta);
101 EXPECT_EQ(1, GetTotalCount("NewTabPage.NumberOfTiles")); 100 EXPECT_EQ(1, GetTotalCount("NewTabPage.NumberOfTiles"));
102 101
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 200
202 // Navigations always increase. 201 // Navigations always increase.
203 logger.LogMostVisitedNavigation(1, NTPLoggingTileSource::SERVER); 202 logger.LogMostVisitedNavigation(1, NTPLoggingTileSource::SERVER);
204 logger.LogMostVisitedNavigation(2, NTPLoggingTileSource::CLIENT); 203 logger.LogMostVisitedNavigation(2, NTPLoggingTileSource::CLIENT);
205 logger.LogMostVisitedNavigation(3, NTPLoggingTileSource::SERVER); 204 logger.LogMostVisitedNavigation(3, NTPLoggingTileSource::SERVER);
206 logger.LogMostVisitedNavigation(4, NTPLoggingTileSource::CLIENT); 205 logger.LogMostVisitedNavigation(4, NTPLoggingTileSource::CLIENT);
207 EXPECT_THAT(TotalNavigations({1, 2, 3, 4}), ElementsAre(2, 2, 2, 2)); 206 EXPECT_THAT(TotalNavigations({1, 2, 3, 4}), ElementsAre(2, 2, 2, 2));
208 EXPECT_THAT(ServerNavigations({1, 2, 3, 4}), ElementsAre(2, 1, 1, 0)); 207 EXPECT_THAT(ServerNavigations({1, 2, 3, 4}), ElementsAre(2, 1, 1, 0));
209 EXPECT_THAT(ClientNavigations({1, 2, 3, 4}), ElementsAre(0, 1, 1, 2)); 208 EXPECT_THAT(ClientNavigations({1, 2, 3, 4}), ElementsAre(0, 1, 1, 2));
210 } 209 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/ntp/ntp_user_data_logger.cc ('k') | chrome/common/search/ntp_logging_events.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698