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

Unified Diff: chrome/browser/metrics/metrics_service_unittest.cc

Issue 81603002: Send UMA stability stats in a separate UMA log on startup. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years 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
Index: chrome/browser/metrics/metrics_service_unittest.cc
===================================================================
--- chrome/browser/metrics/metrics_service_unittest.cc (revision 239504)
+++ chrome/browser/metrics/metrics_service_unittest.cc (working copy)
@@ -14,11 +14,25 @@
#include "chrome/test/base/testing_browser_process.h"
#include "components/variations/metrics_util.h"
#include "content/public/common/process_type.h"
+#include "content/public/common/webplugininfo.h"
#include "content/public/test/test_browser_thread.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace {
+class TestMetricsService : public MetricsService {
+ public:
+ TestMetricsService() {}
+ virtual ~TestMetricsService() {}
+
+ const MetricsLogManager& log_manager() const {
+ return log_manager_;
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(TestMetricsService);
+};
+
class MetricsServiceTest : public testing::Test {
public:
MetricsServiceTest()
@@ -26,6 +40,10 @@
testing_local_state_(TestingBrowserProcess::GetGlobal()) {
}
+ virtual ~MetricsServiceTest() {
+ MetricsService::SetExecutionPhase(MetricsService::UNINITIALIZED_PHASE);
+ }
+
PrefService* GetLocalState() {
return testing_local_state_.Get();
}
@@ -139,6 +157,50 @@
}
}
+TEST_F(MetricsServiceTest, InitialStabilityLogAfterCleanShutDown) {
+ base::FieldTrialList field_trial_list(NULL);
+ base::FieldTrialList::CreateFieldTrial("UMAStability", "SeparateLog");
+
+ GetLocalState()->SetBoolean(prefs::kStabilityExitedCleanly, true);
+
+ TestMetricsService service;
+ service.InitializeMetricsRecordingState(MetricsService::REPORTING_ENABLED);
+ // No initial stability log should be generated.
+ EXPECT_FALSE(service.log_manager().has_unsent_logs());
+ EXPECT_FALSE(service.log_manager().has_staged_log());
+}
+
+TEST_F(MetricsServiceTest, InitialStabilityLogAfterCrash) {
+ base::FieldTrialList field_trial_list(NULL);
+ base::FieldTrialList::CreateFieldTrial("UMAStability", "SeparateLog");
+
+ GetLocalState()->ClearPref(prefs::kStabilityExitedCleanly);
+
+ // Set up prefs to simulate restarting after a crash.
+
+ // Save an existing system profile to prefs, to correspond to what would be
+ // saved from a previous session.
+ MetricsLog log("client", 1);
+ log.RecordEnvironment(std::vector<content::WebPluginInfo>(),
+ GoogleUpdateMetrics(),
+ std::vector<chrome_variations::ActiveGroupId>());
+
+ // Record stability build time and version from previous session, so that
+ // stability metrics (including exited cleanly flag) won't be cleared.
+ GetLocalState()->SetInt64(prefs::kStabilityStatsBuildTime,
+ MetricsLog::GetBuildTime());
+ GetLocalState()->SetString(prefs::kStabilityStatsVersion,
+ MetricsLog::GetVersionString());
+
+ GetLocalState()->SetBoolean(prefs::kStabilityExitedCleanly, false);
+
+ TestMetricsService service;
+ service.InitializeMetricsRecordingState(MetricsService::REPORTING_ENABLED);
+ // The initial stability log should be generated and persisted in unsent logs.
+ EXPECT_TRUE(service.log_manager().has_unsent_logs());
Ilya Sherman 2013/12/12 09:03:38 Can you check the contents of the unsent logs as w
Alexei Svitkine (slow) 2013/12/12 16:09:27 Done.
+ EXPECT_FALSE(service.log_manager().has_staged_log());
+}
+
// Crashes on at least Mac and Linux. http://crbug.com/320433
TEST_F(MetricsServiceTest, DISABLED_RegisterSyntheticTrial) {
MetricsService service;

Powered by Google App Engine
This is Rietveld 408576698