| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "app/keyboard_codes.h" | 5 #include "app/keyboard_codes.h" |
| 6 #include "base/message_loop.h" | 6 #include "base/message_loop.h" |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 #include "views/controls/textfield/native_textfield_views.h" | 9 #include "views/controls/textfield/native_textfield_views.h" |
| 10 #include "views/controls/textfield/textfield.h" | 10 #include "views/controls/textfield/textfield.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 if (widget_) | 41 if (widget_) |
| 42 widget_->Close(); | 42 widget_->Close(); |
| 43 } | 43 } |
| 44 | 44 |
| 45 // Textfield::Controller implementation: | 45 // Textfield::Controller implementation: |
| 46 virtual void ContentsChanged(Textfield* sender, | 46 virtual void ContentsChanged(Textfield* sender, |
| 47 const string16& new_contents){ | 47 const string16& new_contents){ |
| 48 last_contents_ = new_contents; | 48 last_contents_ = new_contents; |
| 49 } | 49 } |
| 50 | 50 |
| 51 virtual bool HandleKeystroke(Textfield* sender, | 51 virtual bool HandleKeyEvent(Textfield* sender, |
| 52 const Textfield::Keystroke& keystroke) { | 52 const KeyEvent& key_event) { |
| 53 |
| 53 // TODO(oshima): figure out how to test the keystroke. | 54 // TODO(oshima): figure out how to test the keystroke. |
| 54 return false; | 55 return false; |
| 55 } | 56 } |
| 56 | 57 |
| 57 void InitTextfield(Textfield::StyleFlags style) { | 58 void InitTextfield(Textfield::StyleFlags style) { |
| 58 ASSERT_FALSE(textfield_); | 59 ASSERT_FALSE(textfield_); |
| 59 textfield_ = new Textfield(style); | 60 textfield_ = new Textfield(style); |
| 60 textfield_->SetController(this); | 61 textfield_->SetController(this); |
| 61 widget_ = Widget::CreatePopupWidget( | 62 widget_ = Widget::CreatePopupWidget( |
| 62 Widget::NotTransparent, | 63 Widget::NotTransparent, |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 // Ctrl+Left to move the cursor to the beginning of the first word. | 294 // Ctrl+Left to move the cursor to the beginning of the first word. |
| 294 SendKeyEventToTextfieldViews(app::VKEY_LEFT, false, true); | 295 SendKeyEventToTextfieldViews(app::VKEY_LEFT, false, true); |
| 295 // Ctrl+Left again should move the cursor back to the very beginning. | 296 // Ctrl+Left again should move the cursor back to the very beginning. |
| 296 SendKeyEventToTextfieldViews(app::VKEY_LEFT, false, true); | 297 SendKeyEventToTextfieldViews(app::VKEY_LEFT, false, true); |
| 297 SendKeyEventToTextfieldViews(app::VKEY_DELETE); | 298 SendKeyEventToTextfieldViews(app::VKEY_DELETE); |
| 298 EXPECT_STR_EQ("one two", textfield_->text()); | 299 EXPECT_STR_EQ("one two", textfield_->text()); |
| 299 EXPECT_STR_EQ("one two", last_contents_); | 300 EXPECT_STR_EQ("one two", last_contents_); |
| 300 } | 301 } |
| 301 | 302 |
| 302 } // namespace views | 303 } // namespace views |
| OLD | NEW |