1 /* 2 * Copyright (C) 2024 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 17 package com.android.car.wifi; 18 19 import static com.google.common.truth.Truth.assertThat; 20 21 import static org.mockito.ArgumentMatchers.anyString; 22 import static org.mockito.Mockito.verify; 23 import static org.mockito.Mockito.when; 24 25 import android.car.wifi.CarWifiManager; 26 import android.car.wifi.ICarWifi; 27 import android.os.IBinder; 28 import android.os.RemoteException; 29 30 import com.android.car.internal.ICarBase; 31 32 import org.junit.Before; 33 import org.junit.Test; 34 import org.junit.runner.RunWith; 35 import org.mockito.Mock; 36 import org.mockito.junit.MockitoJUnitRunner; 37 38 @RunWith(MockitoJUnitRunner.class) 39 public class CarWifiManagerUnitTest { 40 @Mock private ICarBase mCar; 41 @Mock private IBinder mBinder; 42 @Mock private ICarWifi mService; 43 44 private CarWifiManager mCarWifiManager; 45 46 @Before setUp()47 public void setUp() { 48 when(mBinder.queryLocalInterface(anyString())).thenReturn(mService); 49 mCarWifiManager = new CarWifiManager(mCar, mBinder); 50 } 51 52 @Test testCanControlPersistTetheringSettings()53 public void testCanControlPersistTetheringSettings() throws RemoteException { 54 when(mService.canControlPersistTetheringSettings()).thenReturn(true); 55 56 boolean result = mCarWifiManager.canControlPersistTetheringSettings(); 57 58 verify(mService).canControlPersistTetheringSettings(); 59 assertThat(result).isTrue(); 60 } 61 } 62