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" |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 } | 207 } |
208 | 208 |
209 TEST_F(MetricsServiceTest, InitialStabilityLogAtProviderRequest) { | 209 TEST_F(MetricsServiceTest, InitialStabilityLogAtProviderRequest) { |
210 EnableMetricsReporting(); | 210 EnableMetricsReporting(); |
211 | 211 |
212 // Save an existing system profile to prefs, to correspond to what would be | 212 // Save an existing system profile to prefs, to correspond to what would be |
213 // saved from a previous session. | 213 // saved from a previous session. |
214 TestMetricsServiceClient client; | 214 TestMetricsServiceClient client; |
215 TestMetricsLog log("client", 1, &client, GetLocalState()); | 215 TestMetricsLog log("client", 1, &client, GetLocalState()); |
216 log.RecordEnvironment(std::vector<MetricsProvider*>(), | 216 log.RecordEnvironment(std::vector<MetricsProvider*>(), |
217 std::vector<variations::ActiveGroupId>(), | 217 std::vector<variations::ActiveGroupId>(), 0, 0); |
218 0); | |
219 | 218 |
220 // Record stability build time and version from previous session, so that | 219 // Record stability build time and version from previous session, so that |
221 // stability metrics (including exited cleanly flag) won't be cleared. | 220 // stability metrics (including exited cleanly flag) won't be cleared. |
222 GetLocalState()->SetInt64(prefs::kStabilityStatsBuildTime, | 221 GetLocalState()->SetInt64(prefs::kStabilityStatsBuildTime, |
223 MetricsLog::GetBuildTime()); | 222 MetricsLog::GetBuildTime()); |
224 GetLocalState()->SetString(prefs::kStabilityStatsVersion, | 223 GetLocalState()->SetString(prefs::kStabilityStatsVersion, |
225 client.GetVersionString()); | 224 client.GetVersionString()); |
226 | 225 |
227 // Set the clean exit flag, as that will otherwise cause a stabilty | 226 // Set the clean exit flag, as that will otherwise cause a stabilty |
228 // log to be produced, irrespective provider requests. | 227 // log to be produced, irrespective provider requests. |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 EnableMetricsReporting(); | 272 EnableMetricsReporting(); |
274 GetLocalState()->ClearPref(prefs::kStabilityExitedCleanly); | 273 GetLocalState()->ClearPref(prefs::kStabilityExitedCleanly); |
275 | 274 |
276 // Set up prefs to simulate restarting after a crash. | 275 // Set up prefs to simulate restarting after a crash. |
277 | 276 |
278 // Save an existing system profile to prefs, to correspond to what would be | 277 // Save an existing system profile to prefs, to correspond to what would be |
279 // saved from a previous session. | 278 // saved from a previous session. |
280 TestMetricsServiceClient client; | 279 TestMetricsServiceClient client; |
281 TestMetricsLog log("client", 1, &client, GetLocalState()); | 280 TestMetricsLog log("client", 1, &client, GetLocalState()); |
282 log.RecordEnvironment(std::vector<MetricsProvider*>(), | 281 log.RecordEnvironment(std::vector<MetricsProvider*>(), |
283 std::vector<variations::ActiveGroupId>(), | 282 std::vector<variations::ActiveGroupId>(), 0, 0); |
284 0); | |
285 | 283 |
286 // Record stability build time and version from previous session, so that | 284 // Record stability build time and version from previous session, so that |
287 // stability metrics (including exited cleanly flag) won't be cleared. | 285 // stability metrics (including exited cleanly flag) won't be cleared. |
288 GetLocalState()->SetInt64(prefs::kStabilityStatsBuildTime, | 286 GetLocalState()->SetInt64(prefs::kStabilityStatsBuildTime, |
289 MetricsLog::GetBuildTime()); | 287 MetricsLog::GetBuildTime()); |
290 GetLocalState()->SetString(prefs::kStabilityStatsVersion, | 288 GetLocalState()->SetString(prefs::kStabilityStatsVersion, |
291 client.GetVersionString()); | 289 client.GetVersionString()); |
292 | 290 |
293 GetLocalState()->SetBoolean(prefs::kStabilityExitedCleanly, false); | 291 GetLocalState()->SetBoolean(prefs::kStabilityExitedCleanly, false); |
294 | 292 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 "clientID", 1, MetricsLog::ONGOING_LOG, &client, GetLocalState()))); | 378 "clientID", 1, MetricsLog::ONGOING_LOG, &client, GetLocalState()))); |
381 service.GetCurrentSyntheticFieldTrials(&synthetic_trials); | 379 service.GetCurrentSyntheticFieldTrials(&synthetic_trials); |
382 EXPECT_EQ(3U, synthetic_trials.size()); | 380 EXPECT_EQ(3U, synthetic_trials.size()); |
383 EXPECT_TRUE(HasSyntheticTrial(synthetic_trials, "TestTrial1", "Group2")); | 381 EXPECT_TRUE(HasSyntheticTrial(synthetic_trials, "TestTrial1", "Group2")); |
384 EXPECT_TRUE(HasSyntheticTrial(synthetic_trials, "TestTrial2", "Group2")); | 382 EXPECT_TRUE(HasSyntheticTrial(synthetic_trials, "TestTrial2", "Group2")); |
385 EXPECT_TRUE(HasSyntheticTrial(synthetic_trials, "TestTrial3", "Group3")); | 383 EXPECT_TRUE(HasSyntheticTrial(synthetic_trials, "TestTrial3", "Group3")); |
386 service.log_manager_.FinishCurrentLog(); | 384 service.log_manager_.FinishCurrentLog(); |
387 } | 385 } |
388 | 386 |
389 } // namespace metrics | 387 } // namespace metrics |
OLD | NEW |