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

Side by Side Diff: content/shell/renderer/test_runner/mock_spell_check.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, 5 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
(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_MOCK_SPELL_CHECK_H_
6 #define CONTENT_SHELL_RENDERER_TEST_RUNNER_MOCK_SPELL_CHECK_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(
26 const blink::WebString& word,
27 blink::WebVector<blink::WebString>* suggestions);
28
29 MockSpellCheck();
30 ~MockSpellCheck();
31
32 // Checks the spellings of the specified text.
33 // This function returns true if the text consists of valid words, and
34 // returns false if it includes invalid words.
35 // When the given text includes invalid words, this function sets the
36 // position of the first invalid word to misspelledOffset, and the length of
37 // the first invalid word to misspelledLength, respectively.
38 // For example, when the given text is " zz zz", this function sets 3 to
39 // misspelledOffset and 2 to misspelledLength, respectively.
40 bool SpellCheckWord(const blink::WebString& text,
41 int* misspelled_offset,
42 int* misspelled_length);
43
44 // Checks whether the specified text can be spell checked immediately using
45 // the spell checker cache.
46 bool HasInCache(const blink::WebString& text);
47
48 // Checks whether the specified text is a misspelling comprised of more
49 // than one word. If it is, append multiple results to the results vector.
50 bool IsMultiWordMisspelling(
51 const blink::WebString& text,
52 std::vector<blink::WebTextCheckingResult>* results);
53
54 private:
55 // Initialize the internal resources if we need to initialize it.
56 // Initializing this object may take long time. To prevent from hurting
57 // the performance of test_shell, we initialize this object when
58 // SpellCheckWord() is called for the first time.
59 // To be compliant with SpellCheck:InitializeIfNeeded(), this function
60 // returns true if this object is downloading a dictionary, otherwise
61 // it returns false.
62 bool InitializeIfNeeded();
63
64 // A table that consists of misspelled words.
65 std::vector<base::string16> misspelled_words_;
66
67 // A flag representing whether or not this object is initialized.
68 bool initialized_;
69
70 DISALLOW_COPY_AND_ASSIGN(MockSpellCheck);
71 };
72
73 } // namespace content
74
75 #endif // CONTENT_SHELL_RENDERER_TEST_RUNNER_MOCK_SPELL_CHECK_H_
OLDNEW
« no previous file with comments | « content/shell/renderer/test_runner/event_sender.cc ('k') | content/shell/renderer/test_runner/mock_spell_check.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698