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

Side by Side Diff: ios/chrome/browser/metrics/mobile_session_shutdown_metrics_provider_unittest.mm

Issue 1859213002: Move the thread hop for UMA user actions from content:: to base::. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing Chromecast (I hope!) Created 4 years, 8 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "ios/chrome/browser/metrics/mobile_session_shutdown_metrics_provider.h" 5 #include "ios/chrome/browser/metrics/mobile_session_shutdown_metrics_provider.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/metrics/user_metrics.h"
11 #include "base/test/histogram_tester.h" 12 #include "base/test/histogram_tester.h"
12 #include "components/metrics/metrics_pref_names.h" 13 #include "components/metrics/metrics_pref_names.h"
13 #include "components/metrics/metrics_service.h" 14 #include "components/metrics/metrics_service.h"
14 #include "components/metrics/metrics_state_manager.h" 15 #include "components/metrics/metrics_state_manager.h"
15 #include "components/metrics/test_metrics_service_client.h" 16 #include "components/metrics/test_metrics_service_client.h"
16 #include "components/prefs/testing_pref_service.h" 17 #include "components/prefs/testing_pref_service.h"
17 #include "testing/gtest/include/gtest/gtest-param-test.h" 18 #include "testing/gtest/include/gtest/gtest-param-test.h"
18 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
19 20
20 namespace { 21 namespace {
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 FIRST_LAUNCH_AFTER_UPGRADE, 146 FIRST_LAUNCH_AFTER_UPGRADE,
146 }; 147 };
147 148
148 // Setup the MetricsService. 149 // Setup the MetricsService.
149 local_state_.SetBoolean(metrics::prefs::kStabilityExitedCleanly, 150 local_state_.SetBoolean(metrics::prefs::kStabilityExitedCleanly,
150 was_last_shutdown_clean); 151 was_last_shutdown_clean);
151 metrics_state_ = metrics::MetricsStateManager::Create( 152 metrics_state_ = metrics::MetricsStateManager::Create(
152 &local_state_, base::Bind(&IsMetricsReportingEnabled), 153 &local_state_, base::Bind(&IsMetricsReportingEnabled),
153 metrics::MetricsStateManager::StoreClientInfoCallback(), 154 metrics::MetricsStateManager::StoreClientInfoCallback(),
154 metrics::MetricsStateManager::LoadClientInfoCallback()); 155 metrics::MetricsStateManager::LoadClientInfoCallback());
156 base::ResetRecordActionTaskRunnerForTesting();
155 metrics_service_.reset(new metrics::MetricsService( 157 metrics_service_.reset(new metrics::MetricsService(
156 metrics_state_.get(), &metrics_client_, &local_state_)); 158 metrics_state_.get(), &metrics_client_, &local_state_));
157 159
158 // Create the metrics provider to test. 160 // Create the metrics provider to test.
159 metrics_provider_.reset(new MobileSessionShutdownMetricsProviderForTesting( 161 metrics_provider_.reset(new MobileSessionShutdownMetricsProviderForTesting(
160 metrics_service_.get())); 162 metrics_service_.get()));
161 163
162 // Setup the metrics provider for the current test. 164 // Setup the metrics provider for the current test.
163 metrics_provider_->set_is_first_launch_after_upgrade( 165 metrics_provider_->set_is_first_launch_after_upgrade(
164 is_first_launch_after_upgrade); 166 is_first_launch_after_upgrade);
(...skipping 10 matching lines...) Expand all
175 // Now call the method under test and verify exactly one sample is written to 177 // Now call the method under test and verify exactly one sample is written to
176 // the expected bucket. 178 // the expected bucket.
177 metrics_provider_->ProvideInitialStabilityMetrics(nullptr); 179 metrics_provider_->ProvideInitialStabilityMetrics(nullptr);
178 histogram_tester.ExpectUniqueSample("Stability.MobileSessionShutdownType", 180 histogram_tester.ExpectUniqueSample("Stability.MobileSessionShutdownType",
179 expected_buckets[GetParam()], 1); 181 expected_buckets[GetParam()], 1);
180 } 182 }
181 183
182 INSTANTIATE_TEST_CASE_P(/* No InstantiationName */, 184 INSTANTIATE_TEST_CASE_P(/* No InstantiationName */,
183 MobileSessionShutdownMetricsProviderTest, 185 MobileSessionShutdownMetricsProviderTest,
184 testing::Range(0, 32)); 186 testing::Range(0, 32));
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698