All Versions
13
Latest Version
Avg Release Cycle
51 days
Latest Release
1297 days ago

Changelog History
Page 1

  • v4.5-alpha Changes

    September 30, 2020

    πŸ›  Robolectric 4.5 Alpha 1 adds support for Android API 30 (R final) and contains many bug fixes and other enhancements.

    πŸš€ More detailed release notes are forthcoming.

    For all changes view the comparison to 4.4.

    πŸ‘‰ Use Robolectric:

    testCompile "org.robolectric:robolectric:4.5-alpha-1"
    
  • v4.4 Changes

    August 24, 2020

    Robolectric 4.4 is a massive release in terms of improvements to Android compatibility. The most noticeable item in the release is that the new PAUSED looper mode is now the default. You can read about the PAUSED looper in more detail here: http://robolectric.org/blog/2019/06/04/paused-looper/.

    Note:

    πŸš€ 1. Not all changes are listed in the release notes. There were many other minor changes (such as dependency version bumps) that weren't included in this list for brevity. For all changes view the comparison to 4.3.1. πŸš€ 2. Some of the pull requests in this release may contain duplicate changes from other pull requests in this release. We apologize for this messy history, it was the result of some misconfigured code sync tool. We’ve taken measures to ensure it doesn’t happen any more.

    πŸ‘‰ Use Robolectric:

    testCompile "org.robolectric:robolectric:4.4"
    

    πŸ‘ SDK/JVM support

    πŸ—„ Deprecations

    • πŸ—„ Deprecate LooperMode LEGACY in favor of PAUSED (#5490), and default to PAUSED looper mode (#5491)
    • 🚚 Accessibility checking is now deprecated and has been moved into a separate maven artifact org.robolectric:plugin-accessibility-deprecated. Accessibility checking will be removed entirely from Robolectric 4.5. Please switch to Espresso for accessibility checking. (#5547)
    • πŸ—„ Deprecate ShadowContentResolver shadow API because they do not work with ContentProviderClient (#5376)
    • ⚑️ Deprecate ShadowLocationManager.getLocationUpdateListeners and ShadowLocationManager.getLocationUpdateListeners (#5150)
    • πŸ‘‰ Make it an error to run on Q with an unsupported java version
      βœ… instead of just silently skipping tests (#5290)
    • πŸ—„ Deprecate Robolectric's custom cursor implementation (#5613)
    • πŸ”’ The BouncyCastle security provider is now considered deprecated due to the incompatibility with Java 9+ (#5849, #5850). This was preventing Robolectric tests (and Robolectric itself) from making HTTPS network requests on Java 9+. Long term the plan is to switch to Conscrypt.

    βœ… Android support / Robolectric test API improvements

    • πŸ›  Fix bug in ShadowImageDecoder.decodeBitmap (#4966)
    • Use real setting for WIFI_SCAN_ALWAYS_AVAILABLE (#4968)
    • βž• Add a shadow for Font.Builder (#4993)
    • βž• Add killProcess implementation to ShadowProcess (#4985)
    • βž• Add a shadow for CallLog.Calls (#4996)
    • βž• Add a shadow for CallScreeningService (#4997)
    • βž• Add several shadows for camera2 classes (#4874)
    • βž• Add option to avoid calling ShadowApplication.onServiceDisconnected in ShadowApplication.unbindService (#4979)
    • βž• Add ability to simulate Bluetooth unavailable in ShadowBluetoothAdapter (#5002)
    • πŸ“¦ Implement ShadowApplicationPackageManager.getApplicationIcon(ApplicationInfo) (#5005)
    • βž• Add ability to simulate SecurityExceptions in bindService (#4980)
    • βž• Add ability to simulate enabled/disabled networks in ShadowWifiManager (#4974)
    • βž• Add ability to simulate wifi usability system APIs in ShadowWifiManager (#5168)
    • βž• Add null check in ShadowWifiManager.addNetwork (#5014)
    • βž• Add shadow implementation of ShadowTelephonyManager#getDataState (#5003)
    • Fall back to Android's implementation of getResourcesForApplication (#4969)
    • Implement ShadowTypeface.equals and ShadowTypeface.hashCode (#4992)
    • βž• Add ability to make ShadowContentResolver.registerContentObserver throw an exception (#4988)
    • Implement ShadowSubscriptionManager.getActiveSubscriptionInfoCountMax (#5010)
    • βž• Add ability to set system dialer package in ShadowTelecomManager (#4986)
    • Implement ShadowSensorManager.registerListener 5-arg overload (#5014)
    • βž• Add ability to get last flags set in ShadowUIModeManager (#5027)
    • βž• Add a shadow for BluetoothA2dp (#5034)
    • βž• Add shadow implementation for BluetoothDevice.createRfcommSocketToServiceRecord (#5034)
    • βž• Add shadow implementations for BluetoothDevice.setPin and BluetoothDevice.setPairingConfirmation (and ability to get the values set) (#5116)
    • βž• Adding shadow implementations of BluetoothDevice.getAlias and BlueToothDevice.getAliasName and related test APIs (#5222)
    • βž• Adds the ability to get broadcast intents sent to a specific user (#5045)
    • Validate intents passed to start/stop/bindService (#5053)
    • Complete rewrite of ShadowLocationManager to improve fidelity (#5035, #5062, #5152, #5587, #5666)
    • βž• Add ability to clear broadcast intents in ShadowContextWrapper (#5066)
    • πŸ›  Fix package name ShadowApplicationPackageManager's Activity Chooser (#5068)
    • βž• Add shadow implementation for MediaPlayer#setDataSource(Context, Uri) (#5064)
    • βž• Add shadow implementation for UserManager.getUserHandle(int) (#5065)
    • βž• Add shadow implementations for DevicePolicyManager.setSystemUpdatePolicy and DevicePolicyManager.getSystemUpdatePolicy (#5069)
    • βœ‚ Remove ShadowOverscroller (#5081)
    • βž• Add ability to simulate return value of AccessibilityService.getWindows list in ShadowAccessibilityService (#5083)
    • πŸ›  Fix bug in ShadowParcel.writeByteArray (#5089)
    • βž• Add shadow implementation for UserManager.getUserName (#5099)
    • πŸ‘Œ Improve fidelity of ShadowTime#parse3339 (#5101)
    • βž• Add shadow for BiometricManager (#5072)
    • Propagate RemoteException from Binder#onTransact method (#4984)
    • βž• Add shadow for android.service.notification.NotificationListenerService.Ranking (#5113)
    • βž• Add support for VibrationEffect.Prebaked in ShadowSystemVibrator (#5119
    • βž• Add the ability to set Tx and Rx packets/bytes for ShadowTrafficStats (#5121)
    • βž• Add shadow implementation for Activity.getCallingPackage (and the ability to set it) (#5126)
    • βž• Add shadows for several telephony classes (android.telecom.Call, android.telecom.InCallAdapter, android.telecom.InCallService, android.telecom.Phone) (#5107)
    • πŸ‘Œ Improve fidelity of ShadowCookieManager.removeSessionCookies (#5130)
    • πŸ‘Œ Improve fidelity of OpEntry.getTime() and OpEntry.getDuration() in Q (#5133)
    • 0️⃣ Set default NetworkCapabilities for the two Robolectric created Networks (#5129)
    • Set the mimetype in ShadowBitmapFactory.decodeStream() (#5128)
    • βž• Add module support for ShadowPackageManager and ShadowApplicationPackageManager (#5136)
    • βž• Add the ability to set the external storage directory in ShadowEnvironment (#5140)
    • βž• Add support for the dataChanged API in ShadowBackupManager (#5137)
    • βž• Add ShadowContentResolver.registerInputStreamSupplier (#5142)
    • πŸ”” Notify settings ContentResolver when settings change (#5138)
    • Include size and mtime members in Os.stat variants (#5148)
    • Implement ShadowInstrumentation.execStartActivity variant with UserHandle (#5096)
    • βž• Add ability to add entries to ShadowDropBoxManager (#5160)
    • πŸ›  Fix ShadowSigningInfo parceling (#5163)
    • βž• Add ability to set Build.VERSION.SECURITY_PATCH (#5173), Build.PRODUCT (#5304), Build.BRAND (#5566), and Build.HARDWARE (#5619)
    • βž• Add support for DisplayManager BrightnessConfiguration APIs (#5170)
    • βž• Add ability to simulate location power save modes in ShadowPowerManager (#5176)
    • βž• Add shadow method and test API for PowerManager.isLightDeviceIdleMode (#5226)
    • βž• Add support for Android Q usb port statuses in ShadowUsbManager (#5175)
    • βž• Add ability to simulate sending and downloading multimedia messages in ShadowSmsManager (#5177)
    • βž• Add ability to query the number of times a WebView was reloaded (#5182)
    • βž• Add ability to simulate WebViewClient and WebViewClient callbacks on page loads (#5188, #5199)
    • βž• Add shadow method for WebView.getTitle (#5200)
    • βž• Add test APIs to check if WebViewDatabase.clearFormData was called (#5201)
    • βž• Add ability to override autofill service component name to ShadowAutofillManager (#5181)
    • βž• Add ability to construct AttestedKeyPair objects (#5183)
    • βž• Add shadow method for CameraCaptureSessionImpl.capture (#5191)
    • βž• Add shadow method and test APIs for MediaScannerConnection.scanFile (#5178)
    • βž• Add synchronous support to ShadowMediaCodec and the ability to apply fake codecs (#5195)
    • βž• Add shadow methods for CameraParameters metering and focus areas and test APIs (#5189)
    • βž• Add shadow method for AudioManager.getActiveRecordingConfigurations and test APIs (#5198)
    • βž• Add ShadowAudioRecord (#5202, #5789)
    • βž• Add several shadow methods for SliceManager (#5227)
    • βž• Add shadow methods for new Android Q variants of setPackagesSuspended (#5135)
    • βž• Add shadow method and test APIs for AccessibilityManager.sendAccessibilityEvent (#5192)
    • βž• Add ability to log time in ShadowLog (#5224)
    • βž• Add shadow for SuspendDialogInfo system API (#5232)
    • βž• Add shadow method for PackageManager.canonicalToCurrentPackageNames and the ShadowPackageManageraddCanonicalName test API (#5233)
    • βž• Add better support for camera2 CaptureRequestBuilder (#5230)
    • βž• Add shadow method for Os.sysconf and a shadow API to set sysconf values (#5247)
    • βž• Add shadow method for PackageManager.setDistractingPackageRestrictions and shadow API to get the set value (#5248)
    • βž• Add shadow method for Bitmap.extractAlpha(Paint, int[]) (#5240)
    • βž• Add the ability to set the user id in ContextImpl (#5253)
    • πŸ›  Fix some bugs in ShadowStorageManager StorageVolume logic (#5251, #5250)
    • βž• Add shadow method for Trace.isEnabled and shadow API to toggle the value (#5256)
    • πŸ›  Fix infinite loop when using CameraManager (#5269)
    • βž• Add shadow class for MediaController (#5266, #5395)
    • βž• Add shadow method for MediaMetadataRetriever.setDataSource and a shadow API to add bitmaps to a data source (#5279)
    • βž• Add shadow method for MediaMetadataRetriever.getScaledFrameAtTime and the ability to set scaled frames (#5279)
    • βž• Add shadow method for BluetoothDevice.getBluetoothClass and the ability to set the bluetooth class (#5277)
    • βž• Add shadow methods for PendingIntent.readPendingIntentOrNullFromParcel and PendingIntent.writePendingIntentOrNullToParcel (#5283)
    • πŸ‘Œ Improve fidelity of AccessibilityWindowInfo.equals (#5278)
    • βž• Add shadow methods for DevicePolicyManager.bindDeviceAdminServiceAsUser and DevicePolicyManager.getBindDeviceAdminTargetUsers and a shadow API to set the authorized users for these methods (#5287)
    • βž• Add shadow method for ContextImpl.getExternalCacheDirs (#5288)
    • βž• Add shadow method for WebSettings.getDefaultUserAgent to prevent crash (#5294)
    • βž• Add shadow method for MediaBrowserCompat.getSessionToken (#5301)
    • βž• Add shadow method for VMRuntime.getCurrentInstructionSet and shadow API to set the current instruction set (#5318)
    • βž• Add shadow methods for PowerManager.getCurrentThermalStatus, PowerManager.addThermalStatusListener, PowerManager.removeThermalStatusListener. Athermal, and a shadow API to set the current thermal status (#5297)
    • βž• Add support for opening a ParcelFileDescriptor in truncate and append modes (#5322)
    • βž• Add shadow method for UserManager.isUserUnlocked(UserHandle) and shadow API to set user unlocked status (#5323)
    • πŸ‘Œ Improve fidelity of DateFormat.get*DateFormat( #5314)
    • βž• Add shadows for ContextHubManager and ContextHubClient (#5340, #5399)
    • βž• Add support for AudioPlaybackCallback in ShadowAudioManager (#5342)
    • ⚑️ Update many ShadowUserManager methods to support profiles and add shadow method for UserManager.isManagedProfile(int) (#5346)
    • βž• Add shadow for RoleManager (#5357)
    • βž• Add shadow method for AccountManager.addOnAccountsUpdatedListener and shadow API to notify the listeners (#5347)
    • βž• Add shadow API to get AccountManager OnAccountsUpdateListeners (#5361)
    • βž• Add shadow method TelephonyManager.requestCellInfoUpdate and a shadow API to set the cell infos for the callbacks (#5355)
    • βž• Add shadow method for MediaCodec.getOutputFormat and the ability to set the output format (#5372)
    • βž• Add shadow method for AudioManager.isBluetoothScoAvailableOffCall and shadow API to set the value (#5364)
    • βž• Add more complete shadow implementation for TelecomManager.placeCall and shadow API to query information about outgoing calls (#5373)
    • βž• Add shadow APIs for allowing and denying calls to ShadowTelecomManager (#5374)
    • βž• Add shadow method for CrossProfileApps.startActivity and shadow APIs to peek/get/clear the started activities (#5387)
    • βž• Add shadow API to get all available loopers (#5371)
    • βž• Add shadow for android.media.AudioTrack (#5379)
    • βž• Add shadow for android.media.MediaCodecList (#5390, #5699)
    • βž• Add shadow methods for View.addOnAttachStateChangeListener and View.removeOnAttachStateChangeListener and test API to get the OnAttachStateChangeListeners (#5401)
    • πŸ“¦ Throw IllegalArgumentException in PackageManager.getInstallerPackageName if package name is not installed (#5403)
    • βž• Add shadow method for PackageManager.getUnsuspendablePackages (#5406)
    • βž• Add static factory method ShadowSensorManager.createSensorEvent(int, int) that takes a sensor type (#5398)
    • βž• Add shadow method for TelephonyManager.isRttSupported and a test API to set whether or not Rtt is supported (#5411)
    • βž• Add shadow methods for NfcAdapter.enableReaderMode, NfcAdapter.disableReaderMode, and some shadow API to work with reader mode (#5405)
    • βž• Add shadow for UserManager#isQuietModeEnabled (#5416)
    • πŸ‘Œ Improve fidelity of MediaCodec.dequeueOutputBuffer (#5409, #5466)
    • βž• Add shadow methods for AutofillManager.isAutofillSupported and AutofillManager.isEnabled and shadow API to set values returned (#5408)
    • βž• Add shadow method for WifiRttManager.isAvailable (#5429)
    • βž• Add shadow method for AccessibilityService.dispatchGesture and some shadow API to toggle and get the dispatched gestures (#5441)
    • βž• Add shadow method for Adding TelephonyManager.sendDialerSpecialCode and shadow API to get the values sent (#5444)
    • πŸ‘Œ Improve fidelity of Path copy constructor shadow implementation (#5444)
    • βž• Add shadow method for AppOpsManager.java.unsafeCheckOpRawNoThrow (#5448)
    • βž• Add shadow method for TelephonyManager.isHearingAidCompatibilitySupported and a shadow API method to set the value returned (#5450)
    • βž• Add shadow methods for DevicePolicyManager.getAffiliationIds and DevicePolicyManager.setAffiliationIds (#5452)
    • βž• Add shadow method for Canvas.drawRoundRect and shadow API to get information about the drawn round rects (#5451)
    • βž• Add shadow method for UserManager.getProfileParent (#5457)
    • βž• Add shadow method for DevicePolicyManager.isDeviceProvisioned and shadow API to set the value returned (#5461)
    • βž• Add shadow methods for DevicePolicyManager.getPermissionPolicy and DevicePolicyManager.setPermissionPolicy in ShadowDevicePolicyManager (#5453)
    • βž• Add a Configurer plugin that changes the behavior of the PackageManager.html.getInstallerPackageName shadow method to throw an exception (instead of returning null), which is consistent with real Android (#5465)
    • βž• Add shadow API to optionally enforce a notification limit to NotificationManager.notify (#5467)
    • πŸ›  Fix triggering broadcasts from explicit intents if data on intent is specified (#5482)
    • βž• Add shadow for android.telephony.ims.ImsMmTelManager system service and shadow API to set various pieces of state on the shadow (#5483, #5497)
    • πŸ‘‰ Make ShadowTrace sections thread aware (#5494)
    • πŸ›  Fix permission check when matching broadcast receivers (#5495)
    • πŸ”¨ Refactor ShadowWrangler to delegate to a ShadowMatcher for making SDK-level decisions (f5371b5, dda4709)
    • βž• Add shadow for android.media.MediaActionSound and shadow API to get the play counts (#5500)
    • βž• Add shadow method for DownloadManager#setDestinationInExternalPublicDir (#5489)
    • Include StatusBarNotification post times in ShadowNotificationManager (#5519)
    • βž• Add a more complete shadow method for TelecomManager.getDefaultOutgoingPhoneAccount and shadow API to to set (and reset) the default outgoing phone account (#5524)
    • βž• Add shadow method for BluetoothAdapter.isLeExtendedAdvertisingSupported and shadow API to set the value returned (#5515)
    • βž• Add shadow methods for AudioManager.registerAudioPolicy and AudioManager.unregisterAudioPolicy system APIs and shadow API to get information about the audio policies (#5538)
    • βž• Add shadow methods for TrafficStats.setThreadStatsTag and TrafficStats.getThreadStatsTag (#5541)
    • Create separate cache directory for getExternalCacheDir instead of using the external storage root directory (#5534)
    • ⚑️ Use provided executor in TelephonyManager.requestCellInfoUpdate and add shadow API to set the error details for the callback (#5543)
    • βž• Add more complete shadow methods for UserManager.isQuietModeEnabled and UserManager.requestQuietModeEnabled and shadow API to set whether a profile is locked (#5555)
    • βž• Add support for CameraManager.openCamera for older SDKs (21-27) (#5551)
    • βž• Add shadow method for CameraDeviceImpl.close (which is used in CameraDevice.close) (#5552)
    • βž• Add shadow method for ConnectivityManager.getRestrictBackgroundStatus and shadow API to set the returned value (#5556)
    • βž• Add shadow for android.service.voice.VoiceInteractionService and shadow APIs to get set UI hints and set the active service (#5537)
    • βž• Add shadow method for AudioManager.generateAudioSessionId that returns monotonically increasing values (#5559)
    • βž• Add shadow methods for NotificationManager.{getNotificationDelegate,canNotifyAsPackage,setNotificationDelegate} and shadow API ShadowNotificationManager.canNotifyAsPackage (#5565, #5573)
    • βž• Add shadow method for PackageManager.getPackagesHoldingPermissions (#5568)
    • βž• Add shadow method for TelephonyManager.getSimLocale and shadow API to set the returned value (#5582)
    • βž• Add shadow method ConnectivityManager.getProxyForNetwork and shadow API to set the returned value (#5570)
    • βž• Add shadow method for TelephonyManager.getDataNetworkType and shadow API to set the retired value (#5581)
    • βž• Add shadow method for Paint.setUnderlineText (#5585)
    • βž• Add support for MenuItem.setActionView(int) (#5603)
    • βž• Add support for writing and reading FileDescriptors in Parcel. Specifically this adds shadow methods for Parcel.nativeWriteFileDescriptor and Parcel.nativeReadFileDescriptor (#5588)
    • βž• Add shadow methods for DevicePolicyManager.isDeviceProvisioningConfigApplied and DevicePolicyManager.isDeviceProvisioningConfigApplied (#5599)
    • πŸ‘ Better support reading/writing SharedMemory objects to Parcels (#5612, #5756)
    • βž• Add shadow method for GradientDrawable.setStroke and shadow API methods to get the information about the stroke. (#5589)
    • βž• Add shadow API for setting default user agent in ShadowWebSettings (#5615)
    • βž• Add shadow method for TelephonyManager.isVoiceCapable and shadow API to set the value returned (#5606)
    • βž• Add shadow method for Android P Typeface.create static factory method (#5616)
    • βž• Add rudimentary support for Paint#breakText (#5607)
    • βž• Add shadow methods for Environment.isExternalStorageLegacy (both no-arg and 1-arg variants) and shadow API to set the value returned (#5617)
    • βž• Add shadow for android.service.voice.VoiceInteractionSession and many shadow API methods to work with the type (#5595)
    • βž• Add shadow method for TelephonyManager.getCarrierIdFromSimMccMnc and a shadow API method to set the value returned (#5618)
    • βž• Add shadow methods for WebView.goForward and WebView.canGoForward and shadow API to get the number of invocations of goForward (#5620)
    • βž• Add shadow method for WebView.getHitTestResult and shadow API to set the value returned (#5630)
    • βž• Add shadow for android.content.rollback.RollbackManager system API and some shadow API methods to get rollback information (#5621)
    • βž• Add shadow for android.media.audiofx.DynamicsProcessing and make significant improvements to ShadowAudioEffect (#5591)
    • βž• Add support for System.logW (#5634)
    • βž• Add ShadowCamera.removeCamera shadow API for removing cameras (#5651)
    • βž• Add an implementation for async setCookie to RoboCookieManager (#5653)
    • Support ADJUST_LOWER and ADJUST_RAISE in AudioManager.adjustStreamVolume shadow method (#5650)
    • βž• Add shadow for android.bluetooth.le.BluetoothLeScanner and add shadow API to BluetoothAdapter to work with BluetoothLeScanner (#5659)
    • βž• Add shadow method for TileService.startActivityAndCollapse(Intent) (#5664)
    • βž• Add shadow API method ShadowWebView.pushEntryToHistory(String) to improve fidelity of history in a WebView (#5654)
    • βž• Add builders for android.media.MediaCodecInfo and android.media.MediaCodecInfo.CodecCapabilities and a shadow API method ShadowMediaCodecList.addCodec (#5705)
    • ⚑️ Update DeviceConfig to populate additional display metrics (#5706)
    • πŸ‘Œ Improve fidelity of Activity#requestPermissions behavior (#5707)
    • ⚑️ Update ShadowPausedAsyncTaskLoader to allow setting a custom executor (#5708)
    • πŸ‘Œ Improve fidelity of password tokens in DevicePolicyManager (#5693)
    • βž• Add shadow methods for BluetoothA2dp.getConnectedDevices and BluetoothA2dp.getDevicesMatchingConnectionStates and shadow API to set the values returned (#5681)
    • βž• Add shadow for android.media.RingtoneManager (#5689)
    • βž• Add shadow method for MediaCodec.native_flush (to support MediaCodec.flush) (#5698)
    • βž• Add shadow methods for BluetoothHeadset.{startVoiceRecognition,stopVoiceRecognition,isAudioConnected} (#5660)
    • βž• Add shadow for android.os.BugreportManager and some shadow API to query state and trigger callbacks for bug reports #5675)
    • πŸ›  Fix handling of null admin in DevicePolicyManager.isUninstallBlocked() (#5720)
    • πŸ“¦ Implement shadow method for ApplicationPackageManager.isInstantApp (#5725)
    • πŸ‘Œ Improve fidelity related to input buffer ownership in ShadowMediaCodec (#5719)
    • ⚑️ Update ShadowSensorManager to support listeners registering more than one sensor type, as well as a shadow API method to query the registration for a (listener, sensor) pair (#5735)
    • βž• Add shadow method for ContentResolver.query(Uri uri, String[], Bundle, CancellationSignal) (#5729)
    • βž• Add SubscriptionInfoBuilder.setMcc and fix SubscriptionInfoBuilder.setMnc for SDK < Q (#5736)
    • βž• Add shadow method for LauncherApps.isPackageEnabled (#5691)
    • βž• Add shadow for android.media.session.MediaSessionManager (#5741)
    • βž• Add shadow methods for WallpaperManager.setBitmap and WallpaperManager.getWallpaperFile and a shadow API method to get the set bitmap (#5750)
    • βž• Add shadow methods for Android N system APIs ContextHubManager.getContextHubHandles and ContextHubManager.getContextHubInfo (#5760)
    • βž• Add shadow method for Activity.reportFullyDrawn and shadow API to check whether this method has been called
    • βž• Add shadow methods for UsageStatsManager.registerAppUsageLimitObserver, UsageStatsManager.unRegisterAppUsageLimitObserver, and shadow API to get the observers and trigger them (#5770)
    • βž• Add shadow methods for DevicePolicyManager.{getShort,setShort,getLong,setLong}SupportMessage (#5776)
    • βž• Add shadow methods for WallpaperManager.isWallpaperSupported and WallpaperManager.isSetWallpaperAllowed and shadow API to set the values returned (#5765)
    • βž• Add shadow for android.net.wifi.aware.WifiAwareManager, which includes the ability to create WiFI aware sessions (#5766)
    • βž• Add shadow method for LauncherApps.getActivityList and test API to set the values returned (#5771)
    • βž• Add shadow method for TileService#isLocked and shadow API to set the value returned (#5794)
    • πŸ‘Œ Improve fidelity of BitmapFactory.decodeFile by attempting to use the real bitmap file width and height (#5774)
    • βž• Add shadow methods for TextToSpeech.synthesizeToFile, TextToSpeech.isLanguageAvailable, TextToSpeech.setLanguage, and shadow APIs to configure the behavior of these methods (#5797)
    • βž• Add shadow method for WallpaperManager.getWallpaperInfo and the ability for tests to specify the wallpaper service component (#5781)
    • ⚑️ Use loose signatures on ShadowTelephonyManager.requestCellInfoUpdate. This is to continue supporting Java 8 in Robolectric 4.4. (#5835)
    • βž• Add shadow methods for InCallService.canAddCall, InCallService.setMuted, InCallService.setAudioRoute, InCallService.getCallAudioState, InCallService.requestBluetoothAudio, and some shadow API methods to modify the behavior of these methods (#5816)
    • βž• Add shadow for android.media.audiofx.Visualizer (#5818, #5826)
    • βž• Add shadow method of MediaPlayer.setDataSource(AssetFileDescriptor) (#5844)

    Misc improvements

    • βœ… Simplify single-parameter tests in ParameterizedRobolectricTestRunner (#5026)
    • πŸ‘ Allow extension point for running custom actions for unsupported SDKs (#5028)
    • πŸ›  Fix SandboxClassLoader classloader inheritance (#5036)
    • πŸ›  Fix noisy NPE in ShadowInstrumentation (#5063)
    • πŸ“‡ Create Android application specified in package metadata (#5039)
    • Tolerate gaps between ZIP entries when jumping between Local File Headers (#5120)
    • βž• Add extension points so child tests can be created (#5132)
    • πŸ‘Œ Improve thread safety of many shadows (#5018, #5087, #5094, #5144, #5193, #5231, #5306, #5445, #5703, #5676, #5742)
    • Stop depending on javac annotation processing internals (#5155)
    • βž• Add a way to specify classes to not instrument based on a regex (#5264)
    • πŸ‘‰ Make reading binary resource zips more performant (#5309)
    • πŸ›  Fix issue transitioning to RESUMED state in ActivityScenario (#5332, #5331)
    • βž• Add a plugin mechanism to provide a custom ShadowWrangler specialization (#5268)
    • πŸ‘ Better support AssumptionViolatedException in RobolectricTestRunner (#5359, #5704)
    • πŸ›  Fix Util.getJavaVersion to support double-digit values (#5381)
    • πŸ›  Fix duplicate call to ContentProvider.onCreate (#5393)
    • βœ… Use AAPT for R class (and other cleanup) in shadows.support.v4 tests (#5430)
    • Clean up autoservice usage and dependencies (#5432)
    • Mark fields and methods added to classes as synthetic (#5418)
    • πŸ“¦ Stop shadowing ApplicationPackageManager's constructor (#5455)
    • ⬆️ Upgrade to Android Gradle Plugin 3.5.3 and Gradle 5.4.1 (#5498)
    • CircleCI improvements (#5498, a64beaf, #5709, #5700, #5761, #5770, #5769 )
    • βš™ Run google-java-format check on CircleCI (#5769)
    • βž• Add expectLogMessageWithThrowable to ExpectedLogMessagesRule (#5516) and other fixes/improvements to ExpectedLogMessagesRule (#5640, #5657, #5680)
    • ⚑️ Update BouncyCastle security provider due CVE-2018-1000613 (#5572)
    • πŸ“¦ Avoid instrumenting additional packages
      ** Jetpack Compose (#5622)
      ** io.mockk (#5169)
      ** org.bouncycastle and org.conscrypt (#5845)
    • ⚑️ Update RoboMonitoringInstrumentation to post shadowActivity.callOnActivityResult asynchronously (#5671, #5674)
    • ⚑️ Update ShadowServiceManager to lazily create binder proxies (#5716, #5714) and fix issues in ShadowServiceManager (#5717, #5722)
    • βœ… Use guava's ByteStreams to read and copy streams (#5726)
    • Preload android.net.Uri in Android Q+ (#5733)
    • πŸ›  Fix Scheduler return values in PAUSED LooperMode, and support Scheduler#size (#5001)
    • Throw if ShadowPausedLooper APIs are used on a quit looper (#5499)
    • βœ‚ Removed the pegdown-doclet Markdown doclet gradle plugin due to Java 10+ incompatibility (#5743)
    • Converted all Robolectric Markdown Javadoc to regular Javadoc (#5746, #5747, #5753, #5759)
    • βž• Add BackgroundTestRule to simplify running test code in a background thread (#5732)
    • βž• Add BackgroundExecutor.runInBackground(Callable) helper method (similar to the existing BackgroundExecutor.runInBackground(Runnable) (#5730)
    • πŸ‘Œ Improve support for MockK (#5169)
    • πŸ›  Fix 'Duplicate key' error when running ./gradlew upload (#5788)
    • βž• Add robolectric.util.Logger.lifecycle method and use it to log some lifecycle events in RobolectricTestRunner (#5824)
    • ⬇️ Drop maven-ant-tasks dependency (due to CVE) and fetch from Maven manually (#5833, #5842, #5849, #5854, #5855)
    • Generate reflector class with valid access (#5841)
    • βž• Add shadow API to ShadowNetwork to determine whether a socket is bound, or how many sockets are bound (#5836)
    • πŸ‘ Allow tests to configure value returned by P+'s Application.getProcessName (#5825)
    • βž• Add better support for Conscrypt (#5851)
  • v4.4-beta

    August 15, 2020
  • v4.4-alpha Changes

    July 23, 2020

    πŸš€ Robolectric 4.4 Alpha 2 is an alpha release. APIs are very likely to change and new features will be added. We'd love feedback from testing this version, but we recommend you don't rely on it in your test suite.

    This is a massive release in terms of improvements to Android compatibility. The most noticeable item in the release is that the new PAUSED looper mode is now the default. You can read about the PAUSED looper in more detail here: http://robolectric.org/blog/2019/06/04/paused-looper/.

    Note:

    πŸš€ 1. Not all changes are listed in the release notes. There were many other minor changes (such as dependency version bumps) that weren't included in this list for brevity. For all changes view the comparison to 4.3.1. πŸš€ 2. Some of the pull requests in this release may contain duplicate changes from other pull requests in this release. We apologize for this messy history, it was the result of some misconfigured code sync tool. We’ve taken measures to ensure it doesn’t happen any more.

    πŸ‘ Android SDK/JVM support

    • βž• Add support for Android Q final (#5289, #5292)
    • πŸ‘Œ Support running on Java 11 (#5479)
    • πŸ‘Œ Support running on Java 13 (#5550

    πŸ—„ Deprecations

    • πŸ—„ Deprecate LooperMode LEGACY in favor of PAUSED (#5490), and default to PAUSED looper mode (#5491)
    • 🚚 Accessibility checking is now deprecated and has been moved into a separate maven artifact org.robolectric:plugin-accessibility-deprecated. Accessibility checking will be removed entirely from Robolectric 4.5. Please switch to Espresso for accessibility checking. (#5547)
    • πŸ—„ Deprecate ShadowContentResolver shadow API because they do not work with ContentProviderClient (#5376)
    • ⚑️ Deprecate ShadowLocationManager.getLocationUpdateListeners and ShadowLocationManager.getLocationUpdateListeners (#5150)
    • βœ… Make it an error to run on Q with an unsupported java version instead of just silently skipping tests (#5290)
    • πŸ—„ Deprecate Robolectric's custom cursor implementation (#5613)

    βœ… Android support / Robolectric test API improvements

    • πŸ›  Fix bug in ShadowImageDecoder.decodeBitmap (#4966)
    • Use real setting for WIFI_SCAN_ALWAYS_AVAILABLE (#4968)
    • βž• Add a shadow for Font.Builder (#4993)
    • βž• Add killProcess implementation to ShadowProcess (#4985)
    • βž• Add a shadow for CallLog.Calls (#4996)
    • βž• Add a shadow for CallScreeningService (#4997)
    • βž• Add several shadows for camera2 classes (#4874)
    • βž• Add option to avoid calling ShadowApplication.onServiceDisconnected in ShadowApplication.unbindService (#4979)
    • βž• Add ability to simulate Bluetooth unavailable in ShadowBluetoothAdapter (#5002)
    • πŸ“¦ Implement ShadowApplicationPackageManager.getApplicationIcon(ApplicationInfo) (#5005)
    • βž• Add ability to simulate SecurityExceptions in bindService (#4980)
    • βž• Add ability to simulate enabled/disabled networks in ShadowWifiManager (#4974)
    • βž• Add ability to simulate wifi usability system APIs in ShadowWifiManager (#5168)
    • βž• Add null check in ShadowWifiManager.addNetwork (#5014)
    • βž• Add shadow implementation of ShadowTelephonyManager#getDataState (#5003)
    • Fall back to Android's implementation of getResourcesForApplication (#4969)
    • Implement ShadowTypeface.equals and ShadowTypeface.hashCode (#4992)
    • βž• Add ability to make ShadowContentResolver.registerContentObserver throw an exception (#4988)
    • Implement ShadowSubscriptionManager.getActiveSubscriptionInfoCountMax (#5010)
    • βž• Add ability to set system dialer package in ShadowTelecomManager (#4986)
    • Implement ShadowSensorManager.registerListener 5-arg overload (#5014)
    • βž• Add ability to get last flags set in ShadowUIModeManager (#5027)
    • βž• Add a shadow for BluetoothA2dp (#5034)
    • βž• Add shadow implementation for BluetoothDevice.createRfcommSocketToServiceRecord (#5034)
    • βž• Add shadow implementations for BluetoothDevice.setPin and BluetoothDevice.setPairingConfirmation (and ability to get the values set) (#5116)
    • βž• Adding shadow implementations of BluetoothDevice.getAlias and BlueToothDevice.getAliasName and related test APIs (#5222)
    • βž• Adds the ability to get broadcast intents sent to a specific user (#5045)
    • Validate intents passed to start/stop/bindService (#5053)
    • Complete rewrite of ShadowLocationManager to improve fidelity (#5035, #5062, #5152, #5587, #5666)
    • βž• Add ability to clear broadcast intents in ShadowContextWrapper (#5066)
    • πŸ›  Fix package name ShadowApplicationPackageManager's Activity Chooser (#5068)
    • βž• Add shadow implementation for MediaPlayer#setDataSource(Context, Uri) (#5064)
    • βž• Add shadow implementation for UserManager.getUserHandle(int) (#5065)
    • βž• Add shadow implementations for DevicePolicyManager.setSystemUpdatePolicy and DevicePolicyManager.getSystemUpdatePolicy (#5069)
    • βœ‚ Remove ShadowOverscroller (#5081)
    • βž• Add ability to simulate return value of AccessibilityService.getWindows list in ShadowAccessibilityService (#5083)
    • πŸ›  Fix bug in ShadowParcel.writeByteArray (#5089)
    • βž• Add shadow implementation for UserManager.getUserName (#5099)
    • πŸ‘Œ Improve fidelity of ShadowTime#parse3339 (#5101)
    • βž• Add shadow for BiometricManager (#5072)
    • Propagate RemoteException from Binder#onTransact method (#4984)
    • βž• Add shadow for android.service.notification.NotificationListenerService.Ranking (#5113)
    • βž• Add support for VibrationEffect.Prebaked in ShadowSystemVibrator (#5119
    • βž• Add the ability to set Tx and Rx packets/bytes for ShadowTrafficStats (#5121)
    • βž• Add shadow implementation for Activity.getCallingPackage (and the ability to set it) (#5126)
    • βž• Add shadows for several telephony classes (android.telecom.Call, android.telecom.InCallAdapter, android.telecom.InCallService, android.telecom.Phone) (#5107)
    • πŸ‘Œ Improve fidelity of ShadowCookieManager.removeSessionCookies (#5130)
    • πŸ‘Œ Improve fidelity of OpEntry.getTime() and OpEntry.getDuration() in Q (#5133)
    • 0️⃣ Set default NetworkCapabilities for the two Robolectric created Networks (#5129)
    • Set the mimetype in ShadowBitmapFactory.decodeStream() (#5128)
    • βž• Add module support for ShadowPackageManager and ShadowApplicationPackageManager (#5136)
    • βž• Add the ability to set the external storage directory in ShadowEnvironment (#5140)
    • βž• Add support for the dataChanged API in ShadowBackupManager (#5137)
    • βž• Add ShadowContentResolver.registerInputStreamSupplier (#5142)
    • πŸ”” Notify settings ContentResolver when settings change (#5138)
    • Include size and mtime members in Os.stat variants (#5148)
    • Implement ShadowInstrumentation.execStartActivity variant with UserHandle (#5096)
    • βž• Add ability to add entries to ShadowDropBoxManager (#5160)
    • πŸ›  Fix ShadowSigningInfo parceling (#5163)
    • βž• Add ability to set Build.VERSION.SECURITY_PATCH (#5173), Build.PRODUCT (#5304), Build.BRAND (#5566), and Build.HARDWARE (#5619)
    • βž• Add support for DisplayManager BrightnessConfiguration APIs (#5170)
    • βž• Add ability to simulate location power save modes in ShadowPowerManager (#5176)
    • βž• Add shadow method and test API for PowerManager.isLightDeviceIdleMode (#5226)
    • βž• Add support for Android Q usb port statuses in ShadowUsbManager (#5175)
    • βž• Add ability to simulate sending and downloading multimedia messages in ShadowSmsManager (#5177)
    • βž• Add ability to query the number of times a WebView was reloaded (#5182)
    • βž• Add ability to simulate WebViewClient and WebViewClient callbacks on page loads (#5188, #5199)
    • βž• Add shadow method for WebView.getTitle (#5200)
    • βž• Add test APIs to check if WebViewDatabase.clearFormData was called (#5201)
    • βž• Add ability to override autofill service component name to ShadowAutofillManager (#5181)
    • βž• Add ability to construct AttestedKeyPair objects (#5183)
    • βž• Add shadow method for CameraCaptureSessionImpl.capture (#5191)
    • βž• Add shadow method and test APIs for MediaScannerConnection.scanFile (#5178)
    • βž• Add synchronous support to ShadowMediaCodec and the ability to apply fake codecs (#5195)
    • βž• Add shadow methods for CameraParameters metering and focus areas and test APIs (#5189)
    • βž• Add shadow method for AudioManager.getActiveRecordingConfigurations and test APIs (#5198)
    • βž• Add ShadowAudioRecord (#5202)
    • βž• Add several shadow methods for SliceManager (#5227)
    • βž• Add shadow methods for new Android Q variants of setPackagesSuspended (#5135)
    • βž• Add shadow method and test APIs for AccessibilityManager.sendAccessibilityEvent (#5192)
    • βž• Add ability to log time in ShadowLog (#5224)
    • βž• Add shadow for SuspendDialogInfo system API (#5232)
    • βž• Add shadow method for PackageManager.canonicalToCurrentPackageNames and the ShadowPackageManageraddCanonicalName test API (#5233)
    • βž• Add better support for camera2 CaptureRequestBuilder (#5230)
    • βž• Add shadow method for Os.sysconf and a shadow API to set sysconf values (#5247)
    • βž• Add shadow method for PackageManager.setDistractingPackageRestrictions and shadow API to get the set value (#5248)
    • βž• Add shadow method for Bitmap.extractAlpha(Paint, int[]) (#5240)
    • βž• Add the ability to set the user id in ContextImpl (#5253)
    • πŸ›  Fix some bugs in ShadowStorageManager StorageVolume logic (#5251, #5250)
    • βž• Add shadow method for Trace.isEnabled and shadow API to toggle the value (#5256)
    • πŸ›  Fix infinite loop when using CameraManager (#5269)
    • βž• Add shadow class for MediaController (#5266, #5395)
    • βž• Add shadow method for MediaMetadataRetriever.setDataSource and a shadow API to add bitmaps to a data source (#5279)
    • βž• Add shadow method for MediaMetadataRetriever.getScaledFrameAtTime and the ability to set scaled frames (#5279)
    • βž• Add shadow method for BluetoothDevice.getBluetoothClass and the ability to set the bluetooth class (#5277)
    • βž• Add shadow methods for PendingIntent.readPendingIntentOrNullFromParcel and PendingIntent.writePendingIntentOrNullToParcel (#5283)
    • πŸ‘Œ Improve fidelity of AccessibilityWindowInfo.equals (#5278)
    • βž• Add shadow methods for DevicePolicyManager.bindDeviceAdminServiceAsUser and DevicePolicyManager.getBindDeviceAdminTargetUsers and a shadow API to set the authorized users for these methods (#5287)
    • βž• Add shadow method for ContextImpl.getExternalCacheDirs (#5288)
    • βž• Add shadow method for WebSettings.getDefaultUserAgent to prevent crash (#5294)
    • βž• Add shadow method for MediaBrowserCompat.getSessionToken (#5301)
    • βž• Add shadow method for VMRuntime.getCurrentInstructionSet and shadow API to set the current instruction set (#5318)
    • βž• Add shadow methods for PowerManager.getCurrentThermalStatus, PowerManager.addThermalStatusListener, PowerManager.removeThermalStatusListener. Athermal, and a shadow API to set the current thermal status (#5297)
    • βž• Add support for opening a ParcelFileDescriptor in truncate and append modes (#5322)
    • βž• Add shadow method for UserManager.isUserUnlocked(UserHandle) and shadow API to set user unlocked status (#5323)
    • πŸ‘Œ Improve fidelity of DateFormat.get*DateFormat( #5314)
    • βž• Add shadows for ContextHubManager and ContextHubClient (#5340, #5399)
    • βž• Add support for AudioPlaybackCallback in ShadowAudioManager (#5342)
    • ⚑️ Update many ShadowUserManager methods to support profiles and add shadow method for UserManager.isManagedProfile(int) (#5346)
    • βž• Add shadow for RoleManager (#5357)
    • βž• Add shadow method for AccountManager.addOnAccountsUpdatedListener and shadow API to notify the listeners (#5347)
    • βž• Add shadow API to get AccountManager OnAccountsUpdateListeners (#5361)
    • βž• Add shadow method TelephonyManager.requestCellInfoUpdate and a shadow API to set the cell infos for the callbacks (#5355)
    • βž• Add shadow method for MediaCodec.getOutputFormat and the ability to set the output format (#5372)
    • βž• Add shadow method for AudioManager.isBluetoothScoAvailableOffCall and shadow API to set the value (#5364)
    • βž• Add more complete shadow implementation for TelecomManager.placeCall and shadow API to query information about outgoing calls (#5373)
    • βž• Add shadow APIs for allowing and denying calls to ShadowTelecomManager (#5374)
    • βž• Add shadow method for CrossProfileApps.startActivity and shadow APIs to peek/get/clear the started activities (#5387)
    • βž• Add shadow API to get all available loopers (#5371)
    • βž• Add shadow for android.media.AudioTrack (#5379)
    • βž• Add shadow for android.media.MediaCodecList (#5390, #5699)
    • βž• Add shadow methods for View.addOnAttachStateChangeListener and View.removeOnAttachStateChangeListener and test API to get the OnAttachStateChangeListeners (#5401)
    • πŸ“¦ Throw IllegalArgumentException in PackageManager.getInstallerPackageName if package name is not installed (#5403)
    • βž• Add shadow method for PackageManager.getUnsuspendablePackages (#5406)
    • βž• Add static factory method ShadowSensorManager.createSensorEvent(int, int) that takes a sensor type (#5398)
    • βž• Add shadow method for TelephonyManager.isRttSupported and a test API to set whether or not Rtt is supported (#5411)
    • βž• Add shadow methods for NfcAdapter.enableReaderMode, NfcAdapter.disableReaderMode, and some shadow API to work with reader mode (#5405)
    • βž• Add shadow for UserManager#isQuietModeEnabled (#5416)
    • πŸ‘Œ Improve fidelity of MediaCodec.dequeueOutputBuffer (#5409, #5466)
    • βž• Add shadow methods for AutofillManager.isAutofillSupported and AutofillManager.isEnabled and shadow API to set values returned (#5408)
    • βž• Add shadow method for WifiRttManager.isAvailable (#5429)
    • βž• Add shadow method for AccessibilityService.dispatchGesture and some shadow API to toggle and get the dispatched gestures (#5441)
    • βž• Add shadow method for Adding TelephonyManager.sendDialerSpecialCode and shadow API to get the values sent (#5444)
    • πŸ‘Œ Improve fidelity of Path copy constructor shadow implementation (#5444)
    • βž• Add shadow method for AppOpsManager.java.unsafeCheckOpRawNoThrow (#5448)
    • βž• Add shadow method for TelephonyManager.isHearingAidCompatibilitySupported and a shadow API method to set the value returned (#5450)
    • βž• Add shadow methods for DevicePolicyManager.getAffiliationIds and DevicePolicyManager.setAffiliationIds (#5452)
    • βž• Add shadow method for Canvas.drawRoundRect and shadow API to get information about the drawn round rects (#5451)
    • βž• Add shadow method for UserManager.getProfileParent (#5457)
    • βž• Add shadow method for DevicePolicyManager.isDeviceProvisioned and shadow API to set the value returned (#5461)
    • βž• Add shadow methods for DevicePolicyManager.getPermissionPolicy and DevicePolicyManager.setPermissionPolicy in ShadowDevicePolicyManager (#5453)
    • βž• Add a Configurer plugin that changes the behavior of the PackageManager.html.getInstallerPackageName shadow method to throw an exception (instead of returning null), which is consistent with real Android (#5465)
    • βž• Add shadow API to optionally enforce a notification limit to NotificationManager.notify (#5467)
    • πŸ›  Fix triggering broadcasts from explicit intents if data on intent is specified (#5482)
    • βž• Add shadow for android.telephony.ims.ImsMmTelManager system service and shadow API to set various pieces of state on the shadow (#5483, #5497)
    • πŸ‘‰ Make ShadowTrace sections thread aware (#5494)
    • πŸ›  Fix permission check when matching broadcast receivers (#5495)
    • πŸ”¨ Refactor ShadowWrangler to delegate to a ShadowMatcher for making SDK-level decisions (f5371b5, dda4709)
    • βž• Add shadow for android.media.MediaActionSound and shadow API to get the play counts (#5500)
    • βž• Add shadow method for DownloadManager#setDestinationInExternalPublicDir (#5489)
    • Include StatusBarNotification post times in ShadowNotificationManager (#5519)
    • βž• Add a more complete shadow method for TelecomManager.getDefaultOutgoingPhoneAccount and shadow API to to set (and reset) the default outgoing phone account (#5524)
    • βž• Add shadow method for BluetoothAdapter.isLeExtendedAdvertisingSupported and shadow API to set the value returned (#5515)
    • βž• Add shadow methods for AudioManager.registerAudioPolicy and AudioManager.unregisterAudioPolicy system APIs and shadow API to get information about the audio policies (#5538)
    • βž• Add shadow methods for TrafficStats.setThreadStatsTag and TrafficStats.getThreadStatsTag (#5541)
    • Create separate cache directory for getExternalCacheDir instead of using the external storage root directory (#5534)
    • ⚑️ Use provided executor in TelephonyManager.requestCellInfoUpdate and add shadow API to set the error details for the callback (#5543)
    • βž• Add more complete shadow methods for UserManager.isQuietModeEnabled and UserManager.requestQuietModeEnabled and shadow API to set whether a profile is locked (#5555)
    • βž• Add support for CameraManager.openCamera for older SDKs (21-27) (#5551)
    • βž• Add shadow method for CameraDeviceImpl.close (which is used in CameraDevice.close) (#5552)
    • βž• Add shadow method for ConnectivityManager.getRestrictBackgroundStatus and shadow API to set the returned value (#5556)
    • βž• Add shadow for android.service.voice.VoiceInteractionService and shadow APIs to get set UI hints and set the active service (#5537)
    • βž• Add shadow method for AudioManager.generateAudioSessionId that returns monotonically increasing values (#5559)
    • βž• Add shadow methods for NotificationManager.{getNotificationDelegate,canNotifyAsPackage,setNotificationDelegate} and shadow API ShadowNotificationManager.canNotifyAsPackage (#5565, #5573)
    • βž• Add shadow method for PackageManager.getPackagesHoldingPermissions (#5568)
    • βž• Add shadow method for TelephonyManager.getSimLocale and shadow API to set the returned value (#5582)
    • βž• Add shadow method ConnectivityManager.getProxyForNetwork and shadow API to set the returned value (#5570)
    • βž• Add shadow method for TelephonyManager.getDataNetworkType and shadow API to set the retired value (#5581)
    • βž• Add shadow method for Paint.setUnderlineText (#5585)
    • βž• Add support for MenuItem.setActionView(int) (#5603)
    • βž• Add support for writing and reading FileDescriptors in Parcel. Specifically this adds shadow methods for Parcel.nativeWriteFileDescriptor and Parcel.nativeReadFileDescriptor (#5588)
    • βž• Add shadow methods for DevicePolicyManager.isDeviceProvisioningConfigApplied and DevicePolicyManager.isDeviceProvisioningConfigApplied (#5599)
    • πŸ‘ Better support reading/writing SharedMemory objects to Parcels (#5612)
    • βž• Add shadow method for GradientDrawable.setStroke and shadow API methods to get the information about the stroke. (#5589)
    • βž• Add shadow API for setting default user agent in ShadowWebSettings (#5615)
    • βž• Add shadow method for TelephonyManager.isVoiceCapable and shadow API to set the value returned (#5606)
    • βž• Add shadow method for Android P Typeface.create static factory method (#5616)
    • βž• Add rudimentary support for Paint#breakText (#5607)
    • βž• Add shadow methods for Environment.isExternalStorageLegacy (both no-arg and 1-arg variants) and shadow API to set the value returned (#5617)
    • βž• Add shadow for android.service.voice.VoiceInteractionSession and many shadow API methods to work with the type (#5595)
    • βž• Add shadow method for TelephonyManager.getCarrierIdFromSimMccMnc and a shadow API method to set the value returned (#5618)
    • βž• Add shadow methods for WebView.goForward and WebView.canGoForward and shadow API to get the number of invocations of goForward (#5620)
    • βž• Add shadow method for WebView.getHitTestResult and shadow API to set the value returned (#5630)
    • βž• Add shadow for android.content.rollback.RollbackManager system API and some shadow API methods to get rollback information (#5621)
    • βž• Add shadow for android.media.audiofx.DynamicsProcessing and make significant improvements to ShadowAudioEffect (#5591)
    • βž• Add support for System.logW (#5634)
    • βž• Add ShadowCamera.removeCamera shadow API for removing cameras (#5651)
    • βž• Add an implementation for async setCookie to RoboCookieManager (#5653)
    • Support ADJUST_LOWER and ADJUST_RAISE in AudioManager.adjustStreamVolume shadow method (#5650)
    • βž• Add shadow for android.bluetooth.le.BluetoothLeScanner and add shadow API to BluetoothAdapter to work with BluetoothLeScanner (#5659)
    • βž• Add shadow method for TileService.startActivityAndCollapse(Intent) (#5664)
    • βž• Add shadow API method ShadowWebView.pushEntryToHistory(String) to improve fidelity of history in a WebView (#5654)
    • βž• Add builders for android.media.MediaCodecInfo and android.media.MediaCodecInfo.CodecCapabilities and a shadow API method ShadowMediaCodecList.addCodec (#5705)
    • ⚑️ Update DeviceConfig to populate additional display metrics (#5706)
    • πŸ‘Œ Improve fidelity of Activity#requestPermissions behavior (#5707)
    • ⚑️ Update ShadowPausedAsyncTaskLoader to allow setting a custom executor (#5708)
    • πŸ‘Œ Improve fidelity of password tokens in DevicePolicyManager (#5693)
    • βž• Add shadow methods for BluetoothA2dp.getConnectedDevices and BluetoothA2dp.getDevicesMatchingConnectionStates and shadow API to set the values returned (#5681)
    • βž• Add shadow for android.media.RingtoneManager (#5689)
    • βž• Add shadow method for MediaCodec.native_flush (to support MediaCodec.flush) (#5698)
    • βž• Add shadow methods for BluetoothHeadset.{startVoiceRecognition,stopVoiceRecognition,isAudioConnected} (#5660)
    • βž• Add shadow for android.os.BugreportManager and some shadow API to query state and trigger callbacks for bug reports #5675)
    • πŸ›  Fix handling of null admin in DevicePolicyManager.isUninstallBlocked() (#5720)
    • πŸ“¦ Implement shadow method for ApplicationPackageManager.isInstantApp (#5725)
    • πŸ‘Œ Improve fidelity related to input buffer ownership in ShadowMediaCodec (#5719)
    • ⚑️ Update ShadowSensorManager to support listeners registering more than one sensor type, as well as a shadow API method to query the registration for a (listener, sensor) pair (#5735)
    • βž• Add shadow method for ContentResolver.query(Uri uri, String[], Bundle, CancellationSignal) (#5729)

    Misc improvements

    • βœ… Simplify single-parameter tests in ParameterizedRobolectricTestRunner (#5026)
    • πŸ‘ Allow extension point for running custom actions for unsupported SDKs (#5028)
    • πŸ›  Fix SandboxClassLoader classloader inheritance (#5036)
    • πŸ›  Fix noisy NPE in ShadowInstrumentation (#5063)
    • πŸ“‡ Create Android application specified in package metadata (#5039)
    • Tolerate gaps between ZIP entries when jumping between Local File Headers (#5120)
    • βž• Add extension points so child tests can be created (#5132)
    • πŸ‘Œ Improve thread safety of many shadows (#5018, #5087, #5094, #5144, #5193, #5231, #5306, #5445, #5703, #5676 )
    • Stop depending on javac annotation processing internals (#5155)
    • βž• Add a way to specify classes to not instrument based on a regex (#5264)
    • πŸ‘‰ Make reading binary resource zips more performant (#5309)
    • πŸ›  Fix issue transitioning to RESUMED state in ActivityScenario (#5332, #5331)
    • βž• Add a plugin mechanism to provide a custom ShadowWrangler specialization (#5268)
    • πŸ‘ Better support AssumptionViolatedException in RobolectricTestRunner (#5359, #5704)
    • πŸ›  Fix Util.getJavaVersion to support double-digit values (#5381)
    • πŸ›  Fix duplicate call to ContentProvider.onCreate (#5393)
    • βœ… Use AAPT for R class (and other cleanup) in shadows.support.v4 tests (#5430)
    • Clean up autoservice usage and dependencies (#5432)
    • Mark fields and methods added to classes as synthetic (#5418)
    • πŸ“¦ Stop shadowing ApplicationPackageManager's constructor (#5455)
    • ⬆️ Upgrade to Android Gradle Plugin 3.5.3 and Gradle 5.4.1 (#5498)
    • CircleCI improvements (#5498, a64beaf, #5709, #5700)
    • βž• Add expectLogMessageWithThrowable to ExpectedLogMessagesRule (#5516) and other fixes/improvements to ExpectedLogMessagesRule (#5640, #5657, #5680)
    • ⚑️ Update BouncyCastle security provider due CVE-2018-1000613 (#5572)
    • πŸ“¦ Avoid instrumenting additional packages
      ** Jetpack Compose (#5622)
    • ⚑️ Update RoboMonitoringInstrumentation to post shadowActivity.callOnActivityResult asynchronously (#5671, #5674)
    • ⚑️ Update ShadowServiceManager to lazily create binder proxies (#5716, #5714) and fix issues in ShadowServiceManager (#5717, #5722)
    • βœ… Use guava's ByteStreams to read and copy streams (#5726)
    • Preload android.net.Uri in Android Q+ (#5733)
    • πŸ›  Fix Scheduler return values in PAUSED LooperMode, and support Scheduler#size (#5001)
    • Throw if ShadowPausedLooper APIs are used on a quit looper (#5499)

    πŸ‘‰ Use Robolectric:

    testCompile "org.robolectric:robolectric:4.4-alpha-2"
    
  • v4.3.1

    October 11, 2019
  • v4.3 Changes

    May 30, 2019

    πŸš€ This release introduces a new PAUSED Looper mode, enhanced Espresso compatibility, support for Android Q Beta 2, and numerous SDK support improvements and bug fixes

    πŸ”‹ Features

    • πŸ‘Œ Support Android Q beta 2 (build 5415296). [1717fb1]
    • πŸ‘Œ Support for new PAUSED Looper mode.
    • πŸ‘Œ Support clicking menu items via Espresso [issue #4889]
    • More realistically measure and layout Android text views

    βœ… Android SDK support and Test API changes

    • πŸ‘‰ Use real OverScroller in PAUSED LooperMode. [4337639]
    • βž• Add ShadowDevicePolicyManager#isLockTaskPermitted(String).
    • βž• Add Locale methods to Shadow for CaptioningManager.
    • βž• Add enabling/disabling data in ShadowTelephonyManager. [issue #4844]
    • βž• Add an initial shadow for the LauncherApps System Service. [issue #4837]
    • βž• Add ShadowUserManager.removeUser(UserHandle) [issue #4854]
    • βž• Add IntentSenderRequest for startIntentSenderForResult methods. [issue #4870]
    • Shadow night display ColorDisplayManager methods
    • βž• Add getPasswordComplexity support to ShadowDevicePolicyManager [issue #4878]
    • βž• Add shadow implementation for ShadowDexFile.isDexOptNeeded. [issue #4886]
    • Shadow DisplayManagerGlobal#getStableDisplaySize [issue #4838]
    • Shadow ContextImpl.startActivityAsUser [issue #4899]
    • Shadow implementation of android.hardware.HardwareBuffer [issue #4895]
    • βž• Add shadow for ShadowAppOpsManager#noteProxyOpNoThrow. [issue #4906]
    • βž• Add support for new Android Q fields to EventBuilder [issue #4905]
    • βž• Add support for UsageStatsManager#getUsageSource() [issue #4920]
    • πŸ‘Œ Support stopForeground(int) in ShadowService. [issue #4919]
    • πŸ‘Œ Support ShadowSensor#getMaximumRange [issue #4881]
    • βž• Add support for passing resultCode through to broadcasts intents [issue #4917]
    • πŸ›  Fix activities leaking between test cases [issue #4930]
    • πŸ“¦ Fall back to Android's implementation of PackageManager.getPackageArchiveInfo [issue #4928]
    • βž• Add ShadowPausedAsyncTask#overrideExecutor API to replace waitForIdle. [issue #4950]
    • βž• Add API ShadowApplicationPackageManager.getLeanbackLaunchIntentForPackage() (wraps getLaunchIntentForPackage()) [c16c3bf]
    • βž• Add new shadow Looper APIs for retrieving the scheduled time for tasks. [6494bde]
    • βž• Added Robolectric shadow for TotalCaptureResult. [8e1e585]
    • βž• Add ShadowLooper#isIdle [f4a5d49]
    • Create APIs for executing tasks on real background threads in PAUSED looper mode. [d29bf89]
    • βž• Add get/setLockTaskPackages support to DevicePolicyManager [b1ecc5a]
    • βž• Add implementation of - ShadowSubscriptionManager#getAvailableSubscriptionInfoList - ShadowSubscriptionManager#setAvailableSubscriptionInfoList - ShadowSubscriptionManager#setAvailableSubscriptionInfos - SubscriptionInfoBuilder#setMnc [95bac4a]
    • Modify ShadowLocationManager to respect LOCATION_MODE. [348d0d2]
    • πŸ‘‰ Make ActivityController#recreate aware of the current lifecycle state [7cc5b42]
    • Implement ActivityManager#isBackgroundRestricted() [4cbe349]
    • UiModeManager [78a4eec]
    • Set different values for each of OsConstants errno values [aeadc29]
    • βž• Add ShadowIsoDep [2e94093]
    • βž• Add ShadowBluetoothGatt.connect() [8cffa29]
    • Implement SubscriptionManager.getPhoneId() with a map between subscription IDs and phone IDs. [01ea680]
    • βž• Add torch setting capabilities to ShadowCameraManager. [f25ec77]
    • βž• Add method to ShadowContextWrapper to expose the options of the most recently started activity [da1bace]
    • βž• Add setInMultiWindowMode() to change multi window state for ShadowActivity. [9b2af0b]
    • πŸ‘Œ Supports setProfileClass & setIsEmbedded in SubscriptionInfoBuilder [4c74611]
    • πŸ‘Œ Supports EuiccManager#getEid in ShadowEuiccManager [e64f675]
    • πŸ“Œ Fake out a minimal implementation of ShadowSliceManager.getPinnedSlices(). [2f7aa83]
    • βž• Add setSeedAccountType() for ShadowUserManager [70d712f]
    • πŸ‘ Allow delivering broadcasts by class name. [665000d]
    • βž• Add shadow for ColorDisplayManager per-app grayscale [095c527]
    • βž• Add ShadowApplication#clearRegisteredReceivers helper method [c0d1719]
    • ✨ Enhance ShadowBroadcastReceiver to allow testing async receivers [78c3998]
    • βž• Add supportsMultipleUsers() & setSupportsMultipleUsers() for ShadowUserManager [50ec6ed]
    • πŸ‘Œ Support tag in ShadowWakeLock [3137c1c]
    • βž• Add createConfirmFactoryResetCredentialIntent to ShadowKeyguardManager [1d20033]
    • ShadowInputDevice: Add shadow implementation for the getProductId() and getVendorId() methods. [8aa09a5]
    • βž• Add switchUser(UserHandle) for ShadowActivityManager [7a63796]
    • Creating a Shadow for NetworkCapabilities. The current implementation only overrides fetching and updation of transport. [d432dcf]
    • πŸ‘ Allow ShadowEvent to set thread id as well. [ff84723]
    • βž• Add partial (backward) @Implementation of goBackOrForward(steps) to ShadowWebView [a616926]
    • Create a Shadow for SigningInfo, which was added in API 28. [dd1d408]
    • Implement ShadowBinder.setCallingUserHandle() / Binder.getCallingUserHandle() [aaa393b]
    • πŸ‘Œ Support ShadowBluetoothDevice.connectGatt() overloads. [7d95ef4]
    • 🚚 Implement AccountManager.removeAccount(...) with Activity parameter. [63816d7]
    • πŸ›  Fix ShadowMediaPlayer.setDataSource(MediaDataSource) [c3037c1]
    • βž• add missing shadow of MediaPlayer.setDataSource(MediaDataSource) [2876f57]
    • βž• Add getDefault{X}SubscriptionId() equivalents for older versions of Android to ShadowSubscriptionManager. [daa72ae]

    πŸ”§ Configuration

    • πŸ›  Introduced an opt-in mode that fixes zero-sized TextViews in Robolectric [9bfa258]
    • πŸ”§ Move ConfigurationRegistry into shadowsapi [b5e63df]
    • βž• Added extension points to AndroidEnvironment and ClassInstrumentor [3604e42]

    πŸ› Bug Fixes

    • πŸ›  Fix another 'NoSuchMethodError java.nio.ByteBuffer.position' issue in Java8 [804b89a]
    • πŸ›  Fix concurrent modification exception in ShadowAlarmManager [03fd8c3]
    • πŸ›  Fixed transliteration problems where cpp copy assignments were transliterated as java reference copies
    • Propagate RemoteException from Binder#onTransact method
    • πŸ›  Fix AccessibilityNodeinfo.obtation(NodeInfo) to clone Extra correctly [issue #4865]
    • Protecting ShadowSensorManager.sendSensorEvent from ConcurrentModificationException [issue #4839]
    • πŸ”€ Synchronize cleanup of ApkAssets cache with corresponding native object [issue #4910]
    • πŸ›  Fix a bug causing flakes when using ShadowSQLiteConnection. [issue #4904]
    • πŸ›  Fix typing text into phone EditText fields. [issue #4909]
    • Includes st_mode in Os.stat/lstat/fstat system calls. [issue #4915]
    • πŸ›  Fixed an issue where nine patch chunks are overridden [issue #4914]
    • Ensure ActivityScenario lifecycle events are consistent with device. [issue #4954]
    • πŸ‘‰ Make Instrumentation.runOnMainSync behave consistently with device. [issue #4951]
    • πŸ‘‰ Make sure that ShadowAccountManager doesn't crash on empty features. [issue #4953]
    • πŸŽ‰ Initialize Robolectric environment location properly. [72fa419]
    • πŸ›  Introduced an opt-in mode that fixes zero-sized TextViews in Robolectric [9bfa258]
    • Oops, missed a Q Beta 1 shadow. [04db5d5]
    • Don't instrument androidx.room.CoroutinesRoom$Companion. [6d24639]
    • βœ… Stem CachedDependencyResolverFileCacheTest flakiness by increasing valid cache time. [10acb64]
    • 🏁 Windows actually works finally, maybe [issue #4605].
    • πŸ›  Fixes bug in activity lifecycle state transition with finish() in onCreate [7e0d8c1]
    • πŸ›  Apply fixes from LocalActivityInvoker to RoboMonitoringInstrumentation. [017559d]

    πŸ—„ Deprecations and Removals

    • πŸ—„ @Deprecate a bunch of methods in ShadowView where alternatives exist in Espresso [312376d]

    Internal Changes

    • ⚑️ Updated to AndroidX Test 1.2.0 [47c0736]
    • Restructure ShadowLooper and related shadows into a abstract base 'API' class, and two subclasses: ShadowLegacy* and
      ShadowPaused*. A shadowPicker will be used to pick the correct shadow to use based on LooperMode.
    • Exclude Arch Components and Room from Shadows [issue #4883]
    • Break org.robolectric:annotations -> org.robolectric:shadow-api dependency [issue #4948]
    • βœ… Rename (Android)?Environment to (Android)?TestEnvironment. [6308e4f] [issue #4850]
    • βœ… Idle main looper after each SupportFragmentTestUtil call when looper mode is PAUSED. [78d27a9]
    • βž• Added missing native functions in ShadowRenderNode [7740562]
    • βž• Add setExecutor shadow API [1e2c79c]
    • Introduce a new "Paused looper" threading model. [acb7af7]
    • πŸ”„ Change ShadowNativeAllocationRegistry to use loose signatures [5409c0d]
    • πŸ”§ Create a LooperMode configurer annotation. [8e26be1]
    • 0️⃣ Enable callThroughByDefault for NativeAllocationRegistry, and explicitly shadow methods instead. [1f5f0fe]
    • πŸ‘ Allow ShadowAppOpsManager#toOpEntry to be overridden, and make TestUtil use injected DependencyResolver and SdkProvider. [adad503]
    • πŸ”¨ Refactor exception-message assertions to use ThrowableSubject.hasMessageThat(). [729acc2]
    • βž• Add link to github issue explaining workaround. [9ef6e60]
    • πŸ‘» Attempt 2 at clearing exception handler. [2fd0a1b]
    • πŸ”€ Merge pull request #4736 from robolectric/undeclared-activtiy-workaround [a4275f1]
    • Internal change [f662314]
    • βœ… Aggregate test results from all projects. [65b0975]
    • Ignore mysterious AGP fail: [1b0d479]
    • βœ… Test for AGP manifest bug workaround. [6d57524]
    • πŸ‘‰ Make it clear that Util.sneakyThrow() disrupts program flow. [316e3f0]
    • βœ‚ Remove ShadowHandler - it is an empty implementation now. [bcbf11d]
    • πŸ›  Fix ShadowAppOpsManager.toOpEntry() compilation. [37d9948]
    • πŸ”€ Merge pull request #4645 from robolectric:jakew/sneaky-throw/2019-02-17 [91af73f]
    • Internal change [f3980e1]
    • πŸ›  Fix call order of postCreate() and start() in ActivityController#recreate. See https://developer.android.com/reference/android/app/Activity.html#onPostCreate%28android.os.Bundle%29 [0cbe259]
    • πŸ— Quiet some build warnings. [aaf9e8d]
    • Obtain ShadowProviders via Injector. [0e4184c]
    • ⏱ Output scheduler state on test failures (PR#4711) [b89fe07]
    • πŸ— Compatibility test for BuildCompat [cf3a057]
    • Internal [aed7553]
    • πŸ›  Fix call order of postCreate() and start() in LocalActivityInvoker. See https://developer.android.com/reference/android/app/Activity.html#onPostCreate%28android.os.Bundle%29 [d64534c]
    • ⏱ Activity.recreate() should call back to the ActivityController to handle the recreation. This is because we wish to simulate real Android which schedules the activity for recreation with a new instance by the framework. [84f330f]
    • βœ‚ Remove dependency on server side Apache HTTP jars. Use Android legacy jars instead. [6602e1a]
    • ..internal.. [8bd178a]
    • βœ‚ Remove DisplayConfig.address for now. [4443002]
    • Internal change [0b5944c]
    • πŸ‘‰ Use 'sneaky throw' technique instead of Unsafe [13cc3ef]
    • Throw a RuntimeException when Activity cannot be resolved. [5923f51]
    • πŸ”€ Merge pull request #4638 from robolectric:rel-42 [fad2e99]
    • πŸ”¨ Refactor DefaultSdkProvider to allow plugins to customize. [d43598f]
    • πŸ”€ Synchronize list access for bound/unbound services [35098f6]
    • Register shadow classes in a stable order, so locally overridden shadows work predictably. [5725427]
    • Internal [02f57c9]
    • πŸ‘ Subinjectors now work better. [f535f84]
    • βœ‚ remove ShadowExifInterface to allow calling actual methods. [2127bbf]

    Known Issues

    • πŸ‘ Espresso's IdlingResources are not supported
    • ⚠ When running with Java 9, Robolectric triggers a warning about illegal reflective access [issue #4776].
    • πŸ‘€ Activities must now be explicitly declared in a manifest (as is the case for normal Android); however, Android Gradle Plugin doesn't currently merge a test manifest. See #4736 for more context and #4727 for a workaround.
    • βœ… Android Gradle Plugin 3.3 reports 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].

    Compatibility

    • πŸ”Œ Android Studio/Android Gradle Plugin 3.4 or 3.5 Beta
    • βœ… Android SDK 28 (includes support for testing against SDKs from 16 on) and Android Q Beta 2.
    • βœ… Running tests on Android Q requires Java 9.
    • πŸ‘ Legacy resources mode will not be supported for Android Q.
    • πŸš€ AndroidX Test 1.2.0

    πŸ‘‰ Use Robolectric:

    testCompile "org.robolectric:robolectric:4.3"
    

    Find more details here. Report issues here. Enjoy!

  • v4.3-beta Changes

    May 06, 2019

    πŸš€ NOTE: Robolectric 4.3-beta-1 is a outdated preview release; please use 4.3 or later instead.

  • v4.3-alpha Changes

    May 01, 2019

    πŸš€ NOTE: Robolectric 4.3-alpha-3 is a outdated preview release; please use 4.3 or later instead.

  • v4.2.1 Changes

    March 15, 2019

    πŸš€ This release introduces a new extension mechanism for Robolectric, fixes a major performance regression in 4.x, and includes numerous SDK support improvements and bug fixes.

    πŸ› Bug Fixes

    • 🏁 Robolectric 4.2.1 fixes a number of issues when running tests on Windows [issue 4670].
    • πŸ›  Applied fixes to activity lifecycle RoboMonitoringInstrumentation [4c7f968].

    Known Issues

    • πŸ‘€ Activities must now be explicitly declared in a manifest (as is the case for normal Android); however, Android Gradle Plugin doesn't currently merge a test manifest. See #4736 for more context and #4727 for a workaround.
    • βœ… 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].

    Compatibility

    • πŸ”Œ Android Studio/Android Gradle Plugin 3.3 or 3.4 Beta
    • βœ… Android SDK 28 (includes support for testing against SDKs from 16 on)

    πŸ‘‰ Use Robolectric:

    testCompile "org.robolectric:robolectric:4.2.1"
    

    Find more details here. Report issues here. Enjoy!

  • v4.2 Changes

    February 14, 2019

    πŸš€ This release introduces a new extension mechanism for Robolectric, fixes a major performance regression in 4.x, and includes numerous SDK support improvements and bug fixes.

    πŸ”‹ Features

    • πŸ‘€ Robolectric 4.2 introduces a new plugin system, replacing the previous ad-hoc customization mechanisms (subclassing RobolectricTestRunner, providing system properties, etc.). The old mechanisms are deprecated and will eventually be removed; let us know if there are missing extension points you need. See org.robolectric.pluginapi for more details [issue #4362].
    • πŸ›  Fixed a significant performance regression in 4.x. Thanks @cesar1000! [issues #4142, #4585].
    • For developers of custom shadows, Robolectric 4.2 has a new typesafe and more performant way to access fields and methods on @RealObjects using the Reflector API [issues #4361, #4315, #4351, #4456]

    βœ… Android SDK support and Test API changes

    • πŸ‘€ Activities must now be explicitly declared in a manifest (as is the case for normal Android). See #4736 for more context.
    • πŸ“¦ PackageManager
      • PackageManager is moving to returning defensive immutable copies of its internal data (as on a real device). A series of new testing APIs have been added to modify the package under test; see PackageManager.addOrUpdateActivity() and removeActivity(), plus Service, ContentProvider, and BroadcastReceiver equivalents [issue #4489].
      • Implement PackageManager.isSafeMode() [issue #4526].
    • ShadowDisplayManager.getSaturationLevel() is now an instance method [issue #4522].
    • Telephony
      • Add slotId based getImei() and getMeid() to TelephonyManager [issue #4521].
      • Add the ability to prevent certain networks from being updated in tests [issue #4515].
      • Implement TelephonyManager.getListenersForFlags in tests [issue #4469].
      • Implement TelephonyManager.getVisualVoicemailPackageName() [issue #4444].
    • Bluetooth
      • Test APIs for BluetoothSocket and BluetoothServerSocket connections [issue #4510].
      • Implement BluetoothLeAdvertiser [issues #4478 and #4454].
      • Implement BluetoothHeadset.getConnectedDevices(), getConnectionState(), and sendVendorSpecificResultCode(), with test APIs [issue #4442].
      • Add ability to send BluetoothGattCallback connection state change updates [issue #4584].
    • Implement ActivityManager#getCurrentUser() [issue #4483].
    • UserManager
      • Implement UserManager.getUserSerialNumber() [issue #4501].
      • UserManager#addUser returns a UserHandle to the user it creates [issue #4449].
      • Add isRestrictedProfile() and setIsRestrictedProfile() [issue #4554].
    • Implement Context.sendBroadcastAsUser [issue #4486].
    • 🚚 Implement WindowManagerImpl#removeViewImmediate(View) [issue #4447].
    • Implement SensorManager.registerListener(): [issue #4446].
    • Implement NetworkScoreManager.disableScoring() and isScoringEnabled() to [issue #4436].
    • DevicePolicyManager now enforces password restrictions [issues #4532, #4545, and #4539].
    • Implement UiModeManager [issue #4548].
    • Implement AccessibilityManager#addAccessibilityStateChangeListener(AccessibilityStateChangeListener, Handler) [issue #4448].
    • Implement ParcelFileDescriptor.createReliablePipe method [issue #4562].
    • πŸ“¦ Move intent filters to their own lists and out of the Package [issue #4488].
    • Implement WifiRttManager and RangingResult [issue #4561].
    • βž• Add test API to toggle a Sensor wake-up mode [issue #4558].
    • βž• Add PowerManager.WakeLock getTimesHeld() test API to count number of times the wakelock was held [issue #4551].
    • βž• Adds basic MediaCodec and MediaMuxer shadows to robolectric. The MediaCodec shadow implements basic passthrough asynchronous encoding, and the MediaMuxer shadow muxes input bytes directly to the file without modification [issue #4550].
    • ⚑️ Update to ShadowDevicePolicyManager to allow uses-policy granting [issue #4546].
    • Modify ShadowParcel to throw an Error instead of RuntimeException to discourage [issue #4528].
    • Don't autocreate activities in LocalActivityInvoker anymore [issue #4582].
    • 0️⃣ Don't automatically generate default ActivityInfo whenever asked [issue #4580].
    • 🚚 Implements WebView.removeJavascriptInterface [issue #4575].
    • ⚑️ Update to ShadowDevicePolicyManager to set storage encryption [issue #4563].

    πŸ”§ Configuration

    πŸ› Bug Fixes

    • The android system context is no longer a parent of the application context [issue #4481].
    • πŸ›  Fix LocalActivityInvoker.recreateActivity. Before this change, it called Activity.onRetainNonConfigurationInstance() directly to obtain nonConfigInstance for the activity. This should've called indirectly from Activity.retainNonConfigurationInstances(). retainNonConfigurationInstances() also creates nonConfigInstances for fragments to prepare for the host activity recreation [issue #4511].
    • πŸ›  Fix timeout in FontsContract.getFontSync() caused because Context.canLoadUnsafeResources() now returns false since the context isn't a system context [issue #4517].
    • πŸ›  Fix handling of persisted preferred activities [issue #4480].
    • πŸ›  Fix processName setting and add few more reasonable defaults when installing new package [issue #4465].
    • βž• Add permission check to LocationManager.setLocationEnabledForUser [issue #4500].
    • No longer reset the data position after unmarshalling a ShadowParcel [issue #4468].
    • πŸ›  Fix NPE Robolectric when a failure occurs before shadows are set up [issue #4467].
    • Set AppBindData#processName consistently with ApplicationInfo#processName [issue #4537].
    • πŸ“¦ Throw NameNotFoundException from Context.createPackageContext for non-existing packages [issue #4527].
    • πŸ”€ Synchronize access to ShadowPendingIntent and ShadowUsageStatsManager fields [issue #4520].
    • πŸ›  Fix Activity#isChangingConfigurations() returning false during the recreation [issue #4540].
    • πŸ›  Fix equality in ShadowNetwork [issue #4464].

    πŸ—„ Deprecations and Removals

    • 🚚 FsFile et al. have been removed in favor of java.nio.file.Path [issue #4265].
    • ⚑️ ShadowPackageManager.addResolveInfoForIntent is deprecated; add explicit activity declarations in your manifest, or use ShadowPackageManager.addOrUpdateActivity(ActivityInfo) [issue #4489].
    • πŸ—„ Deprecate Robolectric#setupActivity in favor of ActivityScenario [issue #4564].

    Internal Changes

    • βœ… Tests are now run on a dedicated thread for each SDK [issue #4559].
    • πŸ”Œ Resolve AARs like the android plugins do (kind of) [issue #4279].
    • Reflector objects should unwrap invocation exceptions [issue #4361].
    • Fast private method invocation [issue #4315].
    • βž• Add support for static methods and fields to Reflector [issue #4351].
    • πŸ›  Fix Reflector class definition in Java 11 [issue #4456].
    • πŸ‘Œ Support Java 9 [issue #4400].
    • 🏁 Robolectric now builds successfully on Windows, though a few tests still fail [issue #4293].
    • πŸ”§ Extensible configuration system [issue #4519].
    • Switch circleci to API 28 image. Fix SDK install license fail [issue #4541].
    • πŸ”„ Changes to support Java 9 [issue #4452].
    • TypedArray doesn't need a shadow in binary mode [issue #4470].
    • Extract Sdk from SdkConfig [issue #4394].
    • Clean up SdkProvider interface [issue #4513].
    • 🚚 Move PerfStatsReporter to pluginapi [issue #4471].
    • PerfStatsCollector retains min and max timing info for events [issue #4552].
    • βœ‚ Remove DefaultConfigMerger [issue #4549].

    Known Issues

    • πŸ‘€ Activities must now be explicitly declared in a manifest (as is the case for normal Android); however, Android Gradle Plugin doesn't currently merge a test manifest. See #4736 for more context and #4727 for a workaround.
    • 🏁 Robolectric 4.2 doesn't work on Windows in some cases [issue #4603 et al.].
    • βœ… 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].

    Compatibility

    • πŸ”Œ Android Studio/Android Gradle Plugin 3.3 or 3.4 Beta
    • βœ… Android SDK 28 (includes support for testing against SDKs from 16 on)

    πŸ‘‰ Use Robolectric:

    testCompile "org.robolectric:robolectric:4.2"
    

    Find more details here. Report issues here. Enjoy!