OLD | NEW |
| (Empty) |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CONTENT_SHELL_RENDERER_TEST_RUNNER_MOCKWEBSPEECHINPUTCONTROLLER_H_ | |
6 #define CONTENT_SHELL_RENDERER_TEST_RUNNER_MOCKWEBSPEECHINPUTCONTROLLER_H_ | |
7 | |
8 #include <map> | |
9 #include <string> | |
10 #include <vector> | |
11 | |
12 #include "base/basictypes.h" | |
13 #include "content/shell/renderer/test_runner/TestCommon.h" | |
14 #include "content/shell/renderer/test_runner/WebTask.h" | |
15 #include "third_party/WebKit/public/platform/WebRect.h" | |
16 #include "third_party/WebKit/public/web/WebSpeechInputController.h" | |
17 #include "third_party/WebKit/public/web/WebSpeechInputResult.h" | |
18 | |
19 namespace blink { | |
20 class WebSecurityOrigin; | |
21 class WebSpeechInputListener; | |
22 class WebString; | |
23 } | |
24 | |
25 namespace WebTestRunner { | |
26 | |
27 class WebTestDelegate; | |
28 | |
29 // TODO(hans): Remove this once we've stopped running Blink tests that depend | |
30 // on it (crbug.com/223198). | |
31 class MockWebSpeechInputController : public blink::WebSpeechInputController { | |
32 public: | |
33 explicit MockWebSpeechInputController(blink::WebSpeechInputListener*); | |
34 virtual ~MockWebSpeechInputController(); | |
35 | |
36 void addMockRecognitionResult(const blink::WebString& result, double confide
nce, const blink::WebString& language); | |
37 void setDumpRect(bool); | |
38 void clearResults(); | |
39 void setDelegate(WebTestDelegate*); | |
40 | |
41 // WebSpeechInputController implementation: | |
42 virtual bool startRecognition(int requestId, const blink::WebRect& elementRe
ct, const blink::WebString& language, const blink::WebString& grammar, const bli
nk::WebSecurityOrigin&) OVERRIDE; | |
43 virtual void cancelRecognition(int requestId) OVERRIDE; | |
44 virtual void stopRecording(int requestId) OVERRIDE; | |
45 | |
46 WebTaskList* taskList() { return &m_taskList; } | |
47 | |
48 private: | |
49 void speechTaskFired(); | |
50 | |
51 class SpeechTask : public WebMethodTask<MockWebSpeechInputController> { | |
52 public: | |
53 SpeechTask(MockWebSpeechInputController*); | |
54 void stop(); | |
55 | |
56 private: | |
57 virtual void runIfValid() OVERRIDE; | |
58 }; | |
59 | |
60 blink::WebSpeechInputListener* m_listener; | |
61 | |
62 WebTaskList m_taskList; | |
63 SpeechTask* m_speechTask; | |
64 | |
65 bool m_recording; | |
66 int m_requestId; | |
67 blink::WebRect m_requestRect; | |
68 std::string m_language; | |
69 | |
70 std::map<std::string, std::vector<blink::WebSpeechInputResult> > m_recogniti
onResults; | |
71 std::vector<blink::WebSpeechInputResult> m_resultsForEmptyLanguage; | |
72 bool m_dumpRect; | |
73 | |
74 WebTestDelegate* m_delegate; | |
75 | |
76 DISALLOW_COPY_AND_ASSIGN(MockWebSpeechInputController); | |
77 }; | |
78 | |
79 } | |
80 | |
81 #endif // CONTENT_SHELL_RENDERER_TEST_RUNNER_MOCKWEBSPEECHINPUTCONTROLLER_H_ | |
OLD | NEW |