| 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/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 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 base::FilePath(kTestDir).AppendASCII(kAutoDetectDir); | 289 base::FilePath(kTestDir).AppendASCII(kAutoDetectDir); |
| 290 | 290 |
| 291 // Set the default charset to one of encodings not supported by the current | 291 // Set the default charset to one of encodings not supported by the current |
| 292 // auto-detector (Please refer to the above comments) to make sure we | 292 // auto-detector (Please refer to the above comments) to make sure we |
| 293 // incorrectly decode the page. Now we use ISO-8859-4. | 293 // incorrectly decode the page. Now we use ISO-8859-4. |
| 294 browser()->profile()->GetPrefs()->SetString(prefs::kDefaultCharset, | 294 browser()->profile()->GetPrefs()->SetString(prefs::kDefaultCharset, |
| 295 "ISO-8859-4"); | 295 "ISO-8859-4"); |
| 296 | 296 |
| 297 content::WebContents* web_contents = | 297 content::WebContents* web_contents = |
| 298 browser()->tab_strip_model()->GetActiveWebContents(); | 298 browser()->tab_strip_model()->GetActiveWebContents(); |
| 299 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestDatas); ++i) { | 299 for (size_t i = 0; i < arraysize(kTestDatas); ++i) { |
| 300 // Disable auto detect if it is on. | 300 // Disable auto detect if it is on. |
| 301 browser()->profile()->GetPrefs()->SetBoolean( | 301 browser()->profile()->GetPrefs()->SetBoolean( |
| 302 prefs::kWebKitUsesUniversalDetector, false); | 302 prefs::kWebKitUsesUniversalDetector, false); |
| 303 | 303 |
| 304 base::FilePath test_file_path(test_dir_path); | 304 base::FilePath test_file_path(test_dir_path); |
| 305 test_file_path = test_file_path.AppendASCII(kTestDatas[i].test_file_name); | 305 test_file_path = test_file_path.AppendASCII(kTestDatas[i].test_file_name); |
| 306 GURL url = net::URLRequestMockHTTPJob::GetMockUrl(test_file_path); | 306 GURL url = net::URLRequestMockHTTPJob::GetMockUrl(test_file_path); |
| 307 ui_test_utils::NavigateToURL(browser(), url); | 307 ui_test_utils::NavigateToURL(browser(), url); |
| 308 | 308 |
| 309 // Get the encoding used for the page, it must be the default charset we | 309 // Get the encoding used for the page, it must be the default charset we |
| (...skipping 13 matching lines...) Expand all Loading... |
| 323 | 323 |
| 324 // Dump the page, the content of dump page should be equal with our expect | 324 // Dump the page, the content of dump page should be equal with our expect |
| 325 // result file. | 325 // result file. |
| 326 base::FilePath expected_result_file_name = | 326 base::FilePath expected_result_file_name = |
| 327 base::FilePath().AppendASCII(kAutoDetectDir). | 327 base::FilePath().AppendASCII(kAutoDetectDir). |
| 328 AppendASCII(kExpectedResultDir). | 328 AppendASCII(kExpectedResultDir). |
| 329 AppendASCII(kTestDatas[i].expected_result); | 329 AppendASCII(kTestDatas[i].expected_result); |
| 330 SaveAndCompare(kTestDatas[i].test_file_name, expected_result_file_name); | 330 SaveAndCompare(kTestDatas[i].test_file_name, expected_result_file_name); |
| 331 } | 331 } |
| 332 } | 332 } |
| OLD | NEW |