use of com.android.settingslib.wifi.WifiTracker.Scanner in project android_frameworks_base by AOSPA.
the class WifiTrackerTest method testSavedOnly.
public void testSavedOnly() {
mWifiTracker = new WifiTracker(mContext, mWifiListener, mLooper, true, false, true, mWifiManager, mMainLooper);
mWifiTracker.mScanner = mWifiTracker.new Scanner();
List<WifiConfiguration> wifiConfigs = new ArrayList<WifiConfiguration>();
List<ScanResult> scanResults = new ArrayList<ScanResult>();
generateTestNetworks(wifiConfigs, scanResults, true);
// Tell WifiTracker we are connected now.
sendConnected();
// Send all of the configs and scan results to the tracker.
Mockito.when(mWifiManager.getConfiguredNetworks()).thenReturn(wifiConfigs);
Mockito.when(mWifiManager.getScanResults()).thenReturn(scanResults);
sendScanResultsAndProcess(false);
List<AccessPoint> accessPoints = mWifiTracker.getAccessPoints();
// Only expect the first two to come back in the results.
assertEquals("Expected number of results", 2, accessPoints.size());
assertEquals(TEST_SSIDS[1], accessPoints.get(0).getSsid());
assertEquals(TEST_SSIDS[0], accessPoints.get(1).getSsid());
}
use of com.android.settingslib.wifi.WifiTracker.Scanner in project android_frameworks_base by AOSPA.
the class WifiTrackerTest method testSavedOnlyNoLooper.
/**
* This tests the case where Settings runs this on a non-looper thread for indexing.
*/
public void testSavedOnlyNoLooper() {
mWifiTracker = new WifiTracker(mContext, mWifiListener, mLooper, true, false, true, mWifiManager, null);
mWifiTracker.mScanner = mWifiTracker.new Scanner();
List<WifiConfiguration> wifiConfigs = new ArrayList<WifiConfiguration>();
List<ScanResult> scanResults = new ArrayList<ScanResult>();
generateTestNetworks(wifiConfigs, scanResults, true);
// Send all of the configs and scan results to the tracker.
Mockito.when(mWifiManager.getConfiguredNetworks()).thenReturn(wifiConfigs);
Mockito.when(mWifiManager.getScanResults()).thenReturn(scanResults);
mWifiTracker.forceUpdate();
List<AccessPoint> accessPoints = mWifiTracker.getAccessPoints();
// Only expect the first two to come back in the results.
assertEquals("Expected number of results", 2, accessPoints.size());
assertEquals(TEST_SSIDS[1], accessPoints.get(0).getSsid());
assertEquals(TEST_SSIDS[0], accessPoints.get(1).getSsid());
}
use of com.android.settingslib.wifi.WifiTracker.Scanner in project android_frameworks_base by AOSPA.
the class WifiTrackerTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
mWifiManager = Mockito.mock(WifiManager.class);
mWifiListener = Mockito.mock(WifiListener.class);
mWorkerThread = new HandlerThread("TestHandlerThread");
mWorkerThread.start();
mLooper = mWorkerThread.getLooper();
mMainThread = new HandlerThread("TestHandlerThread");
mMainThread.start();
mMainLooper = mMainThread.getLooper();
mWifiTracker = new WifiTracker(mContext, mWifiListener, mLooper, true, true, true, mWifiManager, mMainLooper);
mWifiTracker.mScanner = mWifiTracker.new Scanner();
Mockito.when(mWifiManager.isWifiEnabled()).thenReturn(true);
}
use of com.android.settingslib.wifi.WifiTracker.Scanner in project android_frameworks_base by AOSPA.
the class WifiTrackerTest method testNonEphemeralConnected.
public void testNonEphemeralConnected() {
mWifiTracker = new WifiTracker(mContext, mWifiListener, mLooper, false, true, true, mWifiManager, mMainLooper);
mWifiTracker.mScanner = mWifiTracker.new Scanner();
List<WifiConfiguration> wifiConfigs = new ArrayList<WifiConfiguration>();
List<ScanResult> scanResults = new ArrayList<ScanResult>();
generateTestNetworks(wifiConfigs, scanResults, false);
// Tell WifiTracker we are connected now.
sendConnected();
// Send all of the configs and scan results to the tracker.
Mockito.when(mWifiManager.getConfiguredNetworks()).thenReturn(wifiConfigs);
Mockito.when(mWifiManager.getScanResults()).thenReturn(scanResults);
// Do this twice to catch a bug that was happening in the caching, making things ephemeral.
sendScanResultsAndProcess(true);
List<AccessPoint> accessPoints = mWifiTracker.getAccessPoints();
assertEquals("Expected number of results", NUM_NETWORKS - 1, accessPoints.size());
assertFalse("Connection is not ephemeral", accessPoints.get(0).isEphemeral());
assertTrue("Connected to wifi", accessPoints.get(0).isActive());
}
use of com.android.settingslib.wifi.WifiTracker.Scanner in project android_frameworks_base by ResurrectionRemix.
the class WifiTrackerTest method testSavedOnlyNoLooper.
/**
* This tests the case where Settings runs this on a non-looper thread for indexing.
*/
public void testSavedOnlyNoLooper() {
mWifiTracker = new WifiTracker(mContext, mWifiListener, mLooper, true, false, true, mWifiManager, null);
mWifiTracker.mScanner = mWifiTracker.new Scanner();
List<WifiConfiguration> wifiConfigs = new ArrayList<WifiConfiguration>();
List<ScanResult> scanResults = new ArrayList<ScanResult>();
generateTestNetworks(wifiConfigs, scanResults, true);
// Send all of the configs and scan results to the tracker.
Mockito.when(mWifiManager.getConfiguredNetworks()).thenReturn(wifiConfigs);
Mockito.when(mWifiManager.getScanResults()).thenReturn(scanResults);
mWifiTracker.forceUpdate();
List<AccessPoint> accessPoints = mWifiTracker.getAccessPoints();
// Only expect the first two to come back in the results.
assertEquals("Expected number of results", 2, accessPoints.size());
assertEquals(TEST_SSIDS[1], accessPoints.get(0).getSsid());
assertEquals(TEST_SSIDS[0], accessPoints.get(1).getSsid());
}
Aggregations