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

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

Issue 2318023002: //chrome/browser/chromeos: Change ScopedTempDir::path() to GetPath() (Closed)
Patch Set: Address comment and also remove non-trivial cases Created 4 years, 3 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" 5 #include "chrome/browser/chromeos/external_metrics.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/files/scoped_temp_dir.h" 10 #include "base/files/scoped_temp_dir.h"
11 #include "base/metrics/statistics_recorder.h" 11 #include "base/metrics/statistics_recorder.h"
12 #include "base/test/histogram_tester.h" 12 #include "base/test/histogram_tester.h"
13 #include "components/metrics/serialization/metric_sample.h" 13 #include "components/metrics/serialization/metric_sample.h"
14 #include "components/metrics/serialization/serialization_utils.h" 14 #include "components/metrics/serialization/serialization_utils.h"
15 #include "content/public/test/test_browser_thread_bundle.h" 15 #include "content/public/test/test_browser_thread_bundle.h"
16 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
17 17
18 namespace chromeos { // Need this because of the FRIEND_TEST 18 namespace chromeos { // Need this because of the FRIEND_TEST
19 19
20 class ExternalMetricsTest : public testing::Test { 20 class ExternalMetricsTest : public testing::Test {
21 public: 21 public:
22 void SetUp() override { 22 void SetUp() override {
23 ASSERT_TRUE(dir_.CreateUniqueTempDir()); 23 ASSERT_TRUE(dir_.CreateUniqueTempDir());
24 external_metrics_ = ExternalMetrics::CreateForTesting( 24 external_metrics_ = ExternalMetrics::CreateForTesting(
25 dir_.path().Append("testfile").value()); 25 dir_.GetPath().Append("testfile").value());
26 } 26 }
27 27
28 base::ScopedTempDir dir_; 28 base::ScopedTempDir dir_;
29 scoped_refptr<ExternalMetrics> external_metrics_; 29 scoped_refptr<ExternalMetrics> external_metrics_;
30 content::TestBrowserThreadBundle thread_bundle_; 30 content::TestBrowserThreadBundle thread_bundle_;
31 }; 31 };
32 32
33 TEST_F(ExternalMetricsTest, HandleMissingFile) { 33 TEST_F(ExternalMetricsTest, HandleMissingFile) {
34 ASSERT_TRUE(base::DeleteFile( 34 ASSERT_TRUE(base::DeleteFile(
35 base::FilePath(external_metrics_->uma_events_file_), false)); 35 base::FilePath(external_metrics_->uma_events_file_), false));
(...skipping 24 matching lines...) Expand all
60 60
61 EXPECT_TRUE(metrics::SerializationUtils::WriteMetricToFile( 61 EXPECT_TRUE(metrics::SerializationUtils::WriteMetricToFile(
62 *hist.get(), external_metrics_->uma_events_file_)); 62 *hist.get(), external_metrics_->uma_events_file_));
63 63
64 external_metrics_->CollectEvents(); 64 external_metrics_->CollectEvents();
65 65
66 histogram_tester.ExpectTotalCount("bar", 0); 66 histogram_tester.ExpectTotalCount("bar", 0);
67 } 67 }
68 68
69 } // namespace chromeos 69 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698