Migrate to use instrumentation classes from settingslib.

Test: Compiles. Manually tested.
Change-Id: Ie5515bb0fe3e621fc7723a9b04ba23e4bfa9c401
This commit is contained in:
Leif Hendrik Wilden
2018-01-11 10:15:36 -08:00
parent 2ce430afc4
commit 1546cca529
92 changed files with 177 additions and 1250 deletions

View File

@@ -17,6 +17,7 @@ package com.android.settings;
import android.app.Dialog;
import android.app.Fragment;
import android.content.Context;
import org.junit.Before;
import org.junit.Test;
@@ -38,6 +39,8 @@ public class SettingsDialogFragmentTest {
private static final int DIALOG_ID = 15;
@Mock
private Context mContext;
@Mock
private DialogCreatableFragment mDialogCreatable;
private SettingsPreferenceFragment.SettingsDialogFragment mDialogFragment;
@@ -53,9 +56,10 @@ public class SettingsDialogFragmentTest {
mDialogFragment =
new SettingsPreferenceFragment.SettingsDialogFragment(mDialogCreatable, DIALOG_ID);
mDialogFragment.onAttach(mContext);
mDialogFragment.getMetricsCategory();
// getDialogMetricsCategory called in constructor, and explicitly in test.
// getDialogMetricsCategory called in onAttach, and explicitly in test.
verify(mDialogCreatable, times(2)).getDialogMetricsCategory(DIALOG_ID);
}
@@ -66,6 +70,7 @@ public class SettingsDialogFragmentTest {
try {
mDialogFragment = new SettingsPreferenceFragment.SettingsDialogFragment(
mDialogCreatable, DIALOG_ID);
mDialogFragment.onAttach(mContext);
} catch (IllegalStateException e) {
// getDialogMetricsCategory called in constructor
verify(mDialogCreatable).getDialogMetricsCategory(DIALOG_ID);