Move app setting link from Entity header to pref controller
Change-Id: I13a27486a9c9b4c4fb358715d678473e63c1b624 Merged-In: I13a27486a9c9b4c4fb358715d678473e63c1b624 Fixes: 79688822 Test: robotest
This commit is contained in:
@@ -41,7 +41,6 @@ import android.view.View;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.applications.LayoutPreference;
|
||||
import com.android.settings.testutils.FakeFeatureFactory;
|
||||
@@ -113,7 +112,7 @@ public class EntityHeaderControllerTest {
|
||||
public void bindViews_shouldBindAllData() {
|
||||
final String testString = "test";
|
||||
final View header =
|
||||
mLayoutInflater.inflate(R.layout.settings_entity_header, null /* root */);
|
||||
mLayoutInflater.inflate(R.layout.settings_entity_header, null /* root */);
|
||||
final TextView label = header.findViewById(R.id.entity_header_title);
|
||||
final TextView summary = header.findViewById(R.id.entity_header_summary);
|
||||
final TextView secondSummary = header.findViewById(R.id.entity_header_second_summary);
|
||||
@@ -133,41 +132,6 @@ public class EntityHeaderControllerTest {
|
||||
assertThat(secondSummary.getText()).isEqualTo(testString);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bindButton_hasAppPref_shouldShowButton() {
|
||||
final ResolveInfo info = new ResolveInfo();
|
||||
info.activityInfo = new ActivityInfo();
|
||||
info.activityInfo.packageName = "123";
|
||||
info.activityInfo.name = "321";
|
||||
final View appLinks =
|
||||
mLayoutInflater.inflate(R.layout.settings_entity_header, null /* root */);
|
||||
when(mActivity.getApplicationContext()).thenReturn(mContext);
|
||||
when(mContext.getPackageManager().resolveActivity(any(Intent.class), anyInt()))
|
||||
.thenReturn(info);
|
||||
|
||||
mController = EntityHeaderController.newInstance(mActivity, mFragment, appLinks);
|
||||
mController.setButtonActions(
|
||||
EntityHeaderController.ActionType.ACTION_APP_PREFERENCE,
|
||||
EntityHeaderController.ActionType.ACTION_NONE);
|
||||
mController.done(mActivity);
|
||||
|
||||
final ImageButton button1 = appLinks.findViewById(android.R.id.button1);
|
||||
assertThat(button1).isNotNull();
|
||||
assertThat(button1.getVisibility()).isEqualTo(View.VISIBLE);
|
||||
assertThat(button1.getDrawable()).isNotNull();
|
||||
assertThat(appLinks.findViewById(android.R.id.button2).getVisibility())
|
||||
.isEqualTo(View.GONE);
|
||||
try {
|
||||
appLinks.findViewById(android.R.id.button1).performClick();
|
||||
} catch (Exception e) {
|
||||
// Ignore exception because the launching intent is fake.
|
||||
}
|
||||
verify(mFeatureFactory.metricsFeatureProvider).actionWithSource(mContext,
|
||||
MetricsProto.MetricsEvent.VIEW_UNKNOWN,
|
||||
MetricsProto.MetricsEvent.ACTION_OPEN_APP_SETTING);
|
||||
verify(mFragment).startActivity(any(Intent.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bindButton_hasEditRuleNameClickListener_shouldShowButton() {
|
||||
final ResolveInfo info = new ResolveInfo();
|
||||
@@ -216,31 +180,10 @@ public class EntityHeaderControllerTest {
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void bindButton_noAppPref_shouldNotShowButton() {
|
||||
final View appLinks =
|
||||
mLayoutInflater.inflate(R.layout.settings_entity_header, null /* root */);
|
||||
when(mContext.getPackageManager().resolveActivity(any(Intent.class), anyInt()))
|
||||
.thenReturn(null);
|
||||
|
||||
mController = EntityHeaderController.newInstance(mActivity, mFragment, appLinks);
|
||||
mController.setButtonActions(
|
||||
EntityHeaderController.ActionType.ACTION_APP_PREFERENCE,
|
||||
EntityHeaderController.ActionType.ACTION_NONE);
|
||||
mController.done(mActivity);
|
||||
|
||||
final ImageButton button1 = appLinks.findViewById(android.R.id.button1);
|
||||
assertThat(button1).isNotNull();
|
||||
assertThat(button1.getVisibility()).isEqualTo(View.GONE);
|
||||
assertThat(button1.getDrawable()).isNull();
|
||||
assertThat(appLinks.findViewById(android.R.id.button2).getVisibility())
|
||||
.isEqualTo(View.GONE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bindButton_noAppInfo_shouldNotAttachClickListener() {
|
||||
final View appLinks =
|
||||
mLayoutInflater.inflate(R.layout.settings_entity_header, null /* root */);
|
||||
mLayoutInflater.inflate(R.layout.settings_entity_header, null /* root */);
|
||||
final Activity activity = mock(Activity.class);
|
||||
when(mFragment.getActivity()).thenReturn(activity);
|
||||
|
||||
@@ -265,7 +208,7 @@ public class EntityHeaderControllerTest {
|
||||
@Test
|
||||
public void bindButton_hasAppInfo_shouldAttachClickListener() {
|
||||
final View appLinks =
|
||||
mLayoutInflater.inflate(R.layout.settings_entity_header, null /* root */);
|
||||
mLayoutInflater.inflate(R.layout.settings_entity_header, null /* root */);
|
||||
final Activity activity = mock(Activity.class);
|
||||
when(mFragment.getActivity()).thenReturn(activity);
|
||||
when(mContext.getString(eq(R.string.application_info_label))).thenReturn("App Info");
|
||||
@@ -281,13 +224,13 @@ public class EntityHeaderControllerTest {
|
||||
|
||||
appLinks.findViewById(R.id.entity_header_content).performClick();
|
||||
verify(activity)
|
||||
.startActivityForResultAsUser(any(Intent.class), anyInt(), any(UserHandle.class));
|
||||
.startActivityForResultAsUser(any(Intent.class), anyInt(), any(UserHandle.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void iconContentDescription_shouldWorkWithSetIcon() {
|
||||
final View view =
|
||||
mLayoutInflater.inflate(R.layout.settings_entity_header, null /* root */);
|
||||
mLayoutInflater.inflate(R.layout.settings_entity_header, null /* root */);
|
||||
when(mFragment.getActivity()).thenReturn(mock(Activity.class));
|
||||
mController = EntityHeaderController.newInstance(mActivity, mFragment, view);
|
||||
String description = "Fake Description";
|
||||
|
Reference in New Issue
Block a user