
org.robolectric.shadows.ShadowDisplayManagerGlobal Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of framework Show documentation
Show all versions of framework Show documentation
An alternative Android testing framework.
The newest version!
package org.robolectric.shadows;
import android.hardware.display.DisplayManagerGlobal;
import android.hardware.display.IDisplayManager;
import android.view.Display;
import org.robolectric.annotation.Implementation;
import org.robolectric.annotation.Implements;
import org.robolectric.shadow.api.Shadow;
import org.robolectric.util.ReflectionHelpers;
import org.robolectric.util.ReflectionHelpers.ClassParameter;
import static android.os.Build.VERSION_CODES.JELLY_BEAN_MR1;
import static android.os.Build.VERSION_CODES.M;
import static org.robolectric.RuntimeEnvironment.getApiLevel;
@Implements(value = DisplayManagerGlobal.class, isInAndroidSdk = false, minSdk = JELLY_BEAN_MR1)
public class ShadowDisplayManagerGlobal {
private static final IDisplayManager displayManager = ReflectionHelpers.createNullProxy(IDisplayManager.class);
@Implementation
public static Object getInstance() {
return ReflectionHelpers.callConstructor(DisplayManagerGlobal.class,
ClassParameter.from(IDisplayManager.class, displayManager));
}
@Implementation
public Object getDisplayInfo(int displayId) {
Object result = Shadow.newInstanceOf("android.view.DisplayInfo");
if (getApiLevel() >= M) {
ReflectionHelpers.setField(result, "supportedModes", new Display.Mode[]{new Display.Mode(0, 0, 0, 0.0f)});
}
return result;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy