diff options
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java b/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java index 24f383a1d..e3deb5839 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java @@ -23,7 +23,6 @@ import static org.mockito.Mockito.*; import android.app.ActivityManager; import android.app.test.MockAnswerUtil.AnswerWithArguments; import android.app.test.TestAlarmManager; -import android.content.ContentResolver; import android.content.Context; import android.content.pm.PackageManager; import android.content.pm.UserInfo; @@ -44,6 +43,7 @@ import android.net.wifi.WifiSsid; import android.net.wifi.p2p.IWifiP2pManager; import android.os.BatteryStats; import android.os.Binder; +import android.os.Bundle; import android.os.Handler; import android.os.HandlerThread; import android.os.IBinder; @@ -60,6 +60,8 @@ import android.os.UserManager; import android.os.test.TestLooper; import android.provider.Settings; import android.security.KeyStore; +import android.test.mock.MockContentProvider; +import android.test.mock.MockContentResolver; import android.test.suitebuilder.annotation.SmallTest; import android.util.Log; @@ -199,13 +201,19 @@ public class WifiStateMachineTest { Context context = mock(Context.class); when(context.getPackageManager()).thenReturn(pkgMgr); - when(context.getContentResolver()).thenReturn(mock(ContentResolver.class)); MockResources resources = new com.android.server.wifi.MockResources(); when(context.getResources()).thenReturn(resources); - ContentResolver cr = mock(ContentResolver.class); - when(context.getContentResolver()).thenReturn(cr); + MockContentResolver mockContentResolver = new MockContentResolver(); + mockContentResolver.addProvider(Settings.AUTHORITY, + new MockContentProvider(context) { + @Override + public Bundle call(String method, String arg, Bundle extras) { + return new Bundle(); + } + }); + when(context.getContentResolver()).thenReturn(mockContentResolver); when(context.getSystemService(Context.POWER_SERVICE)).thenReturn( new PowerManager(context, mock(IPowerManager.class), new Handler())); |