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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
6 | 6 |
7 #include "base/shared_memory.h" | 7 #include "base/shared_memory.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "content/common/intents_messages.h" | 10 #include "content/common/intents_messages.h" |
(...skipping 1733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1744 EXPECT_EQ(4, info.selectionStart); | 1744 EXPECT_EQ(4, info.selectionStart); |
1745 EXPECT_EQ(8, info.selectionEnd); | 1745 EXPECT_EQ(8, info.selectionEnd); |
1746 EXPECT_EQ(7, info.compositionStart); | 1746 EXPECT_EQ(7, info.compositionStart); |
1747 EXPECT_EQ(10, info.compositionEnd); | 1747 EXPECT_EQ(10, info.compositionEnd); |
1748 view()->OnUnselect(); | 1748 view()->OnUnselect(); |
1749 info = view()->webview()->textInputInfo(); | 1749 info = view()->webview()->textInputInfo(); |
1750 EXPECT_EQ(0, info.selectionStart); | 1750 EXPECT_EQ(0, info.selectionStart); |
1751 EXPECT_EQ(0, info.selectionEnd); | 1751 EXPECT_EQ(0, info.selectionEnd); |
1752 } | 1752 } |
1753 | 1753 |
1754 TEST_F(RenderViewImplTest, OnReplaceAll) { | |
1755 // Load an HTML page consisting of an input field. | |
1756 LoadHTML("<html>" | |
1757 "<head>" | |
1758 "</head>" | |
1759 "<body>" | |
1760 "<input id=\"test1\" value=\"some test text hello\"></input>" | |
1761 "</body>" | |
1762 "</html>"); | |
1763 ExecuteJavaScript("document.getElementById('test1').focus();"); | |
1764 view()->OnReplaceAll(UTF8ToUTF16("replacement words")); | |
1765 WebKit::WebTextInputInfo info = view()->webview()->textInputInfo(); | |
1766 EXPECT_EQ("replacement words", info.value); | |
1767 } | |
1768 | 1754 |
1769 TEST_F(RenderViewImplTest, OnExtendSelectionAndDelete) { | 1755 TEST_F(RenderViewImplTest, OnExtendSelectionAndDelete) { |
1770 // Load an HTML page consisting of an input field. | 1756 // Load an HTML page consisting of an input field. |
1771 LoadHTML("<html>" | 1757 LoadHTML("<html>" |
1772 "<head>" | 1758 "<head>" |
1773 "</head>" | 1759 "</head>" |
1774 "<body>" | 1760 "<body>" |
1775 "<input id=\"test1\" value=\"abcdefghijklmnopqrstuvwxyz\"></input>" | 1761 "<input id=\"test1\" value=\"abcdefghijklmnopqrstuvwxyz\"></input>" |
1776 "</body>" | 1762 "</body>" |
1777 "</html>"); | 1763 "</html>"); |
1778 ExecuteJavaScript("document.getElementById('test1').focus();"); | 1764 ExecuteJavaScript("document.getElementById('test1').focus();"); |
1779 view()->OnSetEditableSelectionOffsets(10, 10); | 1765 view()->OnSetEditableSelectionOffsets(10, 10); |
1780 view()->OnExtendSelectionAndDelete(3, 4); | 1766 view()->OnExtendSelectionAndDelete(3, 4); |
1781 WebKit::WebTextInputInfo info = view()->webview()->textInputInfo(); | 1767 WebKit::WebTextInputInfo info = view()->webview()->textInputInfo(); |
1782 EXPECT_EQ("abcdefgopqrstuvwxyz", info.value); | 1768 EXPECT_EQ("abcdefgopqrstuvwxyz", info.value); |
1783 EXPECT_EQ(7, info.selectionStart); | 1769 EXPECT_EQ(7, info.selectionStart); |
1784 EXPECT_EQ(7, info.selectionEnd); | 1770 EXPECT_EQ(7, info.selectionEnd); |
1785 view()->OnSetEditableSelectionOffsets(4, 8); | 1771 view()->OnSetEditableSelectionOffsets(4, 8); |
1786 view()->OnExtendSelectionAndDelete(2, 5); | 1772 view()->OnExtendSelectionAndDelete(2, 5); |
1787 info = view()->webview()->textInputInfo(); | 1773 info = view()->webview()->textInputInfo(); |
1788 EXPECT_EQ("abuvwxyz", info.value); | 1774 EXPECT_EQ("abuvwxyz", info.value); |
1789 EXPECT_EQ(2, info.selectionStart); | 1775 EXPECT_EQ(2, info.selectionStart); |
1790 EXPECT_EQ(2, info.selectionEnd); | 1776 EXPECT_EQ(2, info.selectionEnd); |
1791 } | 1777 } |
1792 | 1778 |
1793 } // namespace content | 1779 } // namespace content |
OLD | NEW |