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

Side by Side Diff: Source/web/tests/WebFrameTest.cpp

Issue 181693003: Have Document::markers() return a reference (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 10 months 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 | Annotate | Revision Log
« no previous file with comments | « Source/web/WebViewImpl.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) 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 4080 matching lines...) Expand 10 before | Expand all | Expand 10 after
4091 4091
4092 element->focus(); 4092 element->focus();
4093 document->execCommand("InsertText", false, "_wellcome_."); 4093 document->execCommand("InsertText", false, "_wellcome_.");
4094 4094
4095 const int allTextBeginOffset = 0; 4095 const int allTextBeginOffset = 0;
4096 const int allTextLength = 11; 4096 const int allTextLength = 11;
4097 frame->selectRange(WebRange::fromDocumentRange(frame, allTextBeginOffset, al lTextLength)); 4097 frame->selectRange(WebRange::fromDocumentRange(frame, allTextBeginOffset, al lTextLength));
4098 RefPtr<Range> selectionRange = frame->frame()->selection().toNormalizedRange (); 4098 RefPtr<Range> selectionRange = frame->frame()->selection().toNormalizedRange ();
4099 4099
4100 EXPECT_EQ(1, spellcheck.numberOfTimesChecked()); 4100 EXPECT_EQ(1, spellcheck.numberOfTimesChecked());
4101 EXPECT_EQ(1U, document->markers()->markersInRange(selectionRange.get(), Docu mentMarker::Spelling).size()); 4101 EXPECT_EQ(1U, document->markers().markersInRange(selectionRange.get(), Docum entMarker::Spelling).size());
4102 4102
4103 frame->replaceMisspelledRange("welcome"); 4103 frame->replaceMisspelledRange("welcome");
4104 EXPECT_EQ("_welcome_.", frame->contentAsText(std::numeric_limits<size_t>::ma x()).utf8()); 4104 EXPECT_EQ("_welcome_.", frame->contentAsText(std::numeric_limits<size_t>::ma x()).utf8());
4105 } 4105 }
4106 4106
4107 TEST_F(WebFrameTest, RemoveSpellingMarkers) 4107 TEST_F(WebFrameTest, RemoveSpellingMarkers)
4108 { 4108 {
4109 registerMockedHttpURLLoad("spell.html"); 4109 registerMockedHttpURLLoad("spell.html");
4110 FrameTestHelpers::WebViewHelper webViewHelper; 4110 FrameTestHelpers::WebViewHelper webViewHelper;
4111 webViewHelper.initializeAndLoad(m_baseURL + "spell.html"); 4111 webViewHelper.initializeAndLoad(m_baseURL + "spell.html");
(...skipping 11 matching lines...) Expand all
4123 element->focus(); 4123 element->focus();
4124 document->execCommand("InsertText", false, "_wellcome_."); 4124 document->execCommand("InsertText", false, "_wellcome_.");
4125 4125
4126 frame->removeSpellingMarkers(); 4126 frame->removeSpellingMarkers();
4127 4127
4128 const int allTextBeginOffset = 0; 4128 const int allTextBeginOffset = 0;
4129 const int allTextLength = 11; 4129 const int allTextLength = 11;
4130 frame->selectRange(WebRange::fromDocumentRange(frame, allTextBeginOffset, al lTextLength)); 4130 frame->selectRange(WebRange::fromDocumentRange(frame, allTextBeginOffset, al lTextLength));
4131 RefPtr<Range> selectionRange = frame->frame()->selection().toNormalizedRange (); 4131 RefPtr<Range> selectionRange = frame->frame()->selection().toNormalizedRange ();
4132 4132
4133 EXPECT_EQ(0U, document->markers()->markersInRange(selectionRange.get(), Docu mentMarker::Spelling).size()); 4133 EXPECT_EQ(0U, document->markers().markersInRange(selectionRange.get(), Docum entMarker::Spelling).size());
4134 } 4134 }
4135 4135
4136 TEST_F(WebFrameTest, MarkerHashIdentifiers) { 4136 TEST_F(WebFrameTest, MarkerHashIdentifiers) {
4137 registerMockedHttpURLLoad("spell.html"); 4137 registerMockedHttpURLLoad("spell.html");
4138 FrameTestHelpers::WebViewHelper webViewHelper; 4138 FrameTestHelpers::WebViewHelper webViewHelper;
4139 webViewHelper.initializeAndLoad(m_baseURL + "spell.html"); 4139 webViewHelper.initializeAndLoad(m_baseURL + "spell.html");
4140 4140
4141 static const uint32_t kHash = 42; 4141 static const uint32_t kHash = 42;
4142 SpellCheckClient spellcheck(kHash); 4142 SpellCheckClient spellcheck(kHash);
4143 webViewHelper.webView()->setSpellCheckClient(&spellcheck); 4143 webViewHelper.webView()->setSpellCheckClient(&spellcheck);
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
4273 WebInputElement webInputElement = frame->document().getElementById("data").t o<WebInputElement>(); 4273 WebInputElement webInputElement = frame->document().getElementById("data").t o<WebInputElement>();
4274 Document* document = frame->frame()->document(); 4274 Document* document = frame->frame()->document();
4275 Element* element = document->getElementById("data"); 4275 Element* element = document->getElementById("data");
4276 4276
4277 webViewHelper.webView()->settings()->setAsynchronousSpellCheckingEnabled(tru e); 4277 webViewHelper.webView()->settings()->setAsynchronousSpellCheckingEnabled(tru e);
4278 webViewHelper.webView()->settings()->setUnifiedTextCheckerEnabled(true); 4278 webViewHelper.webView()->settings()->setUnifiedTextCheckerEnabled(true);
4279 webViewHelper.webView()->settings()->setEditingBehavior(WebSettings::Editing BehaviorWin); 4279 webViewHelper.webView()->settings()->setEditingBehavior(WebSettings::Editing BehaviorWin);
4280 4280
4281 element->focus(); 4281 element->focus();
4282 document->execCommand("InsertText", false, "welcome "); 4282 document->execCommand("InsertText", false, "welcome ");
4283 document->markers()->addMarker(rangeOfContents(element->toNode()).get(), Doc umentMarker::Spelling); 4283 document->markers().addMarker(rangeOfContents(element->toNode()).get(), Docu mentMarker::Spelling);
4284 document->markers()->addMarker(rangeOfContents(element->toNode()).get(), Doc umentMarker::Grammar); 4284 document->markers().addMarker(rangeOfContents(element->toNode()).get(), Docu mentMarker::Grammar);
4285 document->markers()->addMarker(rangeOfContents(element->toNode()).get(), Doc umentMarker::InvisibleSpellcheck); 4285 document->markers().addMarker(rangeOfContents(element->toNode()).get(), Docu mentMarker::InvisibleSpellcheck);
4286 EXPECT_EQ(3U, document->markers()->markers().size()); 4286 EXPECT_EQ(3U, document->markers().markers().size());
4287 4287
4288 spellcheck.kickNoResults(); 4288 spellcheck.kickNoResults();
4289 EXPECT_EQ(0U, document->markers()->markers().size()); 4289 EXPECT_EQ(0U, document->markers().markers().size());
4290 } 4290 }
4291 4291
4292 TEST_F(WebFrameTest, SpellcheckResultsSavedInDocument) 4292 TEST_F(WebFrameTest, SpellcheckResultsSavedInDocument)
4293 { 4293 {
4294 registerMockedHttpURLLoad("spell.html"); 4294 registerMockedHttpURLLoad("spell.html");
4295 FrameTestHelpers::WebViewHelper webViewHelper; 4295 FrameTestHelpers::WebViewHelper webViewHelper;
4296 webViewHelper.initializeAndLoad(m_baseURL + "spell.html"); 4296 webViewHelper.initializeAndLoad(m_baseURL + "spell.html");
4297 4297
4298 StubbornSpellCheckClient spellcheck; 4298 StubbornSpellCheckClient spellcheck;
4299 webViewHelper.webView()->setSpellCheckClient(&spellcheck); 4299 webViewHelper.webView()->setSpellCheckClient(&spellcheck);
4300 4300
4301 WebFrameImpl* frame = toWebFrameImpl(webViewHelper.webView()->mainFrame()); 4301 WebFrameImpl* frame = toWebFrameImpl(webViewHelper.webView()->mainFrame());
4302 WebInputElement webInputElement = frame->document().getElementById("data").t o<WebInputElement>(); 4302 WebInputElement webInputElement = frame->document().getElementById("data").t o<WebInputElement>();
4303 Document* document = frame->frame()->document(); 4303 Document* document = frame->frame()->document();
4304 Element* element = document->getElementById("data"); 4304 Element* element = document->getElementById("data");
4305 4305
4306 webViewHelper.webView()->settings()->setAsynchronousSpellCheckingEnabled(tru e); 4306 webViewHelper.webView()->settings()->setAsynchronousSpellCheckingEnabled(tru e);
4307 webViewHelper.webView()->settings()->setUnifiedTextCheckerEnabled(true); 4307 webViewHelper.webView()->settings()->setUnifiedTextCheckerEnabled(true);
4308 webViewHelper.webView()->settings()->setEditingBehavior(WebSettings::Editing BehaviorWin); 4308 webViewHelper.webView()->settings()->setEditingBehavior(WebSettings::Editing BehaviorWin);
4309 4309
4310 element->focus(); 4310 element->focus();
4311 document->execCommand("InsertText", false, "wellcome "); 4311 document->execCommand("InsertText", false, "wellcome ");
4312 4312
4313 spellcheck.kick(); 4313 spellcheck.kick();
4314 ASSERT_EQ(1U, document->markers()->markers().size()); 4314 ASSERT_EQ(1U, document->markers().markers().size());
4315 ASSERT_NE(static_cast<DocumentMarker*>(0), document->markers()->markers()[0] ); 4315 ASSERT_NE(static_cast<DocumentMarker*>(0), document->markers().markers()[0]) ;
4316 EXPECT_EQ(DocumentMarker::Spelling, document->markers()->markers()[0]->type( )); 4316 EXPECT_EQ(DocumentMarker::Spelling, document->markers().markers()[0]->type() );
4317 4317
4318 document->execCommand("InsertText", false, "wellcome "); 4318 document->execCommand("InsertText", false, "wellcome ");
4319 4319
4320 spellcheck.kickGrammar(); 4320 spellcheck.kickGrammar();
4321 ASSERT_EQ(1U, document->markers()->markers().size()); 4321 ASSERT_EQ(1U, document->markers().markers().size());
4322 ASSERT_NE(static_cast<DocumentMarker*>(0), document->markers()->markers()[0] ); 4322 ASSERT_NE(static_cast<DocumentMarker*>(0), document->markers().markers()[0]) ;
4323 EXPECT_EQ(DocumentMarker::Grammar, document->markers()->markers()[0]->type() ); 4323 EXPECT_EQ(DocumentMarker::Grammar, document->markers().markers()[0]->type()) ;
4324 4324
4325 document->execCommand("InsertText", false, "wellcome "); 4325 document->execCommand("InsertText", false, "wellcome ");
4326 4326
4327 spellcheck.kickInvisibleSpellcheck(); 4327 spellcheck.kickInvisibleSpellcheck();
4328 ASSERT_EQ(1U, document->markers()->markers().size()); 4328 ASSERT_EQ(1U, document->markers().markers().size());
4329 ASSERT_NE(static_cast<DocumentMarker*>(0), document->markers()->markers()[0] ); 4329 ASSERT_NE(static_cast<DocumentMarker*>(0), document->markers().markers()[0]) ;
4330 EXPECT_EQ(DocumentMarker::InvisibleSpellcheck, document->markers()->markers( )[0]->type()); 4330 EXPECT_EQ(DocumentMarker::InvisibleSpellcheck, document->markers().markers() [0]->type());
4331 } 4331 }
4332 4332
4333 class TestAccessInitialDocumentWebFrameClient : public WebFrameClient { 4333 class TestAccessInitialDocumentWebFrameClient : public WebFrameClient {
4334 public: 4334 public:
4335 TestAccessInitialDocumentWebFrameClient() : m_didAccessInitialDocument(false ) 4335 TestAccessInitialDocumentWebFrameClient() : m_didAccessInitialDocument(false )
4336 { 4336 {
4337 } 4337 }
4338 4338
4339 virtual void didAccessInitialDocument(WebFrame* frame) 4339 virtual void didAccessInitialDocument(WebFrame* frame)
4340 { 4340 {
(...skipping 876 matching lines...) Expand 10 before | Expand all | Expand 10 after
5217 webViewHelper.initializeAndLoad("about:blank"); 5217 webViewHelper.initializeAndLoad("about:blank");
5218 5218
5219 WebCore::FrameView* frameView = webViewHelper.webViewImpl()->mainFrameImpl() ->frameView(); 5219 WebCore::FrameView* frameView = webViewHelper.webViewImpl()->mainFrameImpl() ->frameView();
5220 frameView->setFrameRect(WebCore::IntRect(0, 0, 200, 200)); 5220 frameView->setFrameRect(WebCore::IntRect(0, 0, 200, 200));
5221 EXPECT_EQ_RECT(WebCore::IntRect(0, 0, 200, 200), frameView->frameRect()); 5221 EXPECT_EQ_RECT(WebCore::IntRect(0, 0, 200, 200), frameView->frameRect());
5222 frameView->setFrameRect(WebCore::IntRect(100, 100, 200, 200)); 5222 frameView->setFrameRect(WebCore::IntRect(100, 100, 200, 200));
5223 EXPECT_EQ_RECT(WebCore::IntRect(100, 100, 200, 200), frameView->frameRect()) ; 5223 EXPECT_EQ_RECT(WebCore::IntRect(100, 100, 200, 200), frameView->frameRect()) ;
5224 } 5224 }
5225 5225
5226 } // namespace 5226 } // namespace
OLDNEW
« no previous file with comments | « Source/web/WebViewImpl.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698