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

Commit 0af95a25 authored by Jack Yu's avatar Jack Yu
Browse files

Removed CDMA unit tests

Bug: 379356026
Test: atest FrameworksTelephonyTests
Flag: EXEMPT test removal
Change-Id: I413e61dd244eb6647f1fdbc77a8dd69a9ffda4f8
parent 5f1d65d8
Loading
Loading
Loading
Loading
+0 −117
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.internal.telephony;

import static org.junit.Assert.assertEquals;

import android.os.Parcel;
import android.telephony.CellIdentityCdma;
import android.test.AndroidTestCase;

import androidx.test.filters.SmallTest;

import com.android.internal.telephony.flags.Flags;

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

public class CellIdentityCdmaTest extends AndroidTestCase {
    private static final String LOG_TAG = "CellIdentityCdmaTest";

    // Network Id ranges from 0 to 65535.
    private static final int NETWORK_ID  = 65535;
    // CDMA System Id ranges from 0 to 32767
    private static final int SYSTEM_ID = 32767;
    // Base Station Id ranges from 0 to 65535
    private static final int BASESTATION_ID = 65535;
    // Longitude ranges from -2592000 to 2592000.
    private static final int LONGITUDE = 2592000;
    // Latitude ranges from -1296000 to 1296000.
    private static final int LATITUDE = 1296000;
    private static final String ALPHA_LONG = "long";
    private static final String ALPHA_SHORT = "short";

    @SmallTest
    public void testConstructor() {
        if (Flags.cleanupCdma()) return;
        CellIdentityCdma  ci =
                new CellIdentityCdma(NETWORK_ID, SYSTEM_ID, BASESTATION_ID, LONGITUDE, LATITUDE,
                        ALPHA_LONG, ALPHA_SHORT);

        assertEquals(NETWORK_ID, ci.getNetworkId());
        assertEquals(LATITUDE, ci.getLatitude());
        assertEquals(LONGITUDE, ci.getLongitude());
        assertEquals(ALPHA_LONG, ci.getOperatorAlphaLong());
        assertEquals(ALPHA_SHORT, ci.getOperatorAlphaShort());

        String globalCi = Integer.toString(SYSTEM_ID, 16) + Integer.toString(NETWORK_ID, 16)
                + Integer.toString(BASESTATION_ID, 16);
        assertEquals(globalCi, ci.getGlobalCellId());
    }

    @SmallTest
    public void testNullIsland() {
        if (Flags.cleanupCdma()) return;
        CellIdentityCdma  ci =
                new CellIdentityCdma(NETWORK_ID, SYSTEM_ID, BASESTATION_ID, -1, 0,
                        ALPHA_LONG, ALPHA_SHORT);

        assertEquals(Integer.MAX_VALUE, ci.getLatitude());
        assertEquals(Integer.MAX_VALUE, ci.getLongitude());
    }

    @SmallTest
    public void testEquals() {
        if (Flags.cleanupCdma()) return;
        CellIdentityCdma  ciA =
                new CellIdentityCdma(NETWORK_ID, SYSTEM_ID, BASESTATION_ID, LONGITUDE, LATITUDE,
                        ALPHA_LONG, ALPHA_SHORT);
        CellIdentityCdma  ciB =
                new CellIdentityCdma(NETWORK_ID, SYSTEM_ID, BASESTATION_ID, LONGITUDE, LATITUDE,
                        ALPHA_LONG, ALPHA_SHORT);

        assertTrue(ciA.equals(ciB));

        ciA = new CellIdentityCdma(NETWORK_ID, SYSTEM_ID, BASESTATION_ID, LONGITUDE, LATITUDE,
                null, null);
        ciB = new CellIdentityCdma(NETWORK_ID, SYSTEM_ID, BASESTATION_ID, LONGITUDE, LATITUDE,
                null, null);

        assertTrue(ciA.equals(ciB));

        ciA = new CellIdentityCdma(NETWORK_ID, SYSTEM_ID, BASESTATION_ID, LONGITUDE, LATITUDE,
                ALPHA_LONG, ALPHA_SHORT);
        ciB = new CellIdentityCdma(NETWORK_ID, SYSTEM_ID, BASESTATION_ID, LONGITUDE, LATITUDE,
                null, null);

        assertFalse(ciA.equals(ciB));
    }

