
org.robolectric.shadows.GraphicsShadowPicker Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of shadows-framework Show documentation
Show all versions of shadows-framework Show documentation
An alternative Android testing framework.
The newest version!
package org.robolectric.shadows;
import static android.os.Build.VERSION_CODES.O;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.GraphicsMode;
import org.robolectric.annotation.GraphicsMode.Mode;
import org.robolectric.config.ConfigurationRegistry;
import org.robolectric.shadow.api.ShadowPicker;
/** A {@link ShadowPicker} that selects between shadows given the Graphics mode. */
public class GraphicsShadowPicker implements ShadowPicker {
private final Class extends T> legacyShadowClass;
private final Class extends T> nativeShadowClass;
public GraphicsShadowPicker(
Class extends T> legacyShadowClass, Class extends T> nativeShadowClass) {
this.legacyShadowClass = legacyShadowClass;
this.nativeShadowClass = nativeShadowClass;
}
@Override
public Class extends T> pickShadowClass() {
if (RuntimeEnvironment.getApiLevel() >= getMinApiLevel()
&& ConfigurationRegistry.get(GraphicsMode.Mode.class) == Mode.NATIVE) {
return nativeShadowClass;
} else {
return legacyShadowClass;
}
}
protected int getMinApiLevel() {
return O;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy