| 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/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| 11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "ui/base/ime/input_method.h" | 12 #include "ui/base/ime/input_method.h" |
| 13 #include "ui/base/ime/text_input_client.h" | 13 #include "ui/base/ime/text_input_client.h" |
| 14 #include "ui/base/resource/resource_bundle.h" | 14 #include "ui/base/resource/resource_bundle.h" |
| 15 #include "ui/base/ui_base_paths.h" | 15 #include "ui/base/ui_base_paths.h" |
| 16 #include "ui/base/ui_base_switches.h" | 16 #include "ui/base/ui_base_switches.h" |
| 17 #include "ui/events/event_processor.h" | 17 #include "ui/events/event_processor.h" |
| 18 #include "ui/events/event_utils.h" | 18 #include "ui/events/event_utils.h" |
| 19 #include "ui/events/test/event_generator.h" | 19 #include "ui/events/test/event_generator.h" |
| 20 #include "ui/gfx/native_widget_types.h" | 20 #include "ui/gfx/native_widget_types.h" |
| 21 #include "ui/gl/gl_surface.h" | 21 #include "ui/gl/gl_surface.h" |
| 22 #include "ui/views/controls/textfield/textfield.h" | 22 #include "ui/views/controls/textfield/textfield.h" |
| 23 #include "ui/views/controls/textfield/textfield_test_api.h" | 23 #include "ui/views/controls/textfield/textfield_test_api.h" |
| 24 #include "ui/views/focus/focus_manager.h" | 24 #include "ui/views/focus/focus_manager.h" |
| 25 #include "ui/views/ime/input_method.h" | |
| 26 #include "ui/views/test/focus_manager_test.h" | 25 #include "ui/views/test/focus_manager_test.h" |
| 27 #include "ui/views/test/widget_test.h" | 26 #include "ui/views/test/widget_test.h" |
| 28 #include "ui/views/touchui/touch_selection_controller_impl.h" | 27 #include "ui/views/touchui/touch_selection_controller_impl.h" |
| 29 #include "ui/views/widget/widget.h" | 28 #include "ui/views/widget/widget.h" |
| 30 #include "ui/views/window/dialog_delegate.h" | 29 #include "ui/views/window/dialog_delegate.h" |
| 31 #include "ui/wm/public/activation_client.h" | 30 #include "ui/wm/public/activation_client.h" |
| 32 | 31 |
| 33 #if defined(OS_WIN) | 32 #if defined(OS_WIN) |
| 34 #include "ui/aura/window.h" | 33 #include "ui/aura/window.h" |
| 35 #include "ui/aura/window_tree_host.h" | 34 #include "ui/aura/window_tree_host.h" |
| (...skipping 1523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1559 parent->GetInputMethod()->GetTextInputType()); | 1558 parent->GetInputMethod()->GetTextInputType()); |
| 1560 | 1559 |
| 1561 ActivateSync(parent); | 1560 ActivateSync(parent); |
| 1562 EXPECT_EQ(ui::TEXT_INPUT_TYPE_PASSWORD, | 1561 EXPECT_EQ(ui::TEXT_INPUT_TYPE_PASSWORD, |
| 1563 parent->GetInputMethod()->GetTextInputType()); | 1562 parent->GetInputMethod()->GetTextInputType()); |
| 1564 #endif | 1563 #endif |
| 1565 | 1564 |
| 1566 parent->CloseNow(); | 1565 parent->CloseNow(); |
| 1567 } | 1566 } |
| 1568 | 1567 |
| 1569 // Test input method focus changes affected by focus changes cross 2 top | |
| 1570 // windows. | |
| 1571 TEST_F(WidgetInputMethodInteractiveTest, TwoTopWindows) { | |
| 1572 Widget* widget1 = CreateWidget(); | |
| 1573 Widget* widget2 = CreateWidget(); | |
| 1574 Textfield* textfield1 = new Textfield; | |
| 1575 Textfield* textfield2 = new Textfield; | |
| 1576 textfield2->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD); | |
| 1577 widget1->GetRootView()->AddChildView(textfield1); | |
| 1578 widget2->GetRootView()->AddChildView(textfield2); | |
| 1579 | |
| 1580 // Do the initial shows synchronously. Otherwise, on X11, the window server | |
| 1581 // messages may be interleaved with the activation requests below. | |
| 1582 ShowSync(widget1); | |
| 1583 ShowSync(widget2); | |
| 1584 | |
| 1585 textfield1->RequestFocus(); | |
| 1586 textfield2->RequestFocus(); | |
| 1587 | |
| 1588 ActivateSync(widget1); | |
| 1589 | |
| 1590 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, | |
| 1591 widget1->GetInputMethod()->GetTextInputType()); | |
| 1592 EXPECT_EQ(ui::TEXT_INPUT_TYPE_NONE, | |
| 1593 widget2->GetInputMethod()->GetTextInputType()); | |
| 1594 | |
| 1595 ActivateSync(widget2); | |
| 1596 | |
| 1597 EXPECT_EQ(ui::TEXT_INPUT_TYPE_NONE, | |
| 1598 widget1->GetInputMethod()->GetTextInputType()); | |
| 1599 EXPECT_EQ(ui::TEXT_INPUT_TYPE_PASSWORD, | |
| 1600 widget2->GetInputMethod()->GetTextInputType()); | |
| 1601 | |
| 1602 widget2->CloseNow(); | |
| 1603 widget1->CloseNow(); | |
| 1604 } | |
| 1605 | |
| 1606 // Test input method focus changes affected by textfield's state changes. | 1568 // Test input method focus changes affected by textfield's state changes. |
| 1607 TEST_F(WidgetInputMethodInteractiveTest, TextField) { | 1569 TEST_F(WidgetInputMethodInteractiveTest, TextField) { |
| 1608 Widget* widget = CreateWidget(); | 1570 Widget* widget = CreateWidget(); |
| 1609 Textfield* textfield = new Textfield; | 1571 Textfield* textfield = new Textfield; |
| 1610 widget->GetRootView()->AddChildView(textfield); | 1572 widget->GetRootView()->AddChildView(textfield); |
| 1611 ShowSync(widget); | 1573 ShowSync(widget); |
| 1612 EXPECT_EQ(ui::TEXT_INPUT_TYPE_NONE, | 1574 EXPECT_EQ(ui::TEXT_INPUT_TYPE_NONE, |
| 1613 widget->GetInputMethod()->GetTextInputType()); | 1575 widget->GetInputMethod()->GetTextInputType()); |
| 1614 | 1576 |
| 1615 textfield->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD); | 1577 textfield->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD); |
| 1616 EXPECT_EQ(ui::TEXT_INPUT_TYPE_NONE, | 1578 EXPECT_EQ(ui::TEXT_INPUT_TYPE_NONE, |
| 1617 widget->GetInputMethod()->GetTextInputType()); | 1579 widget->GetInputMethod()->GetTextInputType()); |
| 1618 | 1580 |
| 1619 textfield->RequestFocus(); | 1581 textfield->RequestFocus(); |
| 1620 EXPECT_EQ(ui::TEXT_INPUT_TYPE_PASSWORD, | 1582 EXPECT_EQ(ui::TEXT_INPUT_TYPE_PASSWORD, |
| 1621 widget->GetInputMethod()->GetTextInputType()); | 1583 widget->GetInputMethod()->GetTextInputType()); |
| 1622 | 1584 |
| 1623 textfield->SetTextInputType(ui::TEXT_INPUT_TYPE_TEXT); | 1585 textfield->SetTextInputType(ui::TEXT_INPUT_TYPE_TEXT); |
| 1624 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, | 1586 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, |
| 1625 widget->GetInputMethod()->GetTextInputType()); | 1587 widget->GetInputMethod()->GetTextInputType()); |
| 1626 | 1588 |
| 1627 textfield->SetReadOnly(true); | 1589 textfield->SetReadOnly(true); |
| 1628 EXPECT_EQ(ui::TEXT_INPUT_TYPE_NONE, | 1590 EXPECT_EQ(ui::TEXT_INPUT_TYPE_NONE, |
| 1629 widget->GetInputMethod()->GetTextInputType()); | 1591 widget->GetInputMethod()->GetTextInputType()); |
| 1630 widget->CloseNow(); | 1592 widget->CloseNow(); |
| 1631 } | 1593 } |
| 1632 | 1594 |
| 1633 } // namespace test | 1595 } // namespace test |
| 1634 } // namespace views | 1596 } // namespace views |
| OLD | NEW |