Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(249)

Unified Diff: views/controls/textfield/textfield_unittest.cc

Issue 8368016: Rebase BookmarkBubble on the new views bubble. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Anchor by View instead of Point, tweak select_on_focus, add TextfieldTest. Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698