Search in sources :

Example 1 with WifiP2pDeviceList

use of android.net.wifi.p2p.WifiP2pDeviceList in project android_packages_apps_Settings by omnirom.

the class WifiP2pSettingsTest method peersCategoryController_withOnePeerDevice_shouldBeAvailable.

@Test
public void peersCategoryController_withOnePeerDevice_shouldBeAvailable() {
    final WifiP2pDevice wifiP2pDevice = mock(WifiP2pDevice.class);
    final ArrayList<WifiP2pDevice> deviceList = new ArrayList<>();
    deviceList.add(wifiP2pDevice);
    final WifiP2pDeviceList peers = mock(WifiP2pDeviceList.class);
    doReturn(deviceList).when(peers).getDeviceList();
    mFragment.onPeersAvailable(peers);
    assertThat(mFragment.mPeerCategoryController.isAvailable()).isTrue();
}
Also used : WifiP2pDevice(android.net.wifi.p2p.WifiP2pDevice) ArrayList(java.util.ArrayList) WifiP2pDeviceList(android.net.wifi.p2p.WifiP2pDeviceList) Test(org.junit.Test)

Example 2 with WifiP2pDeviceList

use of android.net.wifi.p2p.WifiP2pDeviceList in project android_packages_apps_Settings by omnirom.

the class WifiP2pSettingsTest method peersCategoryController_withNoPeerDevice_shouldBeUnavailable.

@Test
public void peersCategoryController_withNoPeerDevice_shouldBeUnavailable() {
    final ArrayList<WifiP2pDevice> deviceList = new ArrayList<>();
    final WifiP2pDeviceList peers = mock(WifiP2pDeviceList.class);
    doReturn(deviceList).when(peers).getDeviceList();
    mFragment.onPeersAvailable(peers);
    assertThat(mFragment.mPeerCategoryController.isAvailable()).isFalse();
}
Also used : WifiP2pDevice(android.net.wifi.p2p.WifiP2pDevice) ArrayList(java.util.ArrayList) WifiP2pDeviceList(android.net.wifi.p2p.WifiP2pDeviceList) Test(org.junit.Test)

Example 3 with WifiP2pDeviceList

use of android.net.wifi.p2p.WifiP2pDeviceList in project android_packages_apps_Settings by omnirom.

the class WifiP2pSettingsTest method withEmptyP2pDeviceList_getP2pPeerChangeIntent_connectedDevicesShouldBeZero.

@Test
public void withEmptyP2pDeviceList_getP2pPeerChangeIntent_connectedDevicesShouldBeZero() {
    final WifiP2pDeviceList peers = new WifiP2pDeviceList();
    final Bundle bundle = new Bundle();
    final Intent intent = new Intent(WifiP2pManager.WIFI_P2P_PEERS_CHANGED_ACTION);
    bundle.putParcelable(WifiP2pManager.EXTRA_P2P_DEVICE_LIST, peers);
    intent.putExtras(bundle);
    mFragment.mReceiver.onReceive(mContext, intent);
    assertThat(mFragment.mConnectedDevices).isEqualTo(0);
}
Also used : Bundle(android.os.Bundle) Intent(android.content.Intent) WifiP2pDeviceList(android.net.wifi.p2p.WifiP2pDeviceList) Test(org.junit.Test)

Aggregations

WifiP2pDeviceList (android.net.wifi.p2p.WifiP2pDeviceList)3 Test (org.junit.Test)3 WifiP2pDevice (android.net.wifi.p2p.WifiP2pDevice)2 ArrayList (java.util.ArrayList)2 Intent (android.content.Intent)1 Bundle (android.os.Bundle)1