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

Commit aad704bd authored by Jack Yu's avatar Jack Yu
Browse files

Added unit test for CellIdentityLte

Test: Manual
Change-Id: I81f069f82e6db7d96dad5fc701b2794a672bdc96
Fix: 149475773
parent 5ef73c8d
Loading
Loading
Loading
Loading
+24 −19
Original line number Diff line number Diff line
@@ -22,7 +22,9 @@ import android.telephony.CellInfo;
import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.SmallTest;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;

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

@@ -36,6 +38,7 @@ public class CellIdentityLteTest extends AndroidTestCase {
    private static final int TAC = 65535;
    // Absolute RF Channel Number ranges from 0 to 262140.
    private static final int EARFCN = 262140;
    private static final List<Integer> BANDS = Arrays.asList(1, 2);
    private static final int MCC = 120;
    private static final int MNC = 260;
    private static final int BANDWIDTH = 5000;  // kHz
@@ -47,7 +50,7 @@ public class CellIdentityLteTest extends AndroidTestCase {
    @SmallTest
    public void testDefaultConstructor() {
        CellIdentityLte ci =
                new CellIdentityLte(CI, PCI, TAC, EARFCN, BANDWIDTH, MCC_STR, MNC_STR,
                new CellIdentityLte(CI, PCI, TAC, EARFCN, BANDS, BANDWIDTH, MCC_STR, MNC_STR,
                        ALPHA_LONG, ALPHA_SHORT, Collections.emptyList(), null);

        assertEquals(CI, ci.getCi());
@@ -69,8 +72,8 @@ public class CellIdentityLteTest extends AndroidTestCase {
    public void testConstructorWithThreeDigitMnc() {
        final String mncWithThreeDigit = "061";
        CellIdentityLte ci =
                new CellIdentityLte(CI, PCI, TAC, EARFCN, BANDWIDTH, MCC_STR, mncWithThreeDigit,
                        ALPHA_LONG, ALPHA_SHORT, Collections.emptyList(), null);
                new CellIdentityLte(CI, PCI, TAC, EARFCN, BANDS, BANDWIDTH, MCC_STR,
                        mncWithThreeDigit, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList(), null);

        assertEquals(MCC, ci.getMcc());
        assertEquals(61, ci.getMnc());
@@ -83,8 +86,8 @@ public class CellIdentityLteTest extends AndroidTestCase {
    public void testConstructorWithTwoDigitMnc() {
        final String mncWithTwoDigit = "61";
        CellIdentityLte ci =
                new CellIdentityLte(CI, PCI, TAC, EARFCN, BANDWIDTH, MCC_STR, mncWithTwoDigit,
                        ALPHA_LONG, ALPHA_SHORT, Collections.emptyList(), null);
                new CellIdentityLte(CI, PCI, TAC, EARFCN, BANDS, BANDWIDTH, MCC_STR,
                        mncWithTwoDigit, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList(), null);

        assertEquals(MCC, ci.getMcc());
        assertEquals(61, ci.getMnc());
@@ -96,8 +99,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,
                Collections.emptyList(), null);
                CI, PCI, TAC, EARFCN, BANDS, BANDWIDTH, null, null, ALPHA_LONG,
                ALPHA_SHORT, Collections.emptyList(), null);

        assertEquals(Integer.MAX_VALUE, ci.getMcc());
        assertEquals(Integer.MAX_VALUE, ci.getMnc());
@@ -106,7 +109,7 @@ 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, BANDS, BANDWIDTH, MCC_STR, null, ALPHA_LONG, ALPHA_SHORT,
                Collections.emptyList(), null);

        assertEquals(MCC, ci.getMcc());
@@ -116,7 +119,7 @@ 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, BANDS, BANDWIDTH, null, MNC_STR, ALPHA_LONG, ALPHA_SHORT,
                Collections.emptyList(), null);

        assertEquals(MNC, ci.getMnc());
@@ -126,7 +129,7 @@ public class CellIdentityLteTest extends AndroidTestCase {
        assertNull(ci.getMobileNetworkOperator());

        ci = new CellIdentityLte(
                CI, PCI, TAC, EARFCN, BANDWIDTH, "", "", ALPHA_LONG, ALPHA_SHORT,
                CI, PCI, TAC, EARFCN, BANDS, BANDWIDTH, "", "", ALPHA_LONG, ALPHA_SHORT,
                Collections.emptyList(), null);

        assertEquals(Integer.MAX_VALUE, ci.getMcc());
@@ -158,28 +161,28 @@ 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, BANDS, 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, BANDS, 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, BANDS, 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, BANDS, 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, BANDS, 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, BANDS, BANDWIDTH, null, null, ALPHA_LONG, ALPHA_SHORT,
                Collections.emptyList(), null);

        assertFalse(ciA.equals(ciB));
@@ -188,7 +191,7 @@ public class CellIdentityLteTest extends AndroidTestCase {
    @SmallTest
    public void testParcel() {
        CellIdentityLte ci =
                new CellIdentityLte(CI, PCI, TAC, EARFCN, BANDWIDTH, MCC_STR, MNC_STR,
                new CellIdentityLte(CI, PCI, TAC, EARFCN, BANDS, BANDWIDTH, MCC_STR, MNC_STR,
                        ALPHA_LONG, ALPHA_SHORT, Collections.emptyList(), null);

        Parcel p = Parcel.obtain();
@@ -202,7 +205,7 @@ 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, BANDS, BANDWIDTH, null, null, ALPHA_LONG, ALPHA_SHORT,
                Collections.emptyList(), null);

        Parcel p = Parcel.obtain();
@@ -215,6 +218,7 @@ public class CellIdentityLteTest extends AndroidTestCase {
        p.writeInt(PCI);
        p.writeInt(TAC);
        p.writeInt(EARFCN);
        p.writeList(BANDS);
        p.writeInt(BANDWIDTH);
        p.setDataPosition(0);

@@ -227,7 +231,7 @@ 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, BANDS, BANDWIDTH, null, null, ALPHA_LONG, ALPHA_SHORT,
                Collections.emptyList(), null);

        Parcel p = Parcel.obtain();
@@ -240,6 +244,7 @@ public class CellIdentityLteTest extends AndroidTestCase {
        p.writeInt(PCI);
        p.writeInt(TAC);
        p.writeInt(EARFCN);
        p.writeList(BANDS);
        p.writeInt(BANDWIDTH);
        p.setDataPosition(0);

+12 −9
Original line number Diff line number Diff line
@@ -25,7 +25,9 @@ import android.telephony.CellInfo;
import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.SmallTest;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class CellIdentityTest extends AndroidTestCase {

@@ -37,6 +39,7 @@ public class CellIdentityTest extends AndroidTestCase {
    private static final int TAC = 65535;
    // Absolute RF Channel Number ranges from 0 to 262140.
    private static final int EARFCN = 262140;
    private static final List<Integer> BANDS = Arrays.asList(1, 2);
    private static final int BANDWIDTH = 5000;  // kHz
    private static final int MCC = 120;
    private static final int MNC = 260;
@@ -98,24 +101,24 @@ 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, BANDS, 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, BANDS, 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,
        ciA = new CellIdentityLte(CI, PCI, TAC, EARFCN, BANDS, BANDWIDTH, null, null, ALPHA_LONG,
                ALPHA_SHORT, Collections.emptyList(), null);
        ciB = new CellIdentityLte(CI, PCI, TAC, EARFCN, BANDWIDTH, null, null, ALPHA_LONG,
        ciB = new CellIdentityLte(CI, PCI, TAC, EARFCN, BANDS, 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, Collections.emptyList(), null);
        ciB = new CellIdentityLte(CI, PCI, TAC, EARFCN, BANDWIDTH, null, null, ALPHA_LONG,
        ciA = new CellIdentityLte(CI, PCI, TAC, EARFCN, BANDS, BANDWIDTH, MCC_STR, null,
                ALPHA_LONG, ALPHA_SHORT, Collections.emptyList(), null);
        ciB = new CellIdentityLte(CI, PCI, TAC, EARFCN, BANDS, BANDWIDTH, null, null, ALPHA_LONG,
                ALPHA_SHORT, Collections.emptyList(), null);

        assertFalse(ciA.equals(ciB));
@@ -123,8 +126,8 @@ 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, Collections.emptyList(), null);
        CellIdentity ci = new CellIdentityLte(CI, PCI, TAC, EARFCN, BANDS, BANDWIDTH, MCC_STR,
                MNC_STR, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList(), null);

        Parcel p = Parcel.obtain();
        ci.writeToParcel(p, 0);
+3 −1
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import androidx.test.filters.SmallTest;
import org.junit.Test;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;

/** Unit tests for {@link NetworkScanResult}. */
@@ -53,7 +54,8 @@ public class NetworkScanResultTest {
        infos.add(gsm);

        CellIdentityLte cil = new CellIdentityLte(
                10, 5, 200, 2000, 10000, "001", "01", "test", "tst", Collections.emptyList(), null);
                10, 5, 200, 2000, Arrays.asList(1, 2), 10000, "001", "01", "test", "tst",
                Collections.emptyList(), null);
        CellSignalStrengthLte cssl = new CellSignalStrengthLte(15, 16, 17, 18, 19, 20);
        CellInfoLte lte = new CellInfoLte();
        lte.setRegistered(false);
+11 −8
Original line number Diff line number Diff line
@@ -210,6 +210,7 @@ public class RILTest extends TelephonyTest {
    private static final int CQI = 2147483647;
    private static final int DBM = -74;
    private static final int EARFCN = 262140;
    private static final List<Integer> BANDS = Arrays.asList(1, 2);
    private static final int BANDWIDTH = 5000;
    private static final int ECIO = -124;
    private static final String EMPTY_ALPHA_LONG = "";
@@ -1189,8 +1190,9 @@ public class RILTest extends TelephonyTest {
        CellInfoLte expected = new CellInfoLte();
        expected.setRegistered(false);
        expected.setTimeStamp(TIMESTAMP);
        CellIdentityLte cil = new CellIdentityLte(CI, PCI, TAC, EARFCN, Integer.MAX_VALUE, MCC_STR,
                MNC_STR, EMPTY_ALPHA_LONG, EMPTY_ALPHA_SHORT, Collections.emptyList(), null);
        CellIdentityLte cil = new CellIdentityLte(CI, PCI, TAC, EARFCN, Collections.emptyList(),
                Integer.MAX_VALUE, MCC_STR, MNC_STR, EMPTY_ALPHA_LONG, EMPTY_ALPHA_SHORT,
                Collections.emptyList(), null);
        CellSignalStrengthLte css = new CellSignalStrengthLte(
                RSSI, RSRP, RSRQ, RSSNR, CQI, TIMING_ADVANCE);
        expected.setCellIdentity(cil);
@@ -1378,8 +1380,8 @@ public class RILTest extends TelephonyTest {
        expected.setRegistered(false);
        expected.setTimeStamp(TIMESTAMP);
        CellIdentityLte cil = new CellIdentityLte(
                CI, PCI, TAC, EARFCN, BANDWIDTH, MCC_STR, MNC_STR, ALPHA_LONG, ALPHA_SHORT,
                Collections.emptyList(), null);
                CI, PCI, TAC, EARFCN, Collections.emptyList(), BANDWIDTH, MCC_STR, MNC_STR,
                ALPHA_LONG, ALPHA_SHORT, Collections.emptyList(), null);
        CellSignalStrengthLte css = new CellSignalStrengthLte(
                RSSI, RSRP, RSRQ, RSSNR, CQI, TIMING_ADVANCE);
        expected.setCellIdentity(cil);
@@ -1399,8 +1401,9 @@ public class RILTest extends TelephonyTest {
        CellInfoLte expected = new CellInfoLte();
        expected.setRegistered(false);
        expected.setTimeStamp(TIMESTAMP);
        CellIdentityLte cil = new CellIdentityLte(CI, PCI, TAC, EARFCN, BANDWIDTH, MCC_STR, MNC_STR,
                EMPTY_ALPHA_LONG, EMPTY_ALPHA_SHORT, Collections.emptyList(), null);
        CellIdentityLte cil = new CellIdentityLte(CI, PCI, TAC, EARFCN, Collections.emptyList(),
                BANDWIDTH, MCC_STR, MNC_STR, EMPTY_ALPHA_LONG, EMPTY_ALPHA_SHORT,
                Collections.emptyList(), null);
        CellSignalStrengthLte css = new CellSignalStrengthLte(
                RSSI, RSRP, RSRQ, RSSNR, CQI, TIMING_ADVANCE);
        expected.setCellIdentity(cil);
@@ -1423,8 +1426,8 @@ public class RILTest extends TelephonyTest {
        expected.setRegistered(false);
        expected.setTimeStamp(TIMESTAMP);
        CellIdentityLte cil = new CellIdentityLte(
                CI, PCI, TAC, EARFCN, BANDWIDTH, null, null, ALPHA_LONG, ALPHA_SHORT,
                Collections.emptyList(), null);
                CI, PCI, TAC, EARFCN, Collections.emptyList(), BANDWIDTH, null, null, ALPHA_LONG,
                ALPHA_SHORT, Collections.emptyList(), null);
        CellSignalStrengthLte css = new CellSignalStrengthLte(
                RSSI, RSRP, RSRQ, RSSNR, CQI, TIMING_ADVANCE);
        expected.setCellIdentity(cil);
+12 −12
Original line number Diff line number Diff line
@@ -2056,8 +2056,8 @@ public class ServiceStateTrackerTest extends TelephonyTest {
    public void testPhyChanBandwidthUpdatedOnDataRegState() throws Exception {
        // Cell ID change should trigger hasLocationChanged.
        CellIdentityLte cellIdentity5 =
                new CellIdentityLte(1, 1, 5, 1, 5000, "001", "01", "test", "tst",
                        Collections.emptyList(), null);
                new CellIdentityLte(1, 1, 5, 1, Arrays.asList(1, 2), 5000, "001", "01", "test",
                        "tst", Collections.emptyList(), null);

        sendPhyChanConfigChange(new int[] {10000});
        sendRegStateUpdateForLteCellId(cellIdentity5);
@@ -2068,8 +2068,8 @@ public class ServiceStateTrackerTest extends TelephonyTest {
    public void testPhyChanBandwidthNotUpdatedWhenInvalidInCellIdentity() throws Exception {
        // Cell ID change should trigger hasLocationChanged.
        CellIdentityLte cellIdentityInv =
                new CellIdentityLte(1, 1, 5, 1, 12345, "001", "01", "test", "tst",
                        Collections.emptyList(), null);
                new CellIdentityLte(1, 1, 5, 1, Arrays.asList(1, 2), 12345, "001", "01", "test",
                        "tst", Collections.emptyList(), null);

        sendPhyChanConfigChange(new int[] {10000});
        sendRegStateUpdateForLteCellId(cellIdentityInv);
@@ -2080,8 +2080,8 @@ public class ServiceStateTrackerTest extends TelephonyTest {
    public void testPhyChanBandwidthPrefersCarrierAggregationReport() throws Exception {
        // Cell ID change should trigger hasLocationChanged.
        CellIdentityLte cellIdentity10 =
                new CellIdentityLte(1, 1, 5, 1, 10000, "001", "01", "test", "tst",
                        Collections.emptyList(), null);
                new CellIdentityLte(1, 1, 5, 1, Arrays.asList(1, 2), 10000, "001", "01", "test",
                        "tst", Collections.emptyList(), null);

        sendPhyChanConfigChange(new int[] {10000, 5000});
        sendRegStateUpdateForLteCellId(cellIdentity10);
@@ -2092,8 +2092,8 @@ public class ServiceStateTrackerTest extends TelephonyTest {
    public void testPhyChanBandwidthRatchetedOnPhyChanBandwidth() throws Exception {
        // LTE Cell with bandwidth = 10000
        CellIdentityLte cellIdentity10 =
                new CellIdentityLte(1, 1, 1, 1, 10000, "1", "1", "test", "tst",
                        Collections.emptyList(), null);
                new CellIdentityLte(1, 1, 1, 1, Arrays.asList(1, 2), 10000, "1", "1", "test",
                        "tst", Collections.emptyList(), null);

        sendRegStateUpdateForLteCellId(cellIdentity10);
        assertTrue(Arrays.equals(new int[] {10000}, sst.mSS.getCellBandwidths()));
@@ -2140,8 +2140,8 @@ public class ServiceStateTrackerTest extends TelephonyTest {

        // Start state: Cell data only LTE + IWLAN
        CellIdentityLte cellIdentity =
                new CellIdentityLte(1, 1, 5, 1, 5000, "001", "01", "test", "tst",
                        Collections.emptyList(), null);
                new CellIdentityLte(1, 1, 5, 1, Arrays.asList(1, 2), 5000, "001", "01", "test",
                        "tst", Collections.emptyList(), null);
        changeRegStateWithIwlan(
                // WWAN
                NetworkRegistrationInfo.REGISTRATION_STATE_HOME, cellIdentity,
@@ -2296,8 +2296,8 @@ public class ServiceStateTrackerTest extends TelephonyTest {
        sst.mSS = ss;

        CellIdentityLte cellId =
                new CellIdentityLte(1, 1, 5, 1, 5000, "001", "01", "test", "tst",
                        Collections.emptyList(), null);
                new CellIdentityLte(1, 1, 5, 1, Arrays.asList(1, 2), 5000, "001", "01", "test",
                        "tst", Collections.emptyList(), null);
        LteVopsSupportInfo lteVopsSupportInfo =
                new LteVopsSupportInfo(LteVopsSupportInfo.LTE_STATUS_NOT_SUPPORTED,
                    LteVopsSupportInfo.LTE_STATUS_NOT_SUPPORTED);