OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/prefs/testing_pref_service.h" | 10 #include "base/prefs/testing_pref_service.h" |
11 #include "base/threading/platform_thread.h" | 11 #include "base/threading/platform_thread.h" |
12 #include "chrome/browser/google/google_util.h" | 12 #include "chrome/browser/google/google_util.h" |
13 #include "chrome/common/pref_names.h" | 13 #include "chrome/common/pref_names.h" |
14 #include "chrome/test/base/scoped_testing_local_state.h" | 14 #include "chrome/test/base/scoped_testing_local_state.h" |
15 #include "chrome/test/base/testing_browser_process.h" | 15 #include "chrome/test/base/testing_browser_process.h" |
| 16 #include "components/metrics/compression_utils.h" |
16 #include "components/metrics/metrics_log.h" | 17 #include "components/metrics/metrics_log.h" |
17 #include "components/metrics/metrics_service_observer.h" | 18 #include "components/metrics/metrics_service_observer.h" |
18 #include "components/metrics/metrics_state_manager.h" | 19 #include "components/metrics/metrics_state_manager.h" |
19 #include "components/metrics/test_metrics_service_client.h" | 20 #include "components/metrics/test_metrics_service_client.h" |
20 #include "components/variations/metrics_util.h" | 21 #include "components/variations/metrics_util.h" |
21 #include "content/public/test/test_browser_thread_bundle.h" | 22 #include "content/public/test/test_browser_thread_bundle.h" |
22 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
23 | 24 |
24 #if defined(OS_CHROMEOS) | 25 #if defined(OS_CHROMEOS) |
25 #include "chromeos/login/login_state.h" | 26 #include "chromeos/login/login_state.h" |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 | 203 |
203 // The initial stability log should be generated and persisted in unsent logs. | 204 // The initial stability log should be generated and persisted in unsent logs. |
204 MetricsLogManager* log_manager = service.log_manager(); | 205 MetricsLogManager* log_manager = service.log_manager(); |
205 EXPECT_TRUE(log_manager->has_unsent_logs()); | 206 EXPECT_TRUE(log_manager->has_unsent_logs()); |
206 EXPECT_FALSE(log_manager->has_staged_log()); | 207 EXPECT_FALSE(log_manager->has_staged_log()); |
207 | 208 |
208 // Stage the log and retrieve it. | 209 // Stage the log and retrieve it. |
209 log_manager->StageNextLogForUpload(); | 210 log_manager->StageNextLogForUpload(); |
210 EXPECT_TRUE(log_manager->has_staged_log()); | 211 EXPECT_TRUE(log_manager->has_staged_log()); |
211 | 212 |
| 213 std::string uncompressed_log; |
| 214 EXPECT_TRUE(metrics::GzipUncompress(log_manager->staged_log(), |
| 215 &uncompressed_log)); |
| 216 |
212 metrics::ChromeUserMetricsExtension uma_log; | 217 metrics::ChromeUserMetricsExtension uma_log; |
213 EXPECT_TRUE(uma_log.ParseFromString(log_manager->staged_log())); | 218 EXPECT_TRUE(uma_log.ParseFromString(uncompressed_log)); |
214 | 219 |
215 EXPECT_TRUE(uma_log.has_client_id()); | 220 EXPECT_TRUE(uma_log.has_client_id()); |
216 EXPECT_TRUE(uma_log.has_session_id()); | 221 EXPECT_TRUE(uma_log.has_session_id()); |
217 EXPECT_TRUE(uma_log.has_system_profile()); | 222 EXPECT_TRUE(uma_log.has_system_profile()); |
218 EXPECT_EQ(0, uma_log.user_action_event_size()); | 223 EXPECT_EQ(0, uma_log.user_action_event_size()); |
219 EXPECT_EQ(0, uma_log.omnibox_event_size()); | 224 EXPECT_EQ(0, uma_log.omnibox_event_size()); |
220 EXPECT_EQ(0, uma_log.histogram_event_size()); | 225 EXPECT_EQ(0, uma_log.histogram_event_size()); |
221 EXPECT_EQ(0, uma_log.profiler_event_size()); | 226 EXPECT_EQ(0, uma_log.profiler_event_size()); |
222 EXPECT_EQ(0, uma_log.perf_data_size()); | 227 EXPECT_EQ(0, uma_log.perf_data_size()); |
223 | 228 |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 | 320 |
316 service.RemoveObserver(&observer1); | 321 service.RemoveObserver(&observer1); |
317 | 322 |
318 service.OpenNewLog(); | 323 service.OpenNewLog(); |
319 EXPECT_EQ(2, observer1.observed()); | 324 EXPECT_EQ(2, observer1.observed()); |
320 EXPECT_EQ(2, observer2.observed()); | 325 EXPECT_EQ(2, observer2.observed()); |
321 service.log_manager_.FinishCurrentLog(); | 326 service.log_manager_.FinishCurrentLog(); |
322 | 327 |
323 service.RemoveObserver(&observer2); | 328 service.RemoveObserver(&observer2); |
324 } | 329 } |
OLD | NEW |