Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2015 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
Jason Monk | e0cdb60 | 2014-11-05 12:39:45 -0500 | [diff] [blame] | 16 | |
| 17 | package com.android.systemui.statusbar.policy; |
| 18 | |
| 19 | import static org.mockito.Mockito.mock; |
| 20 | import static org.mockito.Mockito.when; |
| 21 | |
Jason Monk | e0cdb60 | 2014-11-05 12:39:45 -0500 | [diff] [blame] | 22 | import android.content.Intent; |
| 23 | import android.net.ConnectivityManager; |
Jason Monk | d8e4bf4 | 2014-12-12 10:23:12 -0500 | [diff] [blame] | 24 | import android.net.NetworkCapabilities; |
Jason Monk | f13b4b3 | 2014-11-07 16:39:34 -0500 | [diff] [blame] | 25 | import android.net.wifi.WifiManager; |
Jason Monk | 07b75fe | 2015-05-14 16:47:03 -0400 | [diff] [blame] | 26 | import android.os.Looper; |
Jason Monk | e0cdb60 | 2014-11-05 12:39:45 -0500 | [diff] [blame] | 27 | import android.telephony.PhoneStateListener; |
| 28 | import android.telephony.ServiceState; |
| 29 | import android.telephony.SignalStrength; |
Jason Monk | b574627 | 2014-11-12 16:50:31 -0500 | [diff] [blame] | 30 | import android.telephony.SubscriptionInfo; |
| 31 | import android.telephony.SubscriptionManager; |
Jason Monk | f13b4b3 | 2014-11-07 16:39:34 -0500 | [diff] [blame] | 32 | import android.telephony.TelephonyManager; |
Jason Monk | e0cdb60 | 2014-11-05 12:39:45 -0500 | [diff] [blame] | 33 | import android.util.Log; |
| 34 | |
Jason Monk | f13b4b3 | 2014-11-07 16:39:34 -0500 | [diff] [blame] | 35 | import com.android.internal.telephony.cdma.EriInfo; |
Chris Wren | 930ecca | 2014-11-12 17:43:41 -0500 | [diff] [blame] | 36 | import com.android.systemui.SysuiTestCase; |
Jason Monk | 33f8ae7 | 2015-05-08 10:45:15 -0400 | [diff] [blame] | 37 | import com.android.systemui.statusbar.policy.NetworkController.IconState; |
Jason Monk | d2263cd | 2014-11-10 14:22:56 -0500 | [diff] [blame] | 38 | import com.android.systemui.statusbar.policy.NetworkControllerImpl.Config; |
Jason Monk | e0cdb60 | 2014-11-05 12:39:45 -0500 | [diff] [blame] | 39 | |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 40 | import org.mockito.ArgumentCaptor; |
| 41 | import org.mockito.Mockito; |
| 42 | |
| 43 | import java.io.PrintWriter; |
| 44 | import java.io.StringWriter; |
| 45 | import java.util.ArrayList; |
| 46 | import java.util.List; |
| 47 | |
Chris Wren | 930ecca | 2014-11-12 17:43:41 -0500 | [diff] [blame] | 48 | public class NetworkControllerBaseTest extends SysuiTestCase { |
Jason Monk | e0cdb60 | 2014-11-05 12:39:45 -0500 | [diff] [blame] | 49 | private static final String TAG = "NetworkControllerBaseTest"; |
Jason Monk | f13b4b3 | 2014-11-07 16:39:34 -0500 | [diff] [blame] | 50 | protected static final int DEFAULT_LEVEL = 2; |
| 51 | protected static final int DEFAULT_SIGNAL_STRENGTH = |
| 52 | TelephonyIcons.TELEPHONY_SIGNAL_STRENGTH[1][DEFAULT_LEVEL]; |
| 53 | protected static final int DEFAULT_QS_SIGNAL_STRENGTH = |
| 54 | TelephonyIcons.QS_TELEPHONY_SIGNAL_STRENGTH[1][DEFAULT_LEVEL]; |
| 55 | protected static final int DEFAULT_ICON = TelephonyIcons.ICON_3G; |
| 56 | protected static final int DEFAULT_QS_ICON = TelephonyIcons.QS_ICON_3G; |
Jason Monk | e0cdb60 | 2014-11-05 12:39:45 -0500 | [diff] [blame] | 57 | |
| 58 | protected NetworkControllerImpl mNetworkController; |
Leigh Anne | d0a6279 | 2014-11-13 14:27:10 -0800 | [diff] [blame] | 59 | protected MobileSignalController mMobileSignalController; |
Jason Monk | e0cdb60 | 2014-11-05 12:39:45 -0500 | [diff] [blame] | 60 | protected PhoneStateListener mPhoneStateListener; |
Jason Monk | e0cdb60 | 2014-11-05 12:39:45 -0500 | [diff] [blame] | 61 | private SignalStrength mSignalStrength; |
| 62 | private ServiceState mServiceState; |
Jason Monk | f13b4b3 | 2014-11-07 16:39:34 -0500 | [diff] [blame] | 63 | protected ConnectivityManager mMockCm; |
| 64 | protected WifiManager mMockWm; |
Jason Monk | b574627 | 2014-11-12 16:50:31 -0500 | [diff] [blame] | 65 | protected SubscriptionManager mMockSm; |
Jason Monk | f13b4b3 | 2014-11-07 16:39:34 -0500 | [diff] [blame] | 66 | protected TelephonyManager mMockTm; |
Jason Monk | d2263cd | 2014-11-10 14:22:56 -0500 | [diff] [blame] | 67 | protected Config mConfig; |
Jason Monk | 07b75fe | 2015-05-14 16:47:03 -0400 | [diff] [blame] | 68 | protected CallbackHandler mCallbackHandler; |
Jason Monk | e0cdb60 | 2014-11-05 12:39:45 -0500 | [diff] [blame] | 69 | |
Jason Monk | 18985e0 | 2015-01-07 12:07:06 -0500 | [diff] [blame] | 70 | protected int mSubId; |
| 71 | |
Jason Monk | d8e4bf4 | 2014-12-12 10:23:12 -0500 | [diff] [blame] | 72 | private NetworkCapabilities mNetCapabilities; |
| 73 | |
Jason Monk | e0cdb60 | 2014-11-05 12:39:45 -0500 | [diff] [blame] | 74 | @Override |
| 75 | protected void setUp() throws Exception { |
| 76 | super.setUp(); |
Jason Monk | e0cdb60 | 2014-11-05 12:39:45 -0500 | [diff] [blame] | 77 | |
Jason Monk | f13b4b3 | 2014-11-07 16:39:34 -0500 | [diff] [blame] | 78 | mMockWm = mock(WifiManager.class); |
| 79 | mMockTm = mock(TelephonyManager.class); |
Jason Monk | b574627 | 2014-11-12 16:50:31 -0500 | [diff] [blame] | 80 | mMockSm = mock(SubscriptionManager.class); |
Jason Monk | f13b4b3 | 2014-11-07 16:39:34 -0500 | [diff] [blame] | 81 | mMockCm = mock(ConnectivityManager.class); |
Jason Monk | d8e4bf4 | 2014-12-12 10:23:12 -0500 | [diff] [blame] | 82 | mNetCapabilities = new NetworkCapabilities(); |
Jason Monk | f13b4b3 | 2014-11-07 16:39:34 -0500 | [diff] [blame] | 83 | when(mMockCm.isNetworkSupported(ConnectivityManager.TYPE_MOBILE)).thenReturn(true); |
Jason Monk | d8e4bf4 | 2014-12-12 10:23:12 -0500 | [diff] [blame] | 84 | when(mMockCm.getDefaultNetworkCapabilitiesForUser(0)).thenReturn( |
| 85 | new NetworkCapabilities[] { mNetCapabilities }); |
Jason Monk | e0cdb60 | 2014-11-05 12:39:45 -0500 | [diff] [blame] | 86 | |
Jason Monk | e0cdb60 | 2014-11-05 12:39:45 -0500 | [diff] [blame] | 87 | mSignalStrength = mock(SignalStrength.class); |
| 88 | mServiceState = mock(ServiceState.class); |
Jason Monk | f13b4b3 | 2014-11-07 16:39:34 -0500 | [diff] [blame] | 89 | |
Jason Monk | d2263cd | 2014-11-10 14:22:56 -0500 | [diff] [blame] | 90 | mConfig = new Config(); |
| 91 | mConfig.hspaDataDistinguishable = true; |
Jason Monk | 07b75fe | 2015-05-14 16:47:03 -0400 | [diff] [blame] | 92 | mCallbackHandler = mock(CallbackHandler.class); |
Jason Monk | b574627 | 2014-11-12 16:50:31 -0500 | [diff] [blame] | 93 | mNetworkController = new NetworkControllerImpl(mContext, mMockCm, mMockTm, mMockWm, mMockSm, |
Jason Monk | 07b75fe | 2015-05-14 16:47:03 -0400 | [diff] [blame] | 94 | mConfig, Looper.getMainLooper(), mCallbackHandler, |
| 95 | mock(AccessPointControllerImpl.class), mock(MobileDataControllerImpl.class)); |
Jason Monk | f13b4b3 | 2014-11-07 16:39:34 -0500 | [diff] [blame] | 96 | setupNetworkController(); |
| 97 | } |
| 98 | |
| 99 | protected void setupNetworkController() { |
Jason Monk | b574627 | 2014-11-12 16:50:31 -0500 | [diff] [blame] | 100 | // For now just pretend to be the data sim, so we can test that too. |
Jason Monk | 07b75fe | 2015-05-14 16:47:03 -0400 | [diff] [blame] | 101 | mSubId = SubscriptionManager.DEFAULT_SUBSCRIPTION_ID; |
Jason Monk | b574627 | 2014-11-12 16:50:31 -0500 | [diff] [blame] | 102 | SubscriptionInfo subscription = mock(SubscriptionInfo.class); |
| 103 | List<SubscriptionInfo> subs = new ArrayList<SubscriptionInfo>(); |
Jason Monk | 18985e0 | 2015-01-07 12:07:06 -0500 | [diff] [blame] | 104 | when(subscription.getSubscriptionId()).thenReturn(mSubId); |
Jason Monk | b574627 | 2014-11-12 16:50:31 -0500 | [diff] [blame] | 105 | subs.add(subscription); |
| 106 | mNetworkController.setCurrentSubscriptions(subs); |
Jason Monk | 18985e0 | 2015-01-07 12:07:06 -0500 | [diff] [blame] | 107 | mMobileSignalController = mNetworkController.mMobileSignalControllers.get(mSubId); |
Jason Monk | 07b75fe | 2015-05-14 16:47:03 -0400 | [diff] [blame] | 108 | mMobileSignalController.getState().dataSim = true; |
Leigh Anne | d0a6279 | 2014-11-13 14:27:10 -0800 | [diff] [blame] | 109 | mPhoneStateListener = mMobileSignalController.mPhoneStateListener; |
Jason Monk | 07b75fe | 2015-05-14 16:47:03 -0400 | [diff] [blame] | 110 | |
| 111 | // Trigger blank callbacks to always get the current state (some tests don't trigger |
| 112 | // changes from default state). |
| 113 | mNetworkController.addSignalCallback(null); |
Jason Monk | e0cdb60 | 2014-11-05 12:39:45 -0500 | [diff] [blame] | 114 | } |
| 115 | |
Leigh Anne | d0a6279 | 2014-11-13 14:27:10 -0800 | [diff] [blame] | 116 | protected NetworkControllerImpl setUpNoMobileData() { |
| 117 | when(mMockCm.isNetworkSupported(ConnectivityManager.TYPE_MOBILE)).thenReturn(false); |
| 118 | NetworkControllerImpl networkControllerNoMobile |
| 119 | = new NetworkControllerImpl(mContext, mMockCm, mMockTm, mMockWm, mMockSm, |
Jason Monk | 07b75fe | 2015-05-14 16:47:03 -0400 | [diff] [blame] | 120 | mConfig, Looper.getMainLooper(), mCallbackHandler, |
| 121 | mock(AccessPointControllerImpl.class), |
Leigh Anne | d0a6279 | 2014-11-13 14:27:10 -0800 | [diff] [blame] | 122 | mock(MobileDataControllerImpl.class)); |
| 123 | |
| 124 | setupNetworkController(); |
| 125 | |
| 126 | return networkControllerNoMobile; |
| 127 | |
| 128 | } |
| 129 | |
Jason Monk | e0cdb60 | 2014-11-05 12:39:45 -0500 | [diff] [blame] | 130 | @Override |
| 131 | protected void tearDown() throws Exception { |
| 132 | StringWriter sw = new StringWriter(); |
| 133 | PrintWriter pw = new PrintWriter(sw); |
| 134 | mNetworkController.dump(null, pw, null); |
| 135 | pw.flush(); |
| 136 | Log.d(TAG, sw.toString()); |
| 137 | super.tearDown(); |
| 138 | } |
| 139 | |
Jason Monk | f13b4b3 | 2014-11-07 16:39:34 -0500 | [diff] [blame] | 140 | // 2 Bars 3G GSM. |
| 141 | public void setupDefaultSignal() { |
| 142 | setIsGsm(true); |
| 143 | setVoiceRegState(ServiceState.STATE_IN_SERVICE); |
| 144 | setGsmRoaming(false); |
| 145 | setLevel(DEFAULT_LEVEL); |
| 146 | updateDataConnectionState(TelephonyManager.DATA_CONNECTED, |
| 147 | TelephonyManager.NETWORK_TYPE_UMTS); |
Jason Monk | 33f8ae7 | 2015-05-08 10:45:15 -0400 | [diff] [blame] | 148 | setConnectivity(NetworkCapabilities.TRANSPORT_CELLULAR, true, true); |
Jason Monk | f13b4b3 | 2014-11-07 16:39:34 -0500 | [diff] [blame] | 149 | } |
| 150 | |
Jason Monk | 33f8ae7 | 2015-05-08 10:45:15 -0400 | [diff] [blame] | 151 | public void setConnectivity(int networkType, boolean inetCondition, boolean isConnected) { |
Jason Monk | e0cdb60 | 2014-11-05 12:39:45 -0500 | [diff] [blame] | 152 | Intent i = new Intent(ConnectivityManager.INET_CONDITION_ACTION); |
Jason Monk | d8e4bf4 | 2014-12-12 10:23:12 -0500 | [diff] [blame] | 153 | // TODO: Separate out into several NetworkCapabilities. |
| 154 | if (isConnected) { |
| 155 | mNetCapabilities.addTransportType(networkType); |
| 156 | } else { |
| 157 | mNetCapabilities.removeTransportType(networkType); |
| 158 | } |
Jason Monk | 33f8ae7 | 2015-05-08 10:45:15 -0400 | [diff] [blame] | 159 | if (inetCondition) { |
Jason Monk | d8e4bf4 | 2014-12-12 10:23:12 -0500 | [diff] [blame] | 160 | mNetCapabilities.addCapability(NetworkCapabilities.NET_CAPABILITY_VALIDATED); |
| 161 | } else { |
| 162 | mNetCapabilities.removeCapability(NetworkCapabilities.NET_CAPABILITY_VALIDATED); |
| 163 | } |
Jason Monk | e0cdb60 | 2014-11-05 12:39:45 -0500 | [diff] [blame] | 164 | |
Jason Monk | e0cdb60 | 2014-11-05 12:39:45 -0500 | [diff] [blame] | 165 | mNetworkController.onReceive(mContext, i); |
| 166 | } |
| 167 | |
| 168 | public void setGsmRoaming(boolean isRoaming) { |
| 169 | when(mServiceState.getRoaming()).thenReturn(isRoaming); |
| 170 | updateServiceState(); |
| 171 | } |
| 172 | |
Jason Monk | f13b4b3 | 2014-11-07 16:39:34 -0500 | [diff] [blame] | 173 | public void setCdmaRoaming(boolean isRoaming) { |
| 174 | when(mServiceState.getCdmaEriIconIndex()).thenReturn(isRoaming ? |
| 175 | EriInfo.ROAMING_INDICATOR_ON : EriInfo.ROAMING_INDICATOR_OFF); |
| 176 | when(mServiceState.getCdmaEriIconMode()).thenReturn(isRoaming ? |
| 177 | EriInfo.ROAMING_ICON_MODE_NORMAL : -1); |
| 178 | updateServiceState(); |
| 179 | } |
| 180 | |
Jason Monk | e0cdb60 | 2014-11-05 12:39:45 -0500 | [diff] [blame] | 181 | public void setVoiceRegState(int voiceRegState) { |
| 182 | when(mServiceState.getVoiceRegState()).thenReturn(voiceRegState); |
| 183 | updateServiceState(); |
| 184 | } |
| 185 | |
Jason Monk | f13b4b3 | 2014-11-07 16:39:34 -0500 | [diff] [blame] | 186 | public void setDataRegState(int dataRegState) { |
| 187 | when(mServiceState.getDataRegState()).thenReturn(dataRegState); |
| 188 | updateServiceState(); |
| 189 | } |
| 190 | |
Jason Monk | e0cdb60 | 2014-11-05 12:39:45 -0500 | [diff] [blame] | 191 | public void setIsEmergencyOnly(boolean isEmergency) { |
| 192 | when(mServiceState.isEmergencyOnly()).thenReturn(isEmergency); |
| 193 | updateServiceState(); |
| 194 | } |
| 195 | |
| 196 | public void setCdmaLevel(int level) { |
| 197 | when(mSignalStrength.getCdmaLevel()).thenReturn(level); |
| 198 | updateSignalStrength(); |
| 199 | } |
| 200 | |
| 201 | public void setLevel(int level) { |
| 202 | when(mSignalStrength.getLevel()).thenReturn(level); |
| 203 | updateSignalStrength(); |
| 204 | } |
| 205 | |
| 206 | public void setIsGsm(boolean gsm) { |
| 207 | when(mSignalStrength.isGsm()).thenReturn(gsm); |
| 208 | updateSignalStrength(); |
| 209 | } |
| 210 | |
| 211 | public void setCdmaEri(int index, int mode) { |
| 212 | // TODO: Figure this out. |
| 213 | } |
| 214 | |
| 215 | private void updateSignalStrength() { |
| 216 | Log.d(TAG, "Sending Signal Strength: " + mSignalStrength); |
| 217 | mPhoneStateListener.onSignalStrengthsChanged(mSignalStrength); |
| 218 | } |
| 219 | |
| 220 | private void updateServiceState() { |
| 221 | Log.d(TAG, "Sending Service State: " + mServiceState); |
| 222 | mPhoneStateListener.onServiceStateChanged(mServiceState); |
| 223 | } |
| 224 | |
| 225 | public void updateCallState(int state) { |
| 226 | // Inputs not currently used in NetworkControllerImpl. |
| 227 | mPhoneStateListener.onCallStateChanged(state, "0123456789"); |
| 228 | } |
| 229 | |
| 230 | public void updateDataConnectionState(int dataState, int dataNetType) { |
| 231 | mPhoneStateListener.onDataConnectionStateChanged(dataState, dataNetType); |
| 232 | } |
| 233 | |
| 234 | public void updateDataActivity(int dataActivity) { |
| 235 | mPhoneStateListener.onDataActivity(dataActivity); |
| 236 | } |
| 237 | |
Andrew Flynn | 5e75147 | 2015-05-01 11:50:07 -0400 | [diff] [blame] | 238 | public void setCarrierNetworkChange(boolean enable) { |
| 239 | Log.d(TAG, "setCarrierNetworkChange(" + enable + ")"); |
| 240 | mPhoneStateListener.onCarrierNetworkChange(enable); |
| 241 | } |
| 242 | |
Jason Monk | 21d05a0 | 2014-12-02 12:46:58 -0500 | [diff] [blame] | 243 | protected void verifyHasNoSims(boolean hasNoSimsVisible) { |
| 244 | ArgumentCaptor<Boolean> hasNoSimsArg = ArgumentCaptor.forClass(Boolean.class); |
| 245 | |
Jason Monk | 07b75fe | 2015-05-14 16:47:03 -0400 | [diff] [blame] | 246 | Mockito.verify(mCallbackHandler, Mockito.atLeastOnce()).setNoSims(hasNoSimsArg.capture()); |
| 247 | assertEquals("No sims", hasNoSimsVisible, (boolean) hasNoSimsArg.getValue()); |
Jason Monk | 21d05a0 | 2014-12-02 12:46:58 -0500 | [diff] [blame] | 248 | } |
| 249 | |
Jason Monk | f13b4b3 | 2014-11-07 16:39:34 -0500 | [diff] [blame] | 250 | protected void verifyLastQsMobileDataIndicators(boolean visible, int icon, int typeIcon, |
Jason Monk | b574627 | 2014-11-12 16:50:31 -0500 | [diff] [blame] | 251 | boolean dataIn, boolean dataOut) { |
Jason Monk | 07b75fe | 2015-05-14 16:47:03 -0400 | [diff] [blame] | 252 | ArgumentCaptor<IconState> iconArg = ArgumentCaptor.forClass(IconState.class); |
Jason Monk | f13b4b3 | 2014-11-07 16:39:34 -0500 | [diff] [blame] | 253 | ArgumentCaptor<Integer> typeIconArg = ArgumentCaptor.forClass(Integer.class); |
Jason Monk | f13b4b3 | 2014-11-07 16:39:34 -0500 | [diff] [blame] | 254 | ArgumentCaptor<Boolean> dataInArg = ArgumentCaptor.forClass(Boolean.class); |
| 255 | ArgumentCaptor<Boolean> dataOutArg = ArgumentCaptor.forClass(Boolean.class); |
Jason Monk | f13b4b3 | 2014-11-07 16:39:34 -0500 | [diff] [blame] | 256 | |
Jason Monk | 07b75fe | 2015-05-14 16:47:03 -0400 | [diff] [blame] | 257 | Mockito.verify(mCallbackHandler, Mockito.atLeastOnce()).setMobileDataIndicators( |
| 258 | ArgumentCaptor.forClass(IconState.class).capture(), |
| 259 | iconArg.capture(), |
| 260 | ArgumentCaptor.forClass(Integer.class).capture(), |
Jason Monk | 07b75fe | 2015-05-14 16:47:03 -0400 | [diff] [blame] | 261 | typeIconArg.capture(), dataInArg.capture(), dataOutArg.capture(), |
| 262 | ArgumentCaptor.forClass(String.class).capture(), |
| 263 | ArgumentCaptor.forClass(String.class).capture(), |
| 264 | ArgumentCaptor.forClass(Boolean.class).capture(), |
| 265 | ArgumentCaptor.forClass(Integer.class).capture()); |
| 266 | IconState iconState = iconArg.getValue(); |
| 267 | assertEquals("Visibility in, quick settings", visible, iconState.visible); |
| 268 | assertEquals("Signal icon in, quick settings", icon, iconState.icon); |
Jason Monk | f13b4b3 | 2014-11-07 16:39:34 -0500 | [diff] [blame] | 269 | assertEquals("Data icon in, quick settings", typeIcon, (int) typeIconArg.getValue()); |
| 270 | assertEquals("Data direction in, in quick settings", dataIn, |
| 271 | (boolean) dataInArg.getValue()); |
| 272 | assertEquals("Data direction out, in quick settings", dataOut, |
| 273 | (boolean) dataOutArg.getValue()); |
Jason Monk | f13b4b3 | 2014-11-07 16:39:34 -0500 | [diff] [blame] | 274 | } |
| 275 | |
| 276 | protected void verifyLastMobileDataIndicators(boolean visible, int icon, int typeIcon) { |
Jason Monk | 07b75fe | 2015-05-14 16:47:03 -0400 | [diff] [blame] | 277 | ArgumentCaptor<IconState> iconArg = ArgumentCaptor.forClass(IconState.class); |
Jason Monk | f13b4b3 | 2014-11-07 16:39:34 -0500 | [diff] [blame] | 278 | ArgumentCaptor<Integer> typeIconArg = ArgumentCaptor.forClass(Integer.class); |
Jason Monk | e0cdb60 | 2014-11-05 12:39:45 -0500 | [diff] [blame] | 279 | |
| 280 | // TODO: Verify all fields. |
Jason Monk | 07b75fe | 2015-05-14 16:47:03 -0400 | [diff] [blame] | 281 | Mockito.verify(mCallbackHandler, Mockito.atLeastOnce()).setMobileDataIndicators( |
| 282 | iconArg.capture(), |
| 283 | ArgumentCaptor.forClass(IconState.class).capture(), |
Andrew Flynn | 2fdbe12 | 2015-06-01 16:34:21 -0400 | [diff] [blame^] | 284 | typeIconArg.capture(), |
Jason Monk | 07b75fe | 2015-05-14 16:47:03 -0400 | [diff] [blame] | 285 | ArgumentCaptor.forClass(Integer.class).capture(), |
| 286 | ArgumentCaptor.forClass(Boolean.class).capture(), |
| 287 | ArgumentCaptor.forClass(Boolean.class).capture(), |
Jason Monk | e0cdb60 | 2014-11-05 12:39:45 -0500 | [diff] [blame] | 288 | ArgumentCaptor.forClass(String.class).capture(), |
| 289 | ArgumentCaptor.forClass(String.class).capture(), |
Jason Monk | b574627 | 2014-11-12 16:50:31 -0500 | [diff] [blame] | 290 | ArgumentCaptor.forClass(Boolean.class).capture(), |
| 291 | ArgumentCaptor.forClass(Integer.class).capture()); |
Jason Monk | 07b75fe | 2015-05-14 16:47:03 -0400 | [diff] [blame] | 292 | IconState iconState = iconArg.getValue(); |
Jason Monk | e0cdb60 | 2014-11-05 12:39:45 -0500 | [diff] [blame] | 293 | |
Jason Monk | f13b4b3 | 2014-11-07 16:39:34 -0500 | [diff] [blame] | 294 | assertEquals("Data icon in status bar", typeIcon, (int) typeIconArg.getValue()); |
Jason Monk | 07b75fe | 2015-05-14 16:47:03 -0400 | [diff] [blame] | 295 | assertEquals("Visibility in status bar", visible, iconState.visible); |
Jason Monk | e0cdb60 | 2014-11-05 12:39:45 -0500 | [diff] [blame] | 296 | } |
Leigh Anne | d0a6279 | 2014-11-13 14:27:10 -0800 | [diff] [blame] | 297 | |
Leigh Anne | d0a6279 | 2014-11-13 14:27:10 -0800 | [diff] [blame] | 298 | protected void assertNetworkNameEquals(String expected) { |
Jason Monk | 07b75fe | 2015-05-14 16:47:03 -0400 | [diff] [blame] | 299 | assertEquals("Network name", expected, mMobileSignalController.getState().networkName); |
Leigh Anne | d0a6279 | 2014-11-13 14:27:10 -0800 | [diff] [blame] | 300 | } |
Jason Monk | e0cdb60 | 2014-11-05 12:39:45 -0500 | [diff] [blame] | 301 | } |