| Index: content/browser/speech/google_one_shot_remote_engine_unittest.cc
|
| diff --git a/content/browser/speech/speech_recognition_request_unittest.cc b/content/browser/speech/google_one_shot_remote_engine_unittest.cc
|
| similarity index 85%
|
| rename from content/browser/speech/speech_recognition_request_unittest.cc
|
| rename to content/browser/speech/google_one_shot_remote_engine_unittest.cc
|
| index 822e2540b98bd85e88eb84a73e7bf3e528d51eec..7b94dfafce05bbdcde8a7a3532373c1044d4916a 100644
|
| --- a/content/browser/speech/speech_recognition_request_unittest.cc
|
| +++ b/content/browser/speech/google_one_shot_remote_engine_unittest.cc
|
| @@ -5,7 +5,7 @@
|
| #include "base/message_loop.h"
|
| #include "base/utf_string_conversions.h"
|
| #include "content/browser/speech/audio_buffer.h"
|
| -#include "content/browser/speech/speech_recognition_request.h"
|
| +#include "content/browser/speech/google_one_shot_remote_engine.h"
|
| #include "content/public/common/speech_recognition_result.h"
|
| #include "content/test/test_url_fetcher_factory.h"
|
| #include "net/url_request/url_request_context_getter.h"
|
| @@ -14,37 +14,44 @@
|
|
|
| namespace speech {
|
|
|
| -class SpeechRecognitionRequestTest : public SpeechRecognitionRequestDelegate,
|
| - public testing::Test {
|
| +class GoogleOneShotRemoteEngineTest
|
| + : public SpeechRecognitionEngineDelegate,
|
| + public testing::Test {
|
| public:
|
| - SpeechRecognitionRequestTest() { }
|
| + GoogleOneShotRemoteEngineTest() {}
|
|
|
| // Creates a speech recognition request and invokes it's URL fetcher delegate
|
| // with the given test data.
|
| void CreateAndTestRequest(bool success, const std::string& http_response);
|
|
|
| // SpeechRecognitionRequestDelegate methods.
|
| - virtual void SetRecognitionResult(
|
| + virtual void OnSpeechEngineResult(
|
| const content::SpeechRecognitionResult& result) OVERRIDE {
|
| result_ = result;
|
| }
|
|
|
| + virtual void OnSpeechEngineError(
|
| + const content::SpeechRecognitionError& error) OVERRIDE {
|
| + result_.error = error.code;
|
| + }
|
| +
|
| protected:
|
| MessageLoop message_loop_;
|
| TestURLFetcherFactory url_fetcher_factory_;
|
| content::SpeechRecognitionResult result_;
|
| };
|
|
|
| -void SpeechRecognitionRequestTest::CreateAndTestRequest(
|
| +void GoogleOneShotRemoteEngineTest::CreateAndTestRequest(
|
| bool success, const std::string& http_response) {
|
| - SpeechRecognitionRequest request(NULL, this);
|
| - request.Start(std::string(), std::string(), false, std::string(),
|
| - std::string(), std::string());
|
| + GoogleOneShotRemoteEngine client(NULL);
|
| unsigned char dummy_audio_buffer_data[2] = {'\0', '\0'};
|
| AudioChunk dummy_audio_chunk(&dummy_audio_buffer_data[0],
|
| sizeof(dummy_audio_buffer_data),
|
| 2 /* bytes per sample */);
|
| - request.UploadAudioChunk(dummy_audio_chunk, true);
|
| + client.set_delegate(this);
|
| + client.Initialize();
|
| + client.TakeAudioChunk(dummy_audio_chunk);
|
| + client.AudioChunksEnded();
|
| TestURLFetcher* fetcher = url_fetcher_factory_.GetFetcherByID(0);
|
| ASSERT_TRUE(fetcher);
|
|
|
| @@ -60,7 +67,7 @@ void SpeechRecognitionRequestTest::CreateAndTestRequest(
|
| // Parsed response will be available in result_.
|
| }
|
|
|
| -TEST_F(SpeechRecognitionRequestTest, BasicTest) {
|
| +TEST_F(GoogleOneShotRemoteEngineTest, BasicTest) {
|
| // Normal success case with one result.
|
| CreateAndTestRequest(true,
|
| "{\"status\":0,\"hypotheses\":"
|
|
|