org.robolectric.shadows.ShadowCameraCharacteristics 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.
package org.robolectric.shadows;
import android.annotation.Nullable;
import android.hardware.camera2.CameraCharacteristics;
import android.hardware.camera2.CameraCharacteristics.Key;
import android.os.Build.VERSION_CODES;
import com.google.common.base.Preconditions;
import java.util.HashMap;
import java.util.Map;
import org.robolectric.annotation.Implementation;
import org.robolectric.annotation.Implements;
import org.robolectric.util.ReflectionHelpers;
@Implements(value = CameraCharacteristics.class, minSdk = VERSION_CODES.LOLLIPOP)
public class ShadowCameraCharacteristics {
private final Map, Object> charactersKeyToValue = new HashMap<>();
/** Convenience method which returns a new instance of {@link CameraCharacteristics}. */
public static CameraCharacteristics newCameraCharacteristics() {
return ReflectionHelpers.callConstructor(CameraCharacteristics.class);
}
@Implementation
@Nullable
protected T get(Key key) {
return (T) charactersKeyToValue.get(key);
}
/**
* Sets the value for a given key.
*
* @throws IllegalArgumentException if there's an existing value for the key.
*/
public void set(Key key, Object value) {
Preconditions.checkArgument(!charactersKeyToValue.containsKey(key));
charactersKeyToValue.put(key, value);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy