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

Side by Side Diff: chrome/browser/metrics/metrics_service_uitest.cc

Issue 7601006: GTTF: Use a fresh TestingBrowserProcess for each test, part #5 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 4 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <string> 8 #include <string>
9 9
10 #include "base/file_path.h" 10 #include "base/file_path.h"
11 #include "base/file_util.h" 11 #include "base/file_util.h"
12 #include "base/path_service.h" 12 #include "base/path_service.h"
13 #include "base/test/test_timeouts.h" 13 #include "base/test/test_timeouts.h"
14 #include "base/threading/platform_thread.h" 14 #include "base/threading/platform_thread.h"
15 #include "chrome/browser/prefs/pref_service.h" 15 #include "chrome/browser/prefs/pref_service.h"
16 #include "chrome/browser/prefs/pref_service_mock_builder.h" 16 #include "chrome/browser/prefs/pref_service_mock_builder.h"
17 #include "chrome/browser/prefs/pref_value_store.h" 17 #include "chrome/browser/prefs/pref_value_store.h"
18 #include "chrome/common/chrome_constants.h" 18 #include "chrome/common/chrome_constants.h"
19 #include "chrome/common/chrome_paths.h" 19 #include "chrome/common/chrome_paths.h"
20 #include "chrome/common/json_pref_store.h" 20 #include "chrome/common/json_pref_store.h"
21 #include "chrome/common/pref_names.h" 21 #include "chrome/common/pref_names.h"
22 #include "chrome/common/url_constants.h" 22 #include "chrome/common/url_constants.h"
23 #include "chrome/test/automation/automation_proxy.h" 23 #include "chrome/test/automation/automation_proxy.h"
24 #include "chrome/test/automation/browser_proxy.h" 24 #include "chrome/test/automation/browser_proxy.h"
25 #include "chrome/test/automation/tab_proxy.h" 25 #include "chrome/test/automation/tab_proxy.h"
26 #include "chrome/test/ui/ui_test.h" 26 #include "chrome/test/ui/ui_test.h"
27 #include "content/common/notification_service.h"
27 #include "net/base/net_util.h" 28 #include "net/base/net_util.h"
28 29
29 class MetricsServiceTest : public UITest { 30 class MetricsServiceTest : public UITest {
30 public: 31 public:
31 MetricsServiceTest() : UITest() { 32 MetricsServiceTest() : UITest() {
32 // We need to show the window so web content type tabs load. 33 // We need to show the window so web content type tabs load.
33 show_window_ = true; 34 show_window_ = true;
34 } 35 }
35 36
36 // Open a few tabs of random content 37 // Open a few tabs of random content
(...skipping 12 matching lines...) Expand all
49 ASSERT_TRUE(window->AppendTab(net::FilePathToFileURL(page2_path))); 50 ASSERT_TRUE(window->AppendTab(net::FilePathToFileURL(page2_path)));
50 } 51 }
51 52
52 // Get a PrefService whose contents correspond to the Local State file 53 // Get a PrefService whose contents correspond to the Local State file
53 // that was saved by the app as it closed. The caller takes ownership of the 54 // that was saved by the app as it closed. The caller takes ownership of the
54 // returned PrefService object. 55 // returned PrefService object.
55 PrefService* GetLocalState() { 56 PrefService* GetLocalState() {
56 FilePath path = user_data_dir().Append(chrome::kLocalStateFilename); 57 FilePath path = user_data_dir().Append(chrome::kLocalStateFilename);
57 return PrefServiceMockBuilder().WithUserFilePrefs(path).Create(); 58 return PrefServiceMockBuilder().WithUserFilePrefs(path).Create();
58 } 59 }
60 #if defined(OS_WIN)
61 // This is not really Windows-specific, the transition is just being done
62 // in stages, and Windows is first. See below for more info.
63 // TODO(phajdan.jr): Remove #ifdef after fixing http://crbug.com/61062.
64 private:
65 NotificationService notification_service_;
66 #endif
59 }; 67 };
60 68
61 TEST_F(MetricsServiceTest, CloseRenderersNormally) { 69 TEST_F(MetricsServiceTest, CloseRenderersNormally) {
62 OpenTabs(); 70 OpenTabs();
63 QuitBrowser(); 71 QuitBrowser();
64 72
65 scoped_ptr<PrefService> local_state(GetLocalState()); 73 scoped_ptr<PrefService> local_state(GetLocalState());
66 local_state->RegisterBooleanPref(prefs::kStabilityExitedCleanly, true); 74 local_state->RegisterBooleanPref(prefs::kStabilityExitedCleanly, true);
67 local_state->RegisterIntegerPref(prefs::kStabilityLaunchCount, 0); 75 local_state->RegisterIntegerPref(prefs::kStabilityLaunchCount, 0);
68 local_state->RegisterIntegerPref(prefs::kStabilityPageLoadCount, 0); 76 local_state->RegisterIntegerPref(prefs::kStabilityPageLoadCount, 0);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 EXPECT_TRUE(local_state->GetBoolean(prefs::kStabilityExitedCleanly)); 126 EXPECT_TRUE(local_state->GetBoolean(prefs::kStabilityExitedCleanly));
119 EXPECT_EQ(1, local_state->GetInteger(prefs::kStabilityLaunchCount)); 127 EXPECT_EQ(1, local_state->GetInteger(prefs::kStabilityLaunchCount));
120 #if defined(TOUCH_UI) 128 #if defined(TOUCH_UI)
121 // The keyboard page loads for touchui. 129 // The keyboard page loads for touchui.
122 EXPECT_EQ(5, local_state->GetInteger(prefs::kStabilityPageLoadCount)); 130 EXPECT_EQ(5, local_state->GetInteger(prefs::kStabilityPageLoadCount));
123 #else 131 #else
124 EXPECT_EQ(4, local_state->GetInteger(prefs::kStabilityPageLoadCount)); 132 EXPECT_EQ(4, local_state->GetInteger(prefs::kStabilityPageLoadCount));
125 #endif 133 #endif
126 EXPECT_EQ(1, local_state->GetInteger(prefs::kStabilityRendererCrashCount)); 134 EXPECT_EQ(1, local_state->GetInteger(prefs::kStabilityRendererCrashCount));
127 } 135 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698