Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(588)

Side by Side Diff: content/browser/speech/google_one_shot_remote_engine_unittest.cc

Issue 9861019: Speech refactoring: Turned AudioChunk into a refcounted class (CL1.4) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed according to Hans review. Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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);
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
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
OLDNEW
« no previous file with comments | « content/browser/speech/google_one_shot_remote_engine.cc ('k') | content/browser/speech/speech_recognizer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698