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

Side by Side Diff: content/shell/renderer/test_runner/MockSpellCheck.h

Issue 410283003: test_runner: Migrate MockSpellCheck to Chromium C++ style. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated Build.gn 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
« no previous file with comments | « content/shell/BUILD.gn ('k') | content/shell/renderer/test_runner/MockSpellCheck.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_SHELL_RENDERER_TEST_RUNNER_MOCKSPELLCHECK_H_
6 #define CONTENT_SHELL_RENDERER_TEST_RUNNER_MOCKSPELLCHECK_H_
7
8 #include <vector>
9
10 #include "base/basictypes.h"
11 #include "third_party/WebKit/public/platform/WebString.h"
12 #include "third_party/WebKit/public/platform/WebVector.h"
13 #include "third_party/WebKit/public/web/WebTextCheckingResult.h"
14
15 namespace content {
16
17 // A mock implementation of a spell-checker used for WebKit tests.
18 // This class only implements the minimal functionarities required by WebKit
19 // tests, i.e. this class just compares the given string with known misspelled
20 // words in webkit tests and mark them as missspelled.
21 // Even though this is sufficent for webkit tests, this class is not suitable
22 // for any other usages.
23 class MockSpellCheck {
24 public:
25 static void fillSuggestionList(const blink::WebString& word, blink::WebVecto r<blink::WebString>* suggestions);
26
27 MockSpellCheck();
28 ~MockSpellCheck();
29
30 // Checks the spellings of the specified text.
31 // This function returns true if the text consists of valid words, and
32 // returns false if it includes invalid words.
33 // When the given text includes invalid words, this function sets the
34 // position of the first invalid word to misspelledOffset, and the length of
35 // the first invalid word to misspelledLength, respectively.
36 // For example, when the given text is " zz zz", this function sets 3 to
37 // misspelledOffset and 2 to misspelledLength, respectively.
38 bool spellCheckWord(const blink::WebString& text, int* misspelledOffset, int * misspelledLength);
39
40 // Checks whether the specified text can be spell checked immediately using
41 // the spell checker cache.
42 bool hasInCache(const blink::WebString& text);
43
44 // Checks whether the specified text is a misspelling comprised of more
45 // than one word. If it is, append multiple results to the results vector.
46 bool isMultiWordMisspelling(const blink::WebString& text, std::vector<blink: :WebTextCheckingResult>* results);
47
48 private:
49 // Initialize the internal resources if we need to initialize it.
50 // Initializing this object may take long time. To prevent from hurting
51 // the performance of test_shell, we initialize this object when
52 // SpellCheckWord() is called for the first time.
53 // To be compliant with SpellCheck:InitializeIfNeeded(), this function
54 // returns true if this object is downloading a dictionary, otherwise
55 // it returns false.
56 bool initializeIfNeeded();
57
58 // A table that consists of misspelled words.
59 std::vector<base::string16> m_misspelledWords;
60
61 // A flag representing whether or not this object is initialized.
62 bool m_initialized;
63
64 DISALLOW_COPY_AND_ASSIGN(MockSpellCheck);
65 };
66
67 } // namespace content
68
69 #endif // CONTENT_SHELL_RENDERER_TEST_RUNNER_MOCKSPELLCHECK_H_
OLDNEW
« no previous file with comments | « content/shell/BUILD.gn ('k') | content/shell/renderer/test_runner/MockSpellCheck.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698