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

Commit cfc40307 authored by Lorenzo Colitti's avatar Lorenzo Colitti Committed by Android (Google) Code Review
Browse files

Merge "test: LinkProperties: Unique Route Destinations" into rvc-dev

parents 34e727ec 315e3701
Loading
Loading
Loading
Loading
+12 −9
Original line number Diff line number Diff line
@@ -315,7 +315,7 @@ public class LinkPropertiesTest {
        source.addDnsServer(DNS1);
        source.addDnsServer(DNS2);
        // set 2 gateways
        source.addRoute(new RouteInfo(GATEWAY1));
        source.addRoute(new RouteInfo(LINKADDRV4, GATEWAY1));
        source.addRoute(new RouteInfo(GATEWAY2));
        source.setMtu(MTU);

@@ -327,7 +327,7 @@ public class LinkPropertiesTest {
        target.addDnsServer(DNS2);
        target.addDnsServer(DNS1);
        target.addRoute(new RouteInfo(GATEWAY2));
        target.addRoute(new RouteInfo(GATEWAY1));
        target.addRoute(new RouteInfo(LINKADDRV4, GATEWAY1));
        target.setMtu(MTU);

        assertLinkPropertiesEqual(source, target);
@@ -364,12 +364,13 @@ public class LinkPropertiesTest {

    @Test
    public void testRouteInterfaces() {
        LinkAddress prefix = new LinkAddress(address("2001:db8::"), 32);
        LinkAddress prefix1 = new LinkAddress(address("2001:db8:1::"), 48);
        LinkAddress prefix2 = new LinkAddress(address("2001:db8:2::"), 48);
        InetAddress address = ADDRV6;

        // Add a route with no interface to a LinkProperties with no interface. No errors.
        LinkProperties lp = new LinkProperties();
        RouteInfo r = new RouteInfo(prefix, address, null);
        RouteInfo r = new RouteInfo(prefix1, address, null);
        assertTrue(lp.addRoute(r));
        assertEquals(1, lp.getRoutes().size());
        assertAllRoutesHaveInterface(null, lp);
@@ -379,7 +380,7 @@ public class LinkPropertiesTest {
        assertEquals(1, lp.getRoutes().size());

        // Add a route with an interface. Expect an exception.
        r = new RouteInfo(prefix, address, "wlan0");
        r = new RouteInfo(prefix2, address, "wlan0");
        try {
          lp.addRoute(r);
          fail("Adding wlan0 route to LP with no interface, expect exception");
@@ -398,7 +399,7 @@ public class LinkPropertiesTest {
        } catch (IllegalArgumentException expected) {}

        // If the interface name matches, the route is added.
        r = new RouteInfo(prefix, null, "wlan0");
        r = new RouteInfo(prefix2, null, "wlan0");
        lp.setInterfaceName("wlan0");
        lp.addRoute(r);
        assertEquals(2, lp.getRoutes().size());
@@ -423,10 +424,12 @@ public class LinkPropertiesTest {
        assertEquals(3, lp.compareAllRoutes(lp2).added.size());
        assertEquals(3, lp.compareAllRoutes(lp2).removed.size());

        // Check remove works
        lp.removeRoute(new RouteInfo(prefix, address, null));
        // Remove route with incorrect interface, no route removed.
        lp.removeRoute(new RouteInfo(prefix2, null, null));
        assertEquals(3, lp.getRoutes().size());
        lp.removeRoute(new RouteInfo(prefix, address, "wlan0"));

        // Check remove works when interface is correct.
        lp.removeRoute(new RouteInfo(prefix2, null, "wlan0"));
        assertEquals(2, lp.getRoutes().size());
        assertAllRoutesHaveInterface("wlan0", lp);
        assertAllRoutesNotHaveInterface("p2p0", lp);