Class ShadowSpeechRecognizerImpl

java.lang.Object
org.robolectric.shadows.ShadowSpeechRecognizer
org.robolectric.shadows.ShadowSpeechRecognizerImpl

@Implements(className="android.speech.SpeechRecognizerImpl", isInAndroidSdk=false, minSdk=35) public class ShadowSpeechRecognizerImpl extends ShadowSpeechRecognizer
Robolectric shadow for SpeechRecognizerImpl.

Prior to Android V, SpeechRecognizer contained all functionality within one class. The ShadowSpeechRecognizer shadow would work correctly to shadow both static and instance functions of the class. With Android V, the instance of SpeechRecognizer returned from SpeechRecognizer.createSpeechRecognizer(Context) is an instance of SpeechRecognizerProxy which delegates all calls to SpeechRecognizerImpl. We need this shadow in order to intercept function calls correctly and to ensure that the functionality of ShadowSpeechRecognizer still works in tests prior to Android V and on Android V+.

Customizations for this implementation:

  • Intercept of all needed functions in SpeechRecognizerImpl
  • Direct access to functions/variables in SpeechRecognizerImpl via getDirectAccessors()
  • Parent shadow class' state is used for state (no custom state)