Skip to content

Robolectric 4.1

Compare
Choose a tag to compare
@xian xian released this 13 Dec 01:10
· 4549 commits to master since this release

Robolectric 4.1 has improved support for a number of androidx.test APIs, and new and improved support and testing APIs for scores of Android classes. Robolectric also now works on Windows again, and has a bunch of other awesome bug fixes.

Features

  • Support ActivityScenario and Espresso in Robolectric paused looper mode [issues #4084 and #4157].
  • Add support for Espresso Intents intending() stubbing functionality [issue #4150].
  • Add ShadowAccessibilityButtonController.
  • Add ShadowDevicePolicyManager.isDeviceManaged().
  • Support androidx.test.core.app.ActivityScenario#getActivityResult.
  • Support androidx.test ActivityScenario#getResult.
  • Add ShadowActivity#getLastRequestedPermission.
  • Support ActivityManager#switchUser.
  • Add SupportFragmentController#saveInstanceState.
  • Add ShadowService#getStopSelfId and getStopSelfResultId.
  • Enhance support for `TextToSpeech#speak.
  • Support PackageManager#getPackagesForUid.
  • Support PackageManager#getResourcesForActivity.
  • Limited support for PackageManager#isInstantApp [issue #3991].
  • Properly implement SharedMemory#map.
  • Add ShadowTrafficStats#tagDatagramSocket.
  • Add VpnService support.
  • Add ShadowConnectivityManager#getLinkProperties.
  • Support setting additional StorageVolume attributes via the builder.
  • Add ShadowServiceManager#setServiceAvailability.
  • Add ability to grant/deny permissions for specific process id and user id.
  • Support Bitmap#eraseColor.
  • Support Bitmap.createBitmap(Picture).
  • Support GLES20 glGenFramebuffers.
  • Support Matrix#setRectToRect.
  • Add ShadowStatusBarManager#getDisableFlags and getDisable2Flags.
  • Support AppsOpManager#noteProxOpNoThrow.
  • Add ShadowWebView#setCurrentWebViewPackage.
  • Add support for checking component enabled status.
  • Add WifiManager#getActiveLockCount.
  • Support BluetoothSocket.
  • Support CaptioningManager listeners.
  • Add shadow for performAccessibilityShortcut.
  • Add Trace support.
  • Remove ability to shadow Object.equals/hashCode/toString on subclasses [issue #3692].
  • Remove deprecated @Implements(inheritImplementationMethods) [issue #3909].
  • Feature request: add mapRadius of ShadowMatrix [issue #4055—thanks @crupest].
  • Add mapRadius for ShadowMatrix [issue #4063—thanks @crupest].
  • Make enabled and other flags in the manifest visible in the Component [issue #4103].
  • Prefetch android all m2 [issue #4237].

Bug Fixes

  • Fix parsing of Windows paths [issue #4287].
  • Obtain file lock before downloading android-all from maven - prevents multiple continuous builds corrupting shared android-all jars [issue #3659].
  • Fix BCP47 language tag generation in ShadowAssetManager.
  • Remove custom managed instances of AppWidgetManager, allow Android to manage instance singletons now.
  • Avoid deadlocks in ClassValueMap exposed with newer versions of cglib with mockito.
  • Fix ApplicationInfo.sourceDir for LOLLIPOP+.
  • Support androidx.test.rules.GrantPermissionRule [issue #4133].
  • Fix concurrent android-all download corruption [issue #4237].
  • PackageManager compatibility fixes:
    • Return defensive copies of ResolveInfo and ApplicationInfo objects.
    • Ensure created components are enabled.
    • Add `FLAG_INSTALLED. by default when adding packages, and add new APIs to add packages without adding default flags.
    • Properly load icons/logos for application components.
  • Fix ResourcesCompat.getFont() on API > 26.
  • Fix WebViewDatabase support.
  • Reset ShadowSubscriptionManager state between tests.
  • Support special characters in espresso typeText [issue #4129].
  • Make Bitmap.compress actually write the image to the stream.
  • Support androidx.test GrantPermissionRule [issue #4133].
  • Make SupportFragmentController call on postCreate at correct point.
  • Fix parsing negative hex numbers in resources.
  • Add an auth intent to the getAuthToken callback bundle if no token is available.
  • Only load SoundPool callbacks for known sounds.
  • Set ServiceInfo.processName from ApplicationInfo.processName [issue #4099].
  • Use ASM 7.0 to support class bytecode version 12 and Java 10+. [issue #4085].
  • Fix iteration over integer keys in a hashmap that caused some resource types to be skipped. [issue #4082].
  • Fix ShadowWindowManagerImpl#getViews() for post-Lollipop.
  • ShadowBitmapFactory.decodeByteArray() always returns a 100x100 Bitmap [issue #4028—thanks @tryal-leaf].
  • Method getLocales in android.content.res.Configuration not mocked [issue #4015—thanks @nikoskyr].
  • Method getLocales in android.content.res.Configuration not mocked [issue #4073—thanks @ScottPierce].
  • java.lang.RuntimeException: Failed to extractAlpha on Bitmap [issue #2795—thanks @zhengxiaopeng].
  • GrantPermissionRule rule does not work on AndroidJUnit4 tests [issue #4133—thanks @goblinr].
  • Fix Canvas NoClassDefFound EGLContext error [issue #4146—thanks @jaredsburrows].
  • ShadowKeyCharacterMap doesn't handle '@' or '-' characters [issue #4129—thanks @aisanu].
  • Espresso calls hang when looper is paused [issue #4084].
  • ActivityScenario.launch fails with paused looper [issue #4157].
  • android-all jar download race (tests failing when maxParallelForks > 1) [issue #2346—thanks @NicoloParolini].
  • Espresso Intents onActivityResult() not invoked when intending() matches a component [issue #4150].
  • Unhelpful error message (java.lang.IllegalStateException: this method should only be called by Robolectric) [issue #4235—thanks @neworld].
  • 4.1-beta-2 Bitmap.eraseColor NPE [issue #4289—thanks @NickButcher1].
  • Fix confusing error message when application.onCreate fails [issue #4286].
  • Oops, fix wrong string splits [issue #4156].
  • Fix ApplicationInfo.sourceDir for LOLLIPOP+ [issue #4270].
  • Synchronize maven downloads of android-all [issue #4241].
  • Fix enum value parsing to allow negative values [for legacy resources] [issue #4112—thanks @cesar1000].

Deprecations and Removals

  • Rename addPackage to installPackage in ShadowPackageManager and deprecate.
  • Deprecate ShadowApplication.getAppWidgetManager().
  • Remove ShadowHandler [issue #4245].
  • Make ShadowSharedMemory implementation methods protected.
  • Rename ShadowPackageManager#getPackageInfoForTesting to getInternalMutablePackageInfo.
  • Deprecate ShadowResolveInfo#setLabel.
  • Remove RoboLayoutInflater and ShadowApplication.getLayoutInflater.

Known Issues

  • Android Gradle Plugin 3.2.1 and 3.3 report the following warning, which may be safely ignored: WARNING: The option setting 'android.enableUnitTestBinaryResources=true' is experimental and unsupported.. Android Gradle Plugin 3.4 will resolve this issue.
  • Android Gradle Plugin 3.2.1 does not work on Windows; use 3.3 instead [issue #3955].