1package com.xtremelabs.robolectric.shadows;
2
3import android.net.wifi.WifiInfo;
4import android.net.wifi.WifiManager;
5import com.xtremelabs.robolectric.WithTestDefaultsRunner;
6import org.junit.Test;
7import org.junit.runner.RunWith;
8
9import static android.content.Context.WIFI_SERVICE;
10import static com.xtremelabs.robolectric.Robolectric.application;
11import static com.xtremelabs.robolectric.Robolectric.shadowOf;
12import static org.hamcrest.CoreMatchers.equalTo;
13import static org.hamcrest.MatcherAssert.assertThat;
14
15@RunWith(WithTestDefaultsRunner.class)
16public class WifiInfoTest {
17
18    @Test
19    public void shouldReturnMacAddress() {
20        WifiManager wifiManager = (WifiManager) application.getSystemService(WIFI_SERVICE);
21        WifiInfo wifiInfo = wifiManager.getConnectionInfo();
22        shadowOf(wifiInfo).setMacAddress("mac address");
23
24        wifiManager = (WifiManager) application.getSystemService(WIFI_SERVICE);
25        wifiInfo = wifiManager.getConnectionInfo();
26        assertThat(wifiInfo.getMacAddress(), equalTo("mac address"));
27    }
28}
29