Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3b5dca82 authored by Sarah Chin's avatar Sarah Chin Committed by Gerrit Code Review
Browse files

Merge changes from topics "multi-plmn", "nr_band"

* changes:
  Update CellIdentityNr constructor in tests
  Update Unit tests for Multi-PLMN and CSG
parents a12aa4d8 70c4f22b
Loading
Loading
Loading
Loading
+30 −17
Original line number Original line Diff line number Diff line
@@ -21,8 +21,9 @@ import android.telephony.CellIdentityGsm;
import android.test.AndroidTestCase;
import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.SmallTest;
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 {
public class CellIdentityGsmTest extends AndroidTestCase {


    // Location Area Code ranges from 0 to 65535.
    // Location Area Code ranges from 0 to 65535.
@@ -45,7 +46,7 @@ public class CellIdentityGsmTest extends AndroidTestCase {
    public void testDefaultConstructor() {
    public void testDefaultConstructor() {
        CellIdentityGsm ci =
        CellIdentityGsm ci =
                new CellIdentityGsm(LAC, CID, ARFCN, BSIC, MCC_STR, MNC_STR,
                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(LAC, ci.getLac());
        assertEquals(CID, ci.getCid());
        assertEquals(CID, ci.getCid());
@@ -66,7 +67,7 @@ public class CellIdentityGsmTest extends AndroidTestCase {
        final String mncWithThreeDigit = "061";
        final String mncWithThreeDigit = "061";
        CellIdentityGsm ci =
        CellIdentityGsm ci =
                new CellIdentityGsm(LAC, CID, ARFCN, BSIC, MCC_STR, mncWithThreeDigit,
                new CellIdentityGsm(LAC, CID, ARFCN, BSIC, MCC_STR, mncWithThreeDigit,
                        ALPHA_LONG, ALPHA_SHORT);
                        ALPHA_LONG, ALPHA_SHORT, Collections.emptyList());


        assertEquals(MCC, ci.getMcc());
        assertEquals(MCC, ci.getMcc());
        assertEquals(61, ci.getMnc());
        assertEquals(61, ci.getMnc());
@@ -80,7 +81,7 @@ public class CellIdentityGsmTest extends AndroidTestCase {
        final String mncWithTwoDigit = "61";
        final String mncWithTwoDigit = "61";
        CellIdentityGsm ci =
        CellIdentityGsm ci =
                new CellIdentityGsm(LAC, CID, ARFCN, BSIC, MCC_STR, mncWithTwoDigit,
                new CellIdentityGsm(LAC, CID, ARFCN, BSIC, MCC_STR, mncWithTwoDigit,
                        ALPHA_LONG, ALPHA_SHORT);
                        ALPHA_LONG, ALPHA_SHORT, Collections.emptyList());


        assertEquals(MCC, ci.getMcc());
        assertEquals(MCC, ci.getMcc());
        assertEquals(61, ci.getMnc());
        assertEquals(61, ci.getMnc());
@@ -92,7 +93,8 @@ public class CellIdentityGsmTest extends AndroidTestCase {
    @SmallTest
    @SmallTest
    public void testConstructorWithEmptyMccMnc() {
    public void testConstructorWithEmptyMccMnc() {
        CellIdentityGsm ci =
        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.getMcc());
        assertEquals(Integer.MAX_VALUE, ci.getMnc());
        assertEquals(Integer.MAX_VALUE, ci.getMnc());
@@ -100,7 +102,8 @@ public class CellIdentityGsmTest extends AndroidTestCase {
        assertNull(ci.getMncString());
        assertNull(ci.getMncString());
        assertNull(ci.getMobileNetworkOperator());
        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(MCC, ci.getMcc());
        assertEquals(Integer.MAX_VALUE, ci.getMnc());
        assertEquals(Integer.MAX_VALUE, ci.getMnc());
@@ -108,7 +111,8 @@ public class CellIdentityGsmTest extends AndroidTestCase {
        assertNull(ci.getMncString());
        assertNull(ci.getMncString());
        assertNull(ci.getMobileNetworkOperator());
        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(MNC, ci.getMnc());
        assertEquals(Integer.MAX_VALUE, ci.getMcc());
        assertEquals(Integer.MAX_VALUE, ci.getMcc());
@@ -116,7 +120,8 @@ public class CellIdentityGsmTest extends AndroidTestCase {
        assertNull(ci.getMccString());
        assertNull(ci.getMccString());
        assertNull(ci.getMobileNetworkOperator());
        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.getMcc());
        assertEquals(Integer.MAX_VALUE, ci.getMnc());
        assertEquals(Integer.MAX_VALUE, ci.getMnc());
@@ -128,20 +133,26 @@ public class CellIdentityGsmTest extends AndroidTestCase {
    @SmallTest
    @SmallTest
    public void testEquals() {
    public void testEquals() {
        CellIdentityGsm ciA = new CellIdentityGsm(
        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(
        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));
        assertTrue(ciA.equals(ciB));


        ciA = 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,
        ciB = 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));
        assertTrue(ciA.equals(ciB));


        ciA = new 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,
        ciB = 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());


        assertFalse(ciA.equals(ciB));
        assertFalse(ciA.equals(ciB));
    }
    }
@@ -150,7 +161,7 @@ public class CellIdentityGsmTest extends AndroidTestCase {
    public void testParcel() {
    public void testParcel() {
        CellIdentityGsm ci =
        CellIdentityGsm ci =
                new CellIdentityGsm(LAC, CID, ARFCN, BSIC, MCC_STR, MNC_STR,
                new CellIdentityGsm(LAC, CID, ARFCN, BSIC, MCC_STR, MNC_STR,
                        ALPHA_LONG, ALPHA_SHORT);
                        ALPHA_LONG, ALPHA_SHORT, Collections.emptyList());


        Parcel p = Parcel.obtain();
        Parcel p = Parcel.obtain();
        ci.writeToParcel(p, 0);
        ci.writeToParcel(p, 0);
@@ -163,7 +174,8 @@ public class CellIdentityGsmTest extends AndroidTestCase {
    @SmallTest
    @SmallTest
    public void testParcelWithUnknowMccMnc() {
    public void testParcelWithUnknowMccMnc() {
        CellIdentityGsm ci =
        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();
        Parcel p = Parcel.obtain();
        ci.writeToParcel(p, 0);
        ci.writeToParcel(p, 0);
@@ -178,7 +190,8 @@ public class CellIdentityGsmTest extends AndroidTestCase {
        final String invalidMcc = "randomStuff";
        final String invalidMcc = "randomStuff";
        final String invalidMnc = "randomStuff";
        final String invalidMnc = "randomStuff";
        CellIdentityGsm ci =
        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();
        Parcel p = Parcel.obtain();
        ci.writeToParcel(p, 0);
        ci.writeToParcel(p, 0);
+30 −16
Original line number Original line Diff line number Diff line
@@ -22,6 +22,8 @@ import android.telephony.CellInfo;
import android.test.AndroidTestCase;
import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.SmallTest;
import android.test.suitebuilder.annotation.SmallTest;


import java.util.Collections;

/** Unit tests for {@link CellIdentityLte}. */
/** Unit tests for {@link CellIdentityLte}. */


public class CellIdentityLteTest extends AndroidTestCase {
public class CellIdentityLteTest extends AndroidTestCase {
@@ -46,7 +48,7 @@ public class CellIdentityLteTest extends AndroidTestCase {
    public void testDefaultConstructor() {
    public void testDefaultConstructor() {
        CellIdentityLte ci =
        CellIdentityLte ci =
                new CellIdentityLte(CI, PCI, TAC, EARFCN, BANDWIDTH, MCC_STR, MNC_STR,
                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(CI, ci.getCi());
        assertEquals(PCI, ci.getPci());
        assertEquals(PCI, ci.getPci());
@@ -68,7 +70,7 @@ public class CellIdentityLteTest extends AndroidTestCase {
        final String mncWithThreeDigit = "061";
        final String mncWithThreeDigit = "061";
        CellIdentityLte ci =
        CellIdentityLte ci =
                new CellIdentityLte(CI, PCI, TAC, EARFCN, BANDWIDTH, MCC_STR, mncWithThreeDigit,
                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(MCC, ci.getMcc());
        assertEquals(61, ci.getMnc());
        assertEquals(61, ci.getMnc());
@@ -82,7 +84,7 @@ public class CellIdentityLteTest extends AndroidTestCase {
        final String mncWithTwoDigit = "61";
        final String mncWithTwoDigit = "61";
        CellIdentityLte ci =
        CellIdentityLte ci =
                new CellIdentityLte(CI, PCI, TAC, EARFCN, BANDWIDTH, MCC_STR, mncWithTwoDigit,
                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(MCC, ci.getMcc());
        assertEquals(61, ci.getMnc());
        assertEquals(61, ci.getMnc());
@@ -94,7 +96,8 @@ public class CellIdentityLteTest extends AndroidTestCase {
    @SmallTest
    @SmallTest
    public void testConstructorWithEmptyMccMnc() {
    public void testConstructorWithEmptyMccMnc() {
        CellIdentityLte ci = new CellIdentityLte(
        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.getMcc());
        assertEquals(Integer.MAX_VALUE, ci.getMnc());
        assertEquals(Integer.MAX_VALUE, ci.getMnc());
@@ -103,7 +106,8 @@ public class CellIdentityLteTest extends AndroidTestCase {
        assertNull(ci.getMobileNetworkOperator());
        assertNull(ci.getMobileNetworkOperator());


        ci = new CellIdentityLte(
        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(MCC, ci.getMcc());
        assertEquals(Integer.MAX_VALUE, ci.getMnc());
        assertEquals(Integer.MAX_VALUE, ci.getMnc());
@@ -112,7 +116,8 @@ public class CellIdentityLteTest extends AndroidTestCase {
        assertNull(ci.getMobileNetworkOperator());
        assertNull(ci.getMobileNetworkOperator());


        ci = new CellIdentityLte(
        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(MNC, ci.getMnc());
        assertEquals(Integer.MAX_VALUE, ci.getMcc());
        assertEquals(Integer.MAX_VALUE, ci.getMcc());
@@ -121,7 +126,8 @@ public class CellIdentityLteTest extends AndroidTestCase {
        assertNull(ci.getMobileNetworkOperator());
        assertNull(ci.getMobileNetworkOperator());


        ci = new CellIdentityLte(
        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.getMcc());
        assertEquals(Integer.MAX_VALUE, ci.getMnc());
        assertEquals(Integer.MAX_VALUE, ci.getMnc());
@@ -152,23 +158,29 @@ public class CellIdentityLteTest extends AndroidTestCase {
    @SmallTest
    @SmallTest
    public void testEquals() {
    public void testEquals() {
        CellIdentityLte ciA = new CellIdentityLte(
        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(
        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));
        assertTrue(ciA.equals(ciB));


        ciA = new CellIdentityLte(
        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(
        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));
        assertTrue(ciA.equals(ciB));


        ciA = new CellIdentityLte(
        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(
        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));
        assertFalse(ciA.equals(ciB));
    }
    }
@@ -177,7 +189,7 @@ public class CellIdentityLteTest extends AndroidTestCase {
    public void testParcel() {
    public void testParcel() {
        CellIdentityLte ci =
        CellIdentityLte ci =
                new CellIdentityLte(CI, PCI, TAC, EARFCN, BANDWIDTH, MCC_STR, MNC_STR,
                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();
        Parcel p = Parcel.obtain();
        ci.writeToParcel(p, 0);
        ci.writeToParcel(p, 0);
@@ -190,7 +202,8 @@ public class CellIdentityLteTest extends AndroidTestCase {
    @SmallTest
    @SmallTest
    public void testParcelWithUnknownMccMnc() {
    public void testParcelWithUnknownMccMnc() {
        CellIdentityLte ci = new CellIdentityLte(
        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();
        Parcel p = Parcel.obtain();
        p.writeInt(CellInfo.TYPE_LTE);
        p.writeInt(CellInfo.TYPE_LTE);
@@ -214,7 +227,8 @@ public class CellIdentityLteTest extends AndroidTestCase {
        final String invalidMcc = "randomStuff";
        final String invalidMcc = "randomStuff";
        final String invalidMnc = "randomStuff";
        final String invalidMnc = "randomStuff";
        CellIdentityLte ci = new CellIdentityLte(
        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();
        Parcel p = Parcel.obtain();
        p.writeInt(CellInfo.TYPE_LTE);
        p.writeInt(CellInfo.TYPE_LTE);
+17 −6
Original line number Original line Diff line number Diff line
@@ -19,12 +19,15 @@ package com.android.internal.telephony;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertThat;


import android.os.Parcel;
import android.os.Parcel;
import android.telephony.AccessNetworkConstants;
import android.telephony.CellIdentityNr;
import android.telephony.CellIdentityNr;
import android.telephony.CellInfo;
import android.telephony.CellInfo;
import android.test.AndroidTestCase;
import android.test.AndroidTestCase;


import org.junit.Test;
import org.junit.Test;


import java.util.Collections;

public class CellIdentityNrTest extends AndroidTestCase {
public class CellIdentityNrTest extends AndroidTestCase {
    private static final String MCC = "310";
    private static final String MCC = "310";
    private static final String MNC = "260";
    private static final String MNC = "260";
@@ -36,12 +39,14 @@ public class CellIdentityNrTest extends AndroidTestCase {
    private static final int PCI = 123;
    private static final int PCI = 123;
    private static final int TAC = 32767;
    private static final int TAC = 32767;
    private static final int NCI = 8675309;
    private static final int NCI = 8675309;
    private static final int BAND = AccessNetworkConstants.NgranBands.BAND_1;


    @Test
    @Test
    public void testGetMethod() {
    public void testGetMethod() {
        // GIVEN an instance of CellIdentityNr
        // GIVEN an instance of CellIdentityNr
        CellIdentityNr cellIdentityNr =
        CellIdentityNr cellIdentityNr =
                new CellIdentityNr(PCI, TAC, NRARFCN, MCC, MNC, NCI, ALPHAL, ALPHAS);
                new CellIdentityNr(PCI, TAC, NRARFCN, BAND, MCC, MNC, NCI, ALPHAL, ALPHAS,
                        Collections.emptyList());


        // THEN the get method should return correct value
        // THEN the get method should return correct value
        assertThat(cellIdentityNr.getType()).isEqualTo(CellInfo.TYPE_NR);
        assertThat(cellIdentityNr.getType()).isEqualTo(CellInfo.TYPE_NR);
@@ -60,9 +65,11 @@ public class CellIdentityNrTest extends AndroidTestCase {
    public void testEquals_sameParameters() {
    public void testEquals_sameParameters() {
        // GIVEN an instance of CellIdentityNr, and create another object with the same parameters
        // GIVEN an instance of CellIdentityNr, and create another object with the same parameters
        CellIdentityNr cellIdentityNr =
        CellIdentityNr cellIdentityNr =
                new CellIdentityNr(PCI, TAC, NRARFCN, MCC, MNC, NCI, ALPHAL, ALPHAS);
                new CellIdentityNr(PCI, TAC, NRARFCN, BAND, MCC, MNC, NCI, ALPHAL, ALPHAS,
                        Collections.emptyList());
        CellIdentityNr anotherCellIdentityNr =
        CellIdentityNr anotherCellIdentityNr =
                new CellIdentityNr(PCI, TAC, NRARFCN, MCC, MNC, NCI, ALPHAL, ALPHAS);
                new CellIdentityNr(PCI, TAC, NRARFCN, BAND, MCC, MNC, NCI, ALPHAL, ALPHAS,
                        Collections.emptyList());


        // THEN this two objects are equivalent
        // THEN this two objects are equivalent
        assertThat(cellIdentityNr).isEqualTo(anotherCellIdentityNr);
        assertThat(cellIdentityNr).isEqualTo(anotherCellIdentityNr);
@@ -72,9 +79,11 @@ public class CellIdentityNrTest extends AndroidTestCase {
    public void testEquals_differentParameters() {
    public void testEquals_differentParameters() {
        // GIVEN an instance of CellIdentityNr, and create another object with different parameters
        // GIVEN an instance of CellIdentityNr, and create another object with different parameters
        CellIdentityNr cellIdentityNr =
        CellIdentityNr cellIdentityNr =
                new CellIdentityNr(PCI, TAC, NRARFCN, MCC, MNC, NCI, ALPHAL, ALPHAS);
                new CellIdentityNr(PCI, TAC, NRARFCN, BAND, MCC, MNC, NCI, ALPHAL, ALPHAS,
                        Collections.emptyList());
        CellIdentityNr anotherCellIdentityNr =
        CellIdentityNr anotherCellIdentityNr =
                new CellIdentityNr(PCI, TAC, NRARFCN, MCC, MNC, NCI + 1, ALPHAL, ALPHAS);
                new CellIdentityNr(PCI, TAC, NRARFCN, BAND, MCC, MNC, NCI + 1, ALPHAL, ALPHAS,
                        Collections.emptyList());


        // THEN this two objects are different
        // THEN this two objects are different
        assertThat(cellIdentityNr).isNotEqualTo(anotherCellIdentityNr);
        assertThat(cellIdentityNr).isNotEqualTo(anotherCellIdentityNr);
@@ -84,7 +93,8 @@ public class CellIdentityNrTest extends AndroidTestCase {
    public void testParcel() {
    public void testParcel() {
        // GIVEN an instance of CellIdentityNr
        // GIVEN an instance of CellIdentityNr
        CellIdentityNr cellIdentityNr =
        CellIdentityNr cellIdentityNr =
                new CellIdentityNr(PCI, TAC, NRARFCN, MCC, MNC, NCI, ALPHAL, ALPHAS);
                new CellIdentityNr(PCI, TAC, NRARFCN, BAND, MCC, MNC, NCI, ALPHAL, ALPHAS,
                        Collections.emptyList());


        // WHEN write the object to parcel and create another object with that parcel
        // WHEN write the object to parcel and create another object with that parcel
        Parcel parcel = Parcel.obtain();
        Parcel parcel = Parcel.obtain();
@@ -98,6 +108,7 @@ public class CellIdentityNrTest extends AndroidTestCase {
        assertThat(anotherCellIdentityNr.getNrarfcn()).isEqualTo(NRARFCN);
        assertThat(anotherCellIdentityNr.getNrarfcn()).isEqualTo(NRARFCN);
        assertThat(anotherCellIdentityNr.getPci()).isEqualTo(PCI);
        assertThat(anotherCellIdentityNr.getPci()).isEqualTo(PCI);
        assertThat(anotherCellIdentityNr.getTac()).isEqualTo(TAC);
        assertThat(anotherCellIdentityNr.getTac()).isEqualTo(TAC);
        assertThat(anotherCellIdentityNr.getBand()).isEqualTo(BAND);
        assertThat(anotherCellIdentityNr.getOperatorAlphaLong()).isEqualTo(ALPHAL);
        assertThat(anotherCellIdentityNr.getOperatorAlphaLong()).isEqualTo(ALPHAL);
        assertThat(anotherCellIdentityNr.getOperatorAlphaShort()).isEqualTo(ALPHAS);
        assertThat(anotherCellIdentityNr.getOperatorAlphaShort()).isEqualTo(ALPHAS);
        assertThat(anotherCellIdentityNr.getMccString()).isEqualTo(MCC);
        assertThat(anotherCellIdentityNr.getMccString()).isEqualTo(MCC);
+17 −8
Original line number Original line Diff line number Diff line
@@ -24,6 +24,8 @@ import android.test.suitebuilder.annotation.SmallTest;


/** Unit tests for {@link CellIdentityTdscdma}. */
/** Unit tests for {@link CellIdentityTdscdma}. */


import java.util.Collections;

public class CellIdentityTdscdmaTest extends AndroidTestCase {
public class CellIdentityTdscdmaTest extends AndroidTestCase {


    // Cell identity ranges from 0 to 268435456.
    // Cell identity ranges from 0 to 268435456.
@@ -67,7 +69,8 @@ public class CellIdentityTdscdmaTest extends AndroidTestCase {
    public void testConstructor() {
    public void testConstructor() {
        CellIdentityTdscdma ci =
        CellIdentityTdscdma ci =
                new CellIdentityTdscdma(
                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(MCC_STR, ci.getMccString());
        assertEquals(MNC_STR, ci.getMncString());
        assertEquals(MNC_STR, ci.getMncString());
@@ -83,22 +86,25 @@ public class CellIdentityTdscdmaTest extends AndroidTestCase {
    @SmallTest
    @SmallTest
    public void testConstructorWithEmptyMccMnc() {
    public void testConstructorWithEmptyMccMnc() {
        CellIdentityTdscdma ci = new CellIdentityTdscdma(
        CellIdentityTdscdma ci = new CellIdentityTdscdma(
                null, null, LAC, CID, CPID, UARFCN, "", "");
                null, null, LAC, CID, CPID, UARFCN, "", "", Collections.emptyList(), null);


        assertNull(ci.getMccString());
        assertNull(ci.getMccString());
        assertNull(ci.getMncString());
        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());
        assertEquals(MCC_STR, ci.getMccString());
        assertNull(ci.getMncString());
        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());
        assertEquals(MNC_STR, ci.getMncString());
        assertNull(ci.getMccString());
        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.getMccString());
        assertNull(ci.getMncString());
        assertNull(ci.getMncString());
@@ -107,7 +113,8 @@ public class CellIdentityTdscdmaTest extends AndroidTestCase {
    @SmallTest
    @SmallTest
    public void testParcel() {
    public void testParcel() {
        CellIdentityTdscdma ci = new CellIdentityTdscdma(
        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();
        Parcel p = Parcel.obtain();
        ci.writeToParcel(p, 0);
        ci.writeToParcel(p, 0);
@@ -121,7 +128,8 @@ public class CellIdentityTdscdmaTest extends AndroidTestCase {
    public void testParcelWithUnknowMccMnc() {
    public void testParcelWithUnknowMccMnc() {
        CellIdentityTdscdma ci =
        CellIdentityTdscdma ci =
                new CellIdentityTdscdma(
                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();
        Parcel p = Parcel.obtain();
        p.writeInt(CellInfo.TYPE_TDSCDMA);
        p.writeInt(CellInfo.TYPE_TDSCDMA);
@@ -145,7 +153,8 @@ public class CellIdentityTdscdmaTest extends AndroidTestCase {
        final String invalidMnc = "randomStuff";
        final String invalidMnc = "randomStuff";
        CellIdentityTdscdma ci =
        CellIdentityTdscdma ci =
                new CellIdentityTdscdma(
                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();
        Parcel p = Parcel.obtain();
        p.writeInt(CellInfo.TYPE_TDSCDMA);
        p.writeInt(CellInfo.TYPE_TDSCDMA);
+17 −10
Original line number Original line Diff line number Diff line
@@ -25,6 +25,8 @@ import android.telephony.CellInfo;
import android.test.AndroidTestCase;
import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.SmallTest;
import android.test.suitebuilder.annotation.SmallTest;


import java.util.Collections;

public class CellIdentityTest extends AndroidTestCase {
public class CellIdentityTest extends AndroidTestCase {


    // Cell identity ranges from 0 to 268435456.
    // Cell identity ranges from 0 to 268435456.
@@ -67,14 +69,16 @@ public class CellIdentityTest extends AndroidTestCase {
    @SmallTest
    @SmallTest
    public void testConstructCellIdentityGsm() {
    public void testConstructCellIdentityGsm() {
        // Test values below zero (these must all be non-negative)
        // 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.getLac());
        assertEquals(CellInfo.UNAVAILABLE, gsm.getCid());
        assertEquals(CellInfo.UNAVAILABLE, gsm.getCid());
        assertEquals(CellInfo.UNAVAILABLE, gsm.getArfcn());
        assertEquals(CellInfo.UNAVAILABLE, gsm.getArfcn());
        assertEquals(CellInfo.UNAVAILABLE, gsm.getBsic());
        assertEquals(CellInfo.UNAVAILABLE, gsm.getBsic());


        // Test max values of LAC, CID, ARFCN, and BSIC
        // 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_LAC, gsm.getLac());
        assertEquals(MAX_CID, gsm.getCid());
        assertEquals(MAX_CID, gsm.getCid());
        assertEquals(MAX_ARFCN, gsm.getArfcn());
        assertEquals(MAX_ARFCN, gsm.getArfcn());
@@ -82,7 +86,8 @@ public class CellIdentityTest extends AndroidTestCase {


        // Test max values + 1 of LAC, CID, ARFCN, and BSIC
        // Test max values + 1 of LAC, CID, ARFCN, and BSIC
        gsm = new CellIdentityGsm(
        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.getLac());
        assertEquals(CellInfo.UNAVAILABLE, gsm.getCid());
        assertEquals(CellInfo.UNAVAILABLE, gsm.getCid());
        assertEquals(CellInfo.UNAVAILABLE, gsm.getArfcn());
        assertEquals(CellInfo.UNAVAILABLE, gsm.getArfcn());
@@ -93,23 +98,25 @@ public class CellIdentityTest extends AndroidTestCase {
    @SmallTest
    @SmallTest
    public void testEquals() {
    public void testEquals() {
        CellIdentity ciA = new CellIdentityLte(
        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(
        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));
        assertTrue(ciA.equals(ciB));


        ciA = new CellIdentityLte(CI, PCI, TAC, EARFCN, BANDWIDTH, null, null, ALPHA_LONG,
        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,
        ciB = new CellIdentityLte(CI, PCI, TAC, EARFCN, BANDWIDTH, null, null, ALPHA_LONG,
                ALPHA_SHORT);
                ALPHA_SHORT, Collections.emptyList(), null);


        assertTrue(ciA.equals(ciB));
        assertTrue(ciA.equals(ciB));


        ciA = new CellIdentityLte(CI, PCI, TAC, EARFCN, BANDWIDTH, MCC_STR, null, ALPHA_LONG,
        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,
        ciB = new CellIdentityLte(CI, PCI, TAC, EARFCN, BANDWIDTH, null, null, ALPHA_LONG,
                ALPHA_SHORT);
                ALPHA_SHORT, Collections.emptyList(), null);


        assertFalse(ciA.equals(ciB));
        assertFalse(ciA.equals(ciB));
    }
    }
@@ -117,7 +124,7 @@ public class CellIdentityTest extends AndroidTestCase {
    @SmallTest
    @SmallTest
    public void testParcel() {
    public void testParcel() {
        CellIdentity ci = new CellIdentityLte(CI, PCI, TAC, EARFCN, BANDWIDTH, MCC_STR, MNC_STR,
        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();
        Parcel p = Parcel.obtain();
        ci.writeToParcel(p, 0);
        ci.writeToParcel(p, 0);
Loading