robolectric/robolectric — pull request #1437 by BernNotice (2014-12-24 03:53:28+00:00)
Title: Fixing ContentResolver's add and remove methods for PeriodicSyncs and adding cancelSync

- addPeriodicSync was incorrect. It did not look for a PeriodicSync with the same tuple of (account, authority, bundle) and update its sync time if already existed.
Note, that this implementation is not stable (it removes and adds, instead of replacing).
I do not think getPeriodicSyncs guarantees the return of an ordered list, so I think this is fine.

- removePeriodicSync was also wrong. It cleared all the periodic syncs instead of the (account, authority, bundle) matching tuple.

- cancelSync is implemented. A note is left as to whether removing periodic syncs is going too far. But it seems the safest for now.

- Tests take advantage of fluid assertions, and are changed to reflect the interfaces that methods care about (e.g. add/removePeriodicSync are now tested against getPeriodicSyncs)