Fix ToggleScreenMagnificationPreferenceFragmentTest
- Prevent mocking ToggleScreenMagnificationPreferenceFragment for test - Use Robolectric's way to launch the fragment so that the fragment contains necessary setup **Root cause** - We called onCreateView directly in the test without the necessary setup in onCreate, which causes the FooterPreferenceController not being initialized. - We created a spyContext that returns a mock PackageManager, however, in the test execution, we didn't mock the context used by the fragment under test. Hence, the fragment didn't use the mock PackageManager in test. Bug: 284209879 Test: atest ToggleScreenMagnificationPreferenceFragmentTest --iterations 5 Change-Id: I7e71a03177526f5bb0c20a58855a7dfdffc2a22f
Loading
Please register or sign in to comment