@xian xian released this Jul 27, 2017 · 1909 commits to master since this release

Assets 2

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!