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

Unified Diff: components/metrics/metrics_log_unittest.cc

Issue 2910023003: Change the logic for discarding all non-histogram logs because of actions/omnibox events to truncat… (Closed)
Patch Set: fix comment Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: components/metrics/metrics_log_unittest.cc
diff --git a/components/metrics/metrics_log_unittest.cc b/components/metrics/metrics_log_unittest.cc
index f1a7792f85d45bb5996b2eb9ee808ddde54bf286..bb163d6541a92686487a43659102e3324807227c 100644
--- a/components/metrics/metrics_log_unittest.cc
+++ b/components/metrics/metrics_log_unittest.cc
@@ -413,4 +413,20 @@ TEST_F(MetricsLogTest, ProductSetIfNotDefault) {
EXPECT_EQ(kTestProduct, log.uma_proto().product());
}
+TEST_F(MetricsLogTest, TruncateEvents) {
+ TestMetricsServiceClient client;
+ TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG, &client,
+ &prefs_);
+
+ for (int i = 0; i < internal::kUserActionEventLimit * 2; ++i) {
+ log.RecordUserAction("BasicAction");
+ EXPECT_EQ(i + 1, log.uma_proto().user_action_event_size());
+ }
+
+ // Truncate, and check that the current size is the limit.
+ log.TruncateEvents();
+ EXPECT_EQ(internal::kUserActionEventLimit,
+ log.uma_proto().user_action_event_size());
+}
Alexei Svitkine (slow) 2017/05/30 21:57:00 Nit: Add one for omnibox events too. You can just
rkaplow 2017/05/31 15:17:06 Done.
+
} // namespace metrics

Powered by Google App Engine
This is Rietveld 408576698