| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "base/utf_string_conversions.h" |
| 6 #include "views/controls/textfield/textfield.h" |
| 7 #include "views/test/views_test_base.h" |
| 8 #include "views/widget/widget.h" |
| 9 |
| 10 namespace views { |
| 11 |
| 12 namespace { |
| 13 |
| 14 typedef ViewsTestBase TextfieldTest; |
| 15 |
| 16 TEST_F(TextfieldTest, SelectAllOnFocus) { |
| 17 Widget* widget_ = new Widget; |
| 18 Widget::InitParams params(Widget::InitParams::TYPE_WINDOW); |
| 19 widget_->Init(params); |
| 20 Textfield* textfield = new Textfield(); |
| 21 textfield->SetText(UTF8ToUTF16("Test")); |
| 22 widget_->SetContentsView(textfield); |
| 23 |
| 24 const string16 kEmptyString; |
| 25 EXPECT_FALSE(textfield->select_all_on_focus()); |
| 26 EXPECT_EQ(kEmptyString, textfield->GetSelectedText()); |
| 27 textfield->RequestFocus(); |
| 28 EXPECT_EQ(kEmptyString, textfield->GetSelectedText()); |
| 29 |
| 30 textfield->set_select_all_on_focus(true); |
| 31 textfield->OnFocus(); |
| 32 EXPECT_EQ(textfield->text(), textfield->GetSelectedText()); |
| 33 } |
| 34 |
| 35 } // namespace |
| 36 |
| 37 } // namespace views |
| OLD | NEW |