use of com.android.wifitrackerlib.WifiEntry in project android_packages_apps_Settings by omnirom.
the class WifiSettingsTest method onCreateContextMenu_shouldHaveForgetAndDisconnectMenuForConnectedWifiEntry.
@Test
public void onCreateContextMenu_shouldHaveForgetAndDisconnectMenuForConnectedWifiEntry() {
final FragmentActivity activity = mock(FragmentActivity.class);
when(activity.getApplicationContext()).thenReturn(mContext);
when(mWifiSettings.getActivity()).thenReturn(activity);
final WifiEntry wifiEntry = mock(WifiEntry.class);
when(wifiEntry.canDisconnect()).thenReturn(true);
when(wifiEntry.canForget()).thenReturn(true);
when(wifiEntry.isSaved()).thenReturn(true);
when(wifiEntry.getConnectedState()).thenReturn(WifiEntry.CONNECTED_STATE_CONNECTED);
final LongPressWifiEntryPreference connectedWifiEntryPreference = mWifiSettings.createLongPressWifiEntryPreference(wifiEntry);
final View view = mock(View.class);
when(view.getTag()).thenReturn(connectedWifiEntryPreference);
final ContextMenu menu = mock(ContextMenu.class);
mWifiSettings.onCreateContextMenu(menu, view, null);
verify(menu).add(anyInt(), eq(WifiSettings.MENU_ID_FORGET), anyInt(), anyInt());
verify(menu).add(anyInt(), eq(WifiSettings.MENU_ID_DISCONNECT), anyInt(), anyInt());
}
use of com.android.wifitrackerlib.WifiEntry in project android_packages_apps_Settings by omnirom.
the class ConnectToWifiHandlerTest method onReceive_nonNullKeyAndUri_shouldConnectWifintry.
@Test
public void onReceive_nonNullKeyAndUri_shouldConnectWifintry() {
final Intent intent = new Intent();
final String key = "key";
intent.putExtra(ConnectToWifiHandler.KEY_CHOSEN_WIFIENTRY_KEY, key);
intent.putExtra(ConnectToWifiHandler.KEY_WIFI_SLICE_URI, com.android.settings.slices.CustomSliceRegistry.WIFI_SLICE_URI);
final WifiEntry wifiEntry = mock(WifiEntry.class);
when(mWifiScanWorker.getWifiEntry(key)).thenReturn(wifiEntry);
mHandler.onReceive(mContext, intent);
verify(wifiEntry).connect(any());
}
use of com.android.wifitrackerlib.WifiEntry in project android_packages_apps_Settings by omnirom.
the class WifiScanWorkerTest method getWifiEntry_reachableWifiKey_shouldGetReachableWifi.
@Test
public void getWifiEntry_reachableWifiKey_shouldGetReachableWifi() {
final String key = "key";
final WifiEntry reachableWifiEntry = mock(WifiEntry.class);
when(reachableWifiEntry.getKey()).thenReturn(key);
when(mWifiPickerTracker.getWifiEntries()).thenReturn(Arrays.asList(reachableWifiEntry));
assertThat(mWifiScanWorker.getWifiEntry(key)).isEqualTo(reachableWifiEntry);
}
use of com.android.wifitrackerlib.WifiEntry in project android_packages_apps_Settings by omnirom.
the class WifiNetworkListFragmentTest method onSavedWifiEntriesChanged_saeSavedWifiEntry_add2Preferences.
@Test
public void onSavedWifiEntriesChanged_saeSavedWifiEntry_add2Preferences() {
final WifiEntry wifiEntry = mock(WifiEntry.class);
when(wifiEntry.getSecurity()).thenReturn(WifiEntry.SECURITY_SAE);
when(mWifiNetworkListFragment.mSavedNetworkTracker.getSavedWifiEntries()).thenReturn(Arrays.asList(wifiEntry));
mWifiNetworkListFragment.onSavedWifiEntriesChanged();
verify(mWifiNetworkListFragment.mPreferenceGroup, times(2)).addPreference(any());
}
use of com.android.wifitrackerlib.WifiEntry in project android_packages_apps_Settings by omnirom.
the class WifiNetworkListFragmentTest method onPreferenceClick_validWifiEntryPreference_onChooseNetwork.
@Test
public void onPreferenceClick_validWifiEntryPreference_onChooseNetwork() {
final WifiEntry wifiEntry = mock(WifiEntry.class);
when(wifiEntry.getSecurityString(true)).thenReturn("WPA3");
final WifiConfiguration wifiConfig = mock(WifiConfiguration.class);
when(wifiConfig.getPrintableSsid()).thenReturn("ssid");
when(wifiEntry.getWifiConfiguration()).thenReturn(wifiConfig);
final WifiEntryPreference preference = new WifiEntryPreference(mContext, wifiEntry);
mWifiNetworkListFragment.onPreferenceClick(preference);
verify(mWifiNetworkListFragment.mOnChooseNetworkListener).onChooseNetwork(any());
}
Aggregations