Search in sources :

Example 1 with CellIdentityNr

use of android.telephony.CellIdentityNr in project android_frameworks_opt_telephony by LineageOS.

the class CellIdentityNrTest method testEquals_differentParameters.

@Test
public void testEquals_differentParameters() {
    // GIVEN an instance of CellIdentityNr, and create another object with different parameters
    CellIdentityNr cellIdentityNr = new CellIdentityNr(PCI, TAC, NRARFCN, BANDS, MCC_STR, MNC_STR, NCI, ALPHAL, ALPHAS, Collections.emptyList());
    CellIdentityNr anotherCellIdentityNr = new CellIdentityNr(PCI, TAC, NRARFCN, BANDS, MCC_STR, MNC_STR, NCI + 1, ALPHAL, ALPHAS, Collections.emptyList());
    // THEN this two objects are different
    assertThat(cellIdentityNr).isNotEqualTo(anotherCellIdentityNr);
}
Also used : CellIdentityNr(android.telephony.CellIdentityNr) Test(org.junit.Test)

Example 2 with CellIdentityNr

use of android.telephony.CellIdentityNr in project android_frameworks_opt_telephony by LineageOS.

the class CellIdentityNrTest method testEquals_sameParameters.

@Test
public void testEquals_sameParameters() {
    // GIVEN an instance of CellIdentityNr, and create another object with the same parameters
    CellIdentityNr cellIdentityNr = new CellIdentityNr(PCI, TAC, NRARFCN, BANDS, MCC_STR, MNC_STR, NCI, ALPHAL, ALPHAS, Collections.emptyList());
    CellIdentityNr anotherCellIdentityNr = new CellIdentityNr(PCI, TAC, NRARFCN, BANDS, MCC_STR, MNC_STR, NCI, ALPHAL, ALPHAS, Collections.emptyList());
    // THEN this two objects are equivalent
    assertThat(cellIdentityNr).isEqualTo(anotherCellIdentityNr);
}
Also used : CellIdentityNr(android.telephony.CellIdentityNr) Test(org.junit.Test)

Example 3 with CellIdentityNr

use of android.telephony.CellIdentityNr in project android_frameworks_opt_telephony by LineageOS.

the class CellIdentityNrTest method testParcel.

@Test
public void testParcel() {
    // GIVEN an instance of CellIdentityNr
    CellIdentityNr cellIdentityNr = new CellIdentityNr(PCI, TAC, NRARFCN, BANDS, MCC_STR, MNC_STR, NCI, ALPHAL, ALPHAS, Collections.emptyList());
    // WHEN write the object to parcel and create another object with that parcel
    Parcel parcel = Parcel.obtain();
    cellIdentityNr.writeToParcel(parcel, 0);
    parcel.setDataPosition(0);
    CellIdentityNr anotherCellIdentityNr = CellIdentityNr.CREATOR.createFromParcel(parcel);
    // THEN the new object is equal to the old one
    assertThat(anotherCellIdentityNr).isEqualTo(cellIdentityNr);
    assertThat(anotherCellIdentityNr.getType()).isEqualTo(CellInfo.TYPE_NR);
    assertThat(anotherCellIdentityNr.getNrarfcn()).isEqualTo(NRARFCN);
    assertThat(anotherCellIdentityNr.getPci()).isEqualTo(PCI);
    assertThat(anotherCellIdentityNr.getTac()).isEqualTo(TAC);
    assertTrue(Arrays.equals(anotherCellIdentityNr.getBands(), BANDS));
    assertThat(anotherCellIdentityNr.getOperatorAlphaLong()).isEqualTo(ALPHAL);
    assertThat(anotherCellIdentityNr.getOperatorAlphaShort()).isEqualTo(ALPHAS);
    assertThat(anotherCellIdentityNr.getMccString()).isEqualTo(MCC_STR);
    assertThat(anotherCellIdentityNr.getMncString()).isEqualTo(MNC_STR);
    assertThat(anotherCellIdentityNr.getNci()).isEqualTo(NCI);
}
Also used : Parcel(android.os.Parcel) CellIdentityNr(android.telephony.CellIdentityNr) Test(org.junit.Test)

Example 4 with CellIdentityNr

use of android.telephony.CellIdentityNr in project android_frameworks_opt_telephony by LineageOS.

the class CellIdentityTest method testIsSameCell.