    @SmallTest
    public void testParcel() {
        if (Flags.cleanupCdma()) return;
        CellIdentityCdma  ci =
                new CellIdentityCdma(NETWORK_ID, SYSTEM_ID, BASESTATION_ID, LONGITUDE, LATITUDE,
                        ALPHA_LONG, ALPHA_SHORT);

        Parcel p = Parcel.obtain();
        ci.writeToParcel(p, 0);
        p.setDataPosition(0);

        CellIdentityCdma newCi = CellIdentityCdma.CREATOR.createFromParcel(p);
        assertEquals(ci, newCi);
    }
}
+0 −100
Original line number Diff line number Diff line
/*
 * Copyright (C) 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.internal.telephony;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import android.os.Parcel;
import android.telephony.CellSignalStrengthCdma;
import android.test.AndroidTestCase;

import androidx.test.filters.SmallTest;

import com.android.internal.telephony.flags.Flags;

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

public class CellSignalStrengthCdmaTest extends AndroidTestCase {

    private static final int CDMA_DBM = -74;
    private static final int CDMA_ECIO = -124;
    private static final int EVDO_DBM = -23;
    private static final int EVDO_ECIO = -108;
    private static final int EVDO_SNR = 7;

    @SmallTest
    public void testConstructor() {
        if (Flags.cleanupCdma()) return;
        CellSignalStrengthCdma css = new CellSignalStrengthCdma(
                CDMA_DBM, CDMA_ECIO, EVDO_DBM, EVDO_ECIO, EVDO_SNR);
        assertEquals(CDMA_DBM, css.getCdmaDbm());
        assertEquals(CDMA_ECIO, css.getCdmaEcio());
        assertEquals(EVDO_DBM, css.getEvdoDbm());
        assertEquals(EVDO_ECIO, css.getEvdoEcio());
        assertEquals(EVDO_SNR, css.getEvdoSnr());
    }

    @SmallTest
    public void testInvalidConstructor() {
        if (Flags.cleanupCdma()) return;
        CellSignalStrengthCdma css = new CellSignalStrengthCdma(200, 2000, 20, 400, 200);
        assertEquals(Integer.MAX_VALUE, css.getCdmaDbm());
        assertEquals(Integer.MAX_VALUE, css.getCdmaEcio());
        assertEquals(Integer.MAX_VALUE, css.getEvdoDbm());
        assertEquals(Integer.MAX_VALUE, css.getEvdoEcio());
        assertEquals(Integer.MAX_VALUE, css.getEvdoSnr());
    }

    @SmallTest
    public void testDefaultConstructor() {
        if (Flags.cleanupCdma()) return;
        CellSignalStrengthCdma css = new CellSignalStrengthCdma();
        assertEquals(Integer.MAX_VALUE, css.getCdmaDbm());
        assertEquals(Integer.MAX_VALUE, css.getCdmaEcio());
        assertEquals(Integer.MAX_VALUE, css.getEvdoDbm());
        assertEquals(Integer.MAX_VALUE, css.getEvdoEcio());
        assertEquals(Integer.MAX_VALUE, css.getEvdoSnr());
    }

    @SmallTest
    public void testEquals() {
        if (Flags.cleanupCdma()) return;
        assertTrue(new CellSignalStrengthCdma(
                CDMA_DBM, CDMA_ECIO, EVDO_DBM, EVDO_ECIO, EVDO_SNR).equals(
                        new CellSignalStrengthCdma(
                                CDMA_DBM, CDMA_ECIO, EVDO_DBM, EVDO_ECIO, EVDO_SNR)));
        assertFalse(new CellSignalStrengthCdma(
                CDMA_DBM, CDMA_ECIO, EVDO_DBM, EVDO_ECIO, EVDO_SNR).equals(
                    new CellSignalStrengthCdma(CDMA_DBM, CDMA_ECIO, -24, EVDO_ECIO, EVDO_SNR)));
    }

    @SmallTest
    public void testParcel() {
        if (Flags.cleanupCdma()) return;
        CellSignalStrengthCdma css = new CellSignalStrengthCdma(
                CDMA_DBM, CDMA_ECIO, EVDO_DBM, EVDO_ECIO, EVDO_SNR);

        Parcel p = Parcel.obtain();
        css.writeToParcel(p, 0);
        p.setDataPosition(0);

        CellSignalStrengthCdma newCss = CellSignalStrengthCdma.CREATOR.createFromParcel(p);
        assertEquals(css, newCss);
    }
}