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 18 matching lines...) Expand all Loading... |
29 | 29 |
30 struct EncodingTestData { | 30 struct EncodingTestData { |
31 const char* file_name; | 31 const char* file_name; |
32 const char* encoding_name; | 32 const char* encoding_name; |
33 }; | 33 }; |
34 | 34 |
35 const EncodingTestData kEncodingTestDatas[] = { | 35 const EncodingTestData kEncodingTestDatas[] = { |
36 { "Big5.html", "Big5" }, | 36 { "Big5.html", "Big5" }, |
37 { "EUC-JP.html", "EUC-JP" }, | 37 { "EUC-JP.html", "EUC-JP" }, |
38 { "gb18030.html", "gb18030" }, | 38 { "gb18030.html", "gb18030" }, |
39 { "iso-8859-1.html", "ISO-8859-1" }, | 39 #if 0 |
| 40 // Disable temporarily until Blink CL |
| 41 // (https://codereview.chromium.org/655083002/) is relanded. |
| 42 { "iso-8859-1.html", "windows-1252" }, |
| 43 #endif |
40 { "ISO-8859-2.html", "ISO-8859-2" }, | 44 { "ISO-8859-2.html", "ISO-8859-2" }, |
41 { "ISO-8859-4.html", "ISO-8859-4" }, | 45 { "ISO-8859-4.html", "ISO-8859-4" }, |
42 { "ISO-8859-5.html", "ISO-8859-5" }, | 46 { "ISO-8859-5.html", "ISO-8859-5" }, |
43 { "ISO-8859-6.html", "ISO-8859-6" }, | 47 { "ISO-8859-6.html", "ISO-8859-6" }, |
44 { "ISO-8859-7.html", "ISO-8859-7" }, | 48 { "ISO-8859-7.html", "ISO-8859-7" }, |
45 { "ISO-8859-8.html", "ISO-8859-8" }, | 49 { "ISO-8859-8.html", "ISO-8859-8" }, |
46 { "ISO-8859-13.html", "ISO-8859-13" }, | 50 { "ISO-8859-13.html", "ISO-8859-13" }, |
47 { "ISO-8859-15.html", "ISO-8859-15" }, | 51 { "ISO-8859-15.html", "ISO-8859-15" }, |
48 { "KOI8-R.html", "KOI8-R" }, | 52 { "KOI8-R.html", "KOI8-R" }, |
49 { "KOI8-U.html", "KOI8-U" }, | 53 { "KOI8-U.html", "KOI8-U" }, |
50 { "macintosh.html", "macintosh" }, | 54 { "macintosh.html", "macintosh" }, |
51 { "Shift-JIS.html", "Shift_JIS" }, | 55 { "Shift-JIS.html", "Shift_JIS" }, |
52 { "US-ASCII.html", "ISO-8859-1" }, // http://crbug.com/15801 | 56 #if 0 |
| 57 // See the above. |
| 58 { "US-ASCII.html", "windows-1252" }, // http://crbug.com/15801 |
| 59 #endif |
53 { "UTF-8.html", "UTF-8" }, | 60 { "UTF-8.html", "UTF-8" }, |
54 { "UTF-16LE.html", "UTF-16LE" }, | 61 { "UTF-16LE.html", "UTF-16LE" }, |
55 { "windows-874.html", "windows-874" }, | 62 { "windows-874.html", "windows-874" }, |
56 { "EUC-KR.html", "EUC-KR" }, | 63 { "EUC-KR.html", "EUC-KR" }, |
57 { "windows-1250.html", "windows-1250" }, | 64 { "windows-1250.html", "windows-1250" }, |
58 { "windows-1251.html", "windows-1251" }, | 65 { "windows-1251.html", "windows-1251" }, |
59 { "windows-1252.html", "windows-1252" }, | 66 { "windows-1252.html", "windows-1252" }, |
60 { "windows-1253.html", "windows-1253" }, | 67 { "windows-1253.html", "windows-1253" }, |
61 { "windows-1254.html", "windows-1254" }, | 68 { "windows-1254.html", "windows-1254" }, |
62 { "windows-1255.html", "windows-1255" }, | 69 { "windows-1255.html", "windows-1255" }, |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 "expected_gb18030_saved_from_iso88591_meta.html"; | 189 "expected_gb18030_saved_from_iso88591_meta.html"; |
183 const char* const kOverrideTestDir = "user_override"; | 190 const char* const kOverrideTestDir = "user_override"; |
184 | 191 |
185 base::FilePath test_dir_path = | 192 base::FilePath test_dir_path = |
186 base::FilePath(kTestDir).AppendASCII(kOverrideTestDir); | 193 base::FilePath(kTestDir).AppendASCII(kOverrideTestDir); |
187 test_dir_path = test_dir_path.AppendASCII(kTestFileName); | 194 test_dir_path = test_dir_path.AppendASCII(kTestFileName); |
188 GURL url = net::URLRequestMockHTTPJob::GetMockUrl(test_dir_path); | 195 GURL url = net::URLRequestMockHTTPJob::GetMockUrl(test_dir_path); |
189 ui_test_utils::NavigateToURL(browser(), url); | 196 ui_test_utils::NavigateToURL(browser(), url); |
190 content::WebContents* web_contents = | 197 content::WebContents* web_contents = |
191 browser()->tab_strip_model()->GetActiveWebContents(); | 198 browser()->tab_strip_model()->GetActiveWebContents(); |
192 EXPECT_EQ("ISO-8859-1", web_contents->GetEncoding()); | 199 #if 0 |
| 200 // Temporarily disable until the Blink CL to use windows-1252 is relanded. |
| 201 EXPECT_EQ("windows-1252", web_contents->GetEncoding()); |
| 202 #endif |
193 | 203 |
194 // Override the encoding to "gb18030". | 204 // Override the encoding to "gb18030". |
195 const std::string selected_encoding = | 205 const std::string selected_encoding = |
196 CharacterEncoding::GetCanonicalEncodingNameByAliasName("gb18030"); | 206 CharacterEncoding::GetCanonicalEncodingNameByAliasName("gb18030"); |
197 content::TestNavigationObserver navigation_observer(web_contents); | 207 content::TestNavigationObserver navigation_observer(web_contents); |
198 web_contents->SetOverrideEncoding(selected_encoding); | 208 web_contents->SetOverrideEncoding(selected_encoding); |
199 navigation_observer.Wait(); | 209 navigation_observer.Wait(); |
200 EXPECT_EQ("gb18030", web_contents->GetEncoding()); | 210 EXPECT_EQ("gb18030", web_contents->GetEncoding()); |
201 | 211 |
202 base::FilePath expected_filename = | 212 base::FilePath expected_filename = |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 const char* expected_result; // File name of expected results. | 244 const char* expected_result; // File name of expected results. |
235 const char* expected_encoding; // expected encoding. | 245 const char* expected_encoding; // expected encoding. |
236 }; | 246 }; |
237 const EncodingAutoDetectTestData kTestDatas[] = { | 247 const EncodingAutoDetectTestData kTestDatas[] = { |
238 { "Big5_with_no_encoding_specified.html", | 248 { "Big5_with_no_encoding_specified.html", |
239 "expected_Big5_saved_from_no_encoding_specified.html", | 249 "expected_Big5_saved_from_no_encoding_specified.html", |
240 "Big5" }, | 250 "Big5" }, |
241 { "gb18030_with_no_encoding_specified.html", | 251 { "gb18030_with_no_encoding_specified.html", |
242 "expected_gb18030_saved_from_no_encoding_specified.html", | 252 "expected_gb18030_saved_from_no_encoding_specified.html", |
243 "gb18030" }, | 253 "gb18030" }, |
| 254 #if 0 |
| 255 // Disable until the Blink CL to use 'windows-1252' is relanded. |
244 { "iso-8859-1_with_no_encoding_specified.html", | 256 { "iso-8859-1_with_no_encoding_specified.html", |
245 "expected_iso-8859-1_saved_from_no_encoding_specified.html", | 257 "expected_iso-8859-1_saved_from_no_encoding_specified.html", |
246 "ISO-8859-1" }, | 258 "windows-1252" }, |
| 259 #endif |
247 { "ISO-8859-5_with_no_encoding_specified.html", | 260 { "ISO-8859-5_with_no_encoding_specified.html", |
248 "expected_ISO-8859-5_saved_from_no_encoding_specified.html", | 261 "expected_ISO-8859-5_saved_from_no_encoding_specified.html", |
249 "ISO-8859-5" }, | 262 "ISO-8859-5" }, |
250 { "ISO-8859-6_with_no_encoding_specified.html", | 263 { "ISO-8859-6_with_no_encoding_specified.html", |
251 "expected_ISO-8859-6_saved_from_no_encoding_specified.html", | 264 "expected_ISO-8859-6_saved_from_no_encoding_specified.html", |
252 "ISO-8859-6" }, | 265 "ISO-8859-6" }, |
253 { "ISO-8859-7_with_no_encoding_specified.html", | 266 { "ISO-8859-7_with_no_encoding_specified.html", |
254 "expected_ISO-8859-7_saved_from_no_encoding_specified.html", | 267 "expected_ISO-8859-7_saved_from_no_encoding_specified.html", |
255 "ISO-8859-7" }, | 268 "ISO-8859-7" }, |
256 { "ISO-8859-8_with_no_encoding_specified.html", | 269 { "ISO-8859-8_with_no_encoding_specified.html", |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 | 336 |
324 // Dump the page, the content of dump page should be equal with our expect | 337 // Dump the page, the content of dump page should be equal with our expect |
325 // result file. | 338 // result file. |
326 base::FilePath expected_result_file_name = | 339 base::FilePath expected_result_file_name = |
327 base::FilePath().AppendASCII(kAutoDetectDir). | 340 base::FilePath().AppendASCII(kAutoDetectDir). |
328 AppendASCII(kExpectedResultDir). | 341 AppendASCII(kExpectedResultDir). |
329 AppendASCII(kTestDatas[i].expected_result); | 342 AppendASCII(kTestDatas[i].expected_result); |
330 SaveAndCompare(kTestDatas[i].test_file_name, expected_result_file_name); | 343 SaveAndCompare(kTestDatas[i].test_file_name, expected_result_file_name); |
331 } | 344 } |
332 } | 345 } |
OLD | NEW |