| 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/focus/focus_manager.h" | 5 #include "ui/views/focus/focus_manager.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
| 15 #include "ui/base/accelerators/accelerator.h" | 15 #include "ui/base/accelerators/accelerator.h" |
| 16 #include "ui/events/keycodes/keyboard_codes.h" | 16 #include "ui/events/keycodes/keyboard_codes.h" |
| 17 #include "ui/views/accessible_pane_view.h" | 17 #include "ui/views/accessible_pane_view.h" |
| 18 #include "ui/views/controls/button/label_button.h" | |
| 19 #include "ui/views/focus/focus_manager_factory.h" | 18 #include "ui/views/focus/focus_manager_factory.h" |
| 20 #include "ui/views/focus/widget_focus_manager.h" | 19 #include "ui/views/focus/widget_focus_manager.h" |
| 21 #include "ui/views/test/focus_manager_test.h" | 20 #include "ui/views/test/focus_manager_test.h" |
| 22 #include "ui/views/test/widget_test.h" | 21 #include "ui/views/test/widget_test.h" |
| 23 #include "ui/views/widget/widget.h" | 22 #include "ui/views/widget/widget.h" |
| 24 | 23 |
| 25 namespace views { | 24 namespace views { |
| 26 | 25 |
| 27 enum FocusTestEventType { | 26 enum FocusTestEventType { |
| 28 ON_FOCUS = 0, | 27 ON_FOCUS = 0, |
| (...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 FocusManager* CreateFocusManager(Widget* widget, | 474 FocusManager* CreateFocusManager(Widget* widget, |
| 476 bool desktop_widget) override { | 475 bool desktop_widget) override { |
| 477 return new FocusManagerDtorTracked(widget, dtor_tracker_); | 476 return new FocusManagerDtorTracked(widget, dtor_tracker_); |
| 478 } | 477 } |
| 479 | 478 |
| 480 private: | 479 private: |
| 481 DtorTrackVector* dtor_tracker_; | 480 DtorTrackVector* dtor_tracker_; |
| 482 DISALLOW_COPY_AND_ASSIGN(TestFocusManagerFactory); | 481 DISALLOW_COPY_AND_ASSIGN(TestFocusManagerFactory); |
| 483 }; | 482 }; |
| 484 | 483 |
| 485 class LabelButtonDtorTracked : public LabelButton { | |
| 486 public: | |
| 487 LabelButtonDtorTracked(const base::string16& text, | |
| 488 DtorTrackVector* dtor_tracker) | |
| 489 : LabelButton(NULL, text), | |
| 490 dtor_tracker_(dtor_tracker) { | |
| 491 SetStyle(STYLE_BUTTON); | |
| 492 }; | |
| 493 ~LabelButtonDtorTracked() override { | |
| 494 dtor_tracker_->push_back("LabelButtonDtorTracked"); | |
| 495 } | |
| 496 | |
| 497 DtorTrackVector* dtor_tracker_; | |
| 498 }; | |
| 499 | |
| 500 class WindowDtorTracked : public Widget { | 484 class WindowDtorTracked : public Widget { |
| 501 public: | 485 public: |
| 502 explicit WindowDtorTracked(DtorTrackVector* dtor_tracker) | 486 explicit WindowDtorTracked(DtorTrackVector* dtor_tracker) |
| 503 : dtor_tracker_(dtor_tracker) { | 487 : dtor_tracker_(dtor_tracker) { |
| 504 } | 488 } |
| 505 | 489 |
| 506 ~WindowDtorTracked() override { | 490 ~WindowDtorTracked() override { |
| 507 dtor_tracker_->push_back("WindowDtorTracked"); | 491 dtor_tracker_->push_back("WindowDtorTracked"); |
| 508 } | 492 } |
| 509 | 493 |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 911 EXPECT_EQ(view1, GetFocusManager()->GetFocusedView()); | 895 EXPECT_EQ(view1, GetFocusManager()->GetFocusedView()); |
| 912 | 896 |
| 913 // Allow focus to go to the parent, and focus backwards which should now move | 897 // Allow focus to go to the parent, and focus backwards which should now move |
| 914 // up |widget_view| (in the parent). | 898 // up |widget_view| (in the parent). |
| 915 delegate->set_should_advance_focus_to_parent(true); | 899 delegate->set_should_advance_focus_to_parent(true); |
| 916 GetFocusManager()->AdvanceFocus(true); | 900 GetFocusManager()->AdvanceFocus(true); |
| 917 EXPECT_EQ(widget_view, GetFocusManager()->GetFocusedView()); | 901 EXPECT_EQ(widget_view, GetFocusManager()->GetFocusedView()); |
| 918 } | 902 } |
| 919 | 903 |
| 920 } // namespace views | 904 } // namespace views |
| OLD | NEW |