Fix InstantiationException on fragment
Since we overrided the empty constructor, it can't find a empty constructor when Fragment tries to instantiate a fragment in framework. So, we can't override this constructor, and then just use newInstance() to initialize and setup a new Fragment. Test: robotest Change-Id: Ifcd1c1771bc69d947caeee5c5bc055c4f94365c2 Fixes: 115676209
This commit is contained in:
@@ -51,8 +51,8 @@ public class SettingsDialogFragmentTest {
|
||||
public void testGetMetrics_shouldGetMetricFromDialogCreatable() {
|
||||
when(mDialogCreatable.getDialogMetricsCategory(DIALOG_ID)).thenReturn(1);
|
||||
|
||||
mDialogFragment =
|
||||
new SettingsPreferenceFragment.SettingsDialogFragment(mDialogCreatable, DIALOG_ID);
|
||||
mDialogFragment = SettingsPreferenceFragment.SettingsDialogFragment.newInstance(
|
||||
mDialogCreatable, DIALOG_ID);
|
||||
mDialogFragment.onAttach(RuntimeEnvironment.application);
|
||||
mDialogFragment.getMetricsCategory();
|
||||
|
||||
@@ -65,8 +65,8 @@ public class SettingsDialogFragmentTest {
|
||||
when(mDialogCreatable.getDialogMetricsCategory(DIALOG_ID)).thenReturn(-1);
|
||||
|
||||
try {
|
||||
mDialogFragment =
|
||||
new SettingsPreferenceFragment.SettingsDialogFragment(mDialogCreatable, DIALOG_ID);
|
||||
mDialogFragment = SettingsPreferenceFragment.SettingsDialogFragment.newInstance(
|
||||
mDialogCreatable, DIALOG_ID);
|
||||
mDialogFragment.onAttach(RuntimeEnvironment.application);
|
||||
fail("Should fail with IllegalStateException");
|
||||
} catch (IllegalStateException e) {
|
||||
|
Reference in New Issue
Block a user