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 <utility> | 5 #include <utility> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "ui/base/accelerators/accelerator.h" | 9 #include "ui/base/accelerators/accelerator.h" |
10 #include "ui/base/keycodes/keyboard_codes.h" | 10 #include "ui/base/keycodes/keyboard_codes.h" |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 class TestTextfield : public Textfield { | 171 class TestTextfield : public Textfield { |
172 public: | 172 public: |
173 TestTextfield() {} | 173 TestTextfield() {} |
174 virtual gfx::NativeView TestGetNativeControlView() { | 174 virtual gfx::NativeView TestGetNativeControlView() { |
175 return native_wrapper_->GetTestingHandle(); | 175 return native_wrapper_->GetTestingHandle(); |
176 } | 176 } |
177 }; | 177 }; |
178 | 178 |
179 class TestTabbedPane : public TabbedPane { | 179 class TestTabbedPane : public TabbedPane { |
180 public: | 180 public: |
181 TestTabbedPane() {} | 181 TestTabbedPane() |
| 182 : TabbedPane(false) {} |
182 virtual gfx::NativeView TestGetNativeControlView() { | 183 virtual gfx::NativeView TestGetNativeControlView() { |
183 return native_tabbed_pane_->GetTestingHandle(); | 184 return native_tabbed_pane_->GetTestingHandle(); |
184 } | 185 } |
185 }; | 186 }; |
186 | 187 |
187 // Tests that NativeControls do set the focused View appropriately on the | 188 // Tests that NativeControls do set the focused View appropriately on the |
188 // FocusManager. | 189 // FocusManager. |
189 TEST_F(FocusManagerTest, DISABLED_FocusNativeControls) { | 190 TEST_F(FocusManagerTest, DISABLED_FocusNativeControls) { |
190 TestTextfield* textfield = new TestTextfield(); | 191 TestTextfield* textfield = new TestTextfield(); |
191 TestTabbedPane* tabbed_pane = new TestTabbedPane(); | 192 TestTabbedPane* tabbed_pane = new TestTabbedPane(); |
(...skipping 15 matching lines...) Expand all Loading... |
207 FocusNativeView(textfield2->TestGetNativeControlView()); | 208 FocusNativeView(textfield2->TestGetNativeControlView()); |
208 EXPECT_EQ(textfield2, GetFocusManager()->GetFocusedView()); | 209 EXPECT_EQ(textfield2, GetFocusManager()->GetFocusedView()); |
209 } | 210 } |
210 #endif | 211 #endif |
211 | 212 |
212 // There is no tabbed pane in Aura. | 213 // There is no tabbed pane in Aura. |
213 #if !defined(USE_AURA) | 214 #if !defined(USE_AURA) |
214 TEST_F(FocusManagerTest, ContainsView) { | 215 TEST_F(FocusManagerTest, ContainsView) { |
215 View* view = new View(); | 216 View* view = new View(); |
216 scoped_ptr<View> detached_view(new View()); | 217 scoped_ptr<View> detached_view(new View()); |
217 TabbedPane* tabbed_pane = new TabbedPane(); | 218 TabbedPane* tabbed_pane = new TabbedPane(false); |
218 tabbed_pane->set_use_native_win_control(true); | 219 tabbed_pane->set_use_native_win_control(true); |
219 TabbedPane* nested_tabbed_pane = new TabbedPane(); | 220 TabbedPane* nested_tabbed_pane = new TabbedPane(false); |
220 nested_tabbed_pane->set_use_native_win_control(true); | 221 nested_tabbed_pane->set_use_native_win_control(true); |
221 NativeTextButton* tab_button = new NativeTextButton( | 222 NativeTextButton* tab_button = new NativeTextButton( |
222 NULL, ASCIIToUTF16("tab button")); | 223 NULL, ASCIIToUTF16("tab button")); |
223 | 224 |
224 GetContentsView()->AddChildView(view); | 225 GetContentsView()->AddChildView(view); |
225 GetContentsView()->AddChildView(tabbed_pane); | 226 GetContentsView()->AddChildView(tabbed_pane); |
226 // Adding a View inside a TabbedPane to test the case of nested root view. | 227 // Adding a View inside a TabbedPane to test the case of nested root view. |
227 | 228 |
228 tabbed_pane->AddTab(ASCIIToUTF16("Awesome tab"), nested_tabbed_pane); | 229 tabbed_pane->AddTab(ASCIIToUTF16("Awesome tab"), nested_tabbed_pane); |
229 nested_tabbed_pane->AddTab(ASCIIToUTF16("Awesomer tab"), tab_button); | 230 nested_tabbed_pane->AddTab(ASCIIToUTF16("Awesomer tab"), tab_button); |
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
633 ViewsTestBase::TearDown(); | 634 ViewsTestBase::TearDown(); |
634 } | 635 } |
635 | 636 |
636 FocusManager* tracked_focus_manager_; | 637 FocusManager* tracked_focus_manager_; |
637 DtorTrackVector dtor_tracker_; | 638 DtorTrackVector dtor_tracker_; |
638 }; | 639 }; |
639 | 640 |
640 #if !defined(USE_AURA) | 641 #if !defined(USE_AURA) |
641 TEST_F(FocusManagerDtorTest, FocusManagerDestructedLast) { | 642 TEST_F(FocusManagerDtorTest, FocusManagerDestructedLast) { |
642 // Setup views hierarchy. | 643 // Setup views hierarchy. |
643 TabbedPane* tabbed_pane = new TabbedPane(); | 644 TabbedPane* tabbed_pane = new TabbedPane(false); |
644 tabbed_pane->set_use_native_win_control(true); | 645 tabbed_pane->set_use_native_win_control(true); |
645 GetContentsView()->AddChildView(tabbed_pane); | 646 GetContentsView()->AddChildView(tabbed_pane); |
646 | 647 |
647 NativeButtonDtorTracked* button = new NativeButtonDtorTracked( | 648 NativeButtonDtorTracked* button = new NativeButtonDtorTracked( |
648 ASCIIToUTF16("button"), &dtor_tracker_); | 649 ASCIIToUTF16("button"), &dtor_tracker_); |
649 tabbed_pane->AddTab(ASCIIToUTF16("Awesome tab"), button); | 650 tabbed_pane->AddTab(ASCIIToUTF16("Awesome tab"), button); |
650 | 651 |
651 // Close the window. | 652 // Close the window. |
652 GetWidget()->Close(); | 653 GetWidget()->Close(); |
653 RunPendingMessages(); | 654 RunPendingMessages(); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
697 views::View* v3 = new View; | 698 views::View* v3 = new View; |
698 v3->set_focusable(true); | 699 v3->set_focusable(true); |
699 GetContentsView()->AddChildView(v3); | 700 GetContentsView()->AddChildView(v3); |
700 | 701 |
701 v3->RequestFocus(); | 702 v3->RequestFocus(); |
702 GetWidget()->GetFocusManager()->AdvanceFocus(true); | 703 GetWidget()->GetFocusManager()->AdvanceFocus(true); |
703 EXPECT_TRUE(v1->HasFocus()); | 704 EXPECT_TRUE(v1->HasFocus()); |
704 } | 705 } |
705 | 706 |
706 } // namespace views | 707 } // namespace views |
OLD | NEW |