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 | 3aaabd7 | 2014-12-12 11:11:44 -0500 | [diff] [blame] | 74 | public void test4gDataIcon() { |
| 75 | // Switch to showing 4g icon and re-initialize the NetworkController. |
| 76 | mConfig.show4gForLte = true; |
| 77 | mNetworkController = new NetworkControllerImpl(mContext, mMockCm, mMockTm, mMockWm, mMockSm, |
Jason Monk | 07b75fe | 2015-05-14 16:47:03 -0400 | [diff] [blame] | 78 | mConfig, Looper.getMainLooper(), mCallbackHandler, |
| 79 | Mockito.mock(AccessPointControllerImpl.class), |
Jason Monk | 3aaabd7 | 2014-12-12 11:11:44 -0500 | [diff] [blame] | 80 | Mockito.mock(MobileDataControllerImpl.class)); |
| 81 | setupNetworkController(); |
| 82 | |
| 83 | setupDefaultSignal(); |
| 84 | updateDataConnectionState(TelephonyManager.DATA_CONNECTED, |
| 85 | TelephonyManager.NETWORK_TYPE_LTE); |
| 86 | |
| 87 | verifyDataIndicators(TelephonyIcons.DATA_4G[1][0 /* No direction */], |
Jason Monk | 33f8ae7 | 2015-05-08 10:45:15 -0400 | [diff] [blame^] | 88 | TelephonyIcons.QS_DATA_4G); |
Jason Monk | 3aaabd7 | 2014-12-12 11:11:44 -0500 | [diff] [blame] | 89 | } |
| 90 | |
| 91 | public void test4gDataIconConfigChange() { |
| 92 | setupDefaultSignal(); |
| 93 | updateDataConnectionState(TelephonyManager.DATA_CONNECTED, |
| 94 | TelephonyManager.NETWORK_TYPE_LTE); |
| 95 | |
| 96 | // Switch to showing 4g icon and re-initialize the NetworkController. |
| 97 | mConfig.show4gForLte = true; |
| 98 | // Can't send the broadcast as that would actually read the config from |
| 99 | // the context. Instead we'll just poke at a function that does all of |
| 100 | // the after work. |
| 101 | mNetworkController.handleConfigurationChanged(); |
| 102 | |
| 103 | verifyDataIndicators(TelephonyIcons.DATA_4G[1][0 /* No direction */], |
Jason Monk | 33f8ae7 | 2015-05-08 10:45:15 -0400 | [diff] [blame^] | 104 | TelephonyIcons.QS_DATA_4G); |
Jason Monk | 3aaabd7 | 2014-12-12 11:11:44 -0500 | [diff] [blame] | 105 | } |
| 106 | |
Jason Monk | f13b4b3 | 2014-11-07 16:39:34 -0500 | [diff] [blame] | 107 | public void testDataActivity() { |
| 108 | setupDefaultSignal(); |
| 109 | |
| 110 | testDataActivity(TelephonyManager.DATA_ACTIVITY_NONE, false, false); |
| 111 | testDataActivity(TelephonyManager.DATA_ACTIVITY_IN, true, false); |
| 112 | testDataActivity(TelephonyManager.DATA_ACTIVITY_OUT, false, true); |
| 113 | testDataActivity(TelephonyManager.DATA_ACTIVITY_INOUT, true, true); |
| 114 | } |
| 115 | |
| 116 | private void testDataActivity(int direction, boolean in, boolean out) { |
| 117 | updateDataActivity(direction); |
| 118 | |
| 119 | verifyLastMobileDataIndicators(true, DEFAULT_SIGNAL_STRENGTH, DEFAULT_ICON); |
| 120 | verifyLastQsMobileDataIndicators(true, DEFAULT_QS_SIGNAL_STRENGTH, |
Jason Monk | b574627 | 2014-11-12 16:50:31 -0500 | [diff] [blame] | 121 | DEFAULT_QS_ICON, in, out); |
Jason Monk | f13b4b3 | 2014-11-07 16:39:34 -0500 | [diff] [blame] | 122 | |
| 123 | } |
| 124 | |
| 125 | private void verifyDataIndicators(int dataIcon, int qsDataIcon) { |
| 126 | verifyLastMobileDataIndicators(true, DEFAULT_SIGNAL_STRENGTH, dataIcon); |
| 127 | verifyLastQsMobileDataIndicators(true, DEFAULT_QS_SIGNAL_STRENGTH, qsDataIcon, false, |
Jason Monk | b574627 | 2014-11-12 16:50:31 -0500 | [diff] [blame] | 128 | false); |
Jason Monk | f13b4b3 | 2014-11-07 16:39:34 -0500 | [diff] [blame] | 129 | } |
| 130 | |
| 131 | } |