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

Side by Side Diff: components/test_runner/spell_check_client.cc

Issue 1839853002: Moving remaining mocks from WebTestProxyBase into TestRunner. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@splitting-web-view-test-client
Patch Set: Rebasing... Created 4 years, 8 months 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/test_runner/spell_check_client.h ('k') | components/test_runner/test_runner.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/test_runner/spell_check_client.h" 5 #include "components/test_runner/spell_check_client.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/logging.h"
9 #include "base/macros.h" 10 #include "base/macros.h"
10 #include "components/test_runner/mock_grammar_check.h" 11 #include "components/test_runner/mock_grammar_check.h"
12 #include "components/test_runner/test_runner.h"
11 #include "components/test_runner/web_test_delegate.h" 13 #include "components/test_runner/web_test_delegate.h"
12 #include "components/test_runner/web_test_proxy.h"
13 #include "third_party/WebKit/public/web/WebTextCheckingCompletion.h" 14 #include "third_party/WebKit/public/web/WebTextCheckingCompletion.h"
14 #include "third_party/WebKit/public/web/WebTextCheckingResult.h" 15 #include "third_party/WebKit/public/web/WebTextCheckingResult.h"
15 16
16 namespace test_runner { 17 namespace test_runner {
17 18
18 namespace { 19 namespace {
19 20
20 class HostMethodTask : public WebMethodTask<SpellCheckClient> { 21 class HostMethodTask : public WebMethodTask<SpellCheckClient> {
21 public: 22 public:
22 typedef void (SpellCheckClient::*CallbackMethodType)(); 23 typedef void (SpellCheckClient::*CallbackMethodType)();
23 HostMethodTask(SpellCheckClient* object, CallbackMethodType callback) 24 HostMethodTask(SpellCheckClient* object, CallbackMethodType callback)
24 : WebMethodTask<SpellCheckClient>(object), callback_(callback) {} 25 : WebMethodTask<SpellCheckClient>(object), callback_(callback) {}
25 26
26 ~HostMethodTask() override {} 27 ~HostMethodTask() override {}
27 28
28 void RunIfValid() override { (object_->*callback_)(); } 29 void RunIfValid() override { (object_->*callback_)(); }
29 30
30 private: 31 private:
31 CallbackMethodType callback_; 32 CallbackMethodType callback_;
32 33
33 DISALLOW_COPY_AND_ASSIGN(HostMethodTask); 34 DISALLOW_COPY_AND_ASSIGN(HostMethodTask);
34 }; 35 };
35 36
36 } // namespace 37 } // namespace
37 38
38 SpellCheckClient::SpellCheckClient(WebTestProxyBase* web_test_proxy) 39 SpellCheckClient::SpellCheckClient(TestRunner* test_runner)
39 : last_requested_text_checking_completion_(0), 40 : last_requested_text_checking_completion_(nullptr),
40 web_test_proxy_(web_test_proxy) { 41 test_runner_(test_runner) {
42 DCHECK(test_runner);
41 } 43 }
42 44
43 SpellCheckClient::~SpellCheckClient() { 45 SpellCheckClient::~SpellCheckClient() {
44 } 46 }
45 47
46 void SpellCheckClient::SetDelegate(WebTestDelegate* delegate) { 48 void SpellCheckClient::SetDelegate(WebTestDelegate* delegate) {
47 delegate_ = delegate; 49 delegate_ = delegate;
48 } 50 }
49 51
50 // blink::WebSpellCheckClient 52 // blink::WebSpellCheckClient
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 suggestions.isEmpty() ? blink::WebString() : suggestions[0])); 135 suggestions.isEmpty() ? blink::WebString() : suggestions[0]));
134 text = text.substr(misspelled_position + misspelled_length); 136 text = text.substr(misspelled_position + misspelled_length);
135 offset += misspelled_position + misspelled_length; 137 offset += misspelled_position + misspelled_length;
136 } 138 }
137 MockGrammarCheck::CheckGrammarOfString(last_requested_text_check_string_, 139 MockGrammarCheck::CheckGrammarOfString(last_requested_text_check_string_,
138 &results); 140 &results);
139 } 141 }
140 last_requested_text_checking_completion_->didFinishCheckingText(results); 142 last_requested_text_checking_completion_->didFinishCheckingText(results);
141 last_requested_text_checking_completion_ = 0; 143 last_requested_text_checking_completion_ = 0;
142 144
143 web_test_proxy_->PostSpellCheckEvent(blink::WebString("FinishLastTextCheck")); 145 if (test_runner_->shouldDumpSpellCheckCallbacks())
146 delegate_->PrintMessage("SpellCheckEvent: FinishLastTextCheck\n");
144 } 147 }
145 148
146 } // namespace test_runner 149 } // namespace test_runner
OLDNEW
« no previous file with comments | « components/test_runner/spell_check_client.h ('k') | components/test_runner/test_runner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698