| 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_messages.h" | 8 #include "chrome/common/spellcheck_messages.h" |
| 9 #include "chrome/renderer/spellchecker/spellcheck.h" |
| 9 #include "ipc/ipc_message_macros.h" | 10 #include "ipc/ipc_message_macros.h" |
| 10 | 11 |
| 12 class MockSpellcheck: public SpellCheck { |
| 13 }; |
| 14 |
| 11 FakeTextCheckingCompletion::FakeTextCheckingCompletion() | 15 FakeTextCheckingCompletion::FakeTextCheckingCompletion() |
| 12 : completion_count_(0), | 16 : completion_count_(0), |
| 13 cancellation_count_(0) { | 17 cancellation_count_(0) { |
| 14 } | 18 } |
| 15 | 19 |
| 16 FakeTextCheckingCompletion::~FakeTextCheckingCompletion() {} | 20 FakeTextCheckingCompletion::~FakeTextCheckingCompletion() {} |
| 17 | 21 |
| 18 void FakeTextCheckingCompletion::didFinishCheckingText( | 22 void FakeTextCheckingCompletion::didFinishCheckingText( |
| 19 const WebKit::WebVector<WebKit::WebTextCheckingResult>& results) { | 23 const WebKit::WebVector<WebKit::WebTextCheckingResult>& results) { |
| 20 ++completion_count_; | 24 ++completion_count_; |
| 21 last_results_ = results; | 25 last_results_ = results; |
| 22 } | 26 } |
| 23 | 27 |
| 24 void FakeTextCheckingCompletion::didCancelCheckingText() { | 28 void FakeTextCheckingCompletion::didCancelCheckingText() { |
| 25 ++completion_count_; | 29 ++completion_count_; |
| 26 ++cancellation_count_; | 30 ++cancellation_count_; |
| 27 } | 31 } |
| 28 | 32 |
| 29 TestingSpellCheckProvider::TestingSpellCheckProvider() | 33 TestingSpellCheckProvider::TestingSpellCheckProvider() |
| 30 : SpellCheckProvider(NULL, NULL), | 34 : SpellCheckProvider(NULL, new MockSpellcheck), |
| 31 offset_(-1) { | 35 offset_(-1) { |
| 32 } | 36 } |
| 33 | 37 |
| 34 TestingSpellCheckProvider::~TestingSpellCheckProvider() { | 38 TestingSpellCheckProvider::~TestingSpellCheckProvider() { |
| 35 STLDeleteContainerPointers(messages_.begin(), messages_.end()); | 39 STLDeleteContainerPointers(messages_.begin(), messages_.end()); |
| 40 delete spellcheck_; |
| 36 } | 41 } |
| 37 | 42 |
| 38 bool TestingSpellCheckProvider::Send(IPC::Message* message) { | 43 bool TestingSpellCheckProvider::Send(IPC::Message* message) { |
| 39 // Call our mock message handlers. | 44 // Call our mock message handlers. |
| 40 bool handled = true; | 45 bool handled = true; |
| 41 IPC_BEGIN_MESSAGE_MAP(TestingSpellCheckProvider, *message) | 46 IPC_BEGIN_MESSAGE_MAP(TestingSpellCheckProvider, *message) |
| 42 #if !defined(OS_MACOSX) | 47 #if !defined(OS_MACOSX) |
| 43 IPC_MESSAGE_HANDLER(SpellCheckHostMsg_CallSpellingService, | 48 IPC_MESSAGE_HANDLER(SpellCheckHostMsg_CallSpellingService, |
| 44 OnCallSpellingService) | 49 OnCallSpellingService) |
| 45 #endif | 50 #endif |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 | 84 |
| 80 void TestingSpellCheckProvider::ResetResult() { | 85 void TestingSpellCheckProvider::ResetResult() { |
| 81 offset_ = -1; | 86 offset_ = -1; |
| 82 text_.clear(); | 87 text_.clear(); |
| 83 } | 88 } |
| 84 | 89 |
| 85 SpellCheckProviderTest::SpellCheckProviderTest() {} | 90 SpellCheckProviderTest::SpellCheckProviderTest() {} |
| 86 SpellCheckProviderTest::~SpellCheckProviderTest() {} | 91 SpellCheckProviderTest::~SpellCheckProviderTest() {} |
| 87 | 92 |
| 88 | 93 |
| OLD | NEW |