Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(163)

Side by Side Diff: ui/views/focus/focus_manager_test.cc

Issue 8642002: Enable FocusManager tests for Aura. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(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 #include "ui/views/focus/focus_manager_test.h"
6
7 #include "ui/views/focus/focus_manager.h"
8 #include "ui/views/widget/widget.h"
9
10 namespace views {
11
12 ////////////////////////////////////////////////////////////////////////////////
13 // FocusManagerTest, public:
14
15 FocusManagerTest::FocusManagerTest()
16 : contents_view_(new View),
17 focus_change_listener_(NULL) {
18 }
19
20 FocusManagerTest::~FocusManagerTest() {
21 }
22
23 FocusManager* FocusManagerTest::GetFocusManager() {
24 return GetWidget()->GetFocusManager();
25 }
26
27 ////////////////////////////////////////////////////////////////////////////////
28 // FocusManagerTest, ViewTestBase overrides:
29
30 void FocusManagerTest::SetUp() {
31 ViewsTestBase::SetUp();
32 Widget* widget =
33 Widget::CreateWindowWithBounds(this, gfx::Rect(0, 0, 1024, 768));
34 InitContentView();
35 widget->Show();
36 }
37
38 void FocusManagerTest::TearDown() {
39 if (focus_change_listener_)
40 GetFocusManager()->RemoveFocusChangeListener(focus_change_listener_);
41 GetWidget()->Close();
42
43 // Flush the message loop to make application verifiers happy.
44 RunPendingMessages();
45 ViewsTestBase::TearDown();
46 }
47
48 ////////////////////////////////////////////////////////////////////////////////
49 // FocusManagerTest, WidgetDelegate implementation:
50
51 View* FocusManagerTest::GetContentsView() {
52 return contents_view_;
53 }
54
55 Widget* FocusManagerTest::GetWidget() {
56 return contents_view_->GetWidget();
57 }
58
59 const Widget* FocusManagerTest::GetWidget() const {
60 return contents_view_->GetWidget();
61 }
62
63 ////////////////////////////////////////////////////////////////////////////////
64 // FocusManagerTest, protected:
65
66 void FocusManagerTest::InitContentView() {
67 }
68
69 void FocusManagerTest::AddFocusChangeListener(FocusChangeListener* listener) {
70 ASSERT_FALSE(focus_change_listener_);
71 focus_change_listener_ = listener;
72 GetFocusManager()->AddFocusChangeListener(listener);
73 }
74
75 #if defined(OS_WIN) && !defined(USE_AURA)
76 void FocusManagerTest::SimulateActivateWindow() {
77 SendMessage(GetWidget()->GetNativeWindow(), WM_ACTIVATE, WA_ACTIVE, NULL);
78 }
79
80 void FocusManagerTest::SimulateDeactivateWindow() {
81 SendMessage(GetWidget()->GetNativeWindow(), WM_ACTIVATE, WA_INACTIVE, NULL);
82 }
83
84 void FocusManagerTest::PostKeyDown(ui::KeyboardCode key_code) {
85 PostMessage(GetWidget()->GetNativeView(), WM_KEYDOWN, key_code, 0);
86 }
87
88 void FocusManagerTest::PostKeyUp(ui::KeyboardCode key_code) {
89 PostMessage(GetWidget()->GetNativeView(), WM_KEYUP, key_code, 0);
90 }
91 #endif
92
93 ////////////////////////////////////////////////////////////////////////////////
94 // TestFocusChangeListener
95
96 void TestFocusChangeListener::OnWillChangeFocus(View* focused_before,
97 View* focused_now) {
98 focus_changes_.push_back(ViewPair(focused_before, focused_now));
99 }
100 void TestFocusChangeListener::OnDidChangeFocus(View* focused_before,
101 View* focused_now) {
102 }
103
104 void TestFocusChangeListener::ClearFocusChanges() {
105 focus_changes_.clear();
106 }
107
108 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698