| 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/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "components/spellcheck/common/spellcheck.mojom.h" | 10 #include "components/spellcheck/common/spellcheck.mojom.h" |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 ++spelling_service_call_count_; | 85 ++spelling_service_call_count_; |
| 86 blink::WebTextCheckingCompletion* completion = | 86 blink::WebTextCheckingCompletion* completion = |
| 87 text_check_completions_.Lookup(last_identifier_); | 87 text_check_completions_.Lookup(last_identifier_); |
| 88 if (!completion) { | 88 if (!completion) { |
| 89 ResetResult(); | 89 ResetResult(); |
| 90 return; | 90 return; |
| 91 } | 91 } |
| 92 text_.assign(text); | 92 text_.assign(text); |
| 93 text_check_completions_.Remove(last_identifier_); | 93 text_check_completions_.Remove(last_identifier_); |
| 94 std::vector<blink::WebTextCheckingResult> results; | 94 std::vector<blink::WebTextCheckingResult> results; |
| 95 results.push_back(blink::WebTextCheckingResult( | 95 results.push_back( |
| 96 blink::kWebTextDecorationTypeSpelling, 0, 5, blink::WebString("hello"))); | 96 blink::WebTextCheckingResult(blink::kWebTextDecorationTypeSpelling, 0, 5, |
| 97 std::vector<blink::WebString>({"hello"}))); |
| 97 completion->DidFinishCheckingText(results); | 98 completion->DidFinishCheckingText(results); |
| 98 last_request_ = text; | 99 last_request_ = text; |
| 99 last_results_ = results; | 100 last_results_ = results; |
| 100 #else | 101 #else |
| 101 NOTREACHED(); | 102 NOTREACHED(); |
| 102 #endif | 103 #endif |
| 103 } | 104 } |
| 104 | 105 |
| 105 void TestingSpellCheckProvider::ResetResult() { | 106 void TestingSpellCheckProvider::ResetResult() { |
| 106 text_.clear(); | 107 text_.clear(); |
| 107 } | 108 } |
| 108 | 109 |
| 109 void TestingSpellCheckProvider::SetLastResults( | 110 void TestingSpellCheckProvider::SetLastResults( |
| 110 const base::string16 last_request, | 111 const base::string16 last_request, |
| 111 blink::WebVector<blink::WebTextCheckingResult>& last_results) { | 112 blink::WebVector<blink::WebTextCheckingResult>& last_results) { |
| 112 last_request_ = last_request; | 113 last_request_ = last_request; |
| 113 last_results_ = last_results; | 114 last_results_ = last_results; |
| 114 } | 115 } |
| 115 | 116 |
| 116 bool TestingSpellCheckProvider::SatisfyRequestFromCache( | 117 bool TestingSpellCheckProvider::SatisfyRequestFromCache( |
| 117 const base::string16& text, | 118 const base::string16& text, |
| 118 blink::WebTextCheckingCompletion* completion) { | 119 blink::WebTextCheckingCompletion* completion) { |
| 119 return SpellCheckProvider::SatisfyRequestFromCache(text, completion); | 120 return SpellCheckProvider::SatisfyRequestFromCache(text, completion); |
| 120 } | 121 } |
| 121 | 122 |
| 122 SpellCheckProviderTest::SpellCheckProviderTest() {} | 123 SpellCheckProviderTest::SpellCheckProviderTest() {} |
| 123 SpellCheckProviderTest::~SpellCheckProviderTest() {} | 124 SpellCheckProviderTest::~SpellCheckProviderTest() {} |
| OLD | NEW |