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

Side by Side Diff: Source/testing/runner/MockGrammarCheck.cpp

Issue 105143014: Add base:: to string16 in Source/testing/runner/. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years 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
« no previous file with comments | « no previous file | Source/testing/runner/MockSpellCheck.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 26 matching lines...) Expand all
37 #include <algorithm> 37 #include <algorithm>
38 38
39 using namespace blink; 39 using namespace blink;
40 using namespace std; 40 using namespace std;
41 41
42 namespace WebTestRunner { 42 namespace WebTestRunner {
43 43
44 bool MockGrammarCheck::checkGrammarOfString(const WebString& text, vector<WebTex tCheckingResult>* results) 44 bool MockGrammarCheck::checkGrammarOfString(const WebString& text, vector<WebTex tCheckingResult>* results)
45 { 45 {
46 BLINK_ASSERT(results); 46 BLINK_ASSERT(results);
47 string16 stringText = text; 47 base::string16 stringText = text;
48 if (find_if(stringText.begin(), stringText.end(), isASCIIAlpha) == stringTex t.end()) 48 if (find_if(stringText.begin(), stringText.end(), isASCIIAlpha) == stringTex t.end())
49 return true; 49 return true;
50 50
51 // Find matching grammatical errors from known ones. This function has to 51 // Find matching grammatical errors from known ones. This function has to
52 // check all errors because the given text may consist of two or more 52 // check all errors because the given text may consist of two or more
53 // sentences that have grammatical errors. 53 // sentences that have grammatical errors.
54 static const struct { 54 static const struct {
55 const char* text; 55 const char* text;
56 int location; 56 int location;
57 int length; 57 int length;
58 } grammarErrors[] = { 58 } grammarErrors[] = {
59 {"I have a issue.", 7, 1}, 59 {"I have a issue.", 7, 1},
60 {"I have an grape.", 7, 2}, 60 {"I have an grape.", 7, 2},
61 {"I have an kiwi.", 7, 2}, 61 {"I have an kiwi.", 7, 2},
62 {"I have an muscat.", 7, 2}, 62 {"I have an muscat.", 7, 2},
63 {"You has the right.", 4, 3}, 63 {"You has the right.", 4, 3},
64 {"apple orange zz.", 0, 16}, 64 {"apple orange zz.", 0, 16},
65 {"apple zz orange.", 0, 16}, 65 {"apple zz orange.", 0, 16},
66 {"apple,zz,orange.", 0, 16}, 66 {"apple,zz,orange.", 0, 16},
67 {"orange,zz,apple.", 0, 16}, 67 {"orange,zz,apple.", 0, 16},
68 {"the the adlj adaasj sdklj. there there", 4, 3}, 68 {"the the adlj adaasj sdklj. there there", 4, 3},
69 {"the the adlj adaasj sdklj. there there", 33, 5}, 69 {"the the adlj adaasj sdklj. there there", 33, 5},
70 {"zz apple orange.", 0, 16}, 70 {"zz apple orange.", 0, 16},
71 }; 71 };
72 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(grammarErrors); ++i) { 72 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(grammarErrors); ++i) {
73 size_t offset = 0; 73 size_t offset = 0;
74 string16 error(grammarErrors[i].text, grammarErrors[i].text + strlen(gra mmarErrors[i].text)); 74 base::string16 error(grammarErrors[i].text, grammarErrors[i].text + strl en(grammarErrors[i].text));
75 while ((offset = stringText.find(error, offset)) != string16::npos) { 75 while ((offset = stringText.find(error, offset)) != base::string16::npos ) {
76 results->push_back(WebTextCheckingResult(WebTextDecorationTypeGramma r, offset + grammarErrors[i].location, grammarErrors[i].length)); 76 results->push_back(WebTextCheckingResult(WebTextDecorationTypeGramma r, offset + grammarErrors[i].location, grammarErrors[i].length));
77 offset += grammarErrors[i].length; 77 offset += grammarErrors[i].length;
78 } 78 }
79 } 79 }
80 return false; 80 return false;
81 } 81 }
82 82
83 } 83 }
OLDNEW
« no previous file with comments | « no previous file | Source/testing/runner/MockSpellCheck.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698