OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ui/views/controls/textfield/textfield.h" | 5 #include "ui/views/controls/textfield/textfield.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 13 matching lines...) Expand all Loading... |
24 #include "ui/gfx/render_text.h" | 24 #include "ui/gfx/render_text.h" |
25 #include "ui/strings/grit/ui_strings.h" | 25 #include "ui/strings/grit/ui_strings.h" |
26 #include "ui/views/controls/textfield/textfield_controller.h" | 26 #include "ui/views/controls/textfield/textfield_controller.h" |
27 #include "ui/views/controls/textfield/textfield_model.h" | 27 #include "ui/views/controls/textfield/textfield_model.h" |
28 #include "ui/views/controls/textfield/textfield_test_api.h" | 28 #include "ui/views/controls/textfield/textfield_test_api.h" |
29 #include "ui/views/focus/focus_manager.h" | 29 #include "ui/views/focus/focus_manager.h" |
30 #include "ui/views/ime/mock_input_method.h" | 30 #include "ui/views/ime/mock_input_method.h" |
31 #include "ui/views/test/test_views_delegate.h" | 31 #include "ui/views/test/test_views_delegate.h" |
32 #include "ui/views/test/views_test_base.h" | 32 #include "ui/views/test/views_test_base.h" |
33 #include "ui/views/widget/widget.h" | 33 #include "ui/views/widget/widget.h" |
| 34 #include "ui/wm/core/default_screen_position_client.h" |
34 #include "url/gurl.h" | 35 #include "url/gurl.h" |
35 | 36 |
36 #if defined(OS_WIN) | 37 #if defined(OS_WIN) |
37 #include "base/win/windows_version.h" | 38 #include "base/win/windows_version.h" |
38 #endif | 39 #endif |
39 | 40 |
40 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 41 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
41 #include "ui/events/linux/text_edit_key_bindings_delegate_auralinux.h" | 42 #include "ui/events/linux/text_edit_key_bindings_delegate_auralinux.h" |
42 #endif | 43 #endif |
43 | 44 |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 : widget_(NULL), | 153 : widget_(NULL), |
153 textfield_(NULL), | 154 textfield_(NULL), |
154 model_(NULL), | 155 model_(NULL), |
155 input_method_(NULL), | 156 input_method_(NULL), |
156 on_before_user_action_(0), | 157 on_before_user_action_(0), |
157 on_after_user_action_(0), | 158 on_after_user_action_(0), |
158 copied_to_clipboard_(ui::CLIPBOARD_TYPE_LAST) { | 159 copied_to_clipboard_(ui::CLIPBOARD_TYPE_LAST) { |
159 } | 160 } |
160 | 161 |
161 // ::testing::Test: | 162 // ::testing::Test: |
| 163 void SetUp() override { |
| 164 ViewsTestBase::SetUp(); |
| 165 #if defined(USE_AURA) |
| 166 aura::client::SetScreenPositionClient(GetContext(), |
| 167 &screen_position_client_); |
| 168 #endif // !defined(USE_AURA) |
| 169 } |
| 170 |
162 void TearDown() override { | 171 void TearDown() override { |
163 if (widget_) | 172 if (widget_) |
164 widget_->Close(); | 173 widget_->Close(); |
165 ViewsTestBase::TearDown(); | 174 ViewsTestBase::TearDown(); |
166 } | 175 } |
167 | 176 |
168 ui::ClipboardType GetAndResetCopiedToClipboard() { | 177 ui::ClipboardType GetAndResetCopiedToClipboard() { |
169 ui::ClipboardType clipboard_type = copied_to_clipboard_; | 178 ui::ClipboardType clipboard_type = copied_to_clipboard_; |
170 copied_to_clipboard_ = ui::CLIPBOARD_TYPE_LAST; | 179 copied_to_clipboard_ = ui::CLIPBOARD_TYPE_LAST; |
171 return clipboard_type; | 180 return clipboard_type; |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 MockInputMethod* input_method_; | 377 MockInputMethod* input_method_; |
369 | 378 |
370 // Indicates how many times OnBeforeUserAction() is called. | 379 // Indicates how many times OnBeforeUserAction() is called. |
371 int on_before_user_action_; | 380 int on_before_user_action_; |
372 | 381 |
373 // Indicates how many times OnAfterUserAction() is called. | 382 // Indicates how many times OnAfterUserAction() is called. |
374 int on_after_user_action_; | 383 int on_after_user_action_; |
375 | 384 |
376 private: | 385 private: |
377 ui::ClipboardType copied_to_clipboard_; | 386 ui::ClipboardType copied_to_clipboard_; |
| 387 wm::DefaultScreenPositionClient screen_position_client_; |
378 | 388 |
379 DISALLOW_COPY_AND_ASSIGN(TextfieldTest); | 389 DISALLOW_COPY_AND_ASSIGN(TextfieldTest); |
380 }; | 390 }; |
381 | 391 |
382 TEST_F(TextfieldTest, ModelChangesTest) { | 392 TEST_F(TextfieldTest, ModelChangesTest) { |
383 InitTextfield(); | 393 InitTextfield(); |
384 | 394 |
385 // TextfieldController::ContentsChanged() shouldn't be called when changing | 395 // TextfieldController::ContentsChanged() shouldn't be called when changing |
386 // text programmatically. | 396 // text programmatically. |
387 last_contents_.clear(); | 397 last_contents_.clear(); |
(...skipping 1672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2060 TextfieldDestroyerController controller(textfield_); | 2070 TextfieldDestroyerController controller(textfield_); |
2061 EXPECT_TRUE(controller.target()); | 2071 EXPECT_TRUE(controller.target()); |
2062 | 2072 |
2063 // Send a key to trigger OnKeyEvent(). | 2073 // Send a key to trigger OnKeyEvent(). |
2064 SendKeyEvent('X'); | 2074 SendKeyEvent('X'); |
2065 | 2075 |
2066 EXPECT_FALSE(controller.target()); | 2076 EXPECT_FALSE(controller.target()); |
2067 } | 2077 } |
2068 | 2078 |
2069 } // namespace views | 2079 } // namespace views |
OLD | NEW |