| Index: views/controls/textfield/textfield_unittest.cc
|
| diff --git a/views/controls/textfield/textfield_unittest.cc b/views/controls/textfield/textfield_unittest.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..4060416363b10c815d944cbe9c856af6a2c8cc5e
|
| --- /dev/null
|
| +++ b/views/controls/textfield/textfield_unittest.cc
|
| @@ -0,0 +1,37 @@
|
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "base/utf_string_conversions.h"
|
| +#include "views/controls/textfield/textfield.h"
|
| +#include "views/test/views_test_base.h"
|
| +#include "views/widget/widget.h"
|
| +
|
| +namespace views {
|
| +
|
| +namespace {
|
| +
|
| +typedef ViewsTestBase TextfieldTest;
|
| +
|
| +TEST_F(TextfieldTest, SelectAllOnFocus) {
|
| + Widget* widget_ = new Widget;
|
| + Widget::InitParams params(Widget::InitParams::TYPE_WINDOW);
|
| + widget_->Init(params);
|
| + Textfield* textfield = new Textfield();
|
| + textfield->SetText(UTF8ToUTF16("Test"));
|
| + widget_->SetContentsView(textfield);
|
| +
|
| + const string16 kEmptyString;
|
| + EXPECT_FALSE(textfield->select_all_on_focus());
|
| + EXPECT_EQ(kEmptyString, textfield->GetSelectedText());
|
| + textfield->RequestFocus();
|
| + EXPECT_EQ(kEmptyString, textfield->GetSelectedText());
|
| +
|
| + textfield->set_select_all_on_focus(true);
|
| + textfield->OnFocus();
|
| + EXPECT_EQ(textfield->text(), textfield->GetSelectedText());
|
| +}
|
| +
|
| +} // namespace
|
| +
|
| +} // namespace views
|
|
|