Robolectric 4.3
brettchabot
released this
30 May 17:48
·
4087 commits
to master
since this release
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] - 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!