| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 // Disabled right now as this won't work on BuildBots right now as this test | 5 // Disabled right now as this won't work on BuildBots right now as this test |
| 6 // require the box it runs on to be unlocked (and no screen-savers). | 6 // require the box it runs on to be unlocked (and no screen-savers). |
| 7 // The test actually simulates mouse and key events, so if the screen is locked, | 7 // The test actually simulates mouse and key events, so if the screen is locked, |
| 8 // the events don't go to the Chrome window. | 8 // the events don't go to the Chrome window. |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| 11 #include "app/resource_bundle.h" | 11 #include "app/resource_bundle.h" |
| 12 #include "base/gfx/rect.h" | 12 #include "base/gfx/rect.h" |
| 13 #include "base/string_util.h" | 13 #include "base/string_util.h" |
| 14 #include "third_party/skia/include/core/SkColor.h" | 14 #include "third_party/skia/include/core/SkColor.h" |
| 15 #include "views/background.h" | 15 #include "views/background.h" |
| 16 #include "views/border.h" | 16 #include "views/border.h" |
| 17 #include "views/controls/button/checkbox.h" | 17 #include "views/controls/button/checkbox.h" |
| 18 #include "views/controls/button/native_button.h" | 18 #include "views/controls/button/native_button.h" |
| 19 #include "views/controls/button/radio_button.h" | 19 #include "views/controls/button/radio_button.h" |
| 20 #include "views/controls/combobox/combobox.h" | 20 #include "views/controls/combobox/combobox.h" |
| 21 #include "views/controls/combobox/native_combobox_wrapper.h" | 21 #include "views/controls/combobox/native_combobox_wrapper.h" |
| 22 #include "views/controls/label.h" | 22 #include "views/controls/label.h" |
| 23 #include "views/controls/link.h" | 23 #include "views/controls/link.h" |
| 24 #include "views/controls/native_control.h" |
| 24 #include "views/controls/scroll_view.h" | 25 #include "views/controls/scroll_view.h" |
| 25 #include "views/controls/tabbed_pane.h" | 26 #include "views/controls/tabbed_pane/native_tabbed_pane_wrapper.h" |
| 27 #include "views/controls/tabbed_pane/tabbed_pane.h" |
| 26 #include "views/controls/textfield/textfield.h" | 28 #include "views/controls/textfield/textfield.h" |
| 27 #include "views/widget/accelerator_handler.h" | 29 #include "views/widget/accelerator_handler.h" |
| 28 #include "views/widget/root_view.h" | 30 #include "views/widget/root_view.h" |
| 29 #include "views/widget/widget_win.h" | 31 #include "views/widget/widget_win.h" |
| 30 #include "views/window/window_delegate.h" | 32 #include "views/window/window_delegate.h" |
| 31 #include "views/window/window_win.h" | 33 #include "views/window/window_win.h" |
| 32 | 34 |
| 33 namespace views { | 35 namespace views { |
| 34 | 36 |
| 35 static const int kWindowWidth = 600; | 37 static const int kWindowWidth = 600; |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 FocusTraversalTest(); | 268 FocusTraversalTest(); |
| 267 | 269 |
| 268 virtual gfx::Rect bounds() { | 270 virtual gfx::Rect bounds() { |
| 269 return gfx::Rect(0, 0, 600, 460); | 271 return gfx::Rect(0, 0, 600, 460); |
| 270 } | 272 } |
| 271 | 273 |
| 272 View* FindViewByID(int id) { | 274 View* FindViewByID(int id) { |
| 273 View* view = GetContentsView()->GetViewByID(id); | 275 View* view = GetContentsView()->GetViewByID(id); |
| 274 if (view) | 276 if (view) |
| 275 return view; | 277 return view; |
| 276 view = style_tab_->GetContentsRootView()->GetViewByID(id); | 278 view = style_tab_->GetSelectedTab()->GetViewByID(id); |
| 277 if (view) | 279 if (view) |
| 278 return view; | 280 return view; |
| 279 view = search_border_view_->GetContentsRootView()->GetViewByID(id); | 281 view = search_border_view_->GetContentsRootView()->GetViewByID(id); |
| 280 if (view) | 282 if (view) |
| 281 return view; | 283 return view; |
| 282 return NULL; | 284 return NULL; |
| 283 } | 285 } |
| 284 | 286 |
| 285 private: | 287 private: |
| 286 TabbedPane* style_tab_; | 288 TabbedPane* style_tab_; |
| (...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 737 return 10; | 739 return 10; |
| 738 } | 740 } |
| 739 virtual std::wstring GetItemAt(Combobox* source, int index) { | 741 virtual std::wstring GetItemAt(Combobox* source, int index) { |
| 740 return L"Hello combo"; | 742 return L"Hello combo"; |
| 741 } | 743 } |
| 742 }; | 744 }; |
| 743 | 745 |
| 744 class TestTabbedPane : public TabbedPane { | 746 class TestTabbedPane : public TabbedPane { |
| 745 public: | 747 public: |
| 746 TestTabbedPane() { } | 748 TestTabbedPane() { } |
| 747 virtual HWND TestGetNativeControlHWND() { | 749 virtual HWND TestGetNativeComponent() { |
| 748 return GetNativeControlHWND(); | 750 return native_tabbed_pane_->GetTestingHandle(); |
| 749 } | 751 } |
| 750 }; | 752 }; |
| 751 | 753 |
| 752 // Tests that NativeControls do set the focus View appropriately on the | 754 // Tests that NativeControls do set the focus View appropriately on the |
| 753 // FocusManager. | 755 // FocusManager. |
| 754 TEST_F(FocusManagerTest, FocusNativeControls) { | 756 TEST_F(FocusManagerTest, FocusNativeControls) { |
| 755 TestNativeButton* button = new TestNativeButton(L"Press me"); | 757 TestNativeButton* button = new TestNativeButton(L"Press me"); |
| 756 TestCheckbox* checkbox = new TestCheckbox(L"Checkbox"); | 758 TestCheckbox* checkbox = new TestCheckbox(L"Checkbox"); |
| 757 TestRadioButton* radio_button = new TestRadioButton(L"RadioButton"); | 759 TestRadioButton* radio_button = new TestRadioButton(L"RadioButton"); |
| 758 TestTextfield* textfield = new TestTextfield(); | 760 TestTextfield* textfield = new TestTextfield(); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 778 ::SendMessage(radio_button->TestGetNativeControlHWND(), WM_SETFOCUS, | 780 ::SendMessage(radio_button->TestGetNativeControlHWND(), WM_SETFOCUS, |
| 779 NULL, NULL); | 781 NULL, NULL); |
| 780 EXPECT_EQ(radio_button, GetFocusManager()->GetFocusedView()); | 782 EXPECT_EQ(radio_button, GetFocusManager()->GetFocusedView()); |
| 781 | 783 |
| 782 ::SendMessage(textfield->TestGetNativeComponent(), WM_SETFOCUS, NULL, NULL); | 784 ::SendMessage(textfield->TestGetNativeComponent(), WM_SETFOCUS, NULL, NULL); |
| 783 EXPECT_EQ(textfield, GetFocusManager()->GetFocusedView()); | 785 EXPECT_EQ(textfield, GetFocusManager()->GetFocusedView()); |
| 784 | 786 |
| 785 ::SendMessage(combobox->TestGetNativeComponent(), WM_SETFOCUS, NULL, NULL); | 787 ::SendMessage(combobox->TestGetNativeComponent(), WM_SETFOCUS, NULL, NULL); |
| 786 EXPECT_EQ(combobox, GetFocusManager()->GetFocusedView()); | 788 EXPECT_EQ(combobox, GetFocusManager()->GetFocusedView()); |
| 787 | 789 |
| 788 ::SendMessage(tabbed_pane->TestGetNativeControlHWND(), WM_SETFOCUS, | 790 ::SendMessage(tabbed_pane->TestGetNativeComponent(), WM_SETFOCUS, |
| 789 NULL, NULL); | 791 NULL, NULL); |
| 790 EXPECT_EQ(tabbed_pane, GetFocusManager()->GetFocusedView()); | 792 EXPECT_EQ(tabbed_pane, GetFocusManager()->GetFocusedView()); |
| 791 | 793 |
| 792 ::SendMessage(tab_button->TestGetNativeControlHWND(), WM_SETFOCUS, | 794 ::SendMessage(tab_button->TestGetNativeControlHWND(), WM_SETFOCUS, |
| 793 NULL, NULL); | 795 NULL, NULL); |
| 794 EXPECT_EQ(tab_button, GetFocusManager()->GetFocusedView()); | 796 EXPECT_EQ(tab_button, GetFocusManager()->GetFocusedView()); |
| 795 } | 797 } |
| 796 | 798 |
| 797 // Test that when activating/deactivating the top window, the focus is stored/ | 799 // Test that when activating/deactivating the top window, the focus is stored/ |
| 798 // restored properly. | 800 // restored properly. |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1129 EXPECT_EQ(target.accelerator_count(), 1); | 1131 EXPECT_EQ(target.accelerator_count(), 1); |
| 1130 EXPECT_EQ(NULL, | 1132 EXPECT_EQ(NULL, |
| 1131 focus_manager->GetCurrentTargetForAccelerator(return_accelerator)); | 1133 focus_manager->GetCurrentTargetForAccelerator(return_accelerator)); |
| 1132 | 1134 |
| 1133 // Hitting the return key again; nothing should happen. | 1135 // Hitting the return key again; nothing should happen. |
| 1134 EXPECT_FALSE(focus_manager->ProcessAccelerator(return_accelerator)); | 1136 EXPECT_FALSE(focus_manager->ProcessAccelerator(return_accelerator)); |
| 1135 EXPECT_EQ(target.accelerator_count(), 1); | 1137 EXPECT_EQ(target.accelerator_count(), 1); |
| 1136 } | 1138 } |
| 1137 | 1139 |
| 1138 } // namespace views | 1140 } // namespace views |
| OLD | NEW |