Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "components/spellcheck/renderer/spellcheck.h" | 5 #include "components/spellcheck/renderer/spellcheck.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 171 // non-English word; | 171 // non-English word; |
| 172 // * Tests for the function with an invalid English word with a following | 172 // * Tests for the function with an invalid English word with a following |
| 173 // space character; | 173 // space character; |
| 174 // * Tests for the function with an invalid English word with a following | 174 // * Tests for the function with an invalid English word with a following |
| 175 // non-English word, and; | 175 // non-English word, and; |
| 176 // * Tests for the function with two invalid English words concatenated | 176 // * Tests for the function with two invalid English words concatenated |
| 177 // with space characters or non-English words. | 177 // with space characters or non-English words. |
| 178 // A test with a "[ROBUSTNESS]" mark shows it is a robustness test and it uses | 178 // A test with a "[ROBUSTNESS]" mark shows it is a robustness test and it uses |
| 179 // grammatically incorrect string. | 179 // grammatically incorrect string. |
| 180 // TODO(groby): Please feel free to add more tests. | 180 // TODO(groby): Please feel free to add more tests. |
| 181 #if defined(OS_WIN) && !defined(NDEBUG) | 181 TEST_F(SpellCheckTest, SpellCheckStrings_EN_US) { |
| 182 // Test times out on win dbg. crbug.com/678753. | |
| 183 #define MAYBE_SpellCheckStrings_EN_US DISABLED_SpellCheckStrings_EN_US | |
| 184 #else | |
| 185 #define MAYBE_SpellCheckStrings_EN_US SpellCheckStrings_EN_US | |
| 186 #endif | |
| 187 TEST_F(SpellCheckTest, MAYBE_SpellCheckStrings_EN_US) { | |
| 188 static const struct { | 182 static const struct { |
| 189 // A string to be tested. | 183 // A string to be tested. |
| 190 const wchar_t* input; | 184 const wchar_t* input; |
| 191 // An expected result for this test case. | 185 // An expected result for this test case. |
| 192 // * true: the input string does not have any invalid words. | 186 // * true: the input string does not have any invalid words. |
| 193 // * false: the input string has one or more invalid words. | 187 // * false: the input string has one or more invalid words. |
| 194 bool expected_result; | 188 bool expected_result; |
| 195 // The position and the length of the first invalid word. | 189 // The position and the length of the first invalid word. |
| 196 int misspelling_start; | 190 int misspelling_start; |
| 197 int misspelling_length; | 191 int misspelling_length; |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 488 break; | 482 break; |
| 489 } | 483 } |
| 490 } | 484 } |
| 491 | 485 |
| 492 EXPECT_TRUE(suggested_word_is_present); | 486 EXPECT_TRUE(suggested_word_is_present); |
| 493 } | 487 } |
| 494 } | 488 } |
| 495 | 489 |
| 496 // This test verifies our spellchecker can split a text into words and check | 490 // This test verifies our spellchecker can split a text into words and check |
| 497 // the spelling of each word in the text. | 491 // the spelling of each word in the text. |
| 498 #if defined(THREAD_SANITIZER) || defined(OS_WIN) | 492 #if defined(THREAD_SANITIZER) |
|
groby-ooo-7-16
2017/01/23 21:08:11
Once this has landed, could you give this another
| |
| 499 // SpellCheckTest.SpellCheckText fails under ThreadSanitizer v2. | 493 // SpellCheckTest.SpellCheckText fails under ThreadSanitizer v2. |
| 500 // See http://crbug.com/217909. | 494 // See http://crbug.com/217909. |
| 501 // Also fails on windows: crbug.com/678300. | |
| 502 #define MAYBE_SpellCheckText DISABLED_SpellCheckText | 495 #define MAYBE_SpellCheckText DISABLED_SpellCheckText |
| 503 #else | 496 #else |
| 504 #define MAYBE_SpellCheckText SpellCheckText | 497 #define MAYBE_SpellCheckText SpellCheckText |
| 505 #endif // THREAD_SANITIZER | 498 #endif // THREAD_SANITIZER |
| 506 TEST_F(SpellCheckTest, MAYBE_SpellCheckText) { | 499 TEST_F(SpellCheckTest, MAYBE_SpellCheckText) { |
| 507 static const struct { | 500 static const struct { |
| 508 const char* language; | 501 const char* language; |
| 509 const wchar_t* input; | 502 const wchar_t* input; |
| 510 } kTestCases[] = { | 503 } kTestCases[] = { |
| 511 { | 504 { |
| (...skipping 1058 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1570 // to be updated accordingly. | 1563 // to be updated accordingly. |
| 1571 ASSERT_EQ(5, spellcheck::kMaxSuggestions); | 1564 ASSERT_EQ(5, spellcheck::kMaxSuggestions); |
| 1572 FillSuggestions(suggestions_list, &suggestion_results); | 1565 FillSuggestions(suggestions_list, &suggestion_results); |
| 1573 ASSERT_EQ(5U, suggestion_results.size()); | 1566 ASSERT_EQ(5U, suggestion_results.size()); |
| 1574 EXPECT_EQ(base::ASCIIToUTF16("0foo"), suggestion_results[0]); | 1567 EXPECT_EQ(base::ASCIIToUTF16("0foo"), suggestion_results[0]); |
| 1575 EXPECT_EQ(base::ASCIIToUTF16("1foo"), suggestion_results[1]); | 1568 EXPECT_EQ(base::ASCIIToUTF16("1foo"), suggestion_results[1]); |
| 1576 EXPECT_EQ(base::ASCIIToUTF16("2foo"), suggestion_results[2]); | 1569 EXPECT_EQ(base::ASCIIToUTF16("2foo"), suggestion_results[2]); |
| 1577 EXPECT_EQ(base::ASCIIToUTF16("0bar"), suggestion_results[3]); | 1570 EXPECT_EQ(base::ASCIIToUTF16("0bar"), suggestion_results[3]); |
| 1578 EXPECT_EQ(base::ASCIIToUTF16("1bar"), suggestion_results[4]); | 1571 EXPECT_EQ(base::ASCIIToUTF16("1bar"), suggestion_results[4]); |
| 1579 } | 1572 } |
| OLD | NEW |