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

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

Issue 5646003: Sanitize PrefStore interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix PrefService mock construction in PrefServiceTest to include command line store. Created 10 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/platform_thread.h" 13 #include "base/platform_thread.h"
14 #include "chrome/browser/browser_thread.h" 14 #include "chrome/browser/browser_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_value_store.h" 17 #include "chrome/browser/prefs/pref_value_store.h"
17 #include "chrome/common/chrome_constants.h" 18 #include "chrome/common/chrome_constants.h"
18 #include "chrome/common/chrome_paths.h" 19 #include "chrome/common/chrome_paths.h"
19 #include "chrome/common/json_pref_store.h" 20 #include "chrome/common/json_pref_store.h"
20 #include "chrome/common/pref_names.h" 21 #include "chrome/common/pref_names.h"
21 #include "chrome/common/url_constants.h" 22 #include "chrome/common/url_constants.h"
23 #include "chrome/test/automation/browser_proxy.h"
22 #include "chrome/test/automation/tab_proxy.h" 24 #include "chrome/test/automation/tab_proxy.h"
23 #include "chrome/test/automation/browser_proxy.h"
24 #include "chrome/test/ui/ui_test.h" 25 #include "chrome/test/ui/ui_test.h"
25 #include "net/base/net_util.h" 26 #include "net/base/net_util.h"
26 27
27 class MetricsServiceTest : public UITest { 28 class MetricsServiceTest : public UITest {
28 public: 29 public:
29 MetricsServiceTest() : UITest() { 30 MetricsServiceTest() : UITest() {
30 // We need to show the window so web content type tabs load. 31 // We need to show the window so web content type tabs load.
31 show_window_ = true; 32 show_window_ = true;
32 } 33 }
33 34
(...skipping 10 matching lines...) Expand all
44 FilePath page2_path; 45 FilePath page2_path;
45 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &page2_path)); 46 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &page2_path));
46 page2_path = page2_path.AppendASCII("iframe.html"); 47 page2_path = page2_path.AppendASCII("iframe.html");
47 ASSERT_TRUE(window->AppendTab(net::FilePathToFileURL(page2_path))); 48 ASSERT_TRUE(window->AppendTab(net::FilePathToFileURL(page2_path)));
48 } 49 }
49 50
50 // Get a PrefService whose contents correspond to the Local State file 51 // Get a PrefService whose contents correspond to the Local State file
51 // that was saved by the app as it closed. The caller takes ownership of the 52 // that was saved by the app as it closed. The caller takes ownership of the
52 // returned PrefService object. 53 // returned PrefService object.
53 PrefService* GetLocalState() { 54 PrefService* GetLocalState() {
54 FilePath local_state_path = user_data_dir() 55 FilePath path = user_data_dir().Append(chrome::kLocalStateFilename);
55 .Append(chrome::kLocalStateFilename); 56 return PrefServiceMockBuilder().WithUserFilePrefs(path).Create();
56
57 return PrefService::CreateUserPrefService(local_state_path);
58 } 57 }
59 }; 58 };
60 59
61 TEST_F(MetricsServiceTest, CloseRenderersNormally) { 60 TEST_F(MetricsServiceTest, CloseRenderersNormally) {
62 OpenTabs(); 61 OpenTabs();
63 QuitBrowser(); 62 QuitBrowser();
64 63
65 scoped_ptr<PrefService> local_state(GetLocalState()); 64 scoped_ptr<PrefService> local_state(GetLocalState());
66 local_state->RegisterBooleanPref(prefs::kStabilityExitedCleanly, true); 65 local_state->RegisterBooleanPref(prefs::kStabilityExitedCleanly, true);
67 local_state->RegisterIntegerPref(prefs::kStabilityLaunchCount, 0); 66 local_state->RegisterIntegerPref(prefs::kStabilityLaunchCount, 0);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 scoped_ptr<PrefService> local_state(GetLocalState()); 107 scoped_ptr<PrefService> local_state(GetLocalState());
109 local_state->RegisterBooleanPref(prefs::kStabilityExitedCleanly, true); 108 local_state->RegisterBooleanPref(prefs::kStabilityExitedCleanly, true);
110 local_state->RegisterIntegerPref(prefs::kStabilityLaunchCount, 0); 109 local_state->RegisterIntegerPref(prefs::kStabilityLaunchCount, 0);
111 local_state->RegisterIntegerPref(prefs::kStabilityPageLoadCount, 0); 110 local_state->RegisterIntegerPref(prefs::kStabilityPageLoadCount, 0);
112 local_state->RegisterIntegerPref(prefs::kStabilityRendererCrashCount, 0); 111 local_state->RegisterIntegerPref(prefs::kStabilityRendererCrashCount, 0);
113 EXPECT_TRUE(local_state->GetBoolean(prefs::kStabilityExitedCleanly)); 112 EXPECT_TRUE(local_state->GetBoolean(prefs::kStabilityExitedCleanly));
114 EXPECT_EQ(1, local_state->GetInteger(prefs::kStabilityLaunchCount)); 113 EXPECT_EQ(1, local_state->GetInteger(prefs::kStabilityLaunchCount));
115 EXPECT_EQ(4, local_state->GetInteger(prefs::kStabilityPageLoadCount)); 114 EXPECT_EQ(4, local_state->GetInteger(prefs::kStabilityPageLoadCount));
116 EXPECT_EQ(1, local_state->GetInteger(prefs::kStabilityRendererCrashCount)); 115 EXPECT_EQ(1, local_state->GetInteger(prefs::kStabilityRendererCrashCount));
117 } 116 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/test_extension_prefs.cc ('k') | chrome/browser/net/pref_proxy_config_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698