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