Search in sources :

Example 21 with WifiEntry

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());
}
Also used : FragmentActivity(androidx.fragment.app.FragmentActivity) LongPressWifiEntryPreference(com.android.settingslib.wifi.LongPressWifiEntryPreference) WifiEntry(com.android.wifitrackerlib.WifiEntry) ContextMenu(android.view.ContextMenu) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) Test(org.junit.Test)

Example 22 with WifiEntry

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());
}
Also used : WifiEntry(com.android.wifitrackerlib.WifiEntry) Intent(android.content.Intent) Test(org.junit.Test)

Example 23 with WifiEntry

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);
}
Also used : WifiEntry(com.android.wifitrackerlib.WifiEntry) Test(org.junit.Test)

Example 24 with WifiEntry

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());
}
Also used : WifiEntry(com.android.wifitrackerlib.WifiEntry) Test(org.junit.Test)

Example 25 with WifiEntry

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());
}
Also used : WifiConfiguration(android.net.wifi.WifiConfiguration) WifiEntry(com.android.wifitrackerlib.WifiEntry) WifiEntryPreference(com.android.settingslib.wifi.WifiEntryPreference) Test(org.junit.Test)

Aggregations

WifiEntry (com.android.wifitrackerlib.WifiEntry)54 Test (org.junit.Test)28 WifiConfiguration (android.net.wifi.WifiConfiguration)10 WifiEntryPreference (com.android.settingslib.wifi.WifiEntryPreference)10 LongPressWifiEntryPreference (com.android.settingslib.wifi.LongPressWifiEntryPreference)8 Intent (android.content.Intent)7 Preference (androidx.preference.Preference)5 Context (android.content.Context)4 Bundle (android.os.Bundle)4 DataUsagePreference (com.android.settings.datausage.DataUsagePreference)4 WifiManager (android.net.wifi.WifiManager)3 Handler (android.os.Handler)3 View (android.view.View)3 FragmentActivity (androidx.fragment.app.FragmentActivity)3 SubSettingLauncher (com.android.settings.core.SubSettingLauncher)3 AddWifiNetworkPreference (com.android.settings.wifi.AddWifiNetworkPreference)3 ConnectedWifiEntryPreference (com.android.settings.wifi.ConnectedWifiEntryPreference)3 FooterPreference (com.android.settingslib.widget.FooterPreference)3 LayoutPreference (com.android.settingslib.widget.LayoutPreference)3 ArrayList (java.util.ArrayList)3