summaryrefslogtreecommitdiffstats
path: root/WebCore/platform/mock/SpeechInputClientMock.cpp
diff options
context:
space:
mode:
authorShimeng (Simon) Wang <swang@google.com>2010-12-07 17:22:45 -0800
committerShimeng (Simon) Wang <swang@google.com>2010-12-22 14:15:40 -0800
commit4576aa36e9a9671459299c7963ac95aa94beaea9 (patch)
tree3863574e050f168c0126ecb47c83319fab0972d8 /WebCore/platform/mock/SpeechInputClientMock.cpp
parent55323ac613cc31553107b68603cb627264d22bb0 (diff)
downloadexternal_webkit-4576aa36e9a9671459299c7963ac95aa94beaea9.zip
external_webkit-4576aa36e9a9671459299c7963ac95aa94beaea9.tar.gz
external_webkit-4576aa36e9a9671459299c7963ac95aa94beaea9.tar.bz2
Merge WebKit at r73109: Initial merge by git.
Change-Id: I61f1a66d9642e3d8405d3ac6ccab2a53421c75d8
Diffstat (limited to 'WebCore/platform/mock/SpeechInputClientMock.cpp')
-rw-r--r--WebCore/platform/mock/SpeechInputClientMock.cpp27
1 files changed, 15 insertions, 12 deletions
diff --git a/WebCore/platform/mock/SpeechInputClientMock.cpp b/WebCore/platform/mock/SpeechInputClientMock.cpp
index 820152c..16f2825 100644
--- a/WebCore/platform/mock/SpeechInputClientMock.cpp
+++ b/WebCore/platform/mock/SpeechInputClientMock.cpp
@@ -81,18 +81,21 @@ void SpeechInputClientMock::cancelRecognition(int requestId)
}
}
-void SpeechInputClientMock::setRecognitionResult(const String& result, const AtomicString& language)
+void SpeechInputClientMock::addRecognitionResult(const String& result, double confidence, const AtomicString& language)
{
if (language.isEmpty())
- m_resultForEmptyLanguage = result;
- else
- m_recognitionResult.set(language, result);
+ m_resultsForEmptyLanguage.append(SpeechInputResult::create(result, confidence));
+ else {
+ if (!m_recognitionResults.contains(language))
+ m_recognitionResults.set(language, SpeechInputResultArray());
+ m_recognitionResults.find(language)->second.append(SpeechInputResult::create(result, confidence));
+ }
}
void SpeechInputClientMock::clearResults()
{
- m_resultForEmptyLanguage = String();
- m_recognitionResult.clear();
+ m_resultsForEmptyLanguage.clear();
+ m_recognitionResults.clear();
}
void SpeechInputClientMock::timerFired(WebCore::Timer<SpeechInputClientMock>*)
@@ -102,18 +105,17 @@ void SpeechInputClientMock::timerFired(WebCore::Timer<SpeechInputClientMock>*)
m_listener->didCompleteRecording(m_requestId);
m_timer.startOneShot(0);
} else {
- SpeechInputResultArray results;
bool noResultsFound = false;
// Empty language case must be handled separately to avoid problems with HashMap and empty keys.
if (m_language.isEmpty()) {
- if (!m_resultForEmptyLanguage.isNull())
- results.append(SpeechInputResult::create(m_resultForEmptyLanguage, 1.0));
+ if (!m_resultsForEmptyLanguage.isEmpty())
+ m_listener->setRecognitionResult(m_requestId, m_resultsForEmptyLanguage);
else
noResultsFound = true;
} else {
- if (m_recognitionResult.contains(m_language))
- results.append(SpeechInputResult::create(m_recognitionResult.get(m_language), 1.0));
+ if (m_recognitionResults.contains(m_language))
+ m_listener->setRecognitionResult(m_requestId, m_recognitionResults.get(m_language));
else
noResultsFound = true;
}
@@ -124,10 +126,11 @@ void SpeechInputClientMock::timerFired(WebCore::Timer<SpeechInputClientMock>*)
String error("error: no result found for language '");
error.append(m_language);
error.append("'");
+ SpeechInputResultArray results;
results.append(SpeechInputResult::create(error, 1.0));
+ m_listener->setRecognitionResult(m_requestId, results);
}
- m_listener->setRecognitionResult(m_requestId, results);
m_listener->didCompleteRecognition(m_requestId);
m_requestId = 0;
}