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

Unified Diff: components/test_runner/spell_check_client.cc

Issue 2270293003: Add a switch to TestRunner to enable/disable mock spell checker (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebaselined tests Created 4 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 side-by-side diff with in-line comments
Download patch
Index: components/test_runner/spell_check_client.cc
diff --git a/components/test_runner/spell_check_client.cc b/components/test_runner/spell_check_client.cc
index 94ad604a01948630b226bcf95b09818695f16dcd..f2960ac9d1e52811f01af7e146a0b7d34f0eebb3 100644
--- a/components/test_runner/spell_check_client.cc
+++ b/components/test_runner/spell_check_client.cc
@@ -20,7 +20,8 @@
namespace test_runner {
SpellCheckClient::SpellCheckClient(TestRunner* test_runner)
- : last_requested_text_checking_completion_(nullptr),
+ : enabled_(false),
yosin_UTC9 2016/08/24 08:00:38 nit: let's initialize |enabled_| in class declarat
Xiaocheng 2016/08/24 08:28:23 Done.
+ last_requested_text_checking_completion_(nullptr),
test_runner_(test_runner),
weak_factory_(this) {
DCHECK(test_runner);
@@ -33,12 +34,22 @@ void SpellCheckClient::SetDelegate(WebTestDelegate* delegate) {
delegate_ = delegate;
}
+void SpellCheckClient::SetEnabled(bool enabled) {
+ enabled_ = enabled;
+}
+
// blink::WebSpellCheckClient
void SpellCheckClient::spellCheck(
const blink::WebString& text,
int& misspelled_offset,
int& misspelled_length,
blink::WebVector<blink::WebString>* optional_suggestions) {
+ if (!enabled_) {
+ misspelled_offset = 0;
+ misspelled_length = 0;
+ return;
+ }
+
// Check the spelling of the given text.
spell_check_.SpellCheckWord(text, &misspelled_offset, &misspelled_length);
}
@@ -48,7 +59,7 @@ void SpellCheckClient::requestCheckingOfText(
const blink::WebVector<uint32_t>& markers,
const blink::WebVector<unsigned>& marker_offsets,
blink::WebTextCheckingCompletion* completion) {
- if (text.isEmpty()) {
+ if (!enabled_ || text.isEmpty()) {
if (completion)
completion->didCancelCheckingText();
return;

Powered by Google App Engine
This is Rietveld 408576698