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

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

Issue 2491643004: Update layout in WebInputMethodController::finishComposingText (Closed)
Patch Set: Change test name Created 4 years, 1 month 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
« no previous file with comments | « third_party/WebKit/Source/web/WebInputMethodControllerImpl.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 879 matching lines...) Expand 10 before | Expand all | Expand 10 after
890 frame->setEditableSelectionOffsets(8, 19); 890 frame->setEditableSelectionOffsets(8, 19);
891 EXPECT_EQ("89abcdefghi", frame->selectionAsText()); 891 EXPECT_EQ("89abcdefghi", frame->selectionAsText());
892 info = webView->textInputInfo(); 892 info = webView->textInputInfo();
893 EXPECT_EQ("0123456789abcdefghijklmnopqrstuvwxyz", info.value); 893 EXPECT_EQ("0123456789abcdefghijklmnopqrstuvwxyz", info.value);
894 EXPECT_EQ(8, info.selectionStart); 894 EXPECT_EQ(8, info.selectionStart);
895 EXPECT_EQ(19, info.selectionEnd); 895 EXPECT_EQ(19, info.selectionEnd);
896 EXPECT_EQ(-1, info.compositionStart); 896 EXPECT_EQ(-1, info.compositionStart);
897 EXPECT_EQ(-1, info.compositionEnd); 897 EXPECT_EQ(-1, info.compositionEnd);
898 } 898 }
899 899
900 // Regression test for crbug.com/663645
901 TEST_P(WebViewTest, FinishComposingTextDoesNotAssert) {
902 URLTestHelpers::registerMockedURLFromBaseURL(
903 WebString::fromUTF8(m_baseURL.c_str()),
904 WebString::fromUTF8("input_field_default.html"));
905 WebViewImpl* webView =
906 m_webViewHelper.initializeAndLoad(m_baseURL + "input_field_default.html");
907 webView->setInitialFocus(false);
908
909 WebInputMethodController* activeInputMethodController =
910 webView->mainFrameImpl()
911 ->frameWidget()
912 ->getActiveWebInputMethodController();
913
914 // The test requires non-empty composition.
915 std::string compositionText("hello");
916 WebVector<WebCompositionUnderline> emptyUnderlines;
917 activeInputMethodController->setComposition(
918 WebString::fromUTF8(compositionText.c_str()), emptyUnderlines, 5, 5);
919
920 // Do arbitrary change to make layout dirty.
921 Document& document = *webView->mainFrameImpl()->frame()->document();
922 Element* br = document.createElement("br", ASSERT_NO_EXCEPTION);
923 document.body()->appendChild(br);
924
925 // Should not hit assertion when calling
926 // WebInputMethodController::finishComposingText with non-empty composition
927 // and dirty layout.
928 activeInputMethodController->finishComposingText(
929 WebInputMethodController::KeepSelection);
930 }
931
900 TEST_P(WebViewTest, FinishComposingTextCursorPositionChange) { 932 TEST_P(WebViewTest, FinishComposingTextCursorPositionChange) {
901 URLTestHelpers::registerMockedURLFromBaseURL( 933 URLTestHelpers::registerMockedURLFromBaseURL(
902 WebString::fromUTF8(m_baseURL.c_str()), 934 WebString::fromUTF8(m_baseURL.c_str()),
903 WebString::fromUTF8("input_field_populated.html")); 935 WebString::fromUTF8("input_field_populated.html"));
904 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( 936 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(
905 m_baseURL + "input_field_populated.html"); 937 m_baseURL + "input_field_populated.html");
906 webView->setInitialFocus(false); 938 webView->setInitialFocus(false);
907 939
908 // Set up a composition that needs to be committed. 940 // Set up a composition that needs to be committed.
909 std::string compositionText("hello"); 941 std::string compositionText("hello");
(...skipping 3407 matching lines...) Expand 10 before | Expand all | Expand 10 after
4317 .translate(50, 55) 4349 .translate(50, 55)
4318 .scale(1. / 2.f); 4350 .scale(1. / 2.f);
4319 EXPECT_EQ(expectedMatrix, 4351 EXPECT_EQ(expectedMatrix,
4320 webViewImpl->getDeviceEmulationTransformForTesting()); 4352 webViewImpl->getDeviceEmulationTransformForTesting());
4321 // visibleContentRect doesn't change. 4353 // visibleContentRect doesn't change.
4322 EXPECT_EQ(IntRect(50, 55, 50, 75), 4354 EXPECT_EQ(IntRect(50, 55, 50, 75),
4323 *devToolsEmulator->visibleContentRectForPainting()); 4355 *devToolsEmulator->visibleContentRectForPainting());
4324 } 4356 }
4325 4357
4326 } // namespace blink 4358 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/WebInputMethodControllerImpl.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698