summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/browser_browsertest.cc81
-rw-r--r--chrome/browser/browser_uitest.cc76
-rw-r--r--chrome/chrome.gyp5
3 files changed, 86 insertions, 76 deletions
diff --git a/chrome/browser/browser_browsertest.cc b/chrome/browser/browser_browsertest.cc
new file mode 100644
index 0000000..8b29936
--- /dev/null
+++ b/chrome/browser/browser_browsertest.cc
@@ -0,0 +1,81 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <string>
+
+#include "app/l10n_util.h"
+#include "chrome/browser/browser.h"
+#include "chrome/browser/browser_process.h"
+#include "chrome/browser/tab_contents/tab_contents.h"
+#include "chrome/test/in_process_browser_test.h"
+#include "chrome/test/ui_test_utils.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "grit/chromium_strings.h"
+#include "grit/generated_resources.h"
+
+namespace {
+
+// Given a page title, returns the expected window caption string.
+std::wstring WindowCaptionFromPageTitle(std::wstring page_title) {
+#if defined(OS_WIN) || defined(OS_LINUX)
+ if (page_title.empty())
+ return l10n_util::GetString(IDS_PRODUCT_NAME);
+
+ return l10n_util::GetStringF(IDS_BROWSER_WINDOW_TITLE_FORMAT, page_title);
+#elif defined(OS_MACOSX)
+ // On Mac, we don't want to suffix the page title with the application name.
+ if (page_title.empty())
+ return l10n_util::GetString(IDS_BROWSER_WINDOW_MAC_TAB_UNTITLED);
+ return page_title;
+#endif
+}
+
+} // namespace
+
+class BrowserTest : public InProcessBrowserTest {
+ protected:
+ // 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)
+ std::string locale = g_browser_process->GetApplicationLocale();
+ if (l10n_util::GetTextDirectionForLocale(locale.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
+ }
+};
+
+// Launch the app on a page with no title, check that the app title was set
+// correctly.
+IN_PROC_BROWSER_TEST_F(BrowserTest, NoTitle) {
+ ui_test_utils::NavigateToURL(browser(),
+ ui_test_utils::GetTestUrl(L".", L"title1.html"));
+ EXPECT_EQ(LocaleWindowCaptionFromPageTitle(L"title1.html"),
+ browser()->GetCurrentPageTitle());
+ string16 tab_title;
+ ASSERT_TRUE(ui_test_utils::GetCurrentTabTitle(browser(), &tab_title));
+ EXPECT_EQ(ASCIIToUTF16("title1.html"), tab_title);
+}
+
+// Launch the app, navigate to a page with a title, check that the app title
+// was set correctly.
+IN_PROC_BROWSER_TEST_F(BrowserTest, Title) {
+ ui_test_utils::NavigateToURL(browser(),
+ ui_test_utils::GetTestUrl(L".", L"title2.html"));
+ const std::wstring test_title(L"Title Of Awesomeness");
+ EXPECT_EQ(LocaleWindowCaptionFromPageTitle(test_title),
+ browser()->GetCurrentPageTitle());
+ string16 tab_title;
+ ASSERT_TRUE(ui_test_utils::GetCurrentTabTitle(browser(), &tab_title));
+ EXPECT_EQ(WideToUTF16(test_title), tab_title);
+}
diff --git a/chrome/browser/browser_uitest.cc b/chrome/browser/browser_uitest.cc
index 3b14290..bcb45b0 100644
--- a/chrome/browser/browser_uitest.cc
+++ b/chrome/browser/browser_uitest.cc
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "app/l10n_util.h"
#include "base/file_path.h"
#include "base/gfx/native_widget_types.h"
#include "base/string_util.h"
@@ -24,21 +23,6 @@
namespace {
-// Given a page title, returns the expected window caption string.
-std::wstring WindowCaptionFromPageTitle(std::wstring page_title) {
-#if defined(OS_WIN) || defined(OS_LINUX)
- if (page_title.empty())
- return l10n_util::GetString(IDS_PRODUCT_NAME);
-
- return l10n_util::GetStringF(IDS_BROWSER_WINDOW_TITLE_FORMAT, page_title);
-#elif defined(OS_MACOSX)
- // On Mac, we don't want to suffix the page title with the application name.
- if (page_title.empty())
- return l10n_util::GetString(IDS_BROWSER_WINDOW_MAC_TAB_UNTITLED);
- return page_title;
-#endif
-}
-
class BrowserTest : public UITest {
protected:
#if defined(OS_WIN)
@@ -51,38 +35,6 @@ class BrowserTest : public UITest {
return window_handle;
}
#endif
-
- std::wstring GetWindowTitle() {
- scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0));
- scoped_refptr<WindowProxy> window(browser->GetWindow());
-
- string16 title;
- 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 {
@@ -92,34 +44,6 @@ class VisibleBrowserTest : public UITest {
}
};
-// Launch the app on a page with no title, check that the app title was set
-// correctly.
-TEST_F(BrowserTest, NoTitle) {
- FilePath test_file(test_data_directory_);
- test_file = test_file.AppendASCII("title1.html");
-
- NavigateToURL(net::FilePathToFileURL(test_file));
- // The browser lazily updates the title.
- PlatformThread::Sleep(sleep_timeout_ms());
- EXPECT_EQ(LocaleWindowCaptionFromPageTitle(L"title1.html"), GetWindowTitle());
- EXPECT_EQ(L"title1.html", GetActiveTabTitle());
-}
-
-// Launch the app, navigate to a page with a title, check that the app title
-// was set correctly.
-TEST_F(BrowserTest, Title) {
- FilePath test_file(test_data_directory_);
- test_file = test_file.AppendASCII("title2.html");
-
- NavigateToURL(net::FilePathToFileURL(test_file));
- // The browser lazily updates the title.
- PlatformThread::Sleep(sleep_timeout_ms());
-
- const std::wstring test_title(L"Title Of Awesomeness");
- EXPECT_EQ(LocaleWindowCaptionFromPageTitle(test_title), GetWindowTitle());
- EXPECT_EQ(test_title, GetActiveTabTitle());
-}
-
// Create 34 tabs and verify that a lot of processes have been created. The
// exact number of processes depends on the amount of memory. Previously we
// had a hard limit of 31 processes and this test is mainly directed at
diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp
index 4eb8b1f..ade7104 100644
--- a/chrome/chrome.gyp
+++ b/chrome/chrome.gyp
@@ -20,6 +20,7 @@
],
'grit_out_dir': '<(SHARED_INTERMEDIATE_DIR)/chrome',
'browser_tests_sources': [
+ 'browser/browser_browsertest.cc',
'browser/crash_recovery_browsertest.cc',
'browser/ssl/ssl_browser_tests.cc',
],
@@ -4144,6 +4145,8 @@
'test_support_common',
'../skia/skia.gyp:skia',
'../testing/gtest.gyp:gtest',
+ '../third_party/icu38/icu38.gyp:icui18n',
+ '../third_party/icu38/icu38.gyp:icuuc',
],
'include_dirs': [
'..',
@@ -4498,6 +4501,8 @@
'renderer',
'../skia/skia.gyp:skia',
'../testing/gtest.gyp:gtest',
+ '../third_party/icu38/icu38.gyp:icui18n',
+ '../third_party/icu38/icu38.gyp:icuuc',
],
'include_dirs': [
'..',