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 "chrome/renderer/spellchecker/spellcheck_provider_test.h" | 5 #include "chrome/renderer/spellchecker/spellcheck_provider_test.h" |
6 | 6 |
7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
8 #include "chrome/common/spellcheck_marker.h" | 8 #include "chrome/common/spellcheck_marker.h" |
9 #include "chrome/common/spellcheck_messages.h" | 9 #include "chrome/common/spellcheck_messages.h" |
10 #include "chrome/renderer/spellchecker/spellcheck.h" | 10 #include "chrome/renderer/spellchecker/spellcheck.h" |
11 #include "ipc/ipc_message_macros.h" | 11 #include "ipc/ipc_message_macros.h" |
12 | 12 |
13 class MockSpellcheck: public SpellCheck { | 13 class MockSpellcheck: public SpellCheck { |
14 }; | 14 }; |
15 | 15 |
16 FakeTextCheckingCompletion::FakeTextCheckingCompletion() | 16 FakeTextCheckingCompletion::FakeTextCheckingCompletion() |
17 : completion_count_(0), | 17 : completion_count_(0), |
18 cancellation_count_(0) { | 18 cancellation_count_(0) { |
19 } | 19 } |
20 | 20 |
21 FakeTextCheckingCompletion::~FakeTextCheckingCompletion() {} | 21 FakeTextCheckingCompletion::~FakeTextCheckingCompletion() {} |
22 | 22 |
23 void FakeTextCheckingCompletion::didFinishCheckingText( | 23 void FakeTextCheckingCompletion::didFinishCheckingText( |
24 const WebKit::WebVector<WebKit::WebTextCheckingResult>& results) { | 24 const blink::WebVector<blink::WebTextCheckingResult>& results) { |
25 ++completion_count_; | 25 ++completion_count_; |
26 } | 26 } |
27 | 27 |
28 void FakeTextCheckingCompletion::didCancelCheckingText() { | 28 void FakeTextCheckingCompletion::didCancelCheckingText() { |
29 ++completion_count_; | 29 ++completion_count_; |
30 ++cancellation_count_; | 30 ++cancellation_count_; |
31 } | 31 } |
32 | 32 |
33 TestingSpellCheckProvider::TestingSpellCheckProvider() | 33 TestingSpellCheckProvider::TestingSpellCheckProvider() |
34 : SpellCheckProvider(NULL, new MockSpellcheck), | 34 : SpellCheckProvider(NULL, new MockSpellcheck), |
(...skipping 25 matching lines...) Expand all Loading... |
60 } | 60 } |
61 | 61 |
62 void TestingSpellCheckProvider::OnCallSpellingService(int route_id, | 62 void TestingSpellCheckProvider::OnCallSpellingService(int route_id, |
63 int identifier, | 63 int identifier, |
64 const string16& text, | 64 const string16& text, |
65 const std::vector<SpellCheckMarker>& markers) { | 65 const std::vector<SpellCheckMarker>& markers) { |
66 #if defined (OS_MACOSX) | 66 #if defined (OS_MACOSX) |
67 NOTREACHED(); | 67 NOTREACHED(); |
68 #else | 68 #else |
69 ++spelling_service_call_count_; | 69 ++spelling_service_call_count_; |
70 WebKit::WebTextCheckingCompletion* completion = | 70 blink::WebTextCheckingCompletion* completion = |
71 text_check_completions_.Lookup(identifier); | 71 text_check_completions_.Lookup(identifier); |
72 if (!completion) { | 72 if (!completion) { |
73 ResetResult(); | 73 ResetResult(); |
74 return; | 74 return; |
75 } | 75 } |
76 text_.assign(text); | 76 text_.assign(text); |
77 text_check_completions_.Remove(identifier); | 77 text_check_completions_.Remove(identifier); |
78 std::vector<WebKit::WebTextCheckingResult> results; | 78 std::vector<blink::WebTextCheckingResult> results; |
79 results.push_back(WebKit::WebTextCheckingResult( | 79 results.push_back(blink::WebTextCheckingResult( |
80 WebKit::WebTextDecorationTypeSpelling, | 80 blink::WebTextDecorationTypeSpelling, |
81 0, 5, WebKit::WebString("hello"))); | 81 0, 5, blink::WebString("hello"))); |
82 completion->didFinishCheckingText(results); | 82 completion->didFinishCheckingText(results); |
83 last_request_ = text; | 83 last_request_ = text; |
84 last_results_ = results; | 84 last_results_ = results; |
85 #endif | 85 #endif |
86 } | 86 } |
87 | 87 |
88 void TestingSpellCheckProvider::ResetResult() { | 88 void TestingSpellCheckProvider::ResetResult() { |
89 text_.clear(); | 89 text_.clear(); |
90 } | 90 } |
91 | 91 |
92 SpellCheckProviderTest::SpellCheckProviderTest() {} | 92 SpellCheckProviderTest::SpellCheckProviderTest() {} |
93 SpellCheckProviderTest::~SpellCheckProviderTest() {} | 93 SpellCheckProviderTest::~SpellCheckProviderTest() {} |
94 | 94 |
95 | 95 |
OLD | NEW |