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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/metrics/stability_metrics_provider.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/metrics/stability_metrics_provider_unittest.cc
diff --git a/components/metrics/stability_metrics_provider_unittest.cc b/components/metrics/stability_metrics_provider_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..7b2cb616a46f85ee368b0646efcde890602828de
--- /dev/null
+++ b/components/metrics/stability_metrics_provider_unittest.cc
@@ -0,0 +1,76 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/metrics/stability_metrics_provider.h"
+
+#include "components/metrics/proto/system_profile.pb.h"
+#include "components/prefs/testing_pref_service.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace metrics {
+
+class StabilityMetricsProviderTest : public testing::Test {
+ public:
+ StabilityMetricsProviderTest() {
+ StabilityMetricsProvider::RegisterPrefs(prefs_.registry());
+ }
+
+ ~StabilityMetricsProviderTest() override {}
+
+ protected:
+ TestingPrefServiceSimple prefs_;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(StabilityMetricsProviderTest);
+};
+
+TEST_F(StabilityMetricsProviderTest, ProvideStabilityMetrics) {
+ StabilityMetricsProvider stability_provider(&prefs_);
+ MetricsProvider* provider = &stability_provider;
+ SystemProfileProto system_profile;
+ provider->ProvideStabilityMetrics(&system_profile);
+
+ const SystemProfileProto_Stability& stability = system_profile.stability();
+ // Initial log metrics: only expected if non-zero.
+ EXPECT_FALSE(stability.has_launch_count());
+ EXPECT_FALSE(stability.has_crash_count());
+ EXPECT_FALSE(stability.has_incomplete_shutdown_count());
+ EXPECT_FALSE(stability.has_breakpad_registration_success_count());
+ EXPECT_FALSE(stability.has_breakpad_registration_failure_count());
+ EXPECT_FALSE(stability.has_debugger_present_count());
+ EXPECT_FALSE(stability.has_debugger_not_present_count());
+}
+
+TEST_F(StabilityMetricsProviderTest, RecordStabilityMetrics) {
+ {
+ StabilityMetricsProvider recorder(&prefs_);
+ recorder.LogLaunch();
+ recorder.LogCrash();
+ recorder.MarkSessionEndCompleted(false);
+ recorder.CheckLastSessionEndCompleted();
+ recorder.RecordBreakpadRegistration(true);
+ recorder.RecordBreakpadRegistration(false);
+ recorder.RecordBreakpadHasDebugger(true);
+ recorder.RecordBreakpadHasDebugger(false);
+ }
+
+ {
+ StabilityMetricsProvider stability_provider(&prefs_);
+ MetricsProvider* provider = &stability_provider;
+ SystemProfileProto system_profile;
+ provider->ProvideStabilityMetrics(&system_profile);
+
+ const SystemProfileProto_Stability& stability = system_profile.stability();
+ // Initial log metrics: only expected if non-zero.
+ EXPECT_EQ(1, stability.launch_count());
+ EXPECT_EQ(1, stability.crash_count());
+ EXPECT_EQ(1, stability.incomplete_shutdown_count());
+ EXPECT_EQ(1, stability.breakpad_registration_success_count());
+ EXPECT_EQ(1, stability.breakpad_registration_failure_count());
+ EXPECT_EQ(1, stability.debugger_present_count());
+ EXPECT_EQ(1, stability.debugger_not_present_count());
+ }
+}
+
+} // namespace metrics
« 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