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

Side by Side Diff: third_party/WebKit/Source/core/testing/Internals.cpp

Issue 2727673005: Better spellcheck_test (Closed)
Patch Set: more minor fix 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * Copyright (C) 2013 Apple Inc. All rights reserved. 3 * Copyright (C) 2013 Apple Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 #include "core/dom/shadow/FlatTreeTraversal.h" 63 #include "core/dom/shadow/FlatTreeTraversal.h"
64 #include "core/dom/shadow/SelectRuleFeatureSet.h" 64 #include "core/dom/shadow/SelectRuleFeatureSet.h"
65 #include "core/dom/shadow/ShadowRoot.h" 65 #include "core/dom/shadow/ShadowRoot.h"
66 #include "core/editing/Editor.h" 66 #include "core/editing/Editor.h"
67 #include "core/editing/PlainTextRange.h" 67 #include "core/editing/PlainTextRange.h"
68 #include "core/editing/SurroundingText.h" 68 #include "core/editing/SurroundingText.h"
69 #include "core/editing/iterators/TextIterator.h" 69 #include "core/editing/iterators/TextIterator.h"
70 #include "core/editing/markers/DocumentMarker.h" 70 #include "core/editing/markers/DocumentMarker.h"
71 #include "core/editing/markers/DocumentMarkerController.h" 71 #include "core/editing/markers/DocumentMarkerController.h"
72 #include "core/editing/serializers/Serialization.h" 72 #include "core/editing/serializers/Serialization.h"
73 #include "core/editing/spellcheck/IdleSpellCheckCallback.h"
73 #include "core/editing/spellcheck/SpellCheckRequester.h" 74 #include "core/editing/spellcheck/SpellCheckRequester.h"
74 #include "core/editing/spellcheck/SpellChecker.h" 75 #include "core/editing/spellcheck/SpellChecker.h"
75 #include "core/frame/EventHandlerRegistry.h" 76 #include "core/frame/EventHandlerRegistry.h"
76 #include "core/frame/FrameConsole.h" 77 #include "core/frame/FrameConsole.h"
77 #include "core/frame/FrameView.h" 78 #include "core/frame/FrameView.h"
78 #include "core/frame/LocalDOMWindow.h" 79 #include "core/frame/LocalDOMWindow.h"
79 #include "core/frame/LocalFrame.h" 80 #include "core/frame/LocalFrame.h"
80 #include "core/frame/Settings.h" 81 #include "core/frame/Settings.h"
81 #include "core/frame/VisualViewport.h" 82 #include "core/frame/VisualViewport.h"
82 #include "core/html/HTMLContentElement.h" 83 #include "core/html/HTMLContentElement.h"
(...skipping 1404 matching lines...) Expand 10 before | Expand all | Expand 10 after
1487 if (!requester) { 1488 if (!requester) {
1488 exceptionState.throwDOMException( 1489 exceptionState.throwDOMException(
1489 InvalidAccessError, 1490 InvalidAccessError,
1490 "No spell check requestor can be obtained for the provided document."); 1491 "No spell check requestor can be obtained for the provided document.");
1491 return -1; 1492 return -1;
1492 } 1493 }
1493 1494
1494 return requester->lastProcessedSequence(); 1495 return requester->lastProcessedSequence();
1495 } 1496 }
1496 1497
1498 String Internals::idleTimeSpellCheckerState(Document* document,
1499 ExceptionState& exceptionState) {
1500 if (!document || !document->frame()) {
1501 exceptionState.throwDOMException(
1502 InvalidAccessError,
1503 "No frame can be obtained from the provided document.");
1504 return String();
1505 }
1506
1507 IdleSpellCheckCallback::State state =
1508 document->frame()->spellChecker().idleSpellCheckCallback().state();
1509 switch (state) {
1510 case IdleSpellCheckCallback::State::kInactive:
yosin_UTC9 2017/03/03 04:44:59 Optional: yet another solution is having FOR_EACH_
Xiaocheng 2017/03/03 18:56:41 Updated with FOR_EACH(V) Thanks for the advice.
1511 return "inactive";
1512 case IdleSpellCheckCallback::State::kHotModeRequested:
1513 return "hot-mode-requested";
1514 case IdleSpellCheckCallback::State::kInHotModeInvocation:
1515 return "in-hot-mode-invocation";
1516 case IdleSpellCheckCallback::State::kColdModeTimerStarted:
1517 return "cold-mode-timer-started";
1518 case IdleSpellCheckCallback::State::kColdModeRequested:
1519 return "cold-mode-requested";
1520 case IdleSpellCheckCallback::State::kInColdModeInvocation:
1521 return "in-cold-mode-invocation";
1522 }
1523 }
1524
1525 void Internals::runIdleTimeSpellChecker(Document* document,
1526 ExceptionState& exceptionState) {
1527 if (!document || !document->frame()) {
1528 exceptionState.throwDOMException(
1529 InvalidAccessError,
1530 "No frame can be obtained from the provided document.");
1531 return;
1532 }
1533
1534 document->frame()
1535 ->spellChecker()
1536 .idleSpellCheckCallback()
1537 .forceInvocationForTesting();
1538 }
1539
1497 Vector<AtomicString> Internals::userPreferredLanguages() const { 1540 Vector<AtomicString> Internals::userPreferredLanguages() const {
1498 return blink::userPreferredLanguages(); 1541 return blink::userPreferredLanguages();
1499 } 1542 }
1500 1543
1501 // Optimally, the bindings generator would pass a Vector<AtomicString> here but 1544 // Optimally, the bindings generator would pass a Vector<AtomicString> here but
1502 // this is not supported yet. 1545 // this is not supported yet.
1503 void Internals::setUserPreferredLanguages(const Vector<String>& languages) { 1546 void Internals::setUserPreferredLanguages(const Vector<String>& languages) {
1504 Vector<AtomicString> atomicLanguages; 1547 Vector<AtomicString> atomicLanguages;
1505 for (size_t i = 0; i < languages.size(); ++i) 1548 for (size_t i = 0; i < languages.size(); ++i)
1506 atomicLanguages.push_back(AtomicString(languages[i])); 1549 atomicLanguages.push_back(AtomicString(languages[i]));
(...skipping 1669 matching lines...) Expand 10 before | Expand all | Expand 10 after
3176 3219
3177 void Internals::crash() { 3220 void Internals::crash() {
3178 CHECK(false) << "Intentional crash"; 3221 CHECK(false) << "Intentional crash";
3179 } 3222 }
3180 3223
3181 void Internals::setIsLowEndDevice(bool isLowEndDevice) { 3224 void Internals::setIsLowEndDevice(bool isLowEndDevice) {
3182 MemoryCoordinator::setIsLowEndDeviceForTesting(isLowEndDevice); 3225 MemoryCoordinator::setIsLowEndDeviceForTesting(isLowEndDevice);
3183 } 3226 }
3184 3227
3185 } // namespace blink 3228 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698