OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 15 matching lines...) Expand all Loading... |
26 #ifndef MockWebSpeechRecognizer_h | 26 #ifndef MockWebSpeechRecognizer_h |
27 #define MockWebSpeechRecognizer_h | 27 #define MockWebSpeechRecognizer_h |
28 | 28 |
29 #include "TestCommon.h" | 29 #include "TestCommon.h" |
30 #include "public/platform/WebNonCopyable.h" | 30 #include "public/platform/WebNonCopyable.h" |
31 #include "public/testing/WebTask.h" | 31 #include "public/testing/WebTask.h" |
32 #include "public/web/WebSpeechRecognizer.h" | 32 #include "public/web/WebSpeechRecognizer.h" |
33 #include <deque> | 33 #include <deque> |
34 #include <vector> | 34 #include <vector> |
35 | 35 |
36 namespace WebKit { | 36 namespace blink { |
37 class WebSpeechRecognitionHandle; | 37 class WebSpeechRecognitionHandle; |
38 class WebSpeechRecognitionParams; | 38 class WebSpeechRecognitionParams; |
39 class WebSpeechRecognizerClient; | 39 class WebSpeechRecognizerClient; |
40 } | 40 } |
41 | 41 |
42 namespace WebTestRunner { | 42 namespace WebTestRunner { |
43 | 43 |
44 class WebTestDelegate; | 44 class WebTestDelegate; |
45 | 45 |
46 class MockWebSpeechRecognizer : public WebKit::WebSpeechRecognizer, public WebKi
t::WebNonCopyable { | 46 class MockWebSpeechRecognizer : public blink::WebSpeechRecognizer, public blink:
:WebNonCopyable { |
47 public: | 47 public: |
48 MockWebSpeechRecognizer(); | 48 MockWebSpeechRecognizer(); |
49 ~MockWebSpeechRecognizer(); | 49 ~MockWebSpeechRecognizer(); |
50 | 50 |
51 void setDelegate(WebTestDelegate*); | 51 void setDelegate(WebTestDelegate*); |
52 | 52 |
53 // WebSpeechRecognizer implementation: | 53 // WebSpeechRecognizer implementation: |
54 virtual void start(const WebKit::WebSpeechRecognitionHandle&, const WebKit::
WebSpeechRecognitionParams&, WebKit::WebSpeechRecognizerClient*) OVERRIDE; | 54 virtual void start(const blink::WebSpeechRecognitionHandle&, const blink::We
bSpeechRecognitionParams&, blink::WebSpeechRecognizerClient*) OVERRIDE; |
55 virtual void stop(const WebKit::WebSpeechRecognitionHandle&, WebKit::WebSpee
chRecognizerClient*) OVERRIDE; | 55 virtual void stop(const blink::WebSpeechRecognitionHandle&, blink::WebSpeech
RecognizerClient*) OVERRIDE; |
56 virtual void abort(const WebKit::WebSpeechRecognitionHandle&, WebKit::WebSpe
echRecognizerClient*) OVERRIDE; | 56 virtual void abort(const blink::WebSpeechRecognitionHandle&, blink::WebSpeec
hRecognizerClient*) OVERRIDE; |
57 | 57 |
58 // Methods accessed by layout tests: | 58 // Methods accessed by layout tests: |
59 void addMockResult(const WebKit::WebString& transcript, float confidence); | 59 void addMockResult(const blink::WebString& transcript, float confidence); |
60 void setError(const WebKit::WebString& error, const WebKit::WebString& messa
ge); | 60 void setError(const blink::WebString& error, const blink::WebString& message
); |
61 bool wasAborted() const { return m_wasAborted; } | 61 bool wasAborted() const { return m_wasAborted; } |
62 | 62 |
63 // Methods accessed from Task objects: | 63 // Methods accessed from Task objects: |
64 WebKit::WebSpeechRecognizerClient* client() { return m_client; } | 64 blink::WebSpeechRecognizerClient* client() { return m_client; } |
65 WebKit::WebSpeechRecognitionHandle& handle() { return m_handle; } | 65 blink::WebSpeechRecognitionHandle& handle() { return m_handle; } |
66 WebTaskList* taskList() { return &m_taskList; } | 66 WebTaskList* taskList() { return &m_taskList; } |
67 | 67 |
68 class Task { | 68 class Task { |
69 public: | 69 public: |
70 Task(MockWebSpeechRecognizer* recognizer) : m_recognizer(recognizer) { } | 70 Task(MockWebSpeechRecognizer* recognizer) : m_recognizer(recognizer) { } |
71 virtual ~Task() { } | 71 virtual ~Task() { } |
72 virtual void run() = 0; | 72 virtual void run() = 0; |
73 protected: | 73 protected: |
74 MockWebSpeechRecognizer* m_recognizer; | 74 MockWebSpeechRecognizer* m_recognizer; |
75 }; | 75 }; |
76 | 76 |
77 private: | 77 private: |
78 void startTaskQueue(); | 78 void startTaskQueue(); |
79 void clearTaskQueue(); | 79 void clearTaskQueue(); |
80 | 80 |
81 WebTaskList m_taskList; | 81 WebTaskList m_taskList; |
82 WebKit::WebSpeechRecognitionHandle m_handle; | 82 blink::WebSpeechRecognitionHandle m_handle; |
83 WebKit::WebSpeechRecognizerClient* m_client; | 83 blink::WebSpeechRecognizerClient* m_client; |
84 std::vector<WebKit::WebString> m_mockTranscripts; | 84 std::vector<blink::WebString> m_mockTranscripts; |
85 std::vector<float> m_mockConfidences; | 85 std::vector<float> m_mockConfidences; |
86 bool m_wasAborted; | 86 bool m_wasAborted; |
87 | 87 |
88 // Queue of tasks to be run. | 88 // Queue of tasks to be run. |
89 std::deque<Task*> m_taskQueue; | 89 std::deque<Task*> m_taskQueue; |
90 bool m_taskQueueRunning; | 90 bool m_taskQueueRunning; |
91 | 91 |
92 WebTestDelegate* m_delegate; | 92 WebTestDelegate* m_delegate; |
93 | 93 |
94 // Task for stepping the queue. | 94 // Task for stepping the queue. |
95 class StepTask : public WebMethodTask<MockWebSpeechRecognizer> { | 95 class StepTask : public WebMethodTask<MockWebSpeechRecognizer> { |
96 public: | 96 public: |
97 StepTask(MockWebSpeechRecognizer* object) : WebMethodTask<MockWebSpeechR
ecognizer>(object) { } | 97 StepTask(MockWebSpeechRecognizer* object) : WebMethodTask<MockWebSpeechR
ecognizer>(object) { } |
98 virtual void runIfValid() OVERRIDE; | 98 virtual void runIfValid() OVERRIDE; |
99 }; | 99 }; |
100 }; | 100 }; |
101 | 101 |
102 } | 102 } |
103 | 103 |
104 #endif // MockWebSpeechRecognizer_h | 104 #endif // MockWebSpeechRecognizer_h |
OLD | NEW |