Search in sources :

Example 86 with FragmentActivity

use of androidx.fragment.app.FragmentActivity in project android_packages_apps_Settings by omnirom.

the class NetworkProviderSettingsTest method onNumSavedNetworksChanged_isFinishing_ShouldNotCrash.

@Test
public void onNumSavedNetworksChanged_isFinishing_ShouldNotCrash() {
    final FragmentActivity activity = mock(FragmentActivity.class);
    when(activity.isFinishing()).thenReturn(true);
    when(mNetworkProviderSettings.getActivity()).thenReturn(activity);
    when(mNetworkProviderSettings.getContext()).thenReturn(null);
    mNetworkProviderSettings.onNumSavedNetworksChanged();
}
Also used : FragmentActivity(androidx.fragment.app.FragmentActivity) Test(org.junit.Test)

Example 87 with FragmentActivity

use of androidx.fragment.app.FragmentActivity in project android_packages_apps_Settings by omnirom.

the class KeyboardLayoutPickerControllerTest method testLifecycle_onStart_shouldRegisterInputManager.

@Test
public void testLifecycle_onStart_shouldRegisterInputManager() {
    final FragmentActivity activity = Robolectric.setupActivity(FragmentActivity.class);
    when(mFragment.getActivity()).thenReturn(activity);
    mController.onStart();
    // Register is called, but unregister should not be called.
    verify(mInputManager).registerInputDeviceListener(mController, null);
    verify(mInputManager, never()).unregisterInputDeviceListener(mController);
}
Also used : FragmentActivity(androidx.fragment.app.FragmentActivity) Test(org.junit.Test)

Example 88 with FragmentActivity

use of androidx.fragment.app.FragmentActivity in project android_packages_apps_Settings by omnirom.

the class UtilsTest method setActionBarShadowAnimation_shouldSetElevationToZero.

@Test
public void setActionBarShadowAnimation_shouldSetElevationToZero() {
    final FragmentActivity activity = Robolectric.setupActivity(FragmentActivity.class);
    final ActionBar actionBar = activity.getActionBar();
    Utils.setActionBarShadowAnimation(activity, activity.getLifecycle(), new ScrollView(mContext));
    assertThat(actionBar.getElevation()).isEqualTo(0.f);
}
Also used : FragmentActivity(androidx.fragment.app.FragmentActivity) ScrollView(android.widget.ScrollView) ActionBar(android.app.ActionBar) Test(org.junit.Test)

Example 89 with FragmentActivity

use of androidx.fragment.app.FragmentActivity in project android_packages_apps_Settings by omnirom.

the class WifiSettingsTest method onNumSavedSubscriptionsChanged_isFinishing_ShouldNotCrash.

@Test
public void onNumSavedSubscriptionsChanged_isFinishing_ShouldNotCrash() {
    final FragmentActivity activity = mock(FragmentActivity.class);
    when(activity.isFinishing()).thenReturn(true);
    when(mWifiSettings.getActivity()).thenReturn(activity);
    when(mWifiSettings.getContext()).thenReturn(null);
    mWifiSettings.onNumSavedSubscriptionsChanged();
}
Also used : FragmentActivity(androidx.fragment.app.FragmentActivity) Test(org.junit.Test)

Example 90 with FragmentActivity

use of androidx.fragment.app.FragmentActivity 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)

Aggregations

FragmentActivity (androidx.fragment.app.FragmentActivity)185 Test (org.junit.Test)71 Intent (android.content.Intent)25 Bundle (android.os.Bundle)19 View (android.view.View)11 Config (org.robolectric.annotation.Config)11 TextView (android.widget.TextView)10 Before (org.junit.Before)10 BroadcastReceiver (android.content.BroadcastReceiver)8 Fragment (androidx.fragment.app.Fragment)8 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)8 Activity (android.app.Activity)7 Resources (android.content.res.Resources)7 FragmentManager (androidx.fragment.app.FragmentManager)7 IntentFilter (android.content.IntentFilter)6 UserHandle (android.os.UserHandle)6 Preference (androidx.preference.Preference)6 SwitchPreference (androidx.preference.SwitchPreference)6 RestrictedSwitchPreference (com.android.settingslib.RestrictedSwitchPreference)6 Tile (com.android.settingslib.drawer.Tile)6