Use external/robolectric-shadows/run_robotests.mk

This allows Settings to test against the latest framework changes.

Also replaced TestConfig with traditional robolectric.properties.

Bug: 73173204
Bug: 73892008
Test: make -j56 RunSettingsRoboTests
Change-Id: I3135b4fa5f095ba79b282a76f45dd9baa2584bc7
This commit is contained in:
James Lemieux
2018-02-26 00:51:42 -08:00
parent 229a6a2bc4
commit 22a39c2b93
752 changed files with 5096 additions and 9182 deletions

View File

@@ -15,32 +15,28 @@
*/
package com.android.settings;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.app.Dialog;
import android.app.Fragment;
import android.content.Context;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.annotation.Config;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
public class SettingsDialogFragmentTest {
private static final int DIALOG_ID = 15;
@Mock
private Context mContext;
@Mock
private DialogCreatableFragment mDialogCreatable;
private SettingsPreferenceFragment.SettingsDialogFragment mDialogFragment;
@@ -56,7 +52,7 @@ public class SettingsDialogFragmentTest {
mDialogFragment =
new SettingsPreferenceFragment.SettingsDialogFragment(mDialogCreatable, DIALOG_ID);
mDialogFragment.onAttach(mContext);
mDialogFragment.onAttach(RuntimeEnvironment.application);
mDialogFragment.getMetricsCategory();
// getDialogMetricsCategory called in onAttach, and explicitly in test.
@@ -68,15 +64,15 @@ public class SettingsDialogFragmentTest {
when(mDialogCreatable.getDialogMetricsCategory(DIALOG_ID)).thenReturn(-1);
try {
mDialogFragment = new SettingsPreferenceFragment.SettingsDialogFragment(
mDialogCreatable, DIALOG_ID);
mDialogFragment.onAttach(mContext);
mDialogFragment =
new SettingsPreferenceFragment.SettingsDialogFragment(mDialogCreatable, DIALOG_ID);
mDialogFragment.onAttach(RuntimeEnvironment.application);
fail("Should fail with IllegalStateException");
} catch (IllegalStateException e) {
// getDialogMetricsCategory called in constructor
verify(mDialogCreatable).getDialogMetricsCategory(DIALOG_ID);
return;
}
fail("Should fail with IllegalStateException");
}
public static class DialogCreatableFragment extends Fragment implements DialogCreatable {