| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // Tests the MetricsService stat recording to make sure that the numbers are | 5 // Tests the MetricsService stat recording to make sure that the numbers are |
| 6 // what we expect. | 6 // what we expect. |
| 7 | 7 |
| 8 #include "components/metrics/metrics_service.h" | 8 #include "components/metrics/metrics_service.h" |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
| 14 #include "base/path_service.h" | 14 #include "base/path_service.h" |
| 15 #include "base/prefs/pref_service.h" | |
| 16 #include "build/build_config.h" | 15 #include "build/build_config.h" |
| 17 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
| 18 #include "chrome/browser/ui/browser.h" | 17 #include "chrome/browser/ui/browser.h" |
| 19 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 18 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 20 #include "chrome/common/chrome_paths.h" | 19 #include "chrome/common/chrome_paths.h" |
| 21 #include "chrome/common/chrome_switches.h" | 20 #include "chrome/common/chrome_switches.h" |
| 22 #include "chrome/common/url_constants.h" | 21 #include "chrome/common/url_constants.h" |
| 23 #include "chrome/test/base/in_process_browser_test.h" | 22 #include "chrome/test/base/in_process_browser_test.h" |
| 24 #include "chrome/test/base/ui_test_utils.h" | 23 #include "chrome/test/base/ui_test_utils.h" |
| 25 #include "components/metrics/metrics_pref_names.h" | 24 #include "components/metrics/metrics_pref_names.h" |
| 25 #include "components/prefs/pref_service.h" |
| 26 #include "content/public/test/browser_test_utils.h" | 26 #include "content/public/test/browser_test_utils.h" |
| 27 #include "net/base/filename_util.h" | 27 #include "net/base/filename_util.h" |
| 28 #include "ui/base/window_open_disposition.h" | 28 #include "ui/base/window_open_disposition.h" |
| 29 #include "url/gurl.h" | 29 #include "url/gurl.h" |
| 30 | 30 |
| 31 class MetricsServiceBrowserTest : public InProcessBrowserTest { | 31 class MetricsServiceBrowserTest : public InProcessBrowserTest { |
| 32 public: | 32 public: |
| 33 void SetUpCommandLine(base::CommandLine* command_line) override { | 33 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 34 // Enable the metrics service for testing (in recording-only mode). | 34 // Enable the metrics service for testing (in recording-only mode). |
| 35 command_line->AppendSwitch(switches::kMetricsRecordingOnly); | 35 command_line->AppendSwitch(switches::kMetricsRecordingOnly); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 // Verify that the expected stability metrics were recorded. | 106 // Verify that the expected stability metrics were recorded. |
| 107 EXPECT_EQ(1, prefs->GetInteger(metrics::prefs::kStabilityLaunchCount)); | 107 EXPECT_EQ(1, prefs->GetInteger(metrics::prefs::kStabilityLaunchCount)); |
| 108 EXPECT_EQ(4, prefs->GetInteger(metrics::prefs::kStabilityPageLoadCount)); | 108 EXPECT_EQ(4, prefs->GetInteger(metrics::prefs::kStabilityPageLoadCount)); |
| 109 EXPECT_EQ(1, prefs->GetInteger(metrics::prefs::kStabilityRendererCrashCount)); | 109 EXPECT_EQ(1, prefs->GetInteger(metrics::prefs::kStabilityRendererCrashCount)); |
| 110 // TODO(isherman): We should also verify that | 110 // TODO(isherman): We should also verify that |
| 111 // metrics::prefs::kStabilityExitedCleanly | 111 // metrics::prefs::kStabilityExitedCleanly |
| 112 // is set to true, but this preference isn't set until the browser | 112 // is set to true, but this preference isn't set until the browser |
| 113 // exits... it's not clear to me how to test that. | 113 // exits... it's not clear to me how to test that. |
| 114 } | 114 } |
| 115 | 115 |
| OLD | NEW |