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

Side by Side Diff: components/metrics/metrics_log_manager_unittest.cc

Issue 2358223002: Add log date to the metrics log (Closed)
Patch Set: No explicit migration Created 4 years, 2 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
OLDNEW
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_manager.h" 5 #include "components/metrics/metrics_log_manager.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 TestLogPrefService pref_service; 156 TestLogPrefService pref_service;
157 // Set up some in-progress logging in a scoped log manager simulating the 157 // Set up some in-progress logging in a scoped log manager simulating the
158 // leadup to quitting, then persist as would be done on quit. 158 // leadup to quitting, then persist as would be done on quit.
159 { 159 {
160 MetricsLogManager log_manager(&pref_service, 0); 160 MetricsLogManager log_manager(&pref_service, 0);
161 log_manager.LoadPersistedUnsentLogs(); 161 log_manager.LoadPersistedUnsentLogs();
162 162
163 // Simulate a log having already been unsent from a previous session. 163 // Simulate a log having already been unsent from a previous session.
164 { 164 {
165 std::string log("proto"); 165 std::string log("proto");
166 PersistedLogs ongoing_logs(&pref_service, prefs::kMetricsOngoingLogs, 1, 166 PersistedLogs ongoing_logs(&pref_service, prefs::kMetricsOngoingLogs,
167 1, 0); 167 prefs::kDeprecatedMetricsOngoingLogs, 1, 1, 0);
168 ongoing_logs.StoreLog(log); 168 ongoing_logs.StoreLog(log);
169 ongoing_logs.SerializeLogs(); 169 ongoing_logs.SerializeLogs();
170 } 170 }
171 EXPECT_EQ(1U, pref_service.TypeCount(MetricsLog::ONGOING_LOG)); 171 EXPECT_EQ(1U, pref_service.TypeCount(MetricsLog::ONGOING_LOG));
172 EXPECT_FALSE(log_manager.has_unsent_logs()); 172 EXPECT_FALSE(log_manager.has_unsent_logs());
173 log_manager.LoadPersistedUnsentLogs(); 173 log_manager.LoadPersistedUnsentLogs();
174 EXPECT_TRUE(log_manager.has_unsent_logs()); 174 EXPECT_TRUE(log_manager.has_unsent_logs());
175 175
176 log_manager.BeginLoggingWithLog(base::MakeUnique<MetricsLog>( 176 log_manager.BeginLoggingWithLog(base::MakeUnique<MetricsLog>(
177 "id", 0, MetricsLog::INITIAL_STABILITY_LOG, &client, &pref_service)); 177 "id", 0, MetricsLog::INITIAL_STABILITY_LOG, &client, &pref_service));
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 log_manager.FinishCurrentLog(); 298 log_manager.FinishCurrentLog();
299 log_manager.DiscardStagedLog(); 299 log_manager.DiscardStagedLog();
300 300
301 log_manager.PersistUnsentLogs(); 301 log_manager.PersistUnsentLogs();
302 EXPECT_EQ(0U, pref_service.TypeCount(MetricsLog::INITIAL_STABILITY_LOG)); 302 EXPECT_EQ(0U, pref_service.TypeCount(MetricsLog::INITIAL_STABILITY_LOG));
303 EXPECT_EQ(1U, pref_service.TypeCount(MetricsLog::ONGOING_LOG)); 303 EXPECT_EQ(1U, pref_service.TypeCount(MetricsLog::ONGOING_LOG));
304 } 304 }
305 } 305 }
306 306
307 } // namespace metrics 307 } // namespace metrics
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698