| 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 /* |
| 6 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 7 * |
| 8 * Redistribution and use in source and binary forms, with or without |
| 9 * modification, are permitted provided that the following conditions |
| 10 * are met: |
| 11 * |
| 12 * 1. Redistributions of source code must retain the above copyright |
| 13 * notice, this list of conditions and the following disclaimer. |
| 14 * 2. Redistributions in binary form must reproduce the above copyright |
| 15 * notice, this list of conditions and the following disclaimer in the |
| 16 * documentation and/or other materials provided with the distribution. |
| 17 * |
| 18 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY |
| 19 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 20 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 21 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY |
| 22 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 */ |
| 29 |
| 30 #ifndef MockWebSpeechInputController_h |
| 31 #define MockWebSpeechInputController_h |
| 32 |
| 33 #include <map> |
| 34 #include <string> |
| 35 #include <vector> |
| 36 |
| 37 #include "content/public/test/layout_tests/WebTask.h" |
| 38 #include "content/test/layout_tests/runner/TestCommon.h" |
| 39 #include "third_party/WebKit/public/platform/WebNonCopyable.h" |
| 40 #include "third_party/WebKit/public/platform/WebRect.h" |
| 41 #include "third_party/WebKit/public/web/WebSpeechInputController.h" |
| 42 #include "third_party/WebKit/public/web/WebSpeechInputResult.h" |
| 43 |
| 44 namespace blink { |
| 45 class WebSecurityOrigin; |
| 46 class WebSpeechInputListener; |
| 47 class WebString; |
| 48 } |
| 49 |
| 50 namespace WebTestRunner { |
| 51 |
| 52 class WebTestDelegate; |
| 53 |
| 54 class MockWebSpeechInputController : public blink::WebSpeechInputController, pub
lic blink::WebNonCopyable { |
| 55 public: |
| 56 explicit MockWebSpeechInputController(blink::WebSpeechInputListener*); |
| 57 ~MockWebSpeechInputController(); |
| 58 |
| 59 void addMockRecognitionResult(const blink::WebString& result, double confide
nce, const blink::WebString& language); |
| 60 void setDumpRect(bool); |
| 61 void clearResults(); |
| 62 void setDelegate(WebTestDelegate*); |
| 63 |
| 64 // WebSpeechInputController implementation: |
| 65 virtual bool startRecognition(int requestId, const blink::WebRect& elementRe
ct, const blink::WebString& language, const blink::WebString& grammar, const bli
nk::WebSecurityOrigin&) OVERRIDE; |
| 66 virtual void cancelRecognition(int requestId) OVERRIDE; |
| 67 virtual void stopRecording(int requestId) OVERRIDE; |
| 68 |
| 69 WebTaskList* taskList() { return &m_taskList; } |
| 70 |
| 71 private: |
| 72 void speechTaskFired(); |
| 73 |
| 74 class SpeechTask : public WebMethodTask<MockWebSpeechInputController> { |
| 75 public: |
| 76 SpeechTask(MockWebSpeechInputController*); |
| 77 void stop(); |
| 78 |
| 79 private: |
| 80 virtual void runIfValid() OVERRIDE; |
| 81 }; |
| 82 |
| 83 blink::WebSpeechInputListener* m_listener; |
| 84 |
| 85 WebTaskList m_taskList; |
| 86 SpeechTask* m_speechTask; |
| 87 |
| 88 bool m_recording; |
| 89 int m_requestId; |
| 90 blink::WebRect m_requestRect; |
| 91 std::string m_language; |
| 92 |
| 93 std::map<std::string, std::vector<blink::WebSpeechInputResult> > m_recogniti
onResults; |
| 94 std::vector<blink::WebSpeechInputResult> m_resultsForEmptyLanguage; |
| 95 bool m_dumpRect; |
| 96 |
| 97 WebTestDelegate* m_delegate; |
| 98 }; |
| 99 |
| 100 } |
| 101 |
| 102 #endif // MockWebSpeechInputController_h |
| OLD | NEW |