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

Side by Side Diff: chrome/browser/history/history_browsertest.cc

Issue 10831103: Removing usage of profile_->GetHistory() from the codebase in order to remove that function. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 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
« no previous file with comments | « no previous file | chrome/browser/predictors/autocomplete_action_predictor.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include <vector> 5 #include <vector>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 FilePath().AppendASCII("History"), 151 FilePath().AppendASCII("History"),
152 FilePath().AppendASCII(filename)); 152 FilePath().AppendASCII(filename));
153 LoadAndWaitForURL(url); 153 LoadAndWaitForURL(url);
154 } 154 }
155 }; 155 };
156 156
157 // Test that the browser history is saved (default setting). 157 // Test that the browser history is saved (default setting).
158 IN_PROC_BROWSER_TEST_F(HistoryBrowserTest, SavingHistoryEnabled) { 158 IN_PROC_BROWSER_TEST_F(HistoryBrowserTest, SavingHistoryEnabled) {
159 EXPECT_FALSE(GetPrefs()->GetBoolean(prefs::kSavingBrowserHistoryDisabled)); 159 EXPECT_FALSE(GetPrefs()->GetBoolean(prefs::kSavingBrowserHistoryDisabled));
160 160
161 EXPECT_TRUE(GetProfile()->GetHistoryService(Profile::EXPLICIT_ACCESS)); 161 EXPECT_TRUE(HistoryServiceFactory::GetForProfile(
162 EXPECT_TRUE(GetProfile()->GetHistoryService(Profile::IMPLICIT_ACCESS)); 162 GetProfile(), Profile::EXPLICIT_ACCESS));
163 EXPECT_TRUE(HistoryServiceFactory::GetForProfile(
164 GetProfile(), Profile::IMPLICIT_ACCESS));
163 165
164 ui_test_utils::WaitForHistoryToLoad( 166 ui_test_utils::WaitForHistoryToLoad(HistoryServiceFactory::GetForProfile(
165 browser()->profile()->GetHistoryService(Profile::EXPLICIT_ACCESS)); 167 browser()->profile(), Profile::EXPLICIT_ACCESS));
166 ExpectEmptyHistory(); 168 ExpectEmptyHistory();
167 169
168 ui_test_utils::NavigateToURL(browser(), GetTestUrl()); 170 ui_test_utils::NavigateToURL(browser(), GetTestUrl());
169 WaitForHistoryBackendToRun(); 171 WaitForHistoryBackendToRun();
170 172
171 { 173 {
172 std::vector<GURL> urls(GetHistoryContents()); 174 std::vector<GURL> urls(GetHistoryContents());
173 ASSERT_EQ(1U, urls.size()); 175 ASSERT_EQ(1U, urls.size());
174 EXPECT_EQ(GetTestUrl().spec(), urls[0].spec()); 176 EXPECT_EQ(GetTestUrl().spec(), urls[0].spec());
175 } 177 }
176 } 178 }
177 179
178 // Test that disabling saving browser history really works. 180 // Test that disabling saving browser history really works.
179 IN_PROC_BROWSER_TEST_F(HistoryBrowserTest, SavingHistoryDisabled) { 181 IN_PROC_BROWSER_TEST_F(HistoryBrowserTest, SavingHistoryDisabled) {
180 GetPrefs()->SetBoolean(prefs::kSavingBrowserHistoryDisabled, true); 182 GetPrefs()->SetBoolean(prefs::kSavingBrowserHistoryDisabled, true);
181 183
182 EXPECT_TRUE(GetProfile()->GetHistoryService(Profile::EXPLICIT_ACCESS)); 184 EXPECT_TRUE(HistoryServiceFactory::GetForProfile(
183 EXPECT_FALSE(GetProfile()->GetHistoryService(Profile::IMPLICIT_ACCESS)); 185 GetProfile(), Profile::EXPLICIT_ACCESS));
186 EXPECT_FALSE(HistoryServiceFactory::GetForProfile(
187 GetProfile(), Profile::IMPLICIT_ACCESS));
184 188
185 ui_test_utils::WaitForHistoryToLoad( 189 ui_test_utils::WaitForHistoryToLoad(HistoryServiceFactory::GetForProfile(
186 browser()->profile()->GetHistoryService(Profile::EXPLICIT_ACCESS)); 190 browser()->profile(), Profile::EXPLICIT_ACCESS));
187 ExpectEmptyHistory(); 191 ExpectEmptyHistory();
188 192
189 ui_test_utils::NavigateToURL(browser(), GetTestUrl()); 193 ui_test_utils::NavigateToURL(browser(), GetTestUrl());
190 WaitForHistoryBackendToRun(); 194 WaitForHistoryBackendToRun();
191 ExpectEmptyHistory(); 195 ExpectEmptyHistory();
192 } 196 }
193 197
194 // Test that changing the pref takes effect immediately 198 // Test that changing the pref takes effect immediately
195 // when the browser is running. 199 // when the browser is running.
196 IN_PROC_BROWSER_TEST_F(HistoryBrowserTest, SavingHistoryEnabledThenDisabled) { 200 IN_PROC_BROWSER_TEST_F(HistoryBrowserTest, SavingHistoryEnabledThenDisabled) {
197 EXPECT_FALSE(GetPrefs()->GetBoolean(prefs::kSavingBrowserHistoryDisabled)); 201 EXPECT_FALSE(GetPrefs()->GetBoolean(prefs::kSavingBrowserHistoryDisabled));
198 202
199 ui_test_utils::WaitForHistoryToLoad( 203 ui_test_utils::WaitForHistoryToLoad(HistoryServiceFactory::GetForProfile(
200 browser()->profile()->GetHistoryService(Profile::EXPLICIT_ACCESS)); 204 browser()->profile(), Profile::EXPLICIT_ACCESS));
201 205
202 ui_test_utils::NavigateToURL(browser(), GetTestUrl()); 206 ui_test_utils::NavigateToURL(browser(), GetTestUrl());
203 WaitForHistoryBackendToRun(); 207 WaitForHistoryBackendToRun();
204 208
205 { 209 {
206 std::vector<GURL> urls(GetHistoryContents()); 210 std::vector<GURL> urls(GetHistoryContents());
207 ASSERT_EQ(1U, urls.size()); 211 ASSERT_EQ(1U, urls.size());
208 EXPECT_EQ(GetTestUrl().spec(), urls[0].spec()); 212 EXPECT_EQ(GetTestUrl().spec(), urls[0].spec());
209 } 213 }
210 214
211 GetPrefs()->SetBoolean(prefs::kSavingBrowserHistoryDisabled, true); 215 GetPrefs()->SetBoolean(prefs::kSavingBrowserHistoryDisabled, true);
212 216
213 ui_test_utils::NavigateToURL(browser(), GetTestUrl()); 217 ui_test_utils::NavigateToURL(browser(), GetTestUrl());
214 WaitForHistoryBackendToRun(); 218 WaitForHistoryBackendToRun();
215 219
216 { 220 {
217 // No additional entries should be present in the history. 221 // No additional entries should be present in the history.
218 std::vector<GURL> urls(GetHistoryContents()); 222 std::vector<GURL> urls(GetHistoryContents());
219 ASSERT_EQ(1U, urls.size()); 223 ASSERT_EQ(1U, urls.size());
220 EXPECT_EQ(GetTestUrl().spec(), urls[0].spec()); 224 EXPECT_EQ(GetTestUrl().spec(), urls[0].spec());
221 } 225 }
222 } 226 }
223 227
224 // Test that changing the pref takes effect immediately 228 // Test that changing the pref takes effect immediately
225 // when the browser is running. 229 // when the browser is running.
226 IN_PROC_BROWSER_TEST_F(HistoryBrowserTest, SavingHistoryDisabledThenEnabled) { 230 IN_PROC_BROWSER_TEST_F(HistoryBrowserTest, SavingHistoryDisabledThenEnabled) {
227 GetPrefs()->SetBoolean(prefs::kSavingBrowserHistoryDisabled, true); 231 GetPrefs()->SetBoolean(prefs::kSavingBrowserHistoryDisabled, true);
228 232
229 ui_test_utils::WaitForHistoryToLoad( 233 ui_test_utils::WaitForHistoryToLoad(HistoryServiceFactory::GetForProfile(
230 browser()->profile()->GetHistoryService(Profile::EXPLICIT_ACCESS)); 234 browser()->profile(), Profile::EXPLICIT_ACCESS));
231 ExpectEmptyHistory(); 235 ExpectEmptyHistory();
232 236
233 ui_test_utils::NavigateToURL(browser(), GetTestUrl()); 237 ui_test_utils::NavigateToURL(browser(), GetTestUrl());
234 WaitForHistoryBackendToRun(); 238 WaitForHistoryBackendToRun();
235 ExpectEmptyHistory(); 239 ExpectEmptyHistory();
236 240
237 GetPrefs()->SetBoolean(prefs::kSavingBrowserHistoryDisabled, false); 241 GetPrefs()->SetBoolean(prefs::kSavingBrowserHistoryDisabled, false);
238 242
239 ui_test_utils::NavigateToURL(browser(), GetTestUrl()); 243 ui_test_utils::NavigateToURL(browser(), GetTestUrl());
240 WaitForHistoryBackendToRun(); 244 WaitForHistoryBackendToRun();
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 // Mainly, this is to ensure we send a synchronous message to the renderer 307 // Mainly, this is to ensure we send a synchronous message to the renderer
304 // so that we're not susceptible (less susceptible?) to a race condition. 308 // so that we're not susceptible (less susceptible?) to a race condition.
305 // Should a race condition ever trigger, it won't result in flakiness. 309 // Should a race condition ever trigger, it won't result in flakiness.
306 int num = ui_test_utils::FindInPage( 310 int num = ui_test_utils::FindInPage(
307 chrome::GetActiveTabContents(browser()), ASCIIToUTF16("<img"), true, 311 chrome::GetActiveTabContents(browser()), ASCIIToUTF16("<img"), true,
308 true, NULL); 312 true, NULL);
309 EXPECT_GT(num, 0); 313 EXPECT_GT(num, 0);
310 EXPECT_EQ(ASCIIToUTF16("History"), 314 EXPECT_EQ(ASCIIToUTF16("History"),
311 chrome::GetActiveWebContents(browser())->GetTitle()); 315 chrome::GetActiveWebContents(browser())->GetTitle());
312 } 316 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/predictors/autocomplete_action_predictor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698