diff options
Diffstat (limited to 'ui')
-rw-r--r-- | ui/base/test/dummy_input_method.h | 56 | ||||
-rw-r--r-- | ui/ui_unittests.gypi | 1 | ||||
-rw-r--r-- | ui/views/accessible_pane_view_unittest.cc | 5 | ||||
-rw-r--r-- | ui/views/test/views_test_base.cc | 43 | ||||
-rw-r--r-- | ui/views/views.gyp | 1 | ||||
-rw-r--r-- | ui/views/widget/native_widget_win.cc | 14 |
6 files changed, 78 insertions, 42 deletions
diff --git a/ui/base/test/dummy_input_method.h b/ui/base/test/dummy_input_method.h new file mode 100644 index 0000000..45da353 --- /dev/null +++ b/ui/base/test/dummy_input_method.h @@ -0,0 +1,56 @@ +// 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. + +#ifndef UI_BASE_TEST_DUMMY_INPUT_METHOD_H_ +#define UI_BASE_TEST_DUMMY_INPUT_METHOD_H_ + +#include "ui/base/ime/input_method.h" + +namespace ui { +namespace test { + +class DummyInputMethod : public ui::InputMethod { + public: + DummyInputMethod() {} + virtual ~DummyInputMethod() {} + + // ui::InputMethod overrides: + virtual void SetDelegate( + ui::internal::InputMethodDelegate* delegate) OVERRIDE {} + virtual void Init(bool focused) OVERRIDE {} + virtual void OnFocus() OVERRIDE {} + virtual void OnBlur() OVERRIDE {} + virtual void SetFocusedTextInputClient( + ui::TextInputClient* client) OVERRIDE {} + virtual ui::TextInputClient* GetTextInputClient() const OVERRIDE { + return NULL; + } + virtual void DispatchKeyEvent( + const base::NativeEvent& native_key_event) OVERRIDE {} + virtual void OnTextInputTypeChanged( + const ui::TextInputClient* client) OVERRIDE {} + virtual void OnCaretBoundsChanged( + const ui::TextInputClient* client) OVERRIDE {} + virtual void CancelComposition(const ui::TextInputClient* client) OVERRIDE {} + virtual std::string GetInputLocale() OVERRIDE { return ""; } + virtual base::i18n::TextDirection GetInputTextDirection() OVERRIDE { + return base::i18n::UNKNOWN_DIRECTION; + } + virtual bool IsActive() OVERRIDE { return true; } + virtual ui::TextInputType GetTextInputType() const OVERRIDE { + return ui::TEXT_INPUT_TYPE_NONE; + } + virtual bool CanComposeInline() const OVERRIDE { + return true; + } + + private: + DISALLOW_COPY_AND_ASSIGN(DummyInputMethod); +}; + +} // namespace test +} // namespace ui + +#endif // UI_BASE_TEST_DUMMY_INPUT_METHOD_H_ + diff --git a/ui/ui_unittests.gypi b/ui/ui_unittests.gypi index 0f6d293..26d6bdc 100644 --- a/ui/ui_unittests.gypi +++ b/ui/ui_unittests.gypi @@ -15,6 +15,7 @@ 'base/test/cocoa_test_event_utils.mm', 'base/test/ui_cocoa_test_helper.h', 'base/test/ui_cocoa_test_helper.mm', + 'base/test/dummy_input_method.h', ], 'include_dirs': [ '../', diff --git a/ui/views/accessible_pane_view_unittest.cc b/ui/views/accessible_pane_view_unittest.cc index 467f143..f7551d6 100644 --- a/ui/views/accessible_pane_view_unittest.cc +++ b/ui/views/accessible_pane_view_unittest.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. @@ -84,6 +84,7 @@ TEST_F(AccessiblePaneViewTest, SimpleSetPaneFocus) { View* root = widget->GetRootView(); root->AddChildView(test_view); widget->Show(); + widget->Activate(); // Set pane focus succeeds, focus on child. EXPECT_TRUE(test_view->SetPaneFocusAndFocusDefault()); @@ -113,6 +114,7 @@ TEST_F(AccessiblePaneViewTest, TwoSetPaneFocus) { root->AddChildView(test_view); root->AddChildView(test_view_2); widget->Show(); + widget->Activate(); // Set pane focus succeeds, focus on child. EXPECT_TRUE(test_view->SetPaneFocusAndFocusDefault()); @@ -142,6 +144,7 @@ TEST_F(AccessiblePaneViewTest, PaneFocusTraversal) { root->AddChildView(original_test_view); root->AddChildView(test_view); widget->Show(); + widget->Activate(); // Set pane focus on first view. EXPECT_TRUE(original_test_view->SetPaneFocus( diff --git a/ui/views/test/views_test_base.cc b/ui/views/test/views_test_base.cc index 00a7cb3..4932616 100644 --- a/ui/views/test/views_test_base.cc +++ b/ui/views/test/views_test_base.cc @@ -15,47 +15,8 @@ #include "ui/aura/test/test_screen.h" #include "ui/aura/test/test_stacking_client.h" #include "ui/base/ime/input_method.h" +#include "ui/base/test/dummy_input_method.h" #include "ui/gfx/screen.h" - -namespace { - -class DummyInputMethod : public ui::InputMethod { - public: - DummyInputMethod() {} - virtual ~DummyInputMethod() {} - - // ui::InputMethod overrides: - virtual void SetDelegate( - ui::internal::InputMethodDelegate* delegate) OVERRIDE {} - virtual void Init(bool focused) OVERRIDE {} - virtual void OnFocus() OVERRIDE {} - virtual void OnBlur() OVERRIDE {} - virtual void SetFocusedTextInputClient( - ui::TextInputClient* client) OVERRIDE {} - virtual ui::TextInputClient* GetTextInputClient() const OVERRIDE { - return NULL; - } - virtual void DispatchKeyEvent( - const base::NativeEvent& native_key_event) OVERRIDE {} - virtual void OnTextInputTypeChanged( - const ui::TextInputClient* client) OVERRIDE {} - virtual void OnCaretBoundsChanged( - const ui::TextInputClient* client) OVERRIDE {} - virtual void CancelComposition(const ui::TextInputClient* client) OVERRIDE {} - virtual std::string GetInputLocale() OVERRIDE { return ""; } - virtual base::i18n::TextDirection GetInputTextDirection() OVERRIDE { - return base::i18n::UNKNOWN_DIRECTION; - } - virtual bool IsActive() OVERRIDE { return true; } - virtual ui::TextInputType GetTextInputType() const OVERRIDE { - return ui::TEXT_INPUT_TYPE_NONE; - } - virtual bool CanComposeInline() const OVERRIDE { - return true; - } -}; - -} // namespace #endif namespace views { @@ -64,7 +25,7 @@ ViewsTestBase::ViewsTestBase() : setup_called_(false), teardown_called_(false) { #if defined(USE_AURA) - test_input_method_.reset(new DummyInputMethod); + test_input_method_.reset(new ui::test::DummyInputMethod); #endif } diff --git a/ui/views/views.gyp b/ui/views/views.gyp index 60e0a61..a25a265 100644 --- a/ui/views/views.gyp +++ b/ui/views/views.gyp @@ -499,6 +499,7 @@ '../ui.gyp:ui', '../ui.gyp:ui_resources', '../ui.gyp:ui_resources_standard', + '../ui.gyp:ui_test_support', 'test_support_views', 'views', ], diff --git a/ui/views/widget/native_widget_win.cc b/ui/views/widget/native_widget_win.cc index 975b905..8473c32 100644 --- a/ui/views/widget/native_widget_win.cc +++ b/ui/views/widget/native_widget_win.cc @@ -38,6 +38,7 @@ #include "ui/views/drag_utils.h" #include "ui/views/focus/accelerator_handler.h" #include "ui/views/focus/view_storage.h" +#include "ui/views/focus/widget_focus_manager.h" #include "ui/views/ime/input_method_win.h" #include "ui/views/views_delegate.h" #include "ui/views/widget/aero_tooltip_manager.h" @@ -1332,6 +1333,7 @@ LRESULT NativeWidgetWin::OnCreate(CREATESTRUCT* create_struct) { // Get access to a modifiable copy of the system menu. GetSystemMenu(hwnd(), false); + return 0; } @@ -2255,6 +2257,18 @@ void NativeWidgetWin::PostProcessActivateMessage(NativeWidgetWin* widget, widget->restore_focus_when_enabled_ = true; return; } + + // Mysteriously, this only appears to be needed support restoration of focus + // to a child hwnd when restoring its top level window from the minimized + // state. If we don't do this, then ::SetFocus() to that child HWND returns + // ERROR_INVALID_PARAMETER, despite both HWNDs being of the same thread. + // See http://crbug.com/125976 + { + // Since this is a synthetic reset, we don't need to tell anyone about it. + AutoNativeNotificationDisabler disabler; + focus_manager->ClearFocus(); + } + focus_manager->RestoreFocusedView(); } } |