| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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 #include "components/test_runner/mock_grammar_check.h" | 5 #include "components/test_runner/mock_grammar_check.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "components/test_runner/test_common.h" | 13 #include "components/test_runner/test_common.h" |
| 14 #include "third_party/WebKit/public/platform/WebString.h" | 14 #include "third_party/WebKit/public/platform/WebString.h" |
| 15 #include "third_party/WebKit/public/web/WebTextCheckingResult.h" | 15 #include "third_party/WebKit/public/web/WebTextCheckingResult.h" |
| 16 | 16 |
| 17 namespace test_runner { | 17 namespace test_runner { |
| 18 | 18 |
| 19 bool MockGrammarCheck::CheckGrammarOfString( | 19 bool MockGrammarCheck::CheckGrammarOfString( |
| 20 const blink::WebString& text, | 20 const blink::WebString& text, |
| 21 std::vector<blink::WebTextCheckingResult>* results) { | 21 std::vector<blink::WebTextCheckingResult>* results) { |
| 22 DCHECK(results); | 22 DCHECK(results); |
| 23 base::string16 string_text = text; | 23 base::string16 string_text = text.utf16(); |
| 24 if (std::find_if(string_text.begin(), string_text.end(), IsASCIIAlpha) == | 24 if (std::find_if(string_text.begin(), string_text.end(), IsASCIIAlpha) == |
| 25 string_text.end()) | 25 string_text.end()) |
| 26 return true; | 26 return true; |
| 27 | 27 |
| 28 // Find matching grammatical errors from known ones. This function has to | 28 // Find matching grammatical errors from known ones. This function has to |
| 29 // check all errors because the given text may consist of two or more | 29 // check all errors because the given text may consist of two or more |
| 30 // sentences that have grammatical errors. | 30 // sentences that have grammatical errors. |
| 31 static const struct { | 31 static const struct { |
| 32 const char* text; | 32 const char* text; |
| 33 int location; | 33 int location; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 56 blink::WebTextCheckingResult(blink::WebTextDecorationTypeGrammar, | 56 blink::WebTextCheckingResult(blink::WebTextDecorationTypeGrammar, |
| 57 offset + kGrammarErrors[i].location, | 57 offset + kGrammarErrors[i].location, |
| 58 kGrammarErrors[i].length)); | 58 kGrammarErrors[i].length)); |
| 59 offset += kGrammarErrors[i].length; | 59 offset += kGrammarErrors[i].length; |
| 60 } | 60 } |
| 61 } | 61 } |
| 62 return false; | 62 return false; |
| 63 } | 63 } |
| 64 | 64 |
| 65 } // namespace test_runner | 65 } // namespace test_runner |
| OLD | NEW |