| 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 665 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   676     webView->confirmComposition(WebString::fromUTF8(compositionText.c_str())); |   676     webView->confirmComposition(WebString::fromUTF8(compositionText.c_str())); | 
|   677     info = webView->textInputInfo(); |   677     info = webView->textInputInfo(); | 
|   678     EXPECT_EQ("0123456789abcdefghijklmnopq\nrsyoloxyz", std::string(info.value.u
      tf8().data())); |   678     EXPECT_EQ("0123456789abcdefghijklmnopq\nrsyoloxyz", std::string(info.value.u
      tf8().data())); | 
|   679     EXPECT_EQ(34, info.selectionStart); |   679     EXPECT_EQ(34, info.selectionStart); | 
|   680     EXPECT_EQ(34, info.selectionEnd); |   680     EXPECT_EQ(34, info.selectionEnd); | 
|   681     EXPECT_EQ(-1, info.compositionStart); |   681     EXPECT_EQ(-1, info.compositionStart); | 
|   682     EXPECT_EQ(-1, info.compositionEnd); |   682     EXPECT_EQ(-1, info.compositionEnd); | 
|   683     webView->close(); |   683     webView->close(); | 
|   684 } |   684 } | 
|   685  |   685  | 
 |   686 TEST_F(WebViewTest, SetEditableSelectionOffsetsKeepsComposition) | 
 |   687 { | 
 |   688     URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
      _str()), WebString::fromUTF8("input_field_populated.html")); | 
 |   689     WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "input
      _field_populated.html"); | 
 |   690     webView->setInitialFocus(false); | 
 |   691  | 
 |   692     std::string compositionTextFirst("hello "); | 
 |   693     std::string compositionTextSecond("world"); | 
 |   694     WebVector<WebCompositionUnderline> emptyUnderlines; | 
 |   695  | 
 |   696     webView->confirmComposition(WebString::fromUTF8(compositionTextFirst.c_str()
      )); | 
 |   697     webView->setComposition(WebString::fromUTF8(compositionTextSecond.c_str()), 
      emptyUnderlines, 5, 5); | 
 |   698  | 
 |   699     WebTextInputInfo info = webView->textInputInfo(); | 
 |   700     EXPECT_EQ("hello world", std::string(info.value.utf8().data())); | 
 |   701     EXPECT_EQ(11, info.selectionStart); | 
 |   702     EXPECT_EQ(11, info.selectionEnd); | 
 |   703     EXPECT_EQ(6, info.compositionStart); | 
 |   704     EXPECT_EQ(11, info.compositionEnd); | 
 |   705  | 
 |   706     webView->setEditableSelectionOffsets(6, 6); | 
 |   707     info = webView->textInputInfo(); | 
 |   708     EXPECT_EQ("hello world", std::string(info.value.utf8().data())); | 
 |   709     EXPECT_EQ(6, info.selectionStart); | 
 |   710     EXPECT_EQ(6, info.selectionEnd); | 
 |   711     EXPECT_EQ(6, info.compositionStart); | 
 |   712     EXPECT_EQ(11, info.compositionEnd); | 
 |   713  | 
 |   714     webView->setEditableSelectionOffsets(8, 8); | 
 |   715     info = webView->textInputInfo(); | 
 |   716     EXPECT_EQ("hello world", std::string(info.value.utf8().data())); | 
 |   717     EXPECT_EQ(8, info.selectionStart); | 
 |   718     EXPECT_EQ(8, info.selectionEnd); | 
 |   719     EXPECT_EQ(6, info.compositionStart); | 
 |   720     EXPECT_EQ(11, info.compositionEnd); | 
 |   721  | 
 |   722     webView->setEditableSelectionOffsets(11, 11); | 
 |   723     info = webView->textInputInfo(); | 
 |   724     EXPECT_EQ("hello world", std::string(info.value.utf8().data())); | 
 |   725     EXPECT_EQ(11, info.selectionStart); | 
 |   726     EXPECT_EQ(11, info.selectionEnd); | 
 |   727     EXPECT_EQ(6, info.compositionStart); | 
 |   728     EXPECT_EQ(11, info.compositionEnd); | 
 |   729  | 
 |   730     webView->setEditableSelectionOffsets(6, 11); | 
 |   731     info = webView->textInputInfo(); | 
 |   732     EXPECT_EQ("hello world", std::string(info.value.utf8().data())); | 
 |   733     EXPECT_EQ(6, info.selectionStart); | 
 |   734     EXPECT_EQ(11, info.selectionEnd); | 
 |   735     EXPECT_EQ(6, info.compositionStart); | 
 |   736     EXPECT_EQ(11, info.compositionEnd); | 
 |   737  | 
 |   738     webView->setEditableSelectionOffsets(2, 2); | 
 |   739     info = webView->textInputInfo(); | 
 |   740     EXPECT_EQ("hello world", std::string(info.value.utf8().data())); | 
 |   741     EXPECT_EQ(2, info.selectionStart); | 
 |   742     EXPECT_EQ(2, info.selectionEnd); | 
 |   743     EXPECT_EQ(-1, info.compositionStart); | 
 |   744     EXPECT_EQ(-1, info.compositionEnd); | 
 |   745     webView->close(); | 
 |   746 } | 
 |   747  | 
|   686 TEST_F(WebViewTest, IsSelectionAnchorFirst) |   748 TEST_F(WebViewTest, IsSelectionAnchorFirst) | 
|   687 { |   749 { | 
|   688     URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
      _str()), WebString::fromUTF8("input_field_populated.html")); |   750     URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
      _str()), WebString::fromUTF8("input_field_populated.html")); | 
|   689     WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "input
      _field_populated.html"); |   751     WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "input
      _field_populated.html"); | 
|   690     WebFrame* frame = webView->mainFrame(); |   752     WebFrame* frame = webView->mainFrame(); | 
|   691  |   753  | 
|   692     webView->setInitialFocus(false); |   754     webView->setInitialFocus(false); | 
|   693     webView->setEditableSelectionOffsets(4, 10); |   755     webView->setEditableSelectionOffsets(4, 10); | 
|   694     EXPECT_TRUE(webView->isSelectionAnchorFirst()); |   756     EXPECT_TRUE(webView->isSelectionAnchorFirst()); | 
|   695     WebRect anchor; |   757     WebRect anchor; | 
| (...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1145     WebHelperPluginImpl* helperPlugin = webViewImpl->createHelperPlugin("dummy-p
      lugin-type", frame->document()); |  1207     WebHelperPluginImpl* helperPlugin = webViewImpl->createHelperPlugin("dummy-p
      lugin-type", frame->document()); | 
|  1146     EXPECT_TRUE(helperPlugin); |  1208     EXPECT_TRUE(helperPlugin); | 
|  1147     EXPECT_EQ(0, helperPlugin->getPlugin()); // Invalid plugin type means no plu
      gin. |  1209     EXPECT_EQ(0, helperPlugin->getPlugin()); // Invalid plugin type means no plu
      gin. | 
|  1148  |  1210  | 
|  1149     webViewImpl->closeHelperPluginSoon(helperPlugin); |  1211     webViewImpl->closeHelperPluginSoon(helperPlugin); | 
|  1150  |  1212  | 
|  1151     webViewImpl->close(); |  1213     webViewImpl->close(); | 
|  1152 } |  1214 } | 
|  1153  |  1215  | 
|  1154 } |  1216 } | 
| OLD | NEW |