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

Side by Side Diff: trunk/src/chrome/browser/metrics/metrics_service_browsertest.cc

Issue 268223002: Revert 268232 "Refactor MetricsStateManager class out of Metrics..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
OLDNEW
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 "chrome/browser/metrics/metrics_service.h"
9
10 #include <string> 8 #include <string>
11 9
12 #include "base/command_line.h" 10 #include "base/command_line.h"
13 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
14 #include "base/path_service.h" 12 #include "base/path_service.h"
15 #include "base/prefs/pref_service.h" 13 #include "base/prefs/pref_service.h"
16 #include "chrome/browser/browser_process.h" 14 #include "chrome/browser/browser_process.h"
15 #include "chrome/browser/metrics/metrics_service.h"
17 #include "chrome/browser/ui/browser.h" 16 #include "chrome/browser/ui/browser.h"
18 #include "chrome/browser/ui/tabs/tab_strip_model.h" 17 #include "chrome/browser/ui/tabs/tab_strip_model.h"
19 #include "chrome/common/chrome_paths.h" 18 #include "chrome/common/chrome_paths.h"
20 #include "chrome/common/chrome_switches.h" 19 #include "chrome/common/chrome_switches.h"
21 #include "chrome/common/pref_names.h" 20 #include "chrome/common/pref_names.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 "content/public/test/browser_test_utils.h" 24 #include "content/public/test/browser_test_utils.h"
26 #include "net/base/filename_util.h" 25 #include "net/base/filename_util.h"
(...skipping 25 matching lines...) Expand all
52 51
53 base::FilePath page2_path = test_directory.AppendASCII("iframe.html"); 52 base::FilePath page2_path = test_directory.AppendASCII("iframe.html");
54 ui_test_utils::NavigateToURLWithDisposition( 53 ui_test_utils::NavigateToURLWithDisposition(
55 browser(), 54 browser(),
56 net::FilePathToFileURL(page2_path), 55 net::FilePathToFileURL(page2_path),
57 NEW_FOREGROUND_TAB, 56 NEW_FOREGROUND_TAB,
58 kBrowserTestFlags); 57 kBrowserTestFlags);
59 } 58 }
60 }; 59 };
61 60
61 class MetricsServiceReportingTest : public InProcessBrowserTest {
62 public:
63 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
64 // Enable the metrics service for testing (in the full mode).
65 command_line->AppendSwitch(switches::kEnableMetricsReportingForTesting);
66 }
67 };
68
62 IN_PROC_BROWSER_TEST_F(MetricsServiceBrowserTest, CloseRenderersNormally) { 69 IN_PROC_BROWSER_TEST_F(MetricsServiceBrowserTest, CloseRenderersNormally) {
63 OpenTabs(); 70 OpenTabs();
64 71
65 // Verify that the expected stability metrics were recorded. 72 // Verify that the expected stability metrics were recorded.
66 const PrefService* prefs = g_browser_process->local_state(); 73 const PrefService* prefs = g_browser_process->local_state();
67 EXPECT_EQ(1, prefs->GetInteger(prefs::kStabilityLaunchCount)); 74 EXPECT_EQ(1, prefs->GetInteger(prefs::kStabilityLaunchCount));
68 EXPECT_EQ(3, prefs->GetInteger(prefs::kStabilityPageLoadCount)); 75 EXPECT_EQ(3, prefs->GetInteger(prefs::kStabilityPageLoadCount));
69 EXPECT_EQ(0, prefs->GetInteger(prefs::kStabilityRendererCrashCount)); 76 EXPECT_EQ(0, prefs->GetInteger(prefs::kStabilityRendererCrashCount));
70 // TODO(isherman): We should also verify that prefs::kStabilityExitedCleanly 77 // TODO(isherman): We should also verify that prefs::kStabilityExitedCleanly
71 // is set to true, but this preference isn't set until the browser 78 // is set to true, but this preference isn't set until the browser
(...skipping 29 matching lines...) Expand all
101 108
102 // Verify that the expected stability metrics were recorded. 109 // Verify that the expected stability metrics were recorded.
103 EXPECT_EQ(1, prefs->GetInteger(prefs::kStabilityLaunchCount)); 110 EXPECT_EQ(1, prefs->GetInteger(prefs::kStabilityLaunchCount));
104 EXPECT_EQ(4, prefs->GetInteger(prefs::kStabilityPageLoadCount)); 111 EXPECT_EQ(4, prefs->GetInteger(prefs::kStabilityPageLoadCount));
105 EXPECT_EQ(1, prefs->GetInteger(prefs::kStabilityRendererCrashCount)); 112 EXPECT_EQ(1, prefs->GetInteger(prefs::kStabilityRendererCrashCount));
106 // TODO(isherman): We should also verify that prefs::kStabilityExitedCleanly 113 // TODO(isherman): We should also verify that prefs::kStabilityExitedCleanly
107 // is set to true, but this preference isn't set until the browser 114 // is set to true, but this preference isn't set until the browser
108 // exits... it's not clear to me how to test that. 115 // exits... it's not clear to me how to test that.
109 } 116 }
110 117
118 IN_PROC_BROWSER_TEST_F(MetricsServiceBrowserTest, CheckLowEntropySourceUsed) {
119 // Since MetricsService is only in recording mode, and is not reporting,
120 // check that the low entropy source is returned at some point.
121 ASSERT_TRUE(g_browser_process->metrics_service());
122 EXPECT_EQ(MetricsService::LAST_ENTROPY_LOW,
123 g_browser_process->metrics_service()->entropy_source_returned());
124 }
125
126 IN_PROC_BROWSER_TEST_F(MetricsServiceReportingTest,
127 CheckHighEntropySourceUsed) {
128 // Since the full metrics service runs in this test, we expect that
129 // MetricsService returns the full entropy source at some point during
130 // BrowserMain startup.
131 ASSERT_TRUE(g_browser_process->metrics_service());
132 EXPECT_EQ(MetricsService::LAST_ENTROPY_HIGH,
133 g_browser_process->metrics_service()->entropy_source_returned());
134 }
OLDNEW
« no previous file with comments | « trunk/src/chrome/browser/metrics/metrics_service.cc ('k') | trunk/src/chrome/browser/metrics/metrics_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698