Chromium Code Reviews| 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 879 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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, FinishComposingTextDoesNotCrash) { | |
|
aelias_OOO_until_Jul13
2016/11/11 20:27:31
There's never been a crash here, please rename the
| |
| 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 crash when calling WebInputMethodController::finishComposingText | |
| 926 // with non-empty composition and dirty layout. | |
| 927 activeInputMethodController->finishComposingText( | |
| 928 WebInputMethodController::KeepSelection); | |
| 929 } | |
| 930 | |
| 900 TEST_P(WebViewTest, FinishComposingTextCursorPositionChange) { | 931 TEST_P(WebViewTest, FinishComposingTextCursorPositionChange) { |
| 901 URLTestHelpers::registerMockedURLFromBaseURL( | 932 URLTestHelpers::registerMockedURLFromBaseURL( |
| 902 WebString::fromUTF8(m_baseURL.c_str()), | 933 WebString::fromUTF8(m_baseURL.c_str()), |
| 903 WebString::fromUTF8("input_field_populated.html")); | 934 WebString::fromUTF8("input_field_populated.html")); |
| 904 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( | 935 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( |
| 905 m_baseURL + "input_field_populated.html"); | 936 m_baseURL + "input_field_populated.html"); |
| 906 webView->setInitialFocus(false); | 937 webView->setInitialFocus(false); |
| 907 | 938 |
| 908 // Set up a composition that needs to be committed. | 939 // Set up a composition that needs to be committed. |
| 909 std::string compositionText("hello"); | 940 std::string compositionText("hello"); |
| (...skipping 3406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4316 .translate(50, 55) | 4347 .translate(50, 55) |
| 4317 .scale(1. / 2.f); | 4348 .scale(1. / 2.f); |
| 4318 EXPECT_EQ(expectedMatrix, | 4349 EXPECT_EQ(expectedMatrix, |
| 4319 webViewImpl->getDeviceEmulationTransformForTesting()); | 4350 webViewImpl->getDeviceEmulationTransformForTesting()); |
| 4320 // visibleContentRect doesn't change. | 4351 // visibleContentRect doesn't change. |
| 4321 EXPECT_EQ(IntRect(50, 55, 50, 75), | 4352 EXPECT_EQ(IntRect(50, 55, 50, 75), |
| 4322 *devToolsEmulator->visibleContentRectForPainting()); | 4353 *devToolsEmulator->visibleContentRectForPainting()); |
| 4323 } | 4354 } |
| 4324 | 4355 |
| 4325 } // namespace blink | 4356 } // namespace blink |
| OLD | NEW |