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

Side by Side Diff: webkit/tools/test_shell/mock_spellcheck.h

Issue 5363002: Revert 67248 - TestShell: Backported EventSender.contextClick() improvement t... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef WEBKIT_TOOLS_TEST_SHELL_MOCK_SPELLCHECK_H_ 5 #ifndef WEBKIT_TOOLS_TEST_SHELL_MOCK_SPELLCHECK_H_
6 #define WEBKIT_TOOLS_TEST_SHELL_MOCK_SPELLCHECK_H_ 6 #define WEBKIT_TOOLS_TEST_SHELL_MOCK_SPELLCHECK_H_
7 7
8 #include <map> 8 #include <map>
9 #include <vector>
10 9
11 #include "base/string16.h" 10 #include "base/string16.h"
12 11
13 // A mock implementation of a spell-checker used for WebKit tests. 12 // A mock implementation of a spell-checker used for WebKit tests.
14 // This class only implements the minimal functionarities required by WebKit 13 // This class only implements the minimal functionarities required by WebKit
15 // tests, i.e. this class just compares the given string with known misspelled 14 // tests, i.e. this class just compares the given string with known misspelled
16 // words in webkit tests and mark them as missspelled. 15 // words in webkit tests and mark them as missspelled.
17 // Even though this is sufficent for webkit tests, this class is not suitable 16 // Even though this is sufficent for webkit tests, this class is not suitable
18 // for any other usages. 17 // for any other usages.
19 class MockSpellCheck { 18 class MockSpellCheck {
20 public: 19 public:
21 MockSpellCheck(); 20 MockSpellCheck();
22 ~MockSpellCheck(); 21 ~MockSpellCheck();
23 22
24 // Checks the spellings of the specified text. 23 // Checks the spellings of the specified text.
25 // This function returns true if the text consists of valid words, and 24 // This function returns true if the text consists of valid words, and
26 // returns false if it includes invalid words. 25 // returns false if it includes invalid words.
27 // When the given text includes invalid words, this function sets the 26 // When the given text includes invalid words, this function sets the
28 // position of the first invalid word to misspelledOffset, and the length of 27 // position of the first invalid word to misspelledOffset, and the length of
29 // the first invalid word to misspelledLength, respectively. 28 // the first invalid word to misspelledLength, respectively.
30 // For example, when the given text is " zz zz", this function sets 3 to 29 // For example, when the given text is " zz zz", this function sets 3 to
31 // misspelledOffset and 2 to misspelledLength, respectively. 30 // misspelledOffset and 2 to misspelledLength, respectively.
32 bool SpellCheckWord(const string16& text, 31 bool SpellCheckWord(const string16& text,
33 int* misspelledOffset, 32 int* misspelledOffset,
34 int* misspelledLength); 33 int* misspelledLength);
35 34
36 // Emulates suggestions for misspelled words.
37 // The suggestions are pushed to |suggestions| parameters.
38 void FillSuggestions(const string16& word,
39 std::vector<string16>* suggestions);
40 private: 35 private:
41 // Initialize the internal resources if we need to initialize it. 36 // Initialize the internal resources if we need to initialize it.
42 // Initializing this object may take long time. To prevent from hurting 37 // Initializing this object may take long time. To prevent from hurting
43 // the performance of test_shell, we initialize this object when 38 // the performance of test_shell, we initialize this object when
44 // SpellCheckWord() is called for the first time. 39 // SpellCheckWord() is called for the first time.
45 // To be compliant with SpellCheck:InitializeIfNeeded(), this function 40 // To be compliant with SpellCheck:InitializeIfNeeded(), this function
46 // returns true if this object is downloading a dictionary, otherwise 41 // returns true if this object is downloading a dictionary, otherwise
47 // it returns false. 42 // it returns false.
48 bool InitializeIfNeeded(); 43 bool InitializeIfNeeded();
49 44
50 // A table that consists of misspelled words. 45 // A table that consists of misspelled words.
51 std::map<string16, bool> misspelled_words_; 46 std::map<string16, bool> misspelled_words_;
52 47
53 // A flag representing whether or not this object is initialized. 48 // A flag representing whether or not this object is initialized.
54 bool initialized_; 49 bool initialized_;
55 }; 50 };
56 51
57 #endif // WEBKIT_TOOLS_TEST_SHELL_MOCK_SPELLCHECK_H_ 52 #endif // WEBKIT_TOOLS_TEST_SHELL_MOCK_SPELLCHECK_H_
OLDNEW
« no previous file with comments | « webkit/tools/test_shell/event_sending_controller.cc ('k') | webkit/tools/test_shell/mock_spellcheck.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698