Robolectric 3.2
Android SDK Support
- Android N (API level 24, framework code version 7.0.0_r1) and N_MR1 (API level 25, framework code version 7.1.0_r7) are now supported.
- Android M (API level 23) framework code has been bumped from 6.0.0_r1 to 6.0.1_r3.
- Numerous resource resolution bugs related to AppCompat 24 when running on older SDKs have been fixed.
New Features
RobolectricTestRunnernow supports running tests against multiple SDKs. See Configuring Robolectric for more details.
Android Simulation Changes:
Matrixis now more fully implemented.- Matrix.toString() no longer returns a summary of operations. You may use
shadowOf(matrix).getDescription()orshadowOf(matrix).getPostOperations()etc. instead. - Matrix operations applied to
Bitmaps now cause the size of theBitmapto change accordingly. - Drawable resources declared as
<item type="drawable"/>are now supported. - Location listeners registered multiple times with
LocationManager.requestLocationUpdates()will only receive one notification. Parcelable.readException(),writeInterfaceToken()andenforceInterface()are now implemented.- Binary Drawables with qualifiers (e.g. in
drawable-hdpi) can now be accessed usingResources.openRawResource(). BitmapRegionDecoderis now implemented; bitmap width and height are correctly detected.AssetManager.getThemeValue()now honors the value of theresolveRefsargument, and correctly handles style references to attributes in another package.ShadowIconprovides accessors for hiddenIconinternals.JobScheduler.cancel()andLooper.quitSafely()are now implemented.Canvas.drawBitmap()with destinationRectFis now implemented.IntentFilternow uses all-framework code. Previously,equals()andhashCode()had a partial shadow implementation, but now they are unimplemented.- Some additional methods on
RoboCursorare now implemented. XmlPullParser.getIdAttributeResourceValue()now resolves references.NotificationManager.getActiveNotifications()is now implemented.- Added basic support for device protected storage contexts.
- Added basic support for setting state of
UserManager.isUserUnlocked().
API Changes:
ManifestFactory.identify()won't be called withmanifest = "--default"any more.- Specify
@Implements(minSdk/maxSdk)or@Implementation(minSdk/maxSdk)to restrict shadow classes and methods to the given Android SDK levels. ShadowIntentFilterhas been deprecated and will be removed in the next major release.- If you are doing custom configuration using a subclass of
RobolectricTestRunneryou'll probably need to make a few changes. See Migration Guide for details. - When injecting a
RoboCursor, be sure to callsetColumnNames()on it if you care about whatgetColumnCount()will return later.
Bug Fixes:
- Fixed
java.util.ServiceConfigurationError: org.robolectric.internal.ShadowProvider: Provider org.robolectric.Shadows not a subtype[issue #2737]. - A number of race conditions and minor bugs have been fixed.
Known Issues:
- Robolectric still has issues with PowerMock and Mockito [issues #2429 and #2677]. We'll have a fix soon, promise!
- Some styles may still not resolve properly [issue #2787].
- Fails to run on Windows [issue #2814].
Thanks to the many contributors to this release!
Use Robolectric:
testCompile "org.robolectric:robolectric:3.2"Find more details here.