diff options
author | jcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-30 17:41:18 +0000 |
---|---|---|
committer | jcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-30 17:41:18 +0000 |
commit | 5ed0c5ad10a6bca737bddba34f89291884420d0d (patch) | |
tree | 430a0e21138e9a20d7580329cf210fb001b5a22b /views | |
parent | 07b58366b743ec61d1797f719437b456b952349c (diff) | |
download | chromium_src-5ed0c5ad10a6bca737bddba34f89291884420d0d.zip chromium_src-5ed0c5ad10a6bca737bddba34f89291884420d0d.tar.gz chromium_src-5ed0c5ad10a6bca737bddba34f89291884420d0d.tar.bz2 |
Fix for a focus related unit-test on Linux toolkit views.
The problem was caused by the way we were setting the focus,
using grab_focus which does not work whenthe screen is locked.
We now explicitly send a signal.
Also make sure to give a good parent when building a child
GtkWidget, as using the WidgetGtk native window would cause
a Gtk error.
BUG=23394
TEST=Run the unit-tests.
R=oshima
Review URL: http://codereview.chromium.org/242071
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27629 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r-- | views/focus/focus_manager_unittest.cc | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/views/focus/focus_manager_unittest.cc b/views/focus/focus_manager_unittest.cc index 96c025d..a371d2e 100644 --- a/views/focus/focus_manager_unittest.cc +++ b/views/focus/focus_manager_unittest.cc @@ -150,8 +150,15 @@ class FocusManagerTest : public testing::Test, public WindowDelegate { #if defined(OS_WIN) ::SendMessage(native_view, WM_SETFOCUS, NULL, NULL); #else - gtk_widget_grab_focus(native_view); - message_loop()->RunAllPending(); + gint return_val; + GdkEventFocus event; + event.type = GDK_FOCUS_CHANGE; + event.window = + gtk_widget_get_root_window(GTK_WIDGET(window_->GetNativeWindow())); + event.send_event = TRUE; + event.in = TRUE; + gtk_signal_emit_by_name(GTK_OBJECT(native_view), "focus-in-event", + &event, &return_val); #endif } @@ -871,17 +878,11 @@ class NoNativeFocusView : public View { // Tests that the NativeViewHost class sets the focus View appropriately on the // FocusManager. -#if defined(OS_WIN) TEST_F(FocusManagerTest, FocusNativeViewHost) { -#else -// TODO(jcampan): http::/crbug.com/23394 Disabled as it fails following the -// NativeViewHost refactoring. -TEST_F(FocusManagerTest, DISABLED_FocusNativeViewHost) { -#endif { // Test wrapping a simple native view. - gfx::NativeView native_view = - CreateChildNativeView(content_view_->GetWidget()->GetNativeView()); + gfx::NativeView top_native_view = CreateContainerNativeView(); + gfx::NativeView native_view = CreateChildNativeView(top_native_view); NativeViewHost* native_view_host = new NativeViewHost(); content_view_->AddChildView(native_view_host); native_view_host->Attach(native_view); @@ -911,8 +912,8 @@ TEST_F(FocusManagerTest, DISABLED_FocusNativeViewHost) { { // Now also make sure set_focused_view() works. - gfx::NativeView native_view = - CreateChildNativeView(content_view_->GetWidget()->GetNativeView()); + gfx::NativeView top_native_view = CreateContainerNativeView(); + gfx::NativeView native_view = CreateChildNativeView(top_native_view); NativeViewHost* native_view_host = new NativeViewHost(); NoNativeFocusView* container_view = new NoNativeFocusView(); container_view->AddChildView(native_view_host); |