Chromium Code Reviews| Index: content/browser/speech/google_ssfe_remote_engine_unittest.cc |
| diff --git a/content/browser/speech/speech_recognition_request_unittest.cc b/content/browser/speech/google_ssfe_remote_engine_unittest.cc |
| similarity index 85% |
| rename from content/browser/speech/speech_recognition_request_unittest.cc |
| rename to content/browser/speech/google_ssfe_remote_engine_unittest.cc |
| index 822e2540b98bd85e88eb84a73e7bf3e528d51eec..938d94b33b3890aa3856fd930a1b265739d72f97 100644 |
| --- a/content/browser/speech/speech_recognition_request_unittest.cc |
| +++ b/content/browser/speech/google_ssfe_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_ssfe_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 GoogleSSFERemoteEngineTest |
| + : public SpeechRecognitionEngineDelegate, |
| + public testing::Test { |
| public: |
| - SpeechRecognitionRequestTest() { } |
| + GoogleSSFERemoteEngineTest() { } |
|
hans
2012/03/16 11:12:56
not really your code, but while you're here, there
Primiano Tucci (use gerrit)
2012/03/16 15:03:42
Done.
|
| // 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 GoogleSSFERemoteEngineTest::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()); |
| + GoogleSSFERemoteEngine 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.SpeechRecognitionBegins(); |
| + client.PushSpeechAudio(dummy_audio_chunk); |
| + client.SpeechAudioStreamComplete(); |
| 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(GoogleSSFERemoteEngineTest, BasicTest) { |
| // Normal success case with one result. |
| CreateAndTestRequest(true, |
| "{\"status\":0,\"hypotheses\":" |