| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ui/views/controls/textfield/textfield.h" | 5 #include "ui/views/controls/textfield/textfield.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 658 | 658 |
| 659 // Test if clicking on textfield view sets the focus. | 659 // Test if clicking on textfield view sets the focus. |
| 660 widget_->GetFocusManager()->AdvanceFocus(true); | 660 widget_->GetFocusManager()->AdvanceFocus(true); |
| 661 EXPECT_EQ(3, GetFocusedView()->id()); | 661 EXPECT_EQ(3, GetFocusedView()->id()); |
| 662 ui::MouseEvent click(ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(), | 662 ui::MouseEvent click(ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(), |
| 663 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); | 663 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); |
| 664 textfield_->OnMousePressed(click); | 664 textfield_->OnMousePressed(click); |
| 665 EXPECT_EQ(1, GetFocusedView()->id()); | 665 EXPECT_EQ(1, GetFocusedView()->id()); |
| 666 } | 666 } |
| 667 | 667 |
| 668 // Verify that the text input client properly tracks changing focus between text | |
| 669 // fields. See crbug/365741. | |
| 670 TEST_F(TextfieldTest, TextInputClientFollowsFocusChange) { | |
| 671 InitTextfields(2); | |
| 672 textfield_->RequestFocus(); | |
| 673 | |
| 674 EXPECT_EQ(textfield_, input_method_->GetTextInputClient()); | |
| 675 | |
| 676 widget_->GetFocusManager()->AdvanceFocus(false); | |
| 677 Textfield* second = static_cast<Textfield*>(GetFocusedView()); | |
| 678 EXPECT_EQ(2, second->id()); | |
| 679 EXPECT_EQ(second, input_method_->GetTextInputClient()); | |
| 680 | |
| 681 ui::MouseEvent click(ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(), | |
| 682 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); | |
| 683 textfield_->OnMousePressed(click); | |
| 684 EXPECT_EQ(textfield_, input_method_->GetTextInputClient()); | |
| 685 | |
| 686 input_method_->Clear(); | |
| 687 | |
| 688 // Verify that blur does not reset text input client if field does not | |
| 689 // have focus. | |
| 690 second->OnBlur(); | |
| 691 EXPECT_FALSE(input_method_->text_input_type_changed()); | |
| 692 // Verify that blur on the focused text field resets the text input client. | |
| 693 textfield_->OnBlur(); | |
| 694 EXPECT_TRUE(input_method_->text_input_type_changed()); | |
| 695 } | |
| 696 | |
| 697 TEST_F(TextfieldTest, ContextMenuDisplayTest) { | 668 TEST_F(TextfieldTest, ContextMenuDisplayTest) { |
| 698 InitTextfield(); | 669 InitTextfield(); |
| 699 EXPECT_TRUE(textfield_->context_menu_controller()); | 670 EXPECT_TRUE(textfield_->context_menu_controller()); |
| 700 textfield_->SetText(ASCIIToUTF16("hello world")); | 671 textfield_->SetText(ASCIIToUTF16("hello world")); |
| 701 ui::Clipboard::GetForCurrentThread()->Clear(ui::CLIPBOARD_TYPE_COPY_PASTE); | 672 ui::Clipboard::GetForCurrentThread()->Clear(ui::CLIPBOARD_TYPE_COPY_PASTE); |
| 702 textfield_->ClearEditHistory(); | 673 textfield_->ClearEditHistory(); |
| 703 EXPECT_TRUE(GetContextMenuModel()); | 674 EXPECT_TRUE(GetContextMenuModel()); |
| 704 VerifyTextfieldContextMenuContents(false, false, GetContextMenuModel()); | 675 VerifyTextfieldContextMenuContents(false, false, GetContextMenuModel()); |
| 705 | 676 |
| 706 textfield_->SelectAll(false); | 677 textfield_->SelectAll(false); |
| (...skipping 1307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2014 // Set text which may fall back to a font which has taller baseline than | 1985 // Set text which may fall back to a font which has taller baseline than |
| 2015 // the default font. | 1986 // the default font. |
| 2016 textfield_->SetText(UTF8ToUTF16("\xE0\xB9\x91")); | 1987 textfield_->SetText(UTF8ToUTF16("\xE0\xB9\x91")); |
| 2017 const int new_baseline = textfield_->GetBaseline(); | 1988 const int new_baseline = textfield_->GetBaseline(); |
| 2018 | 1989 |
| 2019 // Regardless of the text, the baseline must be the same. | 1990 // Regardless of the text, the baseline must be the same. |
| 2020 EXPECT_EQ(new_baseline, old_baseline); | 1991 EXPECT_EQ(new_baseline, old_baseline); |
| 2021 } | 1992 } |
| 2022 | 1993 |
| 2023 } // namespace views | 1994 } // namespace views |
| OLD | NEW |