| 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 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 log.RecordEnvironment(metrics_providers.get(), | 381 log.RecordEnvironment(metrics_providers.get(), |
| 382 std::vector<variations::ActiveGroupId>(), kInstallDate, | 382 std::vector<variations::ActiveGroupId>(), kInstallDate, |
| 383 kEnabledDate); | 383 kEnabledDate); |
| 384 log.RecordStabilityMetrics(metrics_providers.get(), base::TimeDelta(), | 384 log.RecordStabilityMetrics(metrics_providers.get(), base::TimeDelta(), |
| 385 base::TimeDelta()); | 385 base::TimeDelta()); |
| 386 const SystemProfileProto_Stability& stability = | 386 const SystemProfileProto_Stability& stability = |
| 387 log.system_profile().stability(); | 387 log.system_profile().stability(); |
| 388 // Required metrics: | 388 // Required metrics: |
| 389 EXPECT_TRUE(stability.has_launch_count()); | 389 EXPECT_TRUE(stability.has_launch_count()); |
| 390 EXPECT_TRUE(stability.has_crash_count()); | 390 EXPECT_TRUE(stability.has_crash_count()); |
| 391 // Initial log metrics: | 391 // Initial log metrics: only expected if non-zero. |
| 392 EXPECT_TRUE(stability.has_incomplete_shutdown_count()); | 392 EXPECT_FALSE(stability.has_incomplete_shutdown_count()); |
| 393 EXPECT_TRUE(stability.has_breakpad_registration_success_count()); | 393 EXPECT_FALSE(stability.has_breakpad_registration_success_count()); |
| 394 EXPECT_TRUE(stability.has_breakpad_registration_failure_count()); | 394 EXPECT_FALSE(stability.has_breakpad_registration_failure_count()); |
| 395 EXPECT_TRUE(stability.has_debugger_present_count()); | 395 EXPECT_FALSE(stability.has_debugger_present_count()); |
| 396 EXPECT_TRUE(stability.has_debugger_not_present_count()); | 396 EXPECT_FALSE(stability.has_debugger_not_present_count()); |
| 397 | 397 |
| 398 // The test provider should have been called upon to provide initial | 398 // The test provider should have been called upon to provide initial |
| 399 // stability and regular stability metrics. | 399 // stability and regular stability metrics. |
| 400 EXPECT_TRUE(test_provider->provide_initial_stability_metrics_called()); | 400 EXPECT_TRUE(test_provider->provide_initial_stability_metrics_called()); |
| 401 EXPECT_TRUE(test_provider->provide_stability_metrics_called()); | 401 EXPECT_TRUE(test_provider->provide_stability_metrics_called()); |
| 402 } | 402 } |
| 403 | 403 |
| 404 TEST_F(MetricsLogTest, OngoingLogStabilityMetrics) { | 404 TEST_F(MetricsLogTest, OngoingLogStabilityMetrics) { |
| 405 TestMetricsServiceClient client; | 405 TestMetricsServiceClient client; |
| 406 TestMetricsLog log( | 406 TestMetricsLog log( |
| 407 kClientId, kSessionId, MetricsLog::ONGOING_LOG, &client, &prefs_); | 407 kClientId, kSessionId, MetricsLog::ONGOING_LOG, &client, &prefs_); |
| 408 TestMetricsProvider* test_provider = new TestMetricsProvider(); | 408 TestMetricsProvider* test_provider = new TestMetricsProvider(); |
| 409 ScopedVector<MetricsProvider> metrics_providers; | 409 ScopedVector<MetricsProvider> metrics_providers; |
| 410 metrics_providers.push_back(test_provider); | 410 metrics_providers.push_back(test_provider); |
| 411 log.RecordEnvironment(metrics_providers.get(), | 411 log.RecordEnvironment(metrics_providers.get(), |
| 412 std::vector<variations::ActiveGroupId>(), kInstallDate, | 412 std::vector<variations::ActiveGroupId>(), kInstallDate, |
| 413 kEnabledDate); | 413 kEnabledDate); |
| 414 log.RecordStabilityMetrics(metrics_providers.get(), base::TimeDelta(), | 414 log.RecordStabilityMetrics(metrics_providers.get(), base::TimeDelta(), |
| 415 base::TimeDelta()); | 415 base::TimeDelta()); |
| 416 const SystemProfileProto_Stability& stability = | 416 const SystemProfileProto_Stability& stability = |
| 417 log.system_profile().stability(); | 417 log.system_profile().stability(); |
| 418 // Required metrics: | 418 // Required metrics: |
| 419 EXPECT_TRUE(stability.has_launch_count()); | 419 EXPECT_TRUE(stability.has_launch_count()); |
| 420 EXPECT_TRUE(stability.has_crash_count()); | 420 EXPECT_TRUE(stability.has_crash_count()); |
| 421 // Initial log metrics: | 421 // Initial log metrics: only expected if non-zero. |
| 422 EXPECT_FALSE(stability.has_incomplete_shutdown_count()); | 422 EXPECT_FALSE(stability.has_incomplete_shutdown_count()); |
| 423 EXPECT_FALSE(stability.has_breakpad_registration_success_count()); | 423 EXPECT_FALSE(stability.has_breakpad_registration_success_count()); |
| 424 EXPECT_FALSE(stability.has_breakpad_registration_failure_count()); | 424 EXPECT_FALSE(stability.has_breakpad_registration_failure_count()); |
| 425 EXPECT_FALSE(stability.has_debugger_present_count()); | 425 EXPECT_FALSE(stability.has_debugger_present_count()); |
| 426 EXPECT_FALSE(stability.has_debugger_not_present_count()); | 426 EXPECT_FALSE(stability.has_debugger_not_present_count()); |
| 427 | 427 |
| 428 // The test provider should have been called upon to provide regular but not | 428 // The test provider should have been called upon to provide regular but not |
| 429 // initial stability metrics. | 429 // initial stability metrics. |
| 430 EXPECT_FALSE(test_provider->provide_initial_stability_metrics_called()); | 430 EXPECT_FALSE(test_provider->provide_initial_stability_metrics_called()); |
| 431 EXPECT_TRUE(test_provider->provide_stability_metrics_called()); | 431 EXPECT_TRUE(test_provider->provide_stability_metrics_called()); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 456 TestMetricsServiceClient client; | 456 TestMetricsServiceClient client; |
| 457 client.set_product(kTestProduct); | 457 client.set_product(kTestProduct); |
| 458 TestMetricsLog log( | 458 TestMetricsLog log( |
| 459 kClientId, kSessionId, MetricsLog::ONGOING_LOG, &client, &prefs_); | 459 kClientId, kSessionId, MetricsLog::ONGOING_LOG, &client, &prefs_); |
| 460 // Check that the product is set to |kTestProduct|. | 460 // Check that the product is set to |kTestProduct|. |
| 461 EXPECT_TRUE(log.uma_proto().has_product()); | 461 EXPECT_TRUE(log.uma_proto().has_product()); |
| 462 EXPECT_EQ(kTestProduct, log.uma_proto().product()); | 462 EXPECT_EQ(kTestProduct, log.uma_proto().product()); |
| 463 } | 463 } |
| 464 | 464 |
| 465 } // namespace metrics | 465 } // namespace metrics |
| OLD | NEW |