diff options
author | grt@chromium.org <grt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-20 14:01:21 +0000 |
---|---|---|
committer | grt@chromium.org <grt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-20 14:01:21 +0000 |
commit | 6ae3d4909757757f27940369e1bdc67eebd52b87 (patch) | |
tree | b95726d81214d6824646008e53d870d0ee8f2feb /chrome_frame/test | |
parent | b85e5120573c61b9bdd492fb903b334bf1119d8f (diff) | |
download | chromium_src-6ae3d4909757757f27940369e1bdc67eebd52b87.zip chromium_src-6ae3d4909757757f27940369e1bdc67eebd52b87.tar.gz chromium_src-6ae3d4909757757f27940369e1bdc67eebd52b87.tar.bz2 |
Various changes to make GCF nicer for the non-en-US world:
- Chrome Frame now uses MUI on Vista+ to detect IE's UX language.
- Chrome Frame now tells Chrome (via the --lang command-line option) what the current langauge is.
- Chrome Frame now respects Chrome's "ApplicationLocaleValue" group policy setting.
BUG=56435,59582
TEST=chrome_frame_unittests and chrome_frame_tests updated
Review URL: http://codereview.chromium.org/3757007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@63208 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame/test')
-rw-r--r-- | chrome_frame/test/automation_client_mock.cc | 16 | ||||
-rw-r--r-- | chrome_frame/test/chrome_frame_automation_mock.h | 14 | ||||
-rw-r--r-- | chrome_frame/test/policy_settings_unittest.cc | 35 | ||||
-rw-r--r-- | chrome_frame/test/proxy_factory_mock.cc | 10 | ||||
-rw-r--r-- | chrome_frame/test/simple_resource_loader_test.cc | 76 |
5 files changed, 126 insertions, 25 deletions
diff --git a/chrome_frame/test/automation_client_mock.cc b/chrome_frame/test/automation_client_mock.cc index 7626c0b..a77b023 100644 --- a/chrome_frame/test/automation_client_mock.cc +++ b/chrome_frame/test/automation_client_mock.cc @@ -104,7 +104,7 @@ TEST(CFACWithChrome, CreateTooFast) { GURL empty; scoped_refptr<ChromeFrameLaunchParams> clp(new ChromeFrameLaunchParams( - empty, empty, profile_path, profile_path.BaseName().value(), L"", + empty, empty, profile_path, profile_path.BaseName().value(), L"", L"", false, false, false)); clp->set_launch_timeout(timeout); clp->set_version_check(false); @@ -136,7 +136,7 @@ TEST(CFACWithChrome, CreateNotSoFast) { GURL empty; scoped_refptr<ChromeFrameLaunchParams> clp(new ChromeFrameLaunchParams( - empty, empty, profile_path, profile_path.BaseName().value(), L"", + empty, empty, profile_path, profile_path.BaseName().value(), L"", L"", false, false, false)); clp->set_launch_timeout(timeout); clp->set_version_check(false); @@ -182,7 +182,7 @@ TEST(CFACWithChrome, NavigateOk) { GURL empty; scoped_refptr<ChromeFrameLaunchParams> clp(new ChromeFrameLaunchParams( - empty, empty, profile_path, profile_path.BaseName().value(), L"", + empty, empty, profile_path, profile_path.BaseName().value(), L"", L"", false, false, false)); clp->set_launch_timeout(timeout); clp->set_version_check(false); @@ -228,7 +228,7 @@ TEST(CFACWithChrome, NavigateFailed) { GURL empty; scoped_refptr<ChromeFrameLaunchParams> clp(new ChromeFrameLaunchParams( - empty, empty, profile_path, profile_path.BaseName().value(), L"", + empty, empty, profile_path, profile_path.BaseName().value(), L"", L"", false, false, false)); clp->set_launch_timeout(10000); clp->set_version_check(false); @@ -266,7 +266,7 @@ TEST_F(CFACMockTest, MockedCreateTabOk) { // Here we go! GURL empty; scoped_refptr<ChromeFrameLaunchParams> clp(new ChromeFrameLaunchParams( - empty, empty, profile_path_, profile_path_.BaseName().value(), L"", + empty, empty, profile_path_, profile_path_.BaseName().value(), L"", L"", false, false, false)); clp->set_launch_timeout(timeout); clp->set_version_check(false); @@ -298,7 +298,7 @@ TEST_F(CFACMockTest, MockedCreateTabFailed) { // Here we go! GURL empty; scoped_refptr<ChromeFrameLaunchParams> clp(new ChromeFrameLaunchParams( - empty, empty, profile_path_, profile_path_.BaseName().value(), L"", + empty, empty, profile_path_, profile_path_.BaseName().value(), L"", L"", false, false, false)); clp->set_launch_timeout(timeout_); clp->set_version_check(false); @@ -338,7 +338,7 @@ TEST_F(CFACMockTest, OnChannelError) { GURL empty; scoped_refptr<ChromeFrameLaunchParams> clp(new ChromeFrameLaunchParams( - empty, empty, profile_path_, profile_path_.BaseName().value(), L"", + empty, empty, profile_path_, profile_path_.BaseName().value(), L"", L"", false, false, false)); clp->set_launch_timeout(1); // Unneeded timeout, but can't be 0. clp->set_version_check(false); @@ -457,7 +457,7 @@ TEST_F(CFACMockTest, NavigateTwiceAfterInitToSameUrl) { scoped_refptr<ChromeFrameLaunchParams> launch_params( new ChromeFrameLaunchParams( GURL("http://www.nonexistent.com"), empty, profile_path_, - profile_path_.BaseName().value(), L"", false, false, false)); + profile_path_.BaseName().value(), L"", L"", false, false, false)); launch_params->set_launch_timeout(timeout); launch_params->set_version_check(false); EXPECT_TRUE(client_->Initialize(&cfd_, launch_params)); diff --git a/chrome_frame/test/chrome_frame_automation_mock.h b/chrome_frame/test/chrome_frame_automation_mock.h index 2d7a76e..0887f81 100644 --- a/chrome_frame/test/chrome_frame_automation_mock.h +++ b/chrome_frame/test/chrome_frame_automation_mock.h @@ -24,6 +24,7 @@ class AutomationMockDelegate AutomationMockDelegate(MessageLoop* caller_message_loop, int launch_timeout, bool perform_version_check, const std::wstring& profile_name, + const std::wstring& language, const std::wstring& extra_chrome_arguments, bool incognito, bool is_widget_mode) : caller_message_loop_(caller_message_loop), is_connected_(false), @@ -40,7 +41,8 @@ class AutomationMockDelegate GURL empty; scoped_refptr<ChromeFrameLaunchParams> clp( new ChromeFrameLaunchParams(empty, empty, profile_path, profile_name, - extra_chrome_arguments, incognito, is_widget_mode, false)); + language, extra_chrome_arguments, incognito, is_widget_mode, + false)); clp->set_launch_timeout(launch_timeout); clp->set_version_check(perform_version_check); automation_client_->Initialize(this, clp); @@ -145,7 +147,7 @@ class AutomationMockLaunch typedef AutomationMockDelegate<AutomationMockLaunch> Base; AutomationMockLaunch(MessageLoop* caller_message_loop, int launch_timeout) - : Base(caller_message_loop, launch_timeout, true, L"", L"", false, + : Base(caller_message_loop, launch_timeout, true, L"", L"", L"", false, false) { } virtual void OnAutomationServerReady() { @@ -163,7 +165,7 @@ class AutomationMockNavigate typedef AutomationMockDelegate<AutomationMockNavigate> Base; AutomationMockNavigate(MessageLoop* caller_message_loop, int launch_timeout) - : Base(caller_message_loop, launch_timeout, true, L"", L"", false, + : Base(caller_message_loop, launch_timeout, true, L"", L"", L"", false, false) { } virtual void OnLoad(int tab_handle, const GURL& url) { @@ -178,7 +180,8 @@ class AutomationMockPostMessage typedef AutomationMockDelegate<AutomationMockPostMessage> Base; AutomationMockPostMessage(MessageLoop* caller_message_loop, int launch_timeout) - : Base(caller_message_loop, launch_timeout, true, L"", L"", false, false), + : Base(caller_message_loop, launch_timeout, true, L"", L"", L"", false, + false), postmessage_result_(false) {} bool postmessage_result() const { return postmessage_result_; @@ -206,7 +209,8 @@ class AutomationMockHostNetworkRequestStart typedef AutomationMockDelegate<AutomationMockHostNetworkRequestStart> Base; AutomationMockHostNetworkRequestStart(MessageLoop* caller_message_loop, int launch_timeout) - : Base(caller_message_loop, launch_timeout, true, L"", L"", false, false), + : Base(caller_message_loop, launch_timeout, true, L"", L"", L"", false, + false), request_start_result_(false) { if (automation()) { automation()->set_use_chrome_network(false); diff --git a/chrome_frame/test/policy_settings_unittest.cc b/chrome_frame/test/policy_settings_unittest.cc index 52a3c55..55a0b32 100644 --- a/chrome_frame/test/policy_settings_unittest.cc +++ b/chrome_frame/test/policy_settings_unittest.cc @@ -25,6 +25,7 @@ void DeleteChromeFramePolicyEntries(HKEY root) { key.DeleteKey(ASCIIToWide(policy::key::kRenderInChromeFrameList).c_str()); key.DeleteKey(ASCIIToWide(policy::key::kRenderInHostList).c_str()); key.DeleteKey(ASCIIToWide(policy::key::kChromeFrameContentTypes).c_str()); + key.DeleteKey(ASCIIToWide(policy::key::kApplicationLocaleValue).c_str()); } } @@ -118,6 +119,17 @@ bool SetCFContentTypes(HKEY policy_root, const wchar_t* content_types[], return true; } +bool SetChromeApplicationLocale(HKEY policy_root, const wchar_t* locale) { + RegKey policy_key; + if (!InitializePolicyKey(policy_root, &policy_key)) + return false; + + std::wstring application_locale_value( + ASCIIToWide(policy::key::kApplicationLocaleValue)); + EXPECT_TRUE(policy_key.WriteValue(application_locale_value.c_str(), locale)); + return true; +} + } // end namespace TEST(PolicySettings, RendererForUrl) { @@ -215,3 +227,26 @@ TEST(PolicySettings, RendererForContentType) { } } +TEST(PolicySettings, ApplicationLocale) { + TempRegKeyOverride::DeleteAllTempKeys(); + + scoped_ptr<TempRegKeyOverride> hklm_pol( + new TempRegKeyOverride(HKEY_LOCAL_MACHINE, L"hklm_pol")); + scoped_ptr<TempRegKeyOverride> hkcu_pol( + new TempRegKeyOverride(HKEY_CURRENT_USER, L"hkcu_pol")); + + scoped_ptr<PolicySettings> settings(new PolicySettings()); + EXPECT_TRUE(settings->ApplicationLocale().empty()); + + static const wchar_t kTestApplicationLocale[] = L"fr-CA"; + + HKEY root[] = { HKEY_LOCAL_MACHINE, HKEY_CURRENT_USER }; + for (int i = 0; i < arraysize(root); ++i) { + SetChromeApplicationLocale(root[i], kTestApplicationLocale); + settings.reset(new PolicySettings()); + EXPECT_EQ(std::wstring(kTestApplicationLocale), + settings->ApplicationLocale()); + + DeleteChromeFramePolicyEntries(root[i]); + } +} diff --git a/chrome_frame/test/proxy_factory_mock.cc b/chrome_frame/test/proxy_factory_mock.cc index 6e15104..effc4a0 100644 --- a/chrome_frame/test/proxy_factory_mock.cc +++ b/chrome_frame/test/proxy_factory_mock.cc @@ -21,7 +21,7 @@ TEST(ProxyFactoryTest, CreateDestroy) { FilePath profile_path; scoped_refptr<ChromeFrameLaunchParams> params( new ChromeFrameLaunchParams(empty, empty, profile_path, - L"Adam.N.Epilinter", L"", false, false, false)); + L"Adam.N.Epilinter", L"", L"", false, false, false)); params->set_launch_timeout(0); params->set_version_check(false); @@ -41,7 +41,7 @@ TEST(ProxyFactoryTest, CreateSameProfile) { FilePath profile_path; scoped_refptr<ChromeFrameLaunchParams> params( new ChromeFrameLaunchParams(empty, empty, profile_path, - L"Dr. Gratiano Forbeson", L"", false, false, false)); + L"Dr. Gratiano Forbeson", L"", L"", false, false, false)); params->set_launch_timeout(0); params->set_version_check(false); @@ -65,13 +65,13 @@ TEST(ProxyFactoryTest, CreateDifferentProfiles) { FilePath profile_path; scoped_refptr<ChromeFrameLaunchParams> params1( new ChromeFrameLaunchParams(empty, empty, profile_path, - L"Adam.N.Epilinter", L"", false, false, false)); + L"Adam.N.Epilinter", L"", L"", false, false, false)); params1->set_launch_timeout(0); params1->set_version_check(false); scoped_refptr<ChromeFrameLaunchParams> params2( new ChromeFrameLaunchParams(empty, empty, profile_path, - L"Dr. Gratiano Forbeson", L"", false, false, false)); + L"Dr. Gratiano Forbeson", L"", L"", false, false, false)); params2->set_launch_timeout(0); params2->set_version_check(false); @@ -95,7 +95,7 @@ TEST(ProxyFactoryTest, FastCreateDestroy) { FilePath profile_path; scoped_refptr<ChromeFrameLaunchParams> params( new ChromeFrameLaunchParams(empty, empty, profile_path, - L"Dr. Gratiano Forbeson", L"", false, false, false)); + L"Dr. Gratiano Forbeson", L"", L"", false, false, false)); params->set_launch_timeout(10000); params->set_version_check(false); diff --git a/chrome_frame/test/simple_resource_loader_test.cc b/chrome_frame/test/simple_resource_loader_test.cc index f67ef49..e120a6b 100644 --- a/chrome_frame/test/simple_resource_loader_test.cc +++ b/chrome_frame/test/simple_resource_loader_test.cc @@ -5,21 +5,83 @@ #include "chrome_frame/simple_resource_loader.h" #include "base/file_path.h" +#include "base/win/windows_version.h" #include "testing/gtest/include/gtest/gtest.h" -TEST(SimpleResourceLoaderTest, GetLocaleFilePath) { - SimpleResourceLoader loader; - +TEST(SimpleResourceLoaderTest, LoadLocaleDll) { + std::vector<std::wstring> language_tags; + FilePath locales_path; FilePath file_path; + HMODULE dll_handle = NULL; + + SimpleResourceLoader::DetermineLocalesDirectory(&locales_path); + // Test valid language-region string: - EXPECT_TRUE(loader.GetLocaleFilePath(L"en", L"GB", &file_path)); + language_tags.clear(); + language_tags.push_back(L"en-GB"); + language_tags.push_back(L"en"); + EXPECT_TRUE( + SimpleResourceLoader::LoadLocaleDll(language_tags, locales_path, + &dll_handle, &file_path)); + if (NULL != dll_handle) { + FreeLibrary(dll_handle); + dll_handle = NULL; + } EXPECT_TRUE(file_path.BaseName() == FilePath(L"en-GB.dll")); // Test valid language-region string for which we only have a language dll: - EXPECT_TRUE(loader.GetLocaleFilePath(L"fr", L"FR", &file_path)); + language_tags.clear(); + language_tags.push_back(L"fr-FR"); + language_tags.push_back(L"fr"); + EXPECT_TRUE( + SimpleResourceLoader::LoadLocaleDll(language_tags, locales_path, + &dll_handle, &file_path)); + if (NULL != dll_handle) { + FreeLibrary(dll_handle); + dll_handle = NULL; + } EXPECT_TRUE(file_path.BaseName() == FilePath(L"fr.dll")); - // Test invalid language-region string, make sure defaults to en-US.dll: - EXPECT_TRUE(loader.GetLocaleFilePath(L"xx", L"XX", &file_path)); + // Test invalid language-region string, make sure fallback works: + language_tags.clear(); + language_tags.push_back(L"xx-XX"); + language_tags.push_back(L"en-US"); + EXPECT_TRUE( + SimpleResourceLoader::LoadLocaleDll(language_tags, locales_path, + &dll_handle, &file_path)); + if (NULL != dll_handle) { + FreeLibrary(dll_handle); + dll_handle = NULL; + } EXPECT_TRUE(file_path.BaseName() == FilePath(L"en-US.dll")); } + +TEST(SimpleResourceLoaderTest, GetThreadPreferredUILanguages) { + std::vector<std::wstring> language_tags; + + if (base::win::GetVersion() >= base::win::VERSION_VISTA) { + EXPECT_TRUE( + SimpleResourceLoader::GetThreadPreferredUILanguages(&language_tags)); + // Did we find at least one language? + EXPECT_NE(static_cast<std::vector<std::wstring>::size_type>(0), + language_tags.size()); + } else { + EXPECT_FALSE( + SimpleResourceLoader::GetThreadPreferredUILanguages(&language_tags)); + } +} + +TEST(SimpleResourceLoaderTest, GetICUSystemLanguage) { + std::wstring language; + std::wstring region; + + SimpleResourceLoader::GetICUSystemLanguage(&language, ®ion); + EXPECT_NE(static_cast<std::wstring::size_type>(0), language.size()); +} + +TEST(SimpleResourceLoaderTest, InstanceTest) { + SimpleResourceLoader* loader = SimpleResourceLoader::instance(); + + ASSERT_TRUE(NULL != loader); + ASSERT_TRUE(NULL != loader->GetResourceModuleHandle()); +} |