Search in sources :

Example 41 with WifiEntry

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

the class NetworkProviderSettings method launchNetworkDetailsFragment.

private void launchNetworkDetailsFragment(LongPressWifiEntryPreference pref) {
    final WifiEntry wifiEntry = pref.getWifiEntry();
    final Context context = getContext();
    final CharSequence title = FeatureFlagUtils.isEnabled(context, FeatureFlags.WIFI_DETAILS_DATAUSAGE_HEADER) ? wifiEntry.getTitle() : context.getText(R.string.pref_title_network_details);
    final Bundle bundle = new Bundle();
    bundle.putString(WifiNetworkDetailsFragment.KEY_CHOSEN_WIFIENTRY_KEY, wifiEntry.getKey());
    new SubSettingLauncher(context).setTitleText(title).setDestination(WifiNetworkDetailsFragment.class.getName()).setArguments(bundle).setSourceMetricsCategory(getMetricsCategory()).launch();
}
Also used : Context(android.content.Context) SubSettingLauncher(com.android.settings.core.SubSettingLauncher) Bundle(android.os.Bundle) WifiEntry(com.android.wifitrackerlib.WifiEntry)

Example 42 with WifiEntry

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

the class SavedAccessPointsPreferenceController2Test method displayPreference_noAccessPoint_shouldRemoveIt.

@Test
public void displayPreference_noAccessPoint_shouldRemoveIt() {
    final String title = "ssid_title";
    final String key = "key";
    final WifiEntry mockWifiEntry = mock(WifiEntry.class);
    when(mockWifiEntry.getTitle()).thenReturn(title);
    when(mockWifiEntry.getKey()).thenReturn(key);
    final WifiEntryPreference preference = new WifiEntryPreference(mContext, mockWifiEntry);
    preference.setKey(key);
    mPreferenceCategory.addPreference(preference);
    mController.displayPreference(mPreferenceScreen, new ArrayList<>());
    assertThat(mPreferenceCategory.getPreferenceCount()).isEqualTo(0);
}
Also used : WifiEntry(com.android.wifitrackerlib.WifiEntry) WifiEntryPreference(com.android.settingslib.wifi.WifiEntryPreference) Test(org.junit.Test)

Example 43 with WifiEntry

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

the class SavedAccessPointsPreferenceController2Test method displayPreference_oneAccessPoint_shouldListIt.

@Test
public void displayPreference_oneAccessPoint_shouldListIt() {
    final String title = "ssid_title";
    final WifiEntry mockWifiEntry = mock(WifiEntry.class);
    when(mockWifiEntry.getTitle()).thenReturn(title);
    final ArgumentCaptor<WifiEntryPreference> captor = ArgumentCaptor.forClass(WifiEntryPreference.class);
    mController.displayPreference(mPreferenceScreen, Arrays.asList(mockWifiEntry));
    verify(mPreferenceCategory).addPreference(captor.capture());
    final List<WifiEntryPreference> prefs = captor.getAllValues();
    assertThat(prefs.size()).isEqualTo(1);
    assertThat(prefs.get(0).getTitle()).isEqualTo(title);
}
Also used : WifiEntry(com.android.wifitrackerlib.WifiEntry) WifiEntryPreference(com.android.settingslib.wifi.WifiEntryPreference) Test(org.junit.Test)

Example 44 with WifiEntry

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

the class SavedAccessPointsPreferenceController2Test method onPreferenceClick_shouldCallShowWifiPage.

@Test
public void onPreferenceClick_shouldCallShowWifiPage() {
    mContext = spy(RuntimeEnvironment.application);
    doNothing().when(mContext).startActivity(any());
    doReturn(mContext).when(mSettings).getContext();
    final String title = "ssid_title";
    final String key = "key";
    final WifiEntry mockWifiEntry = mock(WifiEntry.class);
    when(mockWifiEntry.getTitle()).thenReturn(title);
    when(mockWifiEntry.getKey()).thenReturn(key);
    final WifiEntryPreference preference = new WifiEntryPreference(mContext, mockWifiEntry);
    preference.setKey(key);
    mController.onPreferenceClick(preference);
    verify(mSettings, times(1)).showWifiPage(key, title);
}
Also used : WifiEntry(com.android.wifitrackerlib.WifiEntry) WifiEntryPreference(com.android.settingslib.wifi.WifiEntryPreference) Test(org.junit.Test)

Example 45 with WifiEntry

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

the class ConnectToWifiHandlerTest method onConnectResult_failNoConfig_shouldStartActivity.

@Test
public void onConnectResult_failNoConfig_shouldStartActivity() {
    final String key = "key";
    final WifiEntry wifiEntry = mock(WifiEntry.class);
    when(wifiEntry.getKey()).thenReturn(key);
    final ConnectToWifiHandler.WifiEntryConnectCallback callback = spy(new ConnectToWifiHandler.WifiEntryConnectCallback(mContext, wifiEntry));
    callback.onConnectResult(ConnectCallback.CONNECT_STATUS_FAILURE_NO_CONFIG);
    final ArgumentCaptor<Intent> argument = ArgumentCaptor.forClass(Intent.class);
    verify(mContext).startActivity(argument.capture());
    assertThat(argument.getValue().getStringExtra(WifiDialogActivity.KEY_CHOSEN_WIFIENTRY_KEY)).isEqualTo(key);
    assertThat(argument.getValue().getFlags() & Intent.FLAG_ACTIVITY_NEW_TASK).isEqualTo(Intent.FLAG_ACTIVITY_NEW_TASK);
}
Also used : WifiEntry(com.android.wifitrackerlib.WifiEntry) Intent(android.content.Intent) 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