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

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

Issue 419563003: Adding a word to dictionary should remove spelling markers (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Addressed comment Created 6 years, 4 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
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 4400 matching lines...) Expand 10 before | Expand all | Expand 10 after
4411 frame->removeSpellingMarkers(); 4411 frame->removeSpellingMarkers();
4412 4412
4413 const int allTextBeginOffset = 0; 4413 const int allTextBeginOffset = 0;
4414 const int allTextLength = 11; 4414 const int allTextLength = 11;
4415 frame->selectRange(WebRange::fromDocumentRange(frame, allTextBeginOffset, al lTextLength)); 4415 frame->selectRange(WebRange::fromDocumentRange(frame, allTextBeginOffset, al lTextLength));
4416 RefPtrWillBeRawPtr<Range> selectionRange = frame->frame()->selection().toNor malizedRange(); 4416 RefPtrWillBeRawPtr<Range> selectionRange = frame->frame()->selection().toNor malizedRange();
4417 4417
4418 EXPECT_EQ(0U, document->markers().markersInRange(selectionRange.get(), Docum entMarker::Spelling).size()); 4418 EXPECT_EQ(0U, document->markers().markersInRange(selectionRange.get(), Docum entMarker::Spelling).size());
4419 } 4419 }
4420 4420
4421 TEST_F(WebFrameTest, RemoveSpellingMarkersUnderWords)
4422 {
4423 registerMockedHttpURLLoad("spell.html");
4424 FrameTestHelpers::WebViewHelper webViewHelper;
4425 webViewHelper.initializeAndLoad(m_baseURL + "spell.html");
4426 SpellCheckClient spellcheck;
4427 webViewHelper.webView()->setSpellCheckClient(&spellcheck);
4428
4429 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webViewHelper.webView()->main Frame());
4430 Document* document = frame->frame()->document();
4431 Element* element = document->getElementById("data");
4432
4433 webViewHelper.webView()->settings()->setAsynchronousSpellCheckingEnabled(tru e);
4434 webViewHelper.webView()->settings()->setUnifiedTextCheckerEnabled(true);
4435 webViewHelper.webView()->settings()->setEditingBehavior(WebSettings::Editing BehaviorWin);
4436
4437 element->focus();
4438 document->execCommand("InsertText", false, " wellcome ");
4439
4440 WebVector<uint32_t> documentMarkers1;
4441 webViewHelper.webView()->spellingMarkers(&documentMarkers1);
4442 EXPECT_EQ(1U, documentMarkers1.size());
4443
4444 auto word = WebString::fromUTF8("wellcome");
4445 WebVector<WebString> words(&word, 1);
4446 frame->removeSpellingMarkersUnderWords(words);
4447
4448 WebVector<uint32_t> documentMarkers2;
4449 webViewHelper.webView()->spellingMarkers(&documentMarkers2);
4450 EXPECT_EQ(0U, documentMarkers2.size());
4451 }
4452
4421 TEST_F(WebFrameTest, MarkerHashIdentifiers) { 4453 TEST_F(WebFrameTest, MarkerHashIdentifiers) {
4422 registerMockedHttpURLLoad("spell.html"); 4454 registerMockedHttpURLLoad("spell.html");
4423 FrameTestHelpers::WebViewHelper webViewHelper; 4455 FrameTestHelpers::WebViewHelper webViewHelper;
4424 webViewHelper.initializeAndLoad(m_baseURL + "spell.html"); 4456 webViewHelper.initializeAndLoad(m_baseURL + "spell.html");
4425 4457
4426 static const uint32_t kHash = 42; 4458 static const uint32_t kHash = 42;
4427 SpellCheckClient spellcheck(kHash); 4459 SpellCheckClient spellcheck(kHash);
4428 webViewHelper.webView()->setSpellCheckClient(&spellcheck); 4460 webViewHelper.webView()->setSpellCheckClient(&spellcheck);
4429 4461
4430 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webViewHelper.webView()->main Frame()); 4462 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webViewHelper.webView()->main Frame());
(...skipping 1491 matching lines...) Expand 10 before | Expand all | Expand 10 after
5922 5954
5923 client.reset(); 5955 client.reset();
5924 // Try to load the request with cross origin access. Should succeed. 5956 // Try to load the request with cross origin access. Should succeed.
5925 options.crossOriginRequestPolicy = blink::AllowCrossOriginRequests; 5957 options.crossOriginRequestPolicy = blink::AllowCrossOriginRequests;
5926 blink::DocumentThreadableLoader::loadResourceSynchronously( 5958 blink::DocumentThreadableLoader::loadResourceSynchronously(
5927 *frame->document(), blink::ResourceRequest(resourceUrl), client, options , resourceLoaderOptions); 5959 *frame->document(), blink::ResourceRequest(resourceUrl), client, options , resourceLoaderOptions);
5928 EXPECT_FALSE(client.failed()); 5960 EXPECT_FALSE(client.failed());
5929 } 5961 }
5930 5962
5931 } // namespace 5963 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698