Robolectric 3.3
Robolectric 3.3 fixes some long-standing bugs (notably PowerMock and Mockito integration) and adds some significant new features. Details below.
New Features
- Added support for the Buck build system [issue #2907].
- Added support for generic build system integration [issue #2912].
Android Simulation Changes
<array>resources are now supported [issue #2064].Context#getExternalFilesDirsnow supported [issue #2818].- Implemented
android.opengl.Matrix[issue #2893]. - Implemented a bunch of methods in
PackageManager: [issue #2913].checkSignatures()getDefaultActivityIcon()getInstalledApplications()getInstallerPackageName()andsetInstallerPackageName()getPackageSizeInfo()(UseaddPackage()to control behavior.)getPermissionInfo()(Use manifest oraddPermissionInfo()to control behavior.)resolveContentProvider()
- Implemented a bunch of methods in
AccountManager: [issue #2906].- All methods which return a
AccountManagerFuturewill now post their work to the specifiedHandler, so it will be deferred or executed immediately depending on the state of itsScheduler.
- All methods which return a
- Added initial support for WifiP2pManager [issue #2933].
View.getGlobalVisibleRect()now uses the framework implementation unlesssetGlobalVisibleRect()has been called.
API Changes:
- Several classes have moved to new packages. See Migration Guide for details [issue #2873].
PackageManager's behavior is moving from a subclass to a shadow. See the Migration Guide [issue #2887]- Deprecated
RuntimeEnvironment.getPackageManager(). Use Android APIs instead. - Deprecated
ShadowConfiguration. UseConfigurationdirectly instead. - Deprecated
ShadowView#getQualifiers(). UseRobolectric.getQualifiers()instead. - Deprecated
*Controller.withIntent()and.attach()[issue #2938]. - Removed deprecated
ShadowLocation. Note thatLocation.equals()is no longer shadowed with special equality rules. [issue #2932] - Removed deprecated
ShadowNotification.getProgressBar(),ShadowDrawable.reset(),ShadowContentResolver.registerProvider(),ShadowContentResolver.getContentObserver(),ShadowImageView.getImageResourceId(), andShadowImageView.getImageBitmap()[issue #2932]. - Removed deprecated
ShadowIntentFilter. - Removed deprecated
RoboAttributeSetandAttributeclass. UseRobolectric.buildAttributeSet()instead. - Removed deprecated
MultiApiRobolectricTestRunner[issue #2924]. - The jars that comprise Robolectric have changed a bit. If your build system doesn't automatically pull in dependencies, see this post on (hermetic builds)[http://robolectric.org/blog/2017/03/01/hermetic-builds/] for more info.
Bug Fixes:
- Fixed: PowerMock broken [issue #2208].
- Fixed: Mockito experimental mocking of finals is broken [issue #2677].
- Fixed a bug causing styleable attribute lookup in application resources to fail sometimes [issue #2878].
- Fixed a bug which caused non-layout resources to be seen as layouts [issue #2882].
- Fixed
View.getWindowId()to behave more like Android [issue #2888]. - Fixed a bug in
BitmapRegionDecoder[issue #2926]. - Fixed a bug in
PackageMAnager.queryIntentContentProviders()[issue #2927].
Known Issues:
- Some styles may still not resolve properly [issue #2787].
Use Robolectric:
testCompile "org.robolectric:robolectric:3.3"Find more details here.