diff options
author | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-09 20:14:36 +0000 |
---|---|---|
committer | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-09 20:14:36 +0000 |
commit | b8f48d184700b3bcbb6f0b4d90fe3354d5e6dd96 (patch) | |
tree | d83e1ea7006f2462dfcfec8c65f9de045629eb52 | |
parent | 0e7a02bf814bf5a548e1d846f58fc614c449e31a (diff) | |
download | chromium_src-b8f48d184700b3bcbb6f0b4d90fe3354d5e6dd96.zip chromium_src-b8f48d184700b3bcbb6f0b4d90fe3354d5e6dd96.tar.gz chromium_src-b8f48d184700b3bcbb6f0b4d90fe3354d5e6dd96.tar.bz2 |
Revert 31419 - Commit Issue 255057: Unit Test for Toggling of Encoding AutoDetect
BUG=23617
TEST=BrowserEncodingTest.TestToggleAutoDetect
TBR=rolandsteiner@chromium.org
Review URL: http://codereview.chromium.org/378031
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31465 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/automation/automation_provider.cc | 31 | ||||
-rw-r--r-- | chrome/browser/automation/automation_provider.h | 8 | ||||
-rw-r--r-- | chrome/browser/browser_encoding_uitest.cc | 91 | ||||
-rw-r--r-- | chrome/test/automation/automation_messages_internal.h | 9 | ||||
-rw-r--r-- | chrome/test/automation/tab_proxy.cc | 11 | ||||
-rw-r--r-- | chrome/test/automation/tab_proxy.h | 9 |
6 files changed, 12 insertions, 147 deletions
diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc index e7984bc..8df4ae4 100644 --- a/chrome/browser/automation/automation_provider.cc +++ b/chrome/browser/automation/automation_provider.cc @@ -417,8 +417,6 @@ void AutomationProvider::OnMessageReceived(const IPC::Message& message) { SetBooleanPreference) IPC_MESSAGE_HANDLER(AutomationMsg_GetPageCurrentEncoding, GetPageCurrentEncoding) - IPC_MESSAGE_HANDLER(AutomationMsg_ToggleEncodingAutoDetect, - ToggleEncodingAutoDetect) IPC_MESSAGE_HANDLER(AutomationMsg_OverrideEncoding, OverrideEncoding) IPC_MESSAGE_HANDLER(AutomationMsg_SavePackageShouldPromptUser, SavePackageShouldPromptUser) @@ -1892,8 +1890,8 @@ void AutomationProvider::SetStringPreference(int handle, void AutomationProvider::GetBooleanPreference(int handle, const std::wstring& name, - bool* value, - bool* success) { + bool* success, + bool* value) { *success = false; *value = false; if (browser_tracker_->ContainsHandle(handle)) { @@ -1928,30 +1926,7 @@ void AutomationProvider::GetPageCurrentEncoding( } } -// Toggles the encoding auto-detect setting. -// While the setting is global, the tab needs to be specified as it may need -// to be reloaded. -void AutomationProvider::ToggleEncodingAutoDetect(int tab_handle, - bool* success) { - *success = false; -#if defined(OS_WIN) - if (tab_tracker_->ContainsHandle(tab_handle)) { - NavigationController* nav = tab_tracker_->GetResource(tab_handle); - Browser* browser = FindAndActivateTab(nav); - DCHECK(browser); - - if (browser->command_updater()->IsCommandEnabled(IDC_ENCODING_MENU)) { - browser->ToggleEncodingAutoDetect(); - *success = true; - } - } -#else - // TODO(port): Enable when encoding-related parts of Browser are ported. - NOTIMPLEMENTED(); -#endif -} - -// Sets the override encoding for the page in the specified tab. +// Gets the current used encoding name of the page in the specified tab. void AutomationProvider::OverrideEncoding(int tab_handle, const std::string& encoding_name, bool* success) { diff --git a/chrome/browser/automation/automation_provider.h b/chrome/browser/automation/automation_provider.h index 6a66bd7..66e7de8 100644 --- a/chrome/browser/automation/automation_provider.h +++ b/chrome/browser/automation/automation_provider.h @@ -447,8 +447,8 @@ class AutomationProvider : public base::RefCounted<AutomationProvider>, // Gets the bool value for preference with name |name|. void GetBooleanPreference(int handle, const std::wstring& name, - bool* value, - bool* success); + bool* success, + bool* value); // Sets the bool value for preference with name |name|. void SetBooleanPreference(int handle, @@ -459,10 +459,6 @@ class AutomationProvider : public base::RefCounted<AutomationProvider>, // Gets the current used encoding name of the page in the specified tab. void GetPageCurrentEncoding(int tab_handle, std::string* current_encoding); - // Toggles the encoding auto-detect setting on the given tab - void ToggleEncodingAutoDetect(int tab_handle, - bool* success); - // Uses the specified encoding to override the encoding of the page in the // specified tab. void OverrideEncoding(int tab_handle, diff --git a/chrome/browser/browser_encoding_uitest.cc b/chrome/browser/browser_encoding_uitest.cc index 41b7ba8..8d68314 100644 --- a/chrome/browser/browser_encoding_uitest.cc +++ b/chrome/browser/browser_encoding_uitest.cc @@ -112,9 +112,8 @@ TEST_F(BrowserEncodingTest, TestEncodingAliasMapping) { } #if defined(OS_WIN) -// We are disabling these tests on MacOS and Linux because on those platforms -// AutomationProvider::OverrideEncoding and ToggleEncodingAutoDetect are not -// implemented yet. +// We are disabling this test on MacOS and Linux because on those platforms +// AutomationProvider::OverrideEncoding is not implemented yet. // TODO(port): Enable when encoding-related parts of Browser are ported. TEST_F(BrowserEncodingTest, TestOverrideEncoding) { const char* const kTestFileName = "gb18030_with_iso88591_meta.html"; @@ -160,92 +159,6 @@ TEST_F(BrowserEncodingTest, TestOverrideEncoding) { expected_file_name = expected_file_name.AppendASCII(kExpectedFileName); CheckFile(full_file_name, expected_file_name, true); } - -// Test for fix to issue 2932 (http://crbug.com/2932) -// as described in http://codereview.chromium.org/173265 -TEST_F(BrowserEncodingTest, TestToggleAutoDetect) { - const char* const kTestFileName = "gb18030_with_no_encoding_specified.html"; - const char* const kToggleTestDir = "auto_detect"; - - scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); - ASSERT_TRUE(browser.get()); - - browser->SetStringPreference(prefs::kDefaultCharset, L"ISO-8859-1"); - - // Turn off auto-detect before loading the file. - EXPECT_TRUE( - browser->SetBooleanPreference(prefs::kWebKitUsesUniversalDetector, - false)); - - FilePath test_dir_path = FilePath(kTestDir).AppendASCII(kToggleTestDir); - test_dir_path = test_dir_path.AppendASCII(kTestFileName); - GURL url = URLRequestMockHTTPJob::GetMockUrl(test_dir_path); - scoped_refptr<TabProxy> tab_proxy(GetActiveTab()); - ASSERT_TRUE(tab_proxy.get()); - ASSERT_TRUE(tab_proxy->NavigateToURL(url)); - WaitUntilTabCount(1); - - // Verify that file got default encoding. - std::string encoding; - EXPECT_TRUE(tab_proxy->GetPageCurrentEncoding(&encoding)); - EXPECT_EQ(encoding, "ISO-8859-1"); - - // Turn on auto-detect and verify that encoding changed. - int64 prev_nav_time = 0; - bool encoding_auto_detect = false; - EXPECT_TRUE(tab_proxy->GetLastNavigationTime(&prev_nav_time)); - EXPECT_TRUE(tab_proxy->ToggleEncodingAutoDetect()); - EXPECT_TRUE(tab_proxy->WaitForNavigation(prev_nav_time)); - EXPECT_TRUE(tab_proxy->GetPageCurrentEncoding(&encoding)); - EXPECT_EQ(encoding, "gb18030"); - EXPECT_TRUE( - browser->GetBooleanPreference(prefs::kWebKitUsesUniversalDetector, - &encoding_auto_detect)); - EXPECT_TRUE(encoding_auto_detect); - - // Turn off auto-detect and verify that no navigation occurs. - // The encoding shouldn't change as well. - int64 last_nav_time = 0; - EXPECT_TRUE(tab_proxy->GetLastNavigationTime(&prev_nav_time)); - EXPECT_TRUE(tab_proxy->ToggleEncodingAutoDetect()); - // TODO(rolandsteiner): HACK! this assumes the navigation (if any) will be - // completed in 500ms. Need a better way to ascertain that NO navigation - // was triggered. - EXPECT_TRUE(CrashAwareSleep(500)); - EXPECT_TRUE(tab_proxy->GetLastNavigationTime(&last_nav_time)); - EXPECT_EQ(prev_nav_time, last_nav_time); - EXPECT_TRUE( - browser->GetBooleanPreference(prefs::kWebKitUsesUniversalDetector, - &encoding_auto_detect)); - EXPECT_FALSE(encoding_auto_detect); - - // Choose another encoding and verify that page is reloaded and the new - // encoding set. Auto-detect encoding should still be off. - EXPECT_TRUE(tab_proxy->GetLastNavigationTime(&prev_nav_time)); - EXPECT_TRUE(tab_proxy->OverrideEncoding("ISO-8859-13")); - EXPECT_TRUE(tab_proxy->WaitForNavigation(prev_nav_time)); - EXPECT_TRUE(tab_proxy->GetPageCurrentEncoding(&encoding)); - EXPECT_EQ(encoding, "ISO-8859-13"); - EXPECT_TRUE( - browser->GetBooleanPreference(prefs::kWebKitUsesUniversalDetector, - &encoding_auto_detect)); - EXPECT_FALSE(encoding_auto_detect); - - // Turn on auto-detect again and verify that encoding changed back - // to Chinese. - EXPECT_TRUE(tab_proxy->GetLastNavigationTime(&prev_nav_time)); - EXPECT_TRUE(tab_proxy->ToggleEncodingAutoDetect()); - EXPECT_TRUE(tab_proxy->WaitForNavigation(prev_nav_time)); - EXPECT_TRUE(tab_proxy->GetPageCurrentEncoding(&encoding)); - EXPECT_EQ(encoding, "gb18030"); - EXPECT_TRUE( - browser->GetBooleanPreference(prefs::kWebKitUsesUniversalDetector, - &encoding_auto_detect)); - EXPECT_TRUE(encoding_auto_detect); - - // Close the tab explicitely (avoids spurious "leak" crash on exit) - EXPECT_TRUE(tab_proxy->Close(true)); -} #endif // defined(OS_WIN) // The following encodings are excluded from the auto-detection test because diff --git a/chrome/test/automation/automation_messages_internal.h b/chrome/test/automation/automation_messages_internal.h index db102a7..d2f7458 100644 --- a/chrome/test/automation/automation_messages_internal.h +++ b/chrome/test/automation/automation_messages_internal.h @@ -797,7 +797,7 @@ IPC_BEGIN_MESSAGES(Automation) int64 /* last navigation time */) // This messages is used to block until a new navigation occurs (if there is - // none more recent than the time specified). + // none more recent then the time specified). IPC_SYNC_MESSAGE_ROUTED2_1(AutomationMsg_WaitForNavigation, int /* tab_handle */, int64 /* last navigation time */, @@ -1184,11 +1184,4 @@ IPC_BEGIN_MESSAGES(Automation) int /* tab_handle */, int /* request_id */) - // Toggles the auto-detect encoding setting. - // While the setting is global, the tab needs to be specified as it may need - // to be reloaded. - IPC_SYNC_MESSAGE_ROUTED1_1(AutomationMsg_ToggleEncodingAutoDetect, - int /* tab handle */, - bool /* success */) - IPC_END_MESSAGES(Automation) diff --git a/chrome/test/automation/tab_proxy.cc b/chrome/test/automation/tab_proxy.cc index 875bc3a..43246ea 100644 --- a/chrome/test/automation/tab_proxy.cc +++ b/chrome/test/automation/tab_proxy.cc @@ -664,16 +664,6 @@ bool TabProxy::GetPageCurrentEncoding(std::string* encoding) { return succeeded; } -bool TabProxy::ToggleEncodingAutoDetect() { - if (!is_valid()) - return false; - - bool succeeded = false; - sender_->Send(new AutomationMsg_ToggleEncodingAutoDetect(0, handle_, - &succeeded)); - return succeeded; -} - bool TabProxy::OverrideEncoding(const std::string& encoding) { if (!is_valid()) return false; @@ -688,6 +678,7 @@ bool TabProxy::OverrideEncoding(const std::string& encoding) { void TabProxy::Reposition(HWND window, HWND window_insert_after, int left, int top, int width, int height, int flags, HWND parent_window) { + IPC::Reposition_Params params = {0}; params.window = window; params.window_insert_after = window_insert_after; diff --git a/chrome/test/automation/tab_proxy.h b/chrome/test/automation/tab_proxy.h index 0cc3f26..7693e60 100644 --- a/chrome/test/automation/tab_proxy.h +++ b/chrome/test/automation/tab_proxy.h @@ -327,9 +327,9 @@ class TabProxy : public AutomationResourceProxy { // to be used with WaitForNavigation (see below). bool GetLastNavigationTime(int64* last_navigation_time); - // Waits for a new navigation if none has occurred since - // |last_navigation_time|. The purpose of this function is for operations - // that causes asynchronous navigation to happen. + // Waits for a new navigation if none as occurred since |last_navigation_time| + // The purpose of this function is for operations that causes asynchronous + // navigation to happen. // It is supposed to be used as follow: // int64 last_nav_time; // tab_proxy->GetLastNavigationTime(&last_nav_time); @@ -340,9 +340,6 @@ class TabProxy : public AutomationResourceProxy { // Gets the current used encoding of the page in the tab. bool GetPageCurrentEncoding(std::string* encoding); - // Toggles encoding auto-detect of the page in the tab - bool ToggleEncodingAutoDetect(); - // Uses the specified encoding to override encoding of the page in the tab. bool OverrideEncoding(const std::string& encoding); |