Add additional mocking for Context innards
Test: as follows
- built
- flashed
- booted
- runtest frameworks-net passes
- cherry-picked to master and verified there as well
Bug: 32163131
Bug: 32561414
Merged-In: I2695841bfc31280060754132e589af1ca95911da
Merged-In: I9a05f34035a15b233a44d517f2b2426481679974
Change-Id: I0b5b1b12d55547d08c332c7d274f19f0023a7b07
(cherry picked from commit ec37275ec9702b56bf328031675906a5483b89d4)
diff --git a/tests/net/java/com/android/server/connectivity/tethering/OffloadControllerTest.java b/tests/net/java/com/android/server/connectivity/tethering/OffloadControllerTest.java
index c535c45..4d340d1 100644
--- a/tests/net/java/com/android/server/connectivity/tethering/OffloadControllerTest.java
+++ b/tests/net/java/com/android/server/connectivity/tethering/OffloadControllerTest.java
@@ -30,6 +30,7 @@
import static org.mockito.Mockito.when;
import android.content.Context;
+import android.content.pm.ApplicationInfo;
import android.net.LinkAddress;
import android.net.LinkProperties;
import android.net.RouteInfo;
@@ -59,15 +60,17 @@
public class OffloadControllerTest {
@Mock private OffloadHardwareInterface mHardware;
+ @Mock private ApplicationInfo mApplicationInfo;
@Mock private Context mContext;
final ArgumentCaptor<ArrayList> mStringArrayCaptor = ArgumentCaptor.forClass(ArrayList.class);
private MockContentResolver mContentResolver;
@Before public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
+ when(mContext.getApplicationInfo()).thenReturn(mApplicationInfo);
+ when(mContext.getPackageName()).thenReturn("OffloadControllerTest");
mContentResolver = new MockContentResolver(mContext);
mContentResolver.addProvider(Settings.AUTHORITY, new FakeSettingsProvider());
- when(mContext.getPackageName()).thenReturn("OffloadControllerTest");
when(mContext.getContentResolver()).thenReturn(mContentResolver);
}