Fix references to resources for Settings

Bug: 293810334
Test: m Settings
Change-Id: Ie140278f492ef7e1c062ec1ecae2866c521a86aa
This commit is contained in:
Chaohui Wang
2023-07-31 15:56:42 +08:00
parent ed505c25fa
commit 2541381259
247 changed files with 859 additions and 721 deletions

View File

@@ -100,7 +100,8 @@ public class EntityHeaderControllerTest {
@Test
public void testBuildView_constructedWithView_shouldReturnSameView() {
View inputView = mLayoutInflater.inflate(R.layout.settings_entity_header, null /* root */);
View inputView = mLayoutInflater.inflate(
com.android.settingslib.widget.R.layout.settings_entity_header, null /* root */);
mController = EntityHeaderController.newInstance(mActivity, mFragment, inputView);
View view = mController.done(mActivity);
@@ -110,11 +111,12 @@ public class EntityHeaderControllerTest {
@Test
public void bindViews_shouldBindAllData() {
final String testString = "test";
final View header =
mLayoutInflater.inflate(R.layout.settings_entity_header, null /* root */);
final View header = mLayoutInflater.inflate(
com.android.settingslib.widget.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);
final TextView secondSummary = header.findViewById(
com.android.settingslib.widget.R.id.entity_header_second_summary);
mController = EntityHeaderController.newInstance(mActivity, mFragment, header);
mController.setLabel(testString);
@@ -137,8 +139,8 @@ public class EntityHeaderControllerTest {
info.activityInfo = new ActivityInfo();
info.activityInfo.packageName = "123";
info.activityInfo.name = "321";
final View view = mLayoutInflater
.inflate(R.layout.settings_entity_header, null /* root */);
final View view = mLayoutInflater.inflate(
com.android.settingslib.widget.R.layout.settings_entity_header, null /* root */);
when(mActivity.getApplicationContext()).thenReturn(mContext);
mController = EntityHeaderController.newInstance(mActivity, mFragment, view);
@@ -165,7 +167,8 @@ public class EntityHeaderControllerTest {
info.activityInfo = new ActivityInfo();
info.activityInfo.packageName = "123";
info.activityInfo.name = "321";
final View view = mLayoutInflater.inflate(R.layout.settings_entity_header, null /* root */);
final View view = mLayoutInflater.inflate(
com.android.settingslib.widget.R.layout.settings_entity_header, null /* root */);
when(mActivity.getApplicationContext()).thenReturn(mContext);
mController = EntityHeaderController.newInstance(mActivity, mFragment, view);
@@ -181,8 +184,8 @@ public class EntityHeaderControllerTest {
@Test
public void bindButton_noAppInfo_shouldNotAttachClickListener() {
final View appLinks =
mLayoutInflater.inflate(R.layout.settings_entity_header, null /* root */);
final View appLinks = mLayoutInflater.inflate(
com.android.settingslib.widget.R.layout.settings_entity_header, null /* root */);
final FragmentActivity activity = mock(FragmentActivity.class);
when(mFragment.getActivity()).thenReturn(activity);
@@ -199,7 +202,8 @@ public class EntityHeaderControllerTest {
assertThat(appLinks.findViewById(android.R.id.button2).getVisibility())
.isEqualTo(View.GONE);
appLinks.findViewById(R.id.entity_header_content).performClick();
appLinks.findViewById(com.android.settingslib.widget.R.id.entity_header_content)
.performClick();
verify(mFragment, never()).getActivity();
verify(activity, never()).startActivity(any(Intent.class));
}
@@ -207,8 +211,8 @@ public class EntityHeaderControllerTest {
@Ignore
@Test
public void bindButton_hasAppInfo_shouldAttachClickListener() {
final View appLinks =
mLayoutInflater.inflate(R.layout.settings_entity_header, null /* root */);
final View appLinks = mLayoutInflater.inflate(
com.android.settingslib.widget.R.layout.settings_entity_header, null /* root */);
final FragmentActivity activity = mock(FragmentActivity.class);
when(mFragment.getActivity()).thenReturn(activity);
when(mContext.getString(eq(R.string.application_info_label))).thenReturn("App Info");
@@ -222,15 +226,16 @@ public class EntityHeaderControllerTest {
EntityHeaderController.ActionType.ACTION_NONE);
mController.done(mActivity);
appLinks.findViewById(R.id.entity_header_content).performClick();
appLinks.findViewById(com.android.settingslib.widget.R.id.entity_header_content)
.performClick();
verify(activity)
.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 */);
final View view = mLayoutInflater.inflate(
com.android.settingslib.widget.R.layout.settings_entity_header, null /* root */);
when(mFragment.getActivity()).thenReturn(mock(FragmentActivity.class));
mController = EntityHeaderController.newInstance(mActivity, mFragment, view);
String description = "Fake Description";
@@ -243,8 +248,8 @@ public class EntityHeaderControllerTest {
@Test
public void iconContentDescription_shouldWorkWithoutSetIcon() {
final View view = mLayoutInflater
.inflate(R.layout.settings_entity_header, null /* root */);
final View view = mLayoutInflater.inflate(
com.android.settingslib.widget.R.layout.settings_entity_header, null /* root */);
when(mFragment.getActivity()).thenReturn(mock(FragmentActivity.class));
mController = EntityHeaderController.newInstance(mActivity, mFragment, view);
String description = "Fake Description";
@@ -256,8 +261,8 @@ public class EntityHeaderControllerTest {
@Test
public void bindButton_hasAppNotifIntent_shouldShowButton() {
final View appLinks = mLayoutInflater
.inflate(R.layout.settings_entity_header, null /* root */);
final View appLinks = mLayoutInflater.inflate(
com.android.settingslib.widget.R.layout.settings_entity_header, null /* root */);
mController = EntityHeaderController.newInstance(mActivity, mFragment, appLinks);
mController.setAppNotifPrefIntent(new Intent())
@@ -277,23 +282,23 @@ public class EntityHeaderControllerTest {
@Test
public void instantApps_normalAppsDontGetLabel() {
final View header = mLayoutInflater.inflate(
R.layout.settings_entity_header, null /* root */);
com.android.settingslib.widget.R.layout.settings_entity_header, null /* root */);
mController = EntityHeaderController.newInstance(mActivity, mFragment, header);
mController.done(mActivity);
assertThat(header.findViewById(R.id.install_type).getVisibility())
.isEqualTo(View.GONE);
View installType = header.findViewById(com.android.settingslib.widget.R.id.install_type);
assertThat(installType.getVisibility()).isEqualTo(View.GONE);
}
// Test that the "instant apps" label is present in the header when we have an instant app.
@Test
public void instantApps_expectedHeaderItem() {
final View header = mLayoutInflater.inflate(
R.layout.settings_entity_header, null /* root */);
com.android.settingslib.widget.R.layout.settings_entity_header, null /* root */);
mController = EntityHeaderController.newInstance(mActivity, mFragment, header);
mController.setIsInstantApp(true);
mController.done(mActivity);
TextView label = header.findViewById(R.id.install_type);
TextView label = header.findViewById(com.android.settingslib.widget.R.id.install_type);
assertThat(label.getVisibility()).isEqualTo(View.VISIBLE);
assertThat(label.getText()).isEqualTo(