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

Commit 896b0946 authored by Rambo Wang's avatar Rambo Wang Committed by Automerger Merge Worker
Browse files

Merge "Add UT cases to disallow null thresholds even for privileged apps" am: 7ec53590

Original change: https://android-review.googlesource.com/c/platform/frameworks/opt/telephony/+/1894776

Change-Id: I42ac7dfc6c2615c80b1b987d0c07ed5f086930d6
parents 93256ec5 7ec53590
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@ package com.android.internal.telephony;

import static com.google.common.truth.Truth.assertThat;

import static org.junit.Assert.assertThrows;

import android.os.Parcel;
import android.telephony.AccessNetworkConstants;
import android.telephony.SignalStrengthUpdateRequest;
@@ -30,6 +32,7 @@ import junit.framework.TestCase;
import org.junit.Test;

import java.util.Collection;
import java.util.Collections;
import java.util.List;

public class SignalStrengthUpdateRequestTest extends TestCase {
@@ -162,6 +165,27 @@ public class SignalStrengthUpdateRequestTest extends TestCase {
        assertEquals(infos, request.getSignalThresholdInfos());
    }

    @Test
    @SmallTest
    public void testSetSystemThresholdReportingRequestedWhileIdleToTrue_withNullThresholds() {
        assertThrows(IllegalArgumentException.class,
                () -> new SignalStrengthUpdateRequest.Builder()
                        .setSystemThresholdReportingRequestedWhileIdle(true).build());
    }

    @Test
    @SmallTest
    public void testSetSystemThresholdReportingRequestedWhileIdleToTrue_withEmptyThresholds() {
        SignalStrengthUpdateRequest request = new SignalStrengthUpdateRequest.Builder()
                .setSignalThresholdInfos(Collections.EMPTY_LIST)
                .setSystemThresholdReportingRequestedWhileIdle(true)
                .build();

        assertThat(request.getSignalThresholdInfos()).isEmpty();
        assertThat(request.isReportingRequestedWhileIdle()).isFalse();
        assertThat(request.isSystemThresholdReportingRequestedWhileIdle()).isTrue();
    }

    private void validateBuilderWithInvalidParam(Collection<SignalThresholdInfo> infos) {
        try {
            new SignalStrengthUpdateRequest.Builder()