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

Side by Side Diff: components/omnibox/browser/omnibox_edit_unittest.cc

Issue 1855423003: Interpret '?' and Ctrl-K or Ctrl-E as putting omnibox in keyword search mode for Default Search Pro… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add includes for mac tests Created 4 years, 6 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 void SetUserText(const base::string16& text, 44 void SetUserText(const base::string16& text,
45 bool update_popup) override { 45 bool update_popup) override {
46 text_ = text; 46 text_ = text;
47 } 47 }
48 void SetWindowTextAndCaretPos(const base::string16& text, 48 void SetWindowTextAndCaretPos(const base::string16& text,
49 size_t caret_pos, 49 size_t caret_pos,
50 bool update_popup, 50 bool update_popup,
51 bool notify_text_changed) override { 51 bool notify_text_changed) override {
52 text_ = text; 52 text_ = text;
53 } 53 }
54 void SetForcedQuery() override {} 54 void EnterKeywordModeForDefaultSearchProvider() override {}
55 bool IsSelectAll() const override { return false; } 55 bool IsSelectAll() const override { return false; }
56 bool DeleteAtEndPressed() override { return false; } 56 bool DeleteAtEndPressed() override { return false; }
57 void GetSelectionBounds(size_t* start, size_t* end) const override {} 57 void GetSelectionBounds(size_t* start, size_t* end) const override {}
58 void SelectAll(bool reversed) override {} 58 void SelectAll(bool reversed) override {}
59 void RevertAll() override {} 59 void RevertAll() override {}
60 void UpdatePopup() override {} 60 void UpdatePopup() override {}
61 void SetFocus() override {} 61 void SetFocus() override {}
62 void ApplyCaretVisibility() override {} 62 void ApplyCaretVisibility() override {}
63 void OnTemporaryTextMaybeChanged(const base::string16& display_text, 63 void OnTemporaryTextMaybeChanged(const base::string16& display_text,
64 bool save_original_selection, 64 bool save_original_selection,
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 OmniboxEditModel model(&view, &controller, 337 OmniboxEditModel model(&view, &controller,
338 base::WrapUnique(new TestingOmniboxClient())); 338 base::WrapUnique(new TestingOmniboxClient()));
339 339
340 // Test if the model updates the inline autocomplete text in the view. 340 // Test if the model updates the inline autocomplete text in the view.
341 EXPECT_EQ(base::string16(), view.inline_autocomplete_text()); 341 EXPECT_EQ(base::string16(), view.inline_autocomplete_text());
342 model.SetUserText(UTF8ToUTF16("he")); 342 model.SetUserText(UTF8ToUTF16("he"));
343 model.OnPopupDataChanged(UTF8ToUTF16("llo"), NULL, base::string16(), false); 343 model.OnPopupDataChanged(UTF8ToUTF16("llo"), NULL, base::string16(), false);
344 EXPECT_EQ(UTF8ToUTF16("hello"), view.GetText()); 344 EXPECT_EQ(UTF8ToUTF16("hello"), view.GetText());
345 EXPECT_EQ(UTF8ToUTF16("llo"), view.inline_autocomplete_text()); 345 EXPECT_EQ(UTF8ToUTF16("llo"), view.inline_autocomplete_text());
346 346
347 model.OnAfterPossibleChange(UTF8ToUTF16("he"), UTF8ToUTF16("hel"), 3, 3, 347 base::string16 text_before = UTF8ToUTF16("he");
348 false, true, false, true); 348 base::string16 text_after = UTF8ToUTF16("hel");
349 OmniboxView::StateChanges state_changes{
350 &text_before, &text_after, 3, 3, false, true, false, false};
351 model.OnAfterPossibleChange(state_changes, true);
349 EXPECT_EQ(base::string16(), view.inline_autocomplete_text()); 352 EXPECT_EQ(base::string16(), view.inline_autocomplete_text());
350 model.OnPopupDataChanged(UTF8ToUTF16("lo"), NULL, base::string16(), false); 353 model.OnPopupDataChanged(UTF8ToUTF16("lo"), NULL, base::string16(), false);
351 EXPECT_EQ(UTF8ToUTF16("hello"), view.GetText()); 354 EXPECT_EQ(UTF8ToUTF16("hello"), view.GetText());
352 EXPECT_EQ(UTF8ToUTF16("lo"), view.inline_autocomplete_text()); 355 EXPECT_EQ(UTF8ToUTF16("lo"), view.inline_autocomplete_text());
353 356
354 model.Revert(); 357 model.Revert();
355 EXPECT_EQ(base::string16(), view.GetText()); 358 EXPECT_EQ(base::string16(), view.GetText());
356 EXPECT_EQ(base::string16(), view.inline_autocomplete_text()); 359 EXPECT_EQ(base::string16(), view.inline_autocomplete_text());
357 360
358 model.SetUserText(UTF8ToUTF16("he")); 361 model.SetUserText(UTF8ToUTF16("he"));
359 model.OnPopupDataChanged(UTF8ToUTF16("llo"), NULL, base::string16(), false); 362 model.OnPopupDataChanged(UTF8ToUTF16("llo"), NULL, base::string16(), false);
360 EXPECT_EQ(UTF8ToUTF16("hello"), view.GetText()); 363 EXPECT_EQ(UTF8ToUTF16("hello"), view.GetText());
361 EXPECT_EQ(UTF8ToUTF16("llo"), view.inline_autocomplete_text()); 364 EXPECT_EQ(UTF8ToUTF16("llo"), view.inline_autocomplete_text());
362 365
363 model.AcceptTemporaryTextAsUserText(); 366 model.AcceptTemporaryTextAsUserText();
364 EXPECT_EQ(UTF8ToUTF16("hello"), view.GetText()); 367 EXPECT_EQ(UTF8ToUTF16("hello"), view.GetText());
365 EXPECT_EQ(base::string16(), view.inline_autocomplete_text()); 368 EXPECT_EQ(base::string16(), view.inline_autocomplete_text());
366 } 369 }
OLDNEW
« no previous file with comments | « components/omnibox/browser/omnibox_edit_model.cc ('k') | components/omnibox/browser/omnibox_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698