OLD | NEW |
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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 // supply a non-zero doc_tag, in order to test that ignored words are matched to | 51 // supply a non-zero doc_tag, in order to test that ignored words are matched to |
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(kTestCases); ++i) { |
62 const base::string16 word(base::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. |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 {"visious", "vicious"}, | 349 {"visious", "vicious"}, |
350 {"villege", "village"}, | 350 {"villege", "village"}, |
351 {"wierd", "weird"}, | 351 {"wierd", "weird"}, |
352 {"wellcome", "welcome"}, | 352 {"wellcome", "welcome"}, |
353 {"wellfare", "welfare"}, | 353 {"wellfare", "welfare"}, |
354 {"wilfull", "willful"}, | 354 {"wilfull", "willful"}, |
355 {"withold", "withhold"}, | 355 {"withold", "withhold"}, |
356 {"writting", "writing"}, | 356 {"writting", "writing"}, |
357 }; | 357 }; |
358 | 358 |
359 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); ++i) { | 359 for (size_t i = 0; i < arraysize(kTestCases); ++i) { |
360 const base::string16 word(base::ASCIIToUTF16(kTestCases[i].input)); | 360 const base::string16 word(base::ASCIIToUTF16(kTestCases[i].input)); |
361 EXPECT_FALSE(spellcheck_mac::CheckSpelling(word, 0)) << word; | 361 EXPECT_FALSE(spellcheck_mac::CheckSpelling(word, 0)) << word; |
362 | 362 |
363 // Check if the suggested words occur. | 363 // Check if the suggested words occur. |
364 std::vector<base::string16> suggestions; | 364 std::vector<base::string16> suggestions; |
365 spellcheck_mac::FillSuggestionList(word, &suggestions); | 365 spellcheck_mac::FillSuggestionList(word, &suggestions); |
366 bool suggested_word_is_present = false; | 366 bool suggested_word_is_present = false; |
367 const base::string16 suggested_word( | 367 const base::string16 suggested_word( |
368 base::ASCIIToUTF16(kTestCases[i].suggested_word)); | 368 base::ASCIIToUTF16(kTestCases[i].suggested_word)); |
369 for (size_t j = 0; j < suggestions.size(); j++) { | 369 for (size_t j = 0; j < suggestions.size(); j++) { |
(...skipping 12 matching lines...) Expand all Loading... |
382 // RequestTextCheck results. | 382 // RequestTextCheck results. |
383 TEST_F(SpellcheckMacTest, SpellCheckIgnoresOrthography) { | 383 TEST_F(SpellcheckMacTest, SpellCheckIgnoresOrthography) { |
384 base::string16 test_string(base::ASCIIToUTF16("Icland is awesome.")); | 384 base::string16 test_string(base::ASCIIToUTF16("Icland is awesome.")); |
385 spellcheck_mac::RequestTextCheck(0, test_string, callback_); | 385 spellcheck_mac::RequestTextCheck(0, test_string, callback_); |
386 WaitForCallback(); | 386 WaitForCallback(); |
387 EXPECT_TRUE(callback_finished_); | 387 EXPECT_TRUE(callback_finished_); |
388 EXPECT_EQ(1U, results_.size()); | 388 EXPECT_EQ(1U, results_.size()); |
389 } | 389 } |
390 | 390 |
391 } // namespace | 391 } // namespace |
OLD | NEW |