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();
}
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);
}
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);
}
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);
}
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);
}
Aggregations