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

Side by Side Diff: content/shell/renderer/test_runner/MockGrammarCheck.cpp

Issue 251263002: test_runner: Move three Mock* files into content namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
OLDNEW
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 "content/shell/renderer/test_runner/MockGrammarCheck.h" 5 #include "content/shell/renderer/test_runner/MockGrammarCheck.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "content/shell/renderer/test_runner/TestCommon.h" 10 #include "content/shell/renderer/test_runner/TestCommon.h"
11 #include "third_party/WebKit/public/platform/WebCString.h" 11 #include "third_party/WebKit/public/platform/WebCString.h"
12 #include "third_party/WebKit/public/platform/WebString.h" 12 #include "third_party/WebKit/public/platform/WebString.h"
13 #include "third_party/WebKit/public/web/WebTextCheckingResult.h" 13 #include "third_party/WebKit/public/web/WebTextCheckingResult.h"
14 14
15 using namespace blink; 15 using namespace blink;
16 using namespace std; 16 using namespace std;
17 17
18 namespace WebTestRunner { 18 namespace content {
19 19
20 bool MockGrammarCheck::checkGrammarOfString(const WebString& text, vector<WebTex tCheckingResult>* results) 20 bool MockGrammarCheck::checkGrammarOfString(const WebString& text, vector<WebTex tCheckingResult>* results)
21 { 21 {
22 DCHECK(results); 22 DCHECK(results);
23 base::string16 stringText = text; 23 base::string16 stringText = text;
24 if (find_if(stringText.begin(), stringText.end(), isASCIIAlpha) == stringTex t.end()) 24 if (find_if(stringText.begin(), stringText.end(), WebTestRunner::isASCIIAlph a) == stringText.end())
25 return true; 25 return true;
26 26
27 // Find matching grammatical errors from known ones. This function has to 27 // Find matching grammatical errors from known ones. This function has to
28 // check all errors because the given text may consist of two or more 28 // check all errors because the given text may consist of two or more
29 // sentences that have grammatical errors. 29 // sentences that have grammatical errors.
30 static const struct { 30 static const struct {
31 const char* text; 31 const char* text;
32 int location; 32 int location;
33 int length; 33 int length;
34 } grammarErrors[] = { 34 } grammarErrors[] = {
(...skipping 14 matching lines...) Expand all
49 size_t offset = 0; 49 size_t offset = 0;
50 base::string16 error(grammarErrors[i].text, grammarErrors[i].text + strl en(grammarErrors[i].text)); 50 base::string16 error(grammarErrors[i].text, grammarErrors[i].text + strl en(grammarErrors[i].text));
51 while ((offset = stringText.find(error, offset)) != base::string16::npos ) { 51 while ((offset = stringText.find(error, offset)) != base::string16::npos ) {
52 results->push_back(WebTextCheckingResult(WebTextDecorationTypeGramma r, offset + grammarErrors[i].location, grammarErrors[i].length)); 52 results->push_back(WebTextCheckingResult(WebTextDecorationTypeGramma r, offset + grammarErrors[i].location, grammarErrors[i].length));
53 offset += grammarErrors[i].length; 53 offset += grammarErrors[i].length;
54 } 54 }
55 } 55 }
56 return false; 56 return false;
57 } 57 }
58 58
59 } 59 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698