Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1361)

Unified Diff: ui/views/accessible_pane_view_unittest.cc

Issue 1268293002: [MacViews] Fix AccessiblePaneViewTest.SetPaneFocusAndRestore. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments. Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« ui/base/test/scoped_fake_nswindow_focus.mm ('K') | « ui/base/ui_base.gyp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/accessible_pane_view_unittest.cc
diff --git a/ui/views/accessible_pane_view_unittest.cc b/ui/views/accessible_pane_view_unittest.cc
index d53fb72f67db1d0e3513b3b11a5633e2f249bce5..f0509b1049032568a838999b2ad61b86d98a4173 100644
--- a/ui/views/accessible_pane_view_unittest.cc
+++ b/ui/views/accessible_pane_view_unittest.cc
@@ -10,6 +10,10 @@
#include "ui/views/test/views_test_base.h"
#include "ui/views/widget/widget.h"
+#if defined(OS_MACOSX)
+#include "ui/base/test/scoped_fake_nswindow_focus.h"
+#endif
+
namespace views {
// TODO(alicet): bring pane rotation into views and add tests.
@@ -101,6 +105,13 @@ TEST_F(AccessiblePaneViewTest, SimpleSetPaneFocus) {
// This test will not work properly in Windows because it uses ::GetNextWindow
// on deactivate which is rather unpredictable where the focus will land.
TEST_F(AccessiblePaneViewTest, SetPaneFocusAndRestore) {
+#if defined(OS_MACOSX)
+ // On Aura platforms, this test creates Ash windows and only interacts with
+ // the Ash window manager. On Mac, it creates native windows, but since unit
+ // tests cannot gain key status, fake it out here.
+ ui::test::ScopedFakeNSWindowFocus fake_focus;
+#endif
+
View* test_view_main = new View();
scoped_ptr<Widget> widget_main(new Widget());
Widget::InitParams params_main = CreateParams(Widget::InitParams::TYPE_POPUP);
@@ -133,9 +144,13 @@ TEST_F(AccessiblePaneViewTest, SetPaneFocusAndRestore) {
EXPECT_EQ(test_view_bar->child_button(),
test_view_bar->GetWidget()->GetFocusManager()->GetFocusedView());
+ // Esc should deactivate the widget.
+ // Widget::Deactivate is not supported on Mac.
+#if !defined(OS_MACOSX)
test_view_bar->AcceleratorPressed(test_view_bar->escape_key());
EXPECT_TRUE(widget_main->IsActive());
EXPECT_FALSE(widget_bar->IsActive());
+#endif
widget_bar->CloseNow();
widget_bar.reset();
« ui/base/test/scoped_fake_nswindow_focus.mm ('K') | « ui/base/ui_base.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698