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 #include "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
7 #include "base/scoped_temp_dir.h" | 7 #include "base/scoped_temp_dir.h" |
8 #include "chrome/browser/character_encoding.h" | 8 #include "chrome/browser/character_encoding.h" |
9 #include "chrome/browser/net/url_request_mock_util.h" | 9 #include "chrome/browser/net/url_request_mock_util.h" |
10 #include "chrome/browser/prefs/pref_service.h" | 10 #include "chrome/browser/prefs/pref_service.h" |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 }; | 248 }; |
249 const char* const kAutoDetectDir = "auto_detect"; | 249 const char* const kAutoDetectDir = "auto_detect"; |
250 // Directory of the files of expected results. | 250 // Directory of the files of expected results. |
251 const char* const kExpectedResultDir = "expected_results"; | 251 const char* const kExpectedResultDir = "expected_results"; |
252 | 252 |
253 FilePath test_dir_path = FilePath(kTestDir).AppendASCII(kAutoDetectDir); | 253 FilePath test_dir_path = FilePath(kTestDir).AppendASCII(kAutoDetectDir); |
254 | 254 |
255 // Set the default charset to one of encodings not supported by the current | 255 // Set the default charset to one of encodings not supported by the current |
256 // auto-detector (Please refer to the above comments) to make sure we | 256 // auto-detector (Please refer to the above comments) to make sure we |
257 // incorrectly decode the page. Now we use ISO-8859-4. | 257 // incorrectly decode the page. Now we use ISO-8859-4. |
258 browser()->profile()->GetPrefs()->SetString( | 258 browser()->profile()->GetPrefs()->SetString(prefs::kDefaultCharset, |
259 prefs::kGlobalDefaultCharset, "ISO-8859-4"); | 259 "ISO-8859-4"); |
260 | 260 |
261 content::WebContents* web_contents = browser()->GetSelectedWebContents(); | 261 content::WebContents* web_contents = browser()->GetSelectedWebContents(); |
262 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestDatas); ++i) { | 262 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestDatas); ++i) { |
263 // Disable auto detect if it is on. | 263 // Disable auto detect if it is on. |
264 browser()->profile()->GetPrefs()->SetBoolean( | 264 browser()->profile()->GetPrefs()->SetBoolean( |
265 prefs::kWebKitUsesUniversalDetector, false); | 265 prefs::kWebKitUsesUniversalDetector, false); |
266 | 266 |
267 FilePath test_file_path(test_dir_path); | 267 FilePath test_file_path(test_dir_path); |
268 test_file_path = test_file_path.AppendASCII(kTestDatas[i].test_file_name); | 268 test_file_path = test_file_path.AppendASCII(kTestDatas[i].test_file_name); |
269 GURL url = URLRequestMockHTTPJob::GetMockUrl(test_file_path); | 269 GURL url = URLRequestMockHTTPJob::GetMockUrl(test_file_path); |
(...skipping 17 matching lines...) Expand all Loading... |
287 EXPECT_EQ(kTestDatas[i].expected_encoding, web_contents->GetEncoding()); | 287 EXPECT_EQ(kTestDatas[i].expected_encoding, web_contents->GetEncoding()); |
288 | 288 |
289 // Dump the page, the content of dump page should be equal with our expect | 289 // Dump the page, the content of dump page should be equal with our expect |
290 // result file. | 290 // result file. |
291 FilePath expected_result_file_name = | 291 FilePath expected_result_file_name = |
292 FilePath().AppendASCII(kAutoDetectDir).AppendASCII(kExpectedResultDir). | 292 FilePath().AppendASCII(kAutoDetectDir).AppendASCII(kExpectedResultDir). |
293 AppendASCII(kTestDatas[i].expected_result); | 293 AppendASCII(kTestDatas[i].expected_result); |
294 SaveAndCompare(kTestDatas[i].test_file_name, expected_result_file_name); | 294 SaveAndCompare(kTestDatas[i].test_file_name, expected_result_file_name); |
295 } | 295 } |
296 } | 296 } |
OLD | NEW |