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

Side by Side Diff: ui/views/controls/textfield/textfield_unittest.cc

Issue 700563002: Implementing directional text selection handles (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@new_assets_text
Patch Set: Some test cleanup Created 6 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 unified diff | Download patch
OLDNEW
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
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
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 aura::client::SetScreenPositionClient(GetContext(),
sky 2014/11/14 02:02:47 If the aura usesage.
mfomitchev 2014/11/14 19:56:27 Done.
166 &screen_position_client_);
167 }
168
162 void TearDown() override { 169 void TearDown() override {
163 if (widget_) 170 if (widget_)
164 widget_->Close(); 171 widget_->Close();
165 ViewsTestBase::TearDown(); 172 ViewsTestBase::TearDown();
166 } 173 }
167 174
168 ui::ClipboardType GetAndResetCopiedToClipboard() { 175 ui::ClipboardType GetAndResetCopiedToClipboard() {
169 ui::ClipboardType clipboard_type = copied_to_clipboard_; 176 ui::ClipboardType clipboard_type = copied_to_clipboard_;
170 copied_to_clipboard_ = ui::CLIPBOARD_TYPE_LAST; 177 copied_to_clipboard_ = ui::CLIPBOARD_TYPE_LAST;
171 return clipboard_type; 178 return clipboard_type;
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 MockInputMethod* input_method_; 375 MockInputMethod* input_method_;
369 376
370 // Indicates how many times OnBeforeUserAction() is called. 377 // Indicates how many times OnBeforeUserAction() is called.
371 int on_before_user_action_; 378 int on_before_user_action_;
372 379
373 // Indicates how many times OnAfterUserAction() is called. 380 // Indicates how many times OnAfterUserAction() is called.
374 int on_after_user_action_; 381 int on_after_user_action_;
375 382
376 private: 383 private:
377 ui::ClipboardType copied_to_clipboard_; 384 ui::ClipboardType copied_to_clipboard_;
385 wm::DefaultScreenPositionClient screen_position_client_;
378 386
379 DISALLOW_COPY_AND_ASSIGN(TextfieldTest); 387 DISALLOW_COPY_AND_ASSIGN(TextfieldTest);
380 }; 388 };
381 389
382 TEST_F(TextfieldTest, ModelChangesTest) { 390 TEST_F(TextfieldTest, ModelChangesTest) {
383 InitTextfield(); 391 InitTextfield();
384 392
385 // TextfieldController::ContentsChanged() shouldn't be called when changing 393 // TextfieldController::ContentsChanged() shouldn't be called when changing
386 // text programmatically. 394 // text programmatically.
387 last_contents_.clear(); 395 last_contents_.clear();
(...skipping 1672 matching lines...) Expand 10 before | Expand all | Expand 10 after
2060 TextfieldDestroyerController controller(textfield_); 2068 TextfieldDestroyerController controller(textfield_);
2061 EXPECT_TRUE(controller.target()); 2069 EXPECT_TRUE(controller.target());
2062 2070
2063 // Send a key to trigger OnKeyEvent(). 2071 // Send a key to trigger OnKeyEvent().
2064 SendKeyEvent('X'); 2072 SendKeyEvent('X');
2065 2073
2066 EXPECT_FALSE(controller.target()); 2074 EXPECT_FALSE(controller.target());
2067 } 2075 }
2068 2076
2069 } // namespace views 2077 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698