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

Side by Side Diff: chrome/browser/metrics/metrics_log_unittest.cc

Issue 282093012: Remove dependencies of Metrics{Service,Log} on g_browser_process->local_state() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Android compile fix Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/metrics/metrics_log.cc ('k') | chrome/browser/metrics/metrics_service.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "chrome/browser/metrics/metrics_log.h" 5 #include "chrome/browser/metrics/metrics_log.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/port.h" 12 #include "base/port.h"
13 #include "base/prefs/pref_service.h" 13 #include "base/prefs/pref_service.h"
14 #include "base/prefs/testing_pref_service.h" 14 #include "base/prefs/testing_pref_service.h"
15 #include "base/strings/string_number_conversions.h" 15 #include "base/strings/string_number_conversions.h"
16 #include "base/strings/string_util.h" 16 #include "base/strings/string_util.h"
17 #include "base/strings/stringprintf.h" 17 #include "base/strings/stringprintf.h"
18 #include "base/threading/sequenced_worker_pool.h" 18 #include "base/threading/sequenced_worker_pool.h"
19 #include "base/time/time.h" 19 #include "base/time/time.h"
20 #include "base/tracked_objects.h" 20 #include "base/tracked_objects.h"
21 #include "chrome/browser/google/google_util.h" 21 #include "chrome/browser/google/google_util.h"
22 #include "chrome/browser/metrics/metrics_service.h"
22 #include "chrome/browser/prefs/browser_prefs.h" 23 #include "chrome/browser/prefs/browser_prefs.h"
23 #include "chrome/common/chrome_version_info.h" 24 #include "chrome/common/chrome_version_info.h"
24 #include "chrome/common/pref_names.h" 25 #include "chrome/common/pref_names.h"
25 #include "components/metrics/metrics_hashes.h" 26 #include "components/metrics/metrics_hashes.h"
26 #include "components/metrics/metrics_provider.h" 27 #include "components/metrics/metrics_provider.h"
27 #include "components/metrics/proto/profiler_event.pb.h" 28 #include "components/metrics/proto/profiler_event.pb.h"
28 #include "components/metrics/proto/system_profile.pb.h" 29 #include "components/metrics/proto/system_profile.pb.h"
29 #include "components/metrics/test_metrics_service_client.h" 30 #include "components/metrics/test_metrics_service_client.h"
30 #include "components/variations/active_field_trials.h" 31 #include "components/variations/active_field_trials.h"
31 #include "content/public/browser/browser_thread.h" 32 #include "content/public/browser/browser_thread.h"
(...skipping 24 matching lines...) Expand all
56 const variations::ActiveGroupId kSyntheticTrials[] = { 57 const variations::ActiveGroupId kSyntheticTrials[] = {
57 {55, 15}, 58 {55, 15},
58 {66, 16} 59 {66, 16}
59 }; 60 };
60 61
61 class TestMetricsLog : public MetricsLog { 62 class TestMetricsLog : public MetricsLog {
62 public: 63 public:
63 TestMetricsLog(const std::string& client_id, 64 TestMetricsLog(const std::string& client_id,
64 int session_id, 65 int session_id,
65 LogType log_type, 66 LogType log_type,
66 metrics::MetricsServiceClient* client)
67 : MetricsLog(client_id, session_id, log_type, client),
68 prefs_(&scoped_prefs_) {
69 chrome::RegisterLocalState(scoped_prefs_.registry());
70 InitPrefs();
71 }
72
73 // Creates a TestMetricsLog that will use |prefs| as the fake local state.
74 // Useful for tests that need to re-use the local state prefs between logs.
75 TestMetricsLog(const std::string& client_id,
76 int session_id,
77 LogType log_type,
78 metrics::MetricsServiceClient* client, 67 metrics::MetricsServiceClient* client,
79 TestingPrefServiceSimple* prefs) 68 TestingPrefServiceSimple* prefs)
80 : MetricsLog(client_id, session_id, log_type, client), prefs_(prefs) { 69 : MetricsLog(client_id, session_id, log_type, client, prefs),
70 prefs_(prefs) {
81 InitPrefs(); 71 InitPrefs();
82 } 72 }
83 73
84 virtual ~TestMetricsLog() {} 74 virtual ~TestMetricsLog() {}
85 75
86 virtual PrefService* GetPrefService() OVERRIDE {
87 return prefs_;
88 }
89
90 const metrics::ChromeUserMetricsExtension& uma_proto() const { 76 const metrics::ChromeUserMetricsExtension& uma_proto() const {
91 return *MetricsLog::uma_proto(); 77 return *MetricsLog::uma_proto();
92 } 78 }
93 79
94 const metrics::SystemProfileProto& system_profile() const { 80 const metrics::SystemProfileProto& system_profile() const {
95 return uma_proto().system_profile(); 81 return uma_proto().system_profile();
96 } 82 }
97 83
98 private: 84 private:
99 void InitPrefs() { 85 void InitPrefs() {
100 prefs_->SetInt64(prefs::kInstallDate, kInstallDate); 86 prefs_->SetInt64(prefs::kInstallDate, kInstallDate);
101 prefs_->SetString(prefs::kMetricsReportingEnabledTimestamp, 87 prefs_->SetString(prefs::kMetricsReportingEnabledTimestamp,
102 base::Int64ToString(kEnabledDate)); 88 base::Int64ToString(kEnabledDate));
103 } 89 }
104 90
105 virtual void GetFieldTrialIds( 91 virtual void GetFieldTrialIds(
106 std::vector<variations::ActiveGroupId>* field_trial_ids) const 92 std::vector<variations::ActiveGroupId>* field_trial_ids) const
107 OVERRIDE { 93 OVERRIDE {
108 ASSERT_TRUE(field_trial_ids->empty()); 94 ASSERT_TRUE(field_trial_ids->empty());
109 95
110 for (size_t i = 0; i < arraysize(kFieldTrialIds); ++i) { 96 for (size_t i = 0; i < arraysize(kFieldTrialIds); ++i) {
111 field_trial_ids->push_back(kFieldTrialIds[i]); 97 field_trial_ids->push_back(kFieldTrialIds[i]);
112 } 98 }
113 } 99 }
114 100
115 // Scoped PrefsService, which may not be used if |prefs_ != &scoped_prefs|.
116 TestingPrefServiceSimple scoped_prefs_;
117 // Weak pointer to the PrefsService used by this log. 101 // Weak pointer to the PrefsService used by this log.
118 TestingPrefServiceSimple* prefs_; 102 TestingPrefServiceSimple* prefs_;
119 103
120 DISALLOW_COPY_AND_ASSIGN(TestMetricsLog); 104 DISALLOW_COPY_AND_ASSIGN(TestMetricsLog);
121 }; 105 };
122 106
123 } // namespace 107 } // namespace
124 108
125 class MetricsLogTest : public testing::Test { 109 class MetricsLogTest : public testing::Test {
126 public: 110 public:
127 MetricsLogTest() {} 111 MetricsLogTest() { MetricsService::RegisterPrefs(prefs_.registry()); }
128 112
129 protected: 113 protected:
130 // Check that the values in |system_values| correspond to the test data 114 // Check that the values in |system_values| correspond to the test data
131 // defined at the top of this file. 115 // defined at the top of this file.
132 void CheckSystemProfile(const metrics::SystemProfileProto& system_profile) { 116 void CheckSystemProfile(const metrics::SystemProfileProto& system_profile) {
133 EXPECT_EQ(kInstallDateExpected, system_profile.install_date()); 117 EXPECT_EQ(kInstallDateExpected, system_profile.install_date());
134 EXPECT_EQ(kEnabledDateExpected, system_profile.uma_enabled_date()); 118 EXPECT_EQ(kEnabledDateExpected, system_profile.uma_enabled_date());
135 119
136 ASSERT_EQ(arraysize(kFieldTrialIds) + arraysize(kSyntheticTrials), 120 ASSERT_EQ(arraysize(kFieldTrialIds) + arraysize(kSyntheticTrials),
137 static_cast<size_t>(system_profile.field_trial_size())); 121 static_cast<size_t>(system_profile.field_trial_size()));
(...skipping 18 matching lines...) Expand all
156 system_profile.hardware(); 140 system_profile.hardware();
157 141
158 EXPECT_TRUE(hardware.has_cpu()); 142 EXPECT_TRUE(hardware.has_cpu());
159 EXPECT_TRUE(hardware.cpu().has_vendor_name()); 143 EXPECT_TRUE(hardware.cpu().has_vendor_name());
160 EXPECT_TRUE(hardware.cpu().has_signature()); 144 EXPECT_TRUE(hardware.cpu().has_signature());
161 145
162 // TODO(isherman): Verify other data written into the protobuf as a result 146 // TODO(isherman): Verify other data written into the protobuf as a result
163 // of this call. 147 // of this call.
164 } 148 }
165 149
150 protected:
151 TestingPrefServiceSimple prefs_;
152
166 private: 153 private:
167 content::TestBrowserThreadBundle thread_bundle_; 154 content::TestBrowserThreadBundle thread_bundle_;
168 155
169 DISALLOW_COPY_AND_ASSIGN(MetricsLogTest); 156 DISALLOW_COPY_AND_ASSIGN(MetricsLogTest);
170 }; 157 };
171 158
172 TEST_F(MetricsLogTest, RecordEnvironment) { 159 TEST_F(MetricsLogTest, RecordEnvironment) {
173 metrics::TestMetricsServiceClient client; 160 metrics::TestMetricsServiceClient client;
174 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG, &client); 161 TestMetricsLog log(
162 kClientId, kSessionId, MetricsLog::ONGOING_LOG, &client, &prefs_);
175 163
176 std::vector<variations::ActiveGroupId> synthetic_trials; 164 std::vector<variations::ActiveGroupId> synthetic_trials;
177 // Add two synthetic trials. 165 // Add two synthetic trials.
178 synthetic_trials.push_back(kSyntheticTrials[0]); 166 synthetic_trials.push_back(kSyntheticTrials[0]);
179 synthetic_trials.push_back(kSyntheticTrials[1]); 167 synthetic_trials.push_back(kSyntheticTrials[1]);
180 168
181 log.RecordEnvironment(std::vector<metrics::MetricsProvider*>(), 169 log.RecordEnvironment(std::vector<metrics::MetricsProvider*>(),
182 synthetic_trials); 170 synthetic_trials);
183 // Check that the system profile on the log has the correct values set. 171 // Check that the system profile on the log has the correct values set.
184 CheckSystemProfile(log.system_profile()); 172 CheckSystemProfile(log.system_profile());
185 173
186 // Check that the system profile has also been written to prefs. 174 // Check that the system profile has also been written to prefs.
187 PrefService* local_state = log.GetPrefService();
188 const std::string base64_system_profile = 175 const std::string base64_system_profile =
189 local_state->GetString(prefs::kStabilitySavedSystemProfile); 176 prefs_.GetString(prefs::kStabilitySavedSystemProfile);
190 EXPECT_FALSE(base64_system_profile.empty()); 177 EXPECT_FALSE(base64_system_profile.empty());
191 std::string serialied_system_profile; 178 std::string serialied_system_profile;
192 EXPECT_TRUE(base::Base64Decode(base64_system_profile, 179 EXPECT_TRUE(base::Base64Decode(base64_system_profile,
193 &serialied_system_profile)); 180 &serialied_system_profile));
194 metrics::SystemProfileProto decoded_system_profile; 181 metrics::SystemProfileProto decoded_system_profile;
195 EXPECT_TRUE(decoded_system_profile.ParseFromString(serialied_system_profile)); 182 EXPECT_TRUE(decoded_system_profile.ParseFromString(serialied_system_profile));
196 CheckSystemProfile(decoded_system_profile); 183 CheckSystemProfile(decoded_system_profile);
197 } 184 }
198 185
199 TEST_F(MetricsLogTest, LoadSavedEnvironmentFromPrefs) { 186 TEST_F(MetricsLogTest, LoadSavedEnvironmentFromPrefs) {
200 const char* kSystemProfilePref = prefs::kStabilitySavedSystemProfile; 187 const char* kSystemProfilePref = prefs::kStabilitySavedSystemProfile;
201 const char* kSystemProfileHashPref = prefs::kStabilitySavedSystemProfileHash; 188 const char* kSystemProfileHashPref = prefs::kStabilitySavedSystemProfileHash;
202 189
203 metrics::TestMetricsServiceClient client; 190 metrics::TestMetricsServiceClient client;
204 TestingPrefServiceSimple prefs;
205 chrome::RegisterLocalState(prefs.registry());
206 191
207 // The pref value is empty, so loading it from prefs should fail. 192 // The pref value is empty, so loading it from prefs should fail.
208 { 193 {
209 TestMetricsLog log( 194 TestMetricsLog log(
210 kClientId, kSessionId, MetricsLog::ONGOING_LOG, &client, &prefs); 195 kClientId, kSessionId, MetricsLog::ONGOING_LOG, &client, &prefs_);
211 EXPECT_FALSE(log.LoadSavedEnvironmentFromPrefs()); 196 EXPECT_FALSE(log.LoadSavedEnvironmentFromPrefs());
212 } 197 }
213 198
214 // Do a RecordEnvironment() call and check whether the pref is recorded. 199 // Do a RecordEnvironment() call and check whether the pref is recorded.
215 { 200 {
216 TestMetricsLog log( 201 TestMetricsLog log(
217 kClientId, kSessionId, MetricsLog::ONGOING_LOG, &client, &prefs); 202 kClientId, kSessionId, MetricsLog::ONGOING_LOG, &client, &prefs_);
218 log.RecordEnvironment(std::vector<metrics::MetricsProvider*>(), 203 log.RecordEnvironment(std::vector<metrics::MetricsProvider*>(),
219 std::vector<variations::ActiveGroupId>()); 204 std::vector<variations::ActiveGroupId>());
220 EXPECT_FALSE(prefs.GetString(kSystemProfilePref).empty()); 205 EXPECT_FALSE(prefs_.GetString(kSystemProfilePref).empty());
221 EXPECT_FALSE(prefs.GetString(kSystemProfileHashPref).empty()); 206 EXPECT_FALSE(prefs_.GetString(kSystemProfileHashPref).empty());
222 } 207 }
223 208
224 { 209 {
225 TestMetricsLog log( 210 TestMetricsLog log(
226 kClientId, kSessionId, MetricsLog::ONGOING_LOG, &client, &prefs); 211 kClientId, kSessionId, MetricsLog::ONGOING_LOG, &client, &prefs_);
227 EXPECT_TRUE(log.LoadSavedEnvironmentFromPrefs()); 212 EXPECT_TRUE(log.LoadSavedEnvironmentFromPrefs());
228 // Check some values in the system profile. 213 // Check some values in the system profile.
229 EXPECT_EQ(kInstallDateExpected, log.system_profile().install_date()); 214 EXPECT_EQ(kInstallDateExpected, log.system_profile().install_date());
230 EXPECT_EQ(kEnabledDateExpected, log.system_profile().uma_enabled_date()); 215 EXPECT_EQ(kEnabledDateExpected, log.system_profile().uma_enabled_date());
231 // Ensure that the call cleared the prefs. 216 // Ensure that the call cleared the prefs.
232 EXPECT_TRUE(prefs.GetString(kSystemProfilePref).empty()); 217 EXPECT_TRUE(prefs_.GetString(kSystemProfilePref).empty());
233 EXPECT_TRUE(prefs.GetString(kSystemProfileHashPref).empty()); 218 EXPECT_TRUE(prefs_.GetString(kSystemProfileHashPref).empty());
234 } 219 }
235 220
236 // Ensure that a non-matching hash results in the pref being invalid. 221 // Ensure that a non-matching hash results in the pref being invalid.
237 { 222 {
238 TestMetricsLog log( 223 TestMetricsLog log(
239 kClientId, kSessionId, MetricsLog::ONGOING_LOG, &client, &prefs); 224 kClientId, kSessionId, MetricsLog::ONGOING_LOG, &client, &prefs_);
240 // Call RecordEnvironment() to record the pref again. 225 // Call RecordEnvironment() to record the pref again.
241 log.RecordEnvironment(std::vector<metrics::MetricsProvider*>(), 226 log.RecordEnvironment(std::vector<metrics::MetricsProvider*>(),
242 std::vector<variations::ActiveGroupId>()); 227 std::vector<variations::ActiveGroupId>());
243 } 228 }
244 229
245 { 230 {
246 // Set the hash to a bad value. 231 // Set the hash to a bad value.
247 prefs.SetString(kSystemProfileHashPref, "deadbeef"); 232 prefs_.SetString(kSystemProfileHashPref, "deadbeef");
248 TestMetricsLog log( 233 TestMetricsLog log(
249 kClientId, kSessionId, MetricsLog::ONGOING_LOG, &client, &prefs); 234 kClientId, kSessionId, MetricsLog::ONGOING_LOG, &client, &prefs_);
250 EXPECT_FALSE(log.LoadSavedEnvironmentFromPrefs()); 235 EXPECT_FALSE(log.LoadSavedEnvironmentFromPrefs());
251 // Ensure that the prefs are cleared, even if the call failed. 236 // Ensure that the prefs are cleared, even if the call failed.
252 EXPECT_TRUE(prefs.GetString(kSystemProfilePref).empty()); 237 EXPECT_TRUE(prefs_.GetString(kSystemProfilePref).empty());
253 EXPECT_TRUE(prefs.GetString(kSystemProfileHashPref).empty()); 238 EXPECT_TRUE(prefs_.GetString(kSystemProfileHashPref).empty());
254 } 239 }
255 } 240 }
256 241
257 TEST_F(MetricsLogTest, InitialLogStabilityMetrics) { 242 TEST_F(MetricsLogTest, InitialLogStabilityMetrics) {
258 metrics::TestMetricsServiceClient client; 243 metrics::TestMetricsServiceClient client;
259 TestMetricsLog log( 244 TestMetricsLog log(kClientId,
260 kClientId, kSessionId, MetricsLog::INITIAL_STABILITY_LOG, &client); 245 kSessionId,
246 MetricsLog::INITIAL_STABILITY_LOG,
247 &client,
248 &prefs_);
261 std::vector<metrics::MetricsProvider*> metrics_providers; 249 std::vector<metrics::MetricsProvider*> metrics_providers;
262 log.RecordEnvironment(metrics_providers, 250 log.RecordEnvironment(metrics_providers,
263 std::vector<variations::ActiveGroupId>()); 251 std::vector<variations::ActiveGroupId>());
264 log.RecordStabilityMetrics(metrics_providers, base::TimeDelta(), 252 log.RecordStabilityMetrics(metrics_providers, base::TimeDelta(),
265 base::TimeDelta()); 253 base::TimeDelta());
266 const metrics::SystemProfileProto_Stability& stability = 254 const metrics::SystemProfileProto_Stability& stability =
267 log.system_profile().stability(); 255 log.system_profile().stability();
268 // Required metrics: 256 // Required metrics:
269 EXPECT_TRUE(stability.has_launch_count()); 257 EXPECT_TRUE(stability.has_launch_count());
270 EXPECT_TRUE(stability.has_crash_count()); 258 EXPECT_TRUE(stability.has_crash_count());
271 // Initial log metrics: 259 // Initial log metrics:
272 EXPECT_TRUE(stability.has_incomplete_shutdown_count()); 260 EXPECT_TRUE(stability.has_incomplete_shutdown_count());
273 EXPECT_TRUE(stability.has_breakpad_registration_success_count()); 261 EXPECT_TRUE(stability.has_breakpad_registration_success_count());
274 EXPECT_TRUE(stability.has_breakpad_registration_failure_count()); 262 EXPECT_TRUE(stability.has_breakpad_registration_failure_count());
275 EXPECT_TRUE(stability.has_debugger_present_count()); 263 EXPECT_TRUE(stability.has_debugger_present_count());
276 EXPECT_TRUE(stability.has_debugger_not_present_count()); 264 EXPECT_TRUE(stability.has_debugger_not_present_count());
277 } 265 }
278 266
279 TEST_F(MetricsLogTest, OngoingLogStabilityMetrics) { 267 TEST_F(MetricsLogTest, OngoingLogStabilityMetrics) {
280 metrics::TestMetricsServiceClient client; 268 metrics::TestMetricsServiceClient client;
281 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG, &client); 269 TestMetricsLog log(
270 kClientId, kSessionId, MetricsLog::ONGOING_LOG, &client, &prefs_);
282 std::vector<metrics::MetricsProvider*> metrics_providers; 271 std::vector<metrics::MetricsProvider*> metrics_providers;
283 log.RecordEnvironment(metrics_providers, 272 log.RecordEnvironment(metrics_providers,
284 std::vector<variations::ActiveGroupId>()); 273 std::vector<variations::ActiveGroupId>());
285 log.RecordStabilityMetrics(metrics_providers, base::TimeDelta(), 274 log.RecordStabilityMetrics(metrics_providers, base::TimeDelta(),
286 base::TimeDelta()); 275 base::TimeDelta());
287 const metrics::SystemProfileProto_Stability& stability = 276 const metrics::SystemProfileProto_Stability& stability =
288 log.system_profile().stability(); 277 log.system_profile().stability();
289 // Required metrics: 278 // Required metrics:
290 EXPECT_TRUE(stability.has_launch_count()); 279 EXPECT_TRUE(stability.has_launch_count());
291 EXPECT_TRUE(stability.has_crash_count()); 280 EXPECT_TRUE(stability.has_crash_count());
292 // Initial log metrics: 281 // Initial log metrics:
293 EXPECT_FALSE(stability.has_incomplete_shutdown_count()); 282 EXPECT_FALSE(stability.has_incomplete_shutdown_count());
294 EXPECT_FALSE(stability.has_breakpad_registration_success_count()); 283 EXPECT_FALSE(stability.has_breakpad_registration_success_count());
295 EXPECT_FALSE(stability.has_breakpad_registration_failure_count()); 284 EXPECT_FALSE(stability.has_breakpad_registration_failure_count());
296 EXPECT_FALSE(stability.has_debugger_present_count()); 285 EXPECT_FALSE(stability.has_debugger_present_count());
297 EXPECT_FALSE(stability.has_debugger_not_present_count()); 286 EXPECT_FALSE(stability.has_debugger_not_present_count());
298 } 287 }
299 288
300 // Test that we properly write profiler data to the log. 289 // Test that we properly write profiler data to the log.
301 TEST_F(MetricsLogTest, RecordProfilerData) { 290 TEST_F(MetricsLogTest, RecordProfilerData) {
302 // WARNING: If you broke the below check, you've modified how 291 // WARNING: If you broke the below check, you've modified how
303 // metrics::HashMetricName works. Please also modify all server-side code that 292 // metrics::HashMetricName works. Please also modify all server-side code that
304 // relies on the existing way of hashing. 293 // relies on the existing way of hashing.
305 EXPECT_EQ(GG_UINT64_C(1518842999910132863), 294 EXPECT_EQ(GG_UINT64_C(1518842999910132863),
306 metrics::HashMetricName("birth_thread*")); 295 metrics::HashMetricName("birth_thread*"));
307 296
308 metrics::TestMetricsServiceClient client; 297 metrics::TestMetricsServiceClient client;
309 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG, &client); 298 TestMetricsLog log(
299 kClientId, kSessionId, MetricsLog::ONGOING_LOG, &client, &prefs_);
310 EXPECT_EQ(0, log.uma_proto().profiler_event_size()); 300 EXPECT_EQ(0, log.uma_proto().profiler_event_size());
311 301
312 { 302 {
313 ProcessDataSnapshot process_data; 303 ProcessDataSnapshot process_data;
314 process_data.process_id = 177; 304 process_data.process_id = 177;
315 process_data.tasks.push_back(TaskSnapshot()); 305 process_data.tasks.push_back(TaskSnapshot());
316 process_data.tasks.back().birth.location.file_name = "a/b/file.h"; 306 process_data.tasks.back().birth.location.file_name = "a/b/file.h";
317 process_data.tasks.back().birth.location.function_name = "function"; 307 process_data.tasks.back().birth.location.function_name = "function";
318 process_data.tasks.back().birth.location.line_number = 1337; 308 process_data.tasks.back().birth.location.line_number = 1337;
319 process_data.tasks.back().birth.thread_name = "birth_thread"; 309 process_data.tasks.back().birth.thread_name = "birth_thread";
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 EXPECT_EQ(metrics::HashMetricName(""), 452 EXPECT_EQ(metrics::HashMetricName(""),
463 tracked_object->exec_thread_name_hash()); 453 tracked_object->exec_thread_name_hash());
464 EXPECT_EQ(ProfilerEventProto::TrackedObject::RENDERER, 454 EXPECT_EQ(ProfilerEventProto::TrackedObject::RENDERER,
465 tracked_object->process_type()); 455 tracked_object->process_type());
466 } 456 }
467 } 457 }
468 458
469 TEST_F(MetricsLogTest, ChromeChannelWrittenToProtobuf) { 459 TEST_F(MetricsLogTest, ChromeChannelWrittenToProtobuf) {
470 metrics::TestMetricsServiceClient client; 460 metrics::TestMetricsServiceClient client;
471 TestMetricsLog log( 461 TestMetricsLog log(
472 "user@test.com", kSessionId, MetricsLog::ONGOING_LOG, &client); 462 "user@test.com", kSessionId, MetricsLog::ONGOING_LOG, &client, &prefs_);
473 EXPECT_TRUE(log.uma_proto().system_profile().has_channel()); 463 EXPECT_TRUE(log.uma_proto().system_profile().has_channel());
474 } 464 }
OLDNEW
« no previous file with comments | « chrome/browser/metrics/metrics_log.cc ('k') | chrome/browser/metrics/metrics_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698