Hugo Benichi | 06b1f2b | 2017-07-24 09:30:52 +0900 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2017 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 android.net.ip; |
| 18 | |
Erik Kline | 84714bf | 2017-05-19 09:29:48 +0900 | [diff] [blame] | 19 | import static org.mockito.Mockito.anyString; |
| 20 | import static org.mockito.Mockito.when; |
Hugo Benichi | 06b1f2b | 2017-07-24 09:30:52 +0900 | [diff] [blame] | 21 | |
Remi NGUYEN VAN | 97f69c2 | 2019-01-20 20:35:06 +0900 | [diff] [blame] | 22 | import android.content.Context; |
Erik Kline | 8bd00d5 | 2017-12-08 17:47:50 +0900 | [diff] [blame] | 23 | import android.net.util.InterfaceParams; |
Hugo Benichi | 06b1f2b | 2017-07-24 09:30:52 +0900 | [diff] [blame] | 24 | import android.net.util.SharedLog; |
Erik Kline | 84714bf | 2017-05-19 09:29:48 +0900 | [diff] [blame] | 25 | import android.os.Handler; |
| 26 | import android.os.Looper; |
Hugo Benichi | 06b1f2b | 2017-07-24 09:30:52 +0900 | [diff] [blame] | 27 | import android.support.test.filters.SmallTest; |
| 28 | import android.support.test.runner.AndroidJUnit4; |
| 29 | |
| 30 | import org.junit.Before; |
| 31 | import org.junit.Test; |
| 32 | import org.junit.runner.RunWith; |
| 33 | import org.mockito.Mock; |
| 34 | import org.mockito.MockitoAnnotations; |
| 35 | |
| 36 | |
| 37 | /** |
| 38 | * Tests for IpReachabilityMonitor. |
| 39 | */ |
| 40 | @RunWith(AndroidJUnit4.class) |
| 41 | @SmallTest |
| 42 | public class IpReachabilityMonitorTest { |
| 43 | |
| 44 | @Mock IpReachabilityMonitor.Callback mCallback; |
| 45 | @Mock IpReachabilityMonitor.Dependencies mDependencies; |
| 46 | @Mock SharedLog mLog; |
Remi NGUYEN VAN | 97f69c2 | 2019-01-20 20:35:06 +0900 | [diff] [blame] | 47 | @Mock Context mContext; |
Erik Kline | 84714bf | 2017-05-19 09:29:48 +0900 | [diff] [blame] | 48 | Handler mHandler; |
Hugo Benichi | 06b1f2b | 2017-07-24 09:30:52 +0900 | [diff] [blame] | 49 | |
| 50 | @Before |
| 51 | public void setUp() { |
| 52 | MockitoAnnotations.initMocks(this); |
Erik Kline | 84714bf | 2017-05-19 09:29:48 +0900 | [diff] [blame] | 53 | when(mLog.forSubComponent(anyString())).thenReturn(mLog); |
| 54 | mHandler = new Handler(Looper.getMainLooper()); |
Hugo Benichi | 06b1f2b | 2017-07-24 09:30:52 +0900 | [diff] [blame] | 55 | } |
| 56 | |
| 57 | IpReachabilityMonitor makeMonitor() { |
Erik Kline | 8bd00d5 | 2017-12-08 17:47:50 +0900 | [diff] [blame] | 58 | final InterfaceParams ifParams = new InterfaceParams("fake0", 1, null); |
Remi NGUYEN VAN | 97f69c2 | 2019-01-20 20:35:06 +0900 | [diff] [blame] | 59 | return new IpReachabilityMonitor( |
| 60 | mContext, ifParams, mHandler, mLog, mCallback, false, mDependencies); |
Hugo Benichi | 06b1f2b | 2017-07-24 09:30:52 +0900 | [diff] [blame] | 61 | } |
| 62 | |
| 63 | @Test |
| 64 | public void testNothing() { |
| 65 | IpReachabilityMonitor monitor = makeMonitor(); |
| 66 | } |
| 67 | } |