Jason Monk | f13b4b3 | 2014-11-07 16:39:34 -0500 | [diff] [blame] | 1 | package com.android.systemui.statusbar.policy; |
| 2 | |
Jason Monk | 0288de0 | 2017-02-23 14:48:05 -0500 | [diff] [blame] | 3 | import static org.mockito.Matchers.anyInt; |
Pengquan Meng | a62d32b | 2018-12-06 17:38:38 -0800 | [diff] [blame] | 4 | import static org.mockito.Mockito.doReturn; |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 5 | import static org.mockito.Mockito.mock; |
Jason Monk | 0288de0 | 2017-02-23 14:48:05 -0500 | [diff] [blame] | 6 | import static org.mockito.Mockito.when; |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 7 | |
Jason Monk | fd57ea7 | 2016-04-29 13:37:58 -0400 | [diff] [blame] | 8 | import android.net.NetworkCapabilities; |
Jason Monk | 07b75fe | 2015-05-14 16:47:03 -0400 | [diff] [blame] | 9 | import android.os.Looper; |
Jack Yu | e27d3fd | 2019-03-15 14:49:53 -0700 | [diff] [blame] | 10 | import android.telephony.NetworkRegistrationInfo; |
Pengquan Meng | a62d32b | 2018-12-06 17:38:38 -0800 | [diff] [blame] | 11 | import android.telephony.ServiceState; |
Jason Monk | f13b4b3 | 2014-11-07 16:39:34 -0500 | [diff] [blame] | 12 | import android.telephony.TelephonyManager; |
Jason Monk | e427cb8 | 2015-07-28 09:18:08 -0400 | [diff] [blame] | 13 | import android.test.suitebuilder.annotation.SmallTest; |
Jason Monk | 2515f47 | 2017-09-19 09:52:43 -0400 | [diff] [blame] | 14 | import android.testing.AndroidTestingRunner; |
| 15 | import android.testing.TestableLooper; |
| 16 | import android.testing.TestableLooper.RunWithLooper; |
Jason Monk | 0288de0 | 2017-02-23 14:48:05 -0500 | [diff] [blame] | 17 | |
Jason Monk | f668d7c | 2016-01-14 10:38:41 -0500 | [diff] [blame] | 18 | import com.android.settingslib.net.DataUsageController; |
Jason Monk | 0288de0 | 2017-02-23 14:48:05 -0500 | [diff] [blame] | 19 | |
Geoffrey Pitsch | 2c403db | 2016-08-26 09:09:39 -0400 | [diff] [blame] | 20 | import org.junit.Test; |
| 21 | import org.junit.runner.RunWith; |
Pengquan Meng | a62d32b | 2018-12-06 17:38:38 -0800 | [diff] [blame] | 22 | import org.mockito.Mockito; |
Jason Monk | 33f8ae7 | 2015-05-08 10:45:15 -0400 | [diff] [blame] | 23 | |
Jason Monk | e427cb8 | 2015-07-28 09:18:08 -0400 | [diff] [blame] | 24 | @SmallTest |
Jason Monk | 2515f47 | 2017-09-19 09:52:43 -0400 | [diff] [blame] | 25 | @RunWith(AndroidTestingRunner.class) |
| 26 | @RunWithLooper |
Jason Monk | f13b4b3 | 2014-11-07 16:39:34 -0500 | [diff] [blame] | 27 | public class NetworkControllerDataTest extends NetworkControllerBaseTest { |
| 28 | |
Geoffrey Pitsch | 2c403db | 2016-08-26 09:09:39 -0400 | [diff] [blame] | 29 | @Test |
Jason Monk | f13b4b3 | 2014-11-07 16:39:34 -0500 | [diff] [blame] | 30 | public void test3gDataIcon() { |
| 31 | setupDefaultSignal(); |
| 32 | |
Amin Shaikh | d64e626 | 2018-03-08 10:08:13 -0500 | [diff] [blame] | 33 | verifyDataIndicators(TelephonyIcons.ICON_3G); |
Jason Monk | f13b4b3 | 2014-11-07 16:39:34 -0500 | [diff] [blame] | 34 | } |
| 35 | |
Geoffrey Pitsch | 2c403db | 2016-08-26 09:09:39 -0400 | [diff] [blame] | 36 | @Test |
Jason Monk | f13b4b3 | 2014-11-07 16:39:34 -0500 | [diff] [blame] | 37 | public void test2gDataIcon() { |
| 38 | setupDefaultSignal(); |
| 39 | updateDataConnectionState(TelephonyManager.DATA_CONNECTED, |
| 40 | TelephonyManager.NETWORK_TYPE_GSM); |
| 41 | |
Amin Shaikh | d64e626 | 2018-03-08 10:08:13 -0500 | [diff] [blame] | 42 | verifyDataIndicators(TelephonyIcons.ICON_G); |
Jason Monk | f13b4b3 | 2014-11-07 16:39:34 -0500 | [diff] [blame] | 43 | } |
| 44 | |
Geoffrey Pitsch | 2c403db | 2016-08-26 09:09:39 -0400 | [diff] [blame] | 45 | @Test |
Jason Monk | f13b4b3 | 2014-11-07 16:39:34 -0500 | [diff] [blame] | 46 | public void testCdmaDataIcon() { |
| 47 | setupDefaultSignal(); |
| 48 | updateDataConnectionState(TelephonyManager.DATA_CONNECTED, |
| 49 | TelephonyManager.NETWORK_TYPE_CDMA); |
| 50 | |
Amin Shaikh | d64e626 | 2018-03-08 10:08:13 -0500 | [diff] [blame] | 51 | verifyDataIndicators(TelephonyIcons.ICON_1X); |
Jason Monk | f13b4b3 | 2014-11-07 16:39:34 -0500 | [diff] [blame] | 52 | } |
| 53 | |
Geoffrey Pitsch | 2c403db | 2016-08-26 09:09:39 -0400 | [diff] [blame] | 54 | @Test |
Jason Monk | f13b4b3 | 2014-11-07 16:39:34 -0500 | [diff] [blame] | 55 | public void testEdgeDataIcon() { |
| 56 | setupDefaultSignal(); |
| 57 | updateDataConnectionState(TelephonyManager.DATA_CONNECTED, |
| 58 | TelephonyManager.NETWORK_TYPE_EDGE); |
| 59 | |
Amin Shaikh | d64e626 | 2018-03-08 10:08:13 -0500 | [diff] [blame] | 60 | verifyDataIndicators(TelephonyIcons.ICON_E); |
Jason Monk | f13b4b3 | 2014-11-07 16:39:34 -0500 | [diff] [blame] | 61 | } |
| 62 | |
Geoffrey Pitsch | 2c403db | 2016-08-26 09:09:39 -0400 | [diff] [blame] | 63 | @Test |
Jason Monk | f13b4b3 | 2014-11-07 16:39:34 -0500 | [diff] [blame] | 64 | public void testLteDataIcon() { |
| 65 | setupDefaultSignal(); |
| 66 | updateDataConnectionState(TelephonyManager.DATA_CONNECTED, |
| 67 | TelephonyManager.NETWORK_TYPE_LTE); |
| 68 | |
Amin Shaikh | d64e626 | 2018-03-08 10:08:13 -0500 | [diff] [blame] | 69 | verifyDataIndicators(TelephonyIcons.ICON_LTE); |
Jason Monk | f13b4b3 | 2014-11-07 16:39:34 -0500 | [diff] [blame] | 70 | } |
| 71 | |
Geoffrey Pitsch | 2c403db | 2016-08-26 09:09:39 -0400 | [diff] [blame] | 72 | @Test |
Jason Monk | f13b4b3 | 2014-11-07 16:39:34 -0500 | [diff] [blame] | 73 | public void testHspaDataIcon() { |
| 74 | setupDefaultSignal(); |
| 75 | updateDataConnectionState(TelephonyManager.DATA_CONNECTED, |
| 76 | TelephonyManager.NETWORK_TYPE_HSPA); |
| 77 | |
Amin Shaikh | d64e626 | 2018-03-08 10:08:13 -0500 | [diff] [blame] | 78 | verifyDataIndicators(TelephonyIcons.ICON_H); |
Jason Monk | f13b4b3 | 2014-11-07 16:39:34 -0500 | [diff] [blame] | 79 | } |
| 80 | |
Amin Shaikh | f5830ca | 2018-03-09 14:06:50 -0500 | [diff] [blame] | 81 | |
| 82 | @Test |
| 83 | public void testHspaPlusDataIcon() { |
| 84 | setupDefaultSignal(); |
| 85 | updateDataConnectionState(TelephonyManager.DATA_CONNECTED, |
| 86 | TelephonyManager.NETWORK_TYPE_HSPAP); |
| 87 | |
| 88 | verifyDataIndicators(TelephonyIcons.ICON_H_PLUS); |
| 89 | } |
| 90 | |
| 91 | |
Geoffrey Pitsch | 2c403db | 2016-08-26 09:09:39 -0400 | [diff] [blame] | 92 | @Test |
Jason Monk | 7150d7f | 2015-07-09 10:14:12 -0400 | [diff] [blame] | 93 | public void testWfcNoDataIcon() { |
| 94 | setupDefaultSignal(); |
| 95 | updateDataConnectionState(TelephonyManager.DATA_CONNECTED, |
| 96 | TelephonyManager.NETWORK_TYPE_IWLAN); |
| 97 | |
Amin Shaikh | d64e626 | 2018-03-08 10:08:13 -0500 | [diff] [blame] | 98 | verifyDataIndicators(0); |
Jason Monk | 7150d7f | 2015-07-09 10:14:12 -0400 | [diff] [blame] | 99 | } |
| 100 | |
Geoffrey Pitsch | 2c403db | 2016-08-26 09:09:39 -0400 | [diff] [blame] | 101 | @Test |
Jason Monk | 3aaabd7 | 2014-12-12 11:11:44 -0500 | [diff] [blame] | 102 | public void test4gDataIcon() { |
| 103 | // Switch to showing 4g icon and re-initialize the NetworkController. |
| 104 | mConfig.show4gForLte = true; |
Sundeep Ghuman | 9d10a3c | 2017-06-16 00:05:16 +0000 | [diff] [blame] | 105 | mNetworkController = new NetworkControllerImpl(mContext, mMockCm, mMockTm, mMockWm, mMockSm, |
Jason Monk | 07b75fe | 2015-05-14 16:47:03 -0400 | [diff] [blame] | 106 | mConfig, Looper.getMainLooper(), mCallbackHandler, |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 107 | mock(AccessPointControllerImpl.class), |
| 108 | mock(DataUsageController.class), mMockSubDefaults, |
| 109 | mock(DeviceProvisionedController.class)); |
Jason Monk | 3aaabd7 | 2014-12-12 11:11:44 -0500 | [diff] [blame] | 110 | setupNetworkController(); |
| 111 | |
| 112 | setupDefaultSignal(); |
| 113 | updateDataConnectionState(TelephonyManager.DATA_CONNECTED, |
| 114 | TelephonyManager.NETWORK_TYPE_LTE); |
| 115 | |
Amin Shaikh | d64e626 | 2018-03-08 10:08:13 -0500 | [diff] [blame] | 116 | verifyDataIndicators(TelephonyIcons.ICON_4G); |
Jason Monk | 3aaabd7 | 2014-12-12 11:11:44 -0500 | [diff] [blame] | 117 | } |
| 118 | |
Geoffrey Pitsch | 2c403db | 2016-08-26 09:09:39 -0400 | [diff] [blame] | 119 | @Test |
Fabian Kozynski | c7bc84b | 2019-03-11 13:57:31 -0400 | [diff] [blame] | 120 | public void testNoInternetIcon_withDefaultSub() { |
Amin Shaikh | af4c193 | 2018-03-08 10:29:56 -0500 | [diff] [blame] | 121 | setupNetworkController(); |
Malcolm Chen | 04be9d1 | 2019-06-11 19:48:38 -0700 | [diff] [blame^] | 122 | when(mMockTm.isDataCapable()).thenReturn(false); |
Amin Shaikh | af4c193 | 2018-03-08 10:29:56 -0500 | [diff] [blame] | 123 | setupDefaultSignal(); |
| 124 | updateDataConnectionState(TelephonyManager.DATA_CONNECTED, 0); |
Anarghya Mitra | 678722f | 2018-05-11 14:29:54 -0700 | [diff] [blame] | 125 | setConnectivityViaBroadcast(NetworkCapabilities.TRANSPORT_CELLULAR, false, false); |
Amin Shaikh | af4c193 | 2018-03-08 10:29:56 -0500 | [diff] [blame] | 126 | |
| 127 | // Verify that a SignalDrawable with a cut out is used to display data disabled. |
| 128 | verifyLastMobileDataIndicators(true, DEFAULT_SIGNAL_STRENGTH, 0, |
| 129 | true, DEFAULT_QS_SIGNAL_STRENGTH, 0, false, |
Fabian Kozynski | c7bc84b | 2019-03-11 13:57:31 -0400 | [diff] [blame] | 130 | false, true, NO_DATA_STRING); |
Amin Shaikh | af4c193 | 2018-03-08 10:29:56 -0500 | [diff] [blame] | 131 | } |
| 132 | |
| 133 | @Test |
Fabian Kozynski | c7bc84b | 2019-03-11 13:57:31 -0400 | [diff] [blame] | 134 | public void testDataDisabledIcon_withDefaultSub() { |
Jason Monk | fd57ea7 | 2016-04-29 13:37:58 -0400 | [diff] [blame] | 135 | setupNetworkController(); |
Malcolm Chen | 04be9d1 | 2019-06-11 19:48:38 -0700 | [diff] [blame^] | 136 | when(mMockTm.isDataCapable()).thenReturn(false); |
Jason Monk | fd57ea7 | 2016-04-29 13:37:58 -0400 | [diff] [blame] | 137 | setupDefaultSignal(); |
| 138 | updateDataConnectionState(TelephonyManager.DATA_DISCONNECTED, 0); |
Anarghya Mitra | 678722f | 2018-05-11 14:29:54 -0700 | [diff] [blame] | 139 | setConnectivityViaBroadcast(NetworkCapabilities.TRANSPORT_CELLULAR, false, false); |
Jason Monk | fd57ea7 | 2016-04-29 13:37:58 -0400 | [diff] [blame] | 140 | |
Amin Shaikh | af4c193 | 2018-03-08 10:29:56 -0500 | [diff] [blame] | 141 | // Verify that a SignalDrawable with a cut out is used to display data disabled. |
| 142 | verifyLastMobileDataIndicators(true, DEFAULT_SIGNAL_STRENGTH, 0, |
| 143 | true, DEFAULT_QS_SIGNAL_STRENGTH, 0, false, |
Fabian Kozynski | c7bc84b | 2019-03-11 13:57:31 -0400 | [diff] [blame] | 144 | false, true, NO_DATA_STRING); |
| 145 | } |
| 146 | |
| 147 | @Test |
| 148 | public void testNoInternetIcon_withoutDefaultSub() { |
| 149 | setupNetworkController(); |
Malcolm Chen | 04be9d1 | 2019-06-11 19:48:38 -0700 | [diff] [blame^] | 150 | when(mMockTm.isDataCapable()).thenReturn(false); |
Fabian Kozynski | c7bc84b | 2019-03-11 13:57:31 -0400 | [diff] [blame] | 151 | setupDefaultSignal(); |
| 152 | setDefaultSubId(mSubId + 1); |
| 153 | updateDataConnectionState(TelephonyManager.DATA_CONNECTED, 0); |
| 154 | setConnectivityViaBroadcast(NetworkCapabilities.TRANSPORT_CELLULAR, false, false); |
| 155 | |
| 156 | // Verify that a SignalDrawable with a cut out is used to display data disabled. |
| 157 | verifyLastMobileDataIndicators(true, DEFAULT_SIGNAL_STRENGTH, 0, |
| 158 | true, DEFAULT_QS_SIGNAL_STRENGTH, 0, false, |
| 159 | false, true, NOT_DEFAULT_DATA_STRING); |
| 160 | } |
| 161 | |
| 162 | @Test |
| 163 | public void testDataDisabledIcon_withoutDefaultSub() { |
| 164 | setupNetworkController(); |
Malcolm Chen | 04be9d1 | 2019-06-11 19:48:38 -0700 | [diff] [blame^] | 165 | when(mMockTm.isDataCapable()).thenReturn(false); |
Fabian Kozynski | c7bc84b | 2019-03-11 13:57:31 -0400 | [diff] [blame] | 166 | setupDefaultSignal(); |
| 167 | setDefaultSubId(mSubId + 1); |
| 168 | updateDataConnectionState(TelephonyManager.DATA_DISCONNECTED, 0); |
| 169 | setConnectivityViaBroadcast(NetworkCapabilities.TRANSPORT_CELLULAR, false, false); |
| 170 | |
| 171 | // Verify that a SignalDrawable with a cut out is used to display data disabled. |
| 172 | verifyLastMobileDataIndicators(true, DEFAULT_SIGNAL_STRENGTH, 0, |
| 173 | true, DEFAULT_QS_SIGNAL_STRENGTH, 0, false, |
| 174 | false, true, NOT_DEFAULT_DATA_STRING); |
Jason Monk | fd57ea7 | 2016-04-29 13:37:58 -0400 | [diff] [blame] | 175 | } |
| 176 | |
Geoffrey Pitsch | 2c403db | 2016-08-26 09:09:39 -0400 | [diff] [blame] | 177 | @Test |
Pengquan Meng | a62d32b | 2018-12-06 17:38:38 -0800 | [diff] [blame] | 178 | public void testNr5GIcon_NrConnectedWithoutMMWave_show5GIcon() { |
| 179 | setupDefaultNr5GIconConfiguration(); |
| 180 | setupDefaultSignal(); |
| 181 | updateDataConnectionState(TelephonyManager.DATA_CONNECTED, |
| 182 | TelephonyManager.NETWORK_TYPE_LTE); |
| 183 | ServiceState ss = Mockito.mock(ServiceState.class); |
Jack Yu | 20d7140 | 2019-03-16 23:00:35 -0700 | [diff] [blame] | 184 | doReturn(NetworkRegistrationInfo.NR_STATE_CONNECTED).when(ss).getNrState(); |
Pengquan Meng | a62d32b | 2018-12-06 17:38:38 -0800 | [diff] [blame] | 185 | doReturn(ServiceState.FREQUENCY_RANGE_HIGH).when(ss).getNrFrequencyRange(); |
| 186 | mPhoneStateListener.onServiceStateChanged(ss); |
| 187 | |
| 188 | verifyDataIndicators(TelephonyIcons.ICON_5G); |
| 189 | } |
| 190 | |
| 191 | @Test |
| 192 | public void testNr5GIcon_NrConnectedWithMMWave_show5GPlusIcon() { |
| 193 | setupDefaultNr5GIconConfiguration(); |
| 194 | setupDefaultSignal(); |
| 195 | updateDataConnectionState(TelephonyManager.DATA_CONNECTED, |
| 196 | TelephonyManager.NETWORK_TYPE_LTE); |
| 197 | ServiceState ss = Mockito.mock(ServiceState.class); |
Jack Yu | 20d7140 | 2019-03-16 23:00:35 -0700 | [diff] [blame] | 198 | doReturn(NetworkRegistrationInfo.NR_STATE_CONNECTED).when(ss).getNrState(); |
Pengquan Meng | a62d32b | 2018-12-06 17:38:38 -0800 | [diff] [blame] | 199 | doReturn(ServiceState.FREQUENCY_RANGE_MMWAVE).when(ss).getNrFrequencyRange(); |
| 200 | mPhoneStateListener.onServiceStateChanged(ss); |
| 201 | |
| 202 | verifyDataIndicators(TelephonyIcons.ICON_5G_PLUS); |
| 203 | } |
| 204 | |
| 205 | @Test |
| 206 | public void testNr5GIcon_NrRestricted_showLteIcon() { |
| 207 | setupDefaultNr5GIconConfiguration(); |
| 208 | setupDefaultSignal(); |
| 209 | updateDataConnectionState(TelephonyManager.DATA_CONNECTED, |
| 210 | TelephonyManager.NETWORK_TYPE_LTE); |
| 211 | ServiceState ss = Mockito.mock(ServiceState.class); |
Jack Yu | 20d7140 | 2019-03-16 23:00:35 -0700 | [diff] [blame] | 212 | doReturn(NetworkRegistrationInfo.NR_STATE_RESTRICTED).when(ss).getNrState(); |
Pengquan Meng | a62d32b | 2018-12-06 17:38:38 -0800 | [diff] [blame] | 213 | mPhoneStateListener.onServiceStateChanged(mServiceState); |
| 214 | |
| 215 | verifyDataIndicators(TelephonyIcons.ICON_LTE); |
| 216 | } |
| 217 | |
| 218 | @Test |
Jason Monk | fd57ea7 | 2016-04-29 13:37:58 -0400 | [diff] [blame] | 219 | public void testDataDisabledIcon_UserNotSetup() { |
| 220 | setupNetworkController(); |
Malcolm Chen | 04be9d1 | 2019-06-11 19:48:38 -0700 | [diff] [blame^] | 221 | when(mMockTm.isDataCapable()).thenReturn(false); |
Jason Monk | fd57ea7 | 2016-04-29 13:37:58 -0400 | [diff] [blame] | 222 | setupDefaultSignal(); |
| 223 | updateDataConnectionState(TelephonyManager.DATA_DISCONNECTED, 0); |
Anarghya Mitra | 678722f | 2018-05-11 14:29:54 -0700 | [diff] [blame] | 224 | setConnectivityViaBroadcast(NetworkCapabilities.TRANSPORT_CELLULAR, false, false); |
Jason Monk | 0288de0 | 2017-02-23 14:48:05 -0500 | [diff] [blame] | 225 | when(mMockProvisionController.isUserSetup(anyInt())).thenReturn(false); |
| 226 | mUserCallback.onUserSetupChanged(); |
Jason Monk | 2515f47 | 2017-09-19 09:52:43 -0400 | [diff] [blame] | 227 | TestableLooper.get(this).processAllMessages(); |
Jason Monk | fd57ea7 | 2016-04-29 13:37:58 -0400 | [diff] [blame] | 228 | |
| 229 | // Don't show the X until the device is setup. |
Amin Shaikh | d64e626 | 2018-03-08 10:08:13 -0500 | [diff] [blame] | 230 | verifyDataIndicators(0); |
Jason Monk | fd57ea7 | 2016-04-29 13:37:58 -0400 | [diff] [blame] | 231 | } |
| 232 | |
Geoffrey Pitsch | 2c403db | 2016-08-26 09:09:39 -0400 | [diff] [blame] | 233 | @Test |
Wenting Xiong | 63364fe | 2017-02-07 19:12:27 +0800 | [diff] [blame] | 234 | public void testAlwaysShowDataRatIcon() { |
| 235 | setupDefaultSignal(); |
Malcolm Chen | 04be9d1 | 2019-06-11 19:48:38 -0700 | [diff] [blame^] | 236 | when(mMockTm.isDataCapable()).thenReturn(false); |
Wenting Xiong | 63364fe | 2017-02-07 19:12:27 +0800 | [diff] [blame] | 237 | updateDataConnectionState(TelephonyManager.DATA_DISCONNECTED, |
| 238 | TelephonyManager.NETWORK_TYPE_GSM); |
| 239 | |
| 240 | // Switch to showing data RAT icon when data is disconnected |
| 241 | // and re-initialize the NetworkController. |
| 242 | mConfig.alwaysShowDataRatIcon = true; |
| 243 | mNetworkController.handleConfigurationChanged(); |
| 244 | |
Amin Shaikh | d64e626 | 2018-03-08 10:08:13 -0500 | [diff] [blame] | 245 | verifyDataIndicators(TelephonyIcons.ICON_G); |
Wenting Xiong | 63364fe | 2017-02-07 19:12:27 +0800 | [diff] [blame] | 246 | } |
| 247 | |
| 248 | @Test |
Jason Monk | 3aaabd7 | 2014-12-12 11:11:44 -0500 | [diff] [blame] | 249 | public void test4gDataIconConfigChange() { |
| 250 | setupDefaultSignal(); |
| 251 | updateDataConnectionState(TelephonyManager.DATA_CONNECTED, |
| 252 | TelephonyManager.NETWORK_TYPE_LTE); |
| 253 | |
| 254 | // Switch to showing 4g icon and re-initialize the NetworkController. |
| 255 | mConfig.show4gForLte = true; |
| 256 | // Can't send the broadcast as that would actually read the config from |
| 257 | // the context. Instead we'll just poke at a function that does all of |
| 258 | // the after work. |
| 259 | mNetworkController.handleConfigurationChanged(); |
| 260 | |
Amin Shaikh | d64e626 | 2018-03-08 10:08:13 -0500 | [diff] [blame] | 261 | verifyDataIndicators(TelephonyIcons.ICON_4G); |
Jason Monk | 3aaabd7 | 2014-12-12 11:11:44 -0500 | [diff] [blame] | 262 | } |
| 263 | |
Geoffrey Pitsch | 2c403db | 2016-08-26 09:09:39 -0400 | [diff] [blame] | 264 | @Test |
Jason Monk | 67b2c16 | 2016-01-12 10:24:09 -0500 | [diff] [blame] | 265 | public void testDataChangeWithoutConnectionState() { |
| 266 | setupDefaultSignal(); |
| 267 | updateDataConnectionState(TelephonyManager.DATA_CONNECTED, |
| 268 | TelephonyManager.NETWORK_TYPE_LTE); |
| 269 | |
Amin Shaikh | d64e626 | 2018-03-08 10:08:13 -0500 | [diff] [blame] | 270 | verifyDataIndicators(TelephonyIcons.ICON_LTE); |
Jason Monk | 67b2c16 | 2016-01-12 10:24:09 -0500 | [diff] [blame] | 271 | |
Jason Monk | 0288de0 | 2017-02-23 14:48:05 -0500 | [diff] [blame] | 272 | when(mServiceState.getDataNetworkType()) |
Jason Monk | 67b2c16 | 2016-01-12 10:24:09 -0500 | [diff] [blame] | 273 | .thenReturn(TelephonyManager.NETWORK_TYPE_HSPA); |
| 274 | updateServiceState(); |
Amin Shaikh | d64e626 | 2018-03-08 10:08:13 -0500 | [diff] [blame] | 275 | verifyDataIndicators(TelephonyIcons.ICON_H); |
Jason Monk | 67b2c16 | 2016-01-12 10:24:09 -0500 | [diff] [blame] | 276 | } |
| 277 | |
Geoffrey Pitsch | 2c403db | 2016-08-26 09:09:39 -0400 | [diff] [blame] | 278 | @Test |
Jason Monk | f13b4b3 | 2014-11-07 16:39:34 -0500 | [diff] [blame] | 279 | public void testDataActivity() { |
| 280 | setupDefaultSignal(); |
| 281 | |
| 282 | testDataActivity(TelephonyManager.DATA_ACTIVITY_NONE, false, false); |
| 283 | testDataActivity(TelephonyManager.DATA_ACTIVITY_IN, true, false); |
| 284 | testDataActivity(TelephonyManager.DATA_ACTIVITY_OUT, false, true); |
| 285 | testDataActivity(TelephonyManager.DATA_ACTIVITY_INOUT, true, true); |
| 286 | } |
| 287 | |
Fabian Kozynski | a909199 | 2019-03-25 11:08:32 -0400 | [diff] [blame] | 288 | @Test |
| 289 | public void testUpdateDataNetworkName() { |
| 290 | setupDefaultSignal(); |
| 291 | String newDataName = "TestDataName"; |
| 292 | when(mServiceState.getDataOperatorAlphaShort()).thenReturn(newDataName); |
| 293 | updateServiceState(); |
| 294 | assertDataNetworkNameEquals(newDataName); |
| 295 | } |
| 296 | |
Jason Monk | f13b4b3 | 2014-11-07 16:39:34 -0500 | [diff] [blame] | 297 | private void testDataActivity(int direction, boolean in, boolean out) { |
| 298 | updateDataActivity(direction); |
| 299 | |
Jason Monk | 26ad85a | 2016-12-08 14:45:42 -0500 | [diff] [blame] | 300 | verifyLastMobileDataIndicators(true, DEFAULT_SIGNAL_STRENGTH, DEFAULT_ICON, true, |
Jason Monk | 7e6c83c | 2017-04-26 14:35:24 -0400 | [diff] [blame] | 301 | DEFAULT_QS_SIGNAL_STRENGTH, DEFAULT_QS_ICON, in, out); |
Jason Monk | f13b4b3 | 2014-11-07 16:39:34 -0500 | [diff] [blame] | 302 | } |
| 303 | |
Amin Shaikh | d64e626 | 2018-03-08 10:08:13 -0500 | [diff] [blame] | 304 | private void verifyDataIndicators(int dataIcon) { |
Jason Monk | 26ad85a | 2016-12-08 14:45:42 -0500 | [diff] [blame] | 305 | verifyLastMobileDataIndicators(true, DEFAULT_SIGNAL_STRENGTH, dataIcon, |
Amin Shaikh | d64e626 | 2018-03-08 10:08:13 -0500 | [diff] [blame] | 306 | true, DEFAULT_QS_SIGNAL_STRENGTH, dataIcon, false, |
Jason Monk | b574627 | 2014-11-12 16:50:31 -0500 | [diff] [blame] | 307 | false); |
Jason Monk | f13b4b3 | 2014-11-07 16:39:34 -0500 | [diff] [blame] | 308 | } |
Jason Monk | f13b4b3 | 2014-11-07 16:39:34 -0500 | [diff] [blame] | 309 | } |