| 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 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 617 info = webView->textInputInfo(); | 617 info = webView->textInputInfo(); |
| 618 EXPECT_EQ("ijklmnopqrstuvwxyz", std::string(info.value.utf8().data())); | 618 EXPECT_EQ("ijklmnopqrstuvwxyz", std::string(info.value.utf8().data())); |
| 619 } | 619 } |
| 620 | 620 |
| 621 TEST_F(WebViewTest, SetCompositionFromExistingText) | 621 TEST_F(WebViewTest, SetCompositionFromExistingText) |
| 622 { | 622 { |
| 623 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_populated.html")); | 623 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_populated.html")); |
| 624 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_fiel
d_populated.html"); | 624 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_fiel
d_populated.html"); |
| 625 webView->setInitialFocus(false); | 625 webView->setInitialFocus(false); |
| 626 WebVector<WebCompositionUnderline> underlines(static_cast<size_t>(1)); | 626 WebVector<WebCompositionUnderline> underlines(static_cast<size_t>(1)); |
| 627 underlines[0] = blink::WebCompositionUnderline(0, 4, 0, false); | 627 underlines[0] = blink::WebCompositionUnderline(0, 4, 0, false, 0); |
| 628 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webView->mainFrame()); | 628 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webView->mainFrame()); |
| 629 frame->setEditableSelectionOffsets(4, 10); | 629 frame->setEditableSelectionOffsets(4, 10); |
| 630 frame->setCompositionFromExistingText(8, 12, underlines); | 630 frame->setCompositionFromExistingText(8, 12, underlines); |
| 631 WebVector<WebCompositionUnderline> underlineResults = toWebViewImpl(webView)
->compositionUnderlines(); | 631 WebVector<WebCompositionUnderline> underlineResults = toWebViewImpl(webView)
->compositionUnderlines(); |
| 632 EXPECT_EQ(8u, underlineResults[0].startOffset); | 632 EXPECT_EQ(8u, underlineResults[0].startOffset); |
| 633 EXPECT_EQ(12u, underlineResults[0].endOffset); | 633 EXPECT_EQ(12u, underlineResults[0].endOffset); |
| 634 WebTextInputInfo info = webView->textInputInfo(); | 634 WebTextInputInfo info = webView->textInputInfo(); |
| 635 EXPECT_EQ(4, info.selectionStart); | 635 EXPECT_EQ(4, info.selectionStart); |
| 636 EXPECT_EQ(10, info.selectionEnd); | 636 EXPECT_EQ(10, info.selectionEnd); |
| 637 EXPECT_EQ(8, info.compositionStart); | 637 EXPECT_EQ(8, info.compositionStart); |
| 638 EXPECT_EQ(12, info.compositionEnd); | 638 EXPECT_EQ(12, info.compositionEnd); |
| 639 WebVector<WebCompositionUnderline> emptyUnderlines; | 639 WebVector<WebCompositionUnderline> emptyUnderlines; |
| 640 frame->setCompositionFromExistingText(0, 0, emptyUnderlines); | 640 frame->setCompositionFromExistingText(0, 0, emptyUnderlines); |
| 641 info = webView->textInputInfo(); | 641 info = webView->textInputInfo(); |
| 642 EXPECT_EQ(4, info.selectionStart); | 642 EXPECT_EQ(4, info.selectionStart); |
| 643 EXPECT_EQ(10, info.selectionEnd); | 643 EXPECT_EQ(10, info.selectionEnd); |
| 644 EXPECT_EQ(-1, info.compositionStart); | 644 EXPECT_EQ(-1, info.compositionStart); |
| 645 EXPECT_EQ(-1, info.compositionEnd); | 645 EXPECT_EQ(-1, info.compositionEnd); |
| 646 } | 646 } |
| 647 | 647 |
| 648 TEST_F(WebViewTest, SetCompositionFromExistingTextInTextArea) | 648 TEST_F(WebViewTest, SetCompositionFromExistingTextInTextArea) |
| 649 { | 649 { |
| 650 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("text_area_populated.html")); | 650 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("text_area_populated.html")); |
| 651 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "text_area_
populated.html"); | 651 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "text_area_
populated.html"); |
| 652 webView->setInitialFocus(false); | 652 webView->setInitialFocus(false); |
| 653 WebVector<WebCompositionUnderline> underlines(static_cast<size_t>(1)); | 653 WebVector<WebCompositionUnderline> underlines(static_cast<size_t>(1)); |
| 654 underlines[0] = blink::WebCompositionUnderline(0, 4, 0, false); | 654 underlines[0] = blink::WebCompositionUnderline(0, 4, 0, false, 0); |
| 655 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webView->mainFrame()); | 655 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webView->mainFrame()); |
| 656 frame->setEditableSelectionOffsets(27, 27); | 656 frame->setEditableSelectionOffsets(27, 27); |
| 657 std::string newLineText("\n"); | 657 std::string newLineText("\n"); |
| 658 webView->confirmComposition(WebString::fromUTF8(newLineText.c_str())); | 658 webView->confirmComposition(WebString::fromUTF8(newLineText.c_str())); |
| 659 WebTextInputInfo info = webView->textInputInfo(); | 659 WebTextInputInfo info = webView->textInputInfo(); |
| 660 EXPECT_EQ("0123456789abcdefghijklmnopq\nrstuvwxyz", std::string(info.value.u
tf8().data())); | 660 EXPECT_EQ("0123456789abcdefghijklmnopq\nrstuvwxyz", std::string(info.value.u
tf8().data())); |
| 661 | 661 |
| 662 frame->setEditableSelectionOffsets(31, 31); | 662 frame->setEditableSelectionOffsets(31, 31); |
| 663 frame->setCompositionFromExistingText(30, 34, underlines); | 663 frame->setCompositionFromExistingText(30, 34, underlines); |
| 664 WebVector<WebCompositionUnderline> underlineResults = toWebViewImpl(webView)
->compositionUnderlines(); | 664 WebVector<WebCompositionUnderline> underlineResults = toWebViewImpl(webView)
->compositionUnderlines(); |
| (...skipping 1313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1978 | 1978 |
| 1979 EXPECT_EQ(0, client.getUserGestureNotificationsCount()); | 1979 EXPECT_EQ(0, client.getUserGestureNotificationsCount()); |
| 1980 | 1980 |
| 1981 EXPECT_TRUE(tapElementById(webView, WebInputEvent::GestureTap, WebString::fr
omUTF8("target"))); | 1981 EXPECT_TRUE(tapElementById(webView, WebInputEvent::GestureTap, WebString::fr
omUTF8("target"))); |
| 1982 | 1982 |
| 1983 EXPECT_EQ(1, client.getUserGestureNotificationsCount()); | 1983 EXPECT_EQ(1, client.getUserGestureNotificationsCount()); |
| 1984 webView->setAutofillClient(0); | 1984 webView->setAutofillClient(0); |
| 1985 } | 1985 } |
| 1986 | 1986 |
| 1987 } // namespace | 1987 } // namespace |
| OLD | NEW |