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

Commit dddfd2c6 authored by Hakjun Choi's avatar Hakjun Choi Committed by Android (Google) Code Review
Browse files

Merge "Add sorting by ascending order for repeated atom fields" into main

parents 5f1d65d8 407d3bd8
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -2053,6 +2053,7 @@ public class SatelliteStats {
             */
            public Builder setSupportedSatelliteServices(int[] supportedSatelliteServices) {
                this.mSupportedSatelliteServices = supportedSatelliteServices;
                Arrays.sort(this.mSupportedSatelliteServices);
                return this;
            }

@@ -2495,6 +2496,7 @@ public class SatelliteStats {
             */
            public Builder setEntitlementServiceType(int[] entitlementServiceType) {
                this.mEntitlementServiceType = entitlementServiceType;
                Arrays.sort(this.mEntitlementServiceType);
                return this;
            }

+35 −0
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;

import java.util.Arrays;
import java.util.concurrent.TimeUnit;

public class SatelliteStatsTest extends TelephonyTest {
@@ -636,4 +637,38 @@ public class SatelliteStatsTest extends TelephonyTest {
        assertEquals(param.getConfigDataSource(), stats.configDataSource);
        verifyNoMoreInteractions(mPersistAtomsStorage);
    }

    @Test
    public void testReportRepeatedDataWithAscendingOrder() {
        int[] supportedSatelliteServicesArray = {3, 2, 1};
        SatelliteStats.CarrierRoamingSatelliteSessionParams sessionParams =
                new SatelliteStats.CarrierRoamingSatelliteSessionParams.Builder()
                        .setSupportedSatelliteServices(supportedSatelliteServicesArray)
                        .build();
        mSatelliteStats.onCarrierRoamingSatelliteSessionMetrics(sessionParams);
        ArgumentCaptor<CarrierRoamingSatelliteSession> sessionArgumentCaptor =
                ArgumentCaptor.forClass(CarrierRoamingSatelliteSession.class);
        verify(mPersistAtomsStorage).addCarrierRoamingSatelliteSessionStats(
                sessionArgumentCaptor.capture());
        CarrierRoamingSatelliteSession sessionStats = sessionArgumentCaptor.getValue();

        Arrays.sort(supportedSatelliteServicesArray);
        assertEquals(supportedSatelliteServicesArray, sessionStats.supportedSatelliteServices);
        verifyNoMoreInteractions(mPersistAtomsStorage);

        int[] entitlementServiceTypeArray = {2, 3, 1};
        SatelliteStats.SatelliteEntitlementParams entitlementParams =
                new SatelliteStats.SatelliteEntitlementParams.Builder()
                        .setEntitlementServiceType(entitlementServiceTypeArray)
                        .build();
        mSatelliteStats.onSatelliteEntitlementMetrics(entitlementParams);
        ArgumentCaptor<SatelliteEntitlement> entitlementArgumentCaptor =
                ArgumentCaptor.forClass(SatelliteEntitlement.class);
        verify(mPersistAtomsStorage).addSatelliteEntitlementStats(
                entitlementArgumentCaptor.capture());
        SatelliteEntitlement entitlementStats = entitlementArgumentCaptor.getValue();
        Arrays.sort(entitlementServiceTypeArray);
        assertEquals(entitlementServiceTypeArray, entitlementStats.entitlementServiceType);
        verifyNoMoreInteractions(mPersistAtomsStorage);
    }
}