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

Side by Side Diff: chrome/browser/chromeos/external_metrics_unittest.cc

Issue 1870793002: Convert //chrome/browser/chromeos from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase 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 (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/chromeos/external_metrics.h"
6
7 #include <memory>
8
5 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
6 #include "base/files/scoped_temp_dir.h" 10 #include "base/files/scoped_temp_dir.h"
7 #include "base/memory/scoped_ptr.h"
8 #include "base/metrics/statistics_recorder.h" 11 #include "base/metrics/statistics_recorder.h"
9 #include "base/test/histogram_tester.h" 12 #include "base/test/histogram_tester.h"
10 #include "chrome/browser/chromeos/external_metrics.h"
11 #include "components/metrics/serialization/metric_sample.h" 13 #include "components/metrics/serialization/metric_sample.h"
12 #include "components/metrics/serialization/serialization_utils.h" 14 #include "components/metrics/serialization/serialization_utils.h"
13 #include "content/public/test/test_browser_thread_bundle.h" 15 #include "content/public/test/test_browser_thread_bundle.h"
14 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
15 17
16 namespace chromeos { // Need this because of the FRIEND_TEST 18 namespace chromeos { // Need this because of the FRIEND_TEST
17 19
18 class ExternalMetricsTest : public testing::Test { 20 class ExternalMetricsTest : public testing::Test {
19 public: 21 public:
20 void SetUp() override { 22 void SetUp() override {
(...skipping 10 matching lines...) Expand all
31 TEST_F(ExternalMetricsTest, HandleMissingFile) { 33 TEST_F(ExternalMetricsTest, HandleMissingFile) {
32 ASSERT_TRUE(base::DeleteFile( 34 ASSERT_TRUE(base::DeleteFile(
33 base::FilePath(external_metrics_->uma_events_file_), false)); 35 base::FilePath(external_metrics_->uma_events_file_), false));
34 36
35 EXPECT_EQ(0, external_metrics_->CollectEvents()); 37 EXPECT_EQ(0, external_metrics_->CollectEvents());
36 } 38 }
37 39
38 TEST_F(ExternalMetricsTest, CanReceiveHistogram) { 40 TEST_F(ExternalMetricsTest, CanReceiveHistogram) {
39 base::HistogramTester histogram_tester; 41 base::HistogramTester histogram_tester;
40 42
41 scoped_ptr<metrics::MetricSample> hist = 43 std::unique_ptr<metrics::MetricSample> hist =
42 metrics::MetricSample::HistogramSample("foo", 2, 1, 100, 10); 44 metrics::MetricSample::HistogramSample("foo", 2, 1, 100, 10);
43 45
44 EXPECT_TRUE(metrics::SerializationUtils::WriteMetricToFile( 46 EXPECT_TRUE(metrics::SerializationUtils::WriteMetricToFile(
45 *hist.get(), external_metrics_->uma_events_file_)); 47 *hist.get(), external_metrics_->uma_events_file_));
46 48
47 EXPECT_EQ(1, external_metrics_->CollectEvents()); 49 EXPECT_EQ(1, external_metrics_->CollectEvents());
48 50
49 histogram_tester.ExpectTotalCount("foo", 1); 51 histogram_tester.ExpectTotalCount("foo", 1);
50 } 52 }
51 53
52 TEST_F(ExternalMetricsTest, IncorrectHistogramsAreDiscarded) { 54 TEST_F(ExternalMetricsTest, IncorrectHistogramsAreDiscarded) {
53 base::HistogramTester histogram_tester; 55 base::HistogramTester histogram_tester;
54 56
55 // Malformed histogram (min > max). 57 // Malformed histogram (min > max).
56 scoped_ptr<metrics::MetricSample> hist = 58 std::unique_ptr<metrics::MetricSample> hist =
57 metrics::MetricSample::HistogramSample("bar", 30, 200, 20, 10); 59 metrics::MetricSample::HistogramSample("bar", 30, 200, 20, 10);
58 60
59 EXPECT_TRUE(metrics::SerializationUtils::WriteMetricToFile( 61 EXPECT_TRUE(metrics::SerializationUtils::WriteMetricToFile(
60 *hist.get(), external_metrics_->uma_events_file_)); 62 *hist.get(), external_metrics_->uma_events_file_));
61 63
62 external_metrics_->CollectEvents(); 64 external_metrics_->CollectEvents();
63 65
64 histogram_tester.ExpectTotalCount("bar", 0); 66 histogram_tester.ExpectTotalCount("bar", 0);
65 } 67 }
66 68
67 } // namespace chromeos 69 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/extensions/wallpaper_private_api_unittest.cc ('k') | chrome/browser/chromeos/feedback_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698