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

Side by Side Diff: content/shell/test_runner/mock_web_speech_recognizer.cc

Issue 2707183003: Move //components/test_runner back into //content/shell (Closed)
Patch Set: Trim DEPS Created 3 years, 10 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
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/mock_web_speech_recognizer.h" 5 #include "content/shell/test_runner/mock_web_speech_recognizer.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "components/test_runner/web_test_delegate.h" 13 #include "content/shell/test_runner/web_test_delegate.h"
14 #include "third_party/WebKit/public/web/WebSpeechRecognitionResult.h" 14 #include "third_party/WebKit/public/web/WebSpeechRecognitionResult.h"
15 #include "third_party/WebKit/public/web/WebSpeechRecognizerClient.h" 15 #include "third_party/WebKit/public/web/WebSpeechRecognizerClient.h"
16 16
17 namespace test_runner { 17 namespace test_runner {
18 18
19 namespace { 19 namespace {
20 20
21 // Task class for calling a client function that does not take any parameters. 21 // Task class for calling a client function that does not take any parameters.
22 typedef void (blink::WebSpeechRecognizerClient::*ClientFunctionPointer)( 22 typedef void (blink::WebSpeechRecognizerClient::*ClientFunctionPointer)(
23 const blink::WebSpeechRecognitionHandle&); 23 const blink::WebSpeechRecognitionHandle&);
(...skipping 29 matching lines...) Expand all
53 void run() override { 53 void run() override {
54 blink::WebVector<blink::WebString> transcripts(static_cast<size_t>(1)); 54 blink::WebVector<blink::WebString> transcripts(static_cast<size_t>(1));
55 blink::WebVector<float> confidences(static_cast<size_t>(1)); 55 blink::WebVector<float> confidences(static_cast<size_t>(1));
56 transcripts[0] = transcript_; 56 transcripts[0] = transcript_;
57 confidences[0] = confidence_; 57 confidences[0] = confidence_;
58 blink::WebVector<blink::WebSpeechRecognitionResult> final_results( 58 blink::WebVector<blink::WebSpeechRecognitionResult> final_results(
59 static_cast<size_t>(1)); 59 static_cast<size_t>(1));
60 blink::WebVector<blink::WebSpeechRecognitionResult> interim_results; 60 blink::WebVector<blink::WebSpeechRecognitionResult> interim_results;
61 final_results[0].assign(transcripts, confidences, true); 61 final_results[0].assign(transcripts, confidences, true);
62 62
63 recognizer_->Client()->didReceiveResults( 63 recognizer_->Client()->didReceiveResults(recognizer_->Handle(),
64 recognizer_->Handle(), final_results, interim_results); 64 final_results, interim_results);
65 } 65 }
66 66
67 private: 67 private:
68 blink::WebString transcript_; 68 blink::WebString transcript_;
69 float confidence_; 69 float confidence_;
70 70
71 DISALLOW_COPY_AND_ASSIGN(ResultTask); 71 DISALLOW_COPY_AND_ASSIGN(ResultTask);
72 }; 72 };
73 73
74 // Task for delivering a nomatch event. 74 // Task for delivering a nomatch event.
(...skipping 17 matching lines...) Expand all
92 class ErrorTask : public MockWebSpeechRecognizer::Task { 92 class ErrorTask : public MockWebSpeechRecognizer::Task {
93 public: 93 public:
94 ErrorTask(MockWebSpeechRecognizer* mock, 94 ErrorTask(MockWebSpeechRecognizer* mock,
95 blink::WebSpeechRecognizerClient::ErrorCode code, 95 blink::WebSpeechRecognizerClient::ErrorCode code,
96 const blink::WebString& message) 96 const blink::WebString& message)
97 : MockWebSpeechRecognizer::Task(mock), code_(code), message_(message) {} 97 : MockWebSpeechRecognizer::Task(mock), code_(code), message_(message) {}
98 98
99 ~ErrorTask() override {} 99 ~ErrorTask() override {}
100 100
101 void run() override { 101 void run() override {
102 recognizer_->Client()->didReceiveError( 102 recognizer_->Client()->didReceiveError(recognizer_->Handle(), message_,
103 recognizer_->Handle(), message_, code_); 103 code_);
104 } 104 }
105 105
106 private: 106 private:
107 blink::WebSpeechRecognizerClient::ErrorCode code_; 107 blink::WebSpeechRecognizerClient::ErrorCode code_;
108 blink::WebString message_; 108 blink::WebString message_;
109 109
110 DISALLOW_COPY_AND_ASSIGN(ErrorTask); 110 DISALLOW_COPY_AND_ASSIGN(ErrorTask);
111 }; 111 };
112 112
113 // Task for tidying up after recognition task has ended. 113 // Task for tidying up after recognition task has ended.
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 320
321 bool MockWebSpeechRecognizer::HasPendingNewContextTasks() const { 321 bool MockWebSpeechRecognizer::HasPendingNewContextTasks() const {
322 for (const auto& task : task_queue_) { 322 for (const auto& task : task_queue_) {
323 if (task->isNewContextTask()) 323 if (task->isNewContextTask())
324 return true; 324 return true;
325 } 325 }
326 return false; 326 return false;
327 } 327 }
328 328
329 } // namespace test_runner 329 } // namespace test_runner
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698