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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 void GoogleOneShotRemoteEngineTest::CreateAndTestRequest( | 52 void GoogleOneShotRemoteEngineTest::CreateAndTestRequest( |
53 bool success, const std::string& http_response) { | 53 bool success, const std::string& http_response) { |
54 GoogleOneShotRemoteEngine client(NULL); | 54 GoogleOneShotRemoteEngine client(NULL); |
55 unsigned char dummy_audio_buffer_data[2] = {'\0', '\0'}; | 55 unsigned char dummy_audio_buffer_data[2] = {'\0', '\0'}; |
56 scoped_refptr<AudioChunk> dummy_audio_chunk( | 56 scoped_refptr<AudioChunk> dummy_audio_chunk( |
57 new AudioChunk(&dummy_audio_buffer_data[0], | 57 new AudioChunk(&dummy_audio_buffer_data[0], |
58 sizeof(dummy_audio_buffer_data), | 58 sizeof(dummy_audio_buffer_data), |
59 2 /* bytes per sample */)); | 59 2 /* bytes per sample */)); |
60 client.set_delegate(this); | 60 client.set_delegate(this); |
61 client.StartRecognition(); | 61 client.StartRecognition(); |
62 client.TakeAudioChunk(*dummy_audio_chunk); | 62 client.TakeAudioChunk(*dummy_audio_chunk.get()); |
63 client.AudioChunksEnded(); | 63 client.AudioChunksEnded(); |
64 net::TestURLFetcher* fetcher = url_fetcher_factory_.GetFetcherByID(0); | 64 net::TestURLFetcher* fetcher = url_fetcher_factory_.GetFetcherByID(0); |
65 ASSERT_TRUE(fetcher); | 65 ASSERT_TRUE(fetcher); |
66 | 66 |
67 fetcher->set_url(fetcher->GetOriginalURL()); | 67 fetcher->set_url(fetcher->GetOriginalURL()); |
68 net::URLRequestStatus status; | 68 net::URLRequestStatus status; |
69 status.set_status(success ? net::URLRequestStatus::SUCCESS : | 69 status.set_status(success ? net::URLRequestStatus::SUCCESS : |
70 net::URLRequestStatus::FAILED); | 70 net::URLRequestStatus::FAILED); |
71 fetcher->set_status(status); | 71 fetcher->set_status(status); |
72 fetcher->set_response_code(success ? 200 : 500); | 72 fetcher->set_response_code(success ? 200 : 500); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 EXPECT_EQ(0U, result().hypotheses.size()); | 119 EXPECT_EQ(0U, result().hypotheses.size()); |
120 | 120 |
121 // Malformed JSON case. | 121 // Malformed JSON case. |
122 CreateAndTestRequest(true, "{\"status\":0,\"hypotheses\":" | 122 CreateAndTestRequest(true, "{\"status\":0,\"hypotheses\":" |
123 "[{\"unknownkey\":\"hello\"}]}"); | 123 "[{\"unknownkey\":\"hello\"}]}"); |
124 EXPECT_EQ(error_, SPEECH_RECOGNITION_ERROR_NETWORK); | 124 EXPECT_EQ(error_, SPEECH_RECOGNITION_ERROR_NETWORK); |
125 EXPECT_EQ(0U, result().hypotheses.size()); | 125 EXPECT_EQ(0U, result().hypotheses.size()); |
126 } | 126 } |
127 | 127 |
128 } // namespace content | 128 } // namespace content |
OLD | NEW |