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

Commit e603fe8b authored by Etan Cohen's avatar Etan Cohen Committed by android-build-merger
Browse files

Merge "[CM] Fix comments, add tests to TransportInfo API"

am: 4060bc14

Change-Id: Idd668efdd1fe65754228041f23f3a91148aa38d6
parents 3038f743 4060bc14
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -931,7 +931,7 @@ public final class NetworkCapabilities implements Parcelable {
     * Returns a transport-specific information container. The application may cast this
     * Returns a transport-specific information container. The application may cast this
     * container to a concrete sub-class based on its knowledge of the network request. The
     * container to a concrete sub-class based on its knowledge of the network request. The
     * application should be able to deal with a {@code null} return value or an invalid case,
     * application should be able to deal with a {@code null} return value or an invalid case,
     * e.g. use {@code instanceof} operation to verify expected type.
     * e.g. use {@code instanceof} operator to verify expected type.
     *
     *
     * @return A concrete implementation of the {@link TransportInfo} class or null if not
     * @return A concrete implementation of the {@link TransportInfo} class or null if not
     * available for the network.
     * available for the network.
+9 −2
Original line number Original line Diff line number Diff line
@@ -474,7 +474,7 @@ public class NetworkCapabilitiesTest {
                new StringNetworkSpecifier("specs"));
                new StringNetworkSpecifier("specs"));
        try {
        try {
            nc2.addTransportType(TRANSPORT_WIFI);
            nc2.addTransportType(TRANSPORT_WIFI);
            fail("Cannot set NetworkSpecifier on a NetworkCapability with multiple transports!");
            fail("Cannot set a second TransportType of a network which has a NetworkSpecifier!");
        } catch (IllegalStateException expected) {
        } catch (IllegalStateException expected) {
            // empty
            // empty
        }
        }
@@ -500,16 +500,23 @@ public class NetworkCapabilitiesTest {
            // empty
            // empty
        });
        });
        NetworkCapabilities nc2 = new NetworkCapabilities();
        NetworkCapabilities nc2 = new NetworkCapabilities();
        // new TransportInfo so that object is not #equals to nc1's TransportInfo (that's where
        // combine fails)
        nc2.setTransportInfo(new TransportInfo() {
        nc2.setTransportInfo(new TransportInfo() {
            // empty
            // empty
        });
        });


        try {
        try {
            nc1.combineCapabilities(nc2);
            nc1.combineCapabilities(nc2);
            fail("Should not be able to combine NetworkCaabilities which contain TransportInfos");
            fail("Should not be able to combine NetworkCabilities which contain TransportInfos");
        } catch (IllegalStateException expected) {
        } catch (IllegalStateException expected) {
            // empty
            // empty
        }
        }

        // verify that can combine with identical TransportInfo objects
        NetworkCapabilities nc3 = new NetworkCapabilities();
        nc3.setTransportInfo(nc1.getTransportInfo());
        nc1.combineCapabilities(nc3);
    }
    }


    private void assertEqualsThroughMarshalling(NetworkCapabilities netCap) {
    private void assertEqualsThroughMarshalling(NetworkCapabilities netCap) {