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 1715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1726 // It should work even when the zoom limit is temporarily changed in the page. | 1726 // It should work even when the zoom limit is temporarily changed in the page. |
1727 view()->GetWebView()->zoomLimitsChanged( | 1727 view()->GetWebView()->zoomLimitsChanged( |
1728 WebKit::WebView::zoomFactorToZoomLevel(1.0), | 1728 WebKit::WebView::zoomFactorToZoomLevel(1.0), |
1729 WebKit::WebView::zoomFactorToZoomLevel(1.0)); | 1729 WebKit::WebView::zoomFactorToZoomLevel(1.0)); |
1730 params.url = GURL("data:text/html,max_zoomlimit_test"); | 1730 params.url = GURL("data:text/html,max_zoomlimit_test"); |
1731 view()->OnSetZoomLevelForLoadingURL(params.url, kMaxZoomLevel); | 1731 view()->OnSetZoomLevelForLoadingURL(params.url, kMaxZoomLevel); |
1732 view()->OnNavigate(params); | 1732 view()->OnNavigate(params); |
1733 ProcessPendingMessages(); | 1733 ProcessPendingMessages(); |
1734 EXPECT_DOUBLE_EQ(kMaxZoomLevel, view()->GetWebView()->zoomLevel()); | 1734 EXPECT_DOUBLE_EQ(kMaxZoomLevel, view()->GetWebView()->zoomLevel()); |
1735 } | 1735 } |
| 1736 |
| 1737 TEST_F(RenderViewImplTest, SetEditableSelectionAndComposition) { |
| 1738 // Load an HTML page consisting of an input field. |
| 1739 LoadHTML("<html>" |
| 1740 "<head>" |
| 1741 "</head>" |
| 1742 "<body>" |
| 1743 "<input id=\"test1\" value=\"some test text hello\"></input>" |
| 1744 "</body>" |
| 1745 "</html>"); |
| 1746 ExecuteJavaScript("document.getElementById('test1').focus();"); |
| 1747 view()->OnSetEditableSelectionOffsets(4, 8); |
| 1748 const std::vector<WebKit::WebCompositionUnderline> empty_underline; |
| 1749 view()->OnSetCompositionFromExistingText(7,10, empty_underline); |
| 1750 WebKit::WebTextInputInfo info = view()->webview()->textInputInfo(); |
| 1751 EXPECT_EQ(4, info.selectionStart); |
| 1752 EXPECT_EQ(8, info.selectionEnd); |
| 1753 EXPECT_EQ(7, info.compositionStart); |
| 1754 EXPECT_EQ(10, info.compositionEnd); |
| 1755 view()->OnUnselect(); |
| 1756 info = view()->webview()->textInputInfo(); |
| 1757 EXPECT_EQ(0, info.selectionStart); |
| 1758 EXPECT_EQ(0, info.selectionEnd); |
| 1759 } |
| 1760 |
| 1761 TEST_F(RenderViewImplTest, OnReplaceAll) { |
| 1762 // Load an HTML page consisting of an input field. |
| 1763 LoadHTML("<html>" |
| 1764 "<head>" |
| 1765 "</head>" |
| 1766 "<body>" |
| 1767 "<input id=\"test1\" value=\"some test text hello\"></input>" |
| 1768 "</body>" |
| 1769 "</html>"); |
| 1770 ExecuteJavaScript("document.getElementById('test1').focus();"); |
| 1771 view()->OnReplaceAll(UTF8ToUTF16("replacement words")); |
| 1772 WebKit::WebTextInputInfo info = view()->webview()->textInputInfo(); |
| 1773 EXPECT_EQ("replacement words", info.value); |
| 1774 } |
| 1775 |
| 1776 TEST_F(RenderViewImplTest, OnExtendSelectionAndDelete) { |
| 1777 // Load an HTML page consisting of an input field. |
| 1778 LoadHTML("<html>" |
| 1779 "<head>" |
| 1780 "</head>" |
| 1781 "<body>" |
| 1782 "<input id=\"test1\" value=\"abcdefghijklmnopqrstuvwxyz\"></input>" |
| 1783 "</body>" |
| 1784 "</html>"); |
| 1785 ExecuteJavaScript("document.getElementById('test1').focus();"); |
| 1786 view()->OnSetEditableSelectionOffsets(10, 10); |
| 1787 view()->OnExtendSelectionAndDelete(3, 4); |
| 1788 WebKit::WebTextInputInfo info = view()->webview()->textInputInfo(); |
| 1789 EXPECT_EQ("abcdefgopqrstuvwxyz", info.value); |
| 1790 EXPECT_EQ(7, info.selectionStart); |
| 1791 EXPECT_EQ(7, info.selectionEnd); |
| 1792 view()->OnSetEditableSelectionOffsets(4, 8); |
| 1793 view()->OnExtendSelectionAndDelete(2, 5); |
| 1794 info = view()->webview()->textInputInfo(); |
| 1795 EXPECT_EQ("abuvwxyz", info.value); |
| 1796 EXPECT_EQ(2, info.selectionStart); |
| 1797 EXPECT_EQ(2, info.selectionEnd); |
| 1798 } |
OLD | NEW |