diff options
author | jochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-20 13:27:38 +0000 |
---|---|---|
committer | jochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-20 13:27:38 +0000 |
commit | 3de922f39b244a05cf5ed58699256158048a1b89 (patch) | |
tree | 80f5fd65f420f54afa2daef7d217670812614bb6 /content/shell/renderer/test_runner/MockWebSpeechInputController.h | |
parent | a3e41cd4f1ed6879b25a3dcc8730db868df69fd4 (diff) | |
download | chromium_src-3de922f39b244a05cf5ed58699256158048a1b89.zip chromium_src-3de922f39b244a05cf5ed58699256158048a1b89.tar.gz chromium_src-3de922f39b244a05cf5ed58699256158048a1b89.tar.bz2 |
Import TestRunner library into chromium.
The reasons for the move are:
- it's actually a blink embedder, so it can't use blink/wtf types
- it can't use base either
- we want to replace CppBoundClass with gin::Wrappable, not possible in blink
In the first step, this is mostly a 1:1 copy (except for include paths).
Follow-up CLs will move the test plugin and layout tests helpers and
clean up the coding style
BUG=324658
R=abarth@chromium.org, maruel@chromium.org, torne@chromium.org, jam@chromium.org
TBR=torne@chromium.org
Review URL: https://codereview.chromium.org/110533009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@242095 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/shell/renderer/test_runner/MockWebSpeechInputController.h')
-rw-r--r-- | content/shell/renderer/test_runner/MockWebSpeechInputController.h | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/content/shell/renderer/test_runner/MockWebSpeechInputController.h b/content/shell/renderer/test_runner/MockWebSpeechInputController.h new file mode 100644 index 0000000..af493ce --- /dev/null +++ b/content/shell/renderer/test_runner/MockWebSpeechInputController.h @@ -0,0 +1,77 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef MockWebSpeechInputController_h +#define MockWebSpeechInputController_h + +#include <map> +#include <string> +#include <vector> + +#include "content/shell/renderer/test_runner/TestCommon.h" +#include "content/shell/renderer/test_runner/WebTask.h" +#include "third_party/WebKit/public/platform/WebNonCopyable.h" +#include "third_party/WebKit/public/platform/WebRect.h" +#include "third_party/WebKit/public/web/WebSpeechInputController.h" +#include "third_party/WebKit/public/web/WebSpeechInputResult.h" + +namespace blink { +class WebSecurityOrigin; +class WebSpeechInputListener; +class WebString; +} + +namespace WebTestRunner { + +class WebTestDelegate; + +class MockWebSpeechInputController : public blink::WebSpeechInputController, public blink::WebNonCopyable { +public: + explicit MockWebSpeechInputController(blink::WebSpeechInputListener*); + ~MockWebSpeechInputController(); + + void addMockRecognitionResult(const blink::WebString& result, double confidence, const blink::WebString& language); + void setDumpRect(bool); + void clearResults(); + void setDelegate(WebTestDelegate*); + + // WebSpeechInputController implementation: + virtual bool startRecognition(int requestId, const blink::WebRect& elementRect, const blink::WebString& language, const blink::WebString& grammar, const blink::WebSecurityOrigin&) OVERRIDE; + virtual void cancelRecognition(int requestId) OVERRIDE; + virtual void stopRecording(int requestId) OVERRIDE; + + WebTaskList* taskList() { return &m_taskList; } + +private: + void speechTaskFired(); + + class SpeechTask : public WebMethodTask<MockWebSpeechInputController> { + public: + SpeechTask(MockWebSpeechInputController*); + void stop(); + + private: + virtual void runIfValid() OVERRIDE; + }; + + blink::WebSpeechInputListener* m_listener; + + WebTaskList m_taskList; + SpeechTask* m_speechTask; + + bool m_recording; + int m_requestId; + blink::WebRect m_requestRect; + std::string m_language; + + std::map<std::string, std::vector<blink::WebSpeechInputResult> > m_recognitionResults; + std::vector<blink::WebSpeechInputResult> m_resultsForEmptyLanguage; + bool m_dumpRect; + + WebTestDelegate* m_delegate; +}; + +} + +#endif // MockWebSpeechInputController_h |