Chromium Code Reviews
|
| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef UI_VIEWS_FOCUS_FOCUS_MANAGER_TEST_H_ | |
| 6 #define UI_VIEWS_FOCUS_FOCUS_MANAGER_TEST_H_ | |
| 7 | |
| 8 #include "ui/views/focus/focus_manager.h" | |
| 9 #include "ui/views/test/views_test_base.h" | |
| 10 #include "ui/views/widget/widget_delegate.h" | |
| 11 | |
| 12 namespace views { | |
| 13 | |
| 14 class FocusChangeListener; | |
| 15 | |
| 16 class FocusManagerTest : public ViewsTestBase, | |
| 17 public WidgetDelegate { | |
| 18 public: | |
| 19 FocusManagerTest(); | |
| 20 virtual ~FocusManagerTest(); | |
| 21 | |
| 22 // Convenience to obtain the focus manager for the test's hosting widget. | |
| 23 FocusManager* GetFocusManager(); | |
| 24 | |
| 25 // Overridden from ViewsTestBase: | |
| 26 virtual void SetUp() OVERRIDE; | |
| 27 virtual void TearDown() OVERRIDE; | |
| 28 | |
| 29 // Overridden from WidgetDelegate: | |
| 30 virtual View* GetContentsView() OVERRIDE; | |
| 31 virtual Widget* GetWidget() OVERRIDE; | |
| 32 virtual const Widget* GetWidget() const OVERRIDE; | |
| 33 | |
| 34 protected: | |
| 35 virtual void InitContentView(); | |
|
sky
2011/11/22 21:12:38
Add a description.
| |
| 36 | |
| 37 void AddFocusChangeListener(FocusChangeListener* listener); | |
| 38 | |
| 39 #if defined(OS_WIN) && !defined(USE_AURA) | |
| 40 // Mocks activating/deactivating the window. | |
| 41 void SimulateActivateWindow(); | |
| 42 void SimulateDeactivateWindow(); | |
| 43 | |
| 44 void PostKeyDown(ui::KeyboardCode key_code); | |
| 45 void PostKeyUp(ui::KeyboardCode key_code); | |
| 46 #endif | |
| 47 | |
| 48 private: | |
| 49 View* contents_view_; | |
| 50 FocusChangeListener* focus_change_listener_; | |
| 51 | |
| 52 DISALLOW_COPY_AND_ASSIGN(FocusManagerTest); | |
| 53 }; | |
| 54 | |
| 55 typedef std::pair<View*, View*> ViewPair; | |
| 56 | |
| 57 class TestFocusChangeListener : public FocusChangeListener { | |
|
sky
2011/11/22 21:12:38
Add a description.
| |
| 58 public: | |
| 59 const std::vector<ViewPair>& focus_changes() const { return focus_changes_; } | |
| 60 void ClearFocusChanges(); | |
| 61 | |
| 62 // Overridden from FocusChangeListener: | |
| 63 virtual void OnWillChangeFocus(View* focused_before, | |
| 64 View* focused_now) OVERRIDE; | |
| 65 virtual void OnDidChangeFocus(View* focused_before, | |
| 66 View* focused_now) OVERRIDE; | |
| 67 | |
| 68 private: | |
| 69 // A vector of which views lost/gained focus. | |
| 70 std::vector<ViewPair> focus_changes_; | |
| 71 }; | |
|
sky
2011/11/22 21:12:38
DISALLOW_COPY_AND_ASSIGN
| |
| 72 | |
| 73 } // namespace views | |
| 74 | |
| 75 #endif // UI_VIEWS_FOCUS_FOCUS_MANAGER_TEST_H_ | |
| OLD | NEW |