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

Side by Side Diff: components/metrics/stability_metrics_provider_unittest.cc

Issue 2687393004: Gather stability prefs into managing objects. (Closed)
Patch Set: Remove unused method Created 3 years, 10 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
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "components/metrics/stability_metrics_provider.h"
6
7 #include "components/metrics/proto/system_profile.pb.h"
8 #include "components/prefs/testing_pref_service.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10
11 namespace metrics {
12
13 class StabilityMetricsProviderTest : public testing::Test {
14 public:
15 StabilityMetricsProviderTest() {
16 StabilityMetricsProvider::RegisterPrefs(prefs_.registry());
17 }
18
19 ~StabilityMetricsProviderTest() override {}
20
21 protected:
22 TestingPrefServiceSimple prefs_;
23
24 private:
25 DISALLOW_COPY_AND_ASSIGN(StabilityMetricsProviderTest);
26 };
27
28 TEST_F(StabilityMetricsProviderTest, ProvideStabilityMetrics) {
29 StabilityMetricsProvider stability_provider(&prefs_);
30 MetricsProvider* provider = &stability_provider;
31 SystemProfileProto system_profile;
32 provider->ProvideStabilityMetrics(&system_profile);
33
34 const SystemProfileProto_Stability& stability = system_profile.stability();
35 // Required metrics:
36 EXPECT_TRUE(stability.has_launch_count());
37 EXPECT_EQ(0, stability.launch_count());
38 EXPECT_TRUE(stability.has_crash_count());
39 EXPECT_EQ(0, stability.crash_count());
40 // Initial log metrics: only expected if non-zero.
41 EXPECT_FALSE(stability.has_incomplete_shutdown_count());
42 EXPECT_FALSE(stability.has_breakpad_registration_success_count());
43 EXPECT_FALSE(stability.has_breakpad_registration_failure_count());
44 EXPECT_FALSE(stability.has_debugger_present_count());
45 EXPECT_FALSE(stability.has_debugger_not_present_count());
46 }
47
48 TEST_F(StabilityMetricsProviderTest, RecordStabilityMetrics) {
49 {
50 StabilityMetricsProvider recorder(&prefs_);
51 recorder.LogLaunch();
52 recorder.LogCrash();
53 recorder.MarkSessionEndCompleted(false);
54 recorder.CheckLastSessionEndCompleted();
55 recorder.RecordBreakpadRegistration(true);
56 recorder.RecordBreakpadRegistration(false);
57 recorder.RecordBreakpadHasDebugger(true);
58 recorder.RecordBreakpadHasDebugger(false);
59 }
60
61 {
62 StabilityMetricsProvider stability_provider(&prefs_);
63 MetricsProvider* provider = &stability_provider;
64 SystemProfileProto system_profile;
65 provider->ProvideStabilityMetrics(&system_profile);
66
67 const SystemProfileProto_Stability& stability = system_profile.stability();
68 // Required metrics:
69 EXPECT_EQ(1, stability.launch_count());
70 EXPECT_EQ(1, stability.crash_count());
71 // Initial log metrics: only expected if non-zero.
72 EXPECT_EQ(1, stability.incomplete_shutdown_count());
73 EXPECT_EQ(1, stability.breakpad_registration_success_count());
74 EXPECT_EQ(1, stability.breakpad_registration_failure_count());
75 EXPECT_EQ(1, stability.debugger_present_count());
76 EXPECT_EQ(1, stability.debugger_not_present_count());
77 }
78 }
79
80 } // namespace metrics
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698