Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(98)

Side by Side Diff: content/renderer/render_view_browsertest.cc

Issue 2617443002: Implement ThreadedInputConnection.deleteSurroundingTextInCodePoints() (Closed)
Patch Set: Convert UTF8 to UTF16 Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 1649 matching lines...) Expand 10 before | Expand all | Expand 10 after
1660 EXPECT_EQ(0, info.selectionEnd); 1660 EXPECT_EQ(0, info.selectionEnd);
1661 1661
1662 frame()->DeleteSurroundingText(10, 10); 1662 frame()->DeleteSurroundingText(10, 10);
1663 info = controller->textInputInfo(); 1663 info = controller->textInputInfo();
1664 EXPECT_EQ("", info.value); 1664 EXPECT_EQ("", info.value);
1665 1665
1666 EXPECT_EQ(0, info.selectionStart); 1666 EXPECT_EQ(0, info.selectionStart);
1667 EXPECT_EQ(0, info.selectionEnd); 1667 EXPECT_EQ(0, info.selectionEnd);
1668 } 1668 }
1669 1669
1670 TEST_F(RenderViewImplTest, OnDeleteSurroundingTextInCodePoints) {
1671 // Load an HTML page consisting of an input field.
1672 LoadHTML(
1673 "<html>"
1674 "<head>"
1675 "</head>"
1676 "<body>"
1677 // "ab" + trophy + space + "cdef" + trophy + space + "gh".
1678 "<input id=\"test1\" value=\"ab&#x1f3c6 cdef&#x1f3c6 gh\"></input>"
1679 "</body>"
1680 "</html>");
1681 ExecuteJavaScriptForTests("document.getElementById('test1').focus();");
1682
1683 frame()->SetEditableSelectionOffsets(4, 4);
1684 frame()->DeleteSurroundingTextInCodePoints(2, 2);
1685 blink::WebInputMethodController* controller =
1686 frame()->GetWebFrame()->inputMethodController();
1687 blink::WebTextInputInfo info = controller->textInputInfo();
1688 // "a" + "def" + trophy + space + "gh".
1689 EXPECT_EQ(WebString::fromUTF8("adef\xF0\x9F\x8F\x86 gh"), info.value);
1690 EXPECT_EQ(1, info.selectionStart);
1691 EXPECT_EQ(1, info.selectionEnd);
1692
1693 frame()->SetEditableSelectionOffsets(1, 3);
1694 frame()->DeleteSurroundingTextInCodePoints(1, 4);
1695 info = controller->textInputInfo();
1696 EXPECT_EQ("deh", info.value);
1697 EXPECT_EQ(0, info.selectionStart);
1698 EXPECT_EQ(2, info.selectionEnd);
1699 }
1700
1670 // Test that the navigating specific frames works correctly. 1701 // Test that the navigating specific frames works correctly.
1671 TEST_F(RenderViewImplTest, NavigateSubframe) { 1702 TEST_F(RenderViewImplTest, NavigateSubframe) {
1672 // Load page A. 1703 // Load page A.
1673 LoadHTML("hello <iframe srcdoc='fail' name='frame'></iframe>"); 1704 LoadHTML("hello <iframe srcdoc='fail' name='frame'></iframe>");
1674 1705
1675 // Navigate the frame only. 1706 // Navigate the frame only.
1676 CommonNavigationParams common_params; 1707 CommonNavigationParams common_params;
1677 RequestNavigationParams request_params; 1708 RequestNavigationParams request_params;
1678 common_params.url = GURL("data:text/html,world"); 1709 common_params.url = GURL("data:text/html,world");
1679 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; 1710 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
(...skipping 875 matching lines...) Expand 10 before | Expand all | Expand 10 after
2555 ExpectPauseAndResume(3); 2586 ExpectPauseAndResume(3);
2556 blink::WebScriptSource source2( 2587 blink::WebScriptSource source2(
2557 WebString::fromUTF8("function func2() { func1(); }; func2();")); 2588 WebString::fromUTF8("function func2() { func1(); }; func2();"));
2558 frame()->GetWebFrame()->executeScriptInIsolatedWorld(17, &source2, 1); 2589 frame()->GetWebFrame()->executeScriptInIsolatedWorld(17, &source2, 1);
2559 2590
2560 EXPECT_FALSE(IsPaused()); 2591 EXPECT_FALSE(IsPaused());
2561 Detach(); 2592 Detach();
2562 } 2593 }
2563 2594
2564 } // namespace content 2595 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698