| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/bind.h" | 6 #include "base/bind.h" |
| 7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
| 8 #include "ui/gfx/native_widget_types.h" | 8 #include "ui/gfx/native_widget_types.h" |
| 9 #include "ui/views/test/widget_test.h" | 9 #include "ui/views/test/widget_test.h" |
| 10 #include "ui/views/widget/widget.h" | 10 #include "ui/views/widget/widget.h" |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 CreateParams(Widget::InitParams::TYPE_WINDOW_FRAMELESS); | 185 CreateParams(Widget::InitParams::TYPE_WINDOW_FRAMELESS); |
| 186 init_params2.bounds = gfx::Rect(0, 0, 200, 200); | 186 init_params2.bounds = gfx::Rect(0, 0, 200, 200); |
| 187 init_params2.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 187 init_params2.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| 188 init_params2.native_widget = new DesktopNativeWidgetAura(&widget2); | 188 init_params2.native_widget = new DesktopNativeWidgetAura(&widget2); |
| 189 widget2.Init(init_params2); | 189 widget2.Init(init_params2); |
| 190 widget2.SetContentsView(contents_view2); | 190 widget2.SetContentsView(contents_view2); |
| 191 widget2.Show(); | 191 widget2.Show(); |
| 192 aura::Window* root_window2 = widget2.GetNativeView()->GetRootWindow(); | 192 aura::Window* root_window2 = widget2.GetNativeView()->GetRootWindow(); |
| 193 contents_view2->RequestFocus(); | 193 contents_view2->RequestFocus(); |
| 194 ::SetActiveWindow( | 194 ::SetActiveWindow( |
| 195 root_window2->GetDispatcher()->host()->GetAcceleratedWidget()); | 195 root_window2->GetHost()->GetAcceleratedWidget()); |
| 196 | 196 |
| 197 aura::client::ActivationClient* activation_client2 = | 197 aura::client::ActivationClient* activation_client2 = |
| 198 aura::client::GetActivationClient(root_window2); | 198 aura::client::GetActivationClient(root_window2); |
| 199 EXPECT_TRUE(activation_client2 != NULL); | 199 EXPECT_TRUE(activation_client2 != NULL); |
| 200 EXPECT_EQ(activation_client2->GetActiveWindow(), widget2.GetNativeView()); | 200 EXPECT_EQ(activation_client2->GetActiveWindow(), widget2.GetNativeView()); |
| 201 EXPECT_EQ(activation_client1->GetActiveWindow(), | 201 EXPECT_EQ(activation_client1->GetActiveWindow(), |
| 202 reinterpret_cast<aura::Window*>(NULL)); | 202 reinterpret_cast<aura::Window*>(NULL)); |
| 203 | 203 |
| 204 // Now set focus back to widget 1 and expect the active window to be its | 204 // Now set focus back to widget 1 and expect the active window to be its |
| 205 // window. | 205 // window. |
| 206 contents_view1->RequestFocus(); | 206 contents_view1->RequestFocus(); |
| 207 ::SetActiveWindow( | 207 ::SetActiveWindow( |
| 208 root_window1->GetDispatcher()->host()->GetAcceleratedWidget()); | 208 root_window1->GetHost()->GetAcceleratedWidget()); |
| 209 EXPECT_EQ(activation_client2->GetActiveWindow(), | 209 EXPECT_EQ(activation_client2->GetActiveWindow(), |
| 210 reinterpret_cast<aura::Window*>(NULL)); | 210 reinterpret_cast<aura::Window*>(NULL)); |
| 211 EXPECT_EQ(activation_client1->GetActiveWindow(), widget1.GetNativeView()); | 211 EXPECT_EQ(activation_client1->GetActiveWindow(), widget1.GetNativeView()); |
| 212 } | 212 } |
| 213 #endif | 213 #endif |
| 214 | 214 |
| 215 TEST_F(WidgetTest, CaptureAutoReset) { | 215 TEST_F(WidgetTest, CaptureAutoReset) { |
| 216 Widget* toplevel = CreateTopLevelFramelessPlatformWidget(); | 216 Widget* toplevel = CreateTopLevelFramelessPlatformWidget(); |
| 217 View* container = new View; | 217 View* container = new View; |
| 218 toplevel->SetContentsView(container); | 218 toplevel->SetContentsView(container); |
| (...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 771 EXPECT_FALSE(widget1.HasCapture()); | 771 EXPECT_FALSE(widget1.HasCapture()); |
| 772 EXPECT_TRUE(widget2.HasCapture()); | 772 EXPECT_TRUE(widget2.HasCapture()); |
| 773 | 773 |
| 774 widget1.GetAndClearGotMouseEvent(); | 774 widget1.GetAndClearGotMouseEvent(); |
| 775 widget2.GetAndClearGotMouseEvent(); | 775 widget2.GetAndClearGotMouseEvent(); |
| 776 // Send a mouse event to the RootWindow associated with |widget1|. Even though | 776 // Send a mouse event to the RootWindow associated with |widget1|. Even though |
| 777 // |widget2| has capture, |widget1| should still get the event. | 777 // |widget2| has capture, |widget1| should still get the event. |
| 778 ui::MouseEvent mouse_event(ui::ET_MOUSE_EXITED, gfx::Point(), gfx::Point(), | 778 ui::MouseEvent mouse_event(ui::ET_MOUSE_EXITED, gfx::Point(), gfx::Point(), |
| 779 ui::EF_NONE, ui::EF_NONE); | 779 ui::EF_NONE, ui::EF_NONE); |
| 780 ui::EventDispatchDetails details = widget1.GetNativeWindow()-> | 780 ui::EventDispatchDetails details = widget1.GetNativeWindow()-> |
| 781 GetDispatcher()->OnEventFromSource(&mouse_event); | 781 GetHost()->dispatcher()->OnEventFromSource(&mouse_event); |
| 782 ASSERT_FALSE(details.dispatcher_destroyed); | 782 ASSERT_FALSE(details.dispatcher_destroyed); |
| 783 EXPECT_TRUE(widget1.GetAndClearGotMouseEvent()); | 783 EXPECT_TRUE(widget1.GetAndClearGotMouseEvent()); |
| 784 EXPECT_FALSE(widget2.GetAndClearGotMouseEvent()); | 784 EXPECT_FALSE(widget2.GetAndClearGotMouseEvent()); |
| 785 } | 785 } |
| 786 #endif | 786 #endif |
| 787 | 787 |
| 788 } // namespace test | 788 } // namespace test |
| 789 } // namespace views | 789 } // namespace views |
| OLD | NEW |