robolectric

Android Unit Testing Framework

OTHER License

Stars
5.8K
Committers
672

Bot releases are hidden (Show)

robolectric - Robolectric 4.4 Alpha 2

Published by hoisie about 4 years ago

NOTE: Robolectric 4.4-alpha-2 is a outdated preview release; please use 4.4 or later instead.

robolectric - Robolectric 4.4 Alpha 1

Published by hoisie over 4 years ago

NOTE: Robolectric 4.4-alpha-1 is a outdated preview release; please use 4.4 or later instead.

robolectric - Robolectric 4.3 Alpha 2

Published by xian over 5 years ago

NOTE: Robolectric 4.3-alpha-2 is a outdated preview release; please use 4.3 or later instead.

robolectric - Robolectric 4.2.1

Published by xian over 5 years ago

This release introduces a new extension mechanism for Robolectric, fixes a major performance regression in 4.x, and includes numerous SDK support improvements and bug fixes.

Bug Fixes

  • Robolectric 4.2.1 fixes a number of issues when running tests on Windows [issue 4670].
  • Applied fixes to activity lifecycle RoboMonitoringInstrumentation [4c7f96820].

Known Issues

  • 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.2.1 and 3.3 report 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.3 or 3.4 Beta
  • Android SDK 28 (includes support for testing against SDKs from 16 on)

Use Robolectric:

testCompile "org.robolectric:robolectric:4.2.1"

Find more details here. Report issues here. Enjoy!

robolectric - Robolectric 4.3 Alpha 1

Published by xian over 5 years ago

NOTE: Robolectric 4.3-alpha-1 is a outdated preview release; please use 4.3-alpha-2 or later instead.

robolectric - Robolectric 4.2

Published by xian over 5 years ago

This release introduces a new extension mechanism for Robolectric, fixes a major performance regression in 4.x, and includes numerous SDK support improvements and bug fixes.

