Fix null pointer in dashboard fragment test.

- use context instead of activity to retrieve resource details.
- revert the change previously made in getActivity() calls.
- add null checking in package name and tile intent.

Fix: 34396855
Test: make RunSettingsRoboTests

Change-Id: Ic853939fee3c381b663c0320354da51d3b2a0e11
This commit is contained in:
Doris Ling
2017-01-18 17:03:26 -08:00
parent 1d0e6c8cee
commit fd83b2eb52
2 changed files with 10 additions and 8 deletions

View File

@@ -79,6 +79,7 @@ public class DashboardFragmentTest {
when(mFakeFeatureFactory.dashboardFeatureProvider.getTilesForCategory(anyString()))
.thenReturn(mDashboardCategory);
mTestFragment.onAttach(ShadowApplication.getInstance().getApplicationContext());
when(mContext.getPackageName()).thenReturn("TestPackage");
}
@Test