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> |
(...skipping 28 matching lines...) Expand all Loading... |
39 void OpenTabs() { | 39 void OpenTabs() { |
40 const int kBrowserTestFlags = | 40 const int kBrowserTestFlags = |
41 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB | | 41 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB | |
42 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION; | 42 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION; |
43 | 43 |
44 base::FilePath test_directory; | 44 base::FilePath test_directory; |
45 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_directory)); | 45 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_directory)); |
46 | 46 |
47 base::FilePath page1_path = test_directory.AppendASCII("title2.html"); | 47 base::FilePath page1_path = test_directory.AppendASCII("title2.html"); |
48 ui_test_utils::NavigateToURLWithDisposition( | 48 ui_test_utils::NavigateToURLWithDisposition( |
49 browser(), | 49 browser(), net::FilePathToFileURL(page1_path), |
50 net::FilePathToFileURL(page1_path), | 50 WindowOpenDisposition::NEW_FOREGROUND_TAB, kBrowserTestFlags); |
51 NEW_FOREGROUND_TAB, | |
52 kBrowserTestFlags); | |
53 | 51 |
54 base::FilePath page2_path = test_directory.AppendASCII("iframe.html"); | 52 base::FilePath page2_path = test_directory.AppendASCII("iframe.html"); |
55 ui_test_utils::NavigateToURLWithDisposition( | 53 ui_test_utils::NavigateToURLWithDisposition( |
56 browser(), | 54 browser(), net::FilePathToFileURL(page2_path), |
57 net::FilePathToFileURL(page2_path), | 55 WindowOpenDisposition::NEW_FOREGROUND_TAB, kBrowserTestFlags); |
58 NEW_FOREGROUND_TAB, | |
59 kBrowserTestFlags); | |
60 } | 56 } |
61 }; | 57 }; |
62 | 58 |
63 IN_PROC_BROWSER_TEST_F(MetricsServiceBrowserTest, CloseRenderersNormally) { | 59 IN_PROC_BROWSER_TEST_F(MetricsServiceBrowserTest, CloseRenderersNormally) { |
64 OpenTabs(); | 60 OpenTabs(); |
65 | 61 |
66 // Verify that the expected stability metrics were recorded. | 62 // Verify that the expected stability metrics were recorded. |
67 const PrefService* prefs = g_browser_process->local_state(); | 63 const PrefService* prefs = g_browser_process->local_state(); |
68 EXPECT_EQ(1, prefs->GetInteger(metrics::prefs::kStabilityLaunchCount)); | 64 EXPECT_EQ(1, prefs->GetInteger(metrics::prefs::kStabilityLaunchCount)); |
69 EXPECT_EQ(3, prefs->GetInteger(metrics::prefs::kStabilityPageLoadCount)); | 65 EXPECT_EQ(3, prefs->GetInteger(metrics::prefs::kStabilityPageLoadCount)); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 // Verify that the expected stability metrics were recorded. | 102 // Verify that the expected stability metrics were recorded. |
107 EXPECT_EQ(1, prefs->GetInteger(metrics::prefs::kStabilityLaunchCount)); | 103 EXPECT_EQ(1, prefs->GetInteger(metrics::prefs::kStabilityLaunchCount)); |
108 EXPECT_EQ(4, prefs->GetInteger(metrics::prefs::kStabilityPageLoadCount)); | 104 EXPECT_EQ(4, prefs->GetInteger(metrics::prefs::kStabilityPageLoadCount)); |
109 EXPECT_EQ(1, prefs->GetInteger(metrics::prefs::kStabilityRendererCrashCount)); | 105 EXPECT_EQ(1, prefs->GetInteger(metrics::prefs::kStabilityRendererCrashCount)); |
110 // TODO(isherman): We should also verify that | 106 // TODO(isherman): We should also verify that |
111 // metrics::prefs::kStabilityExitedCleanly | 107 // metrics::prefs::kStabilityExitedCleanly |
112 // is set to true, but this preference isn't set until the browser | 108 // 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. | 109 // exits... it's not clear to me how to test that. |
114 } | 110 } |
115 | 111 |
OLD | NEW |