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

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

Issue 5120002: TestShell: Backported EventSender.contextClick() improvement (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed feedback 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>
9 10
10 #include "base/string16.h" 11 #include "base/string16.h"
11 12
12 // A mock implementation of a spell-checker used for WebKit tests. 13 // A mock implementation of a spell-checker used for WebKit tests.
13 // This class only implements the minimal functionarities required by WebKit 14 // This class only implements the minimal functionarities required by WebKit
14 // tests, i.e. this class just compares the given string with known misspelled 15 // tests, i.e. this class just compares the given string with known misspelled
15 // words in webkit tests and mark them as missspelled. 16 // words in webkit tests and mark them as missspelled.
16 // Even though this is sufficent for webkit tests, this class is not suitable 17 // Even though this is sufficent for webkit tests, this class is not suitable
17 // for any other usages. 18 // for any other usages.
18 class MockSpellCheck { 19 class MockSpellCheck {
19 public: 20 public:
20 MockSpellCheck(); 21 MockSpellCheck();
21 ~MockSpellCheck(); 22 ~MockSpellCheck();
22 23
23 // Checks the spellings of the specified text. 24 // Checks the spellings of the specified text.
24 // This function returns true if the text consists of valid words, and 25 // This function returns true if the text consists of valid words, and
25 // returns false if it includes invalid words. 26 // returns false if it includes invalid words.
26 // When the given text includes invalid words, this function sets the 27 // When the given text includes invalid words, this function sets the
27 // position of the first invalid word to misspelledOffset, and the length of 28 // position of the first invalid word to misspelledOffset, and the length of
28 // the first invalid word to misspelledLength, respectively. 29 // the first invalid word to misspelledLength, respectively.
29 // For example, when the given text is " zz zz", this function sets 3 to 30 // For example, when the given text is " zz zz", this function sets 3 to
30 // misspelledOffset and 2 to misspelledLength, respectively. 31 // misspelledOffset and 2 to misspelledLength, respectively.
31 bool SpellCheckWord(const string16& text, 32 bool SpellCheckWord(const string16& text,
32 int* misspelledOffset, 33 int* misspelledOffset,
33 int* misspelledLength); 34 int* misspelledLength);
34 35
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);
35 private: 40 private:
36 // Initialize the internal resources if we need to initialize it. 41 // Initialize the internal resources if we need to initialize it.
37 // Initializing this object may take long time. To prevent from hurting 42 // Initializing this object may take long time. To prevent from hurting
38 // the performance of test_shell, we initialize this object when 43 // the performance of test_shell, we initialize this object when
39 // SpellCheckWord() is called for the first time. 44 // SpellCheckWord() is called for the first time.
40 // To be compliant with SpellCheck:InitializeIfNeeded(), this function 45 // To be compliant with SpellCheck:InitializeIfNeeded(), this function
41 // returns true if this object is downloading a dictionary, otherwise 46 // returns true if this object is downloading a dictionary, otherwise
42 // it returns false. 47 // it returns false.
43 bool InitializeIfNeeded(); 48 bool InitializeIfNeeded();
44 49
45 // A table that consists of misspelled words. 50 // A table that consists of misspelled words.
46 std::map<string16, bool> misspelled_words_; 51 std::map<string16, bool> misspelled_words_;
47 52
48 // A flag representing whether or not this object is initialized. 53 // A flag representing whether or not this object is initialized.
49 bool initialized_; 54 bool initialized_;
50 }; 55 };
51 56
52 #endif // WEBKIT_TOOLS_TEST_SHELL_MOCK_SPELLCHECK_H_ 57 #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