OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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/strings/utf_string_conversions.h" | 5 #include "base/strings/utf_string_conversions.h" |
6 #include "components/spellcheck/renderer/spellcheck_provider_test.h" | 6 #include "components/spellcheck/renderer/spellcheck_provider_test.h" |
7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 #include "third_party/WebKit/public/platform/WebString.h" | 8 #include "third_party/WebKit/public/platform/WebString.h" |
9 #include "third_party/WebKit/public/platform/WebVector.h" | 9 #include "third_party/WebKit/public/platform/WebVector.h" |
10 #include "third_party/WebKit/public/web/WebTextCheckingCompletion.h" | 10 #include "third_party/WebKit/public/web/WebTextCheckingCompletion.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 EXPECT_TRUE(provider_.SatisfyRequestFromCache(base::ASCIIToUTF16("This is a"), | 22 EXPECT_TRUE(provider_.SatisfyRequestFromCache(base::ASCIIToUTF16("This is a"), |
23 &completion)); | 23 &completion)); |
24 EXPECT_EQ(completion.completion_count_, 1U); | 24 EXPECT_EQ(completion.completion_count_, 1U); |
25 } | 25 } |
26 | 26 |
27 TEST_F(SpellCheckProviderCacheTest, SubstringWithMisspellings) { | 27 TEST_F(SpellCheckProviderCacheTest, SubstringWithMisspellings) { |
28 FakeTextCheckingCompletion completion; | 28 FakeTextCheckingCompletion completion; |
29 | 29 |
30 blink::WebVector<blink::WebTextCheckingResult> last_results; | 30 blink::WebVector<blink::WebTextCheckingResult> last_results; |
31 std::vector<blink::WebTextCheckingResult> results; | 31 std::vector<blink::WebTextCheckingResult> results; |
32 results.push_back( | 32 results.push_back(blink::WebTextCheckingResult( |
33 blink::WebTextCheckingResult(blink::kWebTextDecorationTypeSpelling, 5, 3, | 33 blink::kWebTextDecorationTypeSpelling, 5, 3, blink::WebString("isq"))); |
34 std::vector<blink::WebString>({"isq"}))); | |
35 last_results.Assign(results); | 34 last_results.Assign(results); |
36 provider_.SetLastResults(base::ASCIIToUTF16("This isq a test"), last_results); | 35 provider_.SetLastResults(base::ASCIIToUTF16("This isq a test"), last_results); |
37 EXPECT_TRUE(provider_.SatisfyRequestFromCache( | 36 EXPECT_TRUE(provider_.SatisfyRequestFromCache( |
38 base::ASCIIToUTF16("This isq a"), &completion)); | 37 base::ASCIIToUTF16("This isq a"), &completion)); |
39 EXPECT_EQ(completion.completion_count_, 1U); | 38 EXPECT_EQ(completion.completion_count_, 1U); |
40 } | 39 } |
41 | 40 |
42 TEST_F(SpellCheckProviderCacheTest, ShorterTextNotSubstring) { | 41 TEST_F(SpellCheckProviderCacheTest, ShorterTextNotSubstring) { |
43 FakeTextCheckingCompletion completion; | 42 FakeTextCheckingCompletion completion; |
44 | 43 |
45 blink::WebVector<blink::WebTextCheckingResult> last_results; | 44 blink::WebVector<blink::WebTextCheckingResult> last_results; |
46 provider_.SetLastResults(base::ASCIIToUTF16("This is a test"), last_results); | 45 provider_.SetLastResults(base::ASCIIToUTF16("This is a test"), last_results); |
47 EXPECT_FALSE(provider_.SatisfyRequestFromCache( | 46 EXPECT_FALSE(provider_.SatisfyRequestFromCache( |
48 base::ASCIIToUTF16("That is a"), &completion)); | 47 base::ASCIIToUTF16("That is a"), &completion)); |
49 EXPECT_EQ(completion.completion_count_, 0U); | 48 EXPECT_EQ(completion.completion_count_, 0U); |
50 } | 49 } |
51 | 50 |
52 } // namespace | 51 } // namespace |
OLD | NEW |