Commit aa24df1c authored by Evan Stade's avatar Evan Stade Committed by Commit Bot

Fix a couple bookmark interactive_ui_tests for desktop Linux Aura.

Bug: 163931
Change-Id: Ia6be534c8dd82207d91a584be7a49e42545102dc
Reviewed-on: https://chromium-review.googlesource.com/c/1334841
Commit-Queue: Evan Stade <estade@chromium.org>
Reviewed-by: default avatarMichael Wasserman <msw@chromium.org>
Cr-Commit-Position: refs/heads/master@{#608191}
parent 84cf92ec
...@@ -47,6 +47,7 @@ ...@@ -47,6 +47,7 @@
#include "ui/aura/env_observer.h" #include "ui/aura/env_observer.h"
#include "ui/aura/window.h" #include "ui/aura/window.h"
#include "ui/base/clipboard/clipboard.h" #include "ui/base/clipboard/clipboard.h"
#include "ui/base/test/test_clipboard.h"
#include "ui/base/test/ui_controls.h" #include "ui/base/test/ui_controls.h"
#include "ui/events/keycodes/keyboard_codes.h" #include "ui/events/keycodes/keyboard_codes.h"
#include "ui/views/background.h" #include "ui/views/background.h"
...@@ -103,9 +104,9 @@ class DialogWaiter : public aura::EnvObserver, ...@@ -103,9 +104,9 @@ class DialogWaiter : public aura::EnvObserver,
} }
// views::WidgetObserver: // views::WidgetObserver:
void OnWidgetVisibilityChanged(views::Widget* widget, bool visible) override { void OnWidgetActivationChanged(views::Widget* widget, bool active) override {
CHECK_EQ(dialog_, widget); CHECK_EQ(dialog_, widget);
if (visible) { if (active) {
dialog_created_ = true; dialog_created_ = true;
dialog_->RemoveObserver(this); dialog_->RemoveObserver(this);
if (!quit_closure_.is_null()) if (!quit_closure_.is_null())
...@@ -162,11 +163,11 @@ class TabKeyWaiter : public ui::EventHandler { ...@@ -162,11 +163,11 @@ class TabKeyWaiter : public ui::EventHandler {
explicit TabKeyWaiter(views::Widget* widget) explicit TabKeyWaiter(views::Widget* widget)
: widget_(widget), : widget_(widget),
received_tab_(false) { received_tab_(false) {
widget_->GetNativeView()->AddPreTargetHandler(this); widget_->GetNativeWindow()->AddPreTargetHandler(this);
} }
~TabKeyWaiter() override { ~TabKeyWaiter() override {
widget_->GetNativeView()->RemovePreTargetHandler(this); widget_->GetNativeWindow()->RemovePreTargetHandler(this);
} }
void WaitForTab() { void WaitForTab() {
...@@ -315,6 +316,15 @@ class BookmarkBarViewEventTestBase : public ViewEventTestBase { ...@@ -315,6 +316,15 @@ class BookmarkBarViewEventTestBase : public ViewEventTestBase {
// state calculated in GetPreferredSizeForContents(). // state calculated in GetPreferredSizeForContents().
EXPECT_TRUE(GetBookmarkButton(5)->visible()); EXPECT_TRUE(GetBookmarkButton(5)->visible());
EXPECT_FALSE(GetBookmarkButton(6)->visible()); EXPECT_FALSE(GetBookmarkButton(6)->visible());
#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
// On desktop Linux, the bookmark bar context menu blocks on retrieving the
// clipboard selection from the X server (for the 'paste' item), so mock it
// out.
ui::Clipboard::SetClipboardForCurrentThread(
std::make_unique<ui::TestClipboard>());
GetWidget()->Activate();
#endif
} }
void TearDown() override { void TearDown() override {
...@@ -490,8 +500,6 @@ class BookmarkBarViewTest2 : public BookmarkBarViewEventTestBase { ...@@ -490,8 +500,6 @@ class BookmarkBarViewTest2 : public BookmarkBarViewEventTestBase {
// NOTE: this code assume there is a left margin, which is currently // NOTE: this code assume there is a left margin, which is currently
// true. If that changes, this code will need to find another empty space // true. If that changes, this code will need to find another empty space
// to press the mouse on. // to press the mouse on.
gfx::Point mouse_loc;
views::View::ConvertPointToScreen(bb_view_.get(), &mouse_loc);
ASSERT_TRUE(ui_controls::SendMouseMoveNotifyWhenDone( ASSERT_TRUE(ui_controls::SendMouseMoveNotifyWhenDone(
0, 0, CreateEventTask(this, &BookmarkBarViewTest2::Step3))); 0, 0, CreateEventTask(this, &BookmarkBarViewTest2::Step3)));
} }
...@@ -520,9 +528,8 @@ class BookmarkBarViewTest2 : public BookmarkBarViewEventTestBase { ...@@ -520,9 +528,8 @@ class BookmarkBarViewTest2 : public BookmarkBarViewEventTestBase {
} }
}; };
#if defined(OS_LINUX) && !defined(OS_CHROMEOS) || defined(OS_WIN) #if defined(OS_WIN)
// TODO(erg): linux_aura bringup: http://crbug.com/163931 // Disable this test on Win10: http://crbug.com/828063
// Disable this test on Win10: http://crbug.com/828063
#define MAYBE_HideOnDesktopClick DISABLED_HideOnDesktopClick #define MAYBE_HideOnDesktopClick DISABLED_HideOnDesktopClick
#else #else
#define MAYBE_HideOnDesktopClick HideOnDesktopClick #define MAYBE_HideOnDesktopClick HideOnDesktopClick
...@@ -1298,6 +1305,8 @@ VIEW_TEST(BookmarkBarViewTest11, CloseMenuAfterClosingContextMenu) ...@@ -1298,6 +1305,8 @@ VIEW_TEST(BookmarkBarViewTest11, CloseMenuAfterClosingContextMenu)
class BookmarkBarViewTest12 : public BookmarkBarViewEventTestBase { class BookmarkBarViewTest12 : public BookmarkBarViewEventTestBase {
protected: protected:
void DoTestOnMessageLoop() override { void DoTestOnMessageLoop() override {
base::RunLoop().RunUntilIdle();
// Open up the other folder. // Open up the other folder.
views::LabelButton* button = bb_view_->other_bookmarks_button(); views::LabelButton* button = bb_view_->other_bookmarks_button();
ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::LEFT, ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::LEFT,
...@@ -1330,7 +1339,9 @@ class BookmarkBarViewTest12 : public BookmarkBarViewEventTestBase { ...@@ -1330,7 +1339,9 @@ class BookmarkBarViewTest12 : public BookmarkBarViewEventTestBase {
void Step3() { void Step3() {
// Make sure the context menu is showing. // Make sure the context menu is showing.
views::MenuItemView* menu = bb_view_->GetContextMenu(); views::MenuItemView* menu = bb_view_->GetContextMenu();
ASSERT_TRUE(menu && menu->GetSubmenu() && menu->GetSubmenu()->IsShowing()); ASSERT_TRUE(menu);
ASSERT_TRUE(menu->GetSubmenu());
ASSERT_TRUE(menu->GetSubmenu()->IsShowing());
// Select the first item in the context menu (open all). // Select the first item in the context menu (open all).
views::MenuItemView* child_menu = views::MenuItemView* child_menu =
...@@ -1338,8 +1349,8 @@ class BookmarkBarViewTest12 : public BookmarkBarViewEventTestBase { ...@@ -1338,8 +1349,8 @@ class BookmarkBarViewTest12 : public BookmarkBarViewEventTestBase {
ASSERT_TRUE(child_menu != NULL); ASSERT_TRUE(child_menu != NULL);
// Click and wait until the dialog box appears. // Click and wait until the dialog box appears.
auto dialog_waiter = std::make_unique<DialogWaiter>( auto dialog_waiter =
bb_view_->GetWidget()->GetNativeWindow()->env()); std::make_unique<DialogWaiter>(GetWidget()->GetNativeWindow()->env());
ui_test_utils::MoveMouseToCenterAndPress( ui_test_utils::MoveMouseToCenterAndPress(
child_menu, ui_controls::LEFT, ui_controls::DOWN | ui_controls::UP, child_menu, ui_controls::LEFT, ui_controls::DOWN | ui_controls::UP,
base::Bind(&BookmarkBarViewTest12::Step4, base::Unretained(this), base::Bind(&BookmarkBarViewTest12::Step4, base::Unretained(this),
...@@ -1354,7 +1365,7 @@ class BookmarkBarViewTest12 : public BookmarkBarViewEventTestBase { ...@@ -1354,7 +1365,7 @@ class BookmarkBarViewTest12 : public BookmarkBarViewEventTestBase {
// receives the tab key. // receives the tab key.
TabKeyWaiter tab_waiter(dialog); TabKeyWaiter tab_waiter(dialog);
ASSERT_TRUE(ui_controls::SendKeyPress( ASSERT_TRUE(ui_controls::SendKeyPress(
window_->GetNativeWindow(), ui::VKEY_TAB, false, false, false, false)); dialog->GetNativeWindow(), ui::VKEY_TAB, false, false, false, false));
tab_waiter.WaitForTab(); tab_waiter.WaitForTab();
// For some reason return isn't processed correctly unless we delay. // For some reason return isn't processed correctly unless we delay.
...@@ -1369,21 +1380,14 @@ class BookmarkBarViewTest12 : public BookmarkBarViewEventTestBase { ...@@ -1369,21 +1380,14 @@ class BookmarkBarViewTest12 : public BookmarkBarViewEventTestBase {
DialogCloseWaiter waiter(dialog); DialogCloseWaiter waiter(dialog);
// And press enter so that the cancel button is selected. // And press enter so that the cancel button is selected.
ASSERT_TRUE(ui_controls::SendKeyPressNotifyWhenDone( ASSERT_TRUE(ui_controls::SendKeyPressNotifyWhenDone(
window_->GetNativeWindow(), ui::VKEY_RETURN, false, false, false, false, dialog->GetNativeWindow(), ui::VKEY_RETURN, false, false, false, false,
base::OnceClosure())); base::OnceClosure()));
waiter.WaitForDialogClose(); waiter.WaitForDialogClose();
Done(); Done();
} }
}; };
#if defined(OS_LINUX) && !defined(OS_CHROMEOS) VIEW_TEST(BookmarkBarViewTest12, CloseWithModalDialog)
// TODO(erg): linux_aura bringup: http://crbug.com/163931
#define MAYBE_CloseWithModalDialog DISABLED_CloseWithModalDialog
#else
#define MAYBE_CloseWithModalDialog CloseWithModalDialog
#endif
VIEW_TEST(BookmarkBarViewTest12, MAYBE_CloseWithModalDialog)
// Tests clicking on the separator of a context menu (this is for coverage of // Tests clicking on the separator of a context menu (this is for coverage of
// bug 17862). // bug 17862).
...@@ -1884,7 +1888,7 @@ class BookmarkBarViewTest20 : public BookmarkBarViewEventTestBase { ...@@ -1884,7 +1888,7 @@ class BookmarkBarViewTest20 : public BookmarkBarViewEventTestBase {
} }
void Step3() { void Step3() {
#if defined(OS_CHROMEOS) #if defined(OS_LINUX)
ASSERT_EQ(test_view_->press_count(), 1); ASSERT_EQ(test_view_->press_count(), 1);
#else #else
ASSERT_EQ(test_view_->press_count(), 2); ASSERT_EQ(test_view_->press_count(), 2);
...@@ -1932,14 +1936,7 @@ class BookmarkBarViewTest20 : public BookmarkBarViewEventTestBase { ...@@ -1932,14 +1936,7 @@ class BookmarkBarViewTest20 : public BookmarkBarViewEventTestBase {
TestViewForMenuExit* test_view_; TestViewForMenuExit* test_view_;
}; };
#if defined(OS_LINUX) && !defined(OS_CHROMEOS) VIEW_TEST(BookmarkBarViewTest20, ContextMenuExitTest)
// TODO(erg): linux_aura bringup: http://crbug.com/163931
#define MAYBE_ContextMenuExitTest DISABLED_ContextMenuExitTest
#else
#define MAYBE_ContextMenuExitTest ContextMenuExitTest
#endif
VIEW_TEST(BookmarkBarViewTest20, MAYBE_ContextMenuExitTest)
// Tests context menu by way of opening a context menu for a empty folder menu. // Tests context menu by way of opening a context menu for a empty folder menu.
// The opened context menu should behave as it is from the folder button. // The opened context menu should behave as it is from the folder button.
...@@ -2144,13 +2141,7 @@ class BookmarkBarViewTest23 : public BookmarkBarViewEventTestBase { ...@@ -2144,13 +2141,7 @@ class BookmarkBarViewTest23 : public BookmarkBarViewEventTestBase {
BookmarkContextMenuNotificationObserver observer_; BookmarkContextMenuNotificationObserver observer_;
}; };
#if defined(USE_OZONE) VIEW_TEST(BookmarkBarViewTest23, ContextMenusKeyboard)
// ozone bringup - http://crbug.com/401304
#define MAYBE_ContextMenusKeyboard DISABLED_ContextMenusKeyboard
#else
#define MAYBE_ContextMenusKeyboard ContextMenusKeyboard
#endif
VIEW_TEST(BookmarkBarViewTest23, MAYBE_ContextMenusKeyboard)
// Test that pressing escape on a menu opened via the keyboard dismisses the // Test that pressing escape on a menu opened via the keyboard dismisses the
// context menu but not the parent menu. // context menu but not the parent menu.
...@@ -2228,13 +2219,7 @@ class BookmarkBarViewTest24 : public BookmarkBarViewEventTestBase { ...@@ -2228,13 +2219,7 @@ class BookmarkBarViewTest24 : public BookmarkBarViewEventTestBase {
BookmarkContextMenuNotificationObserver observer_; BookmarkContextMenuNotificationObserver observer_;
}; };
#if defined(USE_OZONE) VIEW_TEST(BookmarkBarViewTest24, ContextMenusKeyboardEscape)
// ozone bringup - http://crbug.com/401304
#define MAYBE_ContextMenusKeyboardEscape DISABLED_ContextMenusKeyboardEscape
#else
#define MAYBE_ContextMenusKeyboardEscape ContextMenusKeyboardEscape
#endif
VIEW_TEST(BookmarkBarViewTest24, MAYBE_ContextMenusKeyboardEscape)
#if defined(OS_WIN) #if defined(OS_WIN)
// Tests that pressing the key KEYCODE closes the menu. // Tests that pressing the key KEYCODE closes the menu.
......
...@@ -250,12 +250,11 @@ class UIControlsDesktopX11 : public UIControlsAura { ...@@ -250,12 +250,11 @@ class UIControlsDesktopX11 : public UIControlsAura {
DesktopWindowTreeHostX11::GetAllOpenWindows(); DesktopWindowTreeHostX11::GetAllOpenWindows();
for (std::vector<aura::Window*>::const_iterator it = windows.begin(); for (std::vector<aura::Window*>::const_iterator it = windows.begin();
it != windows.end(); ++it) { it != windows.end(); ++it) {
if ((*it)->GetBoundsInScreen().Contains(point)) { if ((*it)->GetBoundsInScreen().Contains(point) || (*it)->HasCapture())
return (*it)->GetRootWindow(); return (*it)->GetRootWindow();
}
} }
NOTREACHED() << "Coulding find RW for " << point.ToString() << " among " NOTREACHED() << "Couldn't find RW for " << point.ToString() << " among "
<< windows.size() << " RWs."; << windows.size() << " RWs.";
return NULL; return NULL;
} }
......
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