1 /* 2 * Copyright (C) 2019 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package android.net; 17 18 import static org.junit.Assert.assertEquals; 19 20 import android.os.Build; 21 import android.os.IBinder; 22 23 import androidx.test.runner.AndroidJUnit4; 24 25 import com.android.testutils.DevSdkIgnoreRule; 26 import com.android.testutils.DevSdkIgnoreRule.IgnoreUpTo; 27 28 import org.junit.Before; 29 import org.junit.Rule; 30 import org.junit.Test; 31 import org.junit.runner.RunWith; 32 import org.mockito.Mock; 33 import org.mockito.MockitoAnnotations; 34 35 @RunWith(AndroidJUnit4.class) 36 public class NetworkStackTest { 37 @Rule 38 public DevSdkIgnoreRule mDevSdkIgnoreRule = new DevSdkIgnoreRule(); 39 40 @Mock private IBinder mConnectorBinder; 41 setUp()42 @Before public void setUp() throws Exception { 43 MockitoAnnotations.initMocks(this); 44 } 45 46 @Test @IgnoreUpTo(Build.VERSION_CODES.Q) testGetService()47 public void testGetService() { 48 NetworkStack.setServiceForTest(mConnectorBinder); 49 assertEquals(NetworkStack.getService(), mConnectorBinder); 50 } 51 } 52