| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/views/accessible_pane_view.h" | 5 #include "ui/views/accessible_pane_view.h" |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 #include "ui/base/accelerators/accelerator.h" | 9 #include "ui/base/accelerators/accelerator.h" |
| 10 #include "ui/views/controls/button/label_button.h" | 10 #include "ui/views/controls/button/label_button.h" |
| 11 #include "ui/views/layout/fill_layout.h" | 11 #include "ui/views/layout/fill_layout.h" |
| 12 #include "ui/views/test/views_test_base.h" | 12 #include "ui/views/test/views_test_base.h" |
| 13 #include "ui/views/widget/widget.h" | 13 #include "ui/views/widget/widget.h" |
| 14 | 14 |
| 15 #if defined(OS_MACOSX) | |
| 16 #include "ui/base/test/scoped_fake_nswindow_focus.h" | |
| 17 #endif | |
| 18 | |
| 19 namespace views { | 15 namespace views { |
| 20 | 16 |
| 21 // TODO(alicet): bring pane rotation into views and add tests. | 17 // TODO(alicet): bring pane rotation into views and add tests. |
| 22 // See browser_view.cc for details. | 18 // See browser_view.cc for details. |
| 23 | 19 |
| 24 typedef ViewsTestBase AccessiblePaneViewTest; | 20 typedef ViewsTestBase AccessiblePaneViewTest; |
| 25 | 21 |
| 26 class TestBarView : public AccessiblePaneView, | 22 class TestBarView : public AccessiblePaneView, |
| 27 public ButtonListener { | 23 public ButtonListener { |
| 28 public: | 24 public: |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 EXPECT_TRUE(test_view->SetPaneFocus(test_view->not_child_button())); | 94 EXPECT_TRUE(test_view->SetPaneFocus(test_view->not_child_button())); |
| 99 EXPECT_FALSE(test_view->not_child_button() == | 95 EXPECT_FALSE(test_view->not_child_button() == |
| 100 test_view->GetWidget()->GetFocusManager()->GetFocusedView()); | 96 test_view->GetWidget()->GetFocusManager()->GetFocusedView()); |
| 101 EXPECT_EQ(test_view->child_button(), | 97 EXPECT_EQ(test_view->child_button(), |
| 102 test_view->GetWidget()->GetFocusManager()->GetFocusedView()); | 98 test_view->GetWidget()->GetFocusManager()->GetFocusedView()); |
| 103 widget->CloseNow(); | 99 widget->CloseNow(); |
| 104 widget.reset(); | 100 widget.reset(); |
| 105 } | 101 } |
| 106 | 102 |
| 107 TEST_F(AccessiblePaneViewTest, SetPaneFocusAndRestore) { | 103 TEST_F(AccessiblePaneViewTest, SetPaneFocusAndRestore) { |
| 108 #if defined(OS_MACOSX) | |
| 109 // On Aura platforms, this test creates Ash windows and only interacts with | |
| 110 // the Ash window manager. On Mac, it creates native windows, but since unit | |
| 111 // tests cannot gain key status, fake it out here. | |
| 112 ui::test::ScopedFakeNSWindowFocus fake_focus; | |
| 113 #endif | |
| 114 | |
| 115 View* test_view_main = new View(); | 104 View* test_view_main = new View(); |
| 116 scoped_ptr<Widget> widget_main(new Widget()); | 105 scoped_ptr<Widget> widget_main(new Widget()); |
| 117 Widget::InitParams params_main = CreateParams(Widget::InitParams::TYPE_POPUP); | 106 Widget::InitParams params_main = CreateParams(Widget::InitParams::TYPE_POPUP); |
| 118 params_main.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 107 params_main.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| 119 // By default, TYPE_POPUP is not activatable. | 108 // By default, TYPE_POPUP is not activatable. |
| 120 params_main.activatable = Widget::InitParams::ACTIVATABLE_YES; | 109 params_main.activatable = Widget::InitParams::ACTIVATABLE_YES; |
| 121 params_main.bounds = gfx::Rect(0, 0, 20, 20); | 110 params_main.bounds = gfx::Rect(0, 0, 20, 20); |
| 122 widget_main->Init(params_main); | 111 widget_main->Init(params_main); |
| 123 View* root_main = widget_main->GetRootView(); | 112 View* root_main = widget_main->GetRootView(); |
| 124 root_main->AddChildView(test_view_main); | 113 root_main->AddChildView(test_view_main); |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 test_view->GetWidget()->GetFocusManager()->GetFocusedView()); | 224 test_view->GetWidget()->GetFocusManager()->GetFocusedView()); |
| 236 | 225 |
| 237 // ESC | 226 // ESC |
| 238 test_view->AcceleratorPressed(test_view->escape_key()); | 227 test_view->AcceleratorPressed(test_view->escape_key()); |
| 239 EXPECT_EQ(original_test_view->third_child_button(), | 228 EXPECT_EQ(original_test_view->third_child_button(), |
| 240 test_view->GetWidget()->GetFocusManager()->GetFocusedView()); | 229 test_view->GetWidget()->GetFocusManager()->GetFocusedView()); |
| 241 widget->CloseNow(); | 230 widget->CloseNow(); |
| 242 widget.reset(); | 231 widget.reset(); |
| 243 } | 232 } |
| 244 } // namespace views | 233 } // namespace views |
| OLD | NEW |