Commit 6e739e26 authored by Giovanni Ortuño Urquidi's avatar Giovanni Ortuño Urquidi Committed by Commit Bot

bookmark-apps: Fix focus test for popup and app windows

The browser window wasn't active by the time the test tried to focus
it. This caused GetFocusedView() in IsViewFocused() to return nullptr
and cause a seg fault.

Fixes the test by ensuring the browser is brought to the front before
trying to focus it. Also replaces ClickOnView with FocusView since
ClickOnView could end up clicking the window in the back if the popup
wasn't opened yet.

Bug: 846848, 831483
Change-Id: I66b75dc264b6a82896d5ef20b1a44bc937d367e1
Reviewed-on: https://chromium-review.googlesource.com/1077109
Commit-Queue: Giovanni Ortuño Urquidi <ortuno@chromium.org>
Reviewed-by: default avatarTrent Apted <tapted@chromium.org>
Cr-Commit-Position: refs/heads/master@{#562757}
parent 6a609dd2
......@@ -789,15 +789,13 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, NoFocusForBackgroundNTP) {
// Tests that the location bar is focusable when showing, which is the case in
// popup windows.
// Flaky. See http://crbug.com/846848.
IN_PROC_BROWSER_TEST_F(BrowserFocusTest, DISABLED_PopupLocationBar) {
ui_test_utils::BrowserAddedObserver browser_added_observer;
Browser* popup_browser = new Browser(
Browser::CreateParams(Browser::TYPE_POPUP, browser()->profile(), true));
AddBlankTabAndShow(popup_browser);
browser_added_observer.WaitForSingleNewBrowser();
ui_test_utils::ClickOnView(popup_browser, VIEW_ID_TAB_CONTAINER);
IN_PROC_BROWSER_TEST_F(BrowserFocusTest, PopupLocationBar) {
Browser* popup_browser = CreateBrowserForPopup(browser()->profile());
// Make sure the popup is in the front. Otherwise the test is flaky.
ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(popup_browser));
ui_test_utils::FocusView(popup_browser, VIEW_ID_TAB_CONTAINER);
EXPECT_TRUE(
ui_test_utils::IsViewFocused(popup_browser, VIEW_ID_TAB_CONTAINER));
......@@ -821,21 +819,13 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, DISABLED_PopupLocationBar) {
// Tests that the location bar is not focusable when hidden, which is the case
// in app windows.
// Tests that the location bar is focusable when showing, which is the case in
// popup windows.
// The location bar is currently broken in MacViews Browser.
// TODO(crbug.com/831483): Enable test once mac is fixed.
#if defined(OS_MACOSX)
#define MAYBE_AppLocationBar DISABLED_AppLocationBar
#else
#define MAYBE_AppLocationBar AppLocationBar
#endif
IN_PROC_BROWSER_TEST_F(BrowserFocusTest, MAYBE_AppLocationBar) {
ui_test_utils::BrowserAddedObserver browser_added_observer;
IN_PROC_BROWSER_TEST_F(BrowserFocusTest, AppLocationBar) {
Browser* app_browser = CreateBrowserForApp("foo", browser()->profile());
browser_added_observer.WaitForSingleNewBrowser();
ui_test_utils::ClickOnView(app_browser, VIEW_ID_TAB_CONTAINER);
// Make sure the app window is in the front. Otherwise the test is flaky.
ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(app_browser));
ui_test_utils::FocusView(app_browser, VIEW_ID_TAB_CONTAINER);
EXPECT_TRUE(ui_test_utils::IsViewFocused(app_browser, VIEW_ID_TAB_CONTAINER));
ASSERT_TRUE(PressTabAndWait(app_browser,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment