Jason Monk | f13b4b3 | 2014-11-07 16:39:34 -0500 | [diff] [blame] | 1 | package com.android.systemui.statusbar.policy; |
| 2 | |
Jason Monk | 07b75fe | 2015-05-14 16:47:03 -0400 | [diff] [blame] | 3 | import android.os.Looper; |
Jason Monk | f13b4b3 | 2014-11-07 16:39:34 -0500 | [diff] [blame] | 4 | import android.telephony.TelephonyManager; |
| 5 | |
Jason Monk | 33f8ae7 | 2015-05-08 10:45:15 -0400 | [diff] [blame] | 6 | import org.mockito.Mockito; |
| 7 | |
Jason Monk | f13b4b3 | 2014-11-07 16:39:34 -0500 | [diff] [blame] | 8 | public class NetworkControllerDataTest extends NetworkControllerBaseTest { |
| 9 | |
| 10 | public void test3gDataIcon() { |
| 11 | setupDefaultSignal(); |
| 12 | |
| 13 | verifyDataIndicators(TelephonyIcons.DATA_3G[1][0 /* No direction */], |
Jason Monk | 33f8ae7 | 2015-05-08 10:45:15 -0400 | [diff] [blame] | 14 | TelephonyIcons.QS_DATA_3G); |
Jason Monk | f13b4b3 | 2014-11-07 16:39:34 -0500 | [diff] [blame] | 15 | } |
| 16 | |
| 17 | public void testRoamingDataIcon() { |
| 18 | setupDefaultSignal(); |
| 19 | setGsmRoaming(true); |
| 20 | |
| 21 | verifyLastMobileDataIndicators(true, |
| 22 | TelephonyIcons.TELEPHONY_SIGNAL_STRENGTH_ROAMING[1][DEFAULT_LEVEL], |
| 23 | TelephonyIcons.ROAMING_ICON); |
| 24 | verifyLastQsMobileDataIndicators(true, |
| 25 | TelephonyIcons.QS_TELEPHONY_SIGNAL_STRENGTH[1][DEFAULT_LEVEL], |
Jason Monk | 33f8ae7 | 2015-05-08 10:45:15 -0400 | [diff] [blame] | 26 | TelephonyIcons.QS_DATA_R, false, false); |
Jason Monk | f13b4b3 | 2014-11-07 16:39:34 -0500 | [diff] [blame] | 27 | } |
| 28 | |
| 29 | public void test2gDataIcon() { |
| 30 | setupDefaultSignal(); |
| 31 | updateDataConnectionState(TelephonyManager.DATA_CONNECTED, |
| 32 | TelephonyManager.NETWORK_TYPE_GSM); |
| 33 | |
| 34 | verifyDataIndicators(TelephonyIcons.DATA_G[1][0 /* No direction */], |
Jason Monk | 33f8ae7 | 2015-05-08 10:45:15 -0400 | [diff] [blame] | 35 | TelephonyIcons.QS_DATA_G); |
Jason Monk | f13b4b3 | 2014-11-07 16:39:34 -0500 | [diff] [blame] | 36 | } |
| 37 | |
| 38 | public void testCdmaDataIcon() { |
| 39 | setupDefaultSignal(); |
| 40 | updateDataConnectionState(TelephonyManager.DATA_CONNECTED, |
| 41 | TelephonyManager.NETWORK_TYPE_CDMA); |
| 42 | |
| 43 | verifyDataIndicators(TelephonyIcons.DATA_1X[1][0 /* No direction */], |
Jason Monk | 33f8ae7 | 2015-05-08 10:45:15 -0400 | [diff] [blame] | 44 | TelephonyIcons.QS_DATA_1X); |
Jason Monk | f13b4b3 | 2014-11-07 16:39:34 -0500 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | public void testEdgeDataIcon() { |
| 48 | setupDefaultSignal(); |
| 49 | updateDataConnectionState(TelephonyManager.DATA_CONNECTED, |
| 50 | TelephonyManager.NETWORK_TYPE_EDGE); |
| 51 | |
| 52 | verifyDataIndicators(TelephonyIcons.DATA_E[1][0 /* No direction */], |
Jason Monk | 33f8ae7 | 2015-05-08 10:45:15 -0400 | [diff] [blame] | 53 | TelephonyIcons.QS_DATA_E); |
Jason Monk | f13b4b3 | 2014-11-07 16:39:34 -0500 | [diff] [blame] | 54 | } |
| 55 | |
| 56 | public void testLteDataIcon() { |
| 57 | setupDefaultSignal(); |
| 58 | updateDataConnectionState(TelephonyManager.DATA_CONNECTED, |
| 59 | TelephonyManager.NETWORK_TYPE_LTE); |
| 60 | |
Jason Monk | f13b4b3 | 2014-11-07 16:39:34 -0500 | [diff] [blame] | 61 | verifyDataIndicators(TelephonyIcons.DATA_LTE[1][0 /* No direction */], |
Jason Monk | 33f8ae7 | 2015-05-08 10:45:15 -0400 | [diff] [blame] | 62 | TelephonyIcons.QS_DATA_LTE); |
Jason Monk | f13b4b3 | 2014-11-07 16:39:34 -0500 | [diff] [blame] | 63 | } |
| 64 | |
| 65 | public void testHspaDataIcon() { |
| 66 | setupDefaultSignal(); |
| 67 | updateDataConnectionState(TelephonyManager.DATA_CONNECTED, |
| 68 | TelephonyManager.NETWORK_TYPE_HSPA); |
| 69 | |
Jason Monk | f13b4b3 | 2014-11-07 16:39:34 -0500 | [diff] [blame] | 70 | verifyDataIndicators(TelephonyIcons.DATA_H[1][0 /* No direction */], |
Jason Monk | 33f8ae7 | 2015-05-08 10:45:15 -0400 | [diff] [blame] | 71 | TelephonyIcons.QS_DATA_H); |
Jason Monk | f13b4b3 | 2014-11-07 16:39:34 -0500 | [diff] [blame] | 72 | } |
| 73 | |
Jason Monk | 7150d7f | 2015-07-09 10:14:12 -0400 | [diff] [blame^] | 74 | public void testWfcNoDataIcon() { |
| 75 | setupDefaultSignal(); |
| 76 | updateDataConnectionState(TelephonyManager.DATA_CONNECTED, |
| 77 | TelephonyManager.NETWORK_TYPE_IWLAN); |
| 78 | |
| 79 | verifyDataIndicators(0, 0); |
| 80 | } |
| 81 | |
Jason Monk | 3aaabd7 | 2014-12-12 11:11:44 -0500 | [diff] [blame] | 82 | public void test4gDataIcon() { |
| 83 | // Switch to showing 4g icon and re-initialize the NetworkController. |
| 84 | mConfig.show4gForLte = true; |
| 85 | mNetworkController = new NetworkControllerImpl(mContext, mMockCm, mMockTm, mMockWm, mMockSm, |
Jason Monk | 07b75fe | 2015-05-14 16:47:03 -0400 | [diff] [blame] | 86 | mConfig, Looper.getMainLooper(), mCallbackHandler, |
| 87 | Mockito.mock(AccessPointControllerImpl.class), |
Jason Monk | c6cc626 | 2015-06-11 11:10:15 -0400 | [diff] [blame] | 88 | Mockito.mock(MobileDataControllerImpl.class), mMockSubDefaults); |
Jason Monk | 3aaabd7 | 2014-12-12 11:11:44 -0500 | [diff] [blame] | 89 | setupNetworkController(); |
| 90 | |
| 91 | setupDefaultSignal(); |
| 92 | updateDataConnectionState(TelephonyManager.DATA_CONNECTED, |
| 93 | TelephonyManager.NETWORK_TYPE_LTE); |
| 94 | |
| 95 | verifyDataIndicators(TelephonyIcons.DATA_4G[1][0 /* No direction */], |
Jason Monk | 33f8ae7 | 2015-05-08 10:45:15 -0400 | [diff] [blame] | 96 | TelephonyIcons.QS_DATA_4G); |
Jason Monk | 3aaabd7 | 2014-12-12 11:11:44 -0500 | [diff] [blame] | 97 | } |
| 98 | |
| 99 | public void test4gDataIconConfigChange() { |
| 100 | setupDefaultSignal(); |
| 101 | updateDataConnectionState(TelephonyManager.DATA_CONNECTED, |
| 102 | TelephonyManager.NETWORK_TYPE_LTE); |
| 103 | |
| 104 | // Switch to showing 4g icon and re-initialize the NetworkController. |
| 105 | mConfig.show4gForLte = true; |
| 106 | // Can't send the broadcast as that would actually read the config from |
| 107 | // the context. Instead we'll just poke at a function that does all of |
| 108 | // the after work. |
| 109 | mNetworkController.handleConfigurationChanged(); |
| 110 | |
| 111 | verifyDataIndicators(TelephonyIcons.DATA_4G[1][0 /* No direction */], |
Jason Monk | 33f8ae7 | 2015-05-08 10:45:15 -0400 | [diff] [blame] | 112 | TelephonyIcons.QS_DATA_4G); |
Jason Monk | 3aaabd7 | 2014-12-12 11:11:44 -0500 | [diff] [blame] | 113 | } |
| 114 | |
Jason Monk | f13b4b3 | 2014-11-07 16:39:34 -0500 | [diff] [blame] | 115 | public void testDataActivity() { |
| 116 | setupDefaultSignal(); |
| 117 | |
| 118 | testDataActivity(TelephonyManager.DATA_ACTIVITY_NONE, false, false); |
| 119 | testDataActivity(TelephonyManager.DATA_ACTIVITY_IN, true, false); |
| 120 | testDataActivity(TelephonyManager.DATA_ACTIVITY_OUT, false, true); |
| 121 | testDataActivity(TelephonyManager.DATA_ACTIVITY_INOUT, true, true); |
| 122 | } |
| 123 | |
| 124 | private void testDataActivity(int direction, boolean in, boolean out) { |
| 125 | updateDataActivity(direction); |
| 126 | |
| 127 | verifyLastMobileDataIndicators(true, DEFAULT_SIGNAL_STRENGTH, DEFAULT_ICON); |
| 128 | verifyLastQsMobileDataIndicators(true, DEFAULT_QS_SIGNAL_STRENGTH, |
Jason Monk | b574627 | 2014-11-12 16:50:31 -0500 | [diff] [blame] | 129 | DEFAULT_QS_ICON, in, out); |
Jason Monk | f13b4b3 | 2014-11-07 16:39:34 -0500 | [diff] [blame] | 130 | |
| 131 | } |
| 132 | |
| 133 | private void verifyDataIndicators(int dataIcon, int qsDataIcon) { |
| 134 | verifyLastMobileDataIndicators(true, DEFAULT_SIGNAL_STRENGTH, dataIcon); |
| 135 | verifyLastQsMobileDataIndicators(true, DEFAULT_QS_SIGNAL_STRENGTH, qsDataIcon, false, |
Jason Monk | b574627 | 2014-11-12 16:50:31 -0500 | [diff] [blame] | 136 | false); |
Jason Monk | f13b4b3 | 2014-11-07 16:39:34 -0500 | [diff] [blame] | 137 | } |
| 138 | |
| 139 | } |