Roboletric v4.3 Release Notes
Release Date: 2019-05-30 // almost 5 years ago-
๐ 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()
(wrapsgetLaunchIntentForPackage()
) [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 toDevicePolicyManager
[b1ecc5a] - โ Add implementation of -
ShadowSubscriptionManager#getAvailableSubscriptionInfoList
-ShadowSubscriptionManager#setAvailableSubscriptionInfoList
-ShadowSubscriptionManager#setAvailableSubscriptionInfos
-SubscriptionInfoBuilder#setMnc
[95bac4a] - Modify
ShadowLocationManager
to respectLOCATION_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 forShadowActivity
. [9b2af0b] - ๐ Supports
setProfileClass
&setIsEmbedded
inSubscriptionInfoBuilder
[4c74611] - ๐ Supports
EuiccManager#getEid
inShadowEuiccManager
[e64f675] - ๐ Fake out a minimal implementation of
ShadowSliceManager.getPinnedSlices()
. [2f7aa83] - โ Add
setSeedAccountType()
forShadowUserManager
[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()
forShadowUserManager
[50ec6ed] - ๐ Support tag in
ShadowWakeLock
[3137c1c] - โ Add
createConfirmFactoryResetCredentialIntent
toShadowKeyguardManager
[1d20033] ShadowInputDevice
: Add shadow implementation for thegetProductId()
andgetVendorId()
methods. [8aa09a5]- โ Add
switchUser(UserHandle)
forShadowActivityManager
[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
ofgoBackOrForward(steps)
toShadowWebView
[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(...)
withActivity
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 toShadowSubscriptionManager
. [daa72ae]
๐ง Configuration
- ๐ Introduced an opt-in mode that fixes zero-sized
TextView
s in Robolectric [9bfa258] - ๐ง Move ConfigurationRegistry into shadowsapi [b5e63df]
- โ Added extension points to
AndroidEnvironment
andClassInstrumentor
[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
TextView
s 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
toRoboMonitoringInstrumentation
. [017559d]
๐ Deprecations and Removals
- ๐
@Deprecate
a bunch of methods inShadowView
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 isPAUSED
. [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
forNativeAllocationRegistry
, and explicitly shadow methods instead. [1f5f0fe] - ๐ Allow
ShadowAppOpsManager#toOpEntry
to be overridden, and makeTestUtil
use injectedDependencyResolver
andSdkProvider
. [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() inActivityController#recreate
. See https://developer.android.com/reference/android/app/Activity.html#onPostCreate%28android.os.Bundle%29 [0cbe259] - ๐ Quiet some build warnings. [aaf9e8d]
- Obtain
ShadowProviders
viaInjector
. [0e4184c] - โฑ Output scheduler state on test failures (PR#4711) [b89fe07]
- ๐ Compatibility test for
BuildCompat
[cf3a057] - Internal [aed7553]
- ๐ Fix call order of
postCreate()
andstart()
inLocalActivityInvoker
. See https://developer.android.com/reference/android/app/Activity.html#onPostCreate%28android.os.Bundle%29 [d64534c] - โฑ
Activity.recreate()
should call back to theActivityController
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
whenActivity
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!