robolectric

Android Unit Testing Framework

OTHER License

Stars
5.8K
Committers
672

Bot releases are visible (Hide)

robolectric - Robolectric 4.0.1

Published by xian almost 6 years ago

Robolectric 4.0.1 fixes several bugs in 4.0:

Bug Fixes

  • NPE in PackageParser in binary resources mode [issue #4026].
  • Activity.getLifecycle().getCurrentState()==CREATED although activity is resumed [issue #4038].
  • 4.0 migration tool not working [issue #4052].

Known Issues

  • Robolectric 4 does not work on Windows [issue #3955].
  • Android Gradle Plugin may report the following warning, which may be safely ignored: WARNING: The option setting 'android.enableUnitTestBinaryResources=true' is experimental and unsupported.

Use Robolectric:

testCompile "org.robolectric:robolectric:4.0.1"

Getting Started | Migrating | Report Issues. Enjoy!

robolectric - Robolectric 4.0

Published by xian almost 6 years ago

Robolectric 4.0 brings support for the Android P (SDK 28) release, new and improved support and testing APIs for dozens of Android classes, initial support for some androidx-test APIs, and a complete rewrite of the resource handling code making it behave much more like a real Android device.

With the major version number bump to 4.0, we're making changes to some public APIs, detailed below. Check out the migration notes and use the new automated migration tool to help convert your existing tests to be compatible with Robolectric 4.0.

API Changes

  • Most @Implementation methods in shadow classes are now protected instead of public. Tests should always prefer to call SDK methods directly on Android classes rather than on their shadows [issue #4007].
  • RuntimeEnvironment.application has been deprecated, use androidx.test.core.app.ApplicationProvider.getApplicationContext() instead.
  • AutoCloseable is now supported. In earlier versions of Robolectric, try-with-resources blocks would fail to call close() on the resource.
  • Bumped Android P to build 4913185.

Resources

In conjunction with Android Studio 3.2, Robolectric can now use resources processed using the Android build toolchain, and loads and handles those resources using the same logic as on an actual Android device. Robolectric’s old idiosyncratic resource handling mode is still available for projects not yet using the latest version of the build toolchain, but is now deprecated.

New and improved SDK support and testing APIs for numerous Android classes, including:

  • ActivityManager.getAppTasks()
  • ApplicationPackageManager content providers, canRequestPackageInstalls()
  • AppOpsManager
  • AsyncQueryHandler
  • AudioManager.getActivePlaybackConfiguration()
  • BackupManager
  • BluetoothAdapter profile connection state and bond state
  • Build.getSerial()
  • CameraManager and CameraCharacteristics
  • Camera.Parameters preview sizes
  • CarrierConfigManager.getConfigForSubId()
  • ConnectivityManager support for NetworkCapabilities, requestNetwork().
  • ContentResolver.openOutputStream(), 'getSyncAdapterTypes()'
  • Context.bindServiceAsUser()
  • DevicePolicyManager.setUserProvisioningState()
  • EuiccManager
  • FontFamily
  • Improvements to AccessibilityNodeInfo
  • NotificationManager support for AutomaticZenRules
  • PackageManager.checkPermission() checks PackageInfo.requestedPermissionsFlags to determine if a permission is granted.
  • Path, PathMeasure, and PathParser
  • SensorManager
  • Service.stopSelfResult()
  • ShadowSensor.newInstance()
  • Sms
  • SoundPool now records more details when play() is called.
  • StorageManager test API for adding volumes.
  • SubscriptionManager.getActiveSubscriptionInfoForSimSlotIndex(), getActiveSubscriptionInfoCount() etc., 'getDefaultSubscriptionId()'
  • SystemClock.elapsedRealtimeNanos() and currentNetworkTimeMillis()
  • TelecomManager.silenceRinger()
  • TelephonyManager.getSubscriberId(), getSimSerialNumber(), 'getVoiceNetworkType()'
  • TextToSpeech
  • Tile and TileService minimal implementation
  • TimeZoneFinder
  • UsbManager
  • UserManager now supports multiple users.
  • UserStatsManager test API: ShadowUserStatsManager.simulateTimeChange(); use EventBuilder can be used to return arbitrary events
  • VMRuntime.is64Bit(), ShadowVMRuntime.setIs64Bit(), ShadowBuild.setSupported64BitAbis()
  • WebStorage
  • WebView.saveState() and restoreState()
  • WifiManager.connect(int, ActionListener)
  • Fixed a bug in RoboCursor.getLong().
  • Fixed a deadlock related to saving preferences.
  • Improved support for Java 9.
  • Fixes to Looper.myLooper()
  • Support for color gamut and HDR in @Config(qualifiers).
  • Added subscribe and search functionality to ShadowMediaBrowserCompat. Also added easy ways to create MediaItems and get all created MediaItems with their parent-child relationships [thanks Jehron Petty and Noah Luddy!].
    • getRoot(), getItem(), subscribe(), and search() can only be called successfully after ShadowMediaBroswserCompat.connect() is called.
    • The default root id is root_id. This is what will be returned by getRoot() by default. The root id can be changed with setRootId(). Note that if the root is created with createMediaItem(), setRootId() must also be called with the same mediaId.
    • There is no getSessionToken() method in ShadowMediaBrowserCompat. Follow issue #3962 for updates.

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]
  • Added support for androidx.test's ActivityScenario API.
  • Fixes for ShadowBitmap.(set|is)Premultiplied() and ShadowWebView.copyBackForwardList()

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]
  • Fix ActivityScenario support [Issue #4022]
  • View.post() and postDelayed(). now more properly return true, which fixes a bug that sometimes caused duplicate tap events to be delivered.

Deprecations

  • Deprecate SupportFragmentTestUtil [Issue #3911]
  • ShadowApplication.getInstance()
  • ShadowLooper.getShadowMainLooper()
  • Config(packageName)

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]
  • ShadowContentResolver.clearContentObservers()
  • Replace ShadowAlertDialog.getShadowAlertController() with getAlertController()
  • Various deprecated RobolectricTestRunner methods
  • ShadowAccountManager.get()
  • ShadowKeyguardManager.setinRestrictedInputMode()
  • ShadowNetworkInfo.newInstance()
  • Replace ShadowGradientDrawable.getColor() with getLastSetColor()

Known Issues

  • Robolectric 4 does not work on Windows [issue #3955].
  • Android Gradle Plugin may report the following warning, which may be safely ignored: WARNING: The option setting 'android.enableUnitTestBinaryResources=true' is experimental and unsupported.

Use Robolectric:

testCompile "org.robolectric:robolectric:4.0"

Find more details here. Report issues here. Enjoy!

robolectric - Robolectric 4.0 beta 3

Published by xian almost 6 years ago

NOTE: Robolectric 4.0-beta-3 is a outdated release candidate; please use 4.0 instead.

robolectric - Robolectric 4.0 beta 2

Published by brettchabot almost 6 years ago

NOTE: Robolectric 4.0-beta-2 is a outdated release candidate; please use 4.0 instead.

robolectric - Robolectric 4.0 Beta 1

Published by xian about 6 years ago

NOTE: Robolectric 4.0-beta-1 is a outdated release candidate; please use 4.0 instead.

robolectric - Robolectric 4.0 Alpha 3

Published by brettchabot about 6 years ago

NOTE: Robolectric 4.0-alpha-3 is a outdated release candidate; please use 4.0 instead.

robolectric - Robolectric 4.0 alpha 2

Published by brettchabot over 6 years ago

NOTE: Robolectric 4.0-alpha-2 is a outdated release candidate; please use 4.0 instead.

robolectric - Robolectric 4.0 alpha 1

Published by xian over 6 years ago

NOTE: Robolectric 4.0-alpha-2 is a outdated release candidate; please use 4.0 instead.

robolectric - Robolectric 3.8

Published by brettchabot over 6 years ago

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!

robolectric - Robolectric 3.7.1

Published by brettchabot over 6 years ago

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!

robolectric - Robolectric 3.7

Published by jongerrish over 6 years ago

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!

robolectric - Robolectric 3.6.1

Published by xian almost 7 years ago

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!

robolectric - Robolectric 3.6

Published by xian almost 7 years ago

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!

robolectric - Robolectric 3.6 alpha 1

Published by xian almost 7 years ago

NOTE: Robolectric 3.6-alpha-1 is a outdated release candidate; please use 3.6 instead.

robolectric - Robolectric 3.5.1

Published by xian almost 7 years ago

Robolectric 3.5.1 provides support for Android O_MR1 8.1 beta and two regression fixes.

Features:

  • Support for Android O_MR1 8.1 build 4402310 [issue #3481].

Bug Fixes:

  • Reverts upgrade of bounceycastle which caused SSL handshake failures on some machines. A workaround for people whose builds were fixed by the upgrade is here [issue #3481].
  • Fixed a bug for Buck users that caused an IllegalStateException [issue #3478].

Use Robolectric:

testCompile "org.robolectric:robolectric:3.5.1"

Find more details here. Report issues here. Enjoy!

robolectric - Robolectric 3.5

Published by xian almost 7 years ago

Robolectric 3.5 provides support for Android O 8.0.0_r4 and includes numerous fixes and improvements.

Features:

  • Support for Android O 8.0.0_r4 [issue #3439].
  • Added shadows for DevicePolicyManager [issue #3325] and UsbManager [issue #3420].

Fidelity Improvements

  • Exceptions thrown during Filterable filtering are now correctly caught [issue #3331].
  • Fixed a bug involving AlarmManager and PendingIntents [issue #3332].
  • WebView handles history more consistently [issue #3347].
  • Added attributes and intent filters to BroadcastReceiverData and ServiceData from the manifest [issue #3361].
  • Implemented ApplicationPackageManager.getPackageUid() [issue #3370].
  • Implemented ContentResolver.getPersistedUriPermissions() [issue #3400].
  • Implemented PowerManager.isIgnoringBatteryOptimizations() [issue #3399].
  • Implemented KeyguardManager#isKeyguardLocked() [issue #3401].
  • Implemented UserManager.getSerialNumberForUser() [issue #3406].
  • Implemented NotificationManager.deleteNotificationChannelGroup() [issue #3334] and createNotificationChannels() [issue #3340].
  • More realistic values now provided for ApplicationInfo.uid and Process.myUid() [issue #3440].
  • Implemented TextUtils.ellipsize() [issue #3442].
  • Improved support for KeyguardManager on O [issue #3454].
  • Updated bounceycastle to latest (1.58) [issue #3458].
  • Activity.finishAffinity() correctly causes an activity to be marked finished [issue #3460].

Bug Fixes:

  • Fixes a bug that could cause deadlocks when using AsyncTask [issue #3321].
  • Fixed a bug that caused exceptions thrown during filtering to be incorrectly thrown [issue #3331].
  • ShadowAlarmManager bug fix: PendingIntent equals check now includes requestCode type check [issue #3332].
  • Separated postFrameCallback delay control from postCallback. [issue #3335].
  • Disable animation during DrawerLayout.openDrawer/closeDrawer [issue #3336].
  • Fixed an issue that caused missing resources to throw incorrect exceptions [issues #3312 and #3283].
  • AccessibilityManager now retains state correctly [issue #3372].
  • Fonts in the res directory no longer cause an exception [issue #3398].
  • Improved support for Buck projects with many library dependencies [issue #3429].
  • Improved support for Java 9 [issue #3432].

Deprecations:

  • Deprecated ManifestFactory.create(), RuntimeEnvironment.getAppManifest(), and ShadowApplication.getAppManifest() [issue #3447]. AndroidManifest itself will be deprecated soon; use PackageManager instead.
  • Deprecated WebView.setCanGoBack().
  • Deprecated org.robolectric.util.SimpleFuture [issue #3321].

Misc:

  • Shadow artifacts names are once again correctly prefixed with 'shadows-', so e.g. shadows-framework, etc. Sorry for the thrash on this.
  • Removed support for obsolete Maps API v1 [issue #3305].
  • Shadowed constructor and static initializer methods must now be annotated @Implementation (issue #3122).

Use Robolectric:

testCompile "org.robolectric:robolectric:3.5"

Find more details here. Report issues here. Enjoy!

robolectric - Robolectric 3.4.2

Published by hoisie about 7 years ago

Robolectric 3.4.2 updates the supported version of Android O to Developer Preview 4.

robolectric - Robolectric 3.4.1

Published by xian about 7 years ago

NOTE: this release has a minor bug and has been superseded by 3.4.2.

robolectric - Robolectric 3.4

Published by xian about 7 years ago

Robolectric 3.4 improves support for Android O Developer Preview 2, PackageManager, and many other Android classes, and resolves numerous bugs.

Features:

  • Improved support for NotificationManager features added in Android O [issue #3041].
  • Added test APIs for BatteryManager [issue #3006].
  • Added test APIs for UserManager user restrictions [issue #3027].
  • Added test API for PowerManager.newWakeLock() [issue 3078].
  • Added BackupAgentController test API for backup agents [issue #3016].
  • Added support for BuildCompat's version checking methods; Build.VERSION.CODENAME is now correctly initialized [issue #3031].
  • Improved test API and documentation for ContentResolver.
  • Configuration.orientation now matches the orientation indicated by @Config(qualifiers) [issue #3046].
  • SharedPreferences uses real Android SDK code rather than a shadow [issue #3051].
  • Robolectric.setupContentProvider() can now be called with an authority string [issue #3019].
  • Metadata from manifest is now available for ContentProviders [issue #3022].
  • Added support for SensorManager.createDirectChannel().
  • Added support for get{Target|Creator}Package() to ShadowPendingIntent [issue #3033].
  • Improved support for PackageManager.getResourcesForApplication() [issue #3133].
  • Improved support for PackageManager.queryPermissionsByGroup() [issue #3160].
  • Improved support for PackageManager.getApplicationInfo() [issue #3160].
  • Improved support for PackageManager.getProviderInfo() [issue #3191].
  • ShadowInputMethodManager now supports a callback mechanism for soft input visibility changes [Issue #3136].
  • Added support for several additional methods on StatFs [issue #3128].
  • Added support for WifiManager.getPrivilegedConfiguredNetworks() [issue #3134].
  • Added support for WifiManager#getWifiState() [issue #3146].
  • Added support for WifiManager#isScanAlwaysAvailable() [issue #3259].
  • Added support for queryIntentService() from Manifest [issue #3153].
  • Added support for UserManager.isManagedProfile() [issue #3154].
  • Added PackageInfo.name value to ActivityInfo [issue #3159].
  • Improved support for DownloadManager [issue #3163].
  • Added support for Session.abandon() [issue #3189].
  • Added support for JobScheduler.getPendingJob(int) introduced in Android N [issue #3195].
  • Added support for ‘ShortcutManager’ [issue #3239].
  • Added support for ‘NotificationManager.deleteNotificationChannel’ [issue #3238].
  • Support overridden packages with AGP3.0 [issue #3229].
  • Make TempDirectory shared across entire test env [issue #3199].
  • Added support for AudioManager and TelephonyManager [issue #3255].
  • ShadowService.foregroundStopped is now reset when a service goes into the foreground [issue #3261].
  • ShadowChoreographer now allows customized delay to be specified by application for postCallback and postFrameCallback to avoid animation problems during test [issue #3262].
  • Added correct listen() behavior to ShadowTelephonyManager [issue #3271].

Bug Fixes:

  • Fixed a bug in ShadowLog.getLogs() and getLogsForTags() [issue #3007].
  • Supports targetSdkVersion of O [issue #3037].
  • Fixed a bug that caused Resources.openRawResource() to throw the wrong exception for missing resources [issue #3059].
  • Fixed support for null content values in ContentResolver [issue #3067].
  • Fixed an issue that caused Looper tasks to leak between tests [issue #2963].
  • Fixed a bug parsing escape sequences in string resources [issue #3071].
  • Fixed a bug that could cause temporary files to leak between tests [issue #3081].
  • Fixed a bug that caused MessageQueue to block adding messages to the queue while a message was being handled [issue #3082].
  • Updated ShadowSensorManager and ShadowNotificationManager to be compatible with older SDK versions [issue #3103, #3101].
  • Fixed a bug that caused ActivityManager.getRunningAppProcesses() to return an empty list instead of null [issue #3124].
  • Fixed a bug that prevented BluetoothDevice objects from being created [issue #3197].
  • Fixed a crash in WifiConfiguration.toString() [issue #3144].
  • Fixed Choreographer constructor for O [issue #3240].
  • Fixed race condition in ShadowSQLiteConnection.reset [issue #3211].
  • Fixed a bug that caused file descriptor leaks [issue #3253].
  • Fixed a bug that caused an NPE for some configurations [issue #3220].
  • Fixed a bug that caused an NPE if there's a non-directory with the 'values' prefix in res [issue #3158].

Misc:

  • Robolectric now requires JDK8.
  • Removed deprecated DefaultPackageManager and RobolectricPackageManager [issues #3203 and #3264].
  • Removed deprecated org.robolectric.util controllers [issue #3087].
  • Removed deprecated ShadowConfiguration [issue #3094].
  • Removed deprecated Transcript [issue #3113].
  • Removed unneeded *LayoutParams Shadows [issue #3118].
  • Removed deprecated StubPackageManager [issue #3151].
  • Removed unneeded *CursorAdapter Shadows [issue #3117].
  • Removed deprecated ComponentController.attach() method [issue #3185].
  • Removed deprecated org.robolectric.res.builder.XmlResourceParserImpl.
  • Some Robolectric sub-projects have been renamed. build.gradle files will need to updated accordingly. [issue #3186]:
    • robolectric-annotations -> annotations
    • robolectric-junit -> junit
    • robolectric-processor -> processor
    • robolectric-resources -> resources
    • robolectric-sandbox -> sandbox
    • robolectric-utils -> utils
    • shadows-core -> framework
    • shadows-httpclient -> httpclient
    • shadows-maps -> maps
    • shadows-multidex -> multidex
    • shadows-play-services -> playservices
    • shadows-support-v4 -> supportv4
  • Deprecated @Config attributes that are supplied via new build system API [issue #3230].
  • Bumped android stubs to API 26 [issue #3241].
  • Removed RuntimeAdapter [issue #3218].
  • Removed deprecated ShadowExtractor, AccessibilityUtil, and RoboExecutorService [issue #3174].

Use Robolectric:

testCompile "org.robolectric:robolectric:3.4"

Find more details here. Report issues here. Migration notes here. Enjoy!

robolectric - Robolectric 3.4 RC5

Published by xian about 7 years ago

NOTE: Robolectric 3.4-rc4 is a outdated release candidate; please use 3.4-rc5 instead.