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 #include <stdint.h> | 6 #include <stdint.h> |
7 #include <tuple> | 7 #include <tuple> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 1660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1671 EXPECT_EQ(4, info.selectionStart); | 1671 EXPECT_EQ(4, info.selectionStart); |
1672 EXPECT_EQ(8, info.selectionEnd); | 1672 EXPECT_EQ(8, info.selectionEnd); |
1673 EXPECT_EQ(7, info.compositionStart); | 1673 EXPECT_EQ(7, info.compositionStart); |
1674 EXPECT_EQ(10, info.compositionEnd); | 1674 EXPECT_EQ(10, info.compositionEnd); |
1675 frame()->Unselect(); | 1675 frame()->Unselect(); |
1676 info = view()->webview()->textInputInfo(); | 1676 info = view()->webview()->textInputInfo(); |
1677 EXPECT_EQ(0, info.selectionStart); | 1677 EXPECT_EQ(0, info.selectionStart); |
1678 EXPECT_EQ(0, info.selectionEnd); | 1678 EXPECT_EQ(0, info.selectionEnd); |
1679 } | 1679 } |
1680 | 1680 |
1681 | |
1682 TEST_F(RenderViewImplTest, OnExtendSelectionAndDelete) { | 1681 TEST_F(RenderViewImplTest, OnExtendSelectionAndDelete) { |
1683 // Load an HTML page consisting of an input field. | 1682 // Load an HTML page consisting of an input field. |
1684 LoadHTML("<html>" | 1683 LoadHTML("<html>" |
1685 "<head>" | 1684 "<head>" |
1686 "</head>" | 1685 "</head>" |
1687 "<body>" | 1686 "<body>" |
1688 "<input id=\"test1\" value=\"abcdefghijklmnopqrstuvwxyz\"></input>" | 1687 "<input id=\"test1\" value=\"abcdefghijklmnopqrstuvwxyz\"></input>" |
1689 "</body>" | 1688 "</body>" |
1690 "</html>"); | 1689 "</html>"); |
1691 ExecuteJavaScriptForTests("document.getElementById('test1').focus();"); | 1690 ExecuteJavaScriptForTests("document.getElementById('test1').focus();"); |
1692 frame()->SetEditableSelectionOffsets(10, 10); | 1691 frame()->SetEditableSelectionOffsets(10, 10); |
1693 frame()->ExtendSelectionAndDelete(3, 4); | 1692 frame()->ExtendSelectionAndDelete(3, 4); |
1694 blink::WebTextInputInfo info = view()->webview()->textInputInfo(); | 1693 blink::WebTextInputInfo info = view()->webview()->textInputInfo(); |
1695 EXPECT_EQ("abcdefgopqrstuvwxyz", info.value); | 1694 EXPECT_EQ("abcdefgopqrstuvwxyz", info.value); |
1696 EXPECT_EQ(7, info.selectionStart); | 1695 EXPECT_EQ(7, info.selectionStart); |
1697 EXPECT_EQ(7, info.selectionEnd); | 1696 EXPECT_EQ(7, info.selectionEnd); |
1698 frame()->SetEditableSelectionOffsets(4, 8); | 1697 frame()->SetEditableSelectionOffsets(4, 8); |
1699 frame()->ExtendSelectionAndDelete(2, 5); | 1698 frame()->ExtendSelectionAndDelete(2, 5); |
1700 info = view()->webview()->textInputInfo(); | 1699 info = view()->webview()->textInputInfo(); |
1701 EXPECT_EQ("abuvwxyz", info.value); | 1700 EXPECT_EQ("abuvwxyz", info.value); |
1702 EXPECT_EQ(2, info.selectionStart); | 1701 EXPECT_EQ(2, info.selectionStart); |
1703 EXPECT_EQ(2, info.selectionEnd); | 1702 EXPECT_EQ(2, info.selectionEnd); |
1704 } | 1703 } |
1705 | 1704 |
| 1705 TEST_F(RenderViewImplTest, OnDeleteSurroundingText) { |
| 1706 // Load an HTML page consisting of an input field. |
| 1707 LoadHTML( |
| 1708 "<html>" |
| 1709 "<head>" |
| 1710 "</head>" |
| 1711 "<body>" |
| 1712 "<input id=\"test1\" value=\"abcdefghijklmnopqrstuvwxyz\"></input>" |
| 1713 "</body>" |
| 1714 "</html>"); |
| 1715 ExecuteJavaScriptForTests("document.getElementById('test1').focus();"); |
| 1716 |
| 1717 frame()->SetEditableSelectionOffsets(10, 10); |
| 1718 frame()->DeleteSurroundingText(3, 4); |
| 1719 blink::WebTextInputInfo info = view()->webview()->textInputInfo(); |
| 1720 EXPECT_EQ("abcdefgopqrstuvwxyz", info.value); |
| 1721 EXPECT_EQ(7, info.selectionStart); |
| 1722 EXPECT_EQ(7, info.selectionEnd); |
| 1723 |
| 1724 frame()->SetEditableSelectionOffsets(4, 8); |
| 1725 frame()->DeleteSurroundingText(2, 5); |
| 1726 info = view()->webview()->textInputInfo(); |
| 1727 EXPECT_EQ("abefgouvwxyz", info.value); |
| 1728 EXPECT_EQ(2, info.selectionStart); |
| 1729 EXPECT_EQ(6, info.selectionEnd); |
| 1730 |
| 1731 frame()->SetEditableSelectionOffsets(5, 5); |
| 1732 frame()->DeleteSurroundingText(10, 0); |
| 1733 info = view()->webview()->textInputInfo(); |
| 1734 EXPECT_EQ("ouvwxyz", info.value); |
| 1735 EXPECT_EQ(0, info.selectionStart); |
| 1736 EXPECT_EQ(0, info.selectionEnd); |
| 1737 |
| 1738 frame()->DeleteSurroundingText(0, 10); |
| 1739 info = view()->webview()->textInputInfo(); |
| 1740 EXPECT_EQ("", info.value); |
| 1741 EXPECT_EQ(0, info.selectionStart); |
| 1742 EXPECT_EQ(0, info.selectionEnd); |
| 1743 |
| 1744 frame()->DeleteSurroundingText(10, 10); |
| 1745 info = view()->webview()->textInputInfo(); |
| 1746 EXPECT_EQ("", info.value); |
| 1747 |
| 1748 EXPECT_EQ(0, info.selectionStart); |
| 1749 EXPECT_EQ(0, info.selectionEnd); |
| 1750 } |
| 1751 |
1706 // Test that the navigating specific frames works correctly. | 1752 // Test that the navigating specific frames works correctly. |
1707 TEST_F(RenderViewImplTest, NavigateSubframe) { | 1753 TEST_F(RenderViewImplTest, NavigateSubframe) { |
1708 // Load page A. | 1754 // Load page A. |
1709 LoadHTML("hello <iframe srcdoc='fail' name='frame'></iframe>"); | 1755 LoadHTML("hello <iframe srcdoc='fail' name='frame'></iframe>"); |
1710 | 1756 |
1711 // Navigate the frame only. | 1757 // Navigate the frame only. |
1712 CommonNavigationParams common_params; | 1758 CommonNavigationParams common_params; |
1713 RequestNavigationParams request_params; | 1759 RequestNavigationParams request_params; |
1714 common_params.url = GURL("data:text/html,world"); | 1760 common_params.url = GURL("data:text/html,world"); |
1715 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 1761 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
(...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2495 ExpectPauseAndResume(3); | 2541 ExpectPauseAndResume(3); |
2496 blink::WebScriptSource source2( | 2542 blink::WebScriptSource source2( |
2497 WebString::fromUTF8("function func2() { func1(); }; func2();")); | 2543 WebString::fromUTF8("function func2() { func1(); }; func2();")); |
2498 frame()->GetWebFrame()->executeScriptInIsolatedWorld(17, &source2, 1, 1); | 2544 frame()->GetWebFrame()->executeScriptInIsolatedWorld(17, &source2, 1, 1); |
2499 | 2545 |
2500 EXPECT_FALSE(IsPaused()); | 2546 EXPECT_FALSE(IsPaused()); |
2501 Detach(); | 2547 Detach(); |
2502 } | 2548 } |
2503 | 2549 |
2504 } // namespace content | 2550 } // namespace content |
OLD | NEW |