Migrate to use instrumentation classes from settingslib.

Test: Compiles. Manually tested.
Change-Id: I70a6e76cc8440547746ecc008c32bd06a7de8161
This commit is contained in:
Leif Hendrik Wilden
2018-01-11 10:15:36 -08:00
parent adb949da4c
commit 28dee1f086
93 changed files with 231 additions and 1252 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);