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

Side by Side Diff: third_party/WebKit/Source/web/tests/WebViewTest.cpp

Issue 2611813002: Add support for persisting CompositionUnderlines in InputMethodController (Closed)
Patch Set: Try one more time Created 3 years, 11 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 /* 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 1402 matching lines...) Expand 10 before | Expand all | Expand 10 after
1413 } 1413 }
1414 1414
1415 TEST_P(WebViewTest, SetCompositionFromExistingText) { 1415 TEST_P(WebViewTest, SetCompositionFromExistingText) {
1416 URLTestHelpers::registerMockedURLFromBaseURL( 1416 URLTestHelpers::registerMockedURLFromBaseURL(
1417 WebString::fromUTF8(m_baseURL.c_str()), 1417 WebString::fromUTF8(m_baseURL.c_str()),
1418 WebString::fromUTF8("input_field_populated.html")); 1418 WebString::fromUTF8("input_field_populated.html"));
1419 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( 1419 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(
1420 m_baseURL + "input_field_populated.html"); 1420 m_baseURL + "input_field_populated.html");
1421 webView->setInitialFocus(false); 1421 webView->setInitialFocus(false);
1422 WebVector<WebCompositionUnderline> underlines(static_cast<size_t>(1)); 1422 WebVector<WebCompositionUnderline> underlines(static_cast<size_t>(1));
1423 underlines[0] = WebCompositionUnderline(0, 4, 0, false, 0); 1423 underlines[0] = WebCompositionUnderline(0, 4, 0, false, 0, false);
1424 WebLocalFrameImpl* frame = webView->mainFrameImpl(); 1424 WebLocalFrameImpl* frame = webView->mainFrameImpl();
1425 frame->setEditableSelectionOffsets(4, 10); 1425 frame->setEditableSelectionOffsets(4, 10);
1426 frame->setCompositionFromExistingText(8, 12, underlines); 1426 frame->setCompositionFromExistingText(8, 12, underlines);
1427 WebTextInputInfo info = webView->textInputInfo(); 1427 WebTextInputInfo info = webView->textInputInfo();
1428 EXPECT_EQ(4, info.selectionStart); 1428 EXPECT_EQ(4, info.selectionStart);
1429 EXPECT_EQ(10, info.selectionEnd); 1429 EXPECT_EQ(10, info.selectionEnd);
1430 EXPECT_EQ(8, info.compositionStart); 1430 EXPECT_EQ(8, info.compositionStart);
1431 EXPECT_EQ(12, info.compositionEnd); 1431 EXPECT_EQ(12, info.compositionEnd);
1432 WebVector<WebCompositionUnderline> emptyUnderlines; 1432 WebVector<WebCompositionUnderline> emptyUnderlines;
1433 frame->setCompositionFromExistingText(0, 0, emptyUnderlines); 1433 frame->setCompositionFromExistingText(0, 0, emptyUnderlines);
1434 info = webView->textInputInfo(); 1434 info = webView->textInputInfo();
1435 EXPECT_EQ(4, info.selectionStart); 1435 EXPECT_EQ(4, info.selectionStart);
1436 EXPECT_EQ(10, info.selectionEnd); 1436 EXPECT_EQ(10, info.selectionEnd);
1437 EXPECT_EQ(-1, info.compositionStart); 1437 EXPECT_EQ(-1, info.compositionStart);
1438 EXPECT_EQ(-1, info.compositionEnd); 1438 EXPECT_EQ(-1, info.compositionEnd);
1439 } 1439 }
1440 1440
1441 TEST_P(WebViewTest, SetCompositionFromExistingTextInTextArea) { 1441 TEST_P(WebViewTest, SetCompositionFromExistingTextInTextArea) {
1442 URLTestHelpers::registerMockedURLFromBaseURL( 1442 URLTestHelpers::registerMockedURLFromBaseURL(
1443 WebString::fromUTF8(m_baseURL.c_str()), 1443 WebString::fromUTF8(m_baseURL.c_str()),
1444 WebString::fromUTF8("text_area_populated.html")); 1444 WebString::fromUTF8("text_area_populated.html"));
1445 WebViewImpl* webView = 1445 WebViewImpl* webView =
1446 m_webViewHelper.initializeAndLoad(m_baseURL + "text_area_populated.html"); 1446 m_webViewHelper.initializeAndLoad(m_baseURL + "text_area_populated.html");
1447 webView->setInitialFocus(false); 1447 webView->setInitialFocus(false);
1448 WebVector<WebCompositionUnderline> underlines(static_cast<size_t>(1)); 1448 WebVector<WebCompositionUnderline> underlines(static_cast<size_t>(1));
1449 underlines[0] = WebCompositionUnderline(0, 4, 0, false, 0); 1449 underlines[0] = WebCompositionUnderline(0, 4, 0, false, 0, false);
1450 WebLocalFrameImpl* frame = webView->mainFrameImpl(); 1450 WebLocalFrameImpl* frame = webView->mainFrameImpl();
1451 WebInputMethodController* activeInputMethodController = 1451 WebInputMethodController* activeInputMethodController =
1452 frame->frameWidget()->getActiveWebInputMethodController(); 1452 frame->frameWidget()->getActiveWebInputMethodController();
1453 frame->setEditableSelectionOffsets(27, 27); 1453 frame->setEditableSelectionOffsets(27, 27);
1454 std::string newLineText("\n"); 1454 std::string newLineText("\n");
1455 WebVector<WebCompositionUnderline> emptyUnderlines; 1455 WebVector<WebCompositionUnderline> emptyUnderlines;
1456 activeInputMethodController->commitText( 1456 activeInputMethodController->commitText(
1457 WebString::fromUTF8(newLineText.c_str()), emptyUnderlines, 0); 1457 WebString::fromUTF8(newLineText.c_str()), emptyUnderlines, 0);
1458 WebTextInputInfo info = webView->textInputInfo(); 1458 WebTextInputInfo info = webView->textInputInfo();
1459 EXPECT_EQ("0123456789abcdefghijklmnopq\nrstuvwxyz", 1459 EXPECT_EQ("0123456789abcdefghijklmnopq\nrstuvwxyz",
(...skipping 22 matching lines...) Expand all
1482 } 1482 }
1483 1483
1484 TEST_P(WebViewTest, SetCompositionFromExistingTextInRichText) { 1484 TEST_P(WebViewTest, SetCompositionFromExistingTextInRichText) {
1485 URLTestHelpers::registerMockedURLFromBaseURL( 1485 URLTestHelpers::registerMockedURLFromBaseURL(
1486 WebString::fromUTF8(m_baseURL.c_str()), 1486 WebString::fromUTF8(m_baseURL.c_str()),
1487 WebString::fromUTF8("content_editable_rich_text.html")); 1487 WebString::fromUTF8("content_editable_rich_text.html"));
1488 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( 1488 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(
1489 m_baseURL + "content_editable_rich_text.html"); 1489 m_baseURL + "content_editable_rich_text.html");
1490 webView->setInitialFocus(false); 1490 webView->setInitialFocus(false);
1491 WebVector<WebCompositionUnderline> underlines(static_cast<size_t>(1)); 1491 WebVector<WebCompositionUnderline> underlines(static_cast<size_t>(1));
1492 underlines[0] = WebCompositionUnderline(0, 4, 0, false, 0); 1492 underlines[0] = WebCompositionUnderline(0, 4, 0, false, 0, false);
1493 WebLocalFrameImpl* frame = webView->mainFrameImpl(); 1493 WebLocalFrameImpl* frame = webView->mainFrameImpl();
1494 frame->setEditableSelectionOffsets(1, 1); 1494 frame->setEditableSelectionOffsets(1, 1);
1495 WebDocument document = webView->mainFrame()->document(); 1495 WebDocument document = webView->mainFrame()->document();
1496 EXPECT_FALSE(document.getElementById("bold").isNull()); 1496 EXPECT_FALSE(document.getElementById("bold").isNull());
1497 frame->setCompositionFromExistingText(0, 4, underlines); 1497 frame->setCompositionFromExistingText(0, 4, underlines);
1498 EXPECT_FALSE(document.getElementById("bold").isNull()); 1498 EXPECT_FALSE(document.getElementById("bold").isNull());
1499 } 1499 }
1500 1500
1501 TEST_P(WebViewTest, SetEditableSelectionOffsetsKeepsComposition) { 1501 TEST_P(WebViewTest, SetEditableSelectionOffsetsKeepsComposition) {
1502 URLTestHelpers::registerMockedURLFromBaseURL( 1502 URLTestHelpers::registerMockedURLFromBaseURL(
(...skipping 2797 matching lines...) Expand 10 before | Expand all | Expand 10 after
4300 .translate(50, 55) 4300 .translate(50, 55)
4301 .scale(1. / 2.f); 4301 .scale(1. / 2.f);
4302 EXPECT_EQ(expectedMatrix, 4302 EXPECT_EQ(expectedMatrix,
4303 webViewImpl->getDeviceEmulationTransformForTesting()); 4303 webViewImpl->getDeviceEmulationTransformForTesting());
4304 // visibleContentRect doesn't change. 4304 // visibleContentRect doesn't change.
4305 EXPECT_EQ(IntRect(50, 55, 50, 75), 4305 EXPECT_EQ(IntRect(50, 55, 50, 75),
4306 *devToolsEmulator->visibleContentRectForPainting()); 4306 *devToolsEmulator->visibleContentRectForPainting());
4307 } 4307 }
4308 4308
4309 } // namespace blink 4309 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698