@SmallTest
public void testIsSameCell() {
    int curCi = 268435455;
    CellIdentity ciA = new CellIdentityLte(curCi, PCI, TAC, EARFCN, BANDS, BANDWIDTH, MCC_STR, MNC_STR, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList(), null);
    CellIdentity ciB = new CellIdentityLte(curCi, PCI, TAC, EARFCN, BANDS, BANDWIDTH, MCC_STR, MNC_STR, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList(), null);
    CellIdentity ciC = new CellIdentityLte(curCi, PCI, TAC, EARFCN, BANDS, BANDWIDTH, null, MNC_STR, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList(), null);
    CellIdentity ciD = new CellIdentityLte(-1, PCI, TAC, EARFCN, BANDS, BANDWIDTH, MCC_STR, MNC_STR, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList(), null);
    assertTrue(ciA.isSameCell(ciB));
    assertFalse(ciA.isSameCell(null));
    assertFalse(ciA.isSameCell(ciC));
    assertFalse(ciA.isSameCell(ciD));
    CellIdentityNr cellIdentityNr = new CellIdentityNr(PCI, TAC, EARFCN, BANDS, MCC_STR, MNC_STR, curCi, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList());
    assertFalse(ciA.isSameCell(cellIdentityNr));
}
Also used : CellIdentityLte(android.telephony.CellIdentityLte) CellIdentity(android.telephony.CellIdentity) CellIdentityNr(android.telephony.CellIdentityNr) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 5 with CellIdentityNr

use of android.telephony.CellIdentityNr in project android_frameworks_opt_telephony by LineageOS.

the class CellIdentityTest method testGetMccMncString.

@SmallTest
public void testGetMccMncString() {
    List<CellIdentity> identities = new ArrayList<>(5);
    CellIdentityGsm gsm = new CellIdentityGsm(MAX_LAC, MAX_CID, MAX_ARFCN, MAX_BSIC, MCC_STR, MNC_STR, null, null, Collections.emptyList());
    identities.add(gsm);
    CellIdentityCdma cdma = new CellIdentityCdma(NETWORK_ID, SYSTEM_ID, BASESTATION_ID, LONGITUDE, LATITUDE, ALPHA_LONG, ALPHA_SHORT);
    identities.add(cdma);
    CellIdentity lte = new CellIdentityLte(CI, PCI, TAC, EARFCN, BANDS, BANDWIDTH, MCC_STR, MNC_STR, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList(), null);
    identities.add(lte);
    CellIdentityWcdma wcdma = new CellIdentityWcdma(MAX_LAC, MAX_CID, PSC, UARFCN, MCC_STR, MNC_STR, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList(), null);
    identities.add(wcdma);
    CellIdentityTdscdma tdscdma = new CellIdentityTdscdma(MCC_STR, MNC_STR, MAX_LAC, MAX_CID, CPID, UARFCN, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList(), null);
    identities.add(tdscdma);
    CellIdentityNr nr = new CellIdentityNr(PCI, TAC, EARFCN, BANDS, MCC_STR, MNC_STR, CI, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList());
    identities.add(nr);
    for (CellIdentity identity : identities) {
        final String mccStr = identity.getMccString();
        final String mncStr = identity.getMncString();
        if (identity instanceof CellIdentityCdma) {
            assertNull(mccStr);
            assertNull(mncStr);
        } else {
            assertEquals(MCC_STR, mccStr);
            assertEquals(MNC_STR, mncStr);
        }
    }
}
Also used : CellIdentityCdma(android.telephony.CellIdentityCdma) CellIdentityLte(android.telephony.CellIdentityLte) CellIdentity(android.telephony.CellIdentity) ArrayList(java.util.ArrayList) CellIdentityGsm(android.telephony.CellIdentityGsm) CellIdentityWcdma(android.telephony.CellIdentityWcdma) CellIdentityTdscdma(android.telephony.CellIdentityTdscdma) CellIdentityNr(android.telephony.CellIdentityNr) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Aggregations

CellIdentityNr (android.telephony.CellIdentityNr)8 Test (org.junit.Test)6 CellIdentity (android.telephony.CellIdentity)3 CellIdentityLte (android.telephony.CellIdentityLte)3 SmallTest (android.test.suitebuilder.annotation.SmallTest)3 CellIdentityGsm (android.telephony.CellIdentityGsm)2 CellIdentityTdscdma (android.telephony.CellIdentityTdscdma)2 CellIdentityWcdma (android.telephony.CellIdentityWcdma)2 FlakyTest (androidx.test.filters.FlakyTest)2 ArrayList (java.util.ArrayList)2 Parcel (android.os.Parcel)1 CellIdentityCdma (android.telephony.CellIdentityCdma)1 CellInfo (android.telephony.CellInfo)1 CellInfoNr (android.telephony.CellInfoNr)1 CellSignalStrengthNr (android.telephony.CellSignalStrengthNr)1 MediumTest (android.test.suitebuilder.annotation.MediumTest)1 Method (java.lang.reflect.Method)1