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/memory/ptr_util.h" |
14 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
15 #include "ui/base/accelerators/accelerator.h" | 16 #include "ui/base/accelerators/accelerator.h" |
16 #include "ui/events/keycodes/keyboard_codes.h" | 17 #include "ui/events/keycodes/keyboard_codes.h" |
17 #include "ui/views/accessible_pane_view.h" | 18 #include "ui/views/accessible_pane_view.h" |
18 #include "ui/views/focus/focus_manager_delegate.h" | 19 #include "ui/views/focus/focus_manager_delegate.h" |
19 #include "ui/views/focus/focus_manager_factory.h" | 20 #include "ui/views/focus/focus_manager_factory.h" |
20 #include "ui/views/focus/widget_focus_manager.h" | 21 #include "ui/views/focus/widget_focus_manager.h" |
21 #include "ui/views/test/focus_manager_test.h" | 22 #include "ui/views/test/focus_manager_test.h" |
22 #include "ui/views/test/widget_test.h" | 23 #include "ui/views/test/widget_test.h" |
23 #include "ui/views/widget/widget.h" | 24 #include "ui/views/widget/widget.h" |
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
470 | 471 |
471 private: | 472 private: |
472 DISALLOW_COPY_AND_ASSIGN(FocusManagerDtorTracked); | 473 DISALLOW_COPY_AND_ASSIGN(FocusManagerDtorTracked); |
473 }; | 474 }; |
474 | 475 |
475 class TestFocusManagerFactory : public FocusManagerFactory { | 476 class TestFocusManagerFactory : public FocusManagerFactory { |
476 public: | 477 public: |
477 explicit TestFocusManagerFactory(DtorTrackVector* dtor_tracker) | 478 explicit TestFocusManagerFactory(DtorTrackVector* dtor_tracker) |
478 : dtor_tracker_(dtor_tracker) { | 479 : dtor_tracker_(dtor_tracker) { |
479 } | 480 } |
| 481 ~TestFocusManagerFactory() override {} |
480 | 482 |
481 FocusManager* CreateFocusManager(Widget* widget, | 483 std::unique_ptr<FocusManager> CreateFocusManager( |
482 bool desktop_widget) override { | 484 Widget* widget, |
483 return new FocusManagerDtorTracked(widget, dtor_tracker_); | 485 bool desktop_widget) override { |
| 486 return base::MakeUnique<FocusManagerDtorTracked>(widget, dtor_tracker_); |
484 } | 487 } |
485 | 488 |
486 private: | 489 private: |
487 DtorTrackVector* dtor_tracker_; | 490 DtorTrackVector* dtor_tracker_; |
| 491 |
488 DISALLOW_COPY_AND_ASSIGN(TestFocusManagerFactory); | 492 DISALLOW_COPY_AND_ASSIGN(TestFocusManagerFactory); |
489 }; | 493 }; |
490 | 494 |
491 class WindowDtorTracked : public Widget { | 495 class WindowDtorTracked : public Widget { |
492 public: | 496 public: |
493 explicit WindowDtorTracked(DtorTrackVector* dtor_tracker) | 497 explicit WindowDtorTracked(DtorTrackVector* dtor_tracker) |
494 : dtor_tracker_(dtor_tracker) { | 498 : dtor_tracker_(dtor_tracker) { |
495 } | 499 } |
496 | 500 |
497 ~WindowDtorTracked() override { | 501 ~WindowDtorTracked() override { |
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
899 EXPECT_EQ(view1, GetFocusManager()->GetFocusedView()); | 903 EXPECT_EQ(view1, GetFocusManager()->GetFocusedView()); |
900 | 904 |
901 // Allow focus to go to the parent, and focus backwards which should now move | 905 // Allow focus to go to the parent, and focus backwards which should now move |
902 // up |widget_view| (in the parent). | 906 // up |widget_view| (in the parent). |
903 delegate->set_should_advance_focus_to_parent(true); | 907 delegate->set_should_advance_focus_to_parent(true); |
904 GetFocusManager()->AdvanceFocus(true); | 908 GetFocusManager()->AdvanceFocus(true); |
905 EXPECT_EQ(widget_view, GetFocusManager()->GetFocusedView()); | 909 EXPECT_EQ(widget_view, GetFocusManager()->GetFocusedView()); |
906 } | 910 } |
907 | 911 |
908 } // namespace views | 912 } // namespace views |
OLD | NEW |