OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 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 3073 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3084 | 3084 |
3085 WebVector<uint32_t> documentMarkers; | 3085 WebVector<uint32_t> documentMarkers; |
3086 m_webView->spellingMarkers(&documentMarkers); | 3086 m_webView->spellingMarkers(&documentMarkers); |
3087 EXPECT_EQ(1U, documentMarkers.size()); | 3087 EXPECT_EQ(1U, documentMarkers.size()); |
3088 EXPECT_EQ(kHash, documentMarkers[0]); | 3088 EXPECT_EQ(kHash, documentMarkers[0]); |
3089 | 3089 |
3090 m_webView->close(); | 3090 m_webView->close(); |
3091 m_webView = 0; | 3091 m_webView = 0; |
3092 } | 3092 } |
3093 | 3093 |
| 3094 class StubbornSpellCheckClient : public WebSpellCheckClient { |
| 3095 public: |
| 3096 StubbornSpellCheckClient() : m_completion(0) { } |
| 3097 virtual ~StubbornSpellCheckClient() { } |
| 3098 |
| 3099 virtual void requestCheckingOfText( |
| 3100 const WebKit::WebString&, |
| 3101 const WebKit::WebVector<uint32_t>&, |
| 3102 const WebKit::WebVector<unsigned>&, |
| 3103 WebKit::WebTextCheckingCompletion* completion) OVERRIDE |
| 3104 { |
| 3105 m_completion = completion; |
| 3106 } |
| 3107 |
| 3108 void kick() |
| 3109 { |
| 3110 if (!m_completion) |
| 3111 return; |
| 3112 Vector<WebTextCheckingResult> results; |
| 3113 const int misspellingStartOffset = 1; |
| 3114 const int misspellingLength = 8; |
| 3115 results.append(WebTextCheckingResult(WebTextCheckingTypeSpelling, misspe
llingStartOffset, misspellingLength)); |
| 3116 m_completion->didFinishCheckingText(results); |
| 3117 m_completion = 0; |
| 3118 } |
| 3119 |
| 3120 private: |
| 3121 WebKit::WebTextCheckingCompletion* m_completion; |
| 3122 }; |
| 3123 |
| 3124 TEST_F(WebFrameTest, SlowSpellcheckMarkerPosition) |
| 3125 { |
| 3126 registerMockedHttpURLLoad("spell.html"); |
| 3127 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "spell.html")
; |
| 3128 |
| 3129 StubbornSpellCheckClient spellcheck; |
| 3130 m_webView->setSpellCheckClient(&spellcheck); |
| 3131 |
| 3132 WebFrameImpl* frame = static_cast<WebFrameImpl*>(m_webView->mainFrame()); |
| 3133 WebInputElement webInputElement = frame->document().getElementById("data").t
o<WebInputElement>(); |
| 3134 Document* document = frame->frame()->document(); |
| 3135 Element* element = document->getElementById("data"); |
| 3136 |
| 3137 m_webView->settings()->setAsynchronousSpellCheckingEnabled(true); |
| 3138 m_webView->settings()->setUnifiedTextCheckerEnabled(true); |
| 3139 m_webView->settings()->setEditingBehavior(WebSettings::EditingBehaviorWin); |
| 3140 |
| 3141 element->focus(); |
| 3142 document->execCommand("InsertText", false, "wellcome "); |
| 3143 webInputElement.setSelectionRange(0, 0); |
| 3144 document->execCommand("InsertText", false, "he"); |
| 3145 |
| 3146 spellcheck.kick(); |
| 3147 |
| 3148 WebVector<uint32_t> documentMarkers; |
| 3149 m_webView->spellingMarkers(&documentMarkers); |
| 3150 EXPECT_EQ(0U, documentMarkers.size()); |
| 3151 |
| 3152 m_webView->close(); |
| 3153 m_webView = 0; |
| 3154 } |
| 3155 |
3094 class TestAccessInitialDocumentWebFrameClient : public WebFrameClient { | 3156 class TestAccessInitialDocumentWebFrameClient : public WebFrameClient { |
3095 public: | 3157 public: |
3096 TestAccessInitialDocumentWebFrameClient() : m_didAccessInitialDocument(false
) | 3158 TestAccessInitialDocumentWebFrameClient() : m_didAccessInitialDocument(false
) |
3097 { | 3159 { |
3098 } | 3160 } |
3099 | 3161 |
3100 virtual void didAccessInitialDocument(WebFrame* frame) | 3162 virtual void didAccessInitialDocument(WebFrame* frame) |
3101 { | 3163 { |
3102 EXPECT_TRUE(!m_didAccessInitialDocument); | 3164 EXPECT_TRUE(!m_didAccessInitialDocument); |
3103 m_didAccessInitialDocument = true; | 3165 m_didAccessInitialDocument = true; |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3268 EXPECT_FALSE(client.wasProgrammaticScroll()); | 3330 EXPECT_FALSE(client.wasProgrammaticScroll()); |
3269 EXPECT_TRUE(client.wasUserScroll()); | 3331 EXPECT_TRUE(client.wasUserScroll()); |
3270 client.reset(); | 3332 client.reset(); |
3271 | 3333 |
3272 m_webView->close(); | 3334 m_webView->close(); |
3273 m_webView = 0; | 3335 m_webView = 0; |
3274 } | 3336 } |
3275 | 3337 |
3276 | 3338 |
3277 } // namespace | 3339 } // namespace |
OLD | NEW |