diff options
author | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-25 00:53:42 +0000 |
---|---|---|
committer | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-25 00:53:42 +0000 |
commit | c91b9d414c56955f3ca405fd66c6f567fc16d9fc (patch) | |
tree | 293205b4a78c5ce8571edcb4ae26e1b9880d8e51 /chrome/renderer/spellchecker | |
parent | 036a5f386e1204a861f3b24201bd0f89d359f29c (diff) | |
download | chromium_src-c91b9d414c56955f3ca405fd66c6f567fc16d9fc.zip chromium_src-c91b9d414c56955f3ca405fd66c6f567fc16d9fc.tar.gz chromium_src-c91b9d414c56955f3ca405fd66c6f567fc16d9fc.tar.bz2 |
Update uses of UTF conversions in chrome/installer, chrome/renderer, chrome/service, chrome/test, chrome/third_party, chrome/tools, chrome/utility to use the base:: namespace.
BUG=330556
TEST=no change
TBR=ben@chromium.org
Review URL: https://codereview.chromium.org/119103004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@242472 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer/spellchecker')
9 files changed, 56 insertions, 52 deletions
diff --git a/chrome/renderer/spellchecker/custom_dictionary_engine.cc b/chrome/renderer/spellchecker/custom_dictionary_engine.cc index 976ffea..edf6cdd 100644 --- a/chrome/renderer/spellchecker/custom_dictionary_engine.cc +++ b/chrome/renderer/spellchecker/custom_dictionary_engine.cc @@ -21,7 +21,7 @@ void CustomDictionaryEngine::Init(const std::set<std::string>& custom_words) { for (std::set<std::string>::const_iterator it = custom_words.begin(); it != custom_words.end(); ++it) { - dictionary_.insert(UTF8ToUTF16(*it)); + dictionary_.insert(base::UTF8ToUTF16(*it)); } } @@ -31,12 +31,12 @@ void CustomDictionaryEngine::OnCustomDictionaryChanged( for (std::vector<std::string>::const_iterator it = words_added.begin(); it != words_added.end(); ++it) { - dictionary_.insert(UTF8ToUTF16(*it)); + dictionary_.insert(base::UTF8ToUTF16(*it)); } for (std::vector<std::string>::const_iterator it = words_removed.begin(); it != words_removed.end(); ++it) { - dictionary_.erase(UTF8ToUTF16(*it)); + dictionary_.erase(base::UTF8ToUTF16(*it)); } } diff --git a/chrome/renderer/spellchecker/custom_dictionary_engine_unittest.cc b/chrome/renderer/spellchecker/custom_dictionary_engine_unittest.cc index b57b603..dc9d50e 100644 --- a/chrome/renderer/spellchecker/custom_dictionary_engine_unittest.cc +++ b/chrome/renderer/spellchecker/custom_dictionary_engine_unittest.cc @@ -15,11 +15,13 @@ TEST(CustomDictionaryTest, HandlesEmptyWordWithInvalidSubstring) { TEST(CustomDictionaryTest, Basic) { CustomDictionaryEngine engine; - EXPECT_FALSE(engine.SpellCheckWord(ASCIIToUTF16("helllo").c_str(), 0, 6)); + EXPECT_FALSE(engine.SpellCheckWord(base::ASCIIToUTF16("helllo").c_str(), + 0, 6)); std::set<std::string> custom_words; custom_words.insert("helllo"); engine.Init(custom_words); - EXPECT_TRUE(engine.SpellCheckWord(ASCIIToUTF16("helllo").c_str(), 0, 6)); + EXPECT_TRUE(engine.SpellCheckWord(base::ASCIIToUTF16("helllo").c_str(), + 0, 6)); } TEST(CustomDictionaryTest, HandlesNullCharacters) { diff --git a/chrome/renderer/spellchecker/hunspell_engine.cc b/chrome/renderer/spellchecker/hunspell_engine.cc index 7900c50..74dd292 100644 --- a/chrome/renderer/spellchecker/hunspell_engine.cc +++ b/chrome/renderer/spellchecker/hunspell_engine.cc @@ -80,7 +80,7 @@ bool HunspellEngine::CheckSpelling(const base::string16& word_to_check, // offer suggestions on them, either, there's no point in flagging them to // the user. bool word_correct = true; - std::string word_to_check_utf8(UTF16ToUTF8(word_to_check)); + std::string word_to_check_utf8(base::UTF16ToUTF8(word_to_check)); // Limit the size of checked words. if (word_to_check_utf8.length() <= kMaxCheckedLen) { @@ -98,7 +98,7 @@ bool HunspellEngine::CheckSpelling(const base::string16& word_to_check, void HunspellEngine::FillSuggestionList( const base::string16& wrong_word, std::vector<base::string16>* optional_suggestions) { - std::string wrong_word_utf8(UTF16ToUTF8(wrong_word)); + std::string wrong_word_utf8(base::UTF16ToUTF8(wrong_word)); if (wrong_word_utf8.length() > kMaxSuggestLen) return; @@ -115,7 +115,7 @@ void HunspellEngine::FillSuggestionList( // Populate the vector of WideStrings. for (int i = 0; i < number_of_suggestions; ++i) { if (i < chrome::spellcheck_common::kMaxSuggestions) - optional_suggestions->push_back(UTF8ToUTF16(suggestions[i])); + optional_suggestions->push_back(base::UTF8ToUTF16(suggestions[i])); free(suggestions[i]); } if (suggestions != NULL) diff --git a/chrome/renderer/spellchecker/spellcheck_provider_hunspell_unittest.cc b/chrome/renderer/spellchecker/spellcheck_provider_hunspell_unittest.cc index eb92ceb..a9d5f18 100644 --- a/chrome/renderer/spellchecker/spellcheck_provider_hunspell_unittest.cc +++ b/chrome/renderer/spellchecker/spellcheck_provider_hunspell_unittest.cc @@ -14,6 +14,8 @@ // Tests for Hunspell functionality in SpellcheckingProvider +using base::ASCIIToUTF16; + namespace { TEST_F(SpellCheckProviderTest, UsingHunspell) { diff --git a/chrome/renderer/spellchecker/spellcheck_provider_mac_unittest.cc b/chrome/renderer/spellchecker/spellcheck_provider_mac_unittest.cc index 5cb81f0..bab1107d 100644 --- a/chrome/renderer/spellchecker/spellcheck_provider_mac_unittest.cc +++ b/chrome/renderer/spellchecker/spellcheck_provider_mac_unittest.cc @@ -62,7 +62,7 @@ TEST_F(SpellCheckProviderMacTest, SingleRoundtripSuccess) { MessageParameters read_parameters = ReadRequestTextCheck(provider_.messages_[0]); - EXPECT_EQ(read_parameters.text, UTF8ToUTF16("hello ")); + EXPECT_EQ(read_parameters.text, base::UTF8ToUTF16("hello ")); FakeMessageArrival(&provider_, read_parameters); EXPECT_EQ(completion.completion_count_, 1U); @@ -86,11 +86,11 @@ TEST_F(SpellCheckProviderMacTest, TwoRoundtripSuccess) { MessageParameters read_parameters1 = ReadRequestTextCheck(provider_.messages_[0]); - EXPECT_EQ(read_parameters1.text, UTF8ToUTF16("hello ")); + EXPECT_EQ(read_parameters1.text, base::UTF8ToUTF16("hello ")); MessageParameters read_parameters2 = ReadRequestTextCheck(provider_.messages_[1]); - EXPECT_EQ(read_parameters2.text, UTF8ToUTF16("bye ")); + EXPECT_EQ(read_parameters2.text, base::UTF8ToUTF16("bye ")); FakeMessageArrival(&provider_, read_parameters1); EXPECT_EQ(completion1.completion_count_, 1U); diff --git a/chrome/renderer/spellchecker/spellcheck_unittest.cc b/chrome/renderer/spellchecker/spellcheck_unittest.cc index 143770e..05f0b6b 100644 --- a/chrome/renderer/spellchecker/spellcheck_unittest.cc +++ b/chrome/renderer/spellchecker/spellcheck_unittest.cc @@ -79,7 +79,7 @@ class SpellCheckTest : public testing::Test { bool CheckSpelling(const std::string& word, int tag) { return spell_check_->spellcheck_.platform_spelling_engine_->CheckSpelling( - ASCIIToUTF16(word), tag); + base::ASCIIToUTF16(word), tag); } #if !defined(OS_MACOSX) @@ -388,7 +388,7 @@ TEST_F(SpellCheckTest, SpellCheckStrings_EN_US) { int misspelling_start; int misspelling_length; bool result = spell_check()->SpellCheckWord( - WideToUTF16(kTestCases[i].input).c_str(), + base::WideToUTF16(kTestCases[i].input).c_str(), static_cast<int>(input_length), 0, &misspelling_start, @@ -439,7 +439,7 @@ TEST_F(SpellCheckTest, SpellCheckSuggestions_EN_US) { int misspelling_start; int misspelling_length; bool result = spell_check()->SpellCheckWord( - WideToUTF16(kTestCases[i].input).c_str(), + base::WideToUTF16(kTestCases[i].input).c_str(), static_cast<int>(input_length), 0, &misspelling_start, @@ -452,8 +452,8 @@ TEST_F(SpellCheckTest, SpellCheckSuggestions_EN_US) { // Check if the suggested words occur. bool suggested_word_is_present = false; for (int j = 0; j < static_cast<int>(suggestions.size()); j++) { - if (suggestions.at(j).compare(WideToUTF16(kTestCases[i].suggested_word)) - == 0) { + if (suggestions.at(j).compare( + base::WideToUTF16(kTestCases[i].suggested_word)) == 0) { suggested_word_is_present = true; break; } @@ -804,7 +804,7 @@ TEST_F(SpellCheckTest, MAYBE_SpellCheckText) { int misspelling_start = 0; int misspelling_length = 0; bool result = spell_check()->SpellCheckWord( - WideToUTF16(kTestCases[i].input).c_str(), + base::WideToUTF16(kTestCases[i].input).c_str(), static_cast<int>(input_length), 0, &misspelling_start, @@ -841,9 +841,9 @@ TEST_F(SpellCheckTest, GetAutoCorrectionWord_EN_US) { EnableAutoCorrect(true); for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); ++i) { - base::string16 misspelled_word(UTF8ToUTF16(kTestCases[i].input)); + base::string16 misspelled_word(base::UTF8ToUTF16(kTestCases[i].input)); base::string16 expected_autocorrect_word( - UTF8ToUTF16(kTestCases[i].expected_result)); + base::UTF8ToUTF16(kTestCases[i].expected_result)); base::string16 autocorrect_word = spell_check()->GetAutoCorrectionWord( misspelled_word, 0); @@ -885,7 +885,7 @@ TEST_F(SpellCheckTest, MisspelledWords) { for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); ++i) { ReinitializeSpellCheck(kTestCases[i].language); - base::string16 word(WideToUTF16(kTestCases[i].input)); + base::string16 word(base::WideToUTF16(kTestCases[i].input)); int word_length = static_cast<int>(word.length()); int misspelling_start = 0; int misspelling_length = 0; @@ -908,19 +908,19 @@ TEST_F(SpellCheckTest, MisspelledWords) { // Make sure SpellCheckParagraph does not crash if the input is empty. TEST_F(SpellCheckTest, SpellCheckParagraphEmptyParagraph) { std::vector<SpellCheckResult> expected; - TestSpellCheckParagraph(UTF8ToUTF16(""), expected); + TestSpellCheckParagraph(base::UTF8ToUTF16(""), expected); } // A simple test case having no misspellings. TEST_F(SpellCheckTest, SpellCheckParagraphNoMisspellings) { - const base::string16 text = UTF8ToUTF16("apple"); + const base::string16 text = base::UTF8ToUTF16("apple"); std::vector<SpellCheckResult> expected; TestSpellCheckParagraph(text, expected); } // A simple test case having one misspelling. TEST_F(SpellCheckTest, SpellCheckParagraphSingleMisspellings) { - const base::string16 text = UTF8ToUTF16("zz"); + const base::string16 text = base::UTF8ToUTF16("zz"); std::vector<SpellCheckResult> expected; expected.push_back(SpellCheckResult( SpellCheckResult::SPELLING, 0, 2)); @@ -930,7 +930,7 @@ TEST_F(SpellCheckTest, SpellCheckParagraphSingleMisspellings) { // A simple test case having multiple misspellings. TEST_F(SpellCheckTest, SpellCheckParagraphMultipleMisspellings) { - const base::string16 text = UTF8ToUTF16("zz, zz"); + const base::string16 text = base::UTF8ToUTF16("zz, zz"); std::vector<SpellCheckResult> expected; expected.push_back(SpellCheckResult( SpellCheckResult::SPELLING, 0, 2)); @@ -944,7 +944,7 @@ TEST_F(SpellCheckTest, SpellCheckParagraphMultipleMisspellings) { TEST_F(SpellCheckTest, SpellCheckParagraphLongSentence) { std::vector<SpellCheckResult> expected; // The text is taken from US constitution preamble. - const base::string16 text = UTF8ToUTF16( + const base::string16 text = base::UTF8ToUTF16( "We the people of the United States, in order to form a more perfect " "union, establish justice, insure domestic tranquility, provide for " "the common defense, promote the general welfare, and secure the " @@ -959,7 +959,7 @@ TEST_F(SpellCheckTest, SpellCheckParagraphLongSentenceMultipleMisspellings) { std::vector<SpellCheckResult> expected; // All 'the' are converted to 'hte' in US consitition preamble. - const base::string16 text = UTF8ToUTF16( + const base::string16 text = base::UTF8ToUTF16( "We hte people of hte United States, in order to form a more perfect " "union, establish justice, insure domestic tranquility, provide for " "hte common defense, promote hte general welfare, and secure hte " @@ -1000,7 +1000,7 @@ TEST_F(SpellCheckTest, RequestSpellCheckWithEmptyString) { TEST_F(SpellCheckTest, RequestSpellCheckWithoutMisspelling) { MockTextCheckingCompletion completion; - const base::string16 text = ASCIIToUTF16("hello"); + const base::string16 text = base::ASCIIToUTF16("hello"); spell_check()->RequestTextChecking(text, &completion); base::MessageLoop::current()->RunUntilIdle(); @@ -1012,7 +1012,7 @@ TEST_F(SpellCheckTest, RequestSpellCheckWithoutMisspelling) { TEST_F(SpellCheckTest, RequestSpellCheckWithSingleMisspelling) { MockTextCheckingCompletion completion; - const base::string16 text = ASCIIToUTF16("apple, zz"); + const base::string16 text = base::ASCIIToUTF16("apple, zz"); spell_check()->RequestTextChecking(text, &completion); base::MessageLoop::current()->RunUntilIdle(); @@ -1027,7 +1027,7 @@ TEST_F(SpellCheckTest, RequestSpellCheckWithSingleMisspelling) { TEST_F(SpellCheckTest, RequestSpellCheckWithMisspellings) { MockTextCheckingCompletion completion; - const base::string16 text = ASCIIToUTF16("apple, zz, orange, zz"); + const base::string16 text = base::ASCIIToUTF16("apple, zz, orange, zz"); spell_check()->RequestTextChecking(text, &completion); base::MessageLoop::current()->RunUntilIdle(); @@ -1046,9 +1046,9 @@ TEST_F(SpellCheckTest, RequestSpellCheckWithMultipleRequests) { MockTextCheckingCompletion completion[3]; const base::string16 text[3] = { - ASCIIToUTF16("what, zz"), - ASCIIToUTF16("apple, zz"), - ASCIIToUTF16("orange, zz") + base::ASCIIToUTF16("what, zz"), + base::ASCIIToUTF16("apple, zz"), + base::ASCIIToUTF16("orange, zz") }; for (int i = 0; i < 3; ++i) @@ -1070,7 +1070,7 @@ TEST_F(SpellCheckTest, RequestSpellCheckWithoutInitialization) { UninitializeSpellCheck(); MockTextCheckingCompletion completion; - const base::string16 text = ASCIIToUTF16("zz"); + const base::string16 text = base::ASCIIToUTF16("zz"); spell_check()->RequestTextChecking(text, &completion); @@ -1086,9 +1086,9 @@ TEST_F(SpellCheckTest, RequestSpellCheckMultipleTimesWithoutInitialization) { MockTextCheckingCompletion completion[3]; const base::string16 text[3] = { - ASCIIToUTF16("what, zz"), - ASCIIToUTF16("apple, zz"), - ASCIIToUTF16("orange, zz") + base::ASCIIToUTF16("what, zz"), + base::ASCIIToUTF16("apple, zz"), + base::ASCIIToUTF16("orange, zz") }; // Calls RequestTextchecking a few times. @@ -1117,7 +1117,7 @@ TEST_F(SpellCheckTest, CreateTextCheckingResults) { // Verify that the SpellCheck class keeps the spelling marker added to a // misspelled word "zz". { - base::string16 text = ASCIIToUTF16("zz"); + base::string16 text = base::ASCIIToUTF16("zz"); std::vector<SpellCheckResult> spellcheck_results; spellcheck_results.push_back(SpellCheckResult( SpellCheckResult::SPELLING, 0, 2, base::string16())); @@ -1137,7 +1137,7 @@ TEST_F(SpellCheckTest, CreateTextCheckingResults) { // Verify that the SpellCheck class replaces the spelling marker added to a // contextually-misspelled word "bean" with a grammar marker. { - base::string16 text = ASCIIToUTF16("I have bean to USA."); + base::string16 text = base::ASCIIToUTF16("I have bean to USA."); std::vector<SpellCheckResult> spellcheck_results; spellcheck_results.push_back(SpellCheckResult( SpellCheckResult::SPELLING, 7, 4, base::string16())); @@ -1197,7 +1197,7 @@ TEST_F(SpellCheckTest, EnglishWords) { int misspelling_start = 0; int misspelling_length = 0; bool result = spell_check()->SpellCheckWord( - ASCIIToUTF16(kTestCases[i].input).c_str(), + base::ASCIIToUTF16(kTestCases[i].input).c_str(), static_cast<int>(input_length), 0, &misspelling_start, @@ -1244,7 +1244,7 @@ TEST_F(SpellCheckTest, NoSuggest) { int misspelling_start = 0; int misspelling_length = 0; bool result = spell_check()->SpellCheckWord( - ASCIIToUTF16(kTestCases[i].suggestion).c_str(), + base::ASCIIToUTF16(kTestCases[i].suggestion).c_str(), static_cast<int>(suggestion_length), 0, &misspelling_start, @@ -1259,7 +1259,7 @@ TEST_F(SpellCheckTest, NoSuggest) { if (kTestCases[i].input != NULL) input_length = strlen(kTestCases[i].input); result = spell_check()->SpellCheckWord( - ASCIIToUTF16(kTestCases[i].input).c_str(), + base::ASCIIToUTF16(kTestCases[i].input).c_str(), static_cast<int>(input_length), 0, &misspelling_start, @@ -1272,8 +1272,8 @@ TEST_F(SpellCheckTest, NoSuggest) { // Check if the suggested words occur. for (int j = 0; j < static_cast<int>(suggestions.size()); j++) { for (size_t t = 0; t < test_cases_size; t++) { - int compare_result = - suggestions.at(j).compare(ASCIIToUTF16(kTestCases[t].suggestion)); + int compare_result = suggestions.at(j).compare( + base::ASCIIToUTF16(kTestCases[t].suggestion)); EXPECT_FALSE(compare_result == 0) << kTestCases[t].suggestion << " in " << kTestCases[i].locale; } @@ -1349,7 +1349,7 @@ TEST_F(SpellCheckTest, LogicalSuggestions) { int misspelling_length = 0; std::vector<base::string16> suggestions; EXPECT_FALSE(spell_check()->SpellCheckWord( - ASCIIToUTF16(kTestCases[i].misspelled).c_str(), + base::ASCIIToUTF16(kTestCases[i].misspelled).c_str(), strlen(kTestCases[i].misspelled), 0, &misspelling_start, @@ -1357,6 +1357,6 @@ TEST_F(SpellCheckTest, LogicalSuggestions) { &suggestions)); EXPECT_GE(suggestions.size(), static_cast<size_t>(1)); if (suggestions.size() > 0) - EXPECT_EQ(suggestions[0], ASCIIToUTF16(kTestCases[i].suggestion)); + EXPECT_EQ(suggestions[0], base::ASCIIToUTF16(kTestCases[i].suggestion)); } } diff --git a/chrome/renderer/spellchecker/spellcheck_worditerator.cc b/chrome/renderer/spellchecker/spellcheck_worditerator.cc index ca5c7fa..9d0e555 100644 --- a/chrome/renderer/spellchecker/spellcheck_worditerator.cc +++ b/chrome/renderer/spellchecker/spellcheck_worditerator.cc @@ -174,14 +174,14 @@ void SpellcheckCharAttribute::CreateRuleSets(const std::string& language) { "$ALetterEx ($MidLetterEx | $MidNumLetEx) $ALetterEx {200};"; const char kDisallowContraction[] = ""; - ruleset_allow_contraction_ = ASCIIToUTF16( + ruleset_allow_contraction_ = base::ASCIIToUTF16( base::StringPrintf(kRuleTemplate, aletter, aletter_extra, midletter_extra, aletter_plus, kAllowContraction)); - ruleset_disallow_contraction_ = ASCIIToUTF16( + ruleset_disallow_contraction_ = base::ASCIIToUTF16( base::StringPrintf(kRuleTemplate, aletter, aletter_extra, diff --git a/chrome/renderer/spellchecker/spellcheck_worditerator.h b/chrome/renderer/spellchecker/spellcheck_worditerator.h index 50a0ef6..3a757b9 100644 --- a/chrome/renderer/spellchecker/spellcheck_worditerator.h +++ b/chrome/renderer/spellchecker/spellcheck_worditerator.h @@ -93,7 +93,7 @@ class SpellcheckCharAttribute { // // Set up a SpellcheckWordIterator object which extracts English words, // // and retrieve them. // SpellcheckWordIterator iterator; -// base::string16 text(UTF8ToUTF16("this is a test.")); +// base::string16 text(base::UTF8ToUTF16("this is a test.")); // iterator.Initialize(&attribute, true); // iterator.SetText(text.c_str(), text_.length()); // diff --git a/chrome/renderer/spellchecker/spellcheck_worditerator_unittest.cc b/chrome/renderer/spellchecker/spellcheck_worditerator_unittest.cc index c1e5fce..a87340a 100644 --- a/chrome/renderer/spellchecker/spellcheck_worditerator_unittest.cc +++ b/chrome/renderer/spellchecker/spellcheck_worditerator_unittest.cc @@ -119,7 +119,7 @@ TEST(SpellcheckWordIteratorTest, SplitWord) { SpellcheckCharAttribute attributes; attributes.SetDefaultLanguage(kTestCases[i].language); - base::string16 input(WideToUTF16(kTestText)); + base::string16 input(base::WideToUTF16(kTestText)); SpellcheckWordIterator iterator; EXPECT_TRUE(iterator.Initialize(&attributes, kTestCases[i].allow_contraction)); @@ -127,7 +127,7 @@ TEST(SpellcheckWordIteratorTest, SplitWord) { std::vector<base::string16> expected_words; base::SplitString( - WideToUTF16(kTestCases[i].expected_words), ' ', &expected_words); + base::WideToUTF16(kTestCases[i].expected_words), ' ', &expected_words); base::string16 actual_word; int actual_start, actual_end; @@ -149,7 +149,7 @@ TEST(SpellcheckWordIteratorTest, RuleSetConsistency) { attributes.SetDefaultLanguage("en-US"); const wchar_t kTestText[] = L"\x1791\x17c1\x002e"; - base::string16 input(WideToUTF16(kTestText)); + base::string16 input(base::WideToUTF16(kTestText)); SpellcheckWordIterator iterator; EXPECT_TRUE(iterator.Initialize(&attributes, true)); @@ -214,7 +214,7 @@ TEST(SpellcheckWordIteratorTest, TreatNumbersAsWordCharacters) { SpellcheckCharAttribute attributes; attributes.SetDefaultLanguage(kTestCases[i].language); - base::string16 input_word(WideToUTF16(kTestCases[i].text)); + base::string16 input_word(base::WideToUTF16(kTestCases[i].text)); SpellcheckWordIterator iterator; EXPECT_TRUE(iterator.Initialize(&attributes, true)); EXPECT_TRUE(iterator.SetText(input_word.c_str(), input_word.length())); |