Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/message_loop.h" | 5 #include "base/message_loop.h" |
| 6 #include "base/utf_string_conversions.h" | 6 #include "base/utf_string_conversions.h" |
| 7 #include "content/browser/speech/audio_buffer.h" | 7 #include "content/browser/speech/audio_buffer.h" |
| 8 #include "content/browser/speech/google_one_shot_remote_engine.h" | 8 #include "content/browser/speech/google_one_shot_remote_engine.h" |
| 9 #include "content/public/common/speech_recognition_error.h" | 9 #include "content/public/common/speech_recognition_error.h" |
| 10 #include "content/public/common/speech_recognition_result.h" | 10 #include "content/public/common/speech_recognition_result.h" |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 41 MessageLoop message_loop_; | 41 MessageLoop message_loop_; |
| 42 TestURLFetcherFactory url_fetcher_factory_; | 42 TestURLFetcherFactory url_fetcher_factory_; |
| 43 content::SpeechRecognitionErrorCode error_; | 43 content::SpeechRecognitionErrorCode error_; |
| 44 content::SpeechRecognitionResult result_; | 44 content::SpeechRecognitionResult result_; |
| 45 }; | 45 }; |
| 46 | 46 |
| 47 void GoogleOneShotRemoteEngineTest::CreateAndTestRequest( | 47 void GoogleOneShotRemoteEngineTest::CreateAndTestRequest( |
| 48 bool success, const std::string& http_response) { | 48 bool success, const std::string& http_response) { |
| 49 GoogleOneShotRemoteEngine client(NULL); | 49 GoogleOneShotRemoteEngine client(NULL); |
| 50 unsigned char dummy_audio_buffer_data[2] = {'\0', '\0'}; | 50 unsigned char dummy_audio_buffer_data[2] = {'\0', '\0'}; |
| 51 AudioChunk dummy_audio_chunk(&dummy_audio_buffer_data[0], | 51 scoped_refptr<AudioChunk> dummy_audio_chunk( |
| 52 sizeof(dummy_audio_buffer_data), | 52 new AudioChunk(&dummy_audio_buffer_data[0], |
| 53 2 /* bytes per sample */); | 53 sizeof(dummy_audio_buffer_data), |
| 54 2 /* bytes per sample */)); | |
| 54 client.set_delegate(this); | 55 client.set_delegate(this); |
| 55 client.StartRecognition(); | 56 client.StartRecognition(); |
| 56 client.TakeAudioChunk(dummy_audio_chunk); | 57 client.TakeAudioChunk(*dummy_audio_chunk); |
|
hans
2012/03/27 15:56:31
hmm, i'm trying to think whether passing the Audio
Primiano Tucci (use gerrit)
2012/03/27 16:51:24
I kept the const ref for all those methods that do
| |
| 57 client.AudioChunksEnded(); | 58 client.AudioChunksEnded(); |
| 58 TestURLFetcher* fetcher = url_fetcher_factory_.GetFetcherByID(0); | 59 TestURLFetcher* fetcher = url_fetcher_factory_.GetFetcherByID(0); |
| 59 ASSERT_TRUE(fetcher); | 60 ASSERT_TRUE(fetcher); |
| 60 | 61 |
| 61 fetcher->set_url(fetcher->GetOriginalURL()); | 62 fetcher->set_url(fetcher->GetOriginalURL()); |
| 62 net::URLRequestStatus status; | 63 net::URLRequestStatus status; |
| 63 status.set_status(success ? net::URLRequestStatus::SUCCESS : | 64 status.set_status(success ? net::URLRequestStatus::SUCCESS : |
| 64 net::URLRequestStatus::FAILED); | 65 net::URLRequestStatus::FAILED); |
| 65 fetcher->set_status(status); | 66 fetcher->set_status(status); |
| 66 fetcher->set_response_code(success ? 200 : 500); | 67 fetcher->set_response_code(success ? 200 : 500); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 113 EXPECT_EQ(0U, result_.hypotheses.size()); | 114 EXPECT_EQ(0U, result_.hypotheses.size()); |
| 114 | 115 |
| 115 // Malformed JSON case. | 116 // Malformed JSON case. |
| 116 CreateAndTestRequest(true, "{\"status\":0,\"hypotheses\":" | 117 CreateAndTestRequest(true, "{\"status\":0,\"hypotheses\":" |
| 117 "[{\"unknownkey\":\"hello\"}]}"); | 118 "[{\"unknownkey\":\"hello\"}]}"); |
| 118 EXPECT_EQ(error_, content::SPEECH_RECOGNITION_ERROR_NETWORK); | 119 EXPECT_EQ(error_, content::SPEECH_RECOGNITION_ERROR_NETWORK); |
| 119 EXPECT_EQ(0U, result_.hypotheses.size()); | 120 EXPECT_EQ(0U, result_.hypotheses.size()); |
| 120 } | 121 } |
| 121 | 122 |
| 122 } // namespace speech | 123 } // namespace speech |
| OLD | NEW |