Package org.robolectric.pluginapi
Class Sdk
java.lang.Object
org.robolectric.pluginapi.Sdk
- All Implemented Interfaces:
Comparable<Sdk>
- Direct Known Subclasses:
DefaultSdkProvider.DefaultSdk
Represents a unique build of the Android SDK.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
Instances ofSdk
are ordered by the API level they implement.boolean
abstract String
Returns the Android codename for this SDK.abstract String
Returns the Android Version for this SDK.final int
Returns the Android API level for this SDK.abstract Path
Returns the path to jar for this SDK.abstract String
Returns a human-readable message explaining why this SDK isn't supported.int
hashCode()
boolean
isKnown()
Determines if this SDK is known by its provider.abstract boolean
Determines if this SDK is supported in the running Robolectric environment.toString()
abstract void
verifySupportedSdk
(String testClassName) Verify that the SDK is supported.
-
Constructor Details
-
Sdk
protected Sdk(int apiLevel)
-
-
Method Details
-
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_INT
provided within.- See Also:
-
getAndroidVersion
Returns the Android Version for this SDK.It should match the version reported by
android.os.Build.VERSION.RELEASE
provided within.If this is an expensive operation, the implementation should cache the return value.
- See Also:
-
getAndroidCodeName
Returns the Android codename for this SDK.It should match the version reported by
android.os.Build.VERSION.CODENAME
provided within.If this is an expensive operation, the implementation should cache the return value.
-
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
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
-
hashCode
public int hashCode() -
toString
-
compareTo
Instances ofSdk
are ordered by the API level they implement.- Specified by:
compareTo
in interfaceComparable<Sdk>
-
verifySupportedSdk
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.
-