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_provider_test.h" | 5 #include "components/spellcheck/renderer/spellcheck_provider_test.h" |
6 | 6 |
7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
9 #include "components/spellcheck/common/spellcheck_messages.h" | 9 #include "components/spellcheck/common/spellcheck_messages.h" |
10 #include "components/spellcheck/renderer/spellcheck.h" | 10 #include "components/spellcheck/renderer/spellcheck.h" |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 ++spelling_service_call_count_; | 76 ++spelling_service_call_count_; |
77 blink::WebTextCheckingCompletion* completion = | 77 blink::WebTextCheckingCompletion* completion = |
78 text_check_completions_.Lookup(identifier); | 78 text_check_completions_.Lookup(identifier); |
79 if (!completion) { | 79 if (!completion) { |
80 ResetResult(); | 80 ResetResult(); |
81 return; | 81 return; |
82 } | 82 } |
83 text_.assign(text); | 83 text_.assign(text); |
84 text_check_completions_.Remove(identifier); | 84 text_check_completions_.Remove(identifier); |
85 std::vector<blink::WebTextCheckingResult> results; | 85 std::vector<blink::WebTextCheckingResult> results; |
86 results.push_back( | 86 results.push_back(blink::WebTextCheckingResult( |
87 blink::WebTextCheckingResult(blink::kWebTextDecorationTypeSpelling, 0, 5, | 87 blink::kWebTextDecorationTypeSpelling, 0, 5, blink::WebString("hello"))); |
88 std::vector<blink::WebString>({"hello"}))); | |
89 completion->DidFinishCheckingText(results); | 88 completion->DidFinishCheckingText(results); |
90 last_request_ = text; | 89 last_request_ = text; |
91 last_results_ = results; | 90 last_results_ = results; |
92 #endif | 91 #endif |
93 } | 92 } |
94 | 93 |
95 void TestingSpellCheckProvider::ResetResult() { | 94 void TestingSpellCheckProvider::ResetResult() { |
96 text_.clear(); | 95 text_.clear(); |
97 } | 96 } |
98 | 97 |
99 void TestingSpellCheckProvider::SetLastResults( | 98 void TestingSpellCheckProvider::SetLastResults( |
100 const base::string16 last_request, | 99 const base::string16 last_request, |
101 blink::WebVector<blink::WebTextCheckingResult>& last_results) { | 100 blink::WebVector<blink::WebTextCheckingResult>& last_results) { |
102 last_request_ = last_request; | 101 last_request_ = last_request; |
103 last_results_ = last_results; | 102 last_results_ = last_results; |
104 } | 103 } |
105 | 104 |
106 bool TestingSpellCheckProvider::SatisfyRequestFromCache( | 105 bool TestingSpellCheckProvider::SatisfyRequestFromCache( |
107 const base::string16& text, | 106 const base::string16& text, |
108 blink::WebTextCheckingCompletion* completion) { | 107 blink::WebTextCheckingCompletion* completion) { |
109 return SpellCheckProvider::SatisfyRequestFromCache(text, completion); | 108 return SpellCheckProvider::SatisfyRequestFromCache(text, completion); |
110 } | 109 } |
111 | 110 |
112 SpellCheckProviderTest::SpellCheckProviderTest() {} | 111 SpellCheckProviderTest::SpellCheckProviderTest() {} |
113 SpellCheckProviderTest::~SpellCheckProviderTest() {} | 112 SpellCheckProviderTest::~SpellCheckProviderTest() {} |
OLD | NEW |