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

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

Issue 120983002: Update some uses of UTF conversions in chrome/browser to use the base:: namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/message_loop/message_loop.h" 6 #include "base/message_loop/message_loop.h"
7 #include "base/strings/string_util.h" 7 #include "base/strings/string_util.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/browser/spellchecker/spellcheck_platform_mac.h" 9 #include "chrome/browser/spellchecker/spellcheck_platform_mac.h"
10 #include "chrome/common/spellcheck_result.h" 10 #include "chrome/common/spellcheck_result.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 // the correct document. 52 // the correct document.
53 TEST_F(SpellcheckMacTest, IgnoreWords_EN_US) { 53 TEST_F(SpellcheckMacTest, IgnoreWords_EN_US) {
54 const char* kTestCases[] = { 54 const char* kTestCases[] = {
55 "teh", 55 "teh",
56 "morblier", 56 "morblier",
57 "watre", 57 "watre",
58 "noooen", 58 "noooen",
59 }; 59 };
60 60
61 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); ++i) { 61 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); ++i) {
62 const base::string16 word(ASCIIToUTF16(kTestCases[i])); 62 const base::string16 word(base::ASCIIToUTF16(kTestCases[i]));
63 const int doc_tag = spellcheck_mac::GetDocumentTag(); 63 const int doc_tag = spellcheck_mac::GetDocumentTag();
64 64
65 // The word should show up as misspelled. 65 // The word should show up as misspelled.
66 EXPECT_FALSE(spellcheck_mac::CheckSpelling(word, doc_tag)) << word; 66 EXPECT_FALSE(spellcheck_mac::CheckSpelling(word, doc_tag)) << word;
67 67
68 // Ignore the word. 68 // Ignore the word.
69 spellcheck_mac::IgnoreWord(word); 69 spellcheck_mac::IgnoreWord(word);
70 70
71 // The word should now show up as correctly spelled. 71 // The word should now show up as correctly spelled.
72 EXPECT_TRUE(spellcheck_mac::CheckSpelling(word, doc_tag)) << word; 72 EXPECT_TRUE(spellcheck_mac::CheckSpelling(word, doc_tag)) << word;
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 {"villege", "village"}, 347 {"villege", "village"},
348 {"wierd", "weird"}, 348 {"wierd", "weird"},
349 {"wellcome", "welcome"}, 349 {"wellcome", "welcome"},
350 {"wellfare", "welfare"}, 350 {"wellfare", "welfare"},
351 {"wilfull", "willful"}, 351 {"wilfull", "willful"},
352 {"withold", "withhold"}, 352 {"withold", "withhold"},
353 {"writting", "writing"}, 353 {"writting", "writing"},
354 }; 354 };
355 355
356 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); ++i) { 356 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); ++i) {
357 const base::string16 word(ASCIIToUTF16(kTestCases[i].input)); 357 const base::string16 word(base::ASCIIToUTF16(kTestCases[i].input));
358 EXPECT_FALSE(spellcheck_mac::CheckSpelling(word, 0)) << word; 358 EXPECT_FALSE(spellcheck_mac::CheckSpelling(word, 0)) << word;
359 359
360 // Check if the suggested words occur. 360 // Check if the suggested words occur.
361 std::vector<base::string16> suggestions; 361 std::vector<base::string16> suggestions;
362 spellcheck_mac::FillSuggestionList(word, &suggestions); 362 spellcheck_mac::FillSuggestionList(word, &suggestions);
363 bool suggested_word_is_present = false; 363 bool suggested_word_is_present = false;
364 const base::string16 suggested_word( 364 const base::string16 suggested_word(
365 ASCIIToUTF16(kTestCases[i].suggested_word)); 365 base::ASCIIToUTF16(kTestCases[i].suggested_word));
366 for (size_t j = 0; j < suggestions.size(); j++) { 366 for (size_t j = 0; j < suggestions.size(); j++) {
367 if (suggestions[j].compare(suggested_word) == 0) { 367 if (suggestions[j].compare(suggested_word) == 0) {
368 suggested_word_is_present = true; 368 suggested_word_is_present = true;
369 break; 369 break;
370 } 370 }
371 } 371 }
372 EXPECT_TRUE(suggested_word_is_present) << suggested_word; 372 EXPECT_TRUE(suggested_word_is_present) << suggested_word;
373 } 373 }
374 } 374 }
375 375
376 // The OSX spellchecker returns non-spellcheck results when invoked on a 376 // The OSX spellchecker returns non-spellcheck results when invoked on a
377 // sentence, specifically an NSTextCheckingTypeOrthography result indicating 377 // sentence, specifically an NSTextCheckingTypeOrthography result indicating
378 // the language used in that sentence. Test that it is filtered out from 378 // the language used in that sentence. Test that it is filtered out from
379 // RequestTextCheck results. 379 // RequestTextCheck results.
380 TEST_F(SpellcheckMacTest, SpellCheckIgnoresOrthography) { 380 TEST_F(SpellcheckMacTest, SpellCheckIgnoresOrthography) {
381 base::string16 test_string(ASCIIToUTF16("Icland is awesome.")); 381 base::string16 test_string(base::ASCIIToUTF16("Icland is awesome."));
382 spellcheck_mac::RequestTextCheck(0, test_string, callback_); 382 spellcheck_mac::RequestTextCheck(0, test_string, callback_);
383 WaitForCallback(); 383 WaitForCallback();
384 EXPECT_TRUE(callback_finished_); 384 EXPECT_TRUE(callback_finished_);
385 EXPECT_EQ(1U, results_.size()); 385 EXPECT_EQ(1U, results_.size());
386 } 386 }
387 387
388 } // namespace 388 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698