summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xchrome/browser/automation/automation_provider.cc7
-rw-r--r--chrome/browser/automation/automation_provider.h2
-rw-r--r--chrome/browser/browser_uitest.cc27
-rwxr-xr-xchrome/test/automation/automation_messages_internal.h7
-rw-r--r--chrome/test/automation/automation_proxy.cc14
-rw-r--r--chrome/test/automation/automation_proxy.h5
-rw-r--r--chrome/test/automation/automation_proxy_uitest.cc16
7 files changed, 75 insertions, 3 deletions
diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc
index 3dce551..859beaf 100755
--- a/chrome/browser/automation/automation_provider.cc
+++ b/chrome/browser/automation/automation_provider.cc
@@ -4,6 +4,7 @@
#include "chrome/browser/automation/automation_provider.h"
+#include "app/l10n_util.h"
#include "app/message_box_flags.h"
#include "base/file_version_info.h"
#include "base/message_loop.h"
@@ -956,6 +957,7 @@ void AutomationProvider::OnMessageReceived(const IPC::Message& message) {
IPC_MESSAGE_HANDLER(AutomationMsg_NormalBrowserWindowCount,
GetNormalBrowserWindowCount)
IPC_MESSAGE_HANDLER(AutomationMsg_BrowserWindow, GetBrowserWindow)
+ IPC_MESSAGE_HANDLER(AutomationMsg_GetBrowserLocale, GetBrowserLocale)
IPC_MESSAGE_HANDLER(AutomationMsg_LastActiveBrowserWindow,
GetLastActiveBrowserWindow)
IPC_MESSAGE_HANDLER(AutomationMsg_ActiveWindow, GetActiveWindow)
@@ -1338,6 +1340,11 @@ void AutomationProvider::GetActiveTabIndex(int handle, int* active_tab_index) {
}
}
+void AutomationProvider::GetBrowserLocale(string16* locale) {
+ DCHECK(g_browser_process);
+ *locale = WideToUTF16(g_browser_process->GetApplicationLocale());
+}
+
void AutomationProvider::GetBrowserWindowCount(int* window_count) {
*window_count = static_cast<int>(BrowserList::size());
}
diff --git a/chrome/browser/automation/automation_provider.h b/chrome/browser/automation/automation_provider.h
index 59935f5..389543a 100644
--- a/chrome/browser/automation/automation_provider.h
+++ b/chrome/browser/automation/automation_provider.h
@@ -16,6 +16,7 @@
#include <vector>
#include "base/basictypes.h"
+#include "base/scoped_ptr.h"
#include "chrome/browser/automation/automation_autocomplete_edit_tracker.h"
#include "chrome/browser/automation/automation_browser_tracker.h"
#include "chrome/browser/automation/automation_tab_tracker.h"
@@ -149,6 +150,7 @@ class AutomationProvider : public base::RefCounted<AutomationProvider>,
int handle,
int* response_value);
void GetBrowserWindowCount(int* window_count);
+ void GetBrowserLocale(string16* locale);
void GetNormalBrowserWindowCount(int* window_count);
void GetShowingAppModalDialog(bool* showing_dialog, int* dialog_button);
void ClickAppModalDialogButton(int button, bool* success);
diff --git a/chrome/browser/browser_uitest.cc b/chrome/browser/browser_uitest.cc
index adeea1f..e2533c7 100644
--- a/chrome/browser/browser_uitest.cc
+++ b/chrome/browser/browser_uitest.cc
@@ -59,6 +59,29 @@ class BrowserTest : public UITest {
EXPECT_TRUE(window->GetWindowTitle(&title));
return UTF16ToWide(title);
}
+
+ // In RTL locales wrap the page title with RTL embedding characters so that it
+ // matches the value returned by GetWindowTitle().
+ std::wstring LocaleWindowCaptionFromPageTitle(
+ const std::wstring& expected_title) {
+ std::wstring page_title = WindowCaptionFromPageTitle(expected_title);
+#if defined(OS_WIN)
+ string16 browser_locale;
+
+ EXPECT_TRUE(automation()->GetBrowserLocale(&browser_locale));
+
+ const std::string& locale_utf8 = UTF16ToUTF8(browser_locale);
+ if (l10n_util::GetTextDirectionForLocale(locale_utf8.c_str()) ==
+ l10n_util::RIGHT_TO_LEFT) {
+ l10n_util::WrapStringWithLTRFormatting(&page_title);
+ }
+
+ return page_title;
+#else
+ // Do we need to use the above code on POSIX as well?
+ return page_title;
+#endif
+ }
};
class VisibleBrowserTest : public UITest {
@@ -77,7 +100,7 @@ TEST_F(BrowserTest, NoTitle) {
NavigateToURL(net::FilePathToFileURL(test_file));
// The browser lazily updates the title.
PlatformThread::Sleep(sleep_timeout_ms());
- EXPECT_EQ(WindowCaptionFromPageTitle(L"title1.html"), GetWindowTitle());
+ EXPECT_EQ(LocaleWindowCaptionFromPageTitle(L"title1.html"), GetWindowTitle());
EXPECT_EQ(L"title1.html", GetActiveTabTitle());
}
@@ -92,7 +115,7 @@ TEST_F(BrowserTest, Title) {
PlatformThread::Sleep(sleep_timeout_ms());
const std::wstring test_title(L"Title Of Awesomeness");
- EXPECT_EQ(WindowCaptionFromPageTitle(test_title), GetWindowTitle());
+ EXPECT_EQ(LocaleWindowCaptionFromPageTitle(test_title), GetWindowTitle());
EXPECT_EQ(test_title, GetActiveTabTitle());
}
diff --git a/chrome/test/automation/automation_messages_internal.h b/chrome/test/automation/automation_messages_internal.h
index 7e20454..91961cf 100755
--- a/chrome/test/automation/automation_messages_internal.h
+++ b/chrome/test/automation/automation_messages_internal.h
@@ -939,6 +939,13 @@ IPC_BEGIN_MESSAGES(Automation)
IPC_SYNC_MESSAGE_ROUTED1_1(AutomationMsg_BlockedPopupCount,
int /* tab_handle */,
int /* blocked_popup_count */)
+
+ // This message retrieves the locale of the browser process. On success
+ // |chrome_locale| will contain the locale as reported by ICU. On failure
+ // |chrome_locale| is the empty string.
+ IPC_SYNC_MESSAGE_ROUTED0_1(AutomationMsg_GetBrowserLocale,
+ string16 /* chrome_locale */)
+
#if defined(OS_WIN)
IPC_MESSAGE_ROUTED5(AutomationMsg_ForwardContextMenuToExternalHost,
int /* tab_handle */,
diff --git a/chrome/test/automation/automation_proxy.cc b/chrome/test/automation/automation_proxy.cc
index 37c1037..2d4fe5b 100644
--- a/chrome/test/automation/automation_proxy.cc
+++ b/chrome/test/automation/automation_proxy.cc
@@ -414,6 +414,20 @@ scoped_refptr<BrowserProxy> AutomationProxy::GetBrowserWindow(
return ProxyObjectFromHandle<BrowserProxy>(handle);
}
+bool AutomationProxy::GetBrowserLocale(string16* locale) {
+ DCHECK(locale != NULL);
+ if (!SendWithTimeout(new AutomationMsg_GetBrowserLocale(0, locale),
+ command_execution_timeout_ms(), NULL)) {
+ DLOG(ERROR) << "GetBrowserLocale did not complete in a timely fashion";
+ return false;
+ }
+
+ // An empty locale means that the browser has no UI language
+ // which is impossible.
+ DCHECK(!locale->empty());
+ return !locale->empty();
+}
+
scoped_refptr<BrowserProxy> AutomationProxy::FindNormalBrowserWindow() {
int handle = 0;
diff --git a/chrome/test/automation/automation_proxy.h b/chrome/test/automation/automation_proxy.h
index 11bf615..2271f83 100644
--- a/chrome/test/automation/automation_proxy.h
+++ b/chrome/test/automation/automation_proxy.h
@@ -98,6 +98,11 @@ class AutomationProxy : public IPC::Channel::Listener,
// False likely indicates an IPC error.
bool GetNormalBrowserWindowCount(int* num_windows);
+ // Gets the locale of the chrome browser, currently all browsers forked from
+ // the main chrome share the same UI locale, returning true on success.
+ // False likely indicates an IPC error.
+ bool GetBrowserLocale(string16* locale);
+
// Returns whether an app modal dialog window is showing right now (i.e., a
// javascript alert), and what buttons it contains.
bool GetShowingAppModalDialog(bool* showing_app_modal_dialog,
diff --git a/chrome/test/automation/automation_proxy_uitest.cc b/chrome/test/automation/automation_proxy_uitest.cc
index c6c71c8..611eab5 100644
--- a/chrome/test/automation/automation_proxy_uitest.cc
+++ b/chrome/test/automation/automation_proxy_uitest.cc
@@ -5,6 +5,7 @@
#include <string>
#include "app/app_switches.h"
+#include "app/l10n_util.h"
#include "app/message_box_flags.h"
#include "base/command_line.h"
#include "base/file_path.h"
@@ -94,7 +95,20 @@ TEST_F(AutomationProxyVisibleTest, WindowGetViewBounds) {
ASSERT_TRUE(window->GetViewBounds(VIEW_ID_TAB_LAST, &bounds2, false));
EXPECT_GT(bounds2.width(), 0);
EXPECT_GT(bounds2.height(), 0);
- EXPECT_GT(bounds2.x(), bounds.x());
+
+ // The tab logic is mirrored in RTL locales, so what is to the right in
+ // LTR locales is now on the left with RTL ones.
+ string16 browser_locale;
+
+ EXPECT_TRUE(automation()->GetBrowserLocale(&browser_locale));
+
+ const std::string& locale_utf8 = UTF16ToUTF8(browser_locale);
+ if (l10n_util::GetTextDirectionForLocale(locale_utf8.c_str()) ==
+ l10n_util::RIGHT_TO_LEFT) {
+ EXPECT_LT(bounds2.x(), bounds.x());
+ } else {
+ EXPECT_GT(bounds2.x(), bounds.x());
+ }
EXPECT_EQ(bounds2.y(), bounds.y());
gfx::Rect urlbar_bounds;