Loading tests/telephonytests/src/com/android/internal/telephony/CellIdentityGsmTest.java +30 −17 Original line number Diff line number Diff line Loading @@ -21,8 +21,9 @@ import android.telephony.CellIdentityGsm; import android.test.AndroidTestCase; import android.test.suitebuilder.annotation.SmallTest; /** Unit tests for {@link CellIdentityGsm}. */ import java.util.Collections; /** Unit tests for {@link CellIdentityGsm}. */ public class CellIdentityGsmTest extends AndroidTestCase { // Location Area Code ranges from 0 to 65535. Loading @@ -45,7 +46,7 @@ public class CellIdentityGsmTest extends AndroidTestCase { public void testDefaultConstructor() { CellIdentityGsm ci = new CellIdentityGsm(LAC, CID, ARFCN, BSIC, MCC_STR, MNC_STR, ALPHA_LONG, ALPHA_SHORT); ALPHA_LONG, ALPHA_SHORT, Collections.emptyList()); assertEquals(LAC, ci.getLac()); assertEquals(CID, ci.getCid()); Loading @@ -66,7 +67,7 @@ public class CellIdentityGsmTest extends AndroidTestCase { final String mncWithThreeDigit = "061"; CellIdentityGsm ci = new CellIdentityGsm(LAC, CID, ARFCN, BSIC, MCC_STR, mncWithThreeDigit, ALPHA_LONG, ALPHA_SHORT); ALPHA_LONG, ALPHA_SHORT, Collections.emptyList()); assertEquals(MCC, ci.getMcc()); assertEquals(61, ci.getMnc()); Loading @@ -80,7 +81,7 @@ public class CellIdentityGsmTest extends AndroidTestCase { final String mncWithTwoDigit = "61"; CellIdentityGsm ci = new CellIdentityGsm(LAC, CID, ARFCN, BSIC, MCC_STR, mncWithTwoDigit, ALPHA_LONG, ALPHA_SHORT); ALPHA_LONG, ALPHA_SHORT, Collections.emptyList()); assertEquals(MCC, ci.getMcc()); assertEquals(61, ci.getMnc()); Loading @@ -92,7 +93,8 @@ public class CellIdentityGsmTest extends AndroidTestCase { @SmallTest public void testConstructorWithEmptyMccMnc() { CellIdentityGsm ci = new CellIdentityGsm(LAC, CID, ARFCN, BSIC, null, null, ALPHA_LONG, ALPHA_SHORT); new CellIdentityGsm(LAC, CID, ARFCN, BSIC, null, null, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList()); assertEquals(Integer.MAX_VALUE, ci.getMcc()); assertEquals(Integer.MAX_VALUE, ci.getMnc()); Loading @@ -100,7 +102,8 @@ public class CellIdentityGsmTest extends AndroidTestCase { assertNull(ci.getMncString()); assertNull(ci.getMobileNetworkOperator()); ci = new CellIdentityGsm(LAC, CID, ARFCN, BSIC, MCC_STR, null, ALPHA_LONG, ALPHA_SHORT); ci = new CellIdentityGsm(LAC, CID, ARFCN, BSIC, MCC_STR, null, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList()); assertEquals(MCC, ci.getMcc()); assertEquals(Integer.MAX_VALUE, ci.getMnc()); Loading @@ -108,7 +111,8 @@ public class CellIdentityGsmTest extends AndroidTestCase { assertNull(ci.getMncString()); assertNull(ci.getMobileNetworkOperator()); ci = new CellIdentityGsm(LAC, CID, ARFCN, BSIC, null, MNC_STR, ALPHA_LONG, ALPHA_SHORT); ci = new CellIdentityGsm(LAC, CID, ARFCN, BSIC, null, MNC_STR, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList()); assertEquals(MNC, ci.getMnc()); assertEquals(Integer.MAX_VALUE, ci.getMcc()); Loading @@ -116,7 +120,8 @@ public class CellIdentityGsmTest extends AndroidTestCase { assertNull(ci.getMccString()); assertNull(ci.getMobileNetworkOperator()); ci = new CellIdentityGsm(LAC, CID, ARFCN, BSIC, "", "", ALPHA_LONG, ALPHA_SHORT); ci = new CellIdentityGsm(LAC, CID, ARFCN, BSIC, "", "", ALPHA_LONG, ALPHA_SHORT, Collections.emptyList()); assertEquals(Integer.MAX_VALUE, ci.getMcc()); assertEquals(Integer.MAX_VALUE, ci.getMnc()); Loading @@ -128,20 +133,26 @@ public class CellIdentityGsmTest extends AndroidTestCase { @SmallTest public void testEquals() { CellIdentityGsm ciA = new CellIdentityGsm( LAC, CID, ARFCN, BSIC, MCC_STR, MNC_STR, ALPHA_LONG, ALPHA_SHORT); LAC, CID, ARFCN, BSIC, MCC_STR, MNC_STR, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList()); CellIdentityGsm ciB = new CellIdentityGsm( LAC, CID, ARFCN, BSIC, MCC_STR, MNC_STR, ALPHA_LONG, ALPHA_SHORT); LAC, CID, ARFCN, BSIC, MCC_STR, MNC_STR, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList()); assertTrue(ciA.equals(ciB)); ciA = new CellIdentityGsm(LAC, CID, ARFCN, BSIC, null, MNC_STR, ALPHA_LONG, ALPHA_SHORT); ciB = new CellIdentityGsm(LAC, CID, ARFCN, BSIC, null, MNC_STR, ALPHA_LONG, ALPHA_SHORT); ciA = new CellIdentityGsm(LAC, CID, ARFCN, BSIC, null, MNC_STR, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList()); ciB = new CellIdentityGsm(LAC, CID, ARFCN, BSIC, null, MNC_STR, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList()); assertTrue(ciA.equals(ciB)); ciA = new CellIdentityGsm( LAC, CID, ARFCN, BSIC, MCC_STR, MNC_STR, ALPHA_LONG, ALPHA_SHORT); ciB = new CellIdentityGsm(LAC, CID, ARFCN, BSIC, null, MNC_STR, ALPHA_LONG, ALPHA_SHORT); LAC, CID, ARFCN, BSIC, MCC_STR, MNC_STR, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList()); ciB = new CellIdentityGsm(LAC, CID, ARFCN, BSIC, null, MNC_STR, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList()); assertFalse(ciA.equals(ciB)); } Loading @@ -150,7 +161,7 @@ public class CellIdentityGsmTest extends AndroidTestCase { public void testParcel() { CellIdentityGsm ci = new CellIdentityGsm(LAC, CID, ARFCN, BSIC, MCC_STR, MNC_STR, ALPHA_LONG, ALPHA_SHORT); ALPHA_LONG, ALPHA_SHORT, Collections.emptyList()); Parcel p = Parcel.obtain(); ci.writeToParcel(p, 0); Loading @@ -163,7 +174,8 @@ public class CellIdentityGsmTest extends AndroidTestCase { @SmallTest public void testParcelWithUnknowMccMnc() { CellIdentityGsm ci = new CellIdentityGsm(LAC, CID, ARFCN, BSIC, null, null, ALPHA_LONG, ALPHA_SHORT); new CellIdentityGsm(LAC, CID, ARFCN, BSIC, null, null, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList()); Parcel p = Parcel.obtain(); ci.writeToParcel(p, 0); Loading @@ -178,7 +190,8 @@ public class CellIdentityGsmTest extends AndroidTestCase { final String invalidMcc = "randomStuff"; final String invalidMnc = "randomStuff"; CellIdentityGsm ci = new CellIdentityGsm(LAC, CID, ARFCN, BSIC, null, null, ALPHA_LONG, ALPHA_SHORT); new CellIdentityGsm(LAC, CID, ARFCN, BSIC, null, null, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList()); Parcel p = Parcel.obtain(); ci.writeToParcel(p, 0); Loading tests/telephonytests/src/com/android/internal/telephony/CellIdentityLteTest.java +30 −16 Original line number Diff line number Diff line Loading @@ -22,6 +22,8 @@ import android.telephony.CellInfo; import android.test.AndroidTestCase; import android.test.suitebuilder.annotation.SmallTest; import java.util.Collections; /** Unit tests for {@link CellIdentityLte}. */ public class CellIdentityLteTest extends AndroidTestCase { Loading @@ -46,7 +48,7 @@ public class CellIdentityLteTest extends AndroidTestCase { public void testDefaultConstructor() { CellIdentityLte ci = new CellIdentityLte(CI, PCI, TAC, EARFCN, BANDWIDTH, MCC_STR, MNC_STR, ALPHA_LONG, ALPHA_SHORT); ALPHA_LONG, ALPHA_SHORT, Collections.emptyList(), null); assertEquals(CI, ci.getCi()); assertEquals(PCI, ci.getPci()); Loading @@ -68,7 +70,7 @@ public class CellIdentityLteTest extends AndroidTestCase { final String mncWithThreeDigit = "061"; CellIdentityLte ci = new CellIdentityLte(CI, PCI, TAC, EARFCN, BANDWIDTH, MCC_STR, mncWithThreeDigit, ALPHA_LONG, ALPHA_SHORT); ALPHA_LONG, ALPHA_SHORT, Collections.emptyList(), null); assertEquals(MCC, ci.getMcc()); assertEquals(61, ci.getMnc()); Loading @@ -82,7 +84,7 @@ public class CellIdentityLteTest extends AndroidTestCase { final String mncWithTwoDigit = "61"; CellIdentityLte ci = new CellIdentityLte(CI, PCI, TAC, EARFCN, BANDWIDTH, MCC_STR, mncWithTwoDigit, ALPHA_LONG, ALPHA_SHORT); ALPHA_LONG, ALPHA_SHORT, Collections.emptyList(), null); assertEquals(MCC, ci.getMcc()); assertEquals(61, ci.getMnc()); Loading @@ -94,7 +96,8 @@ public class CellIdentityLteTest extends AndroidTestCase { @SmallTest public void testConstructorWithEmptyMccMnc() { CellIdentityLte ci = new CellIdentityLte( CI, PCI, TAC, EARFCN, BANDWIDTH, null, null, ALPHA_LONG, ALPHA_SHORT); CI, PCI, TAC, EARFCN, BANDWIDTH, null, null, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList(), null); assertEquals(Integer.MAX_VALUE, ci.getMcc()); assertEquals(Integer.MAX_VALUE, ci.getMnc()); Loading @@ -103,7 +106,8 @@ public class CellIdentityLteTest extends AndroidTestCase { assertNull(ci.getMobileNetworkOperator()); ci = new CellIdentityLte( CI, PCI, TAC, EARFCN, BANDWIDTH, MCC_STR, null, ALPHA_LONG, ALPHA_SHORT); CI, PCI, TAC, EARFCN, BANDWIDTH, MCC_STR, null, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList(), null); assertEquals(MCC, ci.getMcc()); assertEquals(Integer.MAX_VALUE, ci.getMnc()); Loading @@ -112,7 +116,8 @@ public class CellIdentityLteTest extends AndroidTestCase { assertNull(ci.getMobileNetworkOperator()); ci = new CellIdentityLte( CI, PCI, TAC, EARFCN, BANDWIDTH, null, MNC_STR, ALPHA_LONG, ALPHA_SHORT); CI, PCI, TAC, EARFCN, BANDWIDTH, null, MNC_STR, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList(), null); assertEquals(MNC, ci.getMnc()); assertEquals(Integer.MAX_VALUE, ci.getMcc()); Loading @@ -121,7 +126,8 @@ public class CellIdentityLteTest extends AndroidTestCase { assertNull(ci.getMobileNetworkOperator()); ci = new CellIdentityLte( CI, PCI, TAC, EARFCN, BANDWIDTH, "", "", ALPHA_LONG, ALPHA_SHORT); CI, PCI, TAC, EARFCN, BANDWIDTH, "", "", ALPHA_LONG, ALPHA_SHORT, Collections.emptyList(), null); assertEquals(Integer.MAX_VALUE, ci.getMcc()); assertEquals(Integer.MAX_VALUE, ci.getMnc()); Loading Loading @@ -152,23 +158,29 @@ public class CellIdentityLteTest extends AndroidTestCase { @SmallTest public void testEquals() { CellIdentityLte ciA = new CellIdentityLte( CI, PCI, TAC, EARFCN, BANDWIDTH, MCC_STR, MNC_STR, ALPHA_LONG, ALPHA_SHORT); CI, PCI, TAC, EARFCN, BANDWIDTH, MCC_STR, MNC_STR, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList(), null); CellIdentityLte ciB = new CellIdentityLte( CI, PCI, TAC, EARFCN, BANDWIDTH, MCC_STR, MNC_STR, ALPHA_LONG, ALPHA_SHORT); CI, PCI, TAC, EARFCN, BANDWIDTH, MCC_STR, MNC_STR, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList(), null); assertTrue(ciA.equals(ciB)); ciA = new CellIdentityLte( CI, PCI, TAC, EARFCN, BANDWIDTH, null, null, ALPHA_LONG, ALPHA_SHORT); CI, PCI, TAC, EARFCN, BANDWIDTH, null, null, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList(), null); ciB = new CellIdentityLte( CI, PCI, TAC, EARFCN, BANDWIDTH, null, null, ALPHA_LONG, ALPHA_SHORT); CI, PCI, TAC, EARFCN, BANDWIDTH, null, null, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList(), null); assertTrue(ciA.equals(ciB)); ciA = new CellIdentityLte( CI, PCI, TAC, EARFCN, BANDWIDTH, MCC_STR, null, ALPHA_LONG, ALPHA_SHORT); CI, PCI, TAC, EARFCN, BANDWIDTH, MCC_STR, null, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList(), null); ciB = new CellIdentityLte( CI, PCI, TAC, EARFCN, BANDWIDTH, null, null, ALPHA_LONG, ALPHA_SHORT); CI, PCI, TAC, EARFCN, BANDWIDTH, null, null, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList(), null); assertFalse(ciA.equals(ciB)); } Loading @@ -177,7 +189,7 @@ public class CellIdentityLteTest extends AndroidTestCase { public void testParcel() { CellIdentityLte ci = new CellIdentityLte(CI, PCI, TAC, EARFCN, BANDWIDTH, MCC_STR, MNC_STR, ALPHA_LONG, ALPHA_SHORT); ALPHA_LONG, ALPHA_SHORT, Collections.emptyList(), null); Parcel p = Parcel.obtain(); ci.writeToParcel(p, 0); Loading @@ -190,7 +202,8 @@ public class CellIdentityLteTest extends AndroidTestCase { @SmallTest public void testParcelWithUnknownMccMnc() { CellIdentityLte ci = new CellIdentityLte( CI, PCI, TAC, EARFCN, BANDWIDTH, null, null, ALPHA_LONG, ALPHA_SHORT); CI, PCI, TAC, EARFCN, BANDWIDTH, null, null, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList(), null); Parcel p = Parcel.obtain(); p.writeInt(CellInfo.TYPE_LTE); Loading @@ -214,7 +227,8 @@ public class CellIdentityLteTest extends AndroidTestCase { final String invalidMcc = "randomStuff"; final String invalidMnc = "randomStuff"; CellIdentityLte ci = new CellIdentityLte( CI, PCI, TAC, EARFCN, BANDWIDTH, null, null, ALPHA_LONG, ALPHA_SHORT); CI, PCI, TAC, EARFCN, BANDWIDTH, null, null, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList(), null); Parcel p = Parcel.obtain(); p.writeInt(CellInfo.TYPE_LTE); Loading tests/telephonytests/src/com/android/internal/telephony/CellIdentityNrTest.java +14 −6 Original line number Diff line number Diff line Loading @@ -25,6 +25,8 @@ import android.test.AndroidTestCase; import org.junit.Test; import java.util.Collections; public class CellIdentityNrTest extends AndroidTestCase { private static final String MCC = "310"; private static final String MNC = "260"; Loading @@ -41,7 +43,8 @@ public class CellIdentityNrTest extends AndroidTestCase { public void testGetMethod() { // GIVEN an instance of CellIdentityNr CellIdentityNr cellIdentityNr = new CellIdentityNr(PCI, TAC, NRARFCN, MCC, MNC, NCI, ALPHAL, ALPHAS); new CellIdentityNr(PCI, TAC, NRARFCN, MCC, MNC, NCI, ALPHAL, ALPHAS, Collections.emptyList()); // THEN the get method should return correct value assertThat(cellIdentityNr.getType()).isEqualTo(CellInfo.TYPE_NR); Loading @@ -60,9 +63,11 @@ public class CellIdentityNrTest extends AndroidTestCase { public void testEquals_sameParameters() { // GIVEN an instance of CellIdentityNr, and create another object with the same parameters CellIdentityNr cellIdentityNr = new CellIdentityNr(PCI, TAC, NRARFCN, MCC, MNC, NCI, ALPHAL, ALPHAS); new CellIdentityNr(PCI, TAC, NRARFCN, MCC, MNC, NCI, ALPHAL, ALPHAS, Collections.emptyList()); CellIdentityNr anotherCellIdentityNr = new CellIdentityNr(PCI, TAC, NRARFCN, MCC, MNC, NCI, ALPHAL, ALPHAS); new CellIdentityNr(PCI, TAC, NRARFCN, MCC, MNC, NCI, ALPHAL, ALPHAS, Collections.emptyList()); // THEN this two objects are equivalent assertThat(cellIdentityNr).isEqualTo(anotherCellIdentityNr); Loading @@ -72,9 +77,11 @@ public class CellIdentityNrTest extends AndroidTestCase { public void testEquals_differentParameters() { // GIVEN an instance of CellIdentityNr, and create another object with different parameters CellIdentityNr cellIdentityNr = new CellIdentityNr(PCI, TAC, NRARFCN, MCC, MNC, NCI, ALPHAL, ALPHAS); new CellIdentityNr(PCI, TAC, NRARFCN, MCC, MNC, NCI, ALPHAL, ALPHAS, Collections.emptyList()); CellIdentityNr anotherCellIdentityNr = new CellIdentityNr(PCI, TAC, NRARFCN, MCC, MNC, NCI + 1, ALPHAL, ALPHAS); new CellIdentityNr(PCI, TAC, NRARFCN, MCC, MNC, NCI + 1, ALPHAL, ALPHAS, Collections.emptyList()); // THEN this two objects are different assertThat(cellIdentityNr).isNotEqualTo(anotherCellIdentityNr); Loading @@ -84,7 +91,8 @@ public class CellIdentityNrTest extends AndroidTestCase { public void testParcel() { // GIVEN an instance of CellIdentityNr CellIdentityNr cellIdentityNr = new CellIdentityNr(PCI, TAC, NRARFCN, MCC, MNC, NCI, ALPHAL, ALPHAS); new CellIdentityNr(PCI, TAC, NRARFCN, MCC, MNC, NCI, ALPHAL, ALPHAS, Collections.emptyList()); // WHEN write the object to parcel and create another object with that parcel Parcel parcel = Parcel.obtain(); Loading tests/telephonytests/src/com/android/internal/telephony/CellIdentityTdscdmaTest.java +17 −8 Original line number Diff line number Diff line Loading @@ -24,6 +24,8 @@ import android.test.suitebuilder.annotation.SmallTest; /** Unit tests for {@link CellIdentityTdscdma}. */ import java.util.Collections; public class CellIdentityTdscdmaTest extends AndroidTestCase { // Cell identity ranges from 0 to 268435456. Loading Loading @@ -67,7 +69,8 @@ public class CellIdentityTdscdmaTest extends AndroidTestCase { public void testConstructor() { CellIdentityTdscdma ci = new CellIdentityTdscdma( MCC_STR, MNC_STR, LAC, CID, CPID, UARFCN, ALPHA_LONG, ALPHA_SHORT); MCC_STR, MNC_STR, LAC, CID, CPID, UARFCN, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList(), null); assertEquals(MCC_STR, ci.getMccString()); assertEquals(MNC_STR, ci.getMncString()); Loading @@ -83,22 +86,25 @@ public class CellIdentityTdscdmaTest extends AndroidTestCase { @SmallTest public void testConstructorWithEmptyMccMnc() { CellIdentityTdscdma ci = new CellIdentityTdscdma( null, null, LAC, CID, CPID, UARFCN, "", ""); null, null, LAC, CID, CPID, UARFCN, "", "", Collections.emptyList(), null); assertNull(ci.getMccString()); assertNull(ci.getMncString()); ci = new CellIdentityTdscdma(MCC_STR, null, LAC, CID, CPID, UARFCN, "", ""); ci = new CellIdentityTdscdma(MCC_STR, null, LAC, CID, CPID, UARFCN, "", "", Collections.emptyList(), null); assertEquals(MCC_STR, ci.getMccString()); assertNull(ci.getMncString()); ci = new CellIdentityTdscdma(null, MNC_STR, LAC, CID, CPID, UARFCN, "", ""); ci = new CellIdentityTdscdma(null, MNC_STR, LAC, CID, CPID, UARFCN, "", "", Collections.emptyList(), null); assertEquals(MNC_STR, ci.getMncString()); assertNull(ci.getMccString()); ci = new CellIdentityTdscdma("", "", LAC, CID, CPID, UARFCN, "", ""); ci = new CellIdentityTdscdma("", "", LAC, CID, CPID, UARFCN, "", "", Collections.emptyList(), null); assertNull(ci.getMccString()); assertNull(ci.getMncString()); Loading @@ -107,7 +113,8 @@ public class CellIdentityTdscdmaTest extends AndroidTestCase { @SmallTest public void testParcel() { CellIdentityTdscdma ci = new CellIdentityTdscdma( MCC_STR, MNC_STR, LAC, CID, UARFCN, CPID, ALPHA_LONG, ALPHA_SHORT); MCC_STR, MNC_STR, LAC, CID, UARFCN, CPID, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList(), null); Parcel p = Parcel.obtain(); ci.writeToParcel(p, 0); Loading @@ -121,7 +128,8 @@ public class CellIdentityTdscdmaTest extends AndroidTestCase { public void testParcelWithUnknowMccMnc() { CellIdentityTdscdma ci = new CellIdentityTdscdma( null, null, LAC, CID, CPID, UARFCN, ALPHA_LONG, ALPHA_SHORT); null, null, LAC, CID, CPID, UARFCN, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList(), null); Parcel p = Parcel.obtain(); p.writeInt(CellInfo.TYPE_TDSCDMA); Loading @@ -145,7 +153,8 @@ public class CellIdentityTdscdmaTest extends AndroidTestCase { final String invalidMnc = "randomStuff"; CellIdentityTdscdma ci = new CellIdentityTdscdma( null, null, LAC, CID, CPID, UARFCN, ALPHA_LONG, ALPHA_SHORT); null, null, LAC, CID, CPID, UARFCN, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList(), null); Parcel p = Parcel.obtain(); p.writeInt(CellInfo.TYPE_TDSCDMA); Loading tests/telephonytests/src/com/android/internal/telephony/CellIdentityTest.java +17 −10 Original line number Diff line number Diff line Loading @@ -25,6 +25,8 @@ import android.telephony.CellInfo; import android.test.AndroidTestCase; import android.test.suitebuilder.annotation.SmallTest; import java.util.Collections; public class CellIdentityTest extends AndroidTestCase { // Cell identity ranges from 0 to 268435456. Loading Loading @@ -67,14 +69,16 @@ public class CellIdentityTest extends AndroidTestCase { @SmallTest public void testConstructCellIdentityGsm() { // Test values below zero (these must all be non-negative) CellIdentityGsm gsm = new CellIdentityGsm(-1, -1, -1, -1, null, null, null, null); CellIdentityGsm gsm = new CellIdentityGsm(-1, -1, -1, -1, null, null, null, null, Collections.emptyList()); assertEquals(CellInfo.UNAVAILABLE, gsm.getLac()); assertEquals(CellInfo.UNAVAILABLE, gsm.getCid()); assertEquals(CellInfo.UNAVAILABLE, gsm.getArfcn()); assertEquals(CellInfo.UNAVAILABLE, gsm.getBsic()); // Test max values of LAC, CID, ARFCN, and BSIC gsm = new CellIdentityGsm(MAX_LAC, MAX_CID, MAX_ARFCN, MAX_BSIC, null, null, null, null); gsm = new CellIdentityGsm(MAX_LAC, MAX_CID, MAX_ARFCN, MAX_BSIC, null, null, null, null, Collections.emptyList()); assertEquals(MAX_LAC, gsm.getLac()); assertEquals(MAX_CID, gsm.getCid()); assertEquals(MAX_ARFCN, gsm.getArfcn()); Loading @@ -82,7 +86,8 @@ public class CellIdentityTest extends AndroidTestCase { // Test max values + 1 of LAC, CID, ARFCN, and BSIC gsm = new CellIdentityGsm( MAX_LAC + 1, MAX_CID + 1, MAX_ARFCN + 1, MAX_BSIC + 1, null, null, null, null); MAX_LAC + 1, MAX_CID + 1, MAX_ARFCN + 1, MAX_BSIC + 1, null, null, null, null, Collections.emptyList()); assertEquals(CellInfo.UNAVAILABLE, gsm.getLac()); assertEquals(CellInfo.UNAVAILABLE, gsm.getCid()); assertEquals(CellInfo.UNAVAILABLE, gsm.getArfcn()); Loading @@ -93,23 +98,25 @@ public class CellIdentityTest extends AndroidTestCase { @SmallTest public void testEquals() { CellIdentity ciA = new CellIdentityLte( CI, PCI, TAC, EARFCN, BANDWIDTH, MCC_STR, MNC_STR, ALPHA_LONG, ALPHA_SHORT); CI, PCI, TAC, EARFCN, BANDWIDTH, MCC_STR, MNC_STR, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList(), null); CellIdentity ciB = new CellIdentityLte( CI, PCI, TAC, EARFCN, BANDWIDTH, MCC_STR, MNC_STR, ALPHA_LONG, ALPHA_SHORT); CI, PCI, TAC, EARFCN, BANDWIDTH, MCC_STR, MNC_STR, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList(), null); assertTrue(ciA.equals(ciB)); ciA = new CellIdentityLte(CI, PCI, TAC, EARFCN, BANDWIDTH, null, null, ALPHA_LONG, ALPHA_SHORT); ALPHA_SHORT, Collections.emptyList(), null); ciB = new CellIdentityLte(CI, PCI, TAC, EARFCN, BANDWIDTH, null, null, ALPHA_LONG, ALPHA_SHORT); ALPHA_SHORT, Collections.emptyList(), null); assertTrue(ciA.equals(ciB)); ciA = new CellIdentityLte(CI, PCI, TAC, EARFCN, BANDWIDTH, MCC_STR, null, ALPHA_LONG, ALPHA_SHORT); ALPHA_SHORT, Collections.emptyList(), null); ciB = new CellIdentityLte(CI, PCI, TAC, EARFCN, BANDWIDTH, null, null, ALPHA_LONG, ALPHA_SHORT); ALPHA_SHORT, Collections.emptyList(), null); assertFalse(ciA.equals(ciB)); } Loading @@ -117,7 +124,7 @@ public class CellIdentityTest extends AndroidTestCase { @SmallTest public void testParcel() { CellIdentity ci = new CellIdentityLte(CI, PCI, TAC, EARFCN, BANDWIDTH, MCC_STR, MNC_STR, ALPHA_LONG, ALPHA_SHORT); ALPHA_LONG, ALPHA_SHORT, Collections.emptyList(), null); Parcel p = Parcel.obtain(); ci.writeToParcel(p, 0); Loading Loading
tests/telephonytests/src/com/android/internal/telephony/CellIdentityGsmTest.java +30 −17 Original line number Diff line number Diff line Loading @@ -21,8 +21,9 @@ import android.telephony.CellIdentityGsm; import android.test.AndroidTestCase; import android.test.suitebuilder.annotation.SmallTest; /** Unit tests for {@link CellIdentityGsm}. */ import java.util.Collections; /** Unit tests for {@link CellIdentityGsm}. */ public class CellIdentityGsmTest extends AndroidTestCase { // Location Area Code ranges from 0 to 65535. Loading @@ -45,7 +46,7 @@ public class CellIdentityGsmTest extends AndroidTestCase { public void testDefaultConstructor() { CellIdentityGsm ci = new CellIdentityGsm(LAC, CID, ARFCN, BSIC, MCC_STR, MNC_STR, ALPHA_LONG, ALPHA_SHORT); ALPHA_LONG, ALPHA_SHORT, Collections.emptyList()); assertEquals(LAC, ci.getLac()); assertEquals(CID, ci.getCid()); Loading @@ -66,7 +67,7 @@ public class CellIdentityGsmTest extends AndroidTestCase { final String mncWithThreeDigit = "061"; CellIdentityGsm ci = new CellIdentityGsm(LAC, CID, ARFCN, BSIC, MCC_STR, mncWithThreeDigit, ALPHA_LONG, ALPHA_SHORT); ALPHA_LONG, ALPHA_SHORT, Collections.emptyList()); assertEquals(MCC, ci.getMcc()); assertEquals(61, ci.getMnc()); Loading @@ -80,7 +81,7 @@ public class CellIdentityGsmTest extends AndroidTestCase { final String mncWithTwoDigit = "61"; CellIdentityGsm ci = new CellIdentityGsm(LAC, CID, ARFCN, BSIC, MCC_STR, mncWithTwoDigit, ALPHA_LONG, ALPHA_SHORT); ALPHA_LONG, ALPHA_SHORT, Collections.emptyList()); assertEquals(MCC, ci.getMcc()); assertEquals(61, ci.getMnc()); Loading @@ -92,7 +93,8 @@ public class CellIdentityGsmTest extends AndroidTestCase { @SmallTest public void testConstructorWithEmptyMccMnc() { CellIdentityGsm ci = new CellIdentityGsm(LAC, CID, ARFCN, BSIC, null, null, ALPHA_LONG, ALPHA_SHORT); new CellIdentityGsm(LAC, CID, ARFCN, BSIC, null, null, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList()); assertEquals(Integer.MAX_VALUE, ci.getMcc()); assertEquals(Integer.MAX_VALUE, ci.getMnc()); Loading @@ -100,7 +102,8 @@ public class CellIdentityGsmTest extends AndroidTestCase { assertNull(ci.getMncString()); assertNull(ci.getMobileNetworkOperator()); ci = new CellIdentityGsm(LAC, CID, ARFCN, BSIC, MCC_STR, null, ALPHA_LONG, ALPHA_SHORT); ci = new CellIdentityGsm(LAC, CID, ARFCN, BSIC, MCC_STR, null, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList()); assertEquals(MCC, ci.getMcc()); assertEquals(Integer.MAX_VALUE, ci.getMnc()); Loading @@ -108,7 +111,8 @@ public class CellIdentityGsmTest extends AndroidTestCase { assertNull(ci.getMncString()); assertNull(ci.getMobileNetworkOperator()); ci = new CellIdentityGsm(LAC, CID, ARFCN, BSIC, null, MNC_STR, ALPHA_LONG, ALPHA_SHORT); ci = new CellIdentityGsm(LAC, CID, ARFCN, BSIC, null, MNC_STR, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList()); assertEquals(MNC, ci.getMnc()); assertEquals(Integer.MAX_VALUE, ci.getMcc()); Loading @@ -116,7 +120,8 @@ public class CellIdentityGsmTest extends AndroidTestCase { assertNull(ci.getMccString()); assertNull(ci.getMobileNetworkOperator()); ci = new CellIdentityGsm(LAC, CID, ARFCN, BSIC, "", "", ALPHA_LONG, ALPHA_SHORT); ci = new CellIdentityGsm(LAC, CID, ARFCN, BSIC, "", "", ALPHA_LONG, ALPHA_SHORT, Collections.emptyList()); assertEquals(Integer.MAX_VALUE, ci.getMcc()); assertEquals(Integer.MAX_VALUE, ci.getMnc()); Loading @@ -128,20 +133,26 @@ public class CellIdentityGsmTest extends AndroidTestCase { @SmallTest public void testEquals() { CellIdentityGsm ciA = new CellIdentityGsm( LAC, CID, ARFCN, BSIC, MCC_STR, MNC_STR, ALPHA_LONG, ALPHA_SHORT); LAC, CID, ARFCN, BSIC, MCC_STR, MNC_STR, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList()); CellIdentityGsm ciB = new CellIdentityGsm( LAC, CID, ARFCN, BSIC, MCC_STR, MNC_STR, ALPHA_LONG, ALPHA_SHORT); LAC, CID, ARFCN, BSIC, MCC_STR, MNC_STR, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList()); assertTrue(ciA.equals(ciB)); ciA = new CellIdentityGsm(LAC, CID, ARFCN, BSIC, null, MNC_STR, ALPHA_LONG, ALPHA_SHORT); ciB = new CellIdentityGsm(LAC, CID, ARFCN, BSIC, null, MNC_STR, ALPHA_LONG, ALPHA_SHORT); ciA = new CellIdentityGsm(LAC, CID, ARFCN, BSIC, null, MNC_STR, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList()); ciB = new CellIdentityGsm(LAC, CID, ARFCN, BSIC, null, MNC_STR, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList()); assertTrue(ciA.equals(ciB)); ciA = new CellIdentityGsm( LAC, CID, ARFCN, BSIC, MCC_STR, MNC_STR, ALPHA_LONG, ALPHA_SHORT); ciB = new CellIdentityGsm(LAC, CID, ARFCN, BSIC, null, MNC_STR, ALPHA_LONG, ALPHA_SHORT); LAC, CID, ARFCN, BSIC, MCC_STR, MNC_STR, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList()); ciB = new CellIdentityGsm(LAC, CID, ARFCN, BSIC, null, MNC_STR, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList()); assertFalse(ciA.equals(ciB)); } Loading @@ -150,7 +161,7 @@ public class CellIdentityGsmTest extends AndroidTestCase { public void testParcel() { CellIdentityGsm ci = new CellIdentityGsm(LAC, CID, ARFCN, BSIC, MCC_STR, MNC_STR, ALPHA_LONG, ALPHA_SHORT); ALPHA_LONG, ALPHA_SHORT, Collections.emptyList()); Parcel p = Parcel.obtain(); ci.writeToParcel(p, 0); Loading @@ -163,7 +174,8 @@ public class CellIdentityGsmTest extends AndroidTestCase { @SmallTest public void testParcelWithUnknowMccMnc() { CellIdentityGsm ci = new CellIdentityGsm(LAC, CID, ARFCN, BSIC, null, null, ALPHA_LONG, ALPHA_SHORT); new CellIdentityGsm(LAC, CID, ARFCN, BSIC, null, null, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList()); Parcel p = Parcel.obtain(); ci.writeToParcel(p, 0); Loading @@ -178,7 +190,8 @@ public class CellIdentityGsmTest extends AndroidTestCase { final String invalidMcc = "randomStuff"; final String invalidMnc = "randomStuff"; CellIdentityGsm ci = new CellIdentityGsm(LAC, CID, ARFCN, BSIC, null, null, ALPHA_LONG, ALPHA_SHORT); new CellIdentityGsm(LAC, CID, ARFCN, BSIC, null, null, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList()); Parcel p = Parcel.obtain(); ci.writeToParcel(p, 0); Loading
tests/telephonytests/src/com/android/internal/telephony/CellIdentityLteTest.java +30 −16 Original line number Diff line number Diff line Loading @@ -22,6 +22,8 @@ import android.telephony.CellInfo; import android.test.AndroidTestCase; import android.test.suitebuilder.annotation.SmallTest; import java.util.Collections; /** Unit tests for {@link CellIdentityLte}. */ public class CellIdentityLteTest extends AndroidTestCase { Loading @@ -46,7 +48,7 @@ public class CellIdentityLteTest extends AndroidTestCase { public void testDefaultConstructor() { CellIdentityLte ci = new CellIdentityLte(CI, PCI, TAC, EARFCN, BANDWIDTH, MCC_STR, MNC_STR, ALPHA_LONG, ALPHA_SHORT); ALPHA_LONG, ALPHA_SHORT, Collections.emptyList(), null); assertEquals(CI, ci.getCi()); assertEquals(PCI, ci.getPci()); Loading @@ -68,7 +70,7 @@ public class CellIdentityLteTest extends AndroidTestCase { final String mncWithThreeDigit = "061"; CellIdentityLte ci = new CellIdentityLte(CI, PCI, TAC, EARFCN, BANDWIDTH, MCC_STR, mncWithThreeDigit, ALPHA_LONG, ALPHA_SHORT); ALPHA_LONG, ALPHA_SHORT, Collections.emptyList(), null); assertEquals(MCC, ci.getMcc()); assertEquals(61, ci.getMnc()); Loading @@ -82,7 +84,7 @@ public class CellIdentityLteTest extends AndroidTestCase { final String mncWithTwoDigit = "61"; CellIdentityLte ci = new CellIdentityLte(CI, PCI, TAC, EARFCN, BANDWIDTH, MCC_STR, mncWithTwoDigit, ALPHA_LONG, ALPHA_SHORT); ALPHA_LONG, ALPHA_SHORT, Collections.emptyList(), null); assertEquals(MCC, ci.getMcc()); assertEquals(61, ci.getMnc()); Loading @@ -94,7 +96,8 @@ public class CellIdentityLteTest extends AndroidTestCase { @SmallTest public void testConstructorWithEmptyMccMnc() { CellIdentityLte ci = new CellIdentityLte( CI, PCI, TAC, EARFCN, BANDWIDTH, null, null, ALPHA_LONG, ALPHA_SHORT); CI, PCI, TAC, EARFCN, BANDWIDTH, null, null, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList(), null); assertEquals(Integer.MAX_VALUE, ci.getMcc()); assertEquals(Integer.MAX_VALUE, ci.getMnc()); Loading @@ -103,7 +106,8 @@ public class CellIdentityLteTest extends AndroidTestCase { assertNull(ci.getMobileNetworkOperator()); ci = new CellIdentityLte( CI, PCI, TAC, EARFCN, BANDWIDTH, MCC_STR, null, ALPHA_LONG, ALPHA_SHORT); CI, PCI, TAC, EARFCN, BANDWIDTH, MCC_STR, null, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList(), null); assertEquals(MCC, ci.getMcc()); assertEquals(Integer.MAX_VALUE, ci.getMnc()); Loading @@ -112,7 +116,8 @@ public class CellIdentityLteTest extends AndroidTestCase { assertNull(ci.getMobileNetworkOperator()); ci = new CellIdentityLte( CI, PCI, TAC, EARFCN, BANDWIDTH, null, MNC_STR, ALPHA_LONG, ALPHA_SHORT); CI, PCI, TAC, EARFCN, BANDWIDTH, null, MNC_STR, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList(), null); assertEquals(MNC, ci.getMnc()); assertEquals(Integer.MAX_VALUE, ci.getMcc()); Loading @@ -121,7 +126,8 @@ public class CellIdentityLteTest extends AndroidTestCase { assertNull(ci.getMobileNetworkOperator()); ci = new CellIdentityLte( CI, PCI, TAC, EARFCN, BANDWIDTH, "", "", ALPHA_LONG, ALPHA_SHORT); CI, PCI, TAC, EARFCN, BANDWIDTH, "", "", ALPHA_LONG, ALPHA_SHORT, Collections.emptyList(), null); assertEquals(Integer.MAX_VALUE, ci.getMcc()); assertEquals(Integer.MAX_VALUE, ci.getMnc()); Loading Loading @@ -152,23 +158,29 @@ public class CellIdentityLteTest extends AndroidTestCase { @SmallTest public void testEquals() { CellIdentityLte ciA = new CellIdentityLte( CI, PCI, TAC, EARFCN, BANDWIDTH, MCC_STR, MNC_STR, ALPHA_LONG, ALPHA_SHORT); CI, PCI, TAC, EARFCN, BANDWIDTH, MCC_STR, MNC_STR, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList(), null); CellIdentityLte ciB = new CellIdentityLte( CI, PCI, TAC, EARFCN, BANDWIDTH, MCC_STR, MNC_STR, ALPHA_LONG, ALPHA_SHORT); CI, PCI, TAC, EARFCN, BANDWIDTH, MCC_STR, MNC_STR, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList(), null); assertTrue(ciA.equals(ciB)); ciA = new CellIdentityLte( CI, PCI, TAC, EARFCN, BANDWIDTH, null, null, ALPHA_LONG, ALPHA_SHORT); CI, PCI, TAC, EARFCN, BANDWIDTH, null, null, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList(), null); ciB = new CellIdentityLte( CI, PCI, TAC, EARFCN, BANDWIDTH, null, null, ALPHA_LONG, ALPHA_SHORT); CI, PCI, TAC, EARFCN, BANDWIDTH, null, null, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList(), null); assertTrue(ciA.equals(ciB)); ciA = new CellIdentityLte( CI, PCI, TAC, EARFCN, BANDWIDTH, MCC_STR, null, ALPHA_LONG, ALPHA_SHORT); CI, PCI, TAC, EARFCN, BANDWIDTH, MCC_STR, null, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList(), null); ciB = new CellIdentityLte( CI, PCI, TAC, EARFCN, BANDWIDTH, null, null, ALPHA_LONG, ALPHA_SHORT); CI, PCI, TAC, EARFCN, BANDWIDTH, null, null, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList(), null); assertFalse(ciA.equals(ciB)); } Loading @@ -177,7 +189,7 @@ public class CellIdentityLteTest extends AndroidTestCase { public void testParcel() { CellIdentityLte ci = new CellIdentityLte(CI, PCI, TAC, EARFCN, BANDWIDTH, MCC_STR, MNC_STR, ALPHA_LONG, ALPHA_SHORT); ALPHA_LONG, ALPHA_SHORT, Collections.emptyList(), null); Parcel p = Parcel.obtain(); ci.writeToParcel(p, 0); Loading @@ -190,7 +202,8 @@ public class CellIdentityLteTest extends AndroidTestCase { @SmallTest public void testParcelWithUnknownMccMnc() { CellIdentityLte ci = new CellIdentityLte( CI, PCI, TAC, EARFCN, BANDWIDTH, null, null, ALPHA_LONG, ALPHA_SHORT); CI, PCI, TAC, EARFCN, BANDWIDTH, null, null, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList(), null); Parcel p = Parcel.obtain(); p.writeInt(CellInfo.TYPE_LTE); Loading @@ -214,7 +227,8 @@ public class CellIdentityLteTest extends AndroidTestCase { final String invalidMcc = "randomStuff"; final String invalidMnc = "randomStuff"; CellIdentityLte ci = new CellIdentityLte( CI, PCI, TAC, EARFCN, BANDWIDTH, null, null, ALPHA_LONG, ALPHA_SHORT); CI, PCI, TAC, EARFCN, BANDWIDTH, null, null, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList(), null); Parcel p = Parcel.obtain(); p.writeInt(CellInfo.TYPE_LTE); Loading
tests/telephonytests/src/com/android/internal/telephony/CellIdentityNrTest.java +14 −6 Original line number Diff line number Diff line Loading @@ -25,6 +25,8 @@ import android.test.AndroidTestCase; import org.junit.Test; import java.util.Collections; public class CellIdentityNrTest extends AndroidTestCase { private static final String MCC = "310"; private static final String MNC = "260"; Loading @@ -41,7 +43,8 @@ public class CellIdentityNrTest extends AndroidTestCase { public void testGetMethod() { // GIVEN an instance of CellIdentityNr CellIdentityNr cellIdentityNr = new CellIdentityNr(PCI, TAC, NRARFCN, MCC, MNC, NCI, ALPHAL, ALPHAS); new CellIdentityNr(PCI, TAC, NRARFCN, MCC, MNC, NCI, ALPHAL, ALPHAS, Collections.emptyList()); // THEN the get method should return correct value assertThat(cellIdentityNr.getType()).isEqualTo(CellInfo.TYPE_NR); Loading @@ -60,9 +63,11 @@ public class CellIdentityNrTest extends AndroidTestCase { public void testEquals_sameParameters() { // GIVEN an instance of CellIdentityNr, and create another object with the same parameters CellIdentityNr cellIdentityNr = new CellIdentityNr(PCI, TAC, NRARFCN, MCC, MNC, NCI, ALPHAL, ALPHAS); new CellIdentityNr(PCI, TAC, NRARFCN, MCC, MNC, NCI, ALPHAL, ALPHAS, Collections.emptyList()); CellIdentityNr anotherCellIdentityNr = new CellIdentityNr(PCI, TAC, NRARFCN, MCC, MNC, NCI, ALPHAL, ALPHAS); new CellIdentityNr(PCI, TAC, NRARFCN, MCC, MNC, NCI, ALPHAL, ALPHAS, Collections.emptyList()); // THEN this two objects are equivalent assertThat(cellIdentityNr).isEqualTo(anotherCellIdentityNr); Loading @@ -72,9 +77,11 @@ public class CellIdentityNrTest extends AndroidTestCase { public void testEquals_differentParameters() { // GIVEN an instance of CellIdentityNr, and create another object with different parameters CellIdentityNr cellIdentityNr = new CellIdentityNr(PCI, TAC, NRARFCN, MCC, MNC, NCI, ALPHAL, ALPHAS); new CellIdentityNr(PCI, TAC, NRARFCN, MCC, MNC, NCI, ALPHAL, ALPHAS, Collections.emptyList()); CellIdentityNr anotherCellIdentityNr = new CellIdentityNr(PCI, TAC, NRARFCN, MCC, MNC, NCI + 1, ALPHAL, ALPHAS); new CellIdentityNr(PCI, TAC, NRARFCN, MCC, MNC, NCI + 1, ALPHAL, ALPHAS, Collections.emptyList()); // THEN this two objects are different assertThat(cellIdentityNr).isNotEqualTo(anotherCellIdentityNr); Loading @@ -84,7 +91,8 @@ public class CellIdentityNrTest extends AndroidTestCase { public void testParcel() { // GIVEN an instance of CellIdentityNr CellIdentityNr cellIdentityNr = new CellIdentityNr(PCI, TAC, NRARFCN, MCC, MNC, NCI, ALPHAL, ALPHAS); new CellIdentityNr(PCI, TAC, NRARFCN, MCC, MNC, NCI, ALPHAL, ALPHAS, Collections.emptyList()); // WHEN write the object to parcel and create another object with that parcel Parcel parcel = Parcel.obtain(); Loading
tests/telephonytests/src/com/android/internal/telephony/CellIdentityTdscdmaTest.java +17 −8 Original line number Diff line number Diff line Loading @@ -24,6 +24,8 @@ import android.test.suitebuilder.annotation.SmallTest; /** Unit tests for {@link CellIdentityTdscdma}. */ import java.util.Collections; public class CellIdentityTdscdmaTest extends AndroidTestCase { // Cell identity ranges from 0 to 268435456. Loading Loading @@ -67,7 +69,8 @@ public class CellIdentityTdscdmaTest extends AndroidTestCase { public void testConstructor() { CellIdentityTdscdma ci = new CellIdentityTdscdma( MCC_STR, MNC_STR, LAC, CID, CPID, UARFCN, ALPHA_LONG, ALPHA_SHORT); MCC_STR, MNC_STR, LAC, CID, CPID, UARFCN, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList(), null); assertEquals(MCC_STR, ci.getMccString()); assertEquals(MNC_STR, ci.getMncString()); Loading @@ -83,22 +86,25 @@ public class CellIdentityTdscdmaTest extends AndroidTestCase { @SmallTest public void testConstructorWithEmptyMccMnc() { CellIdentityTdscdma ci = new CellIdentityTdscdma( null, null, LAC, CID, CPID, UARFCN, "", ""); null, null, LAC, CID, CPID, UARFCN, "", "", Collections.emptyList(), null); assertNull(ci.getMccString()); assertNull(ci.getMncString()); ci = new CellIdentityTdscdma(MCC_STR, null, LAC, CID, CPID, UARFCN, "", ""); ci = new CellIdentityTdscdma(MCC_STR, null, LAC, CID, CPID, UARFCN, "", "", Collections.emptyList(), null); assertEquals(MCC_STR, ci.getMccString()); assertNull(ci.getMncString()); ci = new CellIdentityTdscdma(null, MNC_STR, LAC, CID, CPID, UARFCN, "", ""); ci = new CellIdentityTdscdma(null, MNC_STR, LAC, CID, CPID, UARFCN, "", "", Collections.emptyList(), null); assertEquals(MNC_STR, ci.getMncString()); assertNull(ci.getMccString()); ci = new CellIdentityTdscdma("", "", LAC, CID, CPID, UARFCN, "", ""); ci = new CellIdentityTdscdma("", "", LAC, CID, CPID, UARFCN, "", "", Collections.emptyList(), null); assertNull(ci.getMccString()); assertNull(ci.getMncString()); Loading @@ -107,7 +113,8 @@ public class CellIdentityTdscdmaTest extends AndroidTestCase { @SmallTest public void testParcel() { CellIdentityTdscdma ci = new CellIdentityTdscdma( MCC_STR, MNC_STR, LAC, CID, UARFCN, CPID, ALPHA_LONG, ALPHA_SHORT); MCC_STR, MNC_STR, LAC, CID, UARFCN, CPID, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList(), null); Parcel p = Parcel.obtain(); ci.writeToParcel(p, 0); Loading @@ -121,7 +128,8 @@ public class CellIdentityTdscdmaTest extends AndroidTestCase { public void testParcelWithUnknowMccMnc() { CellIdentityTdscdma ci = new CellIdentityTdscdma( null, null, LAC, CID, CPID, UARFCN, ALPHA_LONG, ALPHA_SHORT); null, null, LAC, CID, CPID, UARFCN, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList(), null); Parcel p = Parcel.obtain(); p.writeInt(CellInfo.TYPE_TDSCDMA); Loading @@ -145,7 +153,8 @@ public class CellIdentityTdscdmaTest extends AndroidTestCase { final String invalidMnc = "randomStuff"; CellIdentityTdscdma ci = new CellIdentityTdscdma( null, null, LAC, CID, CPID, UARFCN, ALPHA_LONG, ALPHA_SHORT); null, null, LAC, CID, CPID, UARFCN, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList(), null); Parcel p = Parcel.obtain(); p.writeInt(CellInfo.TYPE_TDSCDMA); Loading
tests/telephonytests/src/com/android/internal/telephony/CellIdentityTest.java +17 −10 Original line number Diff line number Diff line Loading @@ -25,6 +25,8 @@ import android.telephony.CellInfo; import android.test.AndroidTestCase; import android.test.suitebuilder.annotation.SmallTest; import java.util.Collections; public class CellIdentityTest extends AndroidTestCase { // Cell identity ranges from 0 to 268435456. Loading Loading @@ -67,14 +69,16 @@ public class CellIdentityTest extends AndroidTestCase { @SmallTest public void testConstructCellIdentityGsm() { // Test values below zero (these must all be non-negative) CellIdentityGsm gsm = new CellIdentityGsm(-1, -1, -1, -1, null, null, null, null); CellIdentityGsm gsm = new CellIdentityGsm(-1, -1, -1, -1, null, null, null, null, Collections.emptyList()); assertEquals(CellInfo.UNAVAILABLE, gsm.getLac()); assertEquals(CellInfo.UNAVAILABLE, gsm.getCid()); assertEquals(CellInfo.UNAVAILABLE, gsm.getArfcn()); assertEquals(CellInfo.UNAVAILABLE, gsm.getBsic()); // Test max values of LAC, CID, ARFCN, and BSIC gsm = new CellIdentityGsm(MAX_LAC, MAX_CID, MAX_ARFCN, MAX_BSIC, null, null, null, null); gsm = new CellIdentityGsm(MAX_LAC, MAX_CID, MAX_ARFCN, MAX_BSIC, null, null, null, null, Collections.emptyList()); assertEquals(MAX_LAC, gsm.getLac()); assertEquals(MAX_CID, gsm.getCid()); assertEquals(MAX_ARFCN, gsm.getArfcn()); Loading @@ -82,7 +86,8 @@ public class CellIdentityTest extends AndroidTestCase { // Test max values + 1 of LAC, CID, ARFCN, and BSIC gsm = new CellIdentityGsm( MAX_LAC + 1, MAX_CID + 1, MAX_ARFCN + 1, MAX_BSIC + 1, null, null, null, null); MAX_LAC + 1, MAX_CID + 1, MAX_ARFCN + 1, MAX_BSIC + 1, null, null, null, null, Collections.emptyList()); assertEquals(CellInfo.UNAVAILABLE, gsm.getLac()); assertEquals(CellInfo.UNAVAILABLE, gsm.getCid()); assertEquals(CellInfo.UNAVAILABLE, gsm.getArfcn()); Loading @@ -93,23 +98,25 @@ public class CellIdentityTest extends AndroidTestCase { @SmallTest public void testEquals() { CellIdentity ciA = new CellIdentityLte( CI, PCI, TAC, EARFCN, BANDWIDTH, MCC_STR, MNC_STR, ALPHA_LONG, ALPHA_SHORT); CI, PCI, TAC, EARFCN, BANDWIDTH, MCC_STR, MNC_STR, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList(), null); CellIdentity ciB = new CellIdentityLte( CI, PCI, TAC, EARFCN, BANDWIDTH, MCC_STR, MNC_STR, ALPHA_LONG, ALPHA_SHORT); CI, PCI, TAC, EARFCN, BANDWIDTH, MCC_STR, MNC_STR, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList(), null); assertTrue(ciA.equals(ciB)); ciA = new CellIdentityLte(CI, PCI, TAC, EARFCN, BANDWIDTH, null, null, ALPHA_LONG, ALPHA_SHORT); ALPHA_SHORT, Collections.emptyList(), null); ciB = new CellIdentityLte(CI, PCI, TAC, EARFCN, BANDWIDTH, null, null, ALPHA_LONG, ALPHA_SHORT); ALPHA_SHORT, Collections.emptyList(), null); assertTrue(ciA.equals(ciB)); ciA = new CellIdentityLte(CI, PCI, TAC, EARFCN, BANDWIDTH, MCC_STR, null, ALPHA_LONG, ALPHA_SHORT); ALPHA_SHORT, Collections.emptyList(), null); ciB = new CellIdentityLte(CI, PCI, TAC, EARFCN, BANDWIDTH, null, null, ALPHA_LONG, ALPHA_SHORT); ALPHA_SHORT, Collections.emptyList(), null); assertFalse(ciA.equals(ciB)); } Loading @@ -117,7 +124,7 @@ public class CellIdentityTest extends AndroidTestCase { @SmallTest public void testParcel() { CellIdentity ci = new CellIdentityLte(CI, PCI, TAC, EARFCN, BANDWIDTH, MCC_STR, MNC_STR, ALPHA_LONG, ALPHA_SHORT); ALPHA_LONG, ALPHA_SHORT, Collections.emptyList(), null); Parcel p = Parcel.obtain(); ci.writeToParcel(p, 0); Loading