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

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

Issue 1545223002: Switch to standard integer types in chrome/browser/, part 4 of 4. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 4 years, 12 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 // Unit tests for |FeedbackSender| object. 5 // Unit tests for |FeedbackSender| object.
6 6
7 #include "chrome/browser/spellchecker/feedback_sender.h" 7 #include "chrome/browser/spellchecker/feedback_sender.h"
8 8
9 #include <stddef.h>
10 #include <stdint.h>
11
9 #include "base/bind.h" 12 #include "base/bind.h"
10 #include "base/command_line.h" 13 #include "base/command_line.h"
11 #include "base/json/json_reader.h" 14 #include "base/json/json_reader.h"
12 #include "base/message_loop/message_loop.h" 15 #include "base/message_loop/message_loop.h"
13 #include "base/metrics/field_trial.h" 16 #include "base/metrics/field_trial.h"
14 #include "base/strings/stringprintf.h" 17 #include "base/strings/stringprintf.h"
15 #include "base/strings/utf_string_conversions.h" 18 #include "base/strings/utf_string_conversions.h"
16 #include "base/values.h" 19 #include "base/values.h"
17 #include "chrome/common/chrome_switches.h" 20 #include "chrome/common/chrome_switches.h"
18 #include "chrome/common/spellcheck_common.h" 21 #include "chrome/common/spellcheck_common.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 // TODO(rouslan): Remove the field trial. http://crbug.com/247726 89 // TODO(rouslan): Remove the field trial. http://crbug.com/247726
87 field_trial_list_.reset( 90 field_trial_list_.reset(
88 new base::FieldTrialList(new metrics::SHA1EntropyProvider("foo"))); 91 new base::FieldTrialList(new metrics::SHA1EntropyProvider("foo")));
89 field_trial_ = base::FieldTrialList::CreateFieldTrial( 92 field_trial_ = base::FieldTrialList::CreateFieldTrial(
90 kFeedbackFieldTrialName, kFeedbackFieldTrialEnabledGroupName); 93 kFeedbackFieldTrialName, kFeedbackFieldTrialEnabledGroupName);
91 field_trial_->group(); 94 field_trial_->group();
92 feedback_.reset(new FeedbackSender(NULL, kLanguage, kCountry)); 95 feedback_.reset(new FeedbackSender(NULL, kLanguage, kCountry));
93 feedback_->StartFeedbackCollection(); 96 feedback_->StartFeedbackCollection();
94 } 97 }
95 98
96 uint32 AddPendingFeedback() { 99 uint32_t AddPendingFeedback() {
97 std::vector<SpellCheckResult> results(1, BuildSpellCheckResult()); 100 std::vector<SpellCheckResult> results(1, BuildSpellCheckResult());
98 feedback_->OnSpellcheckResults(kRendererProcessId, 101 feedback_->OnSpellcheckResults(kRendererProcessId,
99 base::UTF8ToUTF16(kText), 102 base::UTF8ToUTF16(kText),
100 std::vector<SpellCheckMarker>(), 103 std::vector<SpellCheckMarker>(),
101 &results); 104 &results);
102 return results[0].hash; 105 return results[0].hash;
103 } 106 }
104 107
105 void ExpireSession() { 108 void ExpireSession() {
106 feedback_->session_start_ = 109 feedback_->session_start_ =
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 content::TestBrowserThread ui_thread_; 149 content::TestBrowserThread ui_thread_;
147 scoped_ptr<base::FieldTrialList> field_trial_list_; 150 scoped_ptr<base::FieldTrialList> field_trial_list_;
148 scoped_refptr<base::FieldTrial> field_trial_; 151 scoped_refptr<base::FieldTrial> field_trial_;
149 net::TestURLFetcherFactory fetchers_; 152 net::TestURLFetcherFactory fetchers_;
150 }; 153 };
151 154
152 // Do not send data if there's no feedback. 155 // Do not send data if there's no feedback.
153 TEST_F(FeedbackSenderTest, NoFeedback) { 156 TEST_F(FeedbackSenderTest, NoFeedback) {
154 EXPECT_FALSE(IsUploadingData()); 157 EXPECT_FALSE(IsUploadingData());
155 feedback_->OnReceiveDocumentMarkers(kRendererProcessId, 158 feedback_->OnReceiveDocumentMarkers(kRendererProcessId,
156 std::vector<uint32>()); 159 std::vector<uint32_t>());
157 EXPECT_FALSE(IsUploadingData()); 160 EXPECT_FALSE(IsUploadingData());
158 } 161 }
159 162
160 // Do not send data if not aware of which markers are still in the document. 163 // Do not send data if not aware of which markers are still in the document.
161 TEST_F(FeedbackSenderTest, NoDocumentMarkersReceived) { 164 TEST_F(FeedbackSenderTest, NoDocumentMarkersReceived) {
162 EXPECT_FALSE(IsUploadingData()); 165 EXPECT_FALSE(IsUploadingData());
163 uint32 hash = AddPendingFeedback(); 166 uint32_t hash = AddPendingFeedback();
164 EXPECT_FALSE(IsUploadingData()); 167 EXPECT_FALSE(IsUploadingData());
165 static const int kSuggestionIndex = 1; 168 static const int kSuggestionIndex = 1;
166 feedback_->SelectedSuggestion(hash, kSuggestionIndex); 169 feedback_->SelectedSuggestion(hash, kSuggestionIndex);
167 EXPECT_FALSE(IsUploadingData()); 170 EXPECT_FALSE(IsUploadingData());
168 } 171 }
169 172
170 // Send PENDING feedback message if the marker is still in the document, and the 173 // Send PENDING feedback message if the marker is still in the document, and the
171 // user has not performed any action on it. 174 // user has not performed any action on it.
172 TEST_F(FeedbackSenderTest, PendingFeedback) { 175 TEST_F(FeedbackSenderTest, PendingFeedback) {
173 uint32 hash = AddPendingFeedback(); 176 uint32_t hash = AddPendingFeedback();
174 feedback_->OnReceiveDocumentMarkers(kRendererProcessId, 177 feedback_->OnReceiveDocumentMarkers(kRendererProcessId,
175 std::vector<uint32>(1, hash)); 178 std::vector<uint32_t>(1, hash));
176 EXPECT_TRUE(UploadDataContains("\"actionType\":\"PENDING\"")); 179 EXPECT_TRUE(UploadDataContains("\"actionType\":\"PENDING\""));
177 } 180 }
178 181
179 // Send NO_ACTION feedback message if the marker has been removed from the 182 // Send NO_ACTION feedback message if the marker has been removed from the
180 // document. 183 // document.
181 TEST_F(FeedbackSenderTest, NoActionFeedback) { 184 TEST_F(FeedbackSenderTest, NoActionFeedback) {
182 AddPendingFeedback(); 185 AddPendingFeedback();
183 feedback_->OnReceiveDocumentMarkers(kRendererProcessId, 186 feedback_->OnReceiveDocumentMarkers(kRendererProcessId,
184 std::vector<uint32>()); 187 std::vector<uint32_t>());
185 EXPECT_TRUE(UploadDataContains("\"actionType\":\"NO_ACTION\"")); 188 EXPECT_TRUE(UploadDataContains("\"actionType\":\"NO_ACTION\""));
186 } 189 }
187 190
188 // Send SELECT feedback message if the user has selected a spelling suggestion. 191 // Send SELECT feedback message if the user has selected a spelling suggestion.
189 TEST_F(FeedbackSenderTest, SelectFeedback) { 192 TEST_F(FeedbackSenderTest, SelectFeedback) {
190 uint32 hash = AddPendingFeedback(); 193 uint32_t hash = AddPendingFeedback();
191 static const int kSuggestionIndex = 0; 194 static const int kSuggestionIndex = 0;
192 feedback_->SelectedSuggestion(hash, kSuggestionIndex); 195 feedback_->SelectedSuggestion(hash, kSuggestionIndex);
193 feedback_->OnReceiveDocumentMarkers(kRendererProcessId, 196 feedback_->OnReceiveDocumentMarkers(kRendererProcessId,
194 std::vector<uint32>()); 197 std::vector<uint32_t>());
195 EXPECT_TRUE(UploadDataContains("\"actionType\":\"SELECT\"")); 198 EXPECT_TRUE(UploadDataContains("\"actionType\":\"SELECT\""));
196 EXPECT_TRUE(UploadDataContains("\"actionTargetIndex\":" + kSuggestionIndex)); 199 EXPECT_TRUE(UploadDataContains("\"actionTargetIndex\":" + kSuggestionIndex));
197 } 200 }
198 201
199 // Send ADD_TO_DICT feedback message if the user has added the misspelled word 202 // Send ADD_TO_DICT feedback message if the user has added the misspelled word
200 // to the custom dictionary. 203 // to the custom dictionary.
201 TEST_F(FeedbackSenderTest, AddToDictFeedback) { 204 TEST_F(FeedbackSenderTest, AddToDictFeedback) {
202 uint32 hash = AddPendingFeedback(); 205 uint32_t hash = AddPendingFeedback();
203 feedback_->AddedToDictionary(hash); 206 feedback_->AddedToDictionary(hash);
204 feedback_->OnReceiveDocumentMarkers(kRendererProcessId, 207 feedback_->OnReceiveDocumentMarkers(kRendererProcessId,
205 std::vector<uint32>()); 208 std::vector<uint32_t>());
206 EXPECT_TRUE(UploadDataContains("\"actionType\":\"ADD_TO_DICT\"")); 209 EXPECT_TRUE(UploadDataContains("\"actionType\":\"ADD_TO_DICT\""));
207 } 210 }
208 211
209 // Send IN_DICTIONARY feedback message if the user has the misspelled word in 212 // Send IN_DICTIONARY feedback message if the user has the misspelled word in
210 // the custom dictionary. 213 // the custom dictionary.
211 TEST_F(FeedbackSenderTest, InDictionaryFeedback) { 214 TEST_F(FeedbackSenderTest, InDictionaryFeedback) {
212 uint32 hash = AddPendingFeedback(); 215 uint32_t hash = AddPendingFeedback();
213 feedback_->RecordInDictionary(hash); 216 feedback_->RecordInDictionary(hash);
214 feedback_->OnReceiveDocumentMarkers(kRendererProcessId, 217 feedback_->OnReceiveDocumentMarkers(kRendererProcessId,
215 std::vector<uint32>()); 218 std::vector<uint32_t>());
216 EXPECT_TRUE(UploadDataContains("\"actionType\":\"IN_DICTIONARY\"")); 219 EXPECT_TRUE(UploadDataContains("\"actionType\":\"IN_DICTIONARY\""));
217 } 220 }
218 221
219 // Send PENDING feedback message if the user saw the spelling suggestion, but 222 // Send PENDING feedback message if the user saw the spelling suggestion, but
220 // decided to not select it, and the marker is still in the document. 223 // decided to not select it, and the marker is still in the document.
221 TEST_F(FeedbackSenderTest, IgnoreFeedbackMarkerInDocument) { 224 TEST_F(FeedbackSenderTest, IgnoreFeedbackMarkerInDocument) {
222 uint32 hash = AddPendingFeedback(); 225 uint32_t hash = AddPendingFeedback();
223 feedback_->IgnoredSuggestions(hash); 226 feedback_->IgnoredSuggestions(hash);
224 feedback_->OnReceiveDocumentMarkers(kRendererProcessId, 227 feedback_->OnReceiveDocumentMarkers(kRendererProcessId,
225 std::vector<uint32>(1, hash)); 228 std::vector<uint32_t>(1, hash));
226 EXPECT_TRUE(UploadDataContains("\"actionType\":\"PENDING\"")); 229 EXPECT_TRUE(UploadDataContains("\"actionType\":\"PENDING\""));
227 } 230 }
228 231
229 // Send IGNORE feedback message if the user saw the spelling suggestion, but 232 // Send IGNORE feedback message if the user saw the spelling suggestion, but
230 // decided to not select it, and the marker is no longer in the document. 233 // decided to not select it, and the marker is no longer in the document.
231 TEST_F(FeedbackSenderTest, IgnoreFeedbackMarkerNotInDocument) { 234 TEST_F(FeedbackSenderTest, IgnoreFeedbackMarkerNotInDocument) {
232 uint32 hash = AddPendingFeedback(); 235 uint32_t hash = AddPendingFeedback();
233 feedback_->IgnoredSuggestions(hash); 236 feedback_->IgnoredSuggestions(hash);
234 feedback_->OnReceiveDocumentMarkers(kRendererProcessId, 237 feedback_->OnReceiveDocumentMarkers(kRendererProcessId,
235 std::vector<uint32>()); 238 std::vector<uint32_t>());
236 EXPECT_TRUE(UploadDataContains("\"actionType\":\"IGNORE\"")); 239 EXPECT_TRUE(UploadDataContains("\"actionType\":\"IGNORE\""));
237 } 240 }
238 241
239 // Send MANUALLY_CORRECTED feedback message if the user manually corrected the 242 // Send MANUALLY_CORRECTED feedback message if the user manually corrected the
240 // misspelled word. 243 // misspelled word.
241 TEST_F(FeedbackSenderTest, ManuallyCorrectedFeedback) { 244 TEST_F(FeedbackSenderTest, ManuallyCorrectedFeedback) {
242 uint32 hash = AddPendingFeedback(); 245 uint32_t hash = AddPendingFeedback();
243 static const std::string kManualCorrection = "Howdy"; 246 static const std::string kManualCorrection = "Howdy";
244 feedback_->ManuallyCorrected(hash, base::ASCIIToUTF16(kManualCorrection)); 247 feedback_->ManuallyCorrected(hash, base::ASCIIToUTF16(kManualCorrection));
245 feedback_->OnReceiveDocumentMarkers(kRendererProcessId, 248 feedback_->OnReceiveDocumentMarkers(kRendererProcessId,
246 std::vector<uint32>()); 249 std::vector<uint32_t>());
247 EXPECT_TRUE(UploadDataContains("\"actionType\":\"MANUALLY_CORRECTED\"")); 250 EXPECT_TRUE(UploadDataContains("\"actionType\":\"MANUALLY_CORRECTED\""));
248 EXPECT_TRUE(UploadDataContains("\"actionTargetValue\":\"" + 251 EXPECT_TRUE(UploadDataContains("\"actionTargetValue\":\"" +
249 kManualCorrection + "\"")); 252 kManualCorrection + "\""));
250 } 253 }
251 254
252 // Send feedback messages in batch. 255 // Send feedback messages in batch.
253 TEST_F(FeedbackSenderTest, BatchFeedback) { 256 TEST_F(FeedbackSenderTest, BatchFeedback) {
254 std::vector<SpellCheckResult> results; 257 std::vector<SpellCheckResult> results;
255 results.push_back(SpellCheckResult(SpellCheckResult::SPELLING, 258 results.push_back(SpellCheckResult(SpellCheckResult::SPELLING,
256 kMisspellingStart, 259 kMisspellingStart,
257 kMisspellingLength, 260 kMisspellingLength,
258 base::ASCIIToUTF16("Hello"))); 261 base::ASCIIToUTF16("Hello")));
259 static const int kSecondMisspellingStart = 7; 262 static const int kSecondMisspellingStart = 7;
260 static const int kSecondMisspellingLength = 5; 263 static const int kSecondMisspellingLength = 5;
261 results.push_back(SpellCheckResult(SpellCheckResult::SPELLING, 264 results.push_back(SpellCheckResult(SpellCheckResult::SPELLING,
262 kSecondMisspellingStart, 265 kSecondMisspellingStart,
263 kSecondMisspellingLength, 266 kSecondMisspellingLength,
264 base::ASCIIToUTF16("world"))); 267 base::ASCIIToUTF16("world")));
265 feedback_->OnSpellcheckResults(kRendererProcessId, 268 feedback_->OnSpellcheckResults(kRendererProcessId,
266 base::UTF8ToUTF16(kText), 269 base::UTF8ToUTF16(kText),
267 std::vector<SpellCheckMarker>(), 270 std::vector<SpellCheckMarker>(),
268 &results); 271 &results);
269 feedback_->OnReceiveDocumentMarkers(kRendererProcessId, 272 feedback_->OnReceiveDocumentMarkers(kRendererProcessId,
270 std::vector<uint32>()); 273 std::vector<uint32_t>());
271 EXPECT_TRUE(UploadDataContains("\"actionType\":\"NO_ACTION\"", 2)); 274 EXPECT_TRUE(UploadDataContains("\"actionType\":\"NO_ACTION\"", 2));
272 } 275 }
273 276
274 // Send a series of PENDING feedback messages and one final NO_ACTION feedback 277 // Send a series of PENDING feedback messages and one final NO_ACTION feedback
275 // message with the same hash identifier for a single misspelling. 278 // message with the same hash identifier for a single misspelling.
276 TEST_F(FeedbackSenderTest, SameHashFeedback) { 279 TEST_F(FeedbackSenderTest, SameHashFeedback) {
277 uint32 hash = AddPendingFeedback(); 280 uint32_t hash = AddPendingFeedback();
278 std::vector<uint32> remaining_markers(1, hash); 281 std::vector<uint32_t> remaining_markers(1, hash);
279 282
280 feedback_->OnReceiveDocumentMarkers(kRendererProcessId, remaining_markers); 283 feedback_->OnReceiveDocumentMarkers(kRendererProcessId, remaining_markers);
281 EXPECT_TRUE(UploadDataContains("\"actionType\":\"PENDING\"")); 284 EXPECT_TRUE(UploadDataContains("\"actionType\":\"PENDING\""));
282 std::string hash_string = base::StringPrintf("\"suggestionId\":\"%u\"", hash); 285 std::string hash_string = base::StringPrintf("\"suggestionId\":\"%u\"", hash);
283 EXPECT_TRUE(UploadDataContains(hash_string)); 286 EXPECT_TRUE(UploadDataContains(hash_string));
284 ClearUploadData(); 287 ClearUploadData();
285 288
286 feedback_->OnReceiveDocumentMarkers(kRendererProcessId, remaining_markers); 289 feedback_->OnReceiveDocumentMarkers(kRendererProcessId, remaining_markers);
287 EXPECT_TRUE(UploadDataContains("\"actionType\":\"PENDING\"")); 290 EXPECT_TRUE(UploadDataContains("\"actionType\":\"PENDING\""));
288 EXPECT_TRUE(UploadDataContains(hash_string)); 291 EXPECT_TRUE(UploadDataContains(hash_string));
289 ClearUploadData(); 292 ClearUploadData();
290 293
291 feedback_->OnReceiveDocumentMarkers(kRendererProcessId, 294 feedback_->OnReceiveDocumentMarkers(kRendererProcessId,
292 std::vector<uint32>()); 295 std::vector<uint32_t>());
293 EXPECT_TRUE(UploadDataContains("\"actionType\":\"NO_ACTION\"")); 296 EXPECT_TRUE(UploadDataContains("\"actionType\":\"NO_ACTION\""));
294 EXPECT_TRUE(UploadDataContains(hash_string)); 297 EXPECT_TRUE(UploadDataContains(hash_string));
295 ClearUploadData(); 298 ClearUploadData();
296 299
297 feedback_->OnReceiveDocumentMarkers(kRendererProcessId, 300 feedback_->OnReceiveDocumentMarkers(kRendererProcessId,
298 std::vector<uint32>()); 301 std::vector<uint32_t>());
299 EXPECT_FALSE(IsUploadingData()); 302 EXPECT_FALSE(IsUploadingData());
300 } 303 }
301 304
302 // When a session expires: 305 // When a session expires:
303 // 1) Pending feedback is finalized and sent to the server in the last message 306 // 1) Pending feedback is finalized and sent to the server in the last message
304 // batch in the session. 307 // batch in the session.
305 // 2) No feedback is sent until a spellcheck request happens. 308 // 2) No feedback is sent until a spellcheck request happens.
306 // 3) Existing markers get new hash identifiers. 309 // 3) Existing markers get new hash identifiers.
307 TEST_F(FeedbackSenderTest, SessionExpirationFeedback) { 310 TEST_F(FeedbackSenderTest, SessionExpirationFeedback) {
308 std::vector<SpellCheckResult> results( 311 std::vector<SpellCheckResult> results(
309 1, 312 1,
310 SpellCheckResult(SpellCheckResult::SPELLING, 313 SpellCheckResult(SpellCheckResult::SPELLING,
311 kMisspellingStart, 314 kMisspellingStart,
312 kMisspellingLength, 315 kMisspellingLength,
313 base::ASCIIToUTF16("Hello"))); 316 base::ASCIIToUTF16("Hello")));
314 feedback_->OnSpellcheckResults(kRendererProcessId, 317 feedback_->OnSpellcheckResults(kRendererProcessId,
315 base::UTF8ToUTF16(kText), 318 base::UTF8ToUTF16(kText),
316 std::vector<SpellCheckMarker>(), 319 std::vector<SpellCheckMarker>(),
317 &results); 320 &results);
318 uint32 original_hash = results[0].hash; 321 uint32_t original_hash = results[0].hash;
319 std::vector<uint32> remaining_markers(1, original_hash); 322 std::vector<uint32_t> remaining_markers(1, original_hash);
320 323
321 feedback_->OnReceiveDocumentMarkers(kRendererProcessId, remaining_markers); 324 feedback_->OnReceiveDocumentMarkers(kRendererProcessId, remaining_markers);
322 EXPECT_FALSE(UploadDataContains("\"actionType\":\"NO_ACTION\"")); 325 EXPECT_FALSE(UploadDataContains("\"actionType\":\"NO_ACTION\""));
323 EXPECT_TRUE(UploadDataContains("\"actionType\":\"PENDING\"")); 326 EXPECT_TRUE(UploadDataContains("\"actionType\":\"PENDING\""));
324 std::string original_hash_string = 327 std::string original_hash_string =
325 base::StringPrintf("\"suggestionId\":\"%u\"", original_hash); 328 base::StringPrintf("\"suggestionId\":\"%u\"", original_hash);
326 EXPECT_TRUE(UploadDataContains(original_hash_string)); 329 EXPECT_TRUE(UploadDataContains(original_hash_string));
327 ClearUploadData(); 330 ClearUploadData();
328 331
329 ExpireSession(); 332 ExpireSession();
(...skipping 13 matching lines...) Expand all
343 // The first spellcheck request after session expiration creates different 346 // The first spellcheck request after session expiration creates different
344 // document marker hash identifiers. 347 // document marker hash identifiers.
345 std::vector<SpellCheckMarker> original_markers( 348 std::vector<SpellCheckMarker> original_markers(
346 1, SpellCheckMarker(results[0].hash, results[0].location)); 349 1, SpellCheckMarker(results[0].hash, results[0].location));
347 results[0] = SpellCheckResult(SpellCheckResult::SPELLING, 350 results[0] = SpellCheckResult(SpellCheckResult::SPELLING,
348 kMisspellingStart, 351 kMisspellingStart,
349 kMisspellingLength, 352 kMisspellingLength,
350 base::ASCIIToUTF16("Hello")); 353 base::ASCIIToUTF16("Hello"));
351 feedback_->OnSpellcheckResults( 354 feedback_->OnSpellcheckResults(
352 kRendererProcessId, base::UTF8ToUTF16(kText), original_markers, &results); 355 kRendererProcessId, base::UTF8ToUTF16(kText), original_markers, &results);
353 uint32 updated_hash = results[0].hash; 356 uint32_t updated_hash = results[0].hash;
354 EXPECT_NE(updated_hash, original_hash); 357 EXPECT_NE(updated_hash, original_hash);
355 remaining_markers[0] = updated_hash; 358 remaining_markers[0] = updated_hash;
356 359
357 // The first feedback message batch in session |i + 1| has the new document 360 // The first feedback message batch in session |i + 1| has the new document
358 // marker hash identifiers. 361 // marker hash identifiers.
359 feedback_->OnReceiveDocumentMarkers(kRendererProcessId, remaining_markers); 362 feedback_->OnReceiveDocumentMarkers(kRendererProcessId, remaining_markers);
360 EXPECT_FALSE(UploadDataContains("\"actionType\":\"NO_ACTION\"")); 363 EXPECT_FALSE(UploadDataContains("\"actionType\":\"NO_ACTION\""));
361 EXPECT_TRUE(UploadDataContains("\"actionType\":\"PENDING\"")); 364 EXPECT_TRUE(UploadDataContains("\"actionType\":\"PENDING\""));
362 EXPECT_FALSE(UploadDataContains(original_hash_string)); 365 EXPECT_FALSE(UploadDataContains(original_hash_string));
363 std::string updated_hash_string = 366 std::string updated_hash_string =
364 base::StringPrintf("\"suggestionId\":\"%u\"", updated_hash); 367 base::StringPrintf("\"suggestionId\":\"%u\"", updated_hash);
365 EXPECT_TRUE(UploadDataContains(updated_hash_string)); 368 EXPECT_TRUE(UploadDataContains(updated_hash_string));
366 } 369 }
367 370
368 // First message in session has an indicator. 371 // First message in session has an indicator.
369 TEST_F(FeedbackSenderTest, FirstMessageInSessionIndicator) { 372 TEST_F(FeedbackSenderTest, FirstMessageInSessionIndicator) {
370 // Session 1, message 1 373 // Session 1, message 1
371 AddPendingFeedback(); 374 AddPendingFeedback();
372 feedback_->OnReceiveDocumentMarkers(kRendererProcessId, 375 feedback_->OnReceiveDocumentMarkers(kRendererProcessId,
373 std::vector<uint32>()); 376 std::vector<uint32_t>());
374 EXPECT_TRUE(UploadDataContains("\"isFirstInSession\":true")); 377 EXPECT_TRUE(UploadDataContains("\"isFirstInSession\":true"));
375 378
376 // Session 1, message 2 379 // Session 1, message 2
377 AddPendingFeedback(); 380 AddPendingFeedback();
378 feedback_->OnReceiveDocumentMarkers(kRendererProcessId, 381 feedback_->OnReceiveDocumentMarkers(kRendererProcessId,
379 std::vector<uint32>()); 382 std::vector<uint32_t>());
380 EXPECT_TRUE(UploadDataContains("\"isFirstInSession\":false")); 383 EXPECT_TRUE(UploadDataContains("\"isFirstInSession\":false"));
381 384
382 ExpireSession(); 385 ExpireSession();
383 386
384 // Session 1, message 3 (last) 387 // Session 1, message 3 (last)
385 AddPendingFeedback(); 388 AddPendingFeedback();
386 feedback_->OnReceiveDocumentMarkers(kRendererProcessId, 389 feedback_->OnReceiveDocumentMarkers(kRendererProcessId,
387 std::vector<uint32>()); 390 std::vector<uint32_t>());
388 EXPECT_TRUE(UploadDataContains("\"isFirstInSession\":false")); 391 EXPECT_TRUE(UploadDataContains("\"isFirstInSession\":false"));
389 392
390 // Session 2, message 1 393 // Session 2, message 1
391 AddPendingFeedback(); 394 AddPendingFeedback();
392 feedback_->OnReceiveDocumentMarkers(kRendererProcessId, 395 feedback_->OnReceiveDocumentMarkers(kRendererProcessId,
393 std::vector<uint32>()); 396 std::vector<uint32_t>());
394 EXPECT_TRUE(UploadDataContains("\"isFirstInSession\":true")); 397 EXPECT_TRUE(UploadDataContains("\"isFirstInSession\":true"));
395 398
396 // Session 2, message 2 399 // Session 2, message 2
397 AddPendingFeedback(); 400 AddPendingFeedback();
398 feedback_->OnReceiveDocumentMarkers(kRendererProcessId, 401 feedback_->OnReceiveDocumentMarkers(kRendererProcessId,
399 std::vector<uint32>()); 402 std::vector<uint32_t>());
400 EXPECT_TRUE(UploadDataContains("\"isFirstInSession\":false")); 403 EXPECT_TRUE(UploadDataContains("\"isFirstInSession\":false"));
401 } 404 }
402 405
403 // Flush all feedback when the spellcheck language and country change. 406 // Flush all feedback when the spellcheck language and country change.
404 TEST_F(FeedbackSenderTest, OnLanguageCountryChange) { 407 TEST_F(FeedbackSenderTest, OnLanguageCountryChange) {
405 AddPendingFeedback(); 408 AddPendingFeedback();
406 feedback_->OnLanguageCountryChange("pt", "BR"); 409 feedback_->OnLanguageCountryChange("pt", "BR");
407 EXPECT_TRUE(UploadDataContains("\"language\":\"en\"")); 410 EXPECT_TRUE(UploadDataContains("\"language\":\"en\""));
408 AddPendingFeedback(); 411 AddPendingFeedback();
409 feedback_->OnLanguageCountryChange("en", "US"); 412 feedback_->OnLanguageCountryChange("en", "US");
410 EXPECT_TRUE(UploadDataContains("\"language\":\"pt\"")); 413 EXPECT_TRUE(UploadDataContains("\"language\":\"pt\""));
411 } 414 }
412 415
413 // The field names and types should correspond to the API. 416 // The field names and types should correspond to the API.
414 TEST_F(FeedbackSenderTest, FeedbackAPI) { 417 TEST_F(FeedbackSenderTest, FeedbackAPI) {
415 AddPendingFeedback(); 418 AddPendingFeedback();
416 feedback_->OnReceiveDocumentMarkers(kRendererProcessId, 419 feedback_->OnReceiveDocumentMarkers(kRendererProcessId,
417 std::vector<uint32>()); 420 std::vector<uint32_t>());
418 std::string actual_data = GetUploadData(); 421 std::string actual_data = GetUploadData();
419 scoped_ptr<base::DictionaryValue> actual(static_cast<base::DictionaryValue*>( 422 scoped_ptr<base::DictionaryValue> actual(static_cast<base::DictionaryValue*>(
420 base::JSONReader::Read(actual_data).release())); 423 base::JSONReader::Read(actual_data).release()));
421 actual->SetString("params.key", "TestDummyKey"); 424 actual->SetString("params.key", "TestDummyKey");
422 base::ListValue* suggestions = NULL; 425 base::ListValue* suggestions = NULL;
423 actual->GetList("params.suggestionInfo", &suggestions); 426 actual->GetList("params.suggestionInfo", &suggestions);
424 base::DictionaryValue* suggestion = NULL; 427 base::DictionaryValue* suggestion = NULL;
425 suggestions->GetDictionary(0, &suggestion); 428 suggestions->GetDictionary(0, &suggestion);
426 suggestion->SetString("suggestionId", "42"); 429 suggestion->SetString("suggestionId", "42");
427 suggestion->SetString("timestamp", "9001"); 430 suggestion->SetString("timestamp", "9001");
(...skipping 18 matching lines...) Expand all
446 scoped_ptr<base::Value> expected = base::JSONReader::Read(expected_data); 449 scoped_ptr<base::Value> expected = base::JSONReader::Read(expected_data);
447 EXPECT_TRUE(expected->Equals(actual.get())) 450 EXPECT_TRUE(expected->Equals(actual.get()))
448 << "Expected data: " << expected_data 451 << "Expected data: " << expected_data
449 << "\nActual data: " << actual_data; 452 << "\nActual data: " << actual_data;
450 } 453 }
451 454
452 // The default API version is "v2". 455 // The default API version is "v2".
453 TEST_F(FeedbackSenderTest, DefaultApiVersion) { 456 TEST_F(FeedbackSenderTest, DefaultApiVersion) {
454 AddPendingFeedback(); 457 AddPendingFeedback();
455 feedback_->OnReceiveDocumentMarkers(kRendererProcessId, 458 feedback_->OnReceiveDocumentMarkers(kRendererProcessId,
456 std::vector<uint32>()); 459 std::vector<uint32_t>());
457 EXPECT_TRUE(UploadDataContains("\"apiVersion\":\"v2\"")); 460 EXPECT_TRUE(UploadDataContains("\"apiVersion\":\"v2\""));
458 EXPECT_FALSE(UploadDataContains("\"apiVersion\":\"v2-internal\"")); 461 EXPECT_FALSE(UploadDataContains("\"apiVersion\":\"v2-internal\""));
459 } 462 }
460 463
461 // The API version should not change for field-trial participants that do not 464 // The API version should not change for field-trial participants that do not
462 // append the command-line switch. 465 // append the command-line switch.
463 TEST_F(FeedbackSenderTest, FieldTrialAloneHasSameApiVersion) { 466 TEST_F(FeedbackSenderTest, FieldTrialAloneHasSameApiVersion) {
464 EnableFieldTrial(); 467 EnableFieldTrial();
465 468
466 AddPendingFeedback(); 469 AddPendingFeedback();
467 feedback_->OnReceiveDocumentMarkers(kRendererProcessId, 470 feedback_->OnReceiveDocumentMarkers(kRendererProcessId,
468 std::vector<uint32>()); 471 std::vector<uint32_t>());
469 472
470 EXPECT_TRUE(UploadDataContains("\"apiVersion\":\"v2\"")); 473 EXPECT_TRUE(UploadDataContains("\"apiVersion\":\"v2\""));
471 EXPECT_FALSE(UploadDataContains("\"apiVersion\":\"v2-internal\"")); 474 EXPECT_FALSE(UploadDataContains("\"apiVersion\":\"v2-internal\""));
472 } 475 }
473 476
474 // The API version should not change if the command-line switch is appended, but 477 // The API version should not change if the command-line switch is appended, but
475 // the user is not participating in the field-trial. 478 // the user is not participating in the field-trial.
476 TEST_F(FeedbackSenderTest, CommandLineSwitchAloneHasSameApiVersion) { 479 TEST_F(FeedbackSenderTest, CommandLineSwitchAloneHasSameApiVersion) {
477 AppendCommandLineSwitch(); 480 AppendCommandLineSwitch();
478 481
479 AddPendingFeedback(); 482 AddPendingFeedback();
480 feedback_->OnReceiveDocumentMarkers(kRendererProcessId, 483 feedback_->OnReceiveDocumentMarkers(kRendererProcessId,
481 std::vector<uint32>()); 484 std::vector<uint32_t>());
482 485
483 EXPECT_TRUE(UploadDataContains("\"apiVersion\":\"v2\"")); 486 EXPECT_TRUE(UploadDataContains("\"apiVersion\":\"v2\""));
484 EXPECT_FALSE(UploadDataContains("\"apiVersion\":\"v2-internal\"")); 487 EXPECT_FALSE(UploadDataContains("\"apiVersion\":\"v2-internal\""));
485 } 488 }
486 489
487 // The API version should be different for field-trial participants that also 490 // The API version should be different for field-trial participants that also
488 // append the command-line switch. 491 // append the command-line switch.
489 TEST_F(FeedbackSenderTest, InternalApiVersion) { 492 TEST_F(FeedbackSenderTest, InternalApiVersion) {
490 AppendCommandLineSwitch(); 493 AppendCommandLineSwitch();
491 EnableFieldTrial(); 494 EnableFieldTrial();
492 495
493 AddPendingFeedback(); 496 AddPendingFeedback();
494 feedback_->OnReceiveDocumentMarkers(kRendererProcessId, 497 feedback_->OnReceiveDocumentMarkers(kRendererProcessId,
495 std::vector<uint32>()); 498 std::vector<uint32_t>());
496 499
497 EXPECT_FALSE(UploadDataContains("\"apiVersion\":\"v2\"")); 500 EXPECT_FALSE(UploadDataContains("\"apiVersion\":\"v2\""));
498 EXPECT_TRUE(UploadDataContains("\"apiVersion\":\"v2-internal\"")); 501 EXPECT_TRUE(UploadDataContains("\"apiVersion\":\"v2-internal\""));
499 } 502 }
500 503
501 // Duplicate spellcheck results should be matched to the existing markers. 504 // Duplicate spellcheck results should be matched to the existing markers.
502 TEST_F(FeedbackSenderTest, MatchDupliateResultsWithExistingMarkers) { 505 TEST_F(FeedbackSenderTest, MatchDupliateResultsWithExistingMarkers) {
503 uint32 hash = AddPendingFeedback(); 506 uint32_t hash = AddPendingFeedback();
504 std::vector<SpellCheckResult> results( 507 std::vector<SpellCheckResult> results(
505 1, 508 1,
506 SpellCheckResult(SpellCheckResult::SPELLING, 509 SpellCheckResult(SpellCheckResult::SPELLING,
507 kMisspellingStart, 510 kMisspellingStart,
508 kMisspellingLength, 511 kMisspellingLength,
509 base::ASCIIToUTF16("Hello"))); 512 base::ASCIIToUTF16("Hello")));
510 std::vector<SpellCheckMarker> markers( 513 std::vector<SpellCheckMarker> markers(
511 1, SpellCheckMarker(hash, results[0].location)); 514 1, SpellCheckMarker(hash, results[0].location));
512 EXPECT_EQ(static_cast<uint32>(0), results[0].hash); 515 EXPECT_EQ(static_cast<uint32_t>(0), results[0].hash);
513 feedback_->OnSpellcheckResults( 516 feedback_->OnSpellcheckResults(
514 kRendererProcessId, base::UTF8ToUTF16(kText), markers, &results); 517 kRendererProcessId, base::UTF8ToUTF16(kText), markers, &results);
515 EXPECT_EQ(hash, results[0].hash); 518 EXPECT_EQ(hash, results[0].hash);
516 } 519 }
517 520
518 // Adding a word to dictionary should trigger ADD_TO_DICT feedback for every 521 // Adding a word to dictionary should trigger ADD_TO_DICT feedback for every
519 // occurrence of that word. 522 // occurrence of that word.
520 TEST_F(FeedbackSenderTest, MultipleAddToDictFeedback) { 523 TEST_F(FeedbackSenderTest, MultipleAddToDictFeedback) {
521 std::vector<SpellCheckResult> results; 524 std::vector<SpellCheckResult> results;
522 static const int kSentenceLength = 14; 525 static const int kSentenceLength = 14;
523 static const int kNumberOfSentences = 2; 526 static const int kNumberOfSentences = 2;
524 static const base::string16 kTextWithDuplicates = 527 static const base::string16 kTextWithDuplicates =
525 base::ASCIIToUTF16("Helllo world. Helllo world."); 528 base::ASCIIToUTF16("Helllo world. Helllo world.");
526 for (int i = 0; i < kNumberOfSentences; ++i) { 529 for (int i = 0; i < kNumberOfSentences; ++i) {
527 results.push_back(SpellCheckResult(SpellCheckResult::SPELLING, 530 results.push_back(SpellCheckResult(SpellCheckResult::SPELLING,
528 kMisspellingStart + i * kSentenceLength, 531 kMisspellingStart + i * kSentenceLength,
529 kMisspellingLength, 532 kMisspellingLength,
530 base::ASCIIToUTF16("Hello"))); 533 base::ASCIIToUTF16("Hello")));
531 } 534 }
532 static const int kNumberOfRenderers = 2; 535 static const int kNumberOfRenderers = 2;
533 int last_renderer_process_id = -1; 536 int last_renderer_process_id = -1;
534 for (int i = 0; i < kNumberOfRenderers; ++i) { 537 for (int i = 0; i < kNumberOfRenderers; ++i) {
535 feedback_->OnSpellcheckResults(kRendererProcessId + i, 538 feedback_->OnSpellcheckResults(kRendererProcessId + i,
536 kTextWithDuplicates, 539 kTextWithDuplicates,
537 std::vector<SpellCheckMarker>(), 540 std::vector<SpellCheckMarker>(),
538 &results); 541 &results);
539 last_renderer_process_id = kRendererProcessId + i; 542 last_renderer_process_id = kRendererProcessId + i;
540 } 543 }
541 std::vector<uint32> remaining_markers; 544 std::vector<uint32_t> remaining_markers;
542 for (size_t i = 0; i < results.size(); ++i) 545 for (size_t i = 0; i < results.size(); ++i)
543 remaining_markers.push_back(results[i].hash); 546 remaining_markers.push_back(results[i].hash);
544 feedback_->OnReceiveDocumentMarkers(last_renderer_process_id, 547 feedback_->OnReceiveDocumentMarkers(last_renderer_process_id,
545 remaining_markers); 548 remaining_markers);
546 EXPECT_TRUE(UploadDataContains("PENDING", 2)); 549 EXPECT_TRUE(UploadDataContains("PENDING", 2));
547 EXPECT_FALSE(UploadDataContains("ADD_TO_DICT")); 550 EXPECT_FALSE(UploadDataContains("ADD_TO_DICT"));
548 551
549 feedback_->AddedToDictionary(results[0].hash); 552 feedback_->AddedToDictionary(results[0].hash);
550 feedback_->OnReceiveDocumentMarkers(last_renderer_process_id, 553 feedback_->OnReceiveDocumentMarkers(last_renderer_process_id,
551 remaining_markers); 554 remaining_markers);
552 EXPECT_FALSE(UploadDataContains("PENDING")); 555 EXPECT_FALSE(UploadDataContains("PENDING"));
553 EXPECT_TRUE(UploadDataContains("ADD_TO_DICT", 2)); 556 EXPECT_TRUE(UploadDataContains("ADD_TO_DICT", 2));
554 } 557 }
555 558
556 // ADD_TO_DICT feedback for multiple occurrences of a word should trigger only 559 // ADD_TO_DICT feedback for multiple occurrences of a word should trigger only
557 // for pending feedback. 560 // for pending feedback.
558 TEST_F(FeedbackSenderTest, AddToDictOnlyPending) { 561 TEST_F(FeedbackSenderTest, AddToDictOnlyPending) {
559 AddPendingFeedback(); 562 AddPendingFeedback();
560 uint32 add_to_dict_hash = AddPendingFeedback(); 563 uint32_t add_to_dict_hash = AddPendingFeedback();
561 uint32 select_hash = AddPendingFeedback(); 564 uint32_t select_hash = AddPendingFeedback();
562 feedback_->SelectedSuggestion(select_hash, 0); 565 feedback_->SelectedSuggestion(select_hash, 0);
563 feedback_->AddedToDictionary(add_to_dict_hash); 566 feedback_->AddedToDictionary(add_to_dict_hash);
564 feedback_->OnReceiveDocumentMarkers(kRendererProcessId, 567 feedback_->OnReceiveDocumentMarkers(kRendererProcessId,
565 std::vector<uint32>()); 568 std::vector<uint32_t>());
566 EXPECT_TRUE(UploadDataContains("SELECT", 1)); 569 EXPECT_TRUE(UploadDataContains("SELECT", 1));
567 EXPECT_TRUE(UploadDataContains("ADD_TO_DICT", 2)); 570 EXPECT_TRUE(UploadDataContains("ADD_TO_DICT", 2));
568 } 571 }
569 572
570 // Spellcheck results that are out-of-bounds are not added to feedback. 573 // Spellcheck results that are out-of-bounds are not added to feedback.
571 TEST_F(FeedbackSenderTest, IgnoreOutOfBounds) { 574 TEST_F(FeedbackSenderTest, IgnoreOutOfBounds) {
572 std::vector<SpellCheckResult> results; 575 std::vector<SpellCheckResult> results;
573 results.push_back(SpellCheckResult( 576 results.push_back(SpellCheckResult(
574 SpellCheckResult::SPELLING, 0, 100, base::UTF8ToUTF16("Hello"))); 577 SpellCheckResult::SPELLING, 0, 100, base::UTF8ToUTF16("Hello")));
575 results.push_back(SpellCheckResult( 578 results.push_back(SpellCheckResult(
576 SpellCheckResult::SPELLING, 100, 3, base::UTF8ToUTF16("world"))); 579 SpellCheckResult::SPELLING, 100, 3, base::UTF8ToUTF16("world")));
577 results.push_back(SpellCheckResult( 580 results.push_back(SpellCheckResult(
578 SpellCheckResult::SPELLING, -1, 3, base::UTF8ToUTF16("how"))); 581 SpellCheckResult::SPELLING, -1, 3, base::UTF8ToUTF16("how")));
579 results.push_back(SpellCheckResult( 582 results.push_back(SpellCheckResult(
580 SpellCheckResult::SPELLING, 0, 0, base::UTF8ToUTF16("are"))); 583 SpellCheckResult::SPELLING, 0, 0, base::UTF8ToUTF16("are")));
581 results.push_back(SpellCheckResult( 584 results.push_back(SpellCheckResult(
582 SpellCheckResult::SPELLING, 2, -1, base::UTF8ToUTF16("you"))); 585 SpellCheckResult::SPELLING, 2, -1, base::UTF8ToUTF16("you")));
583 feedback_->OnSpellcheckResults(kRendererProcessId, 586 feedback_->OnSpellcheckResults(kRendererProcessId,
584 base::UTF8ToUTF16(kText), 587 base::UTF8ToUTF16(kText),
585 std::vector<SpellCheckMarker>(), 588 std::vector<SpellCheckMarker>(),
586 &results); 589 &results);
587 feedback_->OnReceiveDocumentMarkers(kRendererProcessId, 590 feedback_->OnReceiveDocumentMarkers(kRendererProcessId,
588 std::vector<uint32>()); 591 std::vector<uint32_t>());
589 EXPECT_FALSE(IsUploadingData()); 592 EXPECT_FALSE(IsUploadingData());
590 } 593 }
591 594
592 // FeedbackSender does not collect and upload feedback when instructed to stop. 595 // FeedbackSender does not collect and upload feedback when instructed to stop.
593 TEST_F(FeedbackSenderTest, CanStopFeedbackCollection) { 596 TEST_F(FeedbackSenderTest, CanStopFeedbackCollection) {
594 feedback_->StopFeedbackCollection(); 597 feedback_->StopFeedbackCollection();
595 AddPendingFeedback(); 598 AddPendingFeedback();
596 feedback_->OnReceiveDocumentMarkers(kRendererProcessId, 599 feedback_->OnReceiveDocumentMarkers(kRendererProcessId,
597 std::vector<uint32>()); 600 std::vector<uint32_t>());
598 EXPECT_FALSE(IsUploadingData()); 601 EXPECT_FALSE(IsUploadingData());
599 } 602 }
600 603
601 // FeedbackSender resumes collecting and uploading feedback when instructed to 604 // FeedbackSender resumes collecting and uploading feedback when instructed to
602 // start after stopping. 605 // start after stopping.
603 TEST_F(FeedbackSenderTest, CanResumeFeedbackCollection) { 606 TEST_F(FeedbackSenderTest, CanResumeFeedbackCollection) {
604 feedback_->StopFeedbackCollection(); 607 feedback_->StopFeedbackCollection();
605 feedback_->StartFeedbackCollection(); 608 feedback_->StartFeedbackCollection();
606 AddPendingFeedback(); 609 AddPendingFeedback();
607 feedback_->OnReceiveDocumentMarkers(kRendererProcessId, 610 feedback_->OnReceiveDocumentMarkers(kRendererProcessId,
608 std::vector<uint32>()); 611 std::vector<uint32_t>());
609 EXPECT_TRUE(IsUploadingData()); 612 EXPECT_TRUE(IsUploadingData());
610 } 613 }
611 614
612 // FeedbackSender does not collect data while being stopped and upload it later. 615 // FeedbackSender does not collect data while being stopped and upload it later.
613 TEST_F(FeedbackSenderTest, NoFeedbackCollectionWhenStopped) { 616 TEST_F(FeedbackSenderTest, NoFeedbackCollectionWhenStopped) {
614 feedback_->StopFeedbackCollection(); 617 feedback_->StopFeedbackCollection();
615 AddPendingFeedback(); 618 AddPendingFeedback();
616 feedback_->OnReceiveDocumentMarkers(kRendererProcessId, 619 feedback_->OnReceiveDocumentMarkers(kRendererProcessId,
617 std::vector<uint32>()); 620 std::vector<uint32_t>());
618 feedback_->StartFeedbackCollection(); 621 feedback_->StartFeedbackCollection();
619 feedback_->OnReceiveDocumentMarkers(kRendererProcessId, 622 feedback_->OnReceiveDocumentMarkers(kRendererProcessId,
620 std::vector<uint32>()); 623 std::vector<uint32_t>());
621 EXPECT_FALSE(IsUploadingData()); 624 EXPECT_FALSE(IsUploadingData());
622 } 625 }
623 626
624 // The feedback context is trimmed to 2 words on the left and 2 words on the 627 // The feedback context is trimmed to 2 words on the left and 2 words on the
625 // right side of the misspelling. 628 // right side of the misspelling.
626 TEST_F(FeedbackSenderTest, TrimFeedback) { 629 TEST_F(FeedbackSenderTest, TrimFeedback) {
627 std::vector<SpellCheckResult> results( 630 std::vector<SpellCheckResult> results(
628 1, SpellCheckResult(SpellCheckResult::SPELLING, 13, 3, 631 1, SpellCheckResult(SpellCheckResult::SPELLING, 13, 3,
629 base::UTF8ToUTF16("the"))); 632 base::UTF8ToUTF16("the")));
630 feedback_->OnSpellcheckResults( 633 feedback_->OnSpellcheckResults(
631 kRendererProcessId, 634 kRendererProcessId,
632 base::UTF8ToUTF16("Far and away teh best prize that life has to offer is " 635 base::UTF8ToUTF16("Far and away teh best prize that life has to offer is "
633 "the chance to work hard at work worth doing."), 636 "the chance to work hard at work worth doing."),
634 std::vector<SpellCheckMarker>(), &results); 637 std::vector<SpellCheckMarker>(), &results);
635 feedback_->OnReceiveDocumentMarkers(kRendererProcessId, 638 feedback_->OnReceiveDocumentMarkers(kRendererProcessId,
636 std::vector<uint32>()); 639 std::vector<uint32_t>());
637 EXPECT_TRUE( 640 EXPECT_TRUE(
638 UploadDataContains(",\"originalText\":\"and away teh best prize\",")); 641 UploadDataContains(",\"originalText\":\"and away teh best prize\","));
639 EXPECT_TRUE(UploadDataContains(",\"misspelledStart\":9,")); 642 EXPECT_TRUE(UploadDataContains(",\"misspelledStart\":9,"));
640 } 643 }
641 644
642 } // namespace spellcheck 645 } // namespace spellcheck
OLDNEW
« no previous file with comments | « chrome/browser/spellchecker/feedback_sender.cc ('k') | chrome/browser/spellchecker/feedback_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698