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/text_button.h" | 8 #include "ui/views/controls/button/text_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" |
11 #include "ui/views/widget/widget.h" | 11 #include "ui/views/widget/widget.h" |
12 | 12 |
13 namespace views { | 13 namespace views { |
14 | 14 |
15 // TODO(alicet): bring pane rotation into views and add tests. | 15 // TODO(alicet): bring pane rotation into views and add tests. |
16 // See browser_view.cc for details. | 16 // See browser_view.cc for details. |
17 | 17 |
18 typedef ViewsTestBase AccessiblePaneViewTest; | 18 typedef ViewsTestBase AccessiblePaneViewTest; |
19 | 19 |
20 class TestBarView : public AccessiblePaneView, | 20 class TestBarView : public AccessiblePaneView, |
21 public ButtonListener { | 21 public ButtonListener { |
22 public: | 22 public: |
23 TestBarView(); | 23 TestBarView(); |
24 virtual ~TestBarView(); | 24 virtual ~TestBarView(); |
25 | 25 |
26 virtual void ButtonPressed(Button* sender, | 26 virtual void ButtonPressed(Button* sender, |
27 const views::Event& event) OVERRIDE; | 27 const ui::Event& event) OVERRIDE; |
28 TextButton* child_button() const { return child_button_.get(); } | 28 TextButton* child_button() const { return child_button_.get(); } |
29 TextButton* second_child_button() const { return second_child_button_.get(); } | 29 TextButton* second_child_button() const { return second_child_button_.get(); } |
30 TextButton* third_child_button() const { return third_child_button_.get(); } | 30 TextButton* third_child_button() const { return third_child_button_.get(); } |
31 TextButton* not_child_button() const { return not_child_button_.get(); } | 31 TextButton* not_child_button() const { return not_child_button_.get(); } |
32 | 32 |
33 const ui::Accelerator& home_key() const { return home_key_; } | 33 const ui::Accelerator& home_key() const { return home_key_; } |
34 const ui::Accelerator& end_key() const { return end_key_; } | 34 const ui::Accelerator& end_key() const { return end_key_; } |
35 const ui::Accelerator& escape_key() const { return escape_key_; } | 35 const ui::Accelerator& escape_key() const { return escape_key_; } |
36 const ui::Accelerator& left_key() const { return left_key_; } | 36 const ui::Accelerator& left_key() const { return left_key_; } |
37 const ui::Accelerator& right_key() const { return right_key_; } | 37 const ui::Accelerator& right_key() const { return right_key_; } |
(...skipping 10 matching lines...) Expand all Loading... |
48 | 48 |
49 DISALLOW_COPY_AND_ASSIGN(TestBarView); | 49 DISALLOW_COPY_AND_ASSIGN(TestBarView); |
50 }; | 50 }; |
51 | 51 |
52 TestBarView::TestBarView() { | 52 TestBarView::TestBarView() { |
53 Init(); | 53 Init(); |
54 } | 54 } |
55 | 55 |
56 TestBarView::~TestBarView() {} | 56 TestBarView::~TestBarView() {} |
57 | 57 |
58 void TestBarView::ButtonPressed(views::Button* sender, | 58 void TestBarView::ButtonPressed(views::Button* sender, const ui::Event& event) { |
59 const views::Event& event) {} | 59 } |
60 | 60 |
61 void TestBarView::Init() { | 61 void TestBarView::Init() { |
62 SetLayoutManager(new views::FillLayout()); | 62 SetLayoutManager(new views::FillLayout()); |
63 string16 label; | 63 string16 label; |
64 child_button_.reset(new TextButton(this, label)); | 64 child_button_.reset(new TextButton(this, label)); |
65 AddChildView(child_button_.get()); | 65 AddChildView(child_button_.get()); |
66 second_child_button_.reset(new TextButton(this, label)); | 66 second_child_button_.reset(new TextButton(this, label)); |
67 AddChildView(second_child_button_.get()); | 67 AddChildView(second_child_button_.get()); |
68 third_child_button_.reset(new TextButton(this, label)); | 68 third_child_button_.reset(new TextButton(this, label)); |
69 AddChildView(third_child_button_.get()); | 69 AddChildView(third_child_button_.get()); |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 test_view->GetWidget()->GetFocusManager()->GetFocusedView()); | 172 test_view->GetWidget()->GetFocusManager()->GetFocusedView()); |
173 | 173 |
174 // ESC | 174 // ESC |
175 test_view->AcceleratorPressed(test_view->escape_key()); | 175 test_view->AcceleratorPressed(test_view->escape_key()); |
176 EXPECT_EQ(original_test_view->third_child_button(), | 176 EXPECT_EQ(original_test_view->third_child_button(), |
177 test_view->GetWidget()->GetFocusManager()->GetFocusedView()); | 177 test_view->GetWidget()->GetFocusManager()->GetFocusedView()); |
178 widget->CloseNow(); | 178 widget->CloseNow(); |
179 widget.reset(); | 179 widget.reset(); |
180 } | 180 } |
181 } // namespace views | 181 } // namespace views |
OLD | NEW |