Search in sources :

Example 51 with WifiEntry

use of com.android.wifitrackerlib.WifiEntry in project android_packages_apps_Settings by omnirom.

the class NetworkProviderSettingsTest method openSubscriptionHelpPage_shouldCallStartActivityForResult.

@Test
public void openSubscriptionHelpPage_shouldCallStartActivityForResult() {
    doReturn(new Intent()).when(mNetworkProviderSettings).getHelpIntent(mContext, FAKE_URI_STRING);
    doNothing().when(mNetworkProviderSettings).startActivityForResult(any(Intent.class), anyInt());
    final WifiEntry mockWifiEntry = mock(WifiEntry.class);
    when(mockWifiEntry.getHelpUriString()).thenReturn(FAKE_URI_STRING);
    mNetworkProviderSettings.openSubscriptionHelpPage(mockWifiEntry);
    verify(mNetworkProviderSettings, times(1)).startActivityForResult(any(), anyInt());
}
Also used : WifiEntry(com.android.wifitrackerlib.WifiEntry) Intent(android.content.Intent) Test(org.junit.Test)

Example 52 with WifiEntry

use of com.android.wifitrackerlib.WifiEntry in project android_packages_apps_Settings by omnirom.

the class NetworkProviderSettingsTest method createConnectedWifiEntryPreference_internetWiFi_createConnectedPreference.

@Test
public void createConnectedWifiEntryPreference_internetWiFi_createConnectedPreference() {
    final WifiEntry wifiEntry = mock(WifiEntry.class);
    doReturn(InternetUpdater.INTERNET_WIFI).when(mInternetUpdater).getInternetType();
    final Preference p = mNetworkProviderSettings.createConnectedWifiEntryPreference(wifiEntry);
    assertThat(p instanceof ConnectedWifiEntryPreference).isTrue();
}
Also used : FooterPreference(com.android.settingslib.widget.FooterPreference) DataUsagePreference(com.android.settings.datausage.DataUsagePreference) LayoutPreference(com.android.settingslib.widget.LayoutPreference) ConnectedWifiEntryPreference(com.android.settings.wifi.ConnectedWifiEntryPreference) AddWifiNetworkPreference(com.android.settings.wifi.AddWifiNetworkPreference) Preference(androidx.preference.Preference) LongPressWifiEntryPreference(com.android.settingslib.wifi.LongPressWifiEntryPreference) WifiEntry(com.android.wifitrackerlib.WifiEntry) ConnectedWifiEntryPreference(com.android.settings.wifi.ConnectedWifiEntryPreference) Test(org.junit.Test)

Example 53 with WifiEntry

use of com.android.wifitrackerlib.WifiEntry in project android_packages_apps_Settings by omnirom.

the class NetworkProviderSettingsTest method onCreateContextMenu_shouldHaveForgetAndDisconnectMenuForConnectedWifiEntry.

@Test
public void onCreateContextMenu_shouldHaveForgetAndDisconnectMenuForConnectedWifiEntry() {
    final FragmentActivity activity = mock(FragmentActivity.class);
    when(activity.getApplicationContext()).thenReturn(mContext);
    when(mNetworkProviderSettings.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 = mNetworkProviderSettings.createLongPressWifiEntryPreference(wifiEntry);
    final View view = mock(View.class);
    when(view.getTag()).thenReturn(connectedWifiEntryPreference);
    final ContextMenu menu = mock(ContextMenu.class);
    mNetworkProviderSettings.onCreateContextMenu(menu, view, null);
    verify(menu).add(anyInt(), eq(NetworkProviderSettings.MENU_ID_FORGET), anyInt(), anyInt());
    verify(menu).add(anyInt(), eq(NetworkProviderSettings.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 54 with WifiEntry

use of com.android.wifitrackerlib.WifiEntry in project android_packages_apps_Settings by omnirom.

the class WifiUtilsTest method getWifiConfigByWifiEntry_shouldReturnCorrectConfig.

@Test
public void getWifiConfigByWifiEntry_shouldReturnCorrectConfig() {
    final String testSSID = "WifiUtilsTest";
    final WifiEntry wifiEntry = mock(WifiEntry.class);
    when(wifiEntry.getSsid()).thenReturn(testSSID);
    final WifiConfiguration config = WifiUtils.getWifiConfig(wifiEntry, null);
    assertThat(config).isNotNull();
    assertThat(config.SSID).isEqualTo("\"" + testSSID + "\"");
}
Also used : WifiConfiguration(android.net.wifi.WifiConfiguration) WifiEntry(com.android.wifitrackerlib.WifiEntry) 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