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/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/strings/string16.h" | 8 #include "base/strings/string16.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
735 | 735 |
736 EXPECT_NE(old_text, omnibox_view->GetText()); | 736 EXPECT_NE(old_text, omnibox_view->GetText()); |
737 | 737 |
738 // Escape shall revert back to the default match item. | 738 // Escape shall revert back to the default match item. |
739 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_ESCAPE, 0)); | 739 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_ESCAPE, 0)); |
740 EXPECT_EQ(old_text, omnibox_view->GetText()); | 740 EXPECT_EQ(old_text, omnibox_view->GetText()); |
741 EXPECT_EQ(old_selected_line, popup_model->selected_line()); | 741 EXPECT_EQ(old_selected_line, popup_model->selected_line()); |
742 } | 742 } |
743 | 743 |
744 // Flaky on Windows: http://crbug.com/146619 | 744 // Flaky on Windows: http://crbug.com/146619 |
745 // Fails on Linux: http://crbug.com/408637 | 745 #if defined(OS_WIN) |
746 #if defined(OS_WIN) || defined(OS_LINUX) | |
747 #define MAYBE_BasicTextOperations DISABLED_BasicTextOperations | 746 #define MAYBE_BasicTextOperations DISABLED_BasicTextOperations |
748 #else | 747 #else |
749 #define MAYBE_BasicTextOperations BasicTextOperations | 748 #define MAYBE_BasicTextOperations BasicTextOperations |
750 #endif | 749 #endif |
751 | 750 |
752 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, MAYBE_BasicTextOperations) { | 751 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, MAYBE_BasicTextOperations) { |
753 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); | 752 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); |
754 chrome::FocusLocationBar(browser()); | 753 chrome::FocusLocationBar(browser()); |
755 | 754 |
756 OmniboxView* omnibox_view = NULL; | 755 OmniboxView* omnibox_view = NULL; |
757 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view)); | 756 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view)); |
758 | 757 |
759 base::string16 old_text = omnibox_view->GetText(); | 758 base::string16 old_text = omnibox_view->GetText(); |
760 EXPECT_EQ(base::UTF8ToUTF16(url::kAboutBlankURL), old_text); | 759 EXPECT_EQ(base::UTF8ToUTF16(url::kAboutBlankURL), old_text); |
761 EXPECT_TRUE(omnibox_view->IsSelectAll()); | 760 EXPECT_TRUE(omnibox_view->IsSelectAll()); |
762 | 761 |
763 size_t start, end; | 762 size_t start, end; |
764 omnibox_view->GetSelectionBounds(&start, &end); | 763 omnibox_view->GetSelectionBounds(&start, &end); |
764 #if defined(OS_WIN) || defined(OS_LINUX) | |
msw
2014/09/10 23:17:27
I'd suggest using "#if defined(TOOLKIT_VIEWS)", bu
Mark P
2014/09/15 22:54:53
Acknowledged.
| |
765 // In Views textfields (i.e., Windows and Linux), select-all highlights end | |
msw
2014/09/10 23:17:27
nit: consider "Views textfields select-all in reve
Mark P
2014/09/15 22:54:53
Sounds good to me.
| |
766 // to start in order to show the leading text. | |
767 std::swap(start, end); | |
msw
2014/09/10 23:17:27
Hmm, does it make sense to replace these EXPECT_EQ
Mark P
2014/09/15 22:54:53
I think it was a conscious user-interface decision
| |
768 #endif | |
765 EXPECT_EQ(0U, start); | 769 EXPECT_EQ(0U, start); |
766 EXPECT_EQ(old_text.size(), end); | 770 EXPECT_EQ(old_text.size(), end); |
767 | 771 |
768 // Move the cursor to the end. | 772 // Move the cursor to the end. |
769 #if defined(OS_MACOSX) | 773 #if defined(OS_MACOSX) |
770 // End doesn't work on Mac trybot. | 774 // End doesn't work on Mac trybot. |
771 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_E, ui::EF_CONTROL_DOWN)); | 775 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_E, ui::EF_CONTROL_DOWN)); |
772 #else | 776 #else |
773 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_END, 0)); | 777 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_END, 0)); |
774 #endif | 778 #endif |
775 EXPECT_FALSE(omnibox_view->IsSelectAll()); | 779 EXPECT_FALSE(omnibox_view->IsSelectAll()); |
776 | 780 |
777 // Make sure the cursor is placed correctly. | 781 // Make sure the cursor is placed correctly. |
778 omnibox_view->GetSelectionBounds(&start, &end); | 782 omnibox_view->GetSelectionBounds(&start, &end); |
783 #if defined(OS_WIN) || defined(OS_LINUX) | |
784 // In Views textfields (i.e., Windows and Linux), select-all highlights end | |
785 // to start in order to show the leading text. | |
786 std::swap(start, end); | |
msw
2014/09/10 23:17:27
Why is this swap needed? The bounds are expected t
Mark P
2014/09/15 22:54:53
It's not needed. I added it because I liked the c
msw
2014/09/16 18:59:44
But there's no reason to expect consistency in the
Mark P
2014/09/16 21:31:00
Done.
| |
787 #endif | |
779 EXPECT_EQ(old_text.size(), start); | 788 EXPECT_EQ(old_text.size(), start); |
780 EXPECT_EQ(old_text.size(), end); | 789 EXPECT_EQ(old_text.size(), end); |
781 | 790 |
782 // Insert one character at the end. Make sure we won't insert | 791 // Insert one character at the end. Make sure we won't insert |
783 // anything after the special ZWS mark used in gtk implementation. | 792 // anything after the special ZWS mark used in gtk implementation. |
784 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_A, 0)); | 793 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_A, 0)); |
785 EXPECT_EQ(old_text + base::char16('a'), omnibox_view->GetText()); | 794 EXPECT_EQ(old_text + base::char16('a'), omnibox_view->GetText()); |
786 | 795 |
787 // Delete one character from the end. Make sure we won't delete the special | 796 // Delete one character from the end. Make sure we won't delete the special |
788 // ZWS mark used in gtk implementation. | 797 // ZWS mark used in gtk implementation. |
789 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_BACK, 0)); | 798 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_BACK, 0)); |
790 EXPECT_EQ(old_text, omnibox_view->GetText()); | 799 EXPECT_EQ(old_text, omnibox_view->GetText()); |
791 | 800 |
792 omnibox_view->SelectAll(true); | 801 omnibox_view->SelectAll(true); |
793 EXPECT_TRUE(omnibox_view->IsSelectAll()); | 802 EXPECT_TRUE(omnibox_view->IsSelectAll()); |
794 omnibox_view->GetSelectionBounds(&start, &end); | 803 omnibox_view->GetSelectionBounds(&start, &end); |
804 #if defined(OS_WIN) || defined(OS_LINUX) | |
805 // In Views textfields (i.e., Windows and Linux), select-all highlights end | |
806 // to start in order to show the leading text. | |
807 std::swap(start, end); | |
808 #endif | |
795 EXPECT_EQ(0U, start); | 809 EXPECT_EQ(0U, start); |
796 EXPECT_EQ(old_text.size(), end); | 810 EXPECT_EQ(old_text.size(), end); |
797 | 811 |
798 // Delete the content | 812 // Delete the content |
799 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_DELETE, 0)); | 813 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_DELETE, 0)); |
800 EXPECT_TRUE(omnibox_view->IsSelectAll()); | 814 EXPECT_TRUE(omnibox_view->IsSelectAll()); |
801 omnibox_view->GetSelectionBounds(&start, &end); | 815 omnibox_view->GetSelectionBounds(&start, &end); |
802 EXPECT_EQ(0U, start); | 816 EXPECT_EQ(0U, start); |
803 EXPECT_EQ(0U, end); | 817 EXPECT_EQ(0U, end); |
804 EXPECT_TRUE(omnibox_view->GetText().empty()); | 818 EXPECT_TRUE(omnibox_view->GetText().empty()); |
(...skipping 994 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1799 omnibox_view->Update(); | 1813 omnibox_view->Update(); |
1800 EXPECT_EQ(url_c, omnibox_view->GetText()); | 1814 EXPECT_EQ(url_c, omnibox_view->GetText()); |
1801 } | 1815 } |
1802 | 1816 |
1803 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, EscDisablesSearchTermReplacement) { | 1817 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, EscDisablesSearchTermReplacement) { |
1804 browser()->toolbar_model()->set_url_replacement_enabled(true); | 1818 browser()->toolbar_model()->set_url_replacement_enabled(true); |
1805 chrome::FocusLocationBar(browser()); | 1819 chrome::FocusLocationBar(browser()); |
1806 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_ESCAPE, 0)); | 1820 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_ESCAPE, 0)); |
1807 EXPECT_FALSE(browser()->toolbar_model()->url_replacement_enabled()); | 1821 EXPECT_FALSE(browser()->toolbar_model()->url_replacement_enabled()); |
1808 } | 1822 } |
OLD | NEW |