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 <stdio.h> | 5 #include <stdio.h> |
6 | 6 |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "base/string16.h" | 8 #include "base/string16.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/time.h" | 10 #include "base/time.h" |
(...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
808 | 808 |
809 // Keyword should be accepted by pressing space in the middle of context and | 809 // Keyword should be accepted by pressing space in the middle of context and |
810 // just after the keyword. | 810 // just after the keyword. |
811 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_BACK, 0)); | 811 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_BACK, 0)); |
812 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_A, 0)); | 812 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_A, 0)); |
813 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_LEFT, 0)); | 813 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_LEFT, 0)); |
814 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_SPACE, 0)); | 814 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_SPACE, 0)); |
815 ASSERT_FALSE(omnibox_view->model()->is_keyword_hint()); | 815 ASSERT_FALSE(omnibox_view->model()->is_keyword_hint()); |
816 ASSERT_EQ(search_keyword, omnibox_view->model()->keyword()); | 816 ASSERT_EQ(search_keyword, omnibox_view->model()->keyword()); |
817 ASSERT_EQ(ASCIIToUTF16("a "), omnibox_view->GetText()); | 817 ASSERT_EQ(ASCIIToUTF16("a "), omnibox_view->GetText()); |
| 818 size_t start, end; |
| 819 omnibox_view->GetSelectionBounds(&start, &end); |
| 820 EXPECT_EQ(0U, start); |
| 821 EXPECT_EQ(0U, end); |
818 | 822 |
819 // Keyword shouldn't be accepted by pasting "foo bar". | 823 // Keyword shouldn't be accepted by pasting "foo bar". |
820 omnibox_view->SetUserText(string16()); | 824 omnibox_view->SetUserText(string16()); |
821 ASSERT_FALSE(omnibox_view->model()->is_keyword_hint()); | 825 ASSERT_FALSE(omnibox_view->model()->is_keyword_hint()); |
822 ASSERT_TRUE(omnibox_view->model()->keyword().empty()); | 826 ASSERT_TRUE(omnibox_view->model()->keyword().empty()); |
823 | 827 |
824 omnibox_view->OnBeforePossibleChange(); | 828 omnibox_view->OnBeforePossibleChange(); |
825 omnibox_view->model()->on_paste(); | 829 omnibox_view->model()->on_paste(); |
826 omnibox_view->SetWindowTextAndCaretPos(search_keyword + | 830 omnibox_view->SetWindowTextAndCaretPos(search_keyword + |
827 ASCIIToUTF16(" bar"), search_keyword.length() + 4, false, false); | 831 ASCIIToUTF16(" bar"), search_keyword.length() + 4, false, false); |
(...skipping 13 matching lines...) Expand all Loading... |
841 // Keyword could be accepted by pressing space with a selected range at the | 845 // Keyword could be accepted by pressing space with a selected range at the |
842 // end of text. | 846 // end of text. |
843 omnibox_view->OnBeforePossibleChange(); | 847 omnibox_view->OnBeforePossibleChange(); |
844 omnibox_view->OnInlineAutocompleteTextMaybeChanged( | 848 omnibox_view->OnInlineAutocompleteTextMaybeChanged( |
845 search_keyword + ASCIIToUTF16(" "), search_keyword.length()); | 849 search_keyword + ASCIIToUTF16(" "), search_keyword.length()); |
846 omnibox_view->OnAfterPossibleChange(); | 850 omnibox_view->OnAfterPossibleChange(); |
847 ASSERT_TRUE(omnibox_view->model()->is_keyword_hint()); | 851 ASSERT_TRUE(omnibox_view->model()->is_keyword_hint()); |
848 ASSERT_EQ(search_keyword, omnibox_view->model()->keyword()); | 852 ASSERT_EQ(search_keyword, omnibox_view->model()->keyword()); |
849 ASSERT_EQ(search_keyword + ASCIIToUTF16(" "), omnibox_view->GetText()); | 853 ASSERT_EQ(search_keyword + ASCIIToUTF16(" "), omnibox_view->GetText()); |
850 | 854 |
851 size_t start, end; | |
852 omnibox_view->GetSelectionBounds(&start, &end); | 855 omnibox_view->GetSelectionBounds(&start, &end); |
853 ASSERT_NE(start, end); | 856 ASSERT_NE(start, end); |
854 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_SPACE, 0)); | 857 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_SPACE, 0)); |
855 ASSERT_FALSE(omnibox_view->model()->is_keyword_hint()); | 858 ASSERT_FALSE(omnibox_view->model()->is_keyword_hint()); |
856 ASSERT_EQ(search_keyword, omnibox_view->model()->keyword()); | 859 ASSERT_EQ(search_keyword, omnibox_view->model()->keyword()); |
857 ASSERT_EQ(string16(), omnibox_view->GetText()); | 860 ASSERT_EQ(string16(), omnibox_view->GetText()); |
858 | 861 |
859 // Space should accept keyword even when inline autocomplete is available. | 862 // Space should accept keyword even when inline autocomplete is available. |
860 omnibox_view->SetUserText(string16()); | 863 omnibox_view->SetUserText(string16()); |
861 const TestHistoryEntry kHistoryFoobar = { | 864 const TestHistoryEntry kHistoryFoobar = { |
(...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1665 | 1668 |
1666 // Middle-clicking shouldn't select all the text either. | 1669 // Middle-clicking shouldn't select all the text either. |
1667 ASSERT_NO_FATAL_FAILURE( | 1670 ASSERT_NO_FATAL_FAILURE( |
1668 ClickFocusViewOrigin(ui_controls::LEFT, kClickOffset, kClickOffset)); | 1671 ClickFocusViewOrigin(ui_controls::LEFT, kClickOffset, kClickOffset)); |
1669 ASSERT_NO_FATAL_FAILURE(ClickBrowserWindowCenter()); | 1672 ASSERT_NO_FATAL_FAILURE(ClickBrowserWindowCenter()); |
1670 ASSERT_NO_FATAL_FAILURE( | 1673 ASSERT_NO_FATAL_FAILURE( |
1671 ClickFocusViewOrigin(ui_controls::MIDDLE, kClickOffset, kClickOffset)); | 1674 ClickFocusViewOrigin(ui_controls::MIDDLE, kClickOffset, kClickOffset)); |
1672 EXPECT_FALSE(omnibox_view->IsSelectAll()); | 1675 EXPECT_FALSE(omnibox_view->IsSelectAll()); |
1673 } | 1676 } |
1674 #endif // defined(USE_AURA) | 1677 #endif // defined(USE_AURA) |
OLD | NEW |