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

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

Issue 2687393004: Gather stability prefs into managing objects. (Closed)
Patch Set: Incorporate Feedback 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
« no previous file with comments | « components/metrics/stability_metrics_provider.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // Initial log metrics: only expected if non-zero.
36 EXPECT_FALSE(stability.has_launch_count());
37 EXPECT_FALSE(stability.has_crash_count());
38 EXPECT_FALSE(stability.has_incomplete_shutdown_count());
39 EXPECT_FALSE(stability.has_breakpad_registration_success_count());
40 EXPECT_FALSE(stability.has_breakpad_registration_failure_count());
41 EXPECT_FALSE(stability.has_debugger_present_count());
42 EXPECT_FALSE(stability.has_debugger_not_present_count());
43 }
44
45 TEST_F(StabilityMetricsProviderTest, RecordStabilityMetrics) {
46 {
47 StabilityMetricsProvider recorder(&prefs_);
48 recorder.LogLaunch();
49 recorder.LogCrash();
50 recorder.MarkSessionEndCompleted(false);
51 recorder.CheckLastSessionEndCompleted();
52 recorder.RecordBreakpadRegistration(true);
53 recorder.RecordBreakpadRegistration(false);
54 recorder.RecordBreakpadHasDebugger(true);
55 recorder.RecordBreakpadHasDebugger(false);
56 }
57
58 {
59 StabilityMetricsProvider stability_provider(&prefs_);
60 MetricsProvider* provider = &stability_provider;
61 SystemProfileProto system_profile;
62 provider->ProvideStabilityMetrics(&system_profile);
63
64 const SystemProfileProto_Stability& stability = system_profile.stability();
65 // Initial log metrics: only expected if non-zero.
66 EXPECT_EQ(1, stability.launch_count());
67 EXPECT_EQ(1, stability.crash_count());
68 EXPECT_EQ(1, stability.incomplete_shutdown_count());
69 EXPECT_EQ(1, stability.breakpad_registration_success_count());
70 EXPECT_EQ(1, stability.breakpad_registration_failure_count());
71 EXPECT_EQ(1, stability.debugger_present_count());
72 EXPECT_EQ(1, stability.debugger_not_present_count());
73 }
74 }
75
76 } // namespace metrics
OLDNEW
« no previous file with comments | « components/metrics/stability_metrics_provider.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698