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

Commit 598de9a7 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:...

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

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

Change-Id: I9a6990ea7afc7b461b9ade7bcbb6093c04a3c8e1
parents bd36ce0f 63a2ec62
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()