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() (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!