| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 #include <string> | 4 #include <string> |
| 5 | 5 |
| 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/net/url_request_mock_http_job.h" | 8 #include "chrome/browser/net/url_request_mock_http_job.h" |
| 9 #include "chrome/browser/download/save_package.h" | 9 #include "chrome/browser/download/save_package.h" |
| 10 #include "chrome/common/pref_names.h" | 10 #include "chrome/common/pref_names.h" |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 { "windows-1252.html", "windows-1252" }, | 85 { "windows-1252.html", "windows-1252" }, |
| 86 { "windows-1253.html", "windows-1253" }, | 86 { "windows-1253.html", "windows-1253" }, |
| 87 { "windows-1254.html", "windows-1254" }, | 87 { "windows-1254.html", "windows-1254" }, |
| 88 { "windows-1255.html", "windows-1255" }, | 88 { "windows-1255.html", "windows-1255" }, |
| 89 { "windows-1256.html", "windows-1256" }, | 89 { "windows-1256.html", "windows-1256" }, |
| 90 { "windows-1257.html", "windows-1257" }, | 90 { "windows-1257.html", "windows-1257" }, |
| 91 { "windows-1258.html", "windows-1258" } | 91 { "windows-1258.html", "windows-1258" } |
| 92 }; | 92 }; |
| 93 const char* const kAliasTestDir = "alias_mapping"; | 93 const char* const kAliasTestDir = "alias_mapping"; |
| 94 | 94 |
| 95 scoped_refptr<TabProxy> tab_proxy(GetActiveTab()); |
| 96 ASSERT_TRUE(tab_proxy.get()); |
| 97 |
| 95 FilePath test_dir_path = FilePath(kTestDir).AppendASCII(kAliasTestDir); | 98 FilePath test_dir_path = FilePath(kTestDir).AppendASCII(kAliasTestDir); |
| 96 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kEncodingTestDatas); ++i) { | 99 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kEncodingTestDatas); ++i) { |
| 97 FilePath test_file_path(test_dir_path); | 100 FilePath test_file_path(test_dir_path); |
| 98 test_file_path = test_file_path.AppendASCII( | 101 test_file_path = test_file_path.AppendASCII( |
| 99 kEncodingTestDatas[i].file_name); | 102 kEncodingTestDatas[i].file_name); |
| 100 GURL url = | |
| 101 URLRequestMockHTTPJob::GetMockUrl(test_file_path); | |
| 102 | 103 |
| 103 scoped_refptr<TabProxy> tab_proxy(GetActiveTab()); | 104 NavigateToURL(URLRequestMockHTTPJob::GetMockUrl(test_file_path)); |
| 104 ASSERT_TRUE(tab_proxy.get()); | |
| 105 ASSERT_TRUE(tab_proxy->NavigateToURL(url)); | |
| 106 WaitUntilTabCount(1); | |
| 107 | 105 |
| 108 std::string encoding; | 106 std::string encoding; |
| 109 EXPECT_TRUE(tab_proxy->GetPageCurrentEncoding(&encoding)); | 107 EXPECT_TRUE(tab_proxy->GetPageCurrentEncoding(&encoding)); |
| 110 EXPECT_EQ(encoding, kEncodingTestDatas[i].encoding_name); | 108 EXPECT_EQ(encoding, kEncodingTestDatas[i].encoding_name); |
| 111 } | 109 } |
| 112 } | 110 } |
| 113 | 111 |
| 114 #if defined(OS_WIN) | 112 #if defined(OS_WIN) |
| 115 // We are disabling this test on MacOS and Linux because on those platforms | 113 // We are disabling this test on MacOS and Linux because on those platforms |
| 116 // AutomationProvider::OverrideEncoding is not implemented yet. | 114 // AutomationProvider::OverrideEncoding is not implemented yet. |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 L"ISO-8859-4")); | 244 L"ISO-8859-4")); |
| 247 scoped_refptr<TabProxy> tab(GetActiveTab()); | 245 scoped_refptr<TabProxy> tab(GetActiveTab()); |
| 248 ASSERT_TRUE(tab.get()); | 246 ASSERT_TRUE(tab.get()); |
| 249 | 247 |
| 250 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestDatas);i++) { | 248 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestDatas);i++) { |
| 251 FilePath test_file_path(test_dir_path); | 249 FilePath test_file_path(test_dir_path); |
| 252 test_file_path = test_file_path.AppendASCII(kTestDatas[i].test_file_name); | 250 test_file_path = test_file_path.AppendASCII(kTestDatas[i].test_file_name); |
| 253 GURL url = | 251 GURL url = |
| 254 URLRequestMockHTTPJob::GetMockUrl(test_file_path); | 252 URLRequestMockHTTPJob::GetMockUrl(test_file_path); |
| 255 ASSERT_TRUE(tab->NavigateToURL(url)); | 253 ASSERT_TRUE(tab->NavigateToURL(url)); |
| 256 WaitUntilTabCount(1); | |
| 257 | 254 |
| 258 // Disable auto detect if it is on. | 255 // Disable auto detect if it is on. |
| 259 EXPECT_TRUE( | 256 EXPECT_TRUE( |
| 260 browser->SetBooleanPreference(prefs::kWebKitUsesUniversalDetector, | 257 browser->SetBooleanPreference(prefs::kWebKitUsesUniversalDetector, |
| 261 false)); | 258 false)); |
| 262 EXPECT_TRUE(tab->Reload()); | 259 EXPECT_TRUE(tab->Reload()); |
| 263 | 260 |
| 264 // Get the encoding used for the page, it must be the default charset we | 261 // Get the encoding used for the page, it must be the default charset we |
| 265 // just set. | 262 // just set. |
| 266 std::string encoding; | 263 std::string encoding; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 289 expected_result_file_name = expected_result_file_name.AppendASCII( | 286 expected_result_file_name = expected_result_file_name.AppendASCII( |
| 290 kExpectedResultDir); | 287 kExpectedResultDir); |
| 291 expected_result_file_name = expected_result_file_name.AppendASCII( | 288 expected_result_file_name = expected_result_file_name.AppendASCII( |
| 292 kTestDatas[i].expected_result); | 289 kTestDatas[i].expected_result); |
| 293 EXPECT_TRUE(tab->SavePage(full_saved_file_name, temp_sub_resource_dir_, | 290 EXPECT_TRUE(tab->SavePage(full_saved_file_name, temp_sub_resource_dir_, |
| 294 SavePackage::SAVE_AS_COMPLETE_HTML)); | 291 SavePackage::SAVE_AS_COMPLETE_HTML)); |
| 295 EXPECT_TRUE(WaitForDownloadShelfVisible(browser.get())); | 292 EXPECT_TRUE(WaitForDownloadShelfVisible(browser.get())); |
| 296 CheckFile(full_saved_file_name, expected_result_file_name, true); | 293 CheckFile(full_saved_file_name, expected_result_file_name, true); |
| 297 } | 294 } |
| 298 } | 295 } |
| OLD | NEW |