diff options
author | jcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-01 18:37:39 +0000 |
---|---|---|
committer | jcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-01 18:37:39 +0000 |
commit | 680ed93e5e315143eb7e7478e21d2080689cbd07 (patch) | |
tree | 314dce7a8f82ba13446de7d30a55393835fca4b6 /views/view_unittest.cc | |
parent | ef610457ca8d0d43594a765e2b1f1ea194c5a591 (diff) | |
download | chromium_src-680ed93e5e315143eb7e7478e21d2080689cbd07.zip chromium_src-680ed93e5e315143eb7e7478e21d2080689cbd07.tar.gz chromium_src-680ed93e5e315143eb7e7478e21d2080689cbd07.tar.bz2 |
Porting textfield to toolkit_views Gtk.
BUG=None
TEST=Run the view unit-tests.
See original review:
http://codereview.chromium.org/165512/show
Review URL: http://codereview.chromium.org/180061
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25063 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/view_unittest.cc')
-rw-r--r-- | views/view_unittest.cc | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/views/view_unittest.cc b/views/view_unittest.cc index 6778135..64b5848 100644 --- a/views/view_unittest.cc +++ b/views/view_unittest.cc @@ -9,6 +9,7 @@ #include "base/clipboard.h" #include "base/keyboard_codes.h" #include "base/message_loop.h" +#include "base/string_util.h" #include "testing/gtest/include/gtest/gtest.h" #include "views/background.h" #include "views/controls/button/checkbox.h" @@ -18,6 +19,7 @@ #include "views/controls/scroll_view.h" #include "views/controls/textfield/textfield.h" #include "views/event.h" +#include "views/focus/accelerator_handler.h" #include "views/focus/view_storage.h" #include "views/view.h" #include "views/views_delegate.h" @@ -26,6 +28,7 @@ #include "views/widget/widget_win.h" #elif defined(OS_LINUX) #include "views/widget/widget_gtk.h" +#include "views/window/window_gtk.h" #endif #include "views/window/dialog_delegate.h" #include "views/window/window.h" @@ -205,7 +208,6 @@ TEST_F(ViewTest, DidChangeBounds) { delete v; } - //////////////////////////////////////////////////////////////////////////////// // AddRemoveNotifications //////////////////////////////////////////////////////////////////////////////// @@ -616,6 +618,42 @@ TEST_F(ViewTest, HitTestMasks) { EXPECT_EQ(root_view, root_view->GetViewForPoint(v2_origin)); } +TEST_F(ViewTest, Textfield) { + const string16 kText = ASCIIToUTF16("Reality is that which, when you stop " + "believing it, doesn't go away."); + const string16 kExtraText = ASCIIToUTF16("Pretty deep, Philip!"); + const string16 kEmptyString; + + Clipboard clipboard; + + Widget* window = CreateWidget(); +#if defined(OS_WIN) + static_cast<WidgetWin*>(window)->Init(NULL, gfx::Rect(0, 0, 100, 100)); +#else + static_cast<WidgetGtk*>(window)->Init(NULL, gfx::Rect(0, 0, 100, 100)); +#endif + RootView* root_view = window->GetRootView(); + + Textfield* textfield = new Textfield(); + root_view->AddChildView(textfield); + + // Test setting, appending text. + textfield->SetText(kText); + EXPECT_EQ(kText, textfield->text()); + textfield->AppendText(kExtraText); + EXPECT_EQ(kText + kExtraText, textfield->text()); + textfield->SetText(string16()); + EXPECT_EQ(kEmptyString, textfield->text()); + + // Test selection related methods. + textfield->SetText(kText); + EXPECT_EQ(kEmptyString, textfield->GetSelectedText()); + textfield->SelectAll(); + EXPECT_EQ(kText, textfield->text()); + textfield->ClearSelection(); + EXPECT_EQ(kEmptyString, textfield->GetSelectedText()); +} + #if defined(OS_WIN) class TestViewsDelegate : public views::ViewsDelegate { public: |