Merge changes Icc02469b,I506edc8a

* changes:
  move security test package to sdk 26
  Update OwnerInfoPrefCtrlTest to sdk 26
This commit is contained in:
TreeHugger Robot
2017-12-02 00:35:25 +00:00
committed by Android (Google) Code Review
5 changed files with 15 additions and 9 deletions

View File

@@ -36,7 +36,7 @@ import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class) @RunWith(SettingsRobolectricTestRunner.class)
@Config( @Config(
manifest = TestConfig.MANIFEST_PATH, manifest = TestConfig.MANIFEST_PATH,
sdk = TestConfig.SDK_VERSION, sdk = TestConfig.SDK_VERSION_O,
shadows = ShadowEventLogWriter.class shadows = ShadowEventLogWriter.class
) )
public class ConfigureKeyGuardDialogTest { public class ConfigureKeyGuardDialogTest {

View File

@@ -42,7 +42,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
@RunWith(SettingsRobolectricTestRunner.class) @RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION) @Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class EncryptionAndCredentialTest { public class EncryptionAndCredentialTest {
@Mock @Mock

View File

@@ -30,7 +30,7 @@ import org.robolectric.annotation.Config;
import java.util.List; import java.util.List;
@RunWith(SettingsRobolectricTestRunner.class) @RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION) @Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class LockscreenDashboardFragmentTest { public class LockscreenDashboardFragmentTest {
private LockscreenDashboardFragment mFragment; private LockscreenDashboardFragment mFragment;

View File

@@ -16,13 +16,14 @@
package com.android.settings.security; package com.android.settings.security;
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Answers.RETURNS_DEEP_STUBS;
import static org.mockito.Matchers.any; import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyInt; import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyString; import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy; import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
@@ -30,6 +31,7 @@ import android.app.FragmentManager;
import android.app.FragmentTransaction; import android.app.FragmentTransaction;
import android.content.Context; import android.content.Context;
import android.support.v14.preference.PreferenceFragment; import android.support.v14.preference.PreferenceFragment;
import android.support.v7.preference.PreferenceManager;
import android.support.v7.preference.PreferenceScreen; import android.support.v7.preference.PreferenceScreen;
import com.android.internal.widget.LockPatternUtils; import com.android.internal.widget.LockPatternUtils;
@@ -49,14 +51,16 @@ import org.robolectric.shadows.ShadowApplication;
import org.robolectric.util.ReflectionHelpers; import org.robolectric.util.ReflectionHelpers;
@RunWith(SettingsRobolectricTestRunner.class) @RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION) @Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class OwnerInfoPreferenceControllerTest { public class OwnerInfoPreferenceControllerTest {
@Mock(answer = RETURNS_DEEP_STUBS) @Mock
private PreferenceFragment mFragment; private PreferenceFragment mFragment;
@Mock @Mock
private PreferenceScreen mScreen; private PreferenceScreen mScreen;
@Mock @Mock
private PreferenceManager mPreferenceManager;
@Mock
private FragmentManager mFragmentManager; private FragmentManager mFragmentManager;
@Mock @Mock
private FragmentTransaction mFragmentTransaction; private FragmentTransaction mFragmentTransaction;
@@ -76,7 +80,8 @@ public class OwnerInfoPreferenceControllerTest {
when(mFragment.isAdded()).thenReturn(true); when(mFragment.isAdded()).thenReturn(true);
when(mFragment.getPreferenceScreen()).thenReturn(mScreen); when(mFragment.getPreferenceScreen()).thenReturn(mScreen);
when(mFragment.getPreferenceManager().getContext()).thenReturn(mContext); when(mFragment.getPreferenceManager()).thenReturn(mPreferenceManager);
when(mPreference.getContext()).thenReturn(mContext);
when(mFragment.getFragmentManager()).thenReturn(mFragmentManager); when(mFragment.getFragmentManager()).thenReturn(mFragmentManager);
when(mFragmentManager.beginTransaction()).thenReturn(mFragmentTransaction); when(mFragmentManager.beginTransaction()).thenReturn(mFragmentTransaction);
@@ -187,7 +192,8 @@ public class OwnerInfoPreferenceControllerTest {
preference.performClick(); preference.performClick();
verify(mFragment).getFragmentManager(); // Called once in setTargetFragment, and a second time to display the fragment.
verify(mFragment, times(2)).getFragmentManager();
verify(mFragment.getFragmentManager().beginTransaction()) verify(mFragment.getFragmentManager().beginTransaction())
.add(any(OwnerInfoSettings.class), anyString()); .add(any(OwnerInfoSettings.class), anyString());
} }

View File

@@ -53,7 +53,7 @@ import org.robolectric.annotation.Config;
import org.robolectric.shadows.ShadowLooper; import org.robolectric.shadows.ShadowLooper;
@RunWith(SettingsRobolectricTestRunner.class) @RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION) @Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class SecurityFeatureProviderImplTest { public class SecurityFeatureProviderImplTest {
private static final String MOCK_KEY = "key"; private static final String MOCK_KEY = "key";