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

Commit 41426f90 authored by Gil Cukierman's avatar Gil Cukierman
Browse files

Fix testInitializationFromDb

This test was previously passing without the correct permissions, since it just so happened that the instrumentation target's PhoneFactory wasn't initialized.

Instead of relying on the instrumentation context directly, rely on the
TelephonyTest ContextFixture, which already handles privileged phone state read permissions, which are expected by the internal telephony framework.

Bug: 267186351
Fixes: 267186351
Test: atest GsmCdmaPhoneTest InboundSmsTrackerTest
Change-Id: I323d11f84726a403af7af71399ad01d62c52e517
parent 55637423
Loading
Loading
Loading
Loading
+4 −6
Original line number Diff line number Diff line
@@ -24,8 +24,6 @@ import android.database.Cursor;
import android.database.MatrixCursor;
import android.test.suitebuilder.annotation.SmallTest;

import androidx.test.InstrumentationRegistry;

import com.android.internal.util.HexDump;

import org.junit.After;
@@ -34,7 +32,7 @@ import org.junit.Test;

import java.util.Arrays;

public class InboundSmsTrackerTest {
public class InboundSmsTrackerTest extends TelephonyTest {
    InboundSmsTracker mInboundSmsTracker;

    private static final byte[] FAKE_PDU = new byte[]{1, 2, 3};
@@ -50,7 +48,8 @@ public class InboundSmsTrackerTest {

    @Before
    public void setUp() throws Exception {
        mInboundSmsTracker = new InboundSmsTracker(InstrumentationRegistry.getContext(),
        super.setUp(getClass().getSimpleName());
        mInboundSmsTracker = new InboundSmsTracker(mContext,
                FAKE_PDU, FAKE_TIMESTAMP, FAKE_DEST_PORT, false,
                FAKE_ADDRESS, FAKE_DISPLAY_ADDRESS, FAKE_REFERENCE_NUMBER, FAKE_SEQUENCE_NUMBER,
                FAKE_MESSAGE_COUNT, false, FAKE_MESSAGE_BODY, false /* isClass0 */, FAKE_SUBID,
@@ -108,8 +107,7 @@ public class InboundSmsTrackerTest {
    @SmallTest
    public void testInitializationFromDb() {
        Cursor cursor = createFakeCursor();
        mInboundSmsTracker = new InboundSmsTracker(InstrumentationRegistry.getContext(),
                cursor, false);
        mInboundSmsTracker = new InboundSmsTracker(mContext, cursor, false);
        cursor.close();
        testInitialization();
    }