| 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_service.h" | 5 #include "components/metrics/metrics_service.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
| 12 #include "base/metrics/statistics_recorder.h" | 12 #include "base/metrics/statistics_recorder.h" |
| 13 #include "base/prefs/testing_pref_service.h" | 13 #include "base/prefs/testing_pref_service.h" |
| 14 #include "base/threading/platform_thread.h" | 14 #include "base/threading/platform_thread.h" |
| 15 #include "components/compression/compression_utils.h" |
| 15 #include "components/metrics/client_info.h" | 16 #include "components/metrics/client_info.h" |
| 16 #include "components/metrics/compression_utils.h" | |
| 17 #include "components/metrics/metrics_hashes.h" | 17 #include "components/metrics/metrics_hashes.h" |
| 18 #include "components/metrics/metrics_log.h" | 18 #include "components/metrics/metrics_log.h" |
| 19 #include "components/metrics/metrics_pref_names.h" | 19 #include "components/metrics/metrics_pref_names.h" |
| 20 #include "components/metrics/metrics_state_manager.h" | 20 #include "components/metrics/metrics_state_manager.h" |
| 21 #include "components/metrics/test_metrics_provider.h" | 21 #include "components/metrics/test_metrics_provider.h" |
| 22 #include "components/metrics/test_metrics_service_client.h" | 22 #include "components/metrics/test_metrics_service_client.h" |
| 23 #include "components/variations/metrics_util.h" | 23 #include "components/variations/metrics_util.h" |
| 24 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
| 25 | 25 |
| 26 namespace metrics { | 26 namespace metrics { |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 // The test provider should have been called upon to provide initial | 222 // The test provider should have been called upon to provide initial |
| 223 // stability and regular stability metrics. | 223 // stability and regular stability metrics. |
| 224 EXPECT_TRUE(test_provider->provide_initial_stability_metrics_called()); | 224 EXPECT_TRUE(test_provider->provide_initial_stability_metrics_called()); |
| 225 EXPECT_TRUE(test_provider->provide_stability_metrics_called()); | 225 EXPECT_TRUE(test_provider->provide_stability_metrics_called()); |
| 226 | 226 |
| 227 // Stage the log and retrieve it. | 227 // Stage the log and retrieve it. |
| 228 log_manager->StageNextLogForUpload(); | 228 log_manager->StageNextLogForUpload(); |
| 229 EXPECT_TRUE(log_manager->has_staged_log()); | 229 EXPECT_TRUE(log_manager->has_staged_log()); |
| 230 | 230 |
| 231 std::string uncompressed_log; | 231 std::string uncompressed_log; |
| 232 EXPECT_TRUE(GzipUncompress(log_manager->staged_log(), &uncompressed_log)); | 232 EXPECT_TRUE(compression::GzipUncompress(log_manager->staged_log(), |
| 233 &uncompressed_log)); |
| 233 | 234 |
| 234 ChromeUserMetricsExtension uma_log; | 235 ChromeUserMetricsExtension uma_log; |
| 235 EXPECT_TRUE(uma_log.ParseFromString(uncompressed_log)); | 236 EXPECT_TRUE(uma_log.ParseFromString(uncompressed_log)); |
| 236 | 237 |
| 237 EXPECT_TRUE(uma_log.has_client_id()); | 238 EXPECT_TRUE(uma_log.has_client_id()); |
| 238 EXPECT_TRUE(uma_log.has_session_id()); | 239 EXPECT_TRUE(uma_log.has_session_id()); |
| 239 EXPECT_TRUE(uma_log.has_system_profile()); | 240 EXPECT_TRUE(uma_log.has_system_profile()); |
| 240 EXPECT_EQ(0, uma_log.user_action_event_size()); | 241 EXPECT_EQ(0, uma_log.user_action_event_size()); |
| 241 EXPECT_EQ(0, uma_log.omnibox_event_size()); | 242 EXPECT_EQ(0, uma_log.omnibox_event_size()); |
| 242 EXPECT_EQ(0, uma_log.profiler_event_size()); | 243 EXPECT_EQ(0, uma_log.profiler_event_size()); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 // The test provider should have been called upon to provide initial | 285 // The test provider should have been called upon to provide initial |
| 285 // stability and regular stability metrics. | 286 // stability and regular stability metrics. |
| 286 EXPECT_TRUE(test_provider->provide_initial_stability_metrics_called()); | 287 EXPECT_TRUE(test_provider->provide_initial_stability_metrics_called()); |
| 287 EXPECT_TRUE(test_provider->provide_stability_metrics_called()); | 288 EXPECT_TRUE(test_provider->provide_stability_metrics_called()); |
| 288 | 289 |
| 289 // Stage the log and retrieve it. | 290 // Stage the log and retrieve it. |
| 290 log_manager->StageNextLogForUpload(); | 291 log_manager->StageNextLogForUpload(); |
| 291 EXPECT_TRUE(log_manager->has_staged_log()); | 292 EXPECT_TRUE(log_manager->has_staged_log()); |
| 292 | 293 |
| 293 std::string uncompressed_log; | 294 std::string uncompressed_log; |
| 294 EXPECT_TRUE(GzipUncompress(log_manager->staged_log(), &uncompressed_log)); | 295 EXPECT_TRUE(compression::GzipUncompress(log_manager->staged_log(), |
| 296 &uncompressed_log)); |
| 295 | 297 |
| 296 ChromeUserMetricsExtension uma_log; | 298 ChromeUserMetricsExtension uma_log; |
| 297 EXPECT_TRUE(uma_log.ParseFromString(uncompressed_log)); | 299 EXPECT_TRUE(uma_log.ParseFromString(uncompressed_log)); |
| 298 | 300 |
| 299 EXPECT_TRUE(uma_log.has_client_id()); | 301 EXPECT_TRUE(uma_log.has_client_id()); |
| 300 EXPECT_TRUE(uma_log.has_session_id()); | 302 EXPECT_TRUE(uma_log.has_session_id()); |
| 301 EXPECT_TRUE(uma_log.has_system_profile()); | 303 EXPECT_TRUE(uma_log.has_system_profile()); |
| 302 EXPECT_EQ(0, uma_log.user_action_event_size()); | 304 EXPECT_EQ(0, uma_log.user_action_event_size()); |
| 303 EXPECT_EQ(0, uma_log.omnibox_event_size()); | 305 EXPECT_EQ(0, uma_log.omnibox_event_size()); |
| 304 EXPECT_EQ(0, uma_log.profiler_event_size()); | 306 EXPECT_EQ(0, uma_log.profiler_event_size()); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 TestMetricsProvider* test_provider = new TestMetricsProvider(); | 382 TestMetricsProvider* test_provider = new TestMetricsProvider(); |
| 381 service.RegisterMetricsProvider(scoped_ptr<MetricsProvider>(test_provider)); | 383 service.RegisterMetricsProvider(scoped_ptr<MetricsProvider>(test_provider)); |
| 382 | 384 |
| 383 service.InitializeMetricsRecordingState(); | 385 service.InitializeMetricsRecordingState(); |
| 384 service.Stop(); | 386 service.Stop(); |
| 385 | 387 |
| 386 EXPECT_TRUE(test_provider->on_recording_disabled_called()); | 388 EXPECT_TRUE(test_provider->on_recording_disabled_called()); |
| 387 } | 389 } |
| 388 | 390 |
| 389 } // namespace metrics | 391 } // namespace metrics |
| OLD | NEW |