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

Side by Side 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, 6 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/metrics/metrics_log.h" 5 #include "components/metrics/metrics_log.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <string> 10 #include <string>
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 406
407 TestMetricsServiceClient client; 407 TestMetricsServiceClient client;
408 client.set_product(kTestProduct); 408 client.set_product(kTestProduct);
409 TestMetricsLog log( 409 TestMetricsLog log(
410 kClientId, kSessionId, MetricsLog::ONGOING_LOG, &client, &prefs_); 410 kClientId, kSessionId, MetricsLog::ONGOING_LOG, &client, &prefs_);
411 // Check that the product is set to |kTestProduct|. 411 // Check that the product is set to |kTestProduct|.
412 EXPECT_TRUE(log.uma_proto().has_product()); 412 EXPECT_TRUE(log.uma_proto().has_product());
413 EXPECT_EQ(kTestProduct, log.uma_proto().product()); 413 EXPECT_EQ(kTestProduct, log.uma_proto().product());
414 } 414 }
415 415
416 TEST_F(MetricsLogTest, TruncateEvents) {
417 TestMetricsServiceClient client;
418 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG, &client,
419 &prefs_);
420
421 for (int i = 0; i < internal::kUserActionEventLimit * 2; ++i) {
422 log.RecordUserAction("BasicAction");
423 EXPECT_EQ(i + 1, log.uma_proto().user_action_event_size());
424 }
425
426 // Truncate, and check that the current size is the limit.
427 log.TruncateEvents();
428 EXPECT_EQ(internal::kUserActionEventLimit,
429 log.uma_proto().user_action_event_size());
430 }
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.
431
416 } // namespace metrics 432 } // namespace metrics
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698