Use ChooseLockGeneric When Started By Admin App am: 7430932305
Change-Id: I78fd46587c0d3c598867c972bb9c9df038b30a1b
This commit is contained in:
@@ -46,6 +46,7 @@ import com.android.settings.biometrics.BiometricEnrollBase;
|
||||
import com.android.settings.password.ChooseLockGeneric.ChooseLockGenericFragment;
|
||||
import com.android.settings.search.SearchFeatureProvider;
|
||||
import com.android.settings.testutils.shadow.ShadowLockPatternUtils;
|
||||
import com.android.settings.testutils.shadow.ShadowPersistentDataBlockManager;
|
||||
import com.android.settings.testutils.shadow.ShadowStorageManager;
|
||||
import com.android.settings.testutils.shadow.ShadowUserManager;
|
||||
import com.android.settings.testutils.shadow.ShadowUtils;
|
||||
@@ -63,6 +64,7 @@ import org.robolectric.annotation.Config;
|
||||
@Config(
|
||||
shadows = {
|
||||
ShadowLockPatternUtils.class,
|
||||
ShadowPersistentDataBlockManager.class,
|
||||
ShadowStorageManager.class,
|
||||
ShadowUserManager.class,
|
||||
ShadowUtils.class
|
||||
@@ -82,11 +84,13 @@ public class ChooseLockGenericTest {
|
||||
public void tearDown() {
|
||||
Global.putInt(application.getContentResolver(), Global.DEVICE_PROVISIONED, 1);
|
||||
ShadowStorageManager.reset();
|
||||
ShadowPersistentDataBlockManager.reset();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onCreate_deviceNotProvisioned_shouldFinishActivity() {
|
||||
public void onCreate_deviceNotProvisioned_persistentDataExists_shouldFinishActivity() {
|
||||
Global.putInt(application.getContentResolver(), Global.DEVICE_PROVISIONED, 0);
|
||||
ShadowPersistentDataBlockManager.setDataBlockSize(1000);
|
||||
|
||||
initActivity(null);
|
||||
assertThat(mActivity.isFinishing()).isTrue();
|
||||
@@ -191,7 +195,18 @@ public class ChooseLockGenericTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updatePreferencesOrFinish_callingAppIsAdmin_footerInvisible() {
|
||||
public void updatePreferencesOrFinish_callingAppIsAdmin_deviceProvisioned_footerInvisible() {
|
||||
initActivity(new Intent().putExtra(EXTRA_KEY_IS_CALLING_APP_ADMIN, true));
|
||||
|
||||
mFragment.updatePreferencesOrFinish(/* isRecreatingActivity= */ false);
|
||||
|
||||
FooterPreference footer = mFragment.findPreference(KEY_LOCK_SETTINGS_FOOTER);
|
||||
assertThat(footer.isVisible()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updatePreferencesOrFinish_callingAppIsAdmin_deviceNotProvisioned_footerInvisible() {
|
||||
Global.putInt(application.getContentResolver(), Global.DEVICE_PROVISIONED, 0);
|
||||
initActivity(new Intent().putExtra(EXTRA_KEY_IS_CALLING_APP_ADMIN, true));
|
||||
|
||||
mFragment.updatePreferencesOrFinish(/* isRecreatingActivity= */ false);
|
||||
|
@@ -45,6 +45,8 @@ import com.android.settings.testutils.FakeFeatureFactory;
|
||||
import com.android.settings.testutils.shadow.ShadowPasswordUtils;
|
||||
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
||||
|
||||
import com.google.android.setupcompat.util.WizardManagerHelper;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -111,6 +113,7 @@ public class SetNewPasswordActivityTest {
|
||||
activity.launchChooseLock(new Bundle());
|
||||
ShadowActivity shadowActivity = Shadows.shadowOf(activity);
|
||||
Intent intent = getLaunchChooseLockIntent(shadowActivity);
|
||||
intent.putExtra(WizardManagerHelper.EXTRA_IS_FIRST_RUN, true);
|
||||
|
||||
assertThat(intent.getComponent())
|
||||
.isEqualTo(new ComponentName(activity, SetupChooseLockGeneric.class));
|
||||
|
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.testutils.shadow;
|
||||
|
||||
import android.service.persistentdata.PersistentDataBlockManager;
|
||||
|
||||
import org.robolectric.annotation.Implementation;
|
||||
import org.robolectric.annotation.Implements;
|
||||
import org.robolectric.annotation.Resetter;
|
||||
|
||||
@Implements(PersistentDataBlockManager.class)
|
||||
public class ShadowPersistentDataBlockManager {
|
||||
private static int sDataBlockSize = 0;
|
||||
|
||||
@Resetter
|
||||
public static void reset() {
|
||||
sDataBlockSize = 0;
|
||||
}
|
||||
|
||||
@Implementation
|
||||
protected int getDataBlockSize() {
|
||||
return sDataBlockSize;
|
||||
}
|
||||
|
||||
public static void setDataBlockSize(int dataBlockSize) {
|
||||
sDataBlockSize = dataBlockSize;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user