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 1026 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1037 std::string compositionText("yolo"); | 1037 std::string compositionText("yolo"); |
1038 webView->confirmComposition(WebString::fromUTF8(compositionText.c_str())); | 1038 webView->confirmComposition(WebString::fromUTF8(compositionText.c_str())); |
1039 info = webView->textInputInfo(); | 1039 info = webView->textInputInfo(); |
1040 EXPECT_EQ("0123456789abcdefghijklmnopq\nrsyoloxyz", std::string(info.value.u
tf8().data())); | 1040 EXPECT_EQ("0123456789abcdefghijklmnopq\nrsyoloxyz", std::string(info.value.u
tf8().data())); |
1041 EXPECT_EQ(34, info.selectionStart); | 1041 EXPECT_EQ(34, info.selectionStart); |
1042 EXPECT_EQ(34, info.selectionEnd); | 1042 EXPECT_EQ(34, info.selectionEnd); |
1043 EXPECT_EQ(-1, info.compositionStart); | 1043 EXPECT_EQ(-1, info.compositionStart); |
1044 EXPECT_EQ(-1, info.compositionEnd); | 1044 EXPECT_EQ(-1, info.compositionEnd); |
1045 } | 1045 } |
1046 | 1046 |
| 1047 TEST_F(WebViewTest, SetCompositionFromExistingTextInRichText) |
| 1048 { |
| 1049 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("content_editable_rich_text.html")); |
| 1050 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "content_ed
itable_rich_text.html"); |
| 1051 webView->setInitialFocus(false); |
| 1052 WebVector<WebCompositionUnderline> underlines(static_cast<size_t>(1)); |
| 1053 underlines[0] = WebCompositionUnderline(0, 4, 0, false, 0); |
| 1054 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webView->mainFrame()); |
| 1055 frame->setEditableSelectionOffsets(1, 1); |
| 1056 WebDocument document = webView->mainFrame()->document(); |
| 1057 EXPECT_FALSE(document.getElementById("bold").isNull()); |
| 1058 frame->setCompositionFromExistingText(0, 4, underlines); |
| 1059 EXPECT_FALSE(document.getElementById("bold").isNull()); |
| 1060 } |
| 1061 |
1047 TEST_F(WebViewTest, SetEditableSelectionOffsetsKeepsComposition) | 1062 TEST_F(WebViewTest, SetEditableSelectionOffsetsKeepsComposition) |
1048 { | 1063 { |
1049 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_populated.html")); | 1064 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_populated.html")); |
1050 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_fiel
d_populated.html"); | 1065 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_fiel
d_populated.html"); |
1051 webView->setInitialFocus(false); | 1066 webView->setInitialFocus(false); |
1052 | 1067 |
1053 std::string compositionTextFirst("hello "); | 1068 std::string compositionTextFirst("hello "); |
1054 std::string compositionTextSecond("world"); | 1069 std::string compositionTextSecond("world"); |
1055 WebVector<WebCompositionUnderline> emptyUnderlines; | 1070 WebVector<WebCompositionUnderline> emptyUnderlines; |
1056 | 1071 |
(...skipping 1988 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3045 for (size_t i = 0; i < renders.size(); ++i) { | 3060 for (size_t i = 0; i < renders.size(); ++i) { |
3046 double docStartTime = frame->domWindow()->document()->loader()->timing()
.monotonicTimeToZeroBasedDocumentTime(renderPairs[i].startTime) * 1000.0; | 3061 double docStartTime = frame->domWindow()->document()->loader()->timing()
.monotonicTimeToZeroBasedDocumentTime(renderPairs[i].startTime) * 1000.0; |
3047 ASSERT_DOUBLE_EQ(docStartTime, renders[i]->startTime()); | 3062 ASSERT_DOUBLE_EQ(docStartTime, renders[i]->startTime()); |
3048 double docFinishTime = frame->domWindow()->document()->loader()->timing(
).monotonicTimeToZeroBasedDocumentTime(renderPairs[i].finishTime) * 1000.0; | 3063 double docFinishTime = frame->domWindow()->document()->loader()->timing(
).monotonicTimeToZeroBasedDocumentTime(renderPairs[i].finishTime) * 1000.0; |
3049 double docDuration = docFinishTime - docStartTime; | 3064 double docDuration = docFinishTime - docStartTime; |
3050 ASSERT_DOUBLE_EQ(docDuration, renders[i]->duration()); | 3065 ASSERT_DOUBLE_EQ(docDuration, renders[i]->duration()); |
3051 } | 3066 } |
3052 } | 3067 } |
3053 | 3068 |
3054 } // namespace blink | 3069 } // namespace blink |
OLD | NEW |