Index: chrome/renderer/spellchecker/spellcheck_unittest.cc |
diff --git a/chrome/renderer/spellchecker/spellcheck_unittest.cc b/chrome/renderer/spellchecker/spellcheck_unittest.cc |
index f82ac8034560ddbc72df9369e471a6f01f130d01..aa801642831e654acd2fb6c38ed3e2e65bf51c6c 100644 |
--- a/chrome/renderer/spellchecker/spellcheck_unittest.cc |
+++ b/chrome/renderer/spellchecker/spellcheck_unittest.cc |
@@ -1140,7 +1140,7 @@ TEST_F(SpellCheckTest, CreateTextCheckingResults) { |
text, |
spellcheck_results, |
&textcheck_results); |
- EXPECT_EQ(spellcheck_results.size(), textcheck_results.size()); |
+ ASSERT_EQ(spellcheck_results.size(), textcheck_results.size()); |
EXPECT_EQ(blink::WebTextDecorationTypeSpelling, |
textcheck_results[0].decoration); |
EXPECT_EQ(spellcheck_results[0].location, textcheck_results[0].location); |
@@ -1160,12 +1160,51 @@ TEST_F(SpellCheckTest, CreateTextCheckingResults) { |
text, |
spellcheck_results, |
&textcheck_results); |
- EXPECT_EQ(spellcheck_results.size(), textcheck_results.size()); |
+ ASSERT_EQ(spellcheck_results.size(), textcheck_results.size()); |
EXPECT_EQ(blink::WebTextDecorationTypeGrammar, |
textcheck_results[0].decoration); |
EXPECT_EQ(spellcheck_results[0].location, textcheck_results[0].location); |
EXPECT_EQ(spellcheck_results[0].length, textcheck_results[0].length); |
} |
+ |
+ // Verify that the SpellCheck class removes the spelling marker caused only by |
+ // a typographical apostrophe. |
+ { |
+ base::string16 text = |
+ base::WideToUTF16(L"I\x2019ve bean here before, hasn\x2019t I?"); |
+ std::vector<SpellCheckResult> spellcheck_results; |
+ |
+ // Typographical apostrophe correction should be ignored. |
+ spellcheck_results.push_back(SpellCheckResult( |
+ SpellCheckResult::SPELLING, 0, 4, base::ASCIIToUTF16("I've"))); |
+ |
+ // Contextual mistake should be marked as grammar mistake. |
+ spellcheck_results.push_back(SpellCheckResult( |
+ SpellCheckResult::SPELLING, 5, 4, base::ASCIIToUTF16("been"))); |
+ |
+ // Contextual mistake in addition to a typographical apostrophe correction |
+ // should be marked as grammar mistake. |
+ spellcheck_results.push_back(SpellCheckResult( |
+ SpellCheckResult::SPELLING, 23, 6, base::ASCIIToUTF16("haven't"))); |
+ |
+ blink::WebVector<blink::WebTextCheckingResult> textcheck_results; |
+ spell_check()->CreateTextCheckingResults(SpellCheck::USE_NATIVE_CHECKER, |
+ 0, |
+ text, |
+ spellcheck_results, |
+ &textcheck_results); |
+ ASSERT_EQ(2UL, textcheck_results.size()); |
+ |
+ EXPECT_EQ(blink::WebTextDecorationTypeGrammar, |
+ textcheck_results[0].decoration); |
+ EXPECT_EQ(spellcheck_results[1].location, textcheck_results[0].location); |
+ EXPECT_EQ(spellcheck_results[1].length, textcheck_results[0].length); |
+ |
+ EXPECT_EQ(blink::WebTextDecorationTypeGrammar, |
+ textcheck_results[1].decoration); |
+ EXPECT_EQ(spellcheck_results[2].location, textcheck_results[1].location); |
+ EXPECT_EQ(spellcheck_results[2].length, textcheck_results[1].length); |
+ } |
} |
#endif |