| 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..ddc1b68e0f23db6aa22d691da755d64df05887a1 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,49 @@ 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();
|
| +
|
| + std::unique_ptr<Widget> widget1(new Widget());
|
| + widget1->Init(params);
|
| + Textfield* textfield1 = new Textfield();
|
| + widget1->GetRootView()->AddChildView(textfield1);
|
| + Textfield* textfield2 = new Textfield();
|
| + widget1->GetRootView()->AddChildView(textfield2);
|
| +
|
| + std::unique_ptr<Widget> widget2(new Widget());
|
| + widget2->Init(params);
|
| + Textfield* textfield3 = new Textfield();
|
| + widget2->GetRootView()->AddChildView(textfield3);
|
| +
|
| + // |widget1| non-active, |widget2| active. |widget1|'s child view
|
| + // should not be able to get IME focus.
|
| + widget2->Activate();
|
| + EXPECT_FALSE(widget1->IsActive());
|
| + EXPECT_TRUE(widget2->IsActive());
|
| + textfield3->RequestFocus();
|
| + EXPECT_TRUE(textfield3->HasFocus());
|
| + EXPECT_FALSE(textfield1->HasFocus());
|
| + EXPECT_FALSE(textfield2->HasFocus());
|
| + textfield1->RequestFocus();
|
| + EXPECT_TRUE(textfield3->HasFocus());
|
| + EXPECT_FALSE(textfield1->HasFocus());
|
| + EXPECT_FALSE(textfield2->HasFocus());
|
| +
|
| + // |widget1| becomes active. Since |textfield1| requests focus when |widget1|
|
| + // is non-active, the focus is stored and will be set when |widget1|
|
| + // is activated.
|
| + widget1->Activate();
|
| + EXPECT_TRUE(widget1->IsActive());
|
| + EXPECT_FALSE(widget2->IsActive());
|
| + EXPECT_TRUE(textfield1->HasFocus());
|
| + EXPECT_FALSE(textfield2->HasFocus());
|
| + EXPECT_FALSE(textfield3->HasFocus());
|
| +}
|
| +
|
| // A WindowObserver that counts kShowStateKey property changes.
|
| class TestWindowObserver : public aura::WindowObserver {
|
| public:
|
|
|