diff options
author | Rebecca Silberstein <silberst@google.com> | 2017-04-05 10:01:12 -0700 |
---|---|---|
committer | Rebecca Silberstein <silberst@google.com> | 2017-04-11 18:13:03 +0000 |
commit | 6232408a5fc660b2d8642d56747e05c15c6255b8 (patch) | |
tree | 431c8104189c93e105f87b464e5ff476fe8d6ebd | |
parent | 36f52ffb5fd16c89f022dead27d8df9e51874160 (diff) |
WifiServiceImpl: fix failing test
Fix failing unit test due to a change in the implementation of
registerContentObserver. This method is final so our mock was not being
called. The implementation change uses a static method, ultimately the
source of the failure.
Bug: 36919372
Test: frameworks/opt/net/wifi/tests/wifitests/runtests.sh
Change-Id: I15d680fdf1211c1171708a3305bdcdcf4b916961
Merged-In: I15d680fdf1211c1171708a3305bdcdcf4b916961
-rw-r--r-- | service/java/com/android/server/wifi/WifiServiceImpl.java | 3 | ||||
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java | 3 |
2 files changed, 4 insertions, 2 deletions
diff --git a/service/java/com/android/server/wifi/WifiServiceImpl.java b/service/java/com/android/server/wifi/WifiServiceImpl.java index a327fa7b1..c3e80705d 100644 --- a/service/java/com/android/server/wifi/WifiServiceImpl.java +++ b/service/java/com/android/server/wifi/WifiServiceImpl.java @@ -1481,8 +1481,7 @@ public class WifiServiceImpl extends IWifiManager.Stub { mWifiController.sendMessage(CMD_SCAN_ALWAYS_MODE_CHANGED); } }; - - mContext.getContentResolver().registerContentObserver( + mFrameworkFacade.registerContentObserver(mContext, Settings.Global.getUriFor(Settings.Global.WIFI_SCAN_ALWAYS_AVAILABLE), false, contentObserver); } diff --git a/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java b/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java index 71ca0204f..4cdd0f684 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java @@ -151,10 +151,13 @@ public class WifiServiceImplTest { when(mWifiInjector.getWifiController()).thenReturn(mWifiController); when(mWifiInjector.getWifiMetrics()).thenReturn(mWifiMetrics); when(mWifiInjector.getWifiStateMachine()).thenReturn(mWifiStateMachine); + when(mWifiStateMachine.syncInitialize(any())).thenReturn(true); when(mWifiInjector.getWifiServiceHandlerThread()).thenReturn(mHandlerThread); when(mHandlerThread.getLooper()).thenReturn(mLooper.getLooper()); when(mContext.getResources()).thenReturn(mResources); when(mContext.getContentResolver()).thenReturn(mContentResolver); + doNothing().when(mFrameworkFacade).registerContentObserver(eq(mContext), any(), + anyBoolean(), any()); IPowerManager powerManagerService = mock(IPowerManager.class); mPowerManager = new PowerManager(mContext, powerManagerService, new Handler()); when(mContext.getSystemServiceName(PowerManager.class)).thenReturn(Context.POWER_SERVICE); |