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

Side by Side Diff: chrome/browser/metrics/chrome_stability_metrics_provider_unittest.cc

Issue 1886913002: Convert //chrome/browser/metrics from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 "chrome/browser/metrics/chrome_stability_metrics_provider.h" 5 #include "chrome/browser/metrics/chrome_stability_metrics_provider.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "chrome/test/base/testing_browser_process.h" 8 #include "chrome/test/base/testing_browser_process.h"
9 #include "chrome/test/base/testing_profile.h" 9 #include "chrome/test/base/testing_profile.h"
10 #include "chrome/test/base/testing_profile_manager.h" 10 #include "chrome/test/base/testing_profile_manager.h"
(...skipping 21 matching lines...) Expand all
32 32
33 class ChromeStabilityMetricsProviderTest : public testing::Test { 33 class ChromeStabilityMetricsProviderTest : public testing::Test {
34 protected: 34 protected:
35 ChromeStabilityMetricsProviderTest() : prefs_(new TestingPrefServiceSimple) { 35 ChromeStabilityMetricsProviderTest() : prefs_(new TestingPrefServiceSimple) {
36 metrics::StabilityMetricsHelper::RegisterPrefs(prefs()->registry()); 36 metrics::StabilityMetricsHelper::RegisterPrefs(prefs()->registry());
37 } 37 }
38 38
39 TestingPrefServiceSimple* prefs() { return prefs_.get(); } 39 TestingPrefServiceSimple* prefs() { return prefs_.get(); }
40 40
41 private: 41 private:
42 scoped_ptr<TestingPrefServiceSimple> prefs_; 42 std::unique_ptr<TestingPrefServiceSimple> prefs_;
43 content::TestBrowserThreadBundle thread_bundle_; 43 content::TestBrowserThreadBundle thread_bundle_;
44 44
45 DISALLOW_COPY_AND_ASSIGN(ChromeStabilityMetricsProviderTest); 45 DISALLOW_COPY_AND_ASSIGN(ChromeStabilityMetricsProviderTest);
46 }; 46 };
47 47
48 } // namespace 48 } // namespace
49 49
50 TEST_F(ChromeStabilityMetricsProviderTest, BrowserChildProcessObserver) { 50 TEST_F(ChromeStabilityMetricsProviderTest, BrowserChildProcessObserver) {
51 ChromeStabilityMetricsProvider provider(prefs()); 51 ChromeStabilityMetricsProvider provider(prefs());
52 52
53 content::ChildProcessData child_process_data(content::PROCESS_TYPE_RENDERER); 53 content::ChildProcessData child_process_data(content::PROCESS_TYPE_RENDERER);
54 provider.BrowserChildProcessCrashed(child_process_data, 1); 54 provider.BrowserChildProcessCrashed(child_process_data, 1);
55 provider.BrowserChildProcessCrashed(child_process_data, 1); 55 provider.BrowserChildProcessCrashed(child_process_data, 1);
56 56
57 // Call ProvideStabilityMetrics to check that it will force pending tasks to 57 // Call ProvideStabilityMetrics to check that it will force pending tasks to
58 // be executed immediately. 58 // be executed immediately.
59 metrics::SystemProfileProto system_profile; 59 metrics::SystemProfileProto system_profile;
60 60
61 provider.ProvideStabilityMetrics(&system_profile); 61 provider.ProvideStabilityMetrics(&system_profile);
62 62
63 // Check current number of instances created. 63 // Check current number of instances created.
64 const metrics::SystemProfileProto_Stability& stability = 64 const metrics::SystemProfileProto_Stability& stability =
65 system_profile.stability(); 65 system_profile.stability();
66 66
67 EXPECT_EQ(2, stability.child_process_crash_count()); 67 EXPECT_EQ(2, stability.child_process_crash_count());
68 } 68 }
69 69
70 TEST_F(ChromeStabilityMetricsProviderTest, NotificationObserver) { 70 TEST_F(ChromeStabilityMetricsProviderTest, NotificationObserver) {
71 ChromeStabilityMetricsProvider provider(prefs()); 71 ChromeStabilityMetricsProvider provider(prefs());
72 scoped_ptr<TestingProfileManager> profile_manager( 72 std::unique_ptr<TestingProfileManager> profile_manager(
73 new TestingProfileManager(TestingBrowserProcess::GetGlobal())); 73 new TestingProfileManager(TestingBrowserProcess::GetGlobal()));
74 EXPECT_TRUE(profile_manager->SetUp()); 74 EXPECT_TRUE(profile_manager->SetUp());
75 75
76 // Owned by profile_manager. 76 // Owned by profile_manager.
77 TestingProfile* profile( 77 TestingProfile* profile(
78 profile_manager->CreateTestingProfile("StabilityTestProfile")); 78 profile_manager->CreateTestingProfile("StabilityTestProfile"));
79 79
80 scoped_ptr<content::MockRenderProcessHostFactory> rph_factory( 80 std::unique_ptr<content::MockRenderProcessHostFactory> rph_factory(
81 new content::MockRenderProcessHostFactory()); 81 new content::MockRenderProcessHostFactory());
82 scoped_refptr<content::SiteInstance> site_instance( 82 scoped_refptr<content::SiteInstance> site_instance(
83 content::SiteInstance::Create(profile)); 83 content::SiteInstance::Create(profile));
84 84
85 // Owned by rph_factory. 85 // Owned by rph_factory.
86 content::RenderProcessHost* host( 86 content::RenderProcessHost* host(
87 rph_factory->CreateRenderProcessHost(profile, site_instance.get())); 87 rph_factory->CreateRenderProcessHost(profile, site_instance.get()));
88 88
89 // Crash and abnormal termination should increment renderer crash count. 89 // Crash and abnormal termination should increment renderer crash count.
90 content::RenderProcessHost::RendererClosedDetails crash_details( 90 content::RenderProcessHost::RendererClosedDetails crash_details(
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 provider.ProvideStabilityMetrics(&system_profile); 160 provider.ProvideStabilityMetrics(&system_profile);
161 161
162 EXPECT_EQ(0, system_profile.stability().renderer_crash_count()); 162 EXPECT_EQ(0, system_profile.stability().renderer_crash_count());
163 EXPECT_EQ(1, system_profile.stability().extension_renderer_crash_count()); 163 EXPECT_EQ(1, system_profile.stability().extension_renderer_crash_count());
164 EXPECT_EQ( 164 EXPECT_EQ(
165 1, system_profile.stability().extension_renderer_failed_launch_count()); 165 1, system_profile.stability().extension_renderer_failed_launch_count());
166 #endif 166 #endif
167 167
168 profile_manager->DeleteAllTestingProfiles(); 168 profile_manager->DeleteAllTestingProfiles();
169 } 169 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698