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

Side by Side Diff: chrome/browser/ui/views/omnibox/omnibox_view_views_unittest.cc

Issue 2754633002: Fix: Cursor missing in omnibox after entering a alphabet in NTP 'Search box' (Closed)
Patch Set: Created 3 years, 9 months 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
« no previous file with comments | « no previous file | ui/views/controls/textfield/textfield.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2015 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 "chrome/browser/ui/views/omnibox/omnibox_view_views.h" 5 #include "chrome/browser/ui/views/omnibox/omnibox_view_views.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 10
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 142
143 ui::TextEditCommand scheduled_text_edit_command() const { 143 ui::TextEditCommand scheduled_text_edit_command() const {
144 return test_api_->scheduled_text_edit_command(); 144 return test_api_->scheduled_text_edit_command();
145 } 145 }
146 146
147 void SetAndEmphasizeText(const std::string& new_text) { 147 void SetAndEmphasizeText(const std::string& new_text) {
148 omnibox_textfield()->SetText(base::ASCIIToUTF16(new_text)); 148 omnibox_textfield()->SetText(base::ASCIIToUTF16(new_text));
149 omnibox_view()->EmphasizeURLComponents(); 149 omnibox_view()->EmphasizeURLComponents();
150 } 150 }
151 151
152 bool IsCursorEnabled() const {
153 return test_api_->GetRenderText()->cursor_enabled();
154 }
155
152 private: 156 private:
153 // testing::Test: 157 // testing::Test:
154 void SetUp() override { 158 void SetUp() override {
155 #if defined(OS_CHROMEOS) 159 #if defined(OS_CHROMEOS)
156 chromeos::input_method::InitializeForTesting( 160 chromeos::input_method::InitializeForTesting(
157 new chromeos::input_method::MockInputMethodManagerImpl); 161 new chromeos::input_method::MockInputMethodManagerImpl);
158 #endif 162 #endif
159 omnibox_view_.reset(new TestingOmniboxViewViews( 163 omnibox_view_.reset(new TestingOmniboxViewViews(
160 &omnibox_edit_controller_, &profile_, &command_updater_)); 164 &omnibox_edit_controller_, &profile_, &command_updater_));
161 test_api_.reset(new views::TextfieldTestApi(omnibox_view_.get())); 165 test_api_.reset(new views::TextfieldTestApi(omnibox_view_.get()));
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 omnibox_textfield()->InsertChar(char_event); 199 omnibox_textfield()->InsertChar(char_event);
196 omnibox_view()->CheckUpdatePopupCallInfo( 200 omnibox_view()->CheckUpdatePopupCallInfo(
197 2, base::ASCIIToUTF16("ab"), gfx::Range(2)); 201 2, base::ASCIIToUTF16("ab"), gfx::Range(2));
198 202
199 ui::KeyEvent pressed(ui::ET_KEY_PRESSED, ui::VKEY_BACK, 0); 203 ui::KeyEvent pressed(ui::ET_KEY_PRESSED, ui::VKEY_BACK, 0);
200 omnibox_textfield()->OnKeyEvent(&pressed); 204 omnibox_textfield()->OnKeyEvent(&pressed);
201 omnibox_view()->CheckUpdatePopupCallInfo( 205 omnibox_view()->CheckUpdatePopupCallInfo(
202 3, base::ASCIIToUTF16("a"), gfx::Range(1)); 206 3, base::ASCIIToUTF16("a"), gfx::Range(1));
203 } 207 }
204 208
209 // Test that text cursor is shown in the omnibox after entering any single
210 // character in NTP 'Search box'. Test for crbug.com/698172.
211 TEST_F(OmniboxViewViewsTest, EditTextfield) {
212 omnibox_textfield()->SetCursorEnabled(false);
213 ui::KeyEvent char_event(ui::ET_KEY_PRESSED, ui::VKEY_A, ui::DomCode::US_A, 0,
214 ui::DomKey::FromCharacter('a'),
215 ui::EventTimeForNow());
216 omnibox_textfield()->InsertChar(char_event);
217 EXPECT_TRUE(IsCursorEnabled());
218 }
219
205 // Test that the scheduled text edit command is cleared when Textfield receives 220 // Test that the scheduled text edit command is cleared when Textfield receives
206 // a key press event. This ensures that the scheduled text edit command property 221 // a key press event. This ensures that the scheduled text edit command property
207 // is always in the correct state. Test for http://crbug.com/613948. 222 // is always in the correct state. Test for http://crbug.com/613948.
208 TEST_F(OmniboxViewViewsTest, ScheduledTextEditCommand) { 223 TEST_F(OmniboxViewViewsTest, ScheduledTextEditCommand) {
209 omnibox_textfield()->SetTextEditCommandForNextKeyEvent( 224 omnibox_textfield()->SetTextEditCommandForNextKeyEvent(
210 ui::TextEditCommand::MOVE_UP); 225 ui::TextEditCommand::MOVE_UP);
211 EXPECT_EQ(ui::TextEditCommand::MOVE_UP, scheduled_text_edit_command()); 226 EXPECT_EQ(ui::TextEditCommand::MOVE_UP, scheduled_text_edit_command());
212 227
213 ui::KeyEvent up_pressed(ui::ET_KEY_PRESSED, ui::VKEY_UP, 0); 228 ui::KeyEvent up_pressed(ui::ET_KEY_PRESSED, ui::VKEY_UP, 0);
214 omnibox_textfield()->OnKeyEvent(&up_pressed); 229 omnibox_textfield()->OnKeyEvent(&up_pressed);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 } 288 }
274 289
275 // Ensure that everything is emphasized for plain text. 290 // Ensure that everything is emphasized for plain text.
276 TEST_F(OmniboxViewViewsTest, TestEmphasisForNonURLs) { 291 TEST_F(OmniboxViewViewsTest, TestEmphasisForNonURLs) {
277 SetAndEmphasizeText("This is plain text"); 292 SetAndEmphasizeText("This is plain text");
278 293
279 EXPECT_EQ(gfx::Range(), omnibox_view()->scheme_range()); 294 EXPECT_EQ(gfx::Range(), omnibox_view()->scheme_range());
280 EXPECT_TRUE(omnibox_view()->base_text_is_emphasized()); 295 EXPECT_TRUE(omnibox_view()->base_text_is_emphasized());
281 EXPECT_EQ(gfx::Range(), omnibox_view()->emphasis_range()); 296 EXPECT_EQ(gfx::Range(), omnibox_view()->emphasis_range());
282 } 297 }
OLDNEW
« no previous file with comments | « no previous file | ui/views/controls/textfield/textfield.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698