Chromium Code Reviews| Index: ui/views/widget/native_widget_aura_unittest.cc |
| diff --git a/ui/views/widget/native_widget_aura_unittest.cc b/ui/views/widget/native_widget_aura_unittest.cc |
| index 2b6469a36d357b39a91e226663d32969d22ba5fc..96942d07b8d33a4d5b62a60f115c3a994dec4054 100644 |
| --- a/ui/views/widget/native_widget_aura_unittest.cc |
| +++ b/ui/views/widget/native_widget_aura_unittest.cc |
| @@ -19,6 +19,7 @@ |
| #include "ui/aura/window_tree_host.h" |
| #include "ui/events/event.h" |
| #include "ui/events/event_utils.h" |
| +#include "ui/views/controls/textfield/textfield.h" |
| #include "ui/views/layout/fill_layout.h" |
| #include "ui/views/test/widget_test.h" |
| #include "ui/views/widget/root_view.h" |
| @@ -150,6 +151,44 @@ TEST_F(NativeWidgetAuraTest, CreateMinimized) { |
| widget->CloseNow(); |
| } |
| +TEST_F(NativeWidgetAuraTest, NonActiveWindowRequestImeFocus) { |
| + Widget::InitParams params(Widget::InitParams::TYPE_WINDOW_FRAMELESS); |
| + params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| + params.parent = nullptr; |
| + params.context = root_window(); |
| + |
| + // |widget1| sets to non-activatable. |
| + std::unique_ptr<Widget> widget1(new Widget()); |
|
sky
2016/10/13 16:21:21
widget1 and widget2 can be defined on the stack (n
Qiang(Joe) Xu
2016/10/14 01:42:39
Done.
|
| + widget1->Init(params); |
| + widget1->widget_delegate()->set_can_activate(false); |
| + Textfield* textfield0 = new Textfield(); |
| + widget1->GetRootView()->AddChildView(textfield0); |
| + Textfield* textfield1 = new Textfield(); |
| + widget1->GetRootView()->AddChildView(textfield1); |
| + |
| + std::unique_ptr<Widget> widget2(new Widget()); |
| + widget2->Init(params); |
| + Textfield* textfield2 = new Textfield(); |
| + widget2->GetRootView()->AddChildView(textfield2); |
| + |
| + textfield2->RequestFocus(); |
|
sky
2016/10/13 16:21:21
Will this trigger activation at the native level?
Qiang(Joe) Xu
2016/10/14 01:42:39
Because I put it in NativeWidgetAuraTest. So it sh
sky
2016/10/14 15:41:36
NativeWidgetAuraTest runs everywhere but mac (mac
Qiang(Joe) Xu
2016/10/19 05:13:52
Since it does cause OnNativeWidgetActivationChange
|
| + EXPECT_TRUE(textfield2->HasFocus()); |
| + EXPECT_FALSE(textfield0->HasFocus()); |
| + EXPECT_FALSE(textfield1->HasFocus()); |
| + textfield0->RequestFocus(); |
| + EXPECT_TRUE(textfield2->HasFocus()); |
| + EXPECT_FALSE(textfield0->HasFocus()); |
| + EXPECT_FALSE(textfield1->HasFocus()); |
| + |
| + // |widget1| sets to activatable. If now there is an Activate() call, focus |
| + // should restore to |textfield0| properly. |
| + widget1->widget_delegate()->set_can_activate(true); |
| + widget1->Activate(); |
| + EXPECT_TRUE(textfield0->HasFocus()); |
| + EXPECT_FALSE(textfield1->HasFocus()); |
| + EXPECT_FALSE(textfield2->HasFocus()); |
| +} |
| + |
| // A WindowObserver that counts kShowStateKey property changes. |
| class TestWindowObserver : public aura::WindowObserver { |
| public: |