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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 #include "testing/gtest/include/gtest/gtest.h" | 66 #include "testing/gtest/include/gtest/gtest.h" |
67 #include "third_party/WebKit/public/platform/WebData.h" | 67 #include "third_party/WebKit/public/platform/WebData.h" |
68 #include "third_party/WebKit/public/platform/WebHTTPBody.h" | 68 #include "third_party/WebKit/public/platform/WebHTTPBody.h" |
69 #include "third_party/WebKit/public/platform/WebString.h" | 69 #include "third_party/WebKit/public/platform/WebString.h" |
70 #include "third_party/WebKit/public/platform/WebURLResponse.h" | 70 #include "third_party/WebKit/public/platform/WebURLResponse.h" |
71 #include "third_party/WebKit/public/web/WebDataSource.h" | 71 #include "third_party/WebKit/public/web/WebDataSource.h" |
72 #include "third_party/WebKit/public/web/WebDeviceEmulationParams.h" | 72 #include "third_party/WebKit/public/web/WebDeviceEmulationParams.h" |
73 #include "third_party/WebKit/public/web/WebFrameContentDumper.h" | 73 #include "third_party/WebKit/public/web/WebFrameContentDumper.h" |
74 #include "third_party/WebKit/public/web/WebHistoryCommitType.h" | 74 #include "third_party/WebKit/public/web/WebHistoryCommitType.h" |
75 #include "third_party/WebKit/public/web/WebHistoryItem.h" | 75 #include "third_party/WebKit/public/web/WebHistoryItem.h" |
| 76 #include "third_party/WebKit/public/web/WebInputMethodController.h" |
76 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 77 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
77 #include "third_party/WebKit/public/web/WebPerformance.h" | 78 #include "third_party/WebKit/public/web/WebPerformance.h" |
78 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" | 79 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" |
79 #include "third_party/WebKit/public/web/WebScriptSource.h" | 80 #include "third_party/WebKit/public/web/WebScriptSource.h" |
80 #include "third_party/WebKit/public/web/WebSettings.h" | 81 #include "third_party/WebKit/public/web/WebSettings.h" |
81 #include "third_party/WebKit/public/web/WebView.h" | 82 #include "third_party/WebKit/public/web/WebView.h" |
82 #include "third_party/WebKit/public/web/WebWindowFeatures.h" | 83 #include "third_party/WebKit/public/web/WebWindowFeatures.h" |
83 #include "ui/events/event.h" | 84 #include "ui/events/event.h" |
84 #include "ui/events/keycodes/keyboard_codes.h" | 85 #include "ui/events/keycodes/keyboard_codes.h" |
85 #include "ui/gfx/codec/jpeg_codec.h" | 86 #include "ui/gfx/codec/jpeg_codec.h" |
(...skipping 1489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1575 "<head>" | 1576 "<head>" |
1576 "</head>" | 1577 "</head>" |
1577 "<body>" | 1578 "<body>" |
1578 "<input id=\"test1\" value=\"some test text hello\"></input>" | 1579 "<input id=\"test1\" value=\"some test text hello\"></input>" |
1579 "</body>" | 1580 "</body>" |
1580 "</html>"); | 1581 "</html>"); |
1581 ExecuteJavaScriptForTests("document.getElementById('test1').focus();"); | 1582 ExecuteJavaScriptForTests("document.getElementById('test1').focus();"); |
1582 frame()->SetEditableSelectionOffsets(4, 8); | 1583 frame()->SetEditableSelectionOffsets(4, 8); |
1583 const std::vector<blink::WebCompositionUnderline> empty_underline; | 1584 const std::vector<blink::WebCompositionUnderline> empty_underline; |
1584 frame()->SetCompositionFromExistingText(7, 10, empty_underline); | 1585 frame()->SetCompositionFromExistingText(7, 10, empty_underline); |
1585 blink::WebTextInputInfo info = view()->webview()->textInputInfo(); | 1586 blink::WebInputMethodController* controller = |
| 1587 frame()->GetWebFrame()->inputMethodController(); |
| 1588 blink::WebTextInputInfo info = controller->textInputInfo(); |
1586 EXPECT_EQ(4, info.selectionStart); | 1589 EXPECT_EQ(4, info.selectionStart); |
1587 EXPECT_EQ(8, info.selectionEnd); | 1590 EXPECT_EQ(8, info.selectionEnd); |
1588 EXPECT_EQ(7, info.compositionStart); | 1591 EXPECT_EQ(7, info.compositionStart); |
1589 EXPECT_EQ(10, info.compositionEnd); | 1592 EXPECT_EQ(10, info.compositionEnd); |
1590 frame()->Unselect(); | 1593 frame()->Unselect(); |
1591 info = view()->webview()->textInputInfo(); | 1594 info = controller->textInputInfo(); |
1592 EXPECT_EQ(0, info.selectionStart); | 1595 EXPECT_EQ(0, info.selectionStart); |
1593 EXPECT_EQ(0, info.selectionEnd); | 1596 EXPECT_EQ(0, info.selectionEnd); |
1594 } | 1597 } |
1595 | 1598 |
1596 TEST_F(RenderViewImplTest, OnExtendSelectionAndDelete) { | 1599 TEST_F(RenderViewImplTest, OnExtendSelectionAndDelete) { |
1597 // Load an HTML page consisting of an input field. | 1600 // Load an HTML page consisting of an input field. |
1598 LoadHTML("<html>" | 1601 LoadHTML("<html>" |
1599 "<head>" | 1602 "<head>" |
1600 "</head>" | 1603 "</head>" |
1601 "<body>" | 1604 "<body>" |
1602 "<input id=\"test1\" value=\"abcdefghijklmnopqrstuvwxyz\"></input>" | 1605 "<input id=\"test1\" value=\"abcdefghijklmnopqrstuvwxyz\"></input>" |
1603 "</body>" | 1606 "</body>" |
1604 "</html>"); | 1607 "</html>"); |
1605 ExecuteJavaScriptForTests("document.getElementById('test1').focus();"); | 1608 ExecuteJavaScriptForTests("document.getElementById('test1').focus();"); |
1606 frame()->SetEditableSelectionOffsets(10, 10); | 1609 frame()->SetEditableSelectionOffsets(10, 10); |
1607 frame()->ExtendSelectionAndDelete(3, 4); | 1610 frame()->ExtendSelectionAndDelete(3, 4); |
1608 blink::WebTextInputInfo info = view()->webview()->textInputInfo(); | 1611 blink::WebInputMethodController* controller = |
| 1612 frame()->GetWebFrame()->inputMethodController(); |
| 1613 blink::WebTextInputInfo info = controller->textInputInfo(); |
1609 EXPECT_EQ("abcdefgopqrstuvwxyz", info.value); | 1614 EXPECT_EQ("abcdefgopqrstuvwxyz", info.value); |
1610 EXPECT_EQ(7, info.selectionStart); | 1615 EXPECT_EQ(7, info.selectionStart); |
1611 EXPECT_EQ(7, info.selectionEnd); | 1616 EXPECT_EQ(7, info.selectionEnd); |
1612 frame()->SetEditableSelectionOffsets(4, 8); | 1617 frame()->SetEditableSelectionOffsets(4, 8); |
1613 frame()->ExtendSelectionAndDelete(2, 5); | 1618 frame()->ExtendSelectionAndDelete(2, 5); |
1614 info = view()->webview()->textInputInfo(); | 1619 info = controller->textInputInfo(); |
1615 EXPECT_EQ("abuvwxyz", info.value); | 1620 EXPECT_EQ("abuvwxyz", info.value); |
1616 EXPECT_EQ(2, info.selectionStart); | 1621 EXPECT_EQ(2, info.selectionStart); |
1617 EXPECT_EQ(2, info.selectionEnd); | 1622 EXPECT_EQ(2, info.selectionEnd); |
1618 } | 1623 } |
1619 | 1624 |
1620 TEST_F(RenderViewImplTest, OnDeleteSurroundingText) { | 1625 TEST_F(RenderViewImplTest, OnDeleteSurroundingText) { |
1621 // Load an HTML page consisting of an input field. | 1626 // Load an HTML page consisting of an input field. |
1622 LoadHTML( | 1627 LoadHTML( |
1623 "<html>" | 1628 "<html>" |
1624 "<head>" | 1629 "<head>" |
1625 "</head>" | 1630 "</head>" |
1626 "<body>" | 1631 "<body>" |
1627 "<input id=\"test1\" value=\"abcdefghijklmnopqrstuvwxyz\"></input>" | 1632 "<input id=\"test1\" value=\"abcdefghijklmnopqrstuvwxyz\"></input>" |
1628 "</body>" | 1633 "</body>" |
1629 "</html>"); | 1634 "</html>"); |
1630 ExecuteJavaScriptForTests("document.getElementById('test1').focus();"); | 1635 ExecuteJavaScriptForTests("document.getElementById('test1').focus();"); |
1631 | 1636 |
1632 frame()->SetEditableSelectionOffsets(10, 10); | 1637 frame()->SetEditableSelectionOffsets(10, 10); |
1633 frame()->DeleteSurroundingText(3, 4); | 1638 frame()->DeleteSurroundingText(3, 4); |
1634 blink::WebTextInputInfo info = view()->webview()->textInputInfo(); | 1639 blink::WebInputMethodController* controller = |
| 1640 frame()->GetWebFrame()->inputMethodController(); |
| 1641 blink::WebTextInputInfo info = controller->textInputInfo(); |
1635 EXPECT_EQ("abcdefgopqrstuvwxyz", info.value); | 1642 EXPECT_EQ("abcdefgopqrstuvwxyz", info.value); |
1636 EXPECT_EQ(7, info.selectionStart); | 1643 EXPECT_EQ(7, info.selectionStart); |
1637 EXPECT_EQ(7, info.selectionEnd); | 1644 EXPECT_EQ(7, info.selectionEnd); |
1638 | 1645 |
1639 frame()->SetEditableSelectionOffsets(4, 8); | 1646 frame()->SetEditableSelectionOffsets(4, 8); |
1640 frame()->DeleteSurroundingText(2, 5); | 1647 frame()->DeleteSurroundingText(2, 5); |
1641 info = view()->webview()->textInputInfo(); | 1648 info = controller->textInputInfo(); |
1642 EXPECT_EQ("abefgouvwxyz", info.value); | 1649 EXPECT_EQ("abefgouvwxyz", info.value); |
1643 EXPECT_EQ(2, info.selectionStart); | 1650 EXPECT_EQ(2, info.selectionStart); |
1644 EXPECT_EQ(6, info.selectionEnd); | 1651 EXPECT_EQ(6, info.selectionEnd); |
1645 | 1652 |
1646 frame()->SetEditableSelectionOffsets(5, 5); | 1653 frame()->SetEditableSelectionOffsets(5, 5); |
1647 frame()->DeleteSurroundingText(10, 0); | 1654 frame()->DeleteSurroundingText(10, 0); |
1648 info = view()->webview()->textInputInfo(); | 1655 info = controller->textInputInfo(); |
1649 EXPECT_EQ("ouvwxyz", info.value); | 1656 EXPECT_EQ("ouvwxyz", info.value); |
1650 EXPECT_EQ(0, info.selectionStart); | 1657 EXPECT_EQ(0, info.selectionStart); |
1651 EXPECT_EQ(0, info.selectionEnd); | 1658 EXPECT_EQ(0, info.selectionEnd); |
1652 | 1659 |
1653 frame()->DeleteSurroundingText(0, 10); | 1660 frame()->DeleteSurroundingText(0, 10); |
1654 info = view()->webview()->textInputInfo(); | 1661 info = controller->textInputInfo(); |
1655 EXPECT_EQ("", info.value); | 1662 EXPECT_EQ("", info.value); |
1656 EXPECT_EQ(0, info.selectionStart); | 1663 EXPECT_EQ(0, info.selectionStart); |
1657 EXPECT_EQ(0, info.selectionEnd); | 1664 EXPECT_EQ(0, info.selectionEnd); |
1658 | 1665 |
1659 frame()->DeleteSurroundingText(10, 10); | 1666 frame()->DeleteSurroundingText(10, 10); |
1660 info = view()->webview()->textInputInfo(); | 1667 info = controller->textInputInfo(); |
1661 EXPECT_EQ("", info.value); | 1668 EXPECT_EQ("", info.value); |
1662 | 1669 |
1663 EXPECT_EQ(0, info.selectionStart); | 1670 EXPECT_EQ(0, info.selectionStart); |
1664 EXPECT_EQ(0, info.selectionEnd); | 1671 EXPECT_EQ(0, info.selectionEnd); |
1665 } | 1672 } |
1666 | 1673 |
1667 // Test that the navigating specific frames works correctly. | 1674 // Test that the navigating specific frames works correctly. |
1668 TEST_F(RenderViewImplTest, NavigateSubframe) { | 1675 TEST_F(RenderViewImplTest, NavigateSubframe) { |
1669 // Load page A. | 1676 // Load page A. |
1670 LoadHTML("hello <iframe srcdoc='fail' name='frame'></iframe>"); | 1677 LoadHTML("hello <iframe srcdoc='fail' name='frame'></iframe>"); |
(...skipping 881 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2552 ExpectPauseAndResume(3); | 2559 ExpectPauseAndResume(3); |
2553 blink::WebScriptSource source2( | 2560 blink::WebScriptSource source2( |
2554 WebString::fromUTF8("function func2() { func1(); }; func2();")); | 2561 WebString::fromUTF8("function func2() { func1(); }; func2();")); |
2555 frame()->GetWebFrame()->executeScriptInIsolatedWorld(17, &source2, 1, 1); | 2562 frame()->GetWebFrame()->executeScriptInIsolatedWorld(17, &source2, 1, 1); |
2556 | 2563 |
2557 EXPECT_FALSE(IsPaused()); | 2564 EXPECT_FALSE(IsPaused()); |
2558 Detach(); | 2565 Detach(); |
2559 } | 2566 } |
2560 | 2567 |
2561 } // namespace content | 2568 } // namespace content |
OLD | NEW |