OLD | NEW |
---|---|
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 Loading... | |
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 |
OLD | NEW |