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

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

Issue 2729133005: Fix: Cursor missing in omnibox after entering a alphabet in NTP 'Search box' (Closed)
Patch Set: address comments 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
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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 views::Textfield* omnibox_textfield() { return omnibox_view(); } 176 views::Textfield* omnibox_textfield() { return omnibox_view(); }
177 ui::TextEditCommand scheduled_text_edit_command() const { 177 ui::TextEditCommand scheduled_text_edit_command() const {
178 return test_api_->scheduled_text_edit_command(); 178 return test_api_->scheduled_text_edit_command();
179 } 179 }
180 180
181 // Sets |new_text| as the omnibox text, and emphasizes it appropriately. If 181 // Sets |new_text| as the omnibox text, and emphasizes it appropriately. If
182 // |accept_input| is true, pretends that the user has accepted this input 182 // |accept_input| is true, pretends that the user has accepted this input
183 // (i.e. it's been navigated to). 183 // (i.e. it's been navigated to).
184 void SetAndEmphasizeText(const std::string& new_text, bool accept_input); 184 void SetAndEmphasizeText(const std::string& new_text, bool accept_input);
185 185
186 bool IsCursorEnabled() const {
187 return test_api_->GetRenderText()->cursor_enabled();
188 }
189
186 private: 190 private:
187 // testing::Test: 191 // testing::Test:
188 void SetUp() override; 192 void SetUp() override;
189 void TearDown() override; 193 void TearDown() override;
190 194
191 content::TestBrowserThreadBundle thread_bundle_; 195 content::TestBrowserThreadBundle thread_bundle_;
192 TestingProfile profile_; 196 TestingProfile profile_;
193 TemplateURLServiceFactoryTestUtil util_; 197 TemplateURLServiceFactoryTestUtil util_;
194 CommandUpdater command_updater_; 198 CommandUpdater command_updater_;
195 TestToolbarModel toolbar_model_; 199 TestToolbarModel toolbar_model_;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 omnibox_textfield()->InsertChar(char_event); 263 omnibox_textfield()->InsertChar(char_event);
260 omnibox_view()->CheckUpdatePopupCallInfo(2, base::ASCIIToUTF16("ab"), 264 omnibox_view()->CheckUpdatePopupCallInfo(2, base::ASCIIToUTF16("ab"),
261 Range(2)); 265 Range(2));
262 266
263 ui::KeyEvent pressed(ui::ET_KEY_PRESSED, ui::VKEY_BACK, 0); 267 ui::KeyEvent pressed(ui::ET_KEY_PRESSED, ui::VKEY_BACK, 0);
264 omnibox_textfield()->OnKeyEvent(&pressed); 268 omnibox_textfield()->OnKeyEvent(&pressed);
265 omnibox_view()->CheckUpdatePopupCallInfo(3, base::ASCIIToUTF16("a"), 269 omnibox_view()->CheckUpdatePopupCallInfo(3, base::ASCIIToUTF16("a"),
266 Range(1)); 270 Range(1));
267 } 271 }
268 272
273 // Checks that if the text cursor is set to enabled after inserting a single
msw 2017/03/10 21:04:30 nit: no 'if'; cite the bug (and relation to the fa
yiyix 2017/03/13 04:02:16 Done.
274 // char to the omnibox.
275 TEST_F(OmniboxViewViewsTest, EditTextfield) {
276 omnibox_textfield()->SetCursorEnabled(false);
277 ui::KeyEvent char_event(ui::ET_KEY_PRESSED, ui::VKEY_A, ui::DomCode::US_A, 0,
278 ui::DomKey::FromCharacter('a'),
279 ui::EventTimeForNow());
280 omnibox_textfield()->InsertChar(char_event);
msw 2017/03/10 21:04:30 Should this also have a test for pasting, like the
yiyix 2017/03/13 04:02:16 With the old approach, paste and insert char uses
281 EXPECT_TRUE(IsCursorEnabled());
282 }
283
269 // Test that the scheduled text edit command is cleared when Textfield receives 284 // Test that the scheduled text edit command is cleared when Textfield receives
270 // a key press event. This ensures that the scheduled text edit command property 285 // a key press event. This ensures that the scheduled text edit command property
271 // is always in the correct state. Test for http://crbug.com/613948. 286 // is always in the correct state. Test for http://crbug.com/613948.
272 TEST_F(OmniboxViewViewsTest, ScheduledTextEditCommand) { 287 TEST_F(OmniboxViewViewsTest, ScheduledTextEditCommand) {
273 omnibox_textfield()->SetTextEditCommandForNextKeyEvent( 288 omnibox_textfield()->SetTextEditCommandForNextKeyEvent(
274 ui::TextEditCommand::MOVE_UP); 289 ui::TextEditCommand::MOVE_UP);
275 EXPECT_EQ(ui::TextEditCommand::MOVE_UP, scheduled_text_edit_command()); 290 EXPECT_EQ(ui::TextEditCommand::MOVE_UP, scheduled_text_edit_command());
276 291
277 ui::KeyEvent up_pressed(ui::ET_KEY_PRESSED, ui::VKEY_UP, 0); 292 ui::KeyEvent up_pressed(ui::ET_KEY_PRESSED, ui::VKEY_UP, 0);
278 omnibox_textfield()->OnKeyEvent(&up_pressed); 293 omnibox_textfield()->OnKeyEvent(&up_pressed);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 EXPECT_EQ(TestingOmniboxView::to_base_text_emphasis( 333 EXPECT_EQ(TestingOmniboxView::to_base_text_emphasis(
319 test_case.expected_base_text_emphasized), 334 test_case.expected_base_text_emphasized),
320 omnibox_view()->base_text_emphasis()); 335 omnibox_view()->base_text_emphasis());
321 EXPECT_EQ(test_case.expected_emphasis_range, 336 EXPECT_EQ(test_case.expected_emphasis_range,
322 omnibox_view()->emphasis_range()); 337 omnibox_view()->emphasis_range());
323 EXPECT_EQ(test_case.expected_scheme_range, 338 EXPECT_EQ(test_case.expected_scheme_range,
324 omnibox_view()->scheme_range()); 339 omnibox_view()->scheme_range());
325 } 340 }
326 } 341 }
327 } 342 }
OLDNEW
« no previous file with comments | « no previous file | ui/views/controls/textfield/textfield.h » ('j') | ui/views/controls/textfield/textfield.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698