@brettchabot brettchabot released this Jul 23, 2018 · 57 commits to master since this release

Assets 2

Robolectric 4.0 Alpha 3 brings support for Android 28 release, errorprone, shadow method validation and many other improvements. This is an alpha release, use with caution. APIs are likely to change before the final release of Robolectric 4.0.

Features

  • Support for the Android 28 API [Issue #3933]
  • Add errorprone/auto-refactoring support [Issue #3944]
  • Verify shadow @implementation methods against SDKs [Issue #3952]
  • Support Espresso typeText [Issue #3919]
  • Add SupportFragmentController#setupFragment() [Issue #3911]
  • Shadow get/setNotificationPolicy on NotificationManager [Issue #3911]
  • Adds a simple Shadow for JobService so classes that extend it can call jobFinished() without crashing. [Issue #3911]
  • Add createSensorEvent and sendSensorEventToListeners to ShadowSensorManager [Issue #3911]
  • Make the result of WifiScanner#startScan() configurable. [Issue #3911]
  • Add functionality for setting the unbadged application icon in ShadowPackageManager [Issue #3919]
  • Support OnAlarmListener call in ShadowAlarmManager [Issue #3919]
  • Add ParameterizedRobolectricTestRunner#parameter annotation and remove dependency on XStream [Issue #3919]
  • Support CookieManager.removeAllCookies. [Issue #3919]
  • Add overloads to PendingIntent.send [Issue #3919]
  • Support retrieving the last message sent via Messenger [Issue #3919]
  • Add implementation for getAppStandbyBuckets and setAppStandbyBuckets to ShadowUsageStatsManager [Issue #3919]
  • Adding error behavior to ShadowGeocoder. [Issue #3919]
  • Add basic GLES20 support. [Issue #3924], [Issue #3944]
  • Add support for new LocationManager API in Android P [Issue #3924]
  • Add support to ShadowPowerManager to capture rebooting. [Issue #3924]
  • Add support for Parcel.read/writeBlob [Issue #3924]
  • Improve ShadowSoundPool adding the ability to query played sounds. [Issue #3944]
  • Add method to override system properties [Issue #3944]
  • Add BluetoothDevice#getUuids/setUuids [Issue #3944]
  • Enhance support for BluetoothGatt [Issue #3944]
  • Implement the newer AudioManager request and abandon audio focus api [Issue #3944]
  • Add ShadowPackageManager#addSystemSharedLibraryName [Issue #3944]
  • Add setMode and checkOpNotThrow (hidden) APIs to ShadowAppOpsManager [Issue #3944]
  • Update ShadowDebug to allow for method tracing. [Issue #3944]
  • Add setTimeZone method to ShadowAlarmManager [Issue #3944]
  • Add ShadowVisualVoicemailSms [Issue #3944]
  • Add scrollBy methods to ShadowView and ShadowScrollView [Issue #3944]
  • Add ShadowEventLog and ShadowProcess.setUid() [Issue #3944]
  • Add a Shadow class for MediaBrowserCompat. [Issue #3944]
  • Support ConnectivityManager#reportNetworkConnectivity [Issue #3944]
  • Add shadow for DropboxManager. [Issue #3944]
  • Add support for DisplayManager#setDisplaySaturation [Issue #3952]
  • Add scrollBy methods to ShadowView and ShadowScrollView [Issue #3952]
  • Add shadow for UsageStatsManager.queryUsageStats() and a builder for UsageStats. [Issue #3952]
  • Extend ShadowNfcAdapter to verify ndefPushMessage and emulate absence of NFC hardware [Issue #3952]
  • Improve fidelity of WifiInfo by removing shadows in favor of using real Android code. [Issue #3911]
  • Add a Shadow class for MediaControllerCompat. [Issue #3956]
  • Add ShadowNotificationManager#setNotificationPolicyAccessGranted(float) [Issue #3956]
  • Add support for isSystemUser to ShadowUserManager. [Issue #3956]
  • Adding a basic Shadow for the CaptioningManager. [Issue #3956]
  • Add layerType to ShadowView [Issue #3956]

Bug fixes

  • Implement ShadowDevicePolicyManager#setPackagesSuspended correctly. [Issue #3911]
  • Add a NoOp implementation of NfcAdapter#setOnNdefPushCompleteCallback. [Issue #3911]
  • Fix string HTML attributes in binary resources. [Issue #3911]
  • Avoid throwing in Bitmap#reconfigure for non-native backed Bitmaps. [Issue #3911]
  • Overriding getActivityIntent in ActivityTestRule has no effect [Issue #3918]
  • Improved handling of lockTaskMode that works now across activities and ActivityManager. [Issue #3924]
  • Fix NPEs when calling Surface#release and getString [Issue #3924]
  • Enhance TelephonyManager support [Issue #3944]
  • Set DataSource in ShadowMediaPlayer.create() [Issue #3944]
  • Fix signature of ShadowAccessibilityNodeInfo.setTraversalBefore()/After [Issue #3944]
  • Added a few methods to the ShadowCamera to prevent an NPE in Camera.Parameters and execute callbacks passed to takePicture [Issue #3952]
  • Improved package lost sequence number check [Issue #3956]
  • Don't modify PendingIntent extras upon sending it [Issue #2503]

Deprecations

  • Deprecate SupportFragmentTestUtil [Issue #3911]

Removals

  • Remove ShadowApplication.getApplicationContext() in favor of RuntimeEnvironment#application [Issue #3911]
  • Remove unused ShadowFrameLayout [Issue #3924]
  • Remove @implementation methods from ShadowViewGroup that are not necessary as we can just call the real implementation instead. [Issue #3924]
  • Delete shadows.MotionEventBuilder in favor of using androidx.test.core.view.MotionEventBuilder [Issue #3956]

Known Issues

  • Binary resources are not yet supported for Android P.

Use Robolectric:

testCompile "org.robolectric:robolectric:4.0-alpha-3"

Find more details here. Report issues here. Enjoy!

@brettchabot brettchabot released this May 14, 2018 · 230 commits to master since this release

Assets 2

Robolectric 4.0 Alpha 2 brings support for androidx.test APIs and the Android P beta platform. This is an alpha release, use with caution. APIs are likely to change before the final release of Robolectric 4.0.

Features

  • Support the androidx test 1.1.0-alpha2 APIs, including initial support for Espresso interactions (button clicks)
  • Support for the Android P beta platform

Known Issues

  • Binary resources are not yet supported for Android P.

Use Robolectric:

testCompile "org.robolectric:robolectric:4.0-alpha-2"

Find more details here. Report issues here. Enjoy!

@xian xian released this May 9, 2018 · 276 commits to master since this release

Assets 2

Robolectric 4.0 Alpha 1 brings support for Android Jetpack Test APIs, major performance and fidelity improvements, and numerous other fixes and improvements. This is an alpha release, use with caution. APIs are likely to change before the final release of Robolectric 4.0.

Features

  • Support for androidx.test APIs for testing.
  • Support for loading resources processed using the Android build toolchain (aapt) (requires Android Gradle Plugin 3.2, or Bazel's android_local_test) [issue #3850].

Changes

  • Remove deprecated @Config properties constants, buildDir, and abiSplit [issues #3831 and #3859].
  • Correct ShadowBitmap.createdFrom fields [issue #3841].
  • Provide a way for excluding packages to acquire in the sandbox classloader [issue #3676—thanks @kageiit].

Known Issues

  • Binary resources are not yet supported for Android P.
  • The supported version of Android P is Developer Preview 2. To be updated shortly.
  • android.support.test is supported right now, androidx.test coming shortly.

Use Robolectric:

testCompile "org.robolectric:robolectric:4.0-alpha-1"

Find more details here. Report issues here. Enjoy!

Apr 24, 2018

@brettchabot brettchabot released this Mar 16, 2018 · 744 commits to master since this release

Assets 2

Robolectric 3.8 brings support for Android P, performance improvements, and numerous other fixes and improvements.

Features

  • Add support for Android P Developer Preview rev 2 [issue #3821].
  • Performance improvement: remove redundant rest of shadows before tests. [issue #3814].
  • Add ActivityController.windowFocusChanged() API.
  • NotificationManager simulation improvements [issue #3617].
  • Add shadow support for ActivityManager.getMyMemoryState [issue #3775].
  • Add isStopped() method to ShadowTextToSpeech [issue #3818].
  • Shadow DevicePolicyManager.getStorageEncryptionStatus [issue #3807].
  • Added setManifestShortcuts() and setMaxShortcutCountPerActivity() to ShadowShortcutManager [issue #3803].
  • Add shadow support for Settings#canDrawOverlays().

Deprecations

  • ShadowNetworkInfo#newInstance() and setConnectionStatus().

Bug Fixes

  • Fix ShadowMediaPlayer does not correctly handle instantiation off the UI thread. [issue #3050].
  • Allow Jacoco code coverage to work with Robolectric. [issue #3791].
  • Collapse internal whitespace down to single space character in string [issue #3791].
  • Cleanup Shadow MessageQueue/Looper and ViewRootImpl.

Misc

  • Update android O-MR1 platform to newer build [issue #3817].
  • Move JarInstrumentor to sandbox module [issue #3806].

Use Robolectric:

testCompile "org.robolectric:robolectric:3.8"

Find more details here. Report issues here. Enjoy!

@brettchabot brettchabot released this Feb 15, 2018 · 889 commits to master since this release

Assets 2

Robolectric 3.7.1 contains two regression fixes.

Bug Fixes

  • Filter out disabled components in PackageManager query/resolve methods [#3748].
  • Fix 'PackageParser' compile errors when referencing ShadowPackageManager.addPackage [#3752].

Dependencies

  • Requires compiling against SDK 27.
  • Introduces an optional dependency on com.android.support.test:monitor:1.0.2-alpha1. If your project already depends on com.android.support.test.* , you should upgrade to 1.0.2-alpha1 to avoid potential conflicts e.g. java.lang.VerifyError: class org.robolectric.android.fakes.RoboMonitoringInstrumentation overrides final method specifyDexMakerCacheProperty.

Use Robolectric:

testCompile "org.robolectric:robolectric:3.7.1"

Find more details here. Report issues here. Enjoy!

@jongerrish jongerrish released this Feb 14, 2018 · 889 commits to master since this release

Assets 2

Robolectric 3.7 brings simulation improvements and better shadow support as well as numerous other fixes and improvements.

This is the second of several releases in which we're replacing Robolectric's hacked-together approximations of the Android resource management code with actual code from the framework. The result should be a vastly more correct Android simulation.

Features

  • System Services
    • Initial support for FingerprintManager, KeyguardManager, SearchManager, ShortcutManager, UsbManager, RestrictionsManager, TextClassificationManager, and AutofillManager.
    • Vastly improved support for PackageManager, using much more actual Android framework code for manifest parsing.
    • Improved support for UserManager, WifiManager, TelephonyManager, and DevicePolicyManager.
  • Support for building using Bazelinstructions here.
  • System properties now more closely correspond to the Android framework values.
  • Improvements to Shadow support.
    • @Implementation methods can and should now be protected.
    • Performance improvements to shadow handling of > ~1 second per test run, big impact for the interactive use case.
    • New developer's guide for Shadow authors.
  • Beta support for ATSL's ActivityTestRule and Espresso Intents.
  • Lots of other stuff; see change list below.

Dependencies

  • Requires compiling against SDK 27.
  • Introduces an optional dependency on com.android.support.test:monitor:1.0.2-alpha1. If your project already depends on com.android.support.test.* , you should upgrade to 1.0.2-alpha1 to avoid potential conflicts e.g. java.lang.VerifyError: class org.robolectric.android.fakes.RoboMonitoringInstrumentation overrides final method specifyDexMakerCacheProperty.

Migration Notes

  • The shadow methods for Managers listed above have been switched from public to protected. Your test code may have been calling these erroneously instead of calling the Android SDK method, e.g: prefer
    PackageManager.getPackageInfo() to ShadowPackageManager.getPackageInfo(). This is easily fixed by calling the SDK method instead.
  • AndroidManifest has been removed; instead, use PackageManager APIs.

Deprecations

  • ShadowApplication.getReceiversForIntent() and hasReceiversForIntent() are deprecated; use PackageManager APIs instead.
  • ShadowUserManager.setSerlialNumberForUser() is deprecated; use addUserProfile() instead.
  • @Implementation(inheritImplementationMethods = true) is largely unnecessary and will be removed in a forthcoming release.
  • Shadow support for equals/hashcode/toString support in cases where the method exists only on a parent of the shadowed class is deprecated. Don't shadow equals() for the purposes of testing or assertions, rather only for simulation equivalency.
  • RoboLayoutInflater is deprecated; use LayoutInflater instead.
  • RoboVibrator is deprecated, functionality has moved to ShadowVibrator.

Changes

  • Support FingerprintManager [issue #3266—thanks @andreszamoraglobant].
  • ShadowMatrix does not implement map* methods [issue #3602—thanks @Kalabasa].
  • Unit test with WifiManager throws NPE [issue #3655—thanks @qsjh898].
  • Read system properties from android-all.jar!build.prop [issue #3620].
  • Change Robolectric's ShadowAccessibilityNodeInfo.equals() test to use a unique source ID [issue #3623].
  • Fix errorprone warnings [issue #3633].
  • Allow @Implementation methods to be protected instead of public [issue #3130].
  • Remove deprecated ManifestIdentifier.create() [issue #3634].
  • Default minSdkVersion should be Jelly Bean (16), not 1 [issue #3650].
  • Fix asset path searches to include all transitively reachable asset paths [issue #3652].
  • Reapply removal of deprecated ManifestFactory.create() [issue #3636].
  • Fix hash stability bug when overriding shadows using @Config [issue #3667].
  • Remove ShadowPackageManager#setQueryIntentImplicitly [issue #3672].
  • Reintroduce ATSL support as an optional dependency [issue #3679].
  • Add support to method getFromLocation on ShadowGeocoder [issue #3678—thanks @josecoelho].
  • Handle parsing float attribute values with no leading numbers [issue #3699].
  • Refactor instrumentation [issue #3654].
  • Collect perf metrics for shadow method lookup [issue #3706].
  • Refactor @Implementation method resolution [issue #3705].
  • Optimize class analysis for instrumentation [issue #3707].
  • Add RGBA_F16 to getBytesPerPixel in ShadowBitmap [issue #3687].
  • Apply sheepfood changes missed during prior syncs [issue #3718].
  • Switch Robolectric shadow tests to use android_local_test [issue #3715].
  • Fix Parcel.readByteArray() [issue #3710—thanks @cesar1000].
  • Implement ShadowMatrix mapPoints and mapVectors [issue #3609—thanks @Kalabasa].
  • Remove references to AndroidManifest from shadows [issue #3682].
  • UserManager simulation improvements [issue #3681].
  • Adds handling of permission groups to the PackageManager [issue #3680].
  • Delete ShadowActivityThreadTest [issue #3717].
  • Allow ConfigMerger to be overridden [issue #3713].
  • Add ShadowTelephonyManager.setIsSmsCapable [issue #3702].
  • Add support for FingerprintManager [issue #3696].
  • Test cleanups [issue #3695].
  • Add missing methods for testing ConnectivityManager.OnNetworkActiveLi… [issue #3694].
  • Fix Resource mapping tests [issue #3691].
  • Ignore multidex for RoboInstrumentation and code cleanup [issue #3690].
  • Add android.net.INetworkPolicyManager to ServiceManager [issue #3689].
  • Fix InstrumentationRegistryTest when running on device [issue #3686].
  • Re-introduce ActivityTestRule support [issue #3685].
  • Prepare Robolectric's test to run with AGP [issue #3683].
  • KeyguardManager simulation improvements [issue #3644].
  • UserManager simulation enhancements [issue #3643].
  • Add support for UserManager.getApplicationRestrictions() [issue #3637].
  • DevicePolicyManager simulation enhancements [issue #3675].
  • Remove check for min JDK version, Robolectric requires Java 8 anyway [issue #3669].
  • Properly set activityInfo.exported and permission and add ShadowPackageManager.getIntentFiltersForXXX APIs [issue #3666].
  • UserManager simulation enhancements [issue #3662].
  • RestrictionsMananger support getManifestRestrictions() [issue #3660].
  • KeyguardManager simulation improvements [issue #3658].
  • Add support for RestrictionsManager [issue #3656].
  • Switch ProxyMaker to use reflection to run on ART API < 26 [issue #3649].
  • UserManager simulation enhancements [issue #3648].
  • Remove obsolete ShadowsAdapter APIs [issue #3627].
  • Fix imports [issue #3625].
  • Remove @Deprecated TestLifeCycle.createApplication() [issue #3624].
  • Remove obsolete references to Robolectric.getShadowsAdapter() [issue #3622].
  • Fix infinite loop with styles [issue #3616—thanks @nll].
  • KeyguardManager's isKeyguardSecure() is API 16 [issue #3631].
  • Re-work resetter code to simplify [issue #3629].
  • Remove RuntimeEnvironment.getAppManifest [issue #3628].
  • Cache setup database in SQLiteDatabaseTest [issue #3444].
  • Optimize InstrumentingClassLoader.getCommonSuperClass() [issue #3726].
  • Refactor instrumentation even more [issue #3730].
  • Updating string resources parsing [issue #3177—thanks @pivotal-james-zcheng].
  • Xml resource string escaping [issue #3671—thanks @menny].
  • Handle receiver class names with no leading '.' [issue #3740].
  • Move WORKSPACE file and fix path [issue #3735—thanks @dkelmer].
  • Add dependencies for bazel projects using Robolectric [issue #3731—thanks @dkelmer].
  • Implement support for O system services [issue #3729].
  • WifiManager simulation enhancements [issue #3727].
  • Make some @Implementation methods protected [issue #3724].
  • Add basic shadow tro prevent NPE when dereferencing [issue #3739].
  • Add test case for default shared preferences [issue #3612—thanks @roostertech].
  • Stub out restore() method in ShadowCanvas [issue #3521—thanks @cesar1000].
  • Support ATSL Intents verification API on Robolectric [issue #3728].
  • Replace RobolayoutInflator with PhoneLayoutInflator as per framework [issue #3741].
  • Clean up new APIs in 3.7 [issue #3714].
  • Switch Vibrator from fake to Shadow [issue #3742].
  • Implement equals() in ShadowPorterDuffColorFilter [issue #3522—thanks @cesar1000].
  • Add utility to ShadowToast to check whether a toast was cancelled [issue #3711—thanks @cesar1000].
  • SharedPreferences will not persist edits across getSharedPreferences calls [issue #3510—thanks @setheclark].
  • SharedPreferences' commit() hangs if executed after apply() on Android O [issue #3641—thanks @kzaikin].
  • BadParcelableException when unmarshalling Parcelable extending class [issue #2398—thanks @menny].
  • Problem of WARNINGs [issue #3646—thanks @XinyueZ].

Use Robolectric:

testCompile "org.robolectric:robolectric:3.7"

Find more details here. Report issues here. Enjoy!

Feb 2, 2018
Merge pull request #3726 from robolectric/instrumentation-optimization
Optimize InstrumentingClassLoader.getCommonSuperClass().

@xian xian released this Dec 19, 2017 · 1219 commits to master since this release

Assets 2

Robolectric 3.6.1 fixes a couple small issues in 3.6.

Changes

  • Reverted support for android.support.test's InstrumentationRegistry and ActivityTestRule for now, didn't work with Android Gradle Plugin 2.x [issue #3614].
  • Reverted fix for XML references containing whitespace [issue #3198] for now, previous fix caused other problems.

Use Robolectric:

testCompile "org.robolectric:robolectric:3.6.1"

Find more details here. Report issues here. Enjoy!

@xian xian released this Dec 18, 2017 · 1221 commits to master since this release

Assets 2

Robolectric 3.6 provides enhanced device configuration, fixes lots of idiosyncrasies in how resources were picked based on device configuration, and includes numerous other fixes and improvements.

This is the first of several releases in which we're replacing Robolectric's hacked-together approximations of the Android resource management code with actual code from the framework. The result should be a vastly more correct Android simulation.

Features

  • New device configuration APIs [issue #3559]:
    • Qualifiers specified using @Config(qualifiers="...") are used to configure the virtual device's simulated locale, display, and hardware for the test.
    • Display and DisplayMetrics now match the device's configuration.
    • On Jelly Bean MR1 and up, additional displays can be simulated using ShadowDeviceManager#addDisplay() et al.
    • Orientation and other configuration changes are easy to simulate and test.
    • See the page on Device Configuration for lots more details.
  • New APIs for controlling Build constants and ActivityManager.isLowRamDevice [issue #3576].
  • Support for android.support.test's InstrumentationRegistry and ActivityTestRule [issue #3568 and #3578].
  • Bumped API 27 to released Android O 8.1 [issue #3599].
  • Performance statistics collection, within plugin-able reporting mechanism [issue #3548].
  • Implement 'WifiManager.setWifIInfo()' [issue #3569].
  • Added support for fragment arguments in FragmentController [issue #3498].
  • Add multi SIM support to SmsManager [issue #3561].
  • Support for ConnectivityManager to bind networks [issue #3539].
  • Implemented ContextImpl.getSystemService(Context.CAPTIONING_SERVICE) [issue #3527].
  • Add support for PackageManager.queryIntentServicesAsUser() [issue #3597].
  • Add time formatting support for a few locales in ICU [issue #3553].
  • Added initial support for AppOpsManager and CaptioningManager [issues #3494 and #3527].
  • Implemented context.startForegroundService() [issue #3517].

Fidelity Improvements

  • Robolectric now uses the same logic as a real Android device for selecting resources [issue #3504]:
  • Attribute types are now parsed in order specified by Android [issue #3565].
  • ContentObservers now respect notifyForDescendents [issue #3544].
  • AssetManager.open() and list() now include assets from libraries [issue #3605].
  • Added support for AlarmClockInfo to AlarmManager [issue #3483].
  • PackageManager now handles the MATCH_DISABLED_COMPONENTS flag [issue #3499].
  • Improved fidelity of how activities are notified of configuration changes [issue #3581 and #3591].

Bug Fixes

  • Log.getLogsForTag() returns empty list instead of null if no logs with that tag are present [issue #3550].
  • Tests can now be executed from any parent directory [issue #3598].
  • Improved ActivityController lifecycle handling [issue #3591].
  • Fix 'Settings.set24HourMode()` [issue #3525].
  • AccountManageFuture.isDone() no longer returns true on failure [issue #3603].
  • Avoid NPE in AccessibilityNodeInfo child comparing children [issues #3589 and #3579].
  • Avoid NPE in PackageManager.getResolveInfo() [issue #3513].
  • Improved fidelity of PendingIntent [issue #3465].
  • Fixed mipmap resource reference resolution [issue #3495].
  • Fixed detection of color resource types [issue #3512].
  • Whitespace in style XML files no longer causes Robolectric to hang [#3475].

Deprecations

  • TestLifecycle.createApplication() [issue #3555].
  • ShadowPackageManager.setQueryIntentImplicitly() [issue #3584].
  • ShadowsAdapter and Robolectric.getShadowsAdapter()`: access shadows directly instead.
  • Most methods in Qualifiers: use @Config(qualifiers) and related Android platform APIs instead.
  • Methods to directly configure a Display: eg. ShadowApplication.setDefaultDisplay(), ShadowDisplay.setDisplayId(): use @Config(qualifiers) or RuntimeEnvironment.setQualifiers() instead.

Misc

  • Java 9 is now supported [issue #3459].
  • Moved controllers to shadow/framework module [issue #3583].

Migration Notes:

  • Calculations using display size are likely to be affected because display metrics are now correctly configured, instead of being hard-coded to 480x800.
  • More here.

Use Robolectric:

testCompile "org.robolectric:robolectric:3.6"

Find more details here. Report issues here. Enjoy!