
org.robolectric.shadows.ShadowContentProvider 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.Q;
import static org.robolectric.util.reflector.Reflector.reflector;
import android.content.ContentProvider;
import org.robolectric.annotation.Implementation;
import org.robolectric.annotation.Implements;
import org.robolectric.annotation.RealObject;
import org.robolectric.util.reflector.Direct;
import org.robolectric.util.reflector.ForType;
/** Shadow for {@link ContentProvider}. */
@Implements(value = ContentProvider.class)
public class ShadowContentProvider {
@RealObject private ContentProvider realContentProvider;
private String callingPackage;
@Implementation(minSdk = Q, maxSdk = Q)
public String setCallingPackage(String callingPackage) {
this.callingPackage = callingPackage;
return callingPackage;
}
@Implementation
protected String getCallingPackage() {
if (callingPackage != null) {
return callingPackage;
} else {
return reflector(ContentProviderReflector.class, realContentProvider).getCallingPackage();
}
}
@ForType(ContentProvider.class)
interface ContentProviderReflector {
@Direct
String getCallingPackage();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy