summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorErik Kline <ek@google.com>2016-10-04 15:19:37 +0900
committerErik Kline <ek@google.com>2016-10-04 17:08:57 +0900
commit458d8dceedd28a99084d17a5d3118f2c03b3c2d9 (patch)
treed7038cd8dfa52729acded455c1f70c4d01d9baa2 /tests
parent59062f8fb08c9a5587e0155e01df1b9dda24f840 (diff)
Add more capable Settings abstractions to accomodate IpManager
IpManager contains an AvoidBadWifiTracker which makes various settings checks. Add a MockContentProvider with noop implementation. Test: treehugger Bug: 31827713 Change-Id: I9c03c379d2f94fa6f751e2f97a68a5ba1a8eea8b
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java16
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()));