summaryrefslogtreecommitdiffstats
path: root/ui/views/focus/focus_manager_test.cc
diff options
context:
space:
mode:
Diffstat (limited to 'ui/views/focus/focus_manager_test.cc')
-rw-r--r--ui/views/focus/focus_manager_test.cc35
1 files changed, 33 insertions, 2 deletions
diff --git a/ui/views/focus/focus_manager_test.cc b/ui/views/focus/focus_manager_test.cc
index da15b27..4344f12 100644
--- a/ui/views/focus/focus_manager_test.cc
+++ b/ui/views/focus/focus_manager_test.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -14,7 +14,8 @@ namespace views {
FocusManagerTest::FocusManagerTest()
: contents_view_(new View),
- focus_change_listener_(NULL) {
+ focus_change_listener_(NULL),
+ widget_focus_change_listener_(NULL) {
}
FocusManagerTest::~FocusManagerTest() {
@@ -38,6 +39,10 @@ void FocusManagerTest::SetUp() {
void FocusManagerTest::TearDown() {
if (focus_change_listener_)
GetFocusManager()->RemoveFocusChangeListener(focus_change_listener_);
+ if (widget_focus_change_listener_) {
+ WidgetFocusManager::GetInstance()->RemoveFocusChangeListener(
+ widget_focus_change_listener_);
+ }
GetWidget()->Close();
// Flush the message loop to make application verifiers happy.
@@ -72,6 +77,13 @@ void FocusManagerTest::AddFocusChangeListener(FocusChangeListener* listener) {
GetFocusManager()->AddFocusChangeListener(listener);
}
+void FocusManagerTest::AddWidgetFocusChangeListener(
+ WidgetFocusChangeListener* listener) {
+ ASSERT_FALSE(widget_focus_change_listener_);
+ widget_focus_change_listener_ = listener;
+ WidgetFocusManager::GetInstance()->AddFocusChangeListener(listener);
+}
+
#if defined(OS_WIN) && !defined(USE_AURA)
void FocusManagerTest::SimulateActivateWindow() {
SendMessage(GetWidget()->GetNativeWindow(), WM_ACTIVATE, WA_ACTIVE, NULL);
@@ -111,4 +123,23 @@ void TestFocusChangeListener::ClearFocusChanges() {
focus_changes_.clear();
}
+////////////////////////////////////////////////////////////////////////////////
+// TestWidgetFocusChangeListener
+
+TestWidgetFocusChangeListener::TestWidgetFocusChangeListener() {
+}
+
+TestWidgetFocusChangeListener::~TestWidgetFocusChangeListener() {
+}
+
+void TestWidgetFocusChangeListener::ClearFocusChanges() {
+ focus_changes_.clear();
+}
+
+void TestWidgetFocusChangeListener::OnNativeFocusChange(
+ gfx::NativeView focused_before,
+ gfx::NativeView focused_now) {
+ focus_changes_.push_back(NativeViewPair(focused_before, focused_now));
+}
+
} // namespace views