Remove FragmentUtilsTest class
We directly use FragmentController to start fragment.
Change-Id: Iff78f321165d666f96d84f001ff054257a1aaede
Fixes: 111195449
Test: robotest
diff --git a/tests/robotests/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragmentTest.java b/tests/robotests/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragmentTest.java
index 8fc17ce..bfc176f 100644
--- a/tests/robotests/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragmentTest.java
@@ -26,16 +26,17 @@
import android.view.ViewGroup;
import androidx.annotation.XmlRes;
+import androidx.fragment.app.FragmentActivity;
import com.android.settings.R;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.testutils.shadow.SettingsShadowResources;
import com.android.settings.widget.SwitchBar;
-import com.android.settingslib.testutils.FragmentTestUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.annotation.Config;
+import org.robolectric.shadows.androidx.fragment.FragmentController;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(shadows = SettingsShadowResources.SettingsShadowTheme.class)
@@ -46,7 +47,8 @@
@Test
public void createFragment_shouldOnlyAddPreferencesOnce() {
mFragment = spy(new ToggleFeaturePreferenceFragmentTestable());
- FragmentTestUtils.startFragment(mFragment);
+ FragmentController.setupFragment(mFragment, FragmentActivity.class, 0 /* containerViewId*/,
+ null /* bundle */);
// execute exactly once
verify(mFragment).addPreferencesFromResource(R.xml.placeholder_prefs);
diff --git a/tests/robotests/src/com/android/settings/applications/appinfo/ButtonActionDialogFragmentTest.java b/tests/robotests/src/com/android/settings/applications/appinfo/ButtonActionDialogFragmentTest.java
index abce50a..e9ff8fb 100644
--- a/tests/robotests/src/com/android/settings/applications/appinfo/ButtonActionDialogFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/applications/appinfo/ButtonActionDialogFragmentTest.java
@@ -27,12 +27,12 @@
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;
+import androidx.fragment.app.FragmentActivity;
import com.android.settings.R;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.testutils.shadow.SettingsShadowResourcesImpl;
import com.android.settings.testutils.shadow.ShadowAlertDialogCompat;
-import com.android.settingslib.testutils.FragmentTestUtils;
import org.junit.Before;
import org.junit.Test;
@@ -41,6 +41,7 @@
import org.mockito.MockitoAnnotations;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
+import org.robolectric.shadows.androidx.fragment.FragmentController;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(shadows = {ShadowAlertDialogCompat.class, SettingsShadowResourcesImpl.class})
@@ -75,7 +76,8 @@
@Test
public void testOnCreateDialog_forceStopDialog() {
ButtonActionDialogFragment fragment = ButtonActionDialogFragment.newInstance(FORCE_STOP_ID);
- FragmentTestUtils.startFragment(fragment);
+ FragmentController.setupFragment(fragment, FragmentActivity.class, 0 /* containerViewId */,
+ null /* bundle */);
final AlertDialog dialog = ShadowAlertDialogCompat.getLatestAlertDialog();
assertThat(dialog).isNotNull();
@@ -95,7 +97,8 @@
@Test
public void testOnCreateDialog_disableDialog() {
ButtonActionDialogFragment fragment = ButtonActionDialogFragment.newInstance(DISABLE_ID);
- FragmentTestUtils.startFragment(fragment);
+ FragmentController.setupFragment(fragment, FragmentActivity.class, 0 /* containerViewId */,
+ null /* bundle */);
final AlertDialog dialog = ShadowAlertDialogCompat.getLatestAlertDialog();
assertThat(dialog).isNotNull();
@@ -114,7 +117,8 @@
public void testOnCreateDialog_specialDisableDialog() {
ButtonActionDialogFragment fragment =
ButtonActionDialogFragment.newInstance(SPECIAL_DISABLE_ID);
- FragmentTestUtils.startFragment(fragment);
+ FragmentController.setupFragment(fragment, FragmentActivity.class, 0 /* containerViewId */,
+ null /* bundle */);
final AlertDialog dialog = ShadowAlertDialogCompat.getLatestAlertDialog();
assertThat(dialog).isNotNull();
diff --git a/tests/robotests/src/com/android/settings/biometrics/fingerprint/DeleteFingerprintDialogTest.java b/tests/robotests/src/com/android/settings/biometrics/fingerprint/DeleteFingerprintDialogTest.java
index 9479771..1d3d9ea 100644
--- a/tests/robotests/src/com/android/settings/biometrics/fingerprint/DeleteFingerprintDialogTest.java
+++ b/tests/robotests/src/com/android/settings/biometrics/fingerprint/DeleteFingerprintDialogTest.java
@@ -23,12 +23,14 @@
import android.app.Dialog;
import android.hardware.fingerprint.Fingerprint;
+import androidx.fragment.app.FragmentActivity;
+
import com.android.settings.biometrics.fingerprint.FingerprintSettings.FingerprintSettingsFragment;
-import com.android.settings.biometrics.fingerprint.FingerprintSettings.FingerprintSettingsFragment.DeleteFingerprintDialog;
+import com.android.settings.biometrics.fingerprint.FingerprintSettings
+ .FingerprintSettingsFragment.DeleteFingerprintDialog;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.testutils.shadow.SettingsShadowResourcesImpl;
import com.android.settings.testutils.shadow.ShadowFragment;
-import com.android.settingslib.testutils.FragmentTestUtils;
import org.junit.Before;
import org.junit.Test;
@@ -36,6 +38,7 @@
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.annotation.Config;
+import org.robolectric.shadows.androidx.fragment.FragmentController;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(shadows = {ShadowFragment.class, SettingsShadowResourcesImpl.class})
@@ -56,7 +59,8 @@
@Test
public void launchDialog_clickPositive_shouldDeleteFingerprint() {
- FragmentTestUtils.startFragment(mFragment);
+ FragmentController.setupFragment(mFragment, FragmentActivity.class, 0 /* containerViewId */,
+ null /* bundle */);
mFragment.onClick(mFragment.getDialog(), Dialog.BUTTON_POSITIVE);
@@ -65,7 +69,8 @@
@Test
public void launchDialog_clickNegative_shouldDoNothing() {
- FragmentTestUtils.startFragment(mFragment);
+ FragmentController.setupFragment(mFragment, FragmentActivity.class, 0 /* containerViewId */,
+ null /* bundle */);
mFragment.onClick(mFragment.getDialog(), Dialog.BUTTON_NEGATIVE);
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothPairingDialogTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothPairingDialogTest.java
index 37cc1e7..7b50e21 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothPairingDialogTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothPairingDialogTest.java
@@ -37,12 +37,12 @@
import android.widget.TextView;
import androidx.appcompat.app.AlertDialog;
+import androidx.fragment.app.FragmentActivity;
import com.android.settings.R;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.testutils.shadow.SettingsShadowResourcesImpl;
import com.android.settings.testutils.shadow.ShadowAlertDialogCompat;
-import com.android.settingslib.testutils.FragmentTestUtils;
import org.junit.Before;
import org.junit.Test;
@@ -51,6 +51,7 @@
import org.mockito.MockitoAnnotations;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
+import org.robolectric.shadows.androidx.fragment.FragmentController;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(shadows = {ShadowAlertDialogCompat.class, SettingsShadowResourcesImpl.class})
@@ -190,7 +191,8 @@
BluetoothPairingDialogFragment frag = new BluetoothPairingDialogFragment();
// this should throw an error
- FragmentTestUtils.startFragment(frag);
+ FragmentController.setupFragment(frag, FragmentActivity.class, 0 /* containerViewId */,
+ null /* bundle */);
fail("Starting the fragment with no controller set should have thrown an exception.");
}
@@ -286,7 +288,7 @@
// verify that the checkbox is visible and that the device name is correct
CheckBox sharingCheckbox =
- frag.getmDialog().findViewById(R.id.phonebook_sharing_message_confirm_pin);
+ frag.getmDialog().findViewById(R.id.phonebook_sharing_message_confirm_pin);
assertThat(sharingCheckbox.getVisibility()).isEqualTo(View.VISIBLE);
}
@@ -304,7 +306,7 @@
// verify that the checkbox is gone
CheckBox sharingCheckbox =
- frag.getmDialog().findViewById(R.id.phonebook_sharing_message_confirm_pin);
+ frag.getmDialog().findViewById(R.id.phonebook_sharing_message_confirm_pin);
assertThat(sharingCheckbox.getVisibility()).isEqualTo(View.GONE);
}
@@ -450,7 +452,8 @@
frag.setPairingController(controller);
assertThat(frag.isPairingDialogActivitySet()).isFalse();
frag.setPairingDialogActivity(dialogActivity);
- FragmentTestUtils.startFragment(frag);
+ FragmentController.setupFragment(frag, FragmentActivity.class, 0 /* containerViewId */,
+ null /* bundle */);
assertThat(frag.getmDialog()).isNotNull();
assertThat(frag.isPairingControllerSet()).isTrue();
assertThat(frag.isPairingDialogActivitySet()).isTrue();
diff --git a/tests/robotests/src/com/android/settings/bluetooth/LocalDeviceNameDialogFragmentTest.java b/tests/robotests/src/com/android/settings/bluetooth/LocalDeviceNameDialogFragmentTest.java
index d9867cf..b455fa2 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/LocalDeviceNameDialogFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/LocalDeviceNameDialogFragmentTest.java
@@ -28,13 +28,13 @@
import android.view.inputmethod.InputMethodManager;
import androidx.appcompat.app.AlertDialog;
+import androidx.fragment.app.FragmentActivity;
import com.android.settings.R;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.testutils.shadow.SettingsShadowResourcesImpl;
import com.android.settings.testutils.shadow.ShadowAlertDialogCompat;
import com.android.settingslib.bluetooth.LocalBluetoothManager;
-import com.android.settingslib.testutils.FragmentTestUtils;
import org.junit.After;
import org.junit.Before;
@@ -44,6 +44,7 @@
import org.mockito.MockitoAnnotations;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
+import org.robolectric.shadows.androidx.fragment.FragmentController;
import org.robolectric.util.ReflectionHelpers;
@RunWith(SettingsRobolectricTestRunner.class)
@@ -73,7 +74,8 @@
@Test
public void diaglogTriggersShowSoftInput() {
- FragmentTestUtils.startFragment(mFragment);
+ FragmentController.setupFragment(mFragment, FragmentActivity.class, 0 /* containerViewId */,
+ null /* bundle */);
AlertDialog dialog = ShadowAlertDialogCompat.getLatestAlertDialog();
assertThat(dialog).isNotNull();
View view = dialog.findViewById(R.id.edittext);
diff --git a/tests/robotests/src/com/android/settings/bluetooth/RemoteDeviceNameDialogFragmentTest.java b/tests/robotests/src/com/android/settings/bluetooth/RemoteDeviceNameDialogFragmentTest.java
index df3ffbb..31dec3f 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/RemoteDeviceNameDialogFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/RemoteDeviceNameDialogFragmentTest.java
@@ -31,6 +31,7 @@
import android.widget.EditText;
import androidx.appcompat.app.AlertDialog;
+import androidx.fragment.app.FragmentActivity;
import com.android.settings.R;
import com.android.settings.testutils.FakeFeatureFactory;
@@ -38,7 +39,6 @@
import com.android.settings.testutils.shadow.SettingsShadowResourcesImpl;
import com.android.settings.testutils.shadow.ShadowDynamicLayout;
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
-import com.android.settingslib.testutils.FragmentTestUtils;
import org.junit.Before;
import org.junit.Test;
@@ -48,6 +48,7 @@
import org.mockito.MockitoAnnotations;
import org.robolectric.annotation.Config;
import org.robolectric.shadows.ShadowDialog;
+import org.robolectric.shadows.androidx.fragment.FragmentController;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(shadows = {SettingsShadowResourcesImpl.class, ShadowDynamicLayout.class})
@@ -77,7 +78,8 @@
*/
AlertDialog startDialog(String deviceName) {
when(mCachedDevice.getName()).thenReturn(deviceName);
- FragmentTestUtils.startFragment(mFragment);
+ FragmentController.setupFragment(mFragment, FragmentActivity.class, 0 /* containerViewId */,
+ null /* bundle */);
return (AlertDialog) ShadowDialog.getLatestDialog();
}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/RestrictedAppDetailsTest.java b/tests/robotests/src/com/android/settings/fuelgauge/RestrictedAppDetailsTest.java
index f1e92e8..e5a4b3d 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/RestrictedAppDetailsTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/RestrictedAppDetailsTest.java
@@ -32,6 +32,7 @@
import android.util.SparseLongArray;
import androidx.appcompat.app.AlertDialog;
+import androidx.fragment.app.FragmentActivity;
import androidx.preference.CheckBoxPreference;
import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceManager;
@@ -48,7 +49,6 @@
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.testutils.shadow.SettingsShadowResourcesImpl;
import com.android.settings.testutils.shadow.ShadowAlertDialogCompat;
-import com.android.settingslib.testutils.FragmentTestUtils;
import org.junit.Before;
import org.junit.Test;
@@ -58,6 +58,7 @@
import org.mockito.MockitoAnnotations;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
+import org.robolectric.shadows.androidx.fragment.FragmentController;
import java.util.ArrayList;
import java.util.List;
@@ -167,7 +168,8 @@
final BatteryTipDialogFragment dialogFragment = mRestrictedAppDetails.createDialogFragment(
mAppInfo, true);
- FragmentTestUtils.startFragment(dialogFragment);
+ FragmentController.setupFragment(dialogFragment, FragmentActivity.class,
+ 0 /* containerViewId */, null /* bundle */);
final AlertDialog dialog = ShadowAlertDialogCompat.getLatestAlertDialog();
ShadowAlertDialogCompat shadowDialog = ShadowAlertDialogCompat.shadowOf(dialog);
@@ -179,7 +181,8 @@
final BatteryTipDialogFragment dialogFragment = mRestrictedAppDetails.createDialogFragment(
mAppInfo, false);
- FragmentTestUtils.startFragment(dialogFragment);
+ FragmentController.setupFragment(dialogFragment, FragmentActivity.class,
+ 0 /* containerViewId */, null /* bundle */);
final AlertDialog dialog = ShadowAlertDialogCompat.getLatestAlertDialog();
ShadowAlertDialogCompat shadowDialog = ShadowAlertDialogCompat.shadowOf(dialog);
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/BatteryTipDialogFragmentTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/BatteryTipDialogFragmentTest.java
index 9869300..bd4f899 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/BatteryTipDialogFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/BatteryTipDialogFragmentTest.java
@@ -25,6 +25,7 @@
import android.text.format.DateUtils;
import androidx.appcompat.app.AlertDialog;
+import androidx.fragment.app.FragmentActivity;
import com.android.settings.R;
import com.android.settings.fuelgauge.Estimate;
@@ -38,7 +39,6 @@
import com.android.settings.testutils.shadow.SettingsShadowResourcesImpl;
import com.android.settings.testutils.shadow.ShadowAlertDialogCompat;
import com.android.settings.testutils.shadow.ShadowUtils;
-import com.android.settingslib.testutils.FragmentTestUtils;
import org.junit.Before;
import org.junit.Test;
@@ -47,6 +47,7 @@
import org.robolectric.Robolectric;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
+import org.robolectric.shadows.androidx.fragment.FragmentController;
import java.util.ArrayList;
import java.util.List;
@@ -106,7 +107,8 @@
mDialogFragment = BatteryTipDialogFragment.newInstance(mHighUsageTip, METRICS_KEY);
- FragmentTestUtils.startFragment(mDialogFragment);
+ FragmentController.setupFragment(mDialogFragment, FragmentActivity.class,
+ 0 /* containerViewId */, null /* bundle */);
Robolectric.getForegroundThreadScheduler().advanceToLastPostedRunnable();
@@ -121,7 +123,8 @@
public void testOnCreateDialog_restrictOneAppTip_fireRestrictOneAppDialog() {
mDialogFragment = BatteryTipDialogFragment.newInstance(mRestrictedOneAppTip, METRICS_KEY);
- FragmentTestUtils.startFragment(mDialogFragment);
+ FragmentController.setupFragment(mDialogFragment, FragmentActivity.class,
+ 0 /* containerViewId */, null /* bundle */);
final AlertDialog dialog = ShadowAlertDialogCompat.getLatestAlertDialog();
ShadowAlertDialogCompat shadowDialog = ShadowAlertDialogCompat.shadowOf(dialog);
@@ -140,7 +143,8 @@
mDialogFragment = BatteryTipDialogFragment.newInstance(mRestrictTwoAppsTip, METRICS_KEY);
- FragmentTestUtils.startFragment(mDialogFragment);
+ FragmentController.setupFragment(mDialogFragment, FragmentActivity.class,
+ 0 /* containerViewId */, null /* bundle */);
Robolectric.getForegroundThreadScheduler().advanceToLastPostedRunnable();
@@ -169,7 +173,8 @@
mDialogFragment = BatteryTipDialogFragment.newInstance(restrictSixAppsTip, METRICS_KEY);
- FragmentTestUtils.startFragment(mDialogFragment);
+ FragmentController.setupFragment(mDialogFragment, FragmentActivity.class,
+ 0 /* containerViewId */, null /* bundle */);
Robolectric.getForegroundThreadScheduler().advanceToLastPostedRunnable();
@@ -189,7 +194,8 @@
mDialogFragment = BatteryTipDialogFragment.newInstance(mUnrestrictAppTip, METRICS_KEY);
ShadowUtils.setApplicationLabel(PACKAGE_NAME, DISPLAY_NAME);
- FragmentTestUtils.startFragment(mDialogFragment);
+ FragmentController.setupFragment(mDialogFragment, FragmentActivity.class,
+ 0 /* containerViewId */, null /* bundle */);
final AlertDialog dialog = ShadowAlertDialogCompat.getLatestAlertDialog();
ShadowAlertDialogCompat shadowDialog = ShadowAlertDialogCompat.shadowOf(dialog);
@@ -204,7 +210,8 @@
doReturn(AVERAGE_TIME_MS).when(mSummaryTip).getAverageTimeMs();
mDialogFragment = BatteryTipDialogFragment.newInstance(mSummaryTip, METRICS_KEY);
- FragmentTestUtils.startFragment(mDialogFragment);
+ FragmentController.setupFragment(mDialogFragment, FragmentActivity.class,
+ 0 /* containerViewId */, null /* bundle */);
final AlertDialog dialog = ShadowAlertDialogCompat.getLatestAlertDialog();
ShadowAlertDialogCompat shadowDialog = ShadowAlertDialogCompat.shadowOf(dialog);
diff --git a/tests/robotests/src/com/android/settings/password/ChooseLockTypeDialogFragmentTest.java b/tests/robotests/src/com/android/settings/password/ChooseLockTypeDialogFragmentTest.java
index 76c9aba..3b38a56 100644
--- a/tests/robotests/src/com/android/settings/password/ChooseLockTypeDialogFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/password/ChooseLockTypeDialogFragmentTest.java
@@ -28,19 +28,20 @@
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;
+import androidx.fragment.app.FragmentActivity;
import com.android.settings.R;
import com.android.settings.password.ChooseLockTypeDialogFragment.OnLockTypeSelectedListener;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.testutils.shadow.SettingsShadowResourcesImpl;
import com.android.settings.testutils.shadow.ShadowAlertDialogCompat;
-import com.android.settingslib.testutils.FragmentTestUtils;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
+import org.robolectric.shadows.androidx.fragment.FragmentController;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(shadows = {SettingsShadowResourcesImpl.class, ShadowAlertDialogCompat.class})
@@ -53,7 +54,8 @@
public void setUp() {
mContext = RuntimeEnvironment.application;
mFragment = new TestFragment();
- FragmentTestUtils.startFragment(mFragment);
+ FragmentController.setupFragment(mFragment, FragmentActivity.class, 0 /* containerViewId */,
+ null /* bundle */);
}
@Test