summaryrefslogtreecommitdiffstats
path: root/chrome/test
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/test')
-rw-r--r--chrome/test/automated_ui_tests/automated_ui_test_base.cc46
-rw-r--r--chrome/test/automated_ui_tests/automated_ui_test_base.h27
-rw-r--r--chrome/test/automated_ui_tests/automated_ui_test_test.cc93
-rw-r--r--chrome/test/automated_ui_tests/automated_ui_tests.cc30
-rw-r--r--chrome/test/automated_ui_tests/automated_ui_tests.h30
-rw-r--r--chrome/test/ui/ui_test.cc5
6 files changed, 168 insertions, 63 deletions
diff --git a/chrome/test/automated_ui_tests/automated_ui_test_base.cc b/chrome/test/automated_ui_tests/automated_ui_test_base.cc
index bf39831..5f2ef95 100644
--- a/chrome/test/automated_ui_tests/automated_ui_test_base.cc
+++ b/chrome/test/automated_ui_tests/automated_ui_test_base.cc
@@ -241,6 +241,13 @@ bool AutomatedUITestBase::DragActiveTab(bool drag_right) {
}
#endif
+bool AutomatedUITestBase::FindInPage() {
+ if (!RunCommandAsync(IDC_FIND))
+ return false;
+
+ return WaitForFindWindowVisibilityChange(active_browser(), true);
+}
+
bool AutomatedUITestBase::ForwardButton() {
return RunCommand(IDC_FORWARD);
}
@@ -249,6 +256,10 @@ bool AutomatedUITestBase::GoOffTheRecord() {
return RunCommand(IDC_NEW_INCOGNITO_WINDOW);
}
+bool AutomatedUITestBase::Home() {
+ return RunCommand(IDC_HOME);
+}
+
bool AutomatedUITestBase::OpenAndActivateNewBrowserWindow(
scoped_refptr<BrowserProxy>* previous_browser) {
if (!automation()->OpenNewBrowserWindow(true /* SW_SHOWNORMAL */)) {
@@ -317,6 +328,41 @@ bool AutomatedUITestBase::RestoreTab() {
return RunCommand(IDC_RESTORE_TAB);
}
+bool AutomatedUITestBase::SelectNextTab() {
+ return RunCommand(IDC_SELECT_NEXT_TAB);
+}
+
+bool AutomatedUITestBase::SelectPreviousTab() {
+ return RunCommand(IDC_SELECT_PREVIOUS_TAB);
+}
+
+bool AutomatedUITestBase::ShowBookmarkBar() {
+ bool is_visible;
+ bool is_animating;
+ if (!active_browser()->GetBookmarkBarVisibility(&is_visible,
+ &is_animating)) {
+ return false;
+ }
+
+ if (is_visible) {
+ // If the bar is visible, then issuing the command again will toggle it.
+ return true;
+ }
+
+ if (!RunCommandAsync(IDC_SHOW_BOOKMARK_BAR))
+ return false;
+
+ return WaitForBookmarkBarVisibilityChange(active_browser(), true);
+}
+
+bool AutomatedUITestBase::ShowDownloads() {
+ return RunCommand(IDC_SHOW_DOWNLOADS);
+}
+
+bool AutomatedUITestBase::ShowHistory() {
+ return RunCommand(IDC_SHOW_HISTORY);
+}
+
bool AutomatedUITestBase::RunCommandAsync(int browser_command) {
BrowserProxy* browser = active_browser();
if (NULL == browser) {
diff --git a/chrome/test/automated_ui_tests/automated_ui_test_base.h b/chrome/test/automated_ui_tests/automated_ui_test_base.h
index cc4fb8648..c4b9429 100644
--- a/chrome/test/automated_ui_tests/automated_ui_test_base.h
+++ b/chrome/test/automated_ui_tests/automated_ui_test_base.h
@@ -57,6 +57,9 @@ class AutomatedUITestBase : public UITest {
// drag the active tab over.
bool DragActiveTab(bool drag_right);
+ // Activates "find in page" on the current page. Returns true on success.
+ bool FindInPage();
+
// Go forward in active tab.
// Returns true if successful, false otherwise.
bool ForwardButton();
@@ -64,6 +67,10 @@ class AutomatedUITestBase : public UITest {
// Opens an OffTheRecord browser window.
bool GoOffTheRecord();
+ // Navigates to the Home page.
+ // Returns true if call to activate the accelerator is successful.
+ bool Home();
+
// Navigates the activate tab to given url.
bool Navigate(const GURL& url);
@@ -88,6 +95,26 @@ class AutomatedUITestBase : public UITest {
// Returns true if the tab is successfully restored.
bool RestoreTab();
+ // Activates the next tab on the active browser window.
+ // Returns true on success.
+ bool SelectNextTab();
+
+ // Activates the previous tab on the active browser window.
+ // Returns true on success.
+ bool SelectPreviousTab();
+
+ // Displays the bookmark bar.
+ // Returns true on success.
+ bool ShowBookmarkBar();
+
+ // Opens the Downloads page in the current active browser window.
+ // Returns true on success.
+ bool ShowDownloads();
+
+ // Opens the History page in the current active browser window.
+ // Returns true on success.
+ bool ShowHistory();
+
// Runs the specified browser command in the current active browser.
// See browser_commands.cc for the list of commands.
// Returns true if the call is successfully dispatched.
diff --git a/chrome/test/automated_ui_tests/automated_ui_test_test.cc b/chrome/test/automated_ui_tests/automated_ui_test_test.cc
index 383a1e7..b206ef4 100644
--- a/chrome/test/automated_ui_tests/automated_ui_test_test.cc
+++ b/chrome/test/automated_ui_tests/automated_ui_test_test.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "chrome/app/chrome_dll_resource.h"
+#include "chrome/common/url_constants.h"
#include "chrome/test/automated_ui_tests/automated_ui_test_base.h"
#include "chrome/test/automation/browser_proxy.h"
#include "chrome/test/automation/tab_proxy.h"
@@ -32,6 +33,29 @@
#define MAYBE_CloseBrowserWindow CloseBrowserWindow
#endif
+TEST_F(AutomatedUITestBase, FindInPage) {
+ ASSERT_TRUE(FindInPage());
+ bool is_visible;
+ ASSERT_TRUE(active_browser()->IsFindWindowFullyVisible(&is_visible));
+ EXPECT_TRUE(is_visible);
+}
+
+TEST_F(AutomatedUITestBase, Home) {
+ FilePath path_prefix(test_data_directory_.AppendASCII("session_history"));
+ GURL bot1(net::FilePathToFileURL(path_prefix.AppendASCII("bot1.html")));
+ NavigateToURL(bot1); // To help verify that Home does something.
+
+ ASSERT_TRUE(Home());
+
+ GURL url;
+ ASSERT_TRUE(active_browser()->GetActiveTab()->GetCurrentURL(&url));
+ EXPECT_EQ(GURL(chrome::kAboutBlankURL), url);
+
+ std::wstring title;
+ ASSERT_TRUE(active_browser()->GetActiveTab()->GetTabTitle(&title));
+ EXPECT_EQ(L"", title);
+}
+
TEST_F(AutomatedUITestBase, NewTab) {
int tab_count;
active_browser()->GetTabCount(&tab_count);
@@ -294,3 +318,72 @@ TEST_F(AutomatedUITestBase, Navigate) {
ASSERT_TRUE(GetActiveTab()->GetCurrentURL(&url));
ASSERT_EQ(url2, url);
}
+
+TEST_F(AutomatedUITestBase, SelectTab) {
+ FilePath filename(test_data_directory_);
+ filename = filename.AppendASCII("title2.html");
+ GURL url = net::FilePathToFileURL(filename);
+
+ ASSERT_TRUE(active_browser()->AppendTab(url));
+ ASSERT_TRUE(active_browser()->AppendTab(url));
+
+ int active_tab_index;
+ ASSERT_TRUE(active_browser()->GetActiveTabIndex(&active_tab_index));
+ ASSERT_EQ(2, active_tab_index);
+
+ ASSERT_TRUE(SelectNextTab());
+ ASSERT_TRUE(active_browser()->GetActiveTabIndex(&active_tab_index));
+ ASSERT_EQ(0, active_tab_index);
+
+ ASSERT_TRUE(SelectNextTab());
+ ASSERT_TRUE(active_browser()->GetActiveTabIndex(&active_tab_index));
+ ASSERT_EQ(1, active_tab_index);
+
+ ASSERT_TRUE(SelectPreviousTab());
+ ASSERT_TRUE(active_browser()->GetActiveTabIndex(&active_tab_index));
+ ASSERT_EQ(0, active_tab_index);
+
+ ASSERT_TRUE(SelectPreviousTab());
+ ASSERT_TRUE(active_browser()->GetActiveTabIndex(&active_tab_index));
+ ASSERT_EQ(2, active_tab_index);
+
+ ASSERT_TRUE(SelectPreviousTab());
+ ASSERT_TRUE(active_browser()->GetActiveTabIndex(&active_tab_index));
+ ASSERT_EQ(1, active_tab_index);
+
+ ASSERT_TRUE(SelectNextTab());
+ ASSERT_TRUE(active_browser()->GetActiveTabIndex(&active_tab_index));
+ ASSERT_EQ(2, active_tab_index);
+}
+
+TEST_F(AutomatedUITestBase, ShowBookmarkBar) {
+ ASSERT_TRUE(ShowBookmarkBar());
+ bool is_visible;
+ bool is_animating;
+ ASSERT_TRUE(active_browser()->GetBookmarkBarVisibility(&is_visible,
+ &is_animating));
+ ASSERT_TRUE(is_visible);
+ ASSERT_FALSE(is_animating);
+
+ // Try second time to make sure it won't make the bookmark bar
+ // disappear.
+ ASSERT_TRUE(ShowBookmarkBar());
+ ASSERT_TRUE(active_browser()->GetBookmarkBarVisibility(&is_visible,
+ &is_animating));
+ ASSERT_TRUE(is_visible);
+ ASSERT_FALSE(is_animating);
+}
+
+TEST_F(AutomatedUITestBase, ShowDownloads) {
+ ASSERT_TRUE(ShowDownloads());
+ GURL url;
+ ASSERT_TRUE(GetActiveTab()->GetCurrentURL(&url));
+ ASSERT_EQ(GURL(chrome::kChromeUIDownloadsURL), url);
+}
+
+TEST_F(AutomatedUITestBase, ShowHistory) {
+ ASSERT_TRUE(ShowHistory());
+ GURL url;
+ ASSERT_TRUE(GetActiveTab()->GetCurrentURL(&url));
+ ASSERT_EQ(GURL(chrome::kChromeUIHistoryURL), url);
+}
diff --git a/chrome/test/automated_ui_tests/automated_ui_tests.cc b/chrome/test/automated_ui_tests/automated_ui_tests.cc
index 02afb67..394b91c 100644
--- a/chrome/test/automated_ui_tests/automated_ui_tests.cc
+++ b/chrome/test/automated_ui_tests/automated_ui_tests.cc
@@ -425,6 +425,8 @@ bool AutomatedUITest::DoAction(const std::string& action) {
<< action.c_str();
}
+ EXPECT_TRUE(did_complete_action) << action;
+
if (!did_complete_action)
xml_writer_.AddAttribute("failed_to_complete", "yes");
xml_writer_.EndElement();
@@ -455,14 +457,6 @@ bool AutomatedUITest::ChangeEncoding() {
return RunCommandAsync((*encodings)[index].encoding_id);
}
-bool AutomatedUITest::FindInPage() {
- return RunCommandAsync(IDC_FIND);
-}
-
-bool AutomatedUITest::Home() {
- return RunCommandAsync(IDC_HOME);
-}
-
bool AutomatedUITest::JavaScriptConsole() {
return RunCommandAsync(IDC_DEV_TOOLS);
}
@@ -527,26 +521,6 @@ bool AutomatedUITest::PressUpArrow() {
return SimulateKeyPressInActiveWindow(base::VKEY_UP, 0);
}
-bool AutomatedUITest::SelectNextTab() {
- return RunCommandAsync(IDC_SELECT_NEXT_TAB);
-}
-
-bool AutomatedUITest::SelectPreviousTab() {
- return RunCommandAsync(IDC_SELECT_PREVIOUS_TAB);
-}
-
-bool AutomatedUITest::ShowBookmarkBar() {
- return RunCommandAsync(IDC_SHOW_BOOKMARK_BAR);
-}
-
-bool AutomatedUITest::ShowDownloads() {
- return RunCommandAsync(IDC_SHOW_DOWNLOADS);
-}
-
-bool AutomatedUITest::ShowHistory() {
- return RunCommandAsync(IDC_SHOW_HISTORY);
-}
-
bool AutomatedUITest::StarPage() {
return RunCommandAsync(IDC_STAR);
}
diff --git a/chrome/test/automated_ui_tests/automated_ui_tests.h b/chrome/test/automated_ui_tests/automated_ui_tests.h
index 1db44bb..d370b70 100644
--- a/chrome/test/automated_ui_tests/automated_ui_tests.h
+++ b/chrome/test/automated_ui_tests/automated_ui_tests.h
@@ -141,15 +141,6 @@ class AutomatedUITest : public AutomatedUITestBase {
// XML element: <Dialog/>
bool ExerciseDialog();
- // Activates "find in page" on the current page.
- // XML element: <FindInPage/>
- bool FindInPage();
-
- // Navigates to the Home page.
- // Returns true if call to activate the accelerator is successful.
- // XML element: <Home/>
- bool Home();
-
// Opens the JavaScriptConsole window. While it isn't modal, it takes focus
// from the current browser window, so most of the test can't continue until
// it is dismissed.
@@ -226,27 +217,6 @@ class AutomatedUITest : public AutomatedUITestBase {
// XML element: <UpArrow/>
bool PressUpArrow();
- // Activates the next tab on the active browser window.
- // XML element: <SelectNextTab/>
- bool SelectNextTab();
-
- // Activates the previous tab on the active browser window.
- // XML element: <SelectPrevTab/>
- bool SelectPreviousTab();
-
- // Displays the bookmark bar.
- // Returns true if call to activate the accelerator is successful.
- // XML element: <ShowBookmarks/>
- bool ShowBookmarkBar();
-
- // Opens the Downloads page in the current active browser window.
- // XML element: <Downloads/>
- bool ShowDownloads();
-
- // Opens the History page in the current active browser window.
- // XML element: <History/>
- bool ShowHistory();
-
// Stars the current page. This opens a dialog that may or may not be
// dismissed.
// XML element: <Star/>
diff --git a/chrome/test/ui/ui_test.cc b/chrome/test/ui/ui_test.cc
index b59d71f..cacd59d0 100644
--- a/chrome/test/ui/ui_test.cc
+++ b/chrome/test/ui/ui_test.cc
@@ -500,10 +500,6 @@ bool UITest::WaitForDownloadShelfVisibilityChange(BrowserProxy* browser,
return false;
}
-// TODO(port): this #if effectively cuts out half of this file on
-// non-Windows platforms, and is a temporary hack to get things
-// building.
-#if defined(OS_WIN)
bool UITest::WaitForFindWindowVisibilityChange(BrowserProxy* browser,
bool wait_for_open) {
const int kCycles = 10;
@@ -536,7 +532,6 @@ bool UITest::WaitForBookmarkBarVisibilityChange(BrowserProxy* browser,
}
return false;
}
-#endif // defined(OS_WIN)
GURL UITest::GetActiveTabURL(int window_index) {
scoped_refptr<TabProxy> tab_proxy(GetActiveTab(window_index));