Features

  • Robolectric 4.2 introduces a new plugin system, replacing the previous ad-hoc customization mechanisms (subclassing RobolectricTestRunner, providing system properties, etc.). The old mechanisms are deprecated and will eventually be removed; let us know if there are missing extension points you need. See org.robolectric.pluginapi for more details [issue #4362].
  • Fixed a significant performance regression in 4.x. Thanks @cesar1000! [issues #4142, #4585].
  • For developers of custom shadows, Robolectric 4.2 has a new typesafe and more performant way to access fields and methods on @RealObjects using the Reflector API [issues #4361, #4315, #4351, #4456]

Android SDK support and Test API changes

  • Activities must now be explicitly declared in a manifest (as is the case for normal Android). See #4736 for more context.
  • PackageManager
    • PackageManager is moving to returning defensive immutable copies of its internal data (as on a real device). A series of new testing APIs have been added to modify the package under test; see PackageManager.addOrUpdateActivity() and removeActivity(), plus Service, ContentProvider, and BroadcastReceiver equivalents [issue #4489].
    • Implement PackageManager.isSafeMode() [issue #4526].
  • ShadowDisplayManager.getSaturationLevel() is now an instance method [issue #4522].
  • Telephony
    • Add slotId based getImei() and getMeid() to TelephonyManager [issue #4521].
    • Add the ability to prevent certain networks from being updated in tests [issue #4515].
    • Implement TelephonyManager.getListenersForFlags in tests [issue #4469].
    • Implement TelephonyManager.getVisualVoicemailPackageName() [issue #4444].
  • Bluetooth
    • Test APIs for BluetoothSocket and BluetoothServerSocket connections [issue #4510].
    • Implement BluetoothLeAdvertiser [issues #4478 and #4454].
    • Implement BluetoothHeadset.getConnectedDevices(), getConnectionState(), and sendVendorSpecificResultCode(), with test APIs [issue #4442].
    • Add ability to send BluetoothGattCallback connection state change updates [issue #4584].
  • Implement ActivityManager#getCurrentUser() [issue #4483].
  • UserManager
    • Implement UserManager.getUserSerialNumber() [issue #4501].
    • UserManager#addUser returns a UserHandle to the user it creates [issue #4449].
    • Add isRestrictedProfile() and setIsRestrictedProfile() [issue #4554].
  • Implement Context.sendBroadcastAsUser [issue #4486].
  • Implement WindowManagerImpl#removeViewImmediate(View) [issue #4447].
  • Implement SensorManager.registerListener(): [issue #4446].
  • Implement NetworkScoreManager.disableScoring() and isScoringEnabled() to [issue #4436].
  • DevicePolicyManager now enforces password restrictions [issues #4532, #4545, and #4539].
  • Implement UiModeManager [issue #4548].
  • Implement AccessibilityManager#addAccessibilityStateChangeListener(AccessibilityStateChangeListener, Handler) [issue #4448].
  • Implement ParcelFileDescriptor.createReliablePipe method [issue #4562].
  • Move intent filters to their own lists and out of the Package [issue #4488].
  • Implement WifiRttManager and RangingResult [issue #4561].
  • Add test API to toggle a Sensor wake-up mode [issue #4558].
  • Add PowerManager.WakeLock getTimesHeld() test API to count number of times the wakelock was held [issue #4551].
  • Adds basic MediaCodec and MediaMuxer shadows to robolectric. The MediaCodec shadow implements basic passthrough asynchronous encoding, and the MediaMuxer shadow muxes input bytes directly to the file without modification [issue #4550].
  • Update to ShadowDevicePolicyManager to allow uses-policy granting [issue #4546].
  • Modify ShadowParcel to throw an Error instead of RuntimeException to discourage [issue #4528].
  • Don't autocreate activities in LocalActivityInvoker anymore [issue #4582].
  • Don't automatically generate default ActivityInfo whenever asked [issue #4580].
  • Implements WebView.removeJavascriptInterface [issue #4575].
  • Update to ShadowDevicePolicyManager to set storage encryption [issue #4563].

Configuration

  • There are some small changes to the way Android SDK jars are located; see (LegacyDependencyResolver javadoc)[http://robolectric.org/javadoc/4.2/org/robolectric/plugins/LegacyDependencyResolver.html] for details [issue #4599].

Bug Fixes

  • The android system context is no longer a parent of the application context [issue #4481].
  • Fix LocalActivityInvoker.recreateActivity. Before this change, it called Activity.onRetainNonConfigurationInstance() directly to obtain nonConfigInstance for the activity. This should've called indirectly from Activity.retainNonConfigurationInstances(). retainNonConfigurationInstances() also creates nonConfigInstances for fragments to prepare for the host activity recreation [issue #4511].
  • Fix timeout in FontsContract.getFontSync() caused because Context.canLoadUnsafeResources() now returns false since the context isn't a system context [issue #4517].
  • Fix handling of persisted preferred activities [issue #4480].
  • Fix processName setting and add few more reasonable defaults when installing new package [issue #4465].
  • Add permission check to LocationManager.setLocationEnabledForUser [issue #4500].
  • No longer reset the data position after unmarshalling a ShadowParcel [issue #4468].
  • Fix NPE Robolectric when a failure occurs before shadows are set up [issue #4467].
  • Set AppBindData#processName consistently with ApplicationInfo#processName [issue #4537].
  • Throw NameNotFoundException from Context.createPackageContext for non-existing packages [issue #4527].
  • Synchronize access to ShadowPendingIntent and ShadowUsageStatsManager fields [issue #4520].
  • Fix Activity#isChangingConfigurations() returning false during the recreation [issue #4540].
  • Fix equality in ShadowNetwork [issue #4464].

Deprecations and Removals

  • FsFile et al. have been removed in favor of java.nio.file.Path [issue #4265].
  • ShadowPackageManager.addResolveInfoForIntent is deprecated; add explicit activity declarations in your manifest, or use ShadowPackageManager.addOrUpdateActivity(ActivityInfo) [issue #4489].
  • Deprecate Robolectric#setupActivity in favor of ActivityScenario [issue #4564].

Internal Changes

  • Tests are now run on a dedicated thread for each SDK [issue #4559].
  • Resolve AARs like the android plugins do (kind of) [issue #4279].
  • Reflector objects should unwrap invocation exceptions [issue #4361].
  • Fast private method invocation [issue #4315].
  • Add support for static methods and fields to Reflector [issue #4351].
  • Fix Reflector class definition in Java 11 [issue #4456].
  • Support Java 9 [issue #4400].
  • Robolectric now builds successfully on Windows, though a few tests still fail [issue #4293].
  • Extensible configuration system [issue #4519].
  • Switch circleci to API 28 image. Fix SDK install license fail [issue #4541].
  • Changes to support Java 9 [issue #4452].
  • TypedArray doesn't need a shadow in binary mode [issue #4470].
  • Extract Sdk from SdkConfig [issue #4394].
  • Clean up SdkProvider interface [issue #4513].
  • Move PerfStatsReporter to pluginapi [issue #4471].
  • PerfStatsCollector retains min and max timing info for events [issue #4552].
  • Remove DefaultConfigMerger [issue #4549].

Known Issues

  • 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.
  • Robolectric 4.2 doesn't work on Windows in some cases [issue #4603 et al.].
  • Android Gradle Plugin 3.2.1 and 3.3 report 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.3 or 3.4 Beta
  • Android SDK 28 (includes support for testing against SDKs from 16 on)

Use Robolectric:

testCompile "org.robolectric:robolectric:4.2"

Find more details here. Report issues here. Enjoy!

robolectric - Robolectric 4.2 Beta 1

Published by xian over 5 years ago

NOTE: Robolectric 4.2-beta-1 is an outdated beta release; please use the latest release of 4.2 instead.

robolectric - Robolectric 4.2 Alpha 2

Published by xian over 5 years ago

NOTE: Robolectric 4.2-alpha-2 is an outdated alpha release; please use the latest release of 4.2 instead.

robolectric - Robolectric 4.2 Alpha 1

Published by xian over 5 years ago

NOTE: Robolectric 4.2-alpha-1 is an outdated alpha; please use the latest release of 4.2 instead.

robolectric - Robolectric 4.1

Published by xian almost 6 years ago

Robolectric 4.1 has improved support for a number of androidx.test APIs, and new and improved support and testing APIs for scores of Android classes. Robolectric also now works on Windows again, and has a bunch of other awesome bug fixes.

Features

  • Support ActivityScenario and Espresso in Robolectric paused looper mode [issues #4084 and #4157].
  • Add support for Espresso Intents intending() stubbing functionality [issue #4150].
  • Add ShadowAccessibilityButtonController.
  • Add ShadowDevicePolicyManager.isDeviceManaged().
  • Support androidx.test.core.app.ActivityScenario#getActivityResult.
  • Support androidx.test ActivityScenario#getResult.
  • Add ShadowActivity#getLastRequestedPermission.
  • Support ActivityManager#switchUser.
  • Add SupportFragmentController#saveInstanceState.
  • Add ShadowService#getStopSelfId and getStopSelfResultId.
  • Enhance support for `TextToSpeech#speak.
  • Support PackageManager#getPackagesForUid.
  • Support PackageManager#getResourcesForActivity.
  • Limited support for PackageManager#isInstantApp [issue #3991].
  • Properly implement SharedMemory#map.
  • Add ShadowTrafficStats#tagDatagramSocket.
  • Add VpnService support.
  • Add ShadowConnectivityManager#getLinkProperties.
  • Support setting additional StorageVolume attributes via the builder.
  • Add ShadowServiceManager#setServiceAvailability.
  • Add ability to grant/deny permissions for specific process id and user id.
  • Support Bitmap#eraseColor.
  • Support Bitmap.createBitmap(Picture).
  • Support GLES20 glGenFramebuffers.
  • Support Matrix#setRectToRect.
  • Add ShadowStatusBarManager#getDisableFlags and getDisable2Flags.
  • Support AppsOpManager#noteProxOpNoThrow.
  • Add ShadowWebView#setCurrentWebViewPackage.
  • Add support for checking component enabled status.
  • Add WifiManager#getActiveLockCount.
  • Support BluetoothSocket.
  • Support CaptioningManager listeners.
  • Add shadow for performAccessibilityShortcut.
  • Add Trace support.
  • Remove ability to shadow Object.equals/hashCode/toString on subclasses [issue #3692].
  • Remove deprecated @Implements(inheritImplementationMethods) [issue #3909].
  • Feature request: add mapRadius of ShadowMatrix [issue #4055—thanks @crupest].
  • Add mapRadius for ShadowMatrix [issue #4063—thanks @crupest].
  • Make enabled and other flags in the manifest visible in the Component [issue #4103].
  • Prefetch android all m2 [issue #4237].

Bug Fixes

  • Fix parsing of Windows paths [issue #4287].
  • Obtain file lock before downloading android-all from maven - prevents multiple continuous builds corrupting shared android-all jars [issue #3659].
  • Fix BCP47 language tag generation in ShadowAssetManager.
  • Remove custom managed instances of AppWidgetManager, allow Android to manage instance singletons now.
  • Avoid deadlocks in ClassValueMap exposed with newer versions of cglib with mockito.
  • Fix ApplicationInfo.sourceDir for LOLLIPOP+.
  • Support androidx.test.rules.GrantPermissionRule [issue #4133].
  • Fix concurrent android-all download corruption [issue #4237].
  • PackageManager compatibility fixes:
    • Return defensive copies of ResolveInfo and ApplicationInfo objects.
    • Ensure created components are enabled.
    • Add `FLAG_INSTALLED. by default when adding packages, and add new APIs to add packages without adding default flags.
    • Properly load icons/logos for application components.
  • Fix ResourcesCompat.getFont() on API > 26.
  • Fix WebViewDatabase support.
  • Reset ShadowSubscriptionManager state between tests.
  • Support special characters in espresso typeText [issue #4129].
  • Make Bitmap.compress actually write the image to the stream.
  • Support androidx.test GrantPermissionRule [issue #4133].
  • Make SupportFragmentController call on postCreate at correct point.
  • Fix parsing negative hex numbers in resources.
  • Add an auth intent to the getAuthToken callback bundle if no token is available.
  • Only load SoundPool callbacks for known sounds.
  • Set ServiceInfo.processName from ApplicationInfo.processName [issue #4099].
  • Use ASM 7.0 to support class bytecode version 12 and Java 10+. [issue #4085].
  • Fix iteration over integer keys in a hashmap that caused some resource types to be skipped. [issue #4082].
  • Fix ShadowWindowManagerImpl#getViews() for post-Lollipop.
  • ShadowBitmapFactory.decodeByteArray() always returns a 100x100 Bitmap [issue #4028—thanks @tryal-leaf].
  • Method getLocales in android.content.res.Configuration not mocked [issue #4015—thanks @nikoskyr].
  • Method getLocales in android.content.res.Configuration not mocked [issue #4073—thanks @ScottPierce].
  • java.lang.RuntimeException: Failed to extractAlpha on Bitmap [issue #2795—thanks @zhengxiaopeng].
  • GrantPermissionRule rule does not work on AndroidJUnit4 tests [issue #4133—thanks @goblinr].
  • Fix Canvas NoClassDefFound EGLContext error [issue #4146—thanks @jaredsburrows].
  • ShadowKeyCharacterMap doesn't handle '@' or '-' characters [issue #4129—thanks @aisanu].
  • Espresso calls hang when looper is paused [issue #4084].
  • ActivityScenario.launch fails with paused looper [issue #4157].
  • android-all jar download race (tests failing when maxParallelForks > 1) [issue #2346—thanks @NicoloParolini].
  • Espresso Intents onActivityResult() not invoked when intending() matches a component [issue #4150].
  • Unhelpful error message (java.lang.IllegalStateException: this method should only be called by Robolectric) [issue #4235—thanks @neworld].
  • 4.1-beta-2 Bitmap.eraseColor NPE [issue #4289—thanks @NickButcher1].
  • Fix confusing error message when application.onCreate fails [issue #4286].
  • Oops, fix wrong string splits [issue #4156].
  • Fix ApplicationInfo.sourceDir for LOLLIPOP+ [issue #4270].
  • Synchronize maven downloads of android-all [issue #4241].
  • Fix enum value parsing to allow negative values [for legacy resources] [issue #4112—thanks @cesar1000].

Deprecations and Removals

  • Rename addPackage to installPackage in ShadowPackageManager and deprecate.
  • Deprecate ShadowApplication.getAppWidgetManager().
  • Remove ShadowHandler [issue #4245].
  • Make ShadowSharedMemory implementation methods protected.
  • Rename ShadowPackageManager#getPackageInfoForTesting to getInternalMutablePackageInfo.
  • Deprecate ShadowResolveInfo#setLabel.
  • Remove RoboLayoutInflater and ShadowApplication.getLayoutInflater.

Known Issues

  • Android Gradle Plugin 3.2.1 and 3.3 report 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].
robolectric - Robolectric 4.0.2

Published by xian almost 6 years ago

Robolectric 4.0.2 fixes several bugs in 4.0:

Bug Fixes

  • Resources.getXml() fails with Android 9/aapt2/Studio 3.2.1 (android.content.res.Resources$NotFoundException: Resource ID #0x7f090005) resources [issue #4082].
  • Fake ServiceInfo doesn't contain processName, causing LeakCanary failure [issue #4090].
  • Java 10+ failure/java.lang.NoClassDefFoundError: android/text/TextUtils [issue #4085].
  • Robolectric crashes when loading font from Resources.getFont or ResourceCompat.getFont [issue #3590].
  • Test leakage — ShadowSmsManager is missing a resetter for static state [issue #3811].
  • java.lang.IllegalStateException - android.graphics.Canvas.__constructor__ [issue #4072].

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.. Android Gradle Plugin 3.3 will resolve this issue.

Use Robolectric:

testCompile "org.robolectric:robolectric:4.0.2"

Getting Started | Migrating | Report Issues. Enjoy!

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 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 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.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.