Repository navigation
Run SavedStateTest through platform parceling via platformEncodeDecode - #896
Open
marco-schm wants to merge 1 commit into
Open
marco-schm wants to merge 1 commit into
marco-schm wants to merge 1 commit into
Conversation
The SavedState serialization tests already use platformEncodeDecode to simulate parceling/unparceling on Android. This applies the same treatment to SavedStateTest. SavedStateTest now routes every state under test through an overridable postProcessCreated hook (a no-op by default) by shadowing the top-level savedState factories inside the test class. A new ParceledSavedStateTest subclass (androidHostTest and androidDeviceTest) overrides the hook with platformEncodeDecode, so all 187 tests additionally run against a state that went through Parcel writing, byte marshalling, and unparceling. The parceled run initially uncovered 8 tests whose assertions relied on reference equality of values without structural equals (SavedState/Bundle instances, and arrays inside maps), which only passed because the reader returns the stored instances when no parceling is involved. Those assertions now use contentDeepEquals-based structural comparison, matching the approach already used by factory_withSavedState_hasInitialState and the codec tests. Test: ./gradlew :savedstate:savedstate:testAndroidHostTest (SavedStateTest 187 tests and ParceledSavedStateTest 187 tests, all green; full module host suite: 611 tests, 0 failures) Fixes: b/402141515
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed Changes
SavedStateTestthrough an overridablepostProcessCreatedhook (a no-op by default) by shadowing the top-levelsavedStatefactories inside the test classParceledSavedStateTestsubclass (in androidHostTest and androidDeviceTest) that overrides the hook with the existingplatformEncodeDecodefromSavedStateCodecTestUtils, so all 187 tests additionally run against a state that went through Parcel writing, byte marshalling, and unparceling, matching the treatment the serialization tests already getcontentDeepEquals-based structural comparison. The parceled run uncovered that these relied on reference equality of values without structural equals (SavedState/Bundleinstances, and arrays inside maps) and only passed because the reader returns the stored instances when no parceling is involved. This matches the approach already used byfactory_withSavedState_hasInitialStateand the codec testsTesting
Test: ./gradlew :savedstate:savedstate:testAndroidHostTest
SavedStateTest(187 tests) andParceledSavedStateTest(187 tests) both pass; full module host suite: 611 tests, 0 failures. The androidDeviceTest sources compile as well.Issues Fixed
Fixes: b/402141515