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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
203 widget_ = new Widget(); | 204 widget_ = new Widget(); |
204 Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP); | 205 Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP); |
205 params.bounds = gfx::Rect(100, 100, 100, 100); | 206 params.bounds = gfx::Rect(100, 100, 100, 100); |
206 widget_->Init(params); | 207 widget_->Init(params); |
207 View* container = new View(); | 208 View* container = new View(); |
208 widget_->SetContentsView(container); | 209 widget_->SetContentsView(container); |
209 container->AddChildView(textfield_); | 210 container->AddChildView(textfield_); |
210 textfield_->SetBoundsRect(params.bounds); | 211 textfield_->SetBoundsRect(params.bounds); |
211 textfield_->set_id(1); | 212 textfield_->set_id(1); |
212 test_api_.reset(new TextfieldTestApi(textfield_)); | 213 test_api_.reset(new TextfieldTestApi(textfield_)); |
214 aura::client::SetScreenPositionClient( | |
215 widget_->GetNativeView()->GetRootWindow(), | |
216 &screen_position_client_); | |
mohsen
2014/11/10 22:25:59
Can't this be moved to SetUp(), too?
mfomitchev
2014/11/10 23:07:29
I think the widget's window is also the root windo
mohsen
2014/11/11 01:24:39
I don't think so. You can use GetContext() in SetU
mfomitchev
2014/11/12 18:32:49
Great, good to know, thanks!
| |
213 | 217 |
214 for (int i = 1; i < count; i++) { | 218 for (int i = 1; i < count; i++) { |
215 Textfield* textfield = new Textfield(); | 219 Textfield* textfield = new Textfield(); |
216 container->AddChildView(textfield); | 220 container->AddChildView(textfield); |
217 textfield->set_id(i + 1); | 221 textfield->set_id(i + 1); |
218 } | 222 } |
219 | 223 |
220 model_ = test_api_->model(); | 224 model_ = test_api_->model(); |
221 model_->ClearEditHistory(); | 225 model_->ClearEditHistory(); |
222 | 226 |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
368 MockInputMethod* input_method_; | 372 MockInputMethod* input_method_; |
369 | 373 |
370 // Indicates how many times OnBeforeUserAction() is called. | 374 // Indicates how many times OnBeforeUserAction() is called. |
371 int on_before_user_action_; | 375 int on_before_user_action_; |
372 | 376 |
373 // Indicates how many times OnAfterUserAction() is called. | 377 // Indicates how many times OnAfterUserAction() is called. |
374 int on_after_user_action_; | 378 int on_after_user_action_; |
375 | 379 |
376 private: | 380 private: |
377 ui::ClipboardType copied_to_clipboard_; | 381 ui::ClipboardType copied_to_clipboard_; |
382 wm::DefaultScreenPositionClient screen_position_client_; | |
378 | 383 |
379 DISALLOW_COPY_AND_ASSIGN(TextfieldTest); | 384 DISALLOW_COPY_AND_ASSIGN(TextfieldTest); |
380 }; | 385 }; |
381 | 386 |
382 TEST_F(TextfieldTest, ModelChangesTest) { | 387 TEST_F(TextfieldTest, ModelChangesTest) { |
383 InitTextfield(); | 388 InitTextfield(); |
384 | 389 |
385 // TextfieldController::ContentsChanged() shouldn't be called when changing | 390 // TextfieldController::ContentsChanged() shouldn't be called when changing |
386 // text programmatically. | 391 // text programmatically. |
387 last_contents_.clear(); | 392 last_contents_.clear(); |
(...skipping 1672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2060 TextfieldDestroyerController controller(textfield_); | 2065 TextfieldDestroyerController controller(textfield_); |
2061 EXPECT_TRUE(controller.target()); | 2066 EXPECT_TRUE(controller.target()); |
2062 | 2067 |
2063 // Send a key to trigger OnKeyEvent(). | 2068 // Send a key to trigger OnKeyEvent(). |
2064 SendKeyEvent('X'); | 2069 SendKeyEvent('X'); |
2065 | 2070 |
2066 EXPECT_FALSE(controller.target()); | 2071 EXPECT_FALSE(controller.target()); |
2067 } | 2072 } |
2068 | 2073 |
2069 } // namespace views | 2074 } // namespace views |
OLD | NEW |