Snap for 5199742 from eb5e435dc6 to qt-release
Change-Id: I9eb9cfe1a6c45eca4ddc9db67cfaa345ce98e3e4
This commit is contained in:
@@ -21,7 +21,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:icon="@drawable/ic_lock"
|
android:icon="@drawable/ic_lock"
|
||||||
android:layout="@layout/suw_glif_blank_template"
|
android:layout="@layout/sud_glif_blank_template"
|
||||||
settings:suwHeaderText="@string/lock_settings_picker_title">
|
settings:suwHeaderText="@string/lock_settings_picker_title">
|
||||||
|
|
||||||
<com.android.internal.widget.LinearLayoutWithDefaultTouchRecepient
|
<com.android.internal.widget.LinearLayoutWithDefaultTouchRecepient
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:icon="@drawable/ic_lock"
|
android:icon="@drawable/ic_lock"
|
||||||
android:layout="@layout/suw_glif_blank_template">
|
android:layout="@layout/sud_glif_blank_template">
|
||||||
|
|
||||||
<com.android.internal.widget.LinearLayoutWithDefaultTouchRecepient
|
<com.android.internal.widget.LinearLayoutWithDefaultTouchRecepient
|
||||||
android:id="@+id/topLayout"
|
android:id="@+id/topLayout"
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
android:id="@+id/setup_wizard_layout"
|
android:id="@+id/setup_wizard_layout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout="@layout/suw_glif_blank_template"
|
android:layout="@layout/sud_glif_blank_template"
|
||||||
style="?attr/fingerprint_layout_theme">
|
style="?attr/fingerprint_layout_theme">
|
||||||
|
|
||||||
<ScrollView
|
<ScrollView
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
android:id="@+id/setup_wizard_layout"
|
android:id="@+id/setup_wizard_layout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout="@layout/suw_glif_blank_template"
|
android:layout="@layout/sud_glif_blank_template"
|
||||||
style="?attr/fingerprint_layout_theme">
|
style="?attr/fingerprint_layout_theme">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
android:id="@+id/setup_wizard_layout"
|
android:id="@+id/setup_wizard_layout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout="@layout/suw_glif_blank_template"
|
android:layout="@layout/sud_glif_blank_template"
|
||||||
style="?attr/fingerprint_layout_theme">
|
style="?attr/fingerprint_layout_theme">
|
||||||
|
|
||||||
<ScrollView
|
<ScrollView
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:icon="@drawable/ic_lock"
|
android:icon="@drawable/ic_lock"
|
||||||
android:layout="@layout/suw_glif_blank_template"
|
android:layout="@layout/sud_glif_blank_template"
|
||||||
settings:sucFooter="@layout/choose_lock_pattern_common_footer"
|
settings:sucFooter="@layout/choose_lock_pattern_common_footer"
|
||||||
settings:suwHeaderText="@string/lockpassword_choose_your_screen_lock_header">
|
settings:suwHeaderText="@string/lockpassword_choose_your_screen_lock_header">
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:icon="@drawable/ic_lock"
|
android:icon="@drawable/ic_lock"
|
||||||
android:layout="@layout/suw_glif_blank_template">
|
android:layout="@layout/sud_glif_blank_template">
|
||||||
|
|
||||||
<com.android.internal.widget.LinearLayoutWithDefaultTouchRecepient
|
<com.android.internal.widget.LinearLayoutWithDefaultTouchRecepient
|
||||||
android:id="@+id/topLayout"
|
android:id="@+id/topLayout"
|
||||||
|
|||||||
@@ -43,7 +43,6 @@ import android.provider.Settings;
|
|||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewTreeObserver;
|
import android.view.ViewTreeObserver;
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.CheckBox;
|
import android.widget.CheckBox;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.ScrollView;
|
import android.widget.ScrollView;
|
||||||
@@ -51,7 +50,6 @@ import android.widget.ScrollView;
|
|||||||
import androidx.fragment.app.FragmentActivity;
|
import androidx.fragment.app.FragmentActivity;
|
||||||
|
|
||||||
import com.android.settings.testutils.shadow.ShadowUtils;
|
import com.android.settings.testutils.shadow.ShadowUtils;
|
||||||
import com.google.android.setupcompat.item.FooterButton;
|
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -387,7 +385,7 @@ public class MasterClearTest {
|
|||||||
public void testOnGlobalLayout_shouldNotRemoveListener() {
|
public void testOnGlobalLayout_shouldNotRemoveListener() {
|
||||||
final ViewTreeObserver viewTreeObserver = mock(ViewTreeObserver.class);
|
final ViewTreeObserver viewTreeObserver = mock(ViewTreeObserver.class);
|
||||||
mMasterClear.mScrollView = mScrollView;
|
mMasterClear.mScrollView = mScrollView;
|
||||||
mMasterClear.mInitiateButton = mock(FooterButton.class);
|
doNothing().when(mMasterClear).onGlobalLayout();
|
||||||
doReturn(true).when(mMasterClear).hasReachedBottom(any());
|
doReturn(true).when(mMasterClear).hasReachedBottom(any());
|
||||||
when(mScrollView.getViewTreeObserver()).thenReturn(viewTreeObserver);
|
when(mScrollView.getViewTreeObserver()).thenReturn(viewTreeObserver);
|
||||||
|
|
||||||
|
|||||||
@@ -18,13 +18,13 @@ package com.android.settings.applications.appinfo;
|
|||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
import static org.mockito.ArgumentMatchers.argThat;
|
|
||||||
import static org.mockito.Mockito.spy;
|
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
import static org.robolectric.Shadows.shadowOf;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
|
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
@@ -40,12 +40,15 @@ import org.mockito.Mock;
|
|||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.MockitoAnnotations;
|
||||||
import org.robolectric.Robolectric;
|
import org.robolectric.Robolectric;
|
||||||
import org.robolectric.RobolectricTestRunner;
|
import org.robolectric.RobolectricTestRunner;
|
||||||
|
import org.robolectric.annotation.Config;
|
||||||
|
import org.robolectric.shadows.ShadowActivity;
|
||||||
|
import org.robolectric.shadows.ShadowUserManager;
|
||||||
|
|
||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricTestRunner.class)
|
||||||
|
@Config(shadows = ShadowUserManager.class)
|
||||||
public class DefaultAppShortcutPreferenceControllerBaseTest {
|
public class DefaultAppShortcutPreferenceControllerBaseTest {
|
||||||
|
|
||||||
@Mock
|
private ShadowUserManager mShadowUserManager;
|
||||||
private UserManager mUserManager;
|
|
||||||
@Mock
|
@Mock
|
||||||
private AppInfoDashboardFragment mFragment;
|
private AppInfoDashboardFragment mFragment;
|
||||||
@Mock
|
@Mock
|
||||||
@@ -57,8 +60,8 @@ public class DefaultAppShortcutPreferenceControllerBaseTest {
|
|||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
mActivity = spy(Robolectric.setupActivity(Activity.class));
|
mActivity = Robolectric.setupActivity(Activity.class);
|
||||||
when(mActivity.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager);
|
mShadowUserManager = shadowOf(mActivity.getSystemService(UserManager.class));
|
||||||
mController = new TestPreferenceController(mActivity, mFragment);
|
mController = new TestPreferenceController(mActivity, mFragment);
|
||||||
final String key = mController.getPreferenceKey();
|
final String key = mController.getPreferenceKey();
|
||||||
when(mPreference.getKey()).thenReturn(key);
|
when(mPreference.getKey()).thenReturn(key);
|
||||||
@@ -66,28 +69,28 @@ public class DefaultAppShortcutPreferenceControllerBaseTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getAvailabilityStatus_managedProfile_shouldReturnDisabled() {
|
public void getAvailabilityStatus_managedProfile_shouldReturnDisabled() {
|
||||||
when(mUserManager.isManagedProfile()).thenReturn(true);
|
mShadowUserManager.setManagedProfile(true);
|
||||||
|
|
||||||
assertThat(mController.getAvailabilityStatus())
|
assertThat(mController.getAvailabilityStatus())
|
||||||
.isEqualTo(DefaultAppShortcutPreferenceControllerBase.DISABLED_FOR_USER);
|
.isEqualTo(DefaultAppShortcutPreferenceControllerBase.DISABLED_FOR_USER);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getAvailabilityStatus_hasAppCapability_shouldReturnAvailable() {
|
public void getAvailabilityStatus_hasAppCapability_shouldReturnAvailable() {
|
||||||
mController.capable = true;
|
mController.capable = true;
|
||||||
when(mUserManager.isManagedProfile()).thenReturn(false);
|
mShadowUserManager.setManagedProfile(false);
|
||||||
|
|
||||||
assertThat(mController.getAvailabilityStatus())
|
assertThat(mController.getAvailabilityStatus())
|
||||||
.isEqualTo(DefaultAppShortcutPreferenceControllerBase.AVAILABLE);
|
.isEqualTo(DefaultAppShortcutPreferenceControllerBase.AVAILABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getAvailabilityStatus_noAppCapability_shouldReturnDisabled() {
|
public void getAvailabilityStatus_noAppCapability_shouldReturnDisabled() {
|
||||||
mController.capable = false;
|
mController.capable = false;
|
||||||
when(mUserManager.isManagedProfile()).thenReturn(false);
|
mShadowUserManager.setManagedProfile(false);
|
||||||
|
|
||||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(
|
assertThat(mController.getAvailabilityStatus()).isEqualTo(
|
||||||
DefaultAppShortcutPreferenceControllerBase.UNSUPPORTED_ON_DEVICE);
|
DefaultAppShortcutPreferenceControllerBase.UNSUPPORTED_ON_DEVICE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -111,13 +114,17 @@ public class DefaultAppShortcutPreferenceControllerBaseTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void handlePreferenceTreeClick_shouldStartDefaultAppSettings() {
|
public void handlePreferenceTreeClick_shouldStartDefaultAppSettings() {
|
||||||
|
final ShadowActivity shadowActivity = shadowOf(mActivity);
|
||||||
|
|
||||||
mController.handlePreferenceTreeClick(mPreference);
|
mController.handlePreferenceTreeClick(mPreference);
|
||||||
|
|
||||||
verify(mActivity).startActivity(argThat(intent -> intent != null
|
final Intent nextIntent = shadowActivity.getNextStartedActivity();
|
||||||
&& intent.getStringExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT).equals(
|
assertThat(nextIntent).isNotNull();
|
||||||
DefaultAppSettings.class.getName())
|
assertThat(nextIntent.getStringExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT)).isEqualTo(
|
||||||
&& intent.getBundleExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS)
|
DefaultAppSettings.class.getName());
|
||||||
.getString(SettingsActivity.EXTRA_FRAGMENT_ARG_KEY).equals("TestKey")));
|
assertThat(
|
||||||
|
nextIntent.getBundleExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS).getString(
|
||||||
|
SettingsActivity.EXTRA_FRAGMENT_ARG_KEY)).isEqualTo("TestKey");
|
||||||
}
|
}
|
||||||
|
|
||||||
private class TestPreferenceController extends DefaultAppShortcutPreferenceControllerBase {
|
private class TestPreferenceController extends DefaultAppShortcutPreferenceControllerBase {
|
||||||
|
|||||||
Reference in New Issue
Block a user