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

Unified Diff: third_party/WebKit/Source/core/testing/Internals.cpp

Issue 2727673005: Better spellcheck_test (Closed)
Patch Set: Mon Mar 6 11:18:30 PST 2017 Created 3 years, 9 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: third_party/WebKit/Source/core/testing/Internals.cpp
diff --git a/third_party/WebKit/Source/core/testing/Internals.cpp b/third_party/WebKit/Source/core/testing/Internals.cpp
index 94196d9590e5d6f076a8c95817218efca2ef3863..c74a35d0eff8cccb30dd255013b8b8bc0f089c24 100644
--- a/third_party/WebKit/Source/core/testing/Internals.cpp
+++ b/third_party/WebKit/Source/core/testing/Internals.cpp
@@ -70,6 +70,7 @@
#include "core/editing/markers/DocumentMarker.h"
#include "core/editing/markers/DocumentMarkerController.h"
#include "core/editing/serializers/Serialization.h"
+#include "core/editing/spellcheck/IdleSpellCheckCallback.h"
#include "core/editing/spellcheck/SpellCheckRequester.h"
#include "core/editing/spellcheck/SpellChecker.h"
#include "core/frame/EventHandlerRegistry.h"
@@ -1494,6 +1495,44 @@ int Internals::lastSpellCheckProcessedSequence(Document* document,
return requester->lastProcessedSequence();
}
+String Internals::idleTimeSpellCheckerState(Document* document,
+ ExceptionState& exceptionState) {
+ static const char* const texts[] = {
+#define V(state) #state,
+ FOR_EACH_IDLE_SPELL_CHECK_CALLBACK_STATE(V)
+#undef V
+ };
+
+ if (!document || !document->frame()) {
+ exceptionState.throwDOMException(
+ InvalidAccessError,
+ "No frame can be obtained from the provided document.");
+ return String();
+ }
+
+ IdleSpellCheckCallback::State state =
+ document->frame()->spellChecker().idleSpellCheckCallback().state();
+ const auto& it = std::begin(texts) + static_cast<size_t>(state);
+ DCHECK_GE(it, std::begin(texts)) << "Unknown state value";
+ DCHECK_LT(it, std::end(texts)) << "Unknown state value";
+ return *it;
+}
+
+void Internals::runIdleTimeSpellChecker(Document* document,
+ ExceptionState& exceptionState) {
+ if (!document || !document->frame()) {
+ exceptionState.throwDOMException(
+ InvalidAccessError,
+ "No frame can be obtained from the provided document.");
+ return;
+ }
+
+ document->frame()
+ ->spellChecker()
+ .idleSpellCheckCallback()
+ .forceInvocationForTesting();
+}
+
Vector<AtomicString> Internals::userPreferredLanguages() const {
return blink::userPreferredLanguages();
}
« no previous file with comments | « third_party/WebKit/Source/core/testing/Internals.h ('k') | third_party/WebKit/Source/core/testing/Internals.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698