Package org.robolectric.pluginapi
Class Sdk
- java.lang.Object
-
- org.robolectric.pluginapi.Sdk
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedSdk(int apiLevel)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description intcompareTo(Sdk o)Instances ofSdkare ordered by the API level they implement.booleanequals(java.lang.Object o)abstract java.lang.StringgetAndroidCodeName()Returns the Android codename for this SDK.abstract java.lang.StringgetAndroidVersion()Returns the Android Version for this SDK.intgetApiLevel()Returns the Android API level for this SDK.abstract java.nio.file.PathgetJarPath()Returns the path to jar for this SDK.abstract java.lang.StringgetUnsupportedMessage()Returns a human-readable message explaining why this SDK isn't supported.inthashCode()booleanisKnown()Determines if this SDK is known by its provider.abstract booleanisSupported()Determines if this SDK is supported in the running Robolectric environment.java.lang.StringtoString()abstract voidverifySupportedSdk(java.lang.String testClassName)Verify that the SDK is supported.
-
-
-
Method Detail
-
getApiLevel
public final int getApiLevel()
Returns the Android API level for this SDK.It must match the version reported by
android.os.Build.VERSION.SDK_INTprovided within.- See Also:
- Android build numbers
-
getAndroidVersion
public abstract java.lang.String getAndroidVersion()
Returns the Android Version for this SDK.It should match the version reported by
android.os.Build.VERSION.RELEASEprovided within.If this is an expensive operation, the implementation should cache the return value.
- See Also:
- Android build numbers
-
getAndroidCodeName
public abstract java.lang.String getAndroidCodeName()
Returns the Android codename for this SDK.It should match the version reported by
android.os.Build.VERSION.CODENAMEprovided within.If this is an expensive operation, the implementation should cache the return value.
-
getJarPath
public abstract java.nio.file.Path getJarPath()
Returns the path to jar for this SDK.
-
isSupported
public abstract boolean isSupported()
Determines if this SDK is supported in the running Robolectric environment. An SDK might be unsupported if e.g. it requires a newer version of the JVM than is currently running. Unsupported SDKs should throw some explanatory exception whengetJarPath()is invoked. If this is an expensive operation, the implementation should cache the return value.
-
getUnsupportedMessage
public abstract java.lang.String getUnsupportedMessage()
Returns a human-readable message explaining why this SDK isn't supported. If this is an expensive operation, the implementation should cache the return value.
-
isKnown
public boolean isKnown()
Determines if this SDK is known by its provider. Unknown SDKs can serve as placeholder objects; they should throw some explanatory exception whengetJarPath()is invoked.
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
compareTo
public int compareTo(@Nonnull Sdk o)Instances ofSdkare ordered by the API level they implement.- Specified by:
compareToin interfacejava.lang.Comparable<Sdk>
-
verifySupportedSdk
public abstract void verifySupportedSdk(java.lang.String testClassName)
Verify that the SDK is supported.Implementations should throw an exception if SDK is unsupported. They can choose to either throw org.junit.AssumptionViolatedException to just skip execution of tests on the SDK, with a warning, or throw a RuntimeException to fail the test.
- Parameters:
testClassName-
-
-