| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "base/strings/utf_string_conversions.h" |
| 6 #include "components/spellcheck/renderer/spellcheck_provider_test.h" |
| 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 #include "third_party/WebKit/public/platform/WebString.h" |
| 9 #include "third_party/WebKit/public/platform/WebVector.h" |
| 10 #include "third_party/WebKit/public/web/WebTextCheckingCompletion.h" |
| 11 #include "third_party/WebKit/public/web/WebTextCheckingResult.h" |
| 12 |
| 13 namespace { |
| 14 |
| 15 class SpellCheckProviderCacheTest : public SpellCheckProviderTest {}; |
| 16 |
| 17 TEST_F(SpellCheckProviderCacheTest, SubstringWithoutMisspellings) { |
| 18 FakeTextCheckingCompletion completion; |
| 19 |
| 20 blink::WebVector<blink::WebTextCheckingResult> last_results; |
| 21 provider_.SetLastResults(base::ASCIIToUTF16("This is a test"), last_results); |
| 22 EXPECT_TRUE(provider_.SatisfyRequestFromCache(base::ASCIIToUTF16("This is a"), |
| 23 &completion)); |
| 24 EXPECT_EQ(completion.completion_count_, 1U); |
| 25 } |
| 26 |
| 27 TEST_F(SpellCheckProviderCacheTest, SubstringWithMisspellings) { |
| 28 FakeTextCheckingCompletion completion; |
| 29 |
| 30 blink::WebVector<blink::WebTextCheckingResult> last_results; |
| 31 std::vector<blink::WebTextCheckingResult> results; |
| 32 results.push_back(blink::WebTextCheckingResult( |
| 33 blink::WebTextDecorationTypeSpelling, 5, 3, blink::WebString("isq"))); |
| 34 last_results.assign(results); |
| 35 provider_.SetLastResults(base::ASCIIToUTF16("This isq a test"), last_results); |
| 36 EXPECT_TRUE(provider_.SatisfyRequestFromCache( |
| 37 base::ASCIIToUTF16("This isq a"), &completion)); |
| 38 EXPECT_EQ(completion.completion_count_, 1U); |
| 39 } |
| 40 |
| 41 TEST_F(SpellCheckProviderCacheTest, ShorterTextNotSubstring) { |
| 42 FakeTextCheckingCompletion completion; |
| 43 |
| 44 blink::WebVector<blink::WebTextCheckingResult> last_results; |
| 45 provider_.SetLastResults(base::ASCIIToUTF16("This is a test"), last_results); |
| 46 EXPECT_FALSE(provider_.SatisfyRequestFromCache( |
| 47 base::ASCIIToUTF16("That is a"), &completion)); |
| 48 EXPECT_EQ(completion.completion_count_, 0U); |
| 49 } |
| 50 |
| 51 } // namespace |
| OLD | NEW |