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

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: today extension 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
« no previous file with comments | « components/metrics/metrics_log.cc ('k') | components/metrics/metrics_service.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..8a1c6bc158a3661c791df8018e4f27e0d7de657c 100644
--- a/components/metrics/metrics_log_unittest.cc
+++ b/components/metrics/metrics_log_unittest.cc
@@ -74,6 +74,10 @@ class TestMetricsLog : public MetricsLog {
return *MetricsLog::uma_proto();
}
+ ChromeUserMetricsExtension* mutable_uma_proto() {
+ return MetricsLog::uma_proto();
+ }
+
const SystemProfileProto& system_profile() const {
return uma_proto().system_profile();
}
@@ -413,4 +417,27 @@ 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());
+ }
+ for (int i = 0; i < internal::kOmniboxEventLimit * 2; ++i) {
+ // Add an empty omnibox event. Not fully realistic since these are normally
+ // supplied by a metrics provider.
+ log.mutable_uma_proto()->add_omnibox_event();
+ EXPECT_EQ(i + 1, log.uma_proto().omnibox_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());
+ EXPECT_EQ(internal::kOmniboxEventLimit, log.uma_proto().omnibox_event_size());
+}
+
} // namespace metrics
« no previous file with comments | « components/metrics/metrics_log.cc ('k') | components/metrics/metrics_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698