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

Side by Side Diff: chrome/browser/browser_encoding_browsertest.cc

Issue 1391423002: net: Remove FilePath version of URLRequestMockHTTPJob::GetMockUrl(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: mmenke review Created 5 years, 2 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
« no previous file with comments | « no previous file | chrome/browser/browsing_data/browsing_data_remover_browsertest.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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/files/file_util.h" 6 #include "base/files/file_util.h"
7 #include "base/files/scoped_temp_dir.h" 7 #include "base/files/scoped_temp_dir.h"
8 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "chrome/browser/character_encoding.h" 9 #include "chrome/browser/character_encoding.h"
10 #include "chrome/browser/net/url_request_mock_util.h" 10 #include "chrome/browser/net/url_request_mock_util.h"
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 // also necessary. 159 // also necessary.
160 IN_PROC_BROWSER_TEST_P(BrowserEncodingTest, TestEncodingAliasMapping) { 160 IN_PROC_BROWSER_TEST_P(BrowserEncodingTest, TestEncodingAliasMapping) {
161 const char* const kAliasTestDir = "alias_mapping"; 161 const char* const kAliasTestDir = "alias_mapping";
162 162
163 base::FilePath test_dir_path = base::FilePath(kTestDir).AppendASCII( 163 base::FilePath test_dir_path = base::FilePath(kTestDir).AppendASCII(
164 kAliasTestDir); 164 kAliasTestDir);
165 base::FilePath test_file_path(test_dir_path); 165 base::FilePath test_file_path(test_dir_path);
166 test_file_path = test_file_path.AppendASCII( 166 test_file_path = test_file_path.AppendASCII(
167 GetParam().file_name); 167 GetParam().file_name);
168 168
169 GURL url = net::URLRequestMockHTTPJob::GetMockUrl(test_file_path); 169 GURL url =
170 net::URLRequestMockHTTPJob::GetMockUrl(test_file_path.MaybeAsASCII());
170 ui_test_utils::NavigateToURL(browser(), url); 171 ui_test_utils::NavigateToURL(browser(), url);
171 EXPECT_EQ(GetParam().encoding_name, 172 EXPECT_EQ(GetParam().encoding_name,
172 browser()->tab_strip_model()->GetActiveWebContents()-> 173 browser()->tab_strip_model()->GetActiveWebContents()->
173 GetEncoding()); 174 GetEncoding());
174 } 175 }
175 176
176 INSTANTIATE_TEST_CASE_P(EncodingAliases, 177 INSTANTIATE_TEST_CASE_P(EncodingAliases,
177 BrowserEncodingTest, 178 BrowserEncodingTest,
178 testing::ValuesIn(kEncodingTestDatas)); 179 testing::ValuesIn(kEncodingTestDatas));
179 180
180 // Marked as flaky: see http://crbug.com/44668 181 // Marked as flaky: see http://crbug.com/44668
181 IN_PROC_BROWSER_TEST_F(BrowserEncodingTest, DISABLED_TestOverrideEncoding) { 182 IN_PROC_BROWSER_TEST_F(BrowserEncodingTest, DISABLED_TestOverrideEncoding) {
182 const char* const kTestFileName = "gb18030_with_iso88591_meta.html"; 183 const char* const kTestFileName = "gb18030_with_iso88591_meta.html";
183 const char* const kExpectedFileName = 184 const char* const kExpectedFileName =
184 "expected_gb18030_saved_from_iso88591_meta.html"; 185 "expected_gb18030_saved_from_iso88591_meta.html";
185 const char* const kOverrideTestDir = "user_override"; 186 const char* const kOverrideTestDir = "user_override";
186 187
187 base::FilePath test_dir_path = 188 base::FilePath test_dir_path =
188 base::FilePath(kTestDir).AppendASCII(kOverrideTestDir); 189 base::FilePath(kTestDir).AppendASCII(kOverrideTestDir);
189 test_dir_path = test_dir_path.AppendASCII(kTestFileName); 190 test_dir_path = test_dir_path.AppendASCII(kTestFileName);
190 GURL url = net::URLRequestMockHTTPJob::GetMockUrl(test_dir_path); 191 GURL url =
192 net::URLRequestMockHTTPJob::GetMockUrl(test_dir_path.MaybeAsASCII());
191 ui_test_utils::NavigateToURL(browser(), url); 193 ui_test_utils::NavigateToURL(browser(), url);
192 content::WebContents* web_contents = 194 content::WebContents* web_contents =
193 browser()->tab_strip_model()->GetActiveWebContents(); 195 browser()->tab_strip_model()->GetActiveWebContents();
194 EXPECT_EQ("windows-1252", web_contents->GetEncoding()); 196 EXPECT_EQ("windows-1252", web_contents->GetEncoding());
195 197
196 // Override the encoding to "gb18030". 198 // Override the encoding to "gb18030".
197 const std::string selected_encoding = 199 const std::string selected_encoding =
198 CharacterEncoding::GetCanonicalEncodingNameByAliasName("gb18030"); 200 CharacterEncoding::GetCanonicalEncodingNameByAliasName("gb18030");
199 content::TestNavigationObserver navigation_observer(web_contents); 201 content::TestNavigationObserver navigation_observer(web_contents);
200 web_contents->SetOverrideEncoding(selected_encoding); 202 web_contents->SetOverrideEncoding(selected_encoding);
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 301
300 content::WebContents* web_contents = 302 content::WebContents* web_contents =
301 browser()->tab_strip_model()->GetActiveWebContents(); 303 browser()->tab_strip_model()->GetActiveWebContents();
302 for (size_t i = 0; i < arraysize(kTestDatas); ++i) { 304 for (size_t i = 0; i < arraysize(kTestDatas); ++i) {
303 // Disable auto detect if it is on. 305 // Disable auto detect if it is on.
304 browser()->profile()->GetPrefs()->SetBoolean( 306 browser()->profile()->GetPrefs()->SetBoolean(
305 prefs::kWebKitUsesUniversalDetector, false); 307 prefs::kWebKitUsesUniversalDetector, false);
306 308
307 base::FilePath test_file_path(test_dir_path); 309 base::FilePath test_file_path(test_dir_path);
308 test_file_path = test_file_path.AppendASCII(kTestDatas[i].test_file_name); 310 test_file_path = test_file_path.AppendASCII(kTestDatas[i].test_file_name);
309 GURL url = net::URLRequestMockHTTPJob::GetMockUrl(test_file_path); 311 GURL url =
312 net::URLRequestMockHTTPJob::GetMockUrl(test_file_path.MaybeAsASCII());
310 ui_test_utils::NavigateToURL(browser(), url); 313 ui_test_utils::NavigateToURL(browser(), url);
311 314
312 // Get the encoding used for the page, it must be the default charset we 315 // Get the encoding used for the page, it must be the default charset we
313 // just set. 316 // just set.
314 EXPECT_EQ("ISO-8859-4", web_contents->GetEncoding()); 317 EXPECT_EQ("ISO-8859-4", web_contents->GetEncoding());
315 318
316 // Enable the encoding auto detection. 319 // Enable the encoding auto detection.
317 browser()->profile()->GetPrefs()->SetBoolean( 320 browser()->profile()->GetPrefs()->SetBoolean(
318 prefs::kWebKitUsesUniversalDetector, true); 321 prefs::kWebKitUsesUniversalDetector, true);
319 322
320 content::TestNavigationObserver observer(web_contents); 323 content::TestNavigationObserver observer(web_contents);
321 chrome::Reload(browser(), CURRENT_TAB); 324 chrome::Reload(browser(), CURRENT_TAB);
322 observer.Wait(); 325 observer.Wait();
323 326
324 // Re-get the encoding of page. It should return the real encoding now. 327 // Re-get the encoding of page. It should return the real encoding now.
325 EXPECT_EQ(kTestDatas[i].expected_encoding, web_contents->GetEncoding()); 328 EXPECT_EQ(kTestDatas[i].expected_encoding, web_contents->GetEncoding());
326 329
327 // Dump the page, the content of dump page should be equal with our expect 330 // Dump the page, the content of dump page should be equal with our expect
328 // result file. 331 // result file.
329 base::FilePath expected_result_file_name = 332 base::FilePath expected_result_file_name =
330 base::FilePath().AppendASCII(kAutoDetectDir). 333 base::FilePath().AppendASCII(kAutoDetectDir).
331 AppendASCII(kExpectedResultDir). 334 AppendASCII(kExpectedResultDir).
332 AppendASCII(kTestDatas[i].expected_result); 335 AppendASCII(kTestDatas[i].expected_result);
333 SaveAndCompare(kTestDatas[i].test_file_name, expected_result_file_name); 336 SaveAndCompare(kTestDatas[i].test_file_name, expected_result_file_name);
334 } 337 }
335 } 338 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/browsing_data/browsing_data_remover_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698