Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Side by Side Diff: components/spellcheck/renderer/spellcheck_provider_unittest.cc

Issue 2494123002: Spellcheck : Fix caching in cases where text is deleted. (Closed)
Patch Set: rebase + fix year Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/spellcheck/renderer/spellcheck_provider_test.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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
OLDNEW
« no previous file with comments | « components/spellcheck/renderer/spellcheck_provider_test.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698