summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-29 18:45:44 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-29 18:45:44 +0000
commit895a8472bdc74bcaa0c32609f68c6570dedba03e (patch)
tree36b36b3e13d0c1e475a4357874f89f41c9d0a23e
parent57b531b405a961a7af36a54b9956c5514212ac53 (diff)
downloadchromium_src-895a8472bdc74bcaa0c32609f68c6570dedba03e.zip
chromium_src-895a8472bdc74bcaa0c32609f68c6570dedba03e.tar.gz
chromium_src-895a8472bdc74bcaa0c32609f68c6570dedba03e.tar.bz2
Move the test functions that deal with focus to interactive_ui_tets_utils.h and into the interactive_ui_tests target. That way they can't be misused from browser_tests.
Review URL: https://codereview.chromium.org/11414223 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@170224 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/autofill/autofill_browsertest.cc8
-rw-r--r--chrome/browser/browser_keyevents_browsertest.cc1
-rw-r--r--chrome/browser/chromeos/login/login_browsertest.cc1
-rw-r--r--chrome/browser/extensions/api/tabs/tabs_interactive_test.cc58
-rw-r--r--chrome/browser/extensions/api/tabs/tabs_test.cc56
-rw-r--r--chrome/browser/extensions/extension_keybinding_apitest.cc1
-rw-r--r--chrome/browser/instant/instant_browsertest.cc1
-rw-r--r--chrome/browser/ui/browser_focus_uitest.cc42
-rw-r--r--chrome/browser/ui/browser_navigator_browsertest.cc41
-rw-r--r--chrome/browser/ui/fullscreen/fullscreen_controller_interactive_browsertest.cc1
-rw-r--r--chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk_interactive_uitest.cc1
-rw-r--r--chrome/browser/ui/omnibox/action_box_browsertest.cc1
-rw-r--r--chrome/browser/ui/omnibox/omnibox_view_browsertest.cc1
-rw-r--r--chrome/browser/ui/panels/base_panel_browser_test.cc1
-rw-r--r--chrome/browser/ui/panels/panel_browsertest.cc26
-rw-r--r--chrome/browser/ui/panels/panel_extension_browsertest.cc25
-rw-r--r--chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc1
-rw-r--r--chrome/browser/ui/views/button_dropdown_test.cc1
-rw-r--r--chrome/browser/ui/views/find_bar_host_interactive_uitest.cc1
-rw-r--r--chrome/browser/ui/views/keyboard_access_browsertest.cc1
-rw-r--r--chrome/browser/ui/views/menu_item_view_test.cc1
-rw-r--r--chrome/browser/ui/views/menu_model_adapter_test.cc1
-rw-r--r--chrome/browser/ui/views/ssl_client_certificate_selector_browsertest.cc1
-rw-r--r--chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.cc1
-rw-r--r--chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest_win.cc1
-rw-r--r--chrome/browser/ui/views/test/ui_test_utils_win.cc129
-rw-r--r--chrome/chrome_tests.gypi10
-rw-r--r--chrome/chrome_tests_unit.gypi6
-rw-r--r--chrome/test/base/interactive_test_utils.cc105
-rw-r--r--chrome/test/base/interactive_test_utils.h140
-rw-r--r--chrome/test/base/interactive_test_utils_aura.cc (renamed from chrome/browser/ui/views/test/ui_test_utils_aura.cc)4
-rw-r--r--chrome/test/base/interactive_test_utils_aura.h (renamed from chrome/browser/ui/views/test/ui_test_utils_aura.h)6
-rw-r--r--chrome/test/base/interactive_test_utils_gtk.cc (renamed from chrome/browser/ui/gtk/test/ui_test_utils_gtk.cc)2
-rw-r--r--chrome/test/base/interactive_test_utils_mac.mm (renamed from chrome/browser/ui/cocoa/test/ui_test_utils_mac.mm)2
-rw-r--r--chrome/test/base/interactive_test_utils_views.cc (renamed from chrome/browser/ui/views/test/ui_test_utils_views.cc)2
-rw-r--r--chrome/test/base/interactive_test_utils_win.cc64
-rw-r--r--chrome/test/base/ui_test_utils.cc154
-rw-r--r--chrome/test/base/ui_test_utils.h119
-rw-r--r--chrome/test/gpu/gpu_mapsgl_endurance_browsertest.cc2
-rw-r--r--chrome/test/gpu/gpu_pixel_browsertest.cc2
40 files changed, 539 insertions, 482 deletions
diff --git a/chrome/browser/autofill/autofill_browsertest.cc b/chrome/browser/autofill/autofill_browsertest.cc
index 7d6a5b3..4255985 100644
--- a/chrome/browser/autofill/autofill_browsertest.cc
+++ b/chrome/browser/autofill/autofill_browsertest.cc
@@ -450,7 +450,6 @@ IN_PROC_BROWSER_TEST_F(AutofillTest, MAYBE_AutofillViaDownArrow) {
CreateTestProfile();
// Load the test page.
- ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(),
GURL(std::string(kDataURIPrefix) + kTestFormString)));
@@ -507,7 +506,6 @@ IN_PROC_BROWSER_TEST_F(AutofillTest, MAYBE_OnChangeAfterAutofill) {
"</script>";
// Load the test page.
- ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(),
GURL(std::string(kDataURIPrefix) + kTestFormString + kOnChangeScript)));
@@ -582,7 +580,6 @@ IN_PROC_BROWSER_TEST_F(AutofillTest, DISABLED_AutofillFormsDistinguishedById) {
"newForm.id = 'newForm';"
"mainForm.parentNode.insertBefore(newForm, mainForm);"
"</script>";
- ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), GURL(kURL)));
// Invoke Autofill.
@@ -598,7 +595,6 @@ IN_PROC_BROWSER_TEST_F(AutofillTest, DISABLED_AutofillFormWithRepeatedField) {
CreateTestProfile();
// Load the test page.
- ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(),
GURL(std::string(kDataURIPrefix) +
"<form action=\"http://www.example.com/\" method=\"POST\">"
@@ -654,7 +650,6 @@ IN_PROC_BROWSER_TEST_F(AutofillTest,
CreateTestProfile();
// Load the test page.
- ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(),
GURL(std::string(kDataURIPrefix) +
"<form action=\"http://www.example.com/\" method=\"POST\">"
@@ -699,7 +694,6 @@ IN_PROC_BROWSER_TEST_F(AutofillTest, DISABLED_DynamicFormFill) {
CreateTestProfile();
// Load the test page.
- ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(),
GURL(std::string(kDataURIPrefix) +
"<form id=\"form\" action=\"http://www.example.com/\""
@@ -798,7 +792,6 @@ IN_PROC_BROWSER_TEST_F(AutofillTest, MAYBE_AutofillAfterReload) {
// Load the test page.
LOG(WARNING) << "Bringing browser window to front.";
- ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
LOG(WARNING) << "Navigating to URL.";
ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(),
GURL(std::string(kDataURIPrefix) + kTestFormString)));
@@ -849,7 +842,6 @@ IN_PROC_BROWSER_TEST_F(AutofillTest, DISABLED_AutofillAfterTranslate) {
"<label for=\"ph\">Phone number:</label>"
" <input type=\"text\" id=\"ph\"><br>"
"</form>");
- ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), url));
// Get translation bar.
diff --git a/chrome/browser/browser_keyevents_browsertest.cc b/chrome/browser/browser_keyevents_browsertest.cc
index 7b6174a..5381581 100644
--- a/chrome/browser/browser_keyevents_browsertest.cc
+++ b/chrome/browser/browser_keyevents_browsertest.cc
@@ -14,6 +14,7 @@
#include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/chrome_paths.h"
+#include "chrome/test/base/interactive_test_utils.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "content/public/browser/dom_operation_notification_details.h"
diff --git a/chrome/browser/chromeos/login/login_browsertest.cc b/chrome/browser/chromeos/login/login_browsertest.cc
index 3ae35e8..5d5993e 100644
--- a/chrome/browser/chromeos/login/login_browsertest.cc
+++ b/chrome/browser/chromeos/login/login_browsertest.cc
@@ -13,6 +13,7 @@
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/common/chrome_switches.h"
+#include "chrome/test/base/interactive_test_utils.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "testing/gmock/include/gmock/gmock.h"
diff --git a/chrome/browser/extensions/api/tabs/tabs_interactive_test.cc b/chrome/browser/extensions/api/tabs/tabs_interactive_test.cc
index 7114cbc..1d17ce4 100644
--- a/chrome/browser/extensions/api/tabs/tabs_interactive_test.cc
+++ b/chrome/browser/extensions/api/tabs/tabs_interactive_test.cc
@@ -9,6 +9,8 @@
#include "chrome/browser/extensions/extension_function_test_utils.h"
#include "chrome/browser/extensions/extension_tab_util.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_window.h"
+#include "chrome/test/base/interactive_test_utils.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
@@ -51,3 +53,59 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, GetLastFocusedWindow) {
// "populate" was enabled so tabs should be populated.
EXPECT_TRUE(result.get()->GetList(keys::kTabsKey, &tabs));
}
+
+// Flaky: http://crbug.com/136562
+IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, DISABLED_QueryLastFocusedWindowTabs) {
+ const size_t kExtraWindows = 2;
+ for (size_t i = 0; i < kExtraWindows; ++i)
+ CreateBrowser(browser()->profile());
+
+ Browser* focused_window = CreateBrowser(browser()->profile());
+#if defined(OS_MACOSX)
+ // See BrowserWindowCocoa::Show. In tests, Browser::window()->IsActive won't
+ // work unless we fake the browser being launched by the user.
+ ASSERT_TRUE(ui_test_utils::ShowAndFocusNativeWindow(
+ focused_window->window()->GetNativeWindow()));
+#endif
+
+ // Needed on Mac and Linux so that the BrowserWindow::IsActive calls work.
+ content::RunAllPendingInMessageLoop();
+
+ GURL url;
+ AddTabAtIndexToBrowser(focused_window, 0, url, content::PAGE_TRANSITION_LINK);
+ int focused_window_id = ExtensionTabUtil::GetWindowId(focused_window);
+
+ // Get tabs in the 'last focused' window called from non-focused browser.
+ scoped_refptr<QueryTabsFunction> function = new QueryTabsFunction();
+ scoped_ptr<base::ListValue> result(utils::ToList(
+ utils::RunFunctionAndReturnSingleResult(function.get(),
+ "[{\"lastFocusedWindow\":true}]",
+ browser())));
+
+ ListValue* result_tabs = result.get();
+ // We should have one initial tab and one added tab.
+ EXPECT_EQ(2u, result_tabs->GetSize());
+ for (size_t i = 0; i < result_tabs->GetSize(); ++i) {
+ DictionaryValue* result_tab = NULL;
+ EXPECT_TRUE(result_tabs->GetDictionary(i, &result_tab));
+ EXPECT_EQ(focused_window_id, utils::GetInteger(result_tab,
+ keys::kWindowIdKey));
+ }
+
+ // Get tabs NOT in the 'last focused' window called from the focused browser.
+ function = new QueryTabsFunction();
+ result.reset(utils::ToList(
+ utils::RunFunctionAndReturnSingleResult(function.get(),
+ "[{\"lastFocusedWindow\":false}]",
+ browser())));
+
+ result_tabs = result.get();
+ // We should get one tab for each extra window and one for the initial window.
+ EXPECT_EQ(kExtraWindows + 1, result_tabs->GetSize());
+ for (size_t i = 0; i < result_tabs->GetSize(); ++i) {
+ DictionaryValue* result_tab = NULL;
+ EXPECT_TRUE(result_tabs->GetDictionary(i, &result_tab));
+ EXPECT_NE(focused_window_id, utils::GetInteger(result_tab,
+ keys::kWindowIdKey));
+ }
+}
diff --git a/chrome/browser/extensions/api/tabs/tabs_test.cc b/chrome/browser/extensions/api/tabs/tabs_test.cc
index 49ba37c..e04d5cf 100644
--- a/chrome/browser/extensions/api/tabs/tabs_test.cc
+++ b/chrome/browser/extensions/api/tabs/tabs_test.cc
@@ -439,62 +439,6 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, QueryCurrentWindowTabs) {
}
}
-// Flaky: http://crbug.com/136562
-IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, DISABLED_QueryLastFocusedWindowTabs) {
- const size_t kExtraWindows = 2;
- for (size_t i = 0; i < kExtraWindows; ++i)
- CreateBrowser(browser()->profile());
-
- Browser* focused_window = CreateBrowser(browser()->profile());
-#if defined(OS_MACOSX)
- // See BrowserWindowCocoa::Show. In tests, Browser::window()->IsActive won't
- // work unless we fake the browser being launched by the user.
- ASSERT_TRUE(ui_test_utils::ShowAndFocusNativeWindow(
- focused_window->window()->GetNativeWindow()));
-#endif
-
- // Needed on Mac and Linux so that the BrowserWindow::IsActive calls work.
- content::RunAllPendingInMessageLoop();
-
- GURL url;
- AddTabAtIndexToBrowser(focused_window, 0, url, content::PAGE_TRANSITION_LINK);
- int focused_window_id = ExtensionTabUtil::GetWindowId(focused_window);
-
- // Get tabs in the 'last focused' window called from non-focused browser.
- scoped_refptr<QueryTabsFunction> function = new QueryTabsFunction();
- scoped_ptr<base::ListValue> result(utils::ToList(
- utils::RunFunctionAndReturnSingleResult(function.get(),
- "[{\"lastFocusedWindow\":true}]",
- browser())));
-
- ListValue* result_tabs = result.get();
- // We should have one initial tab and one added tab.
- EXPECT_EQ(2u, result_tabs->GetSize());
- for (size_t i = 0; i < result_tabs->GetSize(); ++i) {
- DictionaryValue* result_tab = NULL;
- EXPECT_TRUE(result_tabs->GetDictionary(i, &result_tab));
- EXPECT_EQ(focused_window_id, utils::GetInteger(result_tab,
- keys::kWindowIdKey));
- }
-
- // Get tabs NOT in the 'last focused' window called from the focused browser.
- function = new QueryTabsFunction();
- result.reset(utils::ToList(
- utils::RunFunctionAndReturnSingleResult(function.get(),
- "[{\"lastFocusedWindow\":false}]",
- browser())));
-
- result_tabs = result.get();
- // We should get one tab for each extra window and one for the initial window.
- EXPECT_EQ(kExtraWindows + 1, result_tabs->GetSize());
- for (size_t i = 0; i < result_tabs->GetSize(); ++i) {
- DictionaryValue* result_tab = NULL;
- EXPECT_TRUE(result_tabs->GetDictionary(i, &result_tab));
- EXPECT_NE(focused_window_id, utils::GetInteger(result_tab,
- keys::kWindowIdKey));
- }
-}
-
IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, DontCreateTabInClosingPopupWindow) {
// Test creates new popup window, closes it right away and then tries to open
// a new tab in it. Tab should not be opened in the popup window, but in a
diff --git a/chrome/browser/extensions/extension_keybinding_apitest.cc b/chrome/browser/extensions/extension_keybinding_apitest.cc
index 3fe9591..927edb0 100644
--- a/chrome/browser/extensions/extension_keybinding_apitest.cc
+++ b/chrome/browser/extensions/extension_keybinding_apitest.cc
@@ -15,6 +15,7 @@
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/extensions/extension.h"
+#include "chrome/test/base/interactive_test_utils.h"
#include "chrome/test/base/ui_test_utils.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/web_contents.h"
diff --git a/chrome/browser/instant/instant_browsertest.cc b/chrome/browser/instant/instant_browsertest.cc
index e4e5c5d..e85d755 100644
--- a/chrome/browser/instant/instant_browsertest.cc
+++ b/chrome/browser/instant/instant_browsertest.cc
@@ -21,6 +21,7 @@
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/pref_names.h"
+#include "chrome/test/base/interactive_test_utils.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "content/public/browser/notification_service.h"
diff --git a/chrome/browser/ui/browser_focus_uitest.cc b/chrome/browser/ui/browser_focus_uitest.cc
index 1a4fb90..7726fd0 100644
--- a/chrome/browser/ui/browser_focus_uitest.cc
+++ b/chrome/browser/ui/browser_focus_uitest.cc
@@ -17,12 +17,17 @@
#include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/chrome_pages.h"
+#include "chrome/browser/ui/omnibox/location_bar.h"
+#include "chrome/browser/ui/omnibox/omnibox_edit_controller.h"
+#include "chrome/browser/ui/omnibox/omnibox_edit_model.h"
+#include "chrome/browser/ui/omnibox/omnibox_view.h"
#include "chrome/browser/ui/tab_contents/tab_contents.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/view_ids.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/url_constants.h"
+#include "chrome/test/base/interactive_test_utils.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "content/public/browser/interstitial_page.h"
@@ -922,4 +927,41 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, DISABLED_FocusOnReloadCrashedTab) {
ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER));
}
+// Tests that when a new tab is opened from the omnibox, the focus is moved from
+// the omnibox for the current tab.
+IN_PROC_BROWSER_TEST_F(BrowserFocusTest,
+ NavigateFromOmniboxIntoNewTab) {
+ GURL url("http://www.google.com/");
+ GURL url2("http://maps.google.com/");
+
+ // Navigate to url.
+ chrome::NavigateParams p(browser(), url, content::PAGE_TRANSITION_LINK);
+ p.window_action = chrome::NavigateParams::SHOW_WINDOW;
+ p.disposition = CURRENT_TAB;
+ chrome::Navigate(&p);
+
+ // Focus the omnibox.
+ chrome::FocusLocationBar(browser());
+
+ OmniboxEditController* controller =
+ browser()->window()->GetLocationBar()->GetLocationEntry()->model()->
+ controller();
+
+ // Simulate an alt-enter.
+ controller->OnAutocompleteAccept(url2, NEW_FOREGROUND_TAB,
+ content::PAGE_TRANSITION_TYPED, GURL());
+
+ // Make sure the second tab is selected.
+ EXPECT_EQ(1, browser()->active_index());
+
+ // The tab contents should have the focus in the second tab.
+ EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_TAB_CONTAINER));
+
+ // Go back to the first tab. The focus should not be in the omnibox.
+ chrome::SelectPreviousTab(browser());
+ EXPECT_EQ(0, browser()->active_index());
+ EXPECT_FALSE(ui_test_utils::IsViewFocused(browser(),
+ VIEW_ID_LOCATION_BAR));
+}
+
} // namespace
diff --git a/chrome/browser/ui/browser_navigator_browsertest.cc b/chrome/browser/ui/browser_navigator_browsertest.cc
index fe030ae..9577116 100644
--- a/chrome/browser/ui/browser_navigator_browsertest.cc
+++ b/chrome/browser/ui/browser_navigator_browsertest.cc
@@ -15,10 +15,6 @@
#include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/chrome_pages.h"
-#include "chrome/browser/ui/omnibox/location_bar.h"
-#include "chrome/browser/ui/omnibox/omnibox_edit_controller.h"
-#include "chrome/browser/ui/omnibox/omnibox_edit_model.h"
-#include "chrome/browser/ui/omnibox/omnibox_view.h"
#include "chrome/browser/ui/tab_contents/tab_contents.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/common/chrome_switches.h"
@@ -1161,43 +1157,6 @@ IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
ShortenUberURL(chrome::GetActiveWebContents(browser())->GetURL()));
}
-// Tests that when a new tab is opened from the omnibox, the focus is moved from
-// the omnibox for the current tab.
-IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
- NavigateFromOmniboxIntoNewTab) {
- GURL url("http://www.google.com/");
- GURL url2("http://maps.google.com/");
-
- // Navigate to url.
- chrome::NavigateParams p(MakeNavigateParams());
- p.disposition = CURRENT_TAB;
- p.url = url;
- chrome::Navigate(&p);
-
- // Focus the omnibox.
- chrome::FocusLocationBar(browser());
-
- OmniboxEditController* controller =
- browser()->window()->GetLocationBar()->GetLocationEntry()->model()->
- controller();
-
- // Simulate an alt-enter.
- controller->OnAutocompleteAccept(url2, NEW_FOREGROUND_TAB,
- content::PAGE_TRANSITION_TYPED, GURL());
-
- // Make sure the second tab is selected.
- EXPECT_EQ(1, browser()->active_index());
-
- // The tab contents should have the focus in the second tab.
- EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_TAB_CONTAINER));
-
- // Go back to the first tab. The focus should not be in the omnibox.
- chrome::SelectPreviousTab(browser());
- EXPECT_EQ(0, browser()->active_index());
- EXPECT_FALSE(ui_test_utils::IsViewFocused(browser(),
- VIEW_ID_LOCATION_BAR));
-}
-
// TODO(csilv): Update this for uber page. http://crbug.com/111579.
IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
DISABLED_NavigateFromDefaultToHistoryInSameTab) {
diff --git a/chrome/browser/ui/fullscreen/fullscreen_controller_interactive_browsertest.cc b/chrome/browser/ui/fullscreen/fullscreen_controller_interactive_browsertest.cc
index 6903928..85c2b772 100644
--- a/chrome/browser/ui/fullscreen/fullscreen_controller_interactive_browsertest.cc
+++ b/chrome/browser/ui/fullscreen/fullscreen_controller_interactive_browsertest.cc
@@ -10,6 +10,7 @@
#include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/fullscreen/fullscreen_controller_test.h"
+#include "chrome/test/base/interactive_test_utils.h"
#include "chrome/test/base/ui_test_utils.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/render_widget_host_view.h"
diff --git a/chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk_interactive_uitest.cc b/chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk_interactive_uitest.cc
index 5739c6e..a7151a5 100644
--- a/chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk_interactive_uitest.cc
+++ b/chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk_interactive_uitest.cc
@@ -10,6 +10,7 @@
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/gtk/view_id_util.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
+#include "chrome/test/base/interactive_test_utils.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "net/test/test_server.h"
diff --git a/chrome/browser/ui/omnibox/action_box_browsertest.cc b/chrome/browser/ui/omnibox/action_box_browsertest.cc
index 6e2c1f8..e2310f6 100644
--- a/chrome/browser/ui/omnibox/action_box_browsertest.cc
+++ b/chrome/browser/ui/omnibox/action_box_browsertest.cc
@@ -20,6 +20,7 @@
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/url_constants.h"
+#include "chrome/test/base/interactive_test_utils.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/testing_profile.h"
#include "chrome/test/base/ui_test_utils.h"
diff --git a/chrome/browser/ui/omnibox/omnibox_view_browsertest.cc b/chrome/browser/ui/omnibox/omnibox_view_browsertest.cc
index c967a3a..805abbd 100644
--- a/chrome/browser/ui/omnibox/omnibox_view_browsertest.cc
+++ b/chrome/browser/ui/omnibox/omnibox_view_browsertest.cc
@@ -31,6 +31,7 @@
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/url_constants.h"
+#include "chrome/test/base/interactive_test_utils.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "content/public/browser/notification_service.h"
diff --git a/chrome/browser/ui/panels/base_panel_browser_test.cc b/chrome/browser/ui/panels/base_panel_browser_test.cc
index 3276240..57c0023 100644
--- a/chrome/browser/ui/panels/base_panel_browser_test.cc
+++ b/chrome/browser/ui/panels/base_panel_browser_test.cc
@@ -22,6 +22,7 @@
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/extensions/extension_manifest_constants.h"
+#include "chrome/test/base/interactive_test_utils.h"
#include "chrome/test/base/ui_test_utils.h"
#include "content/public/browser/notification_service.h"
#include "content/public/common/url_constants.h"
diff --git a/chrome/browser/ui/panels/panel_browsertest.cc b/chrome/browser/ui/panels/panel_browsertest.cc
index 71b6d10..ab388f0 100644
--- a/chrome/browser/ui/panels/panel_browsertest.cc
+++ b/chrome/browser/ui/panels/panel_browsertest.cc
@@ -6,6 +6,7 @@
#include "base/utf_string_conversions.h"
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/debugger/devtools_window.h"
+#include "chrome/browser/extensions/extension_apitest.h"
#include "chrome/browser/net/url_request_mock_util.h"
#include "chrome/browser/prefs/browser_prefs.h"
#include "chrome/browser/prefs/pref_service.h"
@@ -25,9 +26,11 @@
#include "chrome/browser/ui/panels/test_panel_active_state_observer.h"
#include "chrome/browser/web_applications/web_app.h"
#include "chrome/common/chrome_notification_types.h"
+#include "chrome/common/chrome_switches.h"
#include "chrome/common/extensions/extension_manifest_constants.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
+#include "chrome/test/base/interactive_test_utils.h"
#include "chrome/test/base/ui_test_utils.h"
#include "content/public/browser/native_web_keyboard_event.h"
#include "content/public/browser/notification_service.h"
@@ -1747,3 +1750,26 @@ IN_PROC_BROWSER_TEST_F(PanelBrowserTest, MAYBE_Accelerator) {
signal.Wait();
EXPECT_EQ(0, panel_manager->num_panels());
}
+
+class PanelExtensionApiTest : public ExtensionApiTest {
+ protected:
+ virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
+ ExtensionApiTest::SetUpCommandLine(command_line);
+ command_line->AppendSwitch(switches::kEnablePanels);
+ }
+};
+
+#if defined(OS_LINUX) || defined(USE_AURA)
+// Focus test fails if there is no window manager on Linux.
+// Aura panels have different behavior that do not apply to this test.
+#define MAYBE_FocusChangeEventOnMinimize DISABLED_FocusChangeEventOnMinimize
+#else
+#define MAYBE_FocusChangeEventOnMinimize FocusChangeEventOnMinimize
+#endif
+IN_PROC_BROWSER_TEST_F(PanelExtensionApiTest,
+ MAYBE_FocusChangeEventOnMinimize) {
+ // This is needed so the subsequently created panels can be activated.
+ // On a Mac, it transforms background-only test process into foreground one.
+ ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
+ ASSERT_TRUE(RunExtensionTest("panels/focus_change_on_minimize")) << message_;
+}
diff --git a/chrome/browser/ui/panels/panel_extension_browsertest.cc b/chrome/browser/ui/panels/panel_extension_browsertest.cc
index a642e06..ae2762d 100644
--- a/chrome/browser/ui/panels/panel_extension_browsertest.cc
+++ b/chrome/browser/ui/panels/panel_extension_browsertest.cc
@@ -6,7 +6,7 @@
#include "base/path_service.h"
#include "base/utf_string_conversions.h"
#include "chrome/app/chrome_command_ids.h"
-#include "chrome/browser/extensions/extension_apitest.h"
+#include "chrome/browser/extensions/extension_browsertest.h"
#include "chrome/browser/extensions/extension_test_message_listener.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/tab_contents/render_view_context_menu.h"
@@ -232,26 +232,3 @@ IN_PROC_BROWSER_TEST_F(PanelExtensionBrowserTest, CustomContextMenu) {
menu->ExecuteCommand(command_id);
EXPECT_TRUE(onclick_listener.WaitUntilSatisfied());
}
-
-class PanelExtensionApiTest : public ExtensionApiTest {
- protected:
- virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
- ExtensionApiTest::SetUpCommandLine(command_line);
- command_line->AppendSwitch(switches::kEnablePanels);
- }
-};
-
-#if defined(OS_LINUX) || defined(USE_AURA)
-// Focus test fails if there is no window manager on Linux.
-// Aura panels have different behavior that do not apply to this test.
-#define MAYBE_FocusChangeEventOnMinimize DISABLED_FocusChangeEventOnMinimize
-#else
-#define MAYBE_FocusChangeEventOnMinimize FocusChangeEventOnMinimize
-#endif
-IN_PROC_BROWSER_TEST_F(PanelExtensionApiTest,
- MAYBE_FocusChangeEventOnMinimize) {
- // This is needed so the subsequently created panels can be activated.
- // On a Mac, it transforms background-only test process into foreground one.
- ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
- ASSERT_TRUE(RunExtensionTest("panels/focus_change_on_minimize")) << message_;
-}
diff --git a/chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc b/chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc
index a17d33f..6947e84 100644
--- a/chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc
+++ b/chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc
@@ -20,6 +20,7 @@
#include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/pref_names.h"
+#include "chrome/test/base/interactive_test_utils.h"
#include "chrome/test/base/test_browser_window.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h"
diff --git a/chrome/browser/ui/views/button_dropdown_test.cc b/chrome/browser/ui/views/button_dropdown_test.cc
index 14a9f9b..6e89a4d 100644
--- a/chrome/browser/ui/views/button_dropdown_test.cc
+++ b/chrome/browser/ui/views/button_dropdown_test.cc
@@ -4,6 +4,7 @@
#include "base/message_loop.h"
#include "base/utf_string_conversions.h"
+#include "chrome/test/base/interactive_test_utils.h"
#include "chrome/test/base/ui_test_utils.h"
#include "chrome/test/base/view_event_test_base.h"
#include "ui/base/models/simple_menu_model.h"
diff --git a/chrome/browser/ui/views/find_bar_host_interactive_uitest.cc b/chrome/browser/ui/views/find_bar_host_interactive_uitest.cc
index 27f8e40..df5a8d2 100644
--- a/chrome/browser/ui/views/find_bar_host_interactive_uitest.cc
+++ b/chrome/browser/ui/views/find_bar_host_interactive_uitest.cc
@@ -15,6 +15,7 @@
#include "chrome/browser/ui/views/find_bar_host.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/common/chrome_notification_types.h"
+#include "chrome/test/base/interactive_test_utils.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "content/public/browser/notification_service.h"
diff --git a/chrome/browser/ui/views/keyboard_access_browsertest.cc b/chrome/browser/ui/views/keyboard_access_browsertest.cc
index ac8dbf7..66df9d7 100644
--- a/chrome/browser/ui/views/keyboard_access_browsertest.cc
+++ b/chrome/browser/ui/views/keyboard_access_browsertest.cc
@@ -13,6 +13,7 @@
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/ui/views/toolbar_view.h"
#include "chrome/common/chrome_notification_types.h"
+#include "chrome/test/base/interactive_test_utils.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "ui/base/events/event_constants.h"
diff --git a/chrome/browser/ui/views/menu_item_view_test.cc b/chrome/browser/ui/views/menu_item_view_test.cc
index 83476c9..acc67f44 100644
--- a/chrome/browser/ui/views/menu_item_view_test.cc
+++ b/chrome/browser/ui/views/menu_item_view_test.cc
@@ -4,6 +4,7 @@
#include "base/callback.h"
#include "base/utf_string_conversions.h"
+#include "chrome/test/base/interactive_test_utils.h"
#include "chrome/test/base/ui_test_utils.h"
#include "chrome/test/base/view_event_test_base.h"
#include "ui/ui_controls/ui_controls.h"
diff --git a/chrome/browser/ui/views/menu_model_adapter_test.cc b/chrome/browser/ui/views/menu_model_adapter_test.cc
index 24dedb9..74b44a5 100644
--- a/chrome/browser/ui/views/menu_model_adapter_test.cc
+++ b/chrome/browser/ui/views/menu_model_adapter_test.cc
@@ -4,6 +4,7 @@
#include "base/callback.h"
#include "base/utf_string_conversions.h"
+#include "chrome/test/base/interactive_test_utils.h"
#include "chrome/test/base/ui_test_utils.h"
#include "chrome/test/base/view_event_test_base.h"
#include "ui/base/models/menu_model.h"
diff --git a/chrome/browser/ui/views/ssl_client_certificate_selector_browsertest.cc b/chrome/browser/ui/views/ssl_client_certificate_selector_browsertest.cc
index 67556bc..4d1df63 100644
--- a/chrome/browser/ui/views/ssl_client_certificate_selector_browsertest.cc
+++ b/chrome/browser/ui/views/ssl_client_certificate_selector_browsertest.cc
@@ -10,6 +10,7 @@
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/views/ssl_client_certificate_selector.h"
+#include "chrome/test/base/interactive_test_utils.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "content/public/browser/web_contents.h"
diff --git a/chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.cc b/chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.cc
index 7bca443..ea80577 100644
--- a/chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.cc
+++ b/chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.cc
@@ -20,6 +20,7 @@
#include "chrome/browser/ui/views/tabs/tab_strip.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/chrome_switches.h"
+#include "chrome/test/base/interactive_test_utils.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "content/public/browser/notification_details.h"
diff --git a/chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest_win.cc b/chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest_win.cc
index ce49624..30f3fb5 100644
--- a/chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest_win.cc
+++ b/chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest_win.cc
@@ -19,6 +19,7 @@
#include "chrome/browser/ui/views/tabs/tab_strip.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/chrome_switches.h"
+#include "chrome/test/base/interactive_test_utils.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "content/public/browser/notification_details.h"
diff --git a/chrome/browser/ui/views/test/ui_test_utils_win.cc b/chrome/browser/ui/views/test/ui_test_utils_win.cc
deleted file mode 100644
index dbf882e..0000000
--- a/chrome/browser/ui/views/test/ui_test_utils_win.cc
+++ /dev/null
@@ -1,129 +0,0 @@
-// Copyright (c) 2012 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 "chrome/test/base/ui_test_utils.h"
-
-#include "base/file_path.h"
-#include "base/file_util.h"
-#include "base/logging.h"
-#include "base/path_service.h"
-#include "base/stringprintf.h"
-#include "base/time.h"
-#include "chrome/browser/ui/window_snapshot/window_snapshot.h"
-#include "ui/base/win/foreground_helper.h"
-#include "ui/ui_controls/ui_controls.h"
-#include "ui/views/focus/focus_manager.h"
-
-#if defined(USE_AURA)
-#include "chrome/browser/ui/host_desktop.h"
-#include "chrome/browser/ui/views/test/ui_test_utils_aura.h"
-#include "ui/aura/root_window.h"
-#endif
-
-namespace ui_test_utils {
-
-namespace {
-
-const char kSnapshotBaseName[] = "ChromiumSnapshot";
-const char kSnapshotExtension[] = ".png";
-
-FilePath GetSnapshotFileName(const FilePath& snapshot_directory) {
- base::Time::Exploded the_time;
-
- base::Time::Now().LocalExplode(&the_time);
- std::string filename(StringPrintf("%s%04d%02d%02d%02d%02d%02d%s",
- kSnapshotBaseName, the_time.year, the_time.month, the_time.day_of_month,
- the_time.hour, the_time.minute, the_time.second, kSnapshotExtension));
-
- FilePath snapshot_file = snapshot_directory.AppendASCII(filename);
- if (file_util::PathExists(snapshot_file)) {
- int index = 0;
- std::string suffix;
- FilePath trial_file;
- do {
- suffix = StringPrintf(" (%d)", ++index);
- trial_file = snapshot_file.InsertBeforeExtensionASCII(suffix);
- } while (file_util::PathExists(trial_file));
- snapshot_file = trial_file;
- }
- return snapshot_file;
-}
-
-} // namespace
-
-void HideNativeWindow(gfx::NativeWindow window) {
-#if defined(USE_AURA)
- if (chrome::GetHostDesktopTypeForNativeWindow(window) ==
- chrome::HOST_DESKTOP_TYPE_ASH) {
- HideNativeWindowAura(window);
- return;
- }
- HWND hwnd = window->GetRootWindow()->GetAcceleratedWidget();
-#else
- HWND hwnd = window;
-#endif
- ::ShowWindow(hwnd, SW_HIDE);
-}
-
-bool ShowAndFocusNativeWindow(gfx::NativeWindow window) {
-#if defined(USE_AURA)
- if (chrome::GetHostDesktopTypeForNativeWindow(window) ==
- chrome::HOST_DESKTOP_TYPE_ASH)
- ShowAndFocusNativeWindowAura(window);
- // Always make sure the window hosting ash is visible and focused.
- HWND hwnd = window->GetRootWindow()->GetAcceleratedWidget();
-#else
- HWND hwnd = window;
-#endif
-
- ::ShowWindow(hwnd, SW_SHOW);
-
- if (GetForegroundWindow() != hwnd) {
- VLOG(1) << "Forcefully refocusing front window";
- ui::ForegroundHelper::SetForeground(hwnd);
- }
-
- // ShowWindow does not necessarily activate the window. In particular if a
- // window from another app is the foreground window then the request to
- // activate the window fails. See SetForegroundWindow for details.
- return GetForegroundWindow() == hwnd;
-}
-
-bool SaveScreenSnapshotToDirectory(const FilePath& directory,
- FilePath* screenshot_path) {
- bool succeeded = false;
- FilePath out_path(GetSnapshotFileName(directory));
-
- MONITORINFO monitor_info = {};
- monitor_info.cbSize = sizeof(monitor_info);
- HMONITOR main_monitor = MonitorFromWindow(NULL, MONITOR_DEFAULTTOPRIMARY);
- if (GetMonitorInfo(main_monitor, &monitor_info)) {
- RECT& rect = monitor_info.rcMonitor;
-
- std::vector<unsigned char> png_data;
- gfx::Rect bounds(
- gfx::Size(rect.right - rect.left, rect.bottom - rect.top));
- if (chrome::internal::GrabWindowSnapshot(NULL, &png_data, bounds) &&
- png_data.size() <= INT_MAX) {
- int bytes = static_cast<int>(png_data.size());
- int written = file_util::WriteFile(
- out_path, reinterpret_cast<char*>(&png_data[0]), bytes);
- succeeded = (written == bytes);
- }
- }
-
- if (succeeded && screenshot_path != NULL)
- *screenshot_path = out_path;
-
- return succeeded;
-}
-
-bool SaveScreenSnapshotToDesktop(FilePath* screenshot_path) {
- FilePath desktop;
-
- return PathService::Get(base::DIR_USER_DESKTOP, &desktop) &&
- SaveScreenSnapshotToDirectory(desktop, screenshot_path);
-}
-
-} // namespace ui_test_utils
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index 37d2417..f2dcffa 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -213,6 +213,14 @@
'browser/ui/views/tabs/tab_drag_controller_interactive_uitest.h',
'browser/ui/views/tabs/tab_drag_controller_interactive_uitest_win.cc',
'test/base/chrome_test_launcher.cc',
+ 'test/base/interactive_test_utils.cc',
+ 'test/base/interactive_test_utils.h',
+ 'test/base/interactive_test_utils_aura.cc',
+ 'test/base/interactive_test_utils_aura.h',
+ 'test/base/interactive_test_utils_gtk.cc',
+ 'test/base/interactive_test_utils_mac.mm',
+ 'test/base/interactive_test_utils_views.cc',
+ 'test/base/interactive_test_utils_win.cc',
'test/base/view_event_test_base.cc',
'test/base/view_event_test_base.h',
'test/ppapi/ppapi_interactive_browsertest.cc',
@@ -296,6 +304,7 @@
'browser/chromeos/cros/cros_in_process_browser_test.h',
'browser/chromeos/cros/cros_mock.cc',
'browser/chromeos/cros/cros_mock.h',
+ 'browser/chromeos/login/login_browsertest.cc',
'browser/chromeos/login/mock_authenticator.cc',
'browser/chromeos/login/mock_authenticator.h',
'browser/chromeos/login/screen_locker_browsertest.cc',
@@ -810,7 +819,6 @@
'browser/chromeos/login/enrollment/mock_enterprise_enrollment_screen.cc',
'browser/chromeos/login/enrollment/mock_enterprise_enrollment_screen.h',
'browser/chromeos/login/existing_user_controller_browsertest.cc',
- 'browser/chromeos/login/login_browsertest.cc',
'browser/chromeos/login/login_utils_browsertest.cc',
'browser/chromeos/login/mock_authenticator.cc',
'browser/chromeos/login/mock_authenticator.h',
diff --git a/chrome/chrome_tests_unit.gypi b/chrome/chrome_tests_unit.gypi
index ba7ed80..ef9606c 100644
--- a/chrome/chrome_tests_unit.gypi
+++ b/chrome/chrome_tests_unit.gypi
@@ -165,19 +165,13 @@
'browser/ui/cocoa/find_bar/find_bar_host_unittest_util_cocoa.mm',
'browser/ui/cocoa/run_loop_testing.h',
'browser/ui/cocoa/run_loop_testing.mm',
- 'browser/ui/cocoa/test/ui_test_utils_mac.mm',
'browser/ui/find_bar/find_bar_host_unittest_util.h',
'browser/ui/fullscreen/fullscreen_controller_state_test.cc',
'browser/ui/fullscreen/fullscreen_controller_state_test.h',
'browser/ui/fullscreen/fullscreen_controller_test.cc',
'browser/ui/fullscreen/fullscreen_controller_test.h',
'browser/ui/gtk/find_bar_host_unittest_util_gtk.cc',
- 'browser/ui/gtk/test/ui_test_utils_gtk.cc',
'browser/ui/views/find_bar_host_unittest_util_views.cc',
- 'browser/ui/views/test/ui_test_utils_aura.cc',
- 'browser/ui/views/test/ui_test_utils_aura.h',
- 'browser/ui/views/test/ui_test_utils_views.cc',
- 'browser/ui/views/test/ui_test_utils_win.cc',
'common/extensions/extension_builder.cc',
'common/extensions/extension_builder.h',
'common/extensions/extension_test_util.cc',
diff --git a/chrome/test/base/interactive_test_utils.cc b/chrome/test/base/interactive_test_utils.cc
new file mode 100644
index 0000000..8029ab6
--- /dev/null
+++ b/chrome/test/base/interactive_test_utils.cc
@@ -0,0 +1,105 @@
+// Copyright (c) 2012 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 "chrome/test/base/interactive_test_utils.h"
+
+#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_window.h"
+
+namespace ui_test_utils {
+
+namespace {
+
+bool GetNativeWindow(const Browser* browser, gfx::NativeWindow* native_window) {
+ BrowserWindow* window = browser->window();
+ if (!window)
+ return false;
+
+ *native_window = window->GetNativeWindow();
+ return *native_window;
+}
+
+} // namespace
+
+bool BringBrowserWindowToFront(const Browser* browser) {
+ gfx::NativeWindow window = NULL;
+ if (!GetNativeWindow(browser, &window))
+ return false;
+
+ return ui_test_utils::ShowAndFocusNativeWindow(window);
+}
+
+bool SendKeyPressSync(const Browser* browser,
+ ui::KeyboardCode key,
+ bool control,
+ bool shift,
+ bool alt,
+ bool command) {
+ gfx::NativeWindow window = NULL;
+ if (!GetNativeWindow(browser, &window))
+ return false;
+ scoped_refptr<content::MessageLoopRunner> runner =
+ new content::MessageLoopRunner;
+ bool result;
+ result = ui_controls::SendKeyPressNotifyWhenDone(
+ window, key, control, shift, alt, command, runner->QuitClosure());
+#if defined(OS_WIN)
+ if (!result && BringBrowserWindowToFront(browser)) {
+ result = ui_controls::SendKeyPressNotifyWhenDone(
+ window, key, control, shift, alt, command, runner->QuitClosure());
+ }
+#endif
+ if (!result) {
+ LOG(ERROR) << "ui_controls::SendKeyPressNotifyWhenDone failed";
+ return false;
+ }
+
+ // Run the message loop. It'll stop running when either the key was received
+ // or the test timed out (in which case testing::Test::HasFatalFailure should
+ // be set).
+ runner->Run();
+ return !testing::Test::HasFatalFailure();
+}
+
+bool SendKeyPressAndWait(const Browser* browser,
+ ui::KeyboardCode key,
+ bool control,
+ bool shift,
+ bool alt,
+ bool command,
+ int type,
+ const content::NotificationSource& source) {
+ content::WindowedNotificationObserver observer(type, source);
+
+ if (!SendKeyPressSync(browser, key, control, shift, alt, command))
+ return false;
+
+ observer.Wait();
+ return !testing::Test::HasFatalFailure();
+}
+
+bool SendMouseMoveSync(const gfx::Point& location) {
+ scoped_refptr<content::MessageLoopRunner> runner =
+ new content::MessageLoopRunner;
+ if (!ui_controls::SendMouseMoveNotifyWhenDone(
+ location.x(), location.y(), runner->QuitClosure())) {
+ return false;
+ }
+ runner->Run();
+ return !testing::Test::HasFatalFailure();
+}
+
+bool SendMouseEventsSync(ui_controls::MouseButton type, int state) {
+ scoped_refptr<content::MessageLoopRunner> runner =
+ new content::MessageLoopRunner;
+ if (!ui_controls::SendMouseEventsNotifyWhenDone(
+ type, state, runner->QuitClosure())) {
+ return false;
+ }
+ runner->Run();
+ return !testing::Test::HasFatalFailure();
+}
+
+
+} // namespace ui_test_utils
diff --git a/chrome/test/base/interactive_test_utils.h b/chrome/test/base/interactive_test_utils.h
new file mode 100644
index 0000000..afe3e58
--- /dev/null
+++ b/chrome/test/base/interactive_test_utils.h
@@ -0,0 +1,140 @@
+// Copyright (c) 2012 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.
+
+#ifndef CHROME_TEST_BASE_INTERACTIVE_TEST_UTILS_H_
+#define CHROME_TEST_BASE_INTERACTIVE_TEST_UTILS_H_
+
+#include "chrome/browser/ui/view_ids.h"
+#include "chrome/test/base/ui_test_utils.h"
+#include "ui/ui_controls/ui_controls.h"
+
+#if defined(TOOLKIT_VIEWS)
+#include "ui/views/view.h"
+#endif
+
+namespace gfx {
+class Point;
+}
+
+namespace ui_test_utils {
+
+// Brings the native window for |browser| to the foreground. Returns true on
+// success.
+bool BringBrowserWindowToFront(const Browser* browser) WARN_UNUSED_RESULT;
+
+// Returns true if the View is focused.
+bool IsViewFocused(const Browser* browser, ViewID vid);
+
+// Simulates a mouse click on a View in the browser.
+void ClickOnView(const Browser* browser, ViewID vid);
+
+// A collection of utilities that are used from interactive_ui_tests. These are
+// separated from ui_test_utils.h to ensure that browser_tests don't use them,
+// since they depend on focus which isn't possible for sharded test.
+
+// Hide a native window.
+void HideNativeWindow(gfx::NativeWindow window);
+
+// Show and focus a native window. Returns true on success.
+bool ShowAndFocusNativeWindow(gfx::NativeWindow window) WARN_UNUSED_RESULT;
+
+// Sends a key press, blocking until the key press is received or the test times
+// out. This uses ui_controls::SendKeyPress, see it for details. Returns true
+// if the event was successfully sent and received.
+bool SendKeyPressSync(const Browser* browser,
+ ui::KeyboardCode key,
+ bool control,
+ bool shift,
+ bool alt,
+ bool command) WARN_UNUSED_RESULT;
+
+// Sends a key press, blocking until both the key press and a notification from
+// |source| of type |type| are received, or until the test times out. This uses
+// ui_controls::SendKeyPress, see it for details. Returns true if the event was
+// successfully sent and both the event and notification were received.
+bool SendKeyPressAndWait(const Browser* browser,
+ ui::KeyboardCode key,
+ bool control,
+ bool shift,
+ bool alt,
+ bool command,
+ int type,
+ const content::NotificationSource& source)
+ WARN_UNUSED_RESULT;
+
+// Sends a move event blocking until received. Returns true if the event was
+// successfully received. This uses ui_controls::SendMouse***NotifyWhenDone,
+// see it for details.
+bool SendMouseMoveSync(const gfx::Point& location) WARN_UNUSED_RESULT;
+bool SendMouseEventsSync(ui_controls::MouseButton type,
+ int state) WARN_UNUSED_RESULT;
+
+// See SendKeyPressAndWait. This function additionally performs a check on the
+// NotificationDetails using the provided Details<U>.
+template <class U>
+bool SendKeyPressAndWaitWithDetails(
+ const Browser* browser,
+ ui::KeyboardCode key,
+ bool control,
+ bool shift,
+ bool alt,
+ bool command,
+ int type,
+ const content::NotificationSource& source,
+ const content::Details<U>& details) WARN_UNUSED_RESULT;
+
+template <class U>
+bool SendKeyPressAndWaitWithDetails(
+ const Browser* browser,
+ ui::KeyboardCode key,
+ bool control,
+ bool shift,
+ bool alt,
+ bool command,
+ int type,
+ const content::NotificationSource& source,
+ const content::Details<U>& details) {
+ WindowedNotificationObserverWithDetails<U> observer(type, source);
+
+ if (!SendKeyPressSync(browser, key, control, shift, alt, command))
+ return false;
+
+ observer.Wait();
+
+ U my_details;
+ if (!observer.GetDetailsFor(source.map_key(), &my_details))
+ return false;
+
+ return *details.ptr() == my_details && !testing::Test::HasFatalFailure();
+}
+
+// A combination of SendMouseMove to the middle of the view followed by
+// SendMouseEvents.
+void MoveMouseToCenterAndPress(
+#if defined(TOOLKIT_VIEWS)
+ views::View* view,
+#elif defined(TOOLKIT_GTK)
+ GtkWidget* widget,
+#elif defined(OS_IOS)
+ UIView* view,
+#elif defined(OS_MACOSX)
+ NSView* view,
+#endif
+ ui_controls::MouseButton button,
+ int state,
+ const base::Closure& task);
+
+namespace internal {
+
+// A utility function to send a mouse click event in a closure. It's shared by
+// ui_controls_linux.cc and ui_controls_mac.cc
+void ClickTask(ui_controls::MouseButton button,
+ int state,
+ const base::Closure& followup);
+
+} // namespace internal
+
+} // namespace ui_test_utils
+
+#endif // CHROME_TEST_BASE_INTERACTIVE_TEST_UTILS_H_
diff --git a/chrome/browser/ui/views/test/ui_test_utils_aura.cc b/chrome/test/base/interactive_test_utils_aura.cc
index 2ee95b6..b780b83 100644
--- a/chrome/browser/ui/views/test/ui_test_utils_aura.cc
+++ b/chrome/test/base/interactive_test_utils_aura.cc
@@ -2,9 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/ui/views/test/ui_test_utils_aura.h"
+#include "chrome/test/base/interactive_test_utils_aura.h"
-#include "chrome/test/base/ui_test_utils.h"
+#include "chrome/test/base/interactive_test_utils.h"
#include "ui/aura/window.h"
namespace ui_test_utils {
diff --git a/chrome/browser/ui/views/test/ui_test_utils_aura.h b/chrome/test/base/interactive_test_utils_aura.h
index 6795434..e157a56 100644
--- a/chrome/browser/ui/views/test/ui_test_utils_aura.h
+++ b/chrome/test/base/interactive_test_utils_aura.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_UI_VIEWS_TEST_UI_TEST_UTILS_AURA_H_
-#define CHROME_BROWSER_UI_VIEWS_TEST_UI_TEST_UTILS_AURA_H_
+#ifndef CHROME_TEST_BASE_INTERACTIVE_TEST_UTILS_AURA_H_
+#define CHROME_TEST_BASE_INTERACTIVE_TEST_UTILS_AURA_H_
#include "chrome/test/base/ui_test_utils.h"
@@ -18,4 +18,4 @@ bool ShowAndFocusNativeWindowAura(gfx::NativeWindow window);
} // namespace ui_test_utils
-#endif // CHROME_BROWSER_UI_VIEWS_TEST_UI_TEST_UTILS_AURA_H_
+#endif // CHROME_TEST_BASE_INTERACTIVE_TEST_UTILS_AURA_H_
diff --git a/chrome/browser/ui/gtk/test/ui_test_utils_gtk.cc b/chrome/test/base/interactive_test_utils_gtk.cc
index d493447..0bda39c 100644
--- a/chrome/browser/ui/gtk/test/ui_test_utils_gtk.cc
+++ b/chrome/test/base/interactive_test_utils_gtk.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/test/base/ui_test_utils.h"
+#include "chrome/test/base/interactive_test_utils.h"
#include <gtk/gtk.h>
diff --git a/chrome/browser/ui/cocoa/test/ui_test_utils_mac.mm b/chrome/test/base/interactive_test_utils_mac.mm
index 706fbd2..ee2a930 100644
--- a/chrome/browser/ui/cocoa/test/ui_test_utils_mac.mm
+++ b/chrome/test/base/interactive_test_utils_mac.mm
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/test/base/ui_test_utils.h"
+#include "chrome/test/base/interactive_test_utils.h"
#include <Carbon/Carbon.h>
#import <Cocoa/Cocoa.h>
diff --git a/chrome/browser/ui/views/test/ui_test_utils_views.cc b/chrome/test/base/interactive_test_utils_views.cc
index c899594..6f41223 100644
--- a/chrome/browser/ui/views/test/ui_test_utils_views.cc
+++ b/chrome/test/base/interactive_test_utils_views.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/test/base/ui_test_utils.h"
+#include "chrome/test/base/interactive_test_utils.h"
#include "base/logging.h"
#include "base/message_loop.h"
diff --git a/chrome/test/base/interactive_test_utils_win.cc b/chrome/test/base/interactive_test_utils_win.cc
new file mode 100644
index 0000000..8215864
--- /dev/null
+++ b/chrome/test/base/interactive_test_utils_win.cc
@@ -0,0 +1,64 @@
+// Copyright (c) 2012 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 "chrome/test/base/interactive_test_utils.h"
+
+#include "base/file_path.h"
+#include "base/file_util.h"
+#include "base/logging.h"
+#include "base/path_service.h"
+#include "base/stringprintf.h"
+#include "base/time.h"
+#include "chrome/browser/ui/window_snapshot/window_snapshot.h"
+#include "ui/base/win/foreground_helper.h"
+#include "ui/ui_controls/ui_controls.h"
+#include "ui/views/focus/focus_manager.h"
+
+#if defined(USE_AURA)
+#include "chrome/browser/ui/host_desktop.h"
+#include "chrome/test/base/interactive_test_utils_aura.h"
+#include "ui/aura/root_window.h"
+#endif
+
+namespace ui_test_utils {
+
+void HideNativeWindow(gfx::NativeWindow window) {
+#if defined(USE_AURA)
+ if (chrome::GetHostDesktopTypeForNativeWindow(window) ==
+ chrome::HOST_DESKTOP_TYPE_ASH) {
+ HideNativeWindowAura(window);
+ return;
+ }
+ HWND hwnd = window->GetRootWindow()->GetAcceleratedWidget();
+#else
+ HWND hwnd = window;
+#endif
+ ::ShowWindow(hwnd, SW_HIDE);
+}
+
+bool ShowAndFocusNativeWindow(gfx::NativeWindow window) {
+#if defined(USE_AURA)
+ if (chrome::GetHostDesktopTypeForNativeWindow(window) ==
+ chrome::HOST_DESKTOP_TYPE_ASH)
+ ShowAndFocusNativeWindowAura(window);
+ // Always make sure the window hosting ash is visible and focused.
+ HWND hwnd = window->GetRootWindow()->GetAcceleratedWidget();
+#else
+ HWND hwnd = window;
+#endif
+
+ ::ShowWindow(hwnd, SW_SHOW);
+
+ if (GetForegroundWindow() != hwnd) {
+ VLOG(1) << "Forcefully refocusing front window";
+ ui::ForegroundHelper::SetForeground(hwnd);
+ }
+
+ // ShowWindow does not necessarily activate the window. In particular if a
+ // window from another app is the foreground window then the request to
+ // activate the window fails. See SetForegroundWindow for details.
+ return GetForegroundWindow() == hwnd;
+}
+
+} // namespace ui_test_utils
diff --git a/chrome/test/base/ui_test_utils.cc b/chrome/test/base/ui_test_utils.cc
index 2d9abdb..d2d6d530 100644
--- a/chrome/test/base/ui_test_utils.cc
+++ b/chrome/test/base/ui_test_utils.cc
@@ -45,6 +45,7 @@
#include "chrome/browser/ui/host_desktop.h"
#include "chrome/browser/ui/omnibox/location_bar.h"
#include "chrome/browser/ui/omnibox/omnibox_view.h"
+#include "chrome/browser/ui/window_snapshot/window_snapshot.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/pref_names.h"
@@ -150,6 +151,31 @@ class FindInPageNotificationObserver : public content::NotificationObserver {
DISALLOW_COPY_AND_ASSIGN(FindInPageNotificationObserver);
};
+const char kSnapshotBaseName[] = "ChromiumSnapshot";
+const char kSnapshotExtension[] = ".png";
+
+FilePath GetSnapshotFileName(const FilePath& snapshot_directory) {
+ base::Time::Exploded the_time;
+
+ base::Time::Now().LocalExplode(&the_time);
+ std::string filename(StringPrintf("%s%04d%02d%02d%02d%02d%02d%s",
+ kSnapshotBaseName, the_time.year, the_time.month, the_time.day_of_month,
+ the_time.hour, the_time.minute, the_time.second, kSnapshotExtension));
+
+ FilePath snapshot_file = snapshot_directory.AppendASCII(filename);
+ if (file_util::PathExists(snapshot_file)) {
+ int index = 0;
+ std::string suffix;
+ FilePath trial_file;
+ do {
+ suffix = StringPrintf(" (%d)", ++index);
+ trial_file = snapshot_file.InsertBeforeExtensionASCII(suffix);
+ } while (file_util::PathExists(trial_file));
+ snapshot_file = trial_file;
+ }
+ return snapshot_file;
+}
+
} // namespace
bool GetCurrentTabTitle(const Browser* browser, string16* title) {
@@ -453,23 +479,6 @@ void SendToOmniboxAndSubmit(LocationBar* location_bar,
}
}
-bool GetNativeWindow(const Browser* browser, gfx::NativeWindow* native_window) {
- BrowserWindow* window = browser->window();
- if (!window)
- return false;
-
- *native_window = window->GetNativeWindow();
- return *native_window;
-}
-
-bool BringBrowserWindowToFront(const Browser* browser) {
- gfx::NativeWindow window = NULL;
- if (!GetNativeWindow(browser, &window))
- return false;
-
- return ui_test_utils::ShowAndFocusNativeWindow(window);
-}
-
Browser* GetBrowserNotInSet(std::set<Browser*> excluded_browsers) {
for (BrowserList::const_iterator iter = BrowserList::begin();
iter != BrowserList::end();
@@ -481,77 +490,6 @@ Browser* GetBrowserNotInSet(std::set<Browser*> excluded_browsers) {
return NULL;
}
-bool SendKeyPressSync(const Browser* browser,
- ui::KeyboardCode key,
- bool control,
- bool shift,
- bool alt,
- bool command) {
- gfx::NativeWindow window = NULL;
- if (!GetNativeWindow(browser, &window))
- return false;
- scoped_refptr<content::MessageLoopRunner> runner =
- new content::MessageLoopRunner;
- bool result;
- result = ui_controls::SendKeyPressNotifyWhenDone(
- window, key, control, shift, alt, command, runner->QuitClosure());
-#if defined(OS_WIN)
- if (!result && BringBrowserWindowToFront(browser)) {
- result = ui_controls::SendKeyPressNotifyWhenDone(
- window, key, control, shift, alt, command, runner->QuitClosure());
- }
-#endif
- if (!result) {
- LOG(ERROR) << "ui_controls::SendKeyPressNotifyWhenDone failed";
- return false;
- }
-
- // Run the message loop. It'll stop running when either the key was received
- // or the test timed out (in which case testing::Test::HasFatalFailure should
- // be set).
- runner->Run();
- return !testing::Test::HasFatalFailure();
-}
-
-bool SendKeyPressAndWait(const Browser* browser,
- ui::KeyboardCode key,
- bool control,
- bool shift,
- bool alt,
- bool command,
- int type,
- const content::NotificationSource& source) {
- content::WindowedNotificationObserver observer(type, source);
-
- if (!SendKeyPressSync(browser, key, control, shift, alt, command))
- return false;
-
- observer.Wait();
- return !testing::Test::HasFatalFailure();
-}
-
-bool SendMouseMoveSync(const gfx::Point& location) {
- scoped_refptr<content::MessageLoopRunner> runner =
- new content::MessageLoopRunner;
- if (!ui_controls::SendMouseMoveNotifyWhenDone(
- location.x(), location.y(), runner->QuitClosure())) {
- return false;
- }
- runner->Run();
- return !testing::Test::HasFatalFailure();
-}
-
-bool SendMouseEventsSync(ui_controls::MouseButton type, int state) {
- scoped_refptr<content::MessageLoopRunner> runner =
- new content::MessageLoopRunner;
- if (!ui_controls::SendMouseEventsNotifyWhenDone(
- type, state, runner->QuitClosure())) {
- return false;
- }
- runner->Run();
- return !testing::Test::HasFatalFailure();
-}
-
WindowedTabAddedNotificationObserver::WindowedTabAddedNotificationObserver(
const content::NotificationSource& source)
: WindowedNotificationObserver(chrome::NOTIFICATION_TAB_ADDED, source),
@@ -680,6 +618,46 @@ bool TakeEntirePageSnapshot(RenderViewHost* rvh, SkBitmap* bitmap) {
return taker.TakeEntirePageSnapshot(rvh, bitmap);
}
+#if defined(OS_WIN)
+
+bool SaveScreenSnapshotToDirectory(const FilePath& directory,
+ FilePath* screenshot_path) {
+ bool succeeded = false;
+ FilePath out_path(GetSnapshotFileName(directory));
+
+ MONITORINFO monitor_info = {};
+ monitor_info.cbSize = sizeof(monitor_info);
+ HMONITOR main_monitor = MonitorFromWindow(NULL, MONITOR_DEFAULTTOPRIMARY);
+ if (GetMonitorInfo(main_monitor, &monitor_info)) {
+ RECT& rect = monitor_info.rcMonitor;
+
+ std::vector<unsigned char> png_data;
+ gfx::Rect bounds(
+ gfx::Size(rect.right - rect.left, rect.bottom - rect.top));
+ if (chrome::internal::GrabWindowSnapshot(NULL, &png_data, bounds) &&
+ png_data.size() <= INT_MAX) {
+ int bytes = static_cast<int>(png_data.size());
+ int written = file_util::WriteFile(
+ out_path, reinterpret_cast<char*>(&png_data[0]), bytes);
+ succeeded = (written == bytes);
+ }
+ }
+
+ if (succeeded && screenshot_path != NULL)
+ *screenshot_path = out_path;
+
+ return succeeded;
+}
+
+bool SaveScreenSnapshotToDesktop(FilePath* screenshot_path) {
+ FilePath desktop;
+
+ return PathService::Get(base::DIR_USER_DESKTOP, &desktop) &&
+ SaveScreenSnapshotToDirectory(desktop, screenshot_path);
+}
+
+#endif // defined(OS_WIN)
+
void OverrideGeolocation(double latitude, double longitude) {
content::Geoposition position;
position.latitude = latitude;
diff --git a/chrome/test/base/ui_test_utils.h b/chrome/test/base/ui_test_utils.h
index 5a98a39..e08ed7d 100644
--- a/chrome/test/base/ui_test_utils.h
+++ b/chrome/test/base/ui_test_utils.h
@@ -15,7 +15,6 @@
#include "base/memory/ref_counted.h"
#include "base/string16.h"
#include "chrome/browser/history/history.h"
-#include "chrome/browser/ui/view_ids.h"
#include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
@@ -25,13 +24,8 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/keycodes/keyboard_codes.h"
#include "ui/gfx/native_widget_types.h"
-#include "ui/ui_controls/ui_controls.h"
#include "webkit/glue/window_open_disposition.h"
-#if defined(TOOLKIT_VIEWS)
-#include "ui/views/view.h"
-#endif
-
class AppModalDialog;
class BookmarkModel;
class Browser;
@@ -53,7 +47,6 @@ class WebContents;
}
namespace gfx {
-class Point;
class Rect;
class Size;
}
@@ -144,12 +137,6 @@ int FindInPage(content::WebContents* tab,
int* ordinal,
gfx::Rect* selection_rect);
-// Returns true if the View is focused.
-bool IsViewFocused(const Browser* browser, ViewID vid);
-
-// Simulates a mouse click on a View in the browser.
-void ClickOnView(const Browser* browser, ViewID vid);
-
// Register |observer| for the given |type| and |source| and run
// the message loop until the observer posts a quit task.
void RegisterAndWait(content::NotificationObserver* observer,
@@ -172,44 +159,9 @@ void DownloadURL(Browser* browser, const GURL& download_url);
void SendToOmniboxAndSubmit(LocationBar* location_bar,
const std::string& input);
-// Brings the native window for |browser| to the foreground. Returns true on
-// success.
-bool BringBrowserWindowToFront(const Browser* browser) WARN_UNUSED_RESULT;
-
// Gets the first browser that is not in the specified set.
Browser* GetBrowserNotInSet(std::set<Browser*> excluded_browsers);
-// Sends a key press, blocking until the key press is received or the test times
-// out. This uses ui_controls::SendKeyPress, see it for details. Returns true
-// if the event was successfully sent and received.
-bool SendKeyPressSync(const Browser* browser,
- ui::KeyboardCode key,
- bool control,
- bool shift,
- bool alt,
- bool command) WARN_UNUSED_RESULT;
-
-// Sends a key press, blocking until both the key press and a notification from
-// |source| of type |type| are received, or until the test times out. This uses
-// ui_controls::SendKeyPress, see it for details. Returns true if the event was
-// successfully sent and both the event and notification were received.
-bool SendKeyPressAndWait(const Browser* browser,
- ui::KeyboardCode key,
- bool control,
- bool shift,
- bool alt,
- bool command,
- int type,
- const content::NotificationSource& source)
- WARN_UNUSED_RESULT;
-
-// Sends a move event blocking until received. Returns true if the event was
-// successfully received. This uses ui_controls::SendMouse***NotifyWhenDone,
-// see it for details.
-bool SendMouseMoveSync(const gfx::Point& location) WARN_UNUSED_RESULT;
-bool SendMouseEventsSync(ui_controls::MouseButton type,
- int state) WARN_UNUSED_RESULT;
-
// A WindowedNotificationObserver hard-wired to observe
// chrome::NOTIFICATION_TAB_ADDED.
class WindowedTabAddedNotificationObserver
@@ -311,51 +263,6 @@ class BrowserAddedObserver {
DISALLOW_COPY_AND_ASSIGN(BrowserAddedObserver);
};
-// See SendKeyPressAndWait. This function additionally performs a check on the
-// NotificationDetails using the provided Details<U>.
-template <class U>
-bool SendKeyPressAndWaitWithDetails(
- const Browser* browser,
- ui::KeyboardCode key,
- bool control,
- bool shift,
- bool alt,
- bool command,
- int type,
- const content::NotificationSource& source,
- const content::Details<U>& details) WARN_UNUSED_RESULT;
-
-template <class U>
-bool SendKeyPressAndWaitWithDetails(
- const Browser* browser,
- ui::KeyboardCode key,
- bool control,
- bool shift,
- bool alt,
- bool command,
- int type,
- const content::NotificationSource& source,
- const content::Details<U>& details) {
- WindowedNotificationObserverWithDetails<U> observer(type, source);
-
- if (!SendKeyPressSync(browser, key, control, shift, alt, command))
- return false;
-
- observer.Wait();
-
- U my_details;
- if (!observer.GetDetailsFor(source.map_key(), &my_details))
- return false;
-
- return *details.ptr() == my_details && !testing::Test::HasFatalFailure();
-}
-
-// Hide a native window.
-void HideNativeWindow(gfx::NativeWindow window);
-
-// Show and focus a native window. Returns true on success.
-bool ShowAndFocusNativeWindow(gfx::NativeWindow window) WARN_UNUSED_RESULT;
-
// Takes a snapshot of the given render widget, rendered at |page_size|. The
// snapshot is set to |bitmap|. Returns true on success.
bool TakeRenderWidgetSnapshot(content::RenderWidgetHost* rwh,
@@ -368,22 +275,6 @@ bool TakeRenderWidgetSnapshot(content::RenderWidgetHost* rwh,
bool TakeEntirePageSnapshot(content::RenderViewHost* rvh,
SkBitmap* bitmap) WARN_UNUSED_RESULT;
-// A combination of SendMouseMove to the middle of the view followed by
-// SendMouseEvents.
-void MoveMouseToCenterAndPress(
-#if defined(TOOLKIT_VIEWS)
- views::View* view,
-#elif defined(TOOLKIT_GTK)
- GtkWidget* widget,
-#elif defined(OS_IOS)
- UIView* view,
-#elif defined(OS_MACOSX)
- NSView* view,
-#endif
- ui_controls::MouseButton button,
- int state,
- const base::Closure& task);
-
#if defined(OS_WIN)
// Saves a snapshot of the entire screen to a file named
// ChromiumSnapshotYYYYMMDDHHMMSS.png to |directory|, returning true on success.
@@ -399,16 +290,6 @@ bool SaveScreenSnapshotToDesktop(FilePath* screenshot_path);
// Configures the geolocation provider to always return the given position.
void OverrideGeolocation(double latitude, double longitude);
-namespace internal {
-
-// A utility function to send a mouse click event in a closure. It's shared by
-// ui_controls_linux.cc and ui_controls_mac.cc
-void ClickTask(ui_controls::MouseButton button,
- int state,
- const base::Closure& followup);
-
-} // namespace internal
-
// Enumerates all history contents on the backend thread. Returns them in
// descending order by time.
class HistoryEnumerator {
diff --git a/chrome/test/gpu/gpu_mapsgl_endurance_browsertest.cc b/chrome/test/gpu/gpu_mapsgl_endurance_browsertest.cc
index 10b4f5d..61dec5b 100644
--- a/chrome/test/gpu/gpu_mapsgl_endurance_browsertest.cc
+++ b/chrome/test/gpu/gpu_mapsgl_endurance_browsertest.cc
@@ -80,7 +80,7 @@ class MapsGLEnduranceTest : public InProcessBrowserTest {
ASSERT_TRUE(tracing::BeginTracing("-test_*"));
#endif
- ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
+ browser()->window()->Activate();
gfx::Rect new_bounds = GetNewTabContainerBounds(tab_container_size);
browser()->window()->SetBounds(new_bounds);
diff --git a/chrome/test/gpu/gpu_pixel_browsertest.cc b/chrome/test/gpu/gpu_pixel_browsertest.cc
index 8121b38..559eb5e 100644
--- a/chrome/test/gpu/gpu_pixel_browsertest.cc
+++ b/chrome/test/gpu/gpu_pixel_browsertest.cc
@@ -167,7 +167,7 @@ class GpuPixelBrowserTest : public InProcessBrowserTest {
ASSERT_TRUE(tracing::BeginTracing("-test_*"));
#endif
- ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
+ browser()->window()->Activate();
content::DOMMessageQueue message_queue;
ui_test_utils::NavigateToURL(browser(), net::FilePathToFileURL(url));