Skip to content

Commit

Permalink
Add triggerOnReadyForSpeech() to ShadowSpeechRecognizer.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 436243233
  • Loading branch information
Googler authored and hoisie committed Mar 22, 2022
1 parent 4abfe22 commit 5f8ac43
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
Expand Up @@ -42,6 +42,20 @@ public void onErrorCalled() {
assertThat(listener.errorReceived).isEqualTo(-1);
}

@Test
public void onReadyForSpeechCalled() {
startListening();
Bundle expectedBundle = new Bundle();
ArrayList<String> results = new ArrayList<>();
String result = "onReadyForSpeech";
results.add(result);
expectedBundle.putStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION, results);

shadowOf(speechRecognizer).triggerOnReadyForSpeech(expectedBundle);

assertThat(listener.bundleReceived).isEqualTo(expectedBundle);
}

@Test
public void onPartialResultsCalled() {
startListening();
Expand Down Expand Up @@ -183,7 +197,9 @@ public void onPartialResults(Bundle bundle) {
}

@Override
public void onReadyForSpeech(Bundle params) {}
public void onReadyForSpeech(Bundle bundle) {
bundleReceived = bundle;
}

@Override
public void onResults(Bundle bundle) {
Expand Down
Expand Up @@ -97,6 +97,10 @@ public void triggerOnError(int error) {
recognitionListener.onError(error);
}

public void triggerOnReadyForSpeech(Bundle bundle) {
recognitionListener.onReadyForSpeech(bundle);
}

public void triggerOnPartialResults(Bundle bundle) {
recognitionListener.onPartialResults(bundle);
}
Expand Down

0 comments on commit 5f8ac43

Please sign in to comment.