| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 635 info = webView->textInputInfo(); | 635 info = webView->textInputInfo(); |
| 636 EXPECT_EQ("ijklmnopqrstuvwxyz", std::string(info.value.utf8().data())); | 636 EXPECT_EQ("ijklmnopqrstuvwxyz", std::string(info.value.utf8().data())); |
| 637 } | 637 } |
| 638 | 638 |
| 639 TEST_F(WebViewTest, SetCompositionFromExistingText) | 639 TEST_F(WebViewTest, SetCompositionFromExistingText) |
| 640 { | 640 { |
| 641 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_populated.html")); | 641 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_populated.html")); |
| 642 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_fiel
d_populated.html"); | 642 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_fiel
d_populated.html"); |
| 643 webView->setInitialFocus(false); | 643 webView->setInitialFocus(false); |
| 644 WebVector<WebCompositionUnderline> underlines(static_cast<size_t>(1)); | 644 WebVector<WebCompositionUnderline> underlines(static_cast<size_t>(1)); |
| 645 underlines[0] = blink::WebCompositionUnderline(0, 4, 0, false); | 645 underlines[0] = blink::WebCompositionUnderline(0, 4, 0, false, 0); |
| 646 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webView->mainFrame()); | 646 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webView->mainFrame()); |
| 647 frame->setEditableSelectionOffsets(4, 10); | 647 frame->setEditableSelectionOffsets(4, 10); |
| 648 frame->setCompositionFromExistingText(8, 12, underlines); | 648 frame->setCompositionFromExistingText(8, 12, underlines); |
| 649 WebVector<WebCompositionUnderline> underlineResults = toWebViewImpl(webView)
->compositionUnderlines(); | 649 WebVector<WebCompositionUnderline> underlineResults = toWebViewImpl(webView)
->compositionUnderlines(); |
| 650 EXPECT_EQ(8u, underlineResults[0].startOffset); | 650 EXPECT_EQ(8u, underlineResults[0].startOffset); |
| 651 EXPECT_EQ(12u, underlineResults[0].endOffset); | 651 EXPECT_EQ(12u, underlineResults[0].endOffset); |
| 652 WebTextInputInfo info = webView->textInputInfo(); | 652 WebTextInputInfo info = webView->textInputInfo(); |
| 653 EXPECT_EQ(4, info.selectionStart); | 653 EXPECT_EQ(4, info.selectionStart); |
| 654 EXPECT_EQ(10, info.selectionEnd); | 654 EXPECT_EQ(10, info.selectionEnd); |
| 655 EXPECT_EQ(8, info.compositionStart); | 655 EXPECT_EQ(8, info.compositionStart); |
| 656 EXPECT_EQ(12, info.compositionEnd); | 656 EXPECT_EQ(12, info.compositionEnd); |
| 657 WebVector<WebCompositionUnderline> emptyUnderlines; | 657 WebVector<WebCompositionUnderline> emptyUnderlines; |
| 658 frame->setCompositionFromExistingText(0, 0, emptyUnderlines); | 658 frame->setCompositionFromExistingText(0, 0, emptyUnderlines); |
| 659 info = webView->textInputInfo(); | 659 info = webView->textInputInfo(); |
| 660 EXPECT_EQ(4, info.selectionStart); | 660 EXPECT_EQ(4, info.selectionStart); |
| 661 EXPECT_EQ(10, info.selectionEnd); | 661 EXPECT_EQ(10, info.selectionEnd); |
| 662 EXPECT_EQ(-1, info.compositionStart); | 662 EXPECT_EQ(-1, info.compositionStart); |
| 663 EXPECT_EQ(-1, info.compositionEnd); | 663 EXPECT_EQ(-1, info.compositionEnd); |
| 664 } | 664 } |
| 665 | 665 |
| 666 TEST_F(WebViewTest, SetCompositionFromExistingTextInTextArea) | 666 TEST_F(WebViewTest, SetCompositionFromExistingTextInTextArea) |
| 667 { | 667 { |
| 668 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("text_area_populated.html")); | 668 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("text_area_populated.html")); |
| 669 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "text_area_
populated.html"); | 669 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "text_area_
populated.html"); |
| 670 webView->setInitialFocus(false); | 670 webView->setInitialFocus(false); |
| 671 WebVector<WebCompositionUnderline> underlines(static_cast<size_t>(1)); | 671 WebVector<WebCompositionUnderline> underlines(static_cast<size_t>(1)); |
| 672 underlines[0] = blink::WebCompositionUnderline(0, 4, 0, false); | 672 underlines[0] = blink::WebCompositionUnderline(0, 4, 0, false, 0); |
| 673 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webView->mainFrame()); | 673 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webView->mainFrame()); |
| 674 frame->setEditableSelectionOffsets(27, 27); | 674 frame->setEditableSelectionOffsets(27, 27); |
| 675 std::string newLineText("\n"); | 675 std::string newLineText("\n"); |
| 676 webView->confirmComposition(WebString::fromUTF8(newLineText.c_str())); | 676 webView->confirmComposition(WebString::fromUTF8(newLineText.c_str())); |
| 677 WebTextInputInfo info = webView->textInputInfo(); | 677 WebTextInputInfo info = webView->textInputInfo(); |
| 678 EXPECT_EQ("0123456789abcdefghijklmnopq\nrstuvwxyz", std::string(info.value.u
tf8().data())); | 678 EXPECT_EQ("0123456789abcdefghijklmnopq\nrstuvwxyz", std::string(info.value.u
tf8().data())); |
| 679 | 679 |
| 680 frame->setEditableSelectionOffsets(31, 31); | 680 frame->setEditableSelectionOffsets(31, 31); |
| 681 frame->setCompositionFromExistingText(30, 34, underlines); | 681 frame->setCompositionFromExistingText(30, 34, underlines); |
| 682 WebVector<WebCompositionUnderline> underlineResults = toWebViewImpl(webView)
->compositionUnderlines(); | 682 WebVector<WebCompositionUnderline> underlineResults = toWebViewImpl(webView)
->compositionUnderlines(); |
| (...skipping 1312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1995 | 1995 |
| 1996 EXPECT_EQ(0, client.getUserGestureNotificationsCount()); | 1996 EXPECT_EQ(0, client.getUserGestureNotificationsCount()); |
| 1997 | 1997 |
| 1998 EXPECT_TRUE(tapElementById(webView, WebInputEvent::GestureTap, WebString::fr
omUTF8("target"))); | 1998 EXPECT_TRUE(tapElementById(webView, WebInputEvent::GestureTap, WebString::fr
omUTF8("target"))); |
| 1999 | 1999 |
| 2000 EXPECT_EQ(1, client.getUserGestureNotificationsCount()); | 2000 EXPECT_EQ(1, client.getUserGestureNotificationsCount()); |
| 2001 webView->setAutofillClient(0); | 2001 webView->setAutofillClient(0); |
| 2002 } | 2002 } |
| 2003 | 2003 |
| 2004 } // namespace | 2004 } // namespace |
| OLD | NEW |