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

Unified Diff: chrome/browser/speech/speech_recognition_request_unittest.cc

Issue 4119004: Add ability to parse multiple recognition results and send them to WebKit. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move header to chrome/common and address review comments. Created 10 years, 2 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
« no previous file with comments | « chrome/browser/speech/speech_recognition_request.cc ('k') | chrome/browser/speech/speech_recognizer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/speech/speech_recognition_request_unittest.cc
diff --git a/chrome/browser/speech/speech_recognition_request_unittest.cc b/chrome/browser/speech/speech_recognition_request_unittest.cc
index dcf0e9b52664fd26373c9506ce2933eac1fa52d2..b9f166878380c9022bb6c9fc5ece855359e48992 100644
--- a/chrome/browser/speech/speech_recognition_request_unittest.cc
+++ b/chrome/browser/speech/speech_recognition_request_unittest.cc
@@ -21,7 +21,8 @@ class SpeechRecognitionRequestTest : public SpeechRecognitionRequestDelegate,
void CreateAndTestRequest(bool success, const std::string& http_response);
// SpeechRecognitionRequestDelegate methods.
- virtual void SetRecognitionResult(bool error, const string16& result) {
+ virtual void SetRecognitionResult(bool error,
+ const SpeechInputResultArray& result) {
error_ = error;
result_ = result;
}
@@ -38,7 +39,7 @@ class SpeechRecognitionRequestTest : public SpeechRecognitionRequestDelegate,
protected:
TestURLFetcherFactory url_fetcher_factory_;
bool error_;
- string16 result_;
+ SpeechInputResultArray result_;
};
void SpeechRecognitionRequestTest::CreateAndTestRequest(
@@ -62,24 +63,30 @@ TEST_F(SpeechRecognitionRequestTest, BasicTest) {
CreateAndTestRequest(true,
"{\"hypotheses\":[{\"utterance\":\"123456\",\"confidence\":0.9}]}");
EXPECT_FALSE(error_);
- EXPECT_EQ(ASCIIToUTF16("123456"), result_);
+ EXPECT_EQ(1U, result_.size());
+ EXPECT_EQ(ASCIIToUTF16("123456"), result_[0].utterance);
+ EXPECT_EQ(0.9, result_[0].confidence);
// Normal success case with multiple results.
CreateAndTestRequest(true,
"{\"hypotheses\":[{\"utterance\":\"hello\",\"confidence\":0.9},"
"{\"utterance\":\"123456\",\"confidence\":0.5}]}");
EXPECT_FALSE(error_);
- EXPECT_EQ(ASCIIToUTF16("hello"), result_);
+ EXPECT_EQ(2u, result_.size());
+ EXPECT_EQ(ASCIIToUTF16("hello"), result_[0].utterance);
+ EXPECT_EQ(0.9, result_[0].confidence);
+ EXPECT_EQ(ASCIIToUTF16("123456"), result_[1].utterance);
+ EXPECT_EQ(0.5, result_[1].confidence);
// Http failure case.
CreateAndTestRequest(false, "");
EXPECT_TRUE(error_);
- EXPECT_EQ(ASCIIToUTF16(""), result_);
+ EXPECT_EQ(0U, result_.size());
// Malformed JSON case.
CreateAndTestRequest(true, "{\"hypotheses\":[{\"unknownkey\":\"hello\"}]}");
EXPECT_TRUE(error_);
- EXPECT_EQ(ASCIIToUTF16(""), result_);
+ EXPECT_EQ(0U, result_.size());
}
} // namespace speech_input
« no previous file with comments | « chrome/browser/speech/speech_recognition_request.cc ('k') | chrome/browser/speech/speech_recognizer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698