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

Unified Diff: content/browser/speech/google_ssfe_remote_engine_unittest.cc

Issue 9663066: Refactoring of chrome speech recognition architecture (CL1.3) (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 side-by-side diff with in-line comments
Download patch
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..cc0460a6d36598b0d72156477fbffe4e92f7df8b 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() {}
// 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\":"

Powered by Google App Engine
This is Rietveld 408576698