| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
| 9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 | 255 |
| 256 // Set the default charset to one of encodings not supported by the current | 256 // Set the default charset to one of encodings not supported by the current |
| 257 // auto-detector (Please refer to the above comments) to make sure we | 257 // auto-detector (Please refer to the above comments) to make sure we |
| 258 // incorrectly decode the page. Now we use ISO-8859-4. | 258 // incorrectly decode the page. Now we use ISO-8859-4. |
| 259 browser()->profile()->GetPrefs()->SetString(prefs::kDefaultCharset, | 259 browser()->profile()->GetPrefs()->SetString(prefs::kDefaultCharset, |
| 260 "ISO-8859-4"); | 260 "ISO-8859-4"); |
| 261 | 261 |
| 262 content::WebContents* web_contents = | 262 content::WebContents* web_contents = |
| 263 browser()->tab_strip_model()->GetActiveWebContents(); | 263 browser()->tab_strip_model()->GetActiveWebContents(); |
| 264 for (size_t i = 0; i < arraysize(kTestDatas); ++i) { | 264 for (size_t i = 0; i < arraysize(kTestDatas); ++i) { |
| 265 // Enable auto detect. | |
| 266 browser()->profile()->GetPrefs()->SetBoolean( | |
| 267 prefs::kWebKitUsesUniversalDetector, true); | |
| 268 | |
| 269 base::FilePath test_file_path(test_dir_path); | 265 base::FilePath test_file_path(test_dir_path); |
| 270 test_file_path = test_file_path.AppendASCII(kTestDatas[i].test_file_name); | 266 test_file_path = test_file_path.AppendASCII(kTestDatas[i].test_file_name); |
| 271 GURL url = | 267 GURL url = |
| 272 net::URLRequestMockHTTPJob::GetMockUrl(test_file_path.MaybeAsASCII()); | 268 net::URLRequestMockHTTPJob::GetMockUrl(test_file_path.MaybeAsASCII()); |
| 273 ui_test_utils::NavigateToURL(browser(), url); | 269 ui_test_utils::NavigateToURL(browser(), url); |
| 274 | 270 |
| 275 // Get the encoding of page. It should return the real encoding now. | 271 // Get the encoding of page. It should return the real encoding now. |
| 276 EXPECT_EQ(kTestDatas[i].expected_encoding, web_contents->GetEncoding()); | 272 EXPECT_EQ(kTestDatas[i].expected_encoding, web_contents->GetEncoding()); |
| 277 | 273 |
| 278 // Dump the page, the content of dump page should be equal with our expect | 274 // Dump the page, the content of dump page should be equal with our expect |
| 279 // result file. | 275 // result file. |
| 280 base::FilePath expected_result_file_name = | 276 base::FilePath expected_result_file_name = |
| 281 base::FilePath().AppendASCII(kAutoDetectDir). | 277 base::FilePath().AppendASCII(kAutoDetectDir). |
| 282 AppendASCII(kExpectedResultDir). | 278 AppendASCII(kExpectedResultDir). |
| 283 AppendASCII(kTestDatas[i].expected_result); | 279 AppendASCII(kTestDatas[i].expected_result); |
| 284 SaveAndCompare(kTestDatas[i].test_file_name, expected_result_file_name); | 280 SaveAndCompare(kTestDatas[i].test_file_name, expected_result_file_name); |
| 285 } | 281 } |
| 286 } | 282 } |
| OLD | NEW |