| 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 "ui/base/accelerators/accelerator.h" | 7 #include "ui/base/accelerators/accelerator.h" |
| 8 #include "ui/views/controls/button/label_button.h" | 8 #include "ui/views/controls/button/label_button.h" |
| 9 #include "ui/views/layout/fill_layout.h" | 9 #include "ui/views/layout/fill_layout.h" |
| 10 #include "ui/views/test/views_test_base.h" | 10 #include "ui/views/test/views_test_base.h" |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 EXPECT_FALSE(test_view->not_child_button() == | 94 EXPECT_FALSE(test_view->not_child_button() == |
| 95 test_view->GetWidget()->GetFocusManager()->GetFocusedView()); | 95 test_view->GetWidget()->GetFocusManager()->GetFocusedView()); |
| 96 EXPECT_EQ(test_view->child_button(), | 96 EXPECT_EQ(test_view->child_button(), |
| 97 test_view->GetWidget()->GetFocusManager()->GetFocusedView()); | 97 test_view->GetWidget()->GetFocusManager()->GetFocusedView()); |
| 98 widget->CloseNow(); | 98 widget->CloseNow(); |
| 99 widget.reset(); | 99 widget.reset(); |
| 100 } | 100 } |
| 101 | 101 |
| 102 // This test will not work properly in Windows because it uses ::GetNextWindow | 102 // This test will not work properly in Windows because it uses ::GetNextWindow |
| 103 // on deactivate which is rather unpredictable where the focus will land. | 103 // on deactivate which is rather unpredictable where the focus will land. |
| 104 #if !defined(OS_WIN)||defined(USE_AURA) | |
| 105 TEST_F(AccessiblePaneViewTest, SetPaneFocusAndRestore) { | 104 TEST_F(AccessiblePaneViewTest, SetPaneFocusAndRestore) { |
| 106 View* test_view_main = new View(); | 105 View* test_view_main = new View(); |
| 107 scoped_ptr<Widget> widget_main(new Widget()); | 106 scoped_ptr<Widget> widget_main(new Widget()); |
| 108 Widget::InitParams params_main = CreateParams(Widget::InitParams::TYPE_POPUP); | 107 Widget::InitParams params_main = CreateParams(Widget::InitParams::TYPE_POPUP); |
| 109 params_main.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 108 params_main.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| 110 params_main.bounds = gfx::Rect(0, 0, 20, 20); | 109 params_main.bounds = gfx::Rect(0, 0, 20, 20); |
| 111 widget_main->Init(params_main); | 110 widget_main->Init(params_main); |
| 112 View* root_main = widget_main->GetRootView(); | 111 View* root_main = widget_main->GetRootView(); |
| 113 root_main->AddChildView(test_view_main); | 112 root_main->AddChildView(test_view_main); |
| 114 widget_main->Activate(); | 113 widget_main->Activate(); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 138 test_view_bar->AcceleratorPressed(test_view_bar->escape_key()); | 137 test_view_bar->AcceleratorPressed(test_view_bar->escape_key()); |
| 139 EXPECT_TRUE(widget_main->IsActive()); | 138 EXPECT_TRUE(widget_main->IsActive()); |
| 140 EXPECT_FALSE(widget_bar->IsActive()); | 139 EXPECT_FALSE(widget_bar->IsActive()); |
| 141 | 140 |
| 142 widget_bar->CloseNow(); | 141 widget_bar->CloseNow(); |
| 143 widget_bar.reset(); | 142 widget_bar.reset(); |
| 144 | 143 |
| 145 widget_main->CloseNow(); | 144 widget_main->CloseNow(); |
| 146 widget_main.reset(); | 145 widget_main.reset(); |
| 147 } | 146 } |
| 148 #endif // !defined(OS_WIN)||defined(USE_AURA) | |
| 149 | 147 |
| 150 TEST_F(AccessiblePaneViewTest, TwoSetPaneFocus) { | 148 TEST_F(AccessiblePaneViewTest, TwoSetPaneFocus) { |
| 151 TestBarView* test_view = new TestBarView(); | 149 TestBarView* test_view = new TestBarView(); |
| 152 TestBarView* test_view_2 = new TestBarView(); | 150 TestBarView* test_view_2 = new TestBarView(); |
| 153 scoped_ptr<Widget> widget(new Widget()); | 151 scoped_ptr<Widget> widget(new Widget()); |
| 154 Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP); | 152 Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP); |
| 155 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 153 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| 156 params.bounds = gfx::Rect(50, 50, 650, 650); | 154 params.bounds = gfx::Rect(50, 50, 650, 650); |
| 157 widget->Init(params); | 155 widget->Init(params); |
| 158 View* root = widget->GetRootView(); | 156 View* root = widget->GetRootView(); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 test_view->GetWidget()->GetFocusManager()->GetFocusedView()); | 215 test_view->GetWidget()->GetFocusManager()->GetFocusedView()); |
| 218 | 216 |
| 219 // ESC | 217 // ESC |
| 220 test_view->AcceleratorPressed(test_view->escape_key()); | 218 test_view->AcceleratorPressed(test_view->escape_key()); |
| 221 EXPECT_EQ(original_test_view->third_child_button(), | 219 EXPECT_EQ(original_test_view->third_child_button(), |
| 222 test_view->GetWidget()->GetFocusManager()->GetFocusedView()); | 220 test_view->GetWidget()->GetFocusManager()->GetFocusedView()); |
| 223 widget->CloseNow(); | 221 widget->CloseNow(); |
| 224 widget.reset(); | 222 widget.reset(); |
| 225 } | 223 } |
| 226 } // namespace views | 224 } // namespace views |
| OLD | NEW |