Fix AccessibilityButtonFragmentTest

**Root cause**
We expected the spy resources will be used when calling
context.getResources(). However, we didn't set up the connection. Hence
the test failed due to trying to use the original resources.

Bug: 279082331
Test: atest AccessibilityButtonFragmentTest
Change-Id: Ib6e51b2b2607bec7980b9288a0a8076e4a036863
This commit is contained in:
Chun-Ku Lin
2023-06-02 22:15:15 +00:00
parent aeb630b1f5
commit e63659e6db

View File

@@ -67,6 +67,7 @@ public class AccessibilityButtonFragmentTest {
@Before
public void setUp() {
mFragment = spy(new TestAccessibilityButtonFragment(mContext));
when(mContext.getResources()).thenReturn(mResources);
when(mFragment.getResources()).thenReturn(mResources);
when(mFragment.getActivity()).thenReturn(Robolectric.setupActivity(FragmentActivity.class));
}