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

Commit 2ba75746 authored by Patrick Rohr's avatar Patrick Rohr Committed by Automerger Merge Worker
Browse files

Move InterfaceParamsTest to frameworks/libs/net am: 0e424142

Original change: https://android-review.googlesource.com/c/platform/packages/modules/NetworkStack/+/2007759

Change-Id: I1cee39c750f042030b7d728f214f1150353df04b
parents 762d4f61 0e424142
Loading
Loading
Loading
Loading
+0 −56
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2017 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.net.util;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;

import androidx.test.filters.SmallTest;
import androidx.test.runner.AndroidJUnit4;

import com.android.net.module.util.NetworkStackConstants;

import org.junit.Test;
import org.junit.runner.RunWith;

@RunWith(AndroidJUnit4.class)
@SmallTest
public class InterfaceParamsTest {
    @Test
    public void testNullInterfaceReturnsNull() {
        assertNull(InterfaceParams.getByName(null));
    }

    @Test
    public void testNonExistentInterfaceReturnsNull() {
        assertNull(InterfaceParams.getByName("doesnotexist0"));
    }

    @Test
    public void testLoopback() {
        final InterfaceParams ifParams = InterfaceParams.getByName("lo");
        assertNotNull(ifParams);
        assertEquals("lo", ifParams.name);
        assertTrue(ifParams.index > 0);
        assertNotNull(ifParams.macAddr);
        assertFalse(ifParams.hasMacAddress);
        assertTrue(ifParams.defaultMtu >= NetworkStackConstants.ETHER_MTU);
    }
}