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

Side by Side Diff: chrome/browser/spellchecker/spelling_service_client_unittest.cc

Issue 2848943002: Allow storing multiple replacements on SpellCheckResult (Closed)
Patch Set: Rebase Created 3 years, 6 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/spellcheck/browser/spelling_service_client.h" 5 #include "components/spellcheck/browser/spelling_service_client.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 fetcher_ = NULL; 153 fetcher_ = NULL;
154 } 154 }
155 155
156 void VerifyResponse(bool success, 156 void VerifyResponse(bool success,
157 const base::string16& request_text, 157 const base::string16& request_text,
158 const std::vector<SpellCheckResult>& results) { 158 const std::vector<SpellCheckResult>& results) {
159 EXPECT_EQ(success_, success); 159 EXPECT_EQ(success_, success);
160 base::string16 text(base::UTF8ToUTF16(sanitized_request_text_)); 160 base::string16 text(base::UTF8ToUTF16(sanitized_request_text_));
161 for (std::vector<SpellCheckResult>::const_iterator it = results.begin(); 161 for (std::vector<SpellCheckResult>::const_iterator it = results.begin();
162 it != results.end(); ++it) { 162 it != results.end(); ++it) {
163 text.replace(it->location, it->length, it->replacement); 163 text.replace(it->location, it->length, it->replacements[0]);
164 } 164 }
165 EXPECT_EQ(corrected_text_, text); 165 EXPECT_EQ(corrected_text_, text);
166 } 166 }
167 167
168 bool ParseResponseSuccess(const std::string& data) { 168 bool ParseResponseSuccess(const std::string& data) {
169 std::vector<SpellCheckResult> results; 169 std::vector<SpellCheckResult> results;
170 return ParseResponse(data, &results); 170 return ParseResponse(data, &results);
171 } 171 }
172 172
173 private: 173 private:
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 EXPECT_FALSE(client_.IsAvailable(&profile_, kSpellcheck)); 418 EXPECT_FALSE(client_.IsAvailable(&profile_, kSpellcheck));
419 } 419 }
420 } 420 }
421 421
422 // Verify that an error in JSON response from spelling service will result in 422 // Verify that an error in JSON response from spelling service will result in
423 // ParseResponse returning false. 423 // ParseResponse returning false.
424 TEST_F(SpellingServiceClientTest, ResponseErrorTest) { 424 TEST_F(SpellingServiceClientTest, ResponseErrorTest) {
425 EXPECT_TRUE(client_.ParseResponseSuccess("{\"result\": {}}")); 425 EXPECT_TRUE(client_.ParseResponseSuccess("{\"result\": {}}"));
426 EXPECT_FALSE(client_.ParseResponseSuccess("{\"error\": {}}")); 426 EXPECT_FALSE(client_.ParseResponseSuccess("{\"error\": {}}"));
427 } 427 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698