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

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: Remove blank line. 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
« no previous file with comments | « 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..51de32447a512b3424bc32ede3ec623cefee0ae1 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.
@@ -98,13 +102,19 @@ TEST_F(AccessiblePaneViewTest, SimpleSetPaneFocus) {
widget.reset();
}
-// 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);
params_main.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
+ params_main.activatable = Widget::InitParams::ACTIVATABLE_YES;
params_main.bounds = gfx::Rect(0, 0, 20, 20);
widget_main->Init(params_main);
View* root_main = widget_main->GetRootView();
@@ -118,6 +128,7 @@ TEST_F(AccessiblePaneViewTest, SetPaneFocusAndRestore) {
scoped_ptr<Widget> widget_bar(new Widget());
Widget::InitParams params_bar = CreateParams(Widget::InitParams::TYPE_POPUP);
params_bar.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
+ params_bar.activatable = Widget::InitParams::ACTIVATABLE_YES;
params_bar.bounds = gfx::Rect(50, 50, 650, 650);
widget_bar->Init(params_bar);
View* root_bar = widget_bar->GetRootView();
@@ -133,9 +144,15 @@ TEST_F(AccessiblePaneViewTest, SetPaneFocusAndRestore) {
EXPECT_EQ(test_view_bar->child_button(),
test_view_bar->GetWidget()->GetFocusManager()->GetFocusedView());
+ // Deactivate() is only reliable on Ash. On Windows it uses ::GetNextWindow
tapted 2015/08/06 06:49:12 nit: ::GetNextWindow()
jackhou1 2015/08/06 07:35:02 Done.
+ // simply activates another window, and which one is not predictable. On Mac,
tapted 2015/08/06 06:49:12 simply activates -> to simply activate
jackhou1 2015/08/06 07:35:02 Done.
+ // Deactivate() is not implemented.
tapted 2015/08/06 06:49:12 Add: Note that TestBarView calls set_allow_deacti
jackhou1 2015/08/06 07:35:02 Done.
+#if !defined(OS_MACOSX) || defined(USE_ASH)
+ // Esc should deactivate the widget.
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();
« no previous file with comments | « ui/base/ui_base.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698