| OLD | NEW |
| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 const base::string16& display_text, | 45 const base::string16& display_text, |
| 46 bool update_popup) override { | 46 bool update_popup) override { |
| 47 text_ = display_text; | 47 text_ = display_text; |
| 48 } | 48 } |
| 49 void SetWindowTextAndCaretPos(const base::string16& text, | 49 void SetWindowTextAndCaretPos(const base::string16& text, |
| 50 size_t caret_pos, | 50 size_t caret_pos, |
| 51 bool update_popup, | 51 bool update_popup, |
| 52 bool notify_text_changed) override { | 52 bool notify_text_changed) override { |
| 53 text_ = text; | 53 text_ = text; |
| 54 } | 54 } |
| 55 void SetForcedQuery() override {} | 55 void SetCaretPos(size_t caret_pos) override {} |
| 56 void EnterKeywordModeForDefaultSearchProvider() override {} |
| 56 bool IsSelectAll() const override { return false; } | 57 bool IsSelectAll() const override { return false; } |
| 57 bool DeleteAtEndPressed() override { return false; } | 58 bool DeleteAtEndPressed() override { return false; } |
| 58 void GetSelectionBounds(size_t* start, size_t* end) const override {} | 59 void GetSelectionBounds(size_t* start, size_t* end) const override {} |
| 59 void SelectAll(bool reversed) override {} | 60 void SelectAll(bool reversed) override {} |
| 60 void RevertAll() override {} | 61 void RevertAll() override {} |
| 61 void UpdatePopup() override {} | 62 void UpdatePopup() override {} |
| 62 void SetFocus() override {} | 63 void SetFocus() override {} |
| 63 void ApplyCaretVisibility() override {} | 64 void ApplyCaretVisibility() override {} |
| 64 void OnTemporaryTextMaybeChanged(const base::string16& display_text, | 65 void OnTemporaryTextMaybeChanged(const base::string16& display_text, |
| 65 bool save_original_selection, | 66 bool save_original_selection, |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 base::WrapUnique(new TestingOmniboxClient())); | 341 base::WrapUnique(new TestingOmniboxClient())); |
| 341 | 342 |
| 342 // Test if the model updates the inline autocomplete text in the view. | 343 // Test if the model updates the inline autocomplete text in the view. |
| 343 EXPECT_EQ(base::string16(), view.inline_autocomplete_text()); | 344 EXPECT_EQ(base::string16(), view.inline_autocomplete_text()); |
| 344 model.SetUserText(UTF8ToUTF16("he")); | 345 model.SetUserText(UTF8ToUTF16("he")); |
| 345 model.OnPopupDataChanged(UTF8ToUTF16("llo"), NULL, base::string16(), false); | 346 model.OnPopupDataChanged(UTF8ToUTF16("llo"), NULL, base::string16(), false); |
| 346 EXPECT_EQ(UTF8ToUTF16("hello"), view.GetText()); | 347 EXPECT_EQ(UTF8ToUTF16("hello"), view.GetText()); |
| 347 EXPECT_EQ(UTF8ToUTF16("llo"), view.inline_autocomplete_text()); | 348 EXPECT_EQ(UTF8ToUTF16("llo"), view.inline_autocomplete_text()); |
| 348 | 349 |
| 349 model.OnAfterPossibleChange(UTF8ToUTF16("he"), UTF8ToUTF16("hel"), 3, 3, | 350 model.OnAfterPossibleChange(UTF8ToUTF16("he"), UTF8ToUTF16("hel"), 3, 3, |
| 350 false, true, false, true); | 351 false, true, false, false, true); |
| 351 EXPECT_EQ(base::string16(), view.inline_autocomplete_text()); | 352 EXPECT_EQ(base::string16(), view.inline_autocomplete_text()); |
| 352 model.OnPopupDataChanged(UTF8ToUTF16("lo"), NULL, base::string16(), false); | 353 model.OnPopupDataChanged(UTF8ToUTF16("lo"), NULL, base::string16(), false); |
| 353 EXPECT_EQ(UTF8ToUTF16("hello"), view.GetText()); | 354 EXPECT_EQ(UTF8ToUTF16("hello"), view.GetText()); |
| 354 EXPECT_EQ(UTF8ToUTF16("lo"), view.inline_autocomplete_text()); | 355 EXPECT_EQ(UTF8ToUTF16("lo"), view.inline_autocomplete_text()); |
| 355 | 356 |
| 356 model.Revert(); | 357 model.Revert(); |
| 357 EXPECT_EQ(base::string16(), view.GetText()); | 358 EXPECT_EQ(base::string16(), view.GetText()); |
| 358 EXPECT_EQ(base::string16(), view.inline_autocomplete_text()); | 359 EXPECT_EQ(base::string16(), view.inline_autocomplete_text()); |
| 359 | 360 |
| 360 model.SetUserText(UTF8ToUTF16("he")); | 361 model.SetUserText(UTF8ToUTF16("he")); |
| 361 model.OnPopupDataChanged(UTF8ToUTF16("llo"), NULL, base::string16(), false); | 362 model.OnPopupDataChanged(UTF8ToUTF16("llo"), NULL, base::string16(), false); |
| 362 EXPECT_EQ(UTF8ToUTF16("hello"), view.GetText()); | 363 EXPECT_EQ(UTF8ToUTF16("hello"), view.GetText()); |
| 363 EXPECT_EQ(UTF8ToUTF16("llo"), view.inline_autocomplete_text()); | 364 EXPECT_EQ(UTF8ToUTF16("llo"), view.inline_autocomplete_text()); |
| 364 | 365 |
| 365 model.AcceptTemporaryTextAsUserText(); | 366 model.AcceptTemporaryTextAsUserText(); |
| 366 EXPECT_EQ(UTF8ToUTF16("hello"), view.GetText()); | 367 EXPECT_EQ(UTF8ToUTF16("hello"), view.GetText()); |
| 367 EXPECT_EQ(base::string16(), view.inline_autocomplete_text()); | 368 EXPECT_EQ(base::string16(), view.inline_autocomplete_text()); |
| 368 } | 369 } |
| OLD | NEW |