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 <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <string> | 10 #include <string> |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 EXPECT_FALSE(test_provider->provide_stability_metrics_called()); | 199 EXPECT_FALSE(test_provider->provide_stability_metrics_called()); |
200 } | 200 } |
201 | 201 |
202 TEST_F(MetricsServiceTest, InitialStabilityLogAtProviderRequest) { | 202 TEST_F(MetricsServiceTest, InitialStabilityLogAtProviderRequest) { |
203 EnableMetricsReporting(); | 203 EnableMetricsReporting(); |
204 | 204 |
205 // Save an existing system profile to prefs, to correspond to what would be | 205 // Save an existing system profile to prefs, to correspond to what would be |
206 // saved from a previous session. | 206 // saved from a previous session. |
207 TestMetricsServiceClient client; | 207 TestMetricsServiceClient client; |
208 TestMetricsLog log("client", 1, &client, GetLocalState()); | 208 TestMetricsLog log("client", 1, &client, GetLocalState()); |
209 log.RecordEnvironment(std::vector<MetricsProvider*>(), | 209 log.RecordEnvironment(std::vector<std::unique_ptr<MetricsProvider>>(), |
210 std::vector<variations::ActiveGroupId>(), 0, 0); | 210 std::vector<variations::ActiveGroupId>(), 0, 0); |
211 | 211 |
212 // Record stability build time and version from previous session, so that | 212 // Record stability build time and version from previous session, so that |
213 // stability metrics (including exited cleanly flag) won't be cleared. | 213 // stability metrics (including exited cleanly flag) won't be cleared. |
214 GetLocalState()->SetInt64(prefs::kStabilityStatsBuildTime, | 214 GetLocalState()->SetInt64(prefs::kStabilityStatsBuildTime, |
215 MetricsLog::GetBuildTime()); | 215 MetricsLog::GetBuildTime()); |
216 GetLocalState()->SetString(prefs::kStabilityStatsVersion, | 216 GetLocalState()->SetString(prefs::kStabilityStatsVersion, |
217 client.GetVersionString()); | 217 client.GetVersionString()); |
218 | 218 |
219 // Set the clean exit flag, as that will otherwise cause a stabilty | 219 // Set the clean exit flag, as that will otherwise cause a stabilty |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 TEST_F(MetricsServiceTest, InitialStabilityLogAfterCrash) { | 271 TEST_F(MetricsServiceTest, InitialStabilityLogAfterCrash) { |
272 EnableMetricsReporting(); | 272 EnableMetricsReporting(); |
273 GetLocalState()->ClearPref(prefs::kStabilityExitedCleanly); | 273 GetLocalState()->ClearPref(prefs::kStabilityExitedCleanly); |
274 | 274 |
275 // Set up prefs to simulate restarting after a crash. | 275 // Set up prefs to simulate restarting after a crash. |
276 | 276 |
277 // 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 |
278 // saved from a previous session. | 278 // saved from a previous session. |
279 TestMetricsServiceClient client; | 279 TestMetricsServiceClient client; |
280 TestMetricsLog log("client", 1, &client, GetLocalState()); | 280 TestMetricsLog log("client", 1, &client, GetLocalState()); |
281 log.RecordEnvironment(std::vector<MetricsProvider*>(), | 281 log.RecordEnvironment(std::vector<std::unique_ptr<MetricsProvider>>(), |
282 std::vector<variations::ActiveGroupId>(), 0, 0); | 282 std::vector<variations::ActiveGroupId>(), 0, 0); |
283 | 283 |
284 // Record stability build time and version from previous session, so that | 284 // Record stability build time and version from previous session, so that |
285 // stability metrics (including exited cleanly flag) won't be cleared. | 285 // stability metrics (including exited cleanly flag) won't be cleared. |
286 GetLocalState()->SetInt64(prefs::kStabilityStatsBuildTime, | 286 GetLocalState()->SetInt64(prefs::kStabilityStatsBuildTime, |
287 MetricsLog::GetBuildTime()); | 287 MetricsLog::GetBuildTime()); |
288 GetLocalState()->SetString(prefs::kStabilityStatsVersion, | 288 GetLocalState()->SetString(prefs::kStabilityStatsVersion, |
289 client.GetVersionString()); | 289 client.GetVersionString()); |
290 | 290 |
291 GetLocalState()->SetBoolean(prefs::kStabilityExitedCleanly, false); | 291 GetLocalState()->SetBoolean(prefs::kStabilityExitedCleanly, false); |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
547 client.uploader()->CompleteUpload(200); | 547 client.uploader()->CompleteUpload(200); |
548 EXPECT_FALSE(client.uploader()->is_uploading()); | 548 EXPECT_FALSE(client.uploader()->is_uploading()); |
549 EXPECT_EQ(1U, task_runner_->NumPendingTasks()); | 549 EXPECT_EQ(1U, task_runner_->NumPendingTasks()); |
550 // Upload should start. | 550 // Upload should start. |
551 task_runner_->RunPendingTasks(); | 551 task_runner_->RunPendingTasks(); |
552 EXPECT_TRUE(client.uploader()->is_uploading()); | 552 EXPECT_TRUE(client.uploader()->is_uploading()); |
553 EXPECT_EQ(0U, task_runner_->NumPendingTasks()); | 553 EXPECT_EQ(0U, task_runner_->NumPendingTasks()); |
554 } | 554 } |
555 | 555 |
556 } // namespace metrics | 556 } // namespace metrics |
OLD | NEW |