summaryrefslogtreecommitdiff
path: root/java/tests/src
diff options
context:
space:
mode:
author Joshua Trask <joshtrask@google.com> 2023-03-13 19:57:27 +0000
committer Joshua Trask <joshtrask@google.com> 2023-03-14 15:01:18 +0000
commit961d141bc72743ee8c42ce21bb6b0e5e01b30c4c (patch)
treec6e03189e14ca37a925c8deaafafd1483575a722 /java/tests/src
parente7f8555d956c8bf5f338a182d8023b2740edc389 (diff)
Stop sharing framework strings from unbundled Java
This kind of sharing was a relic of unbundling, and is known to cause inscrutable failures (e.g. b/270760957) when the unbundled tests were run on a device with an out-of-date framework version. We've already hard-forked (duplicated into the IntentResolver package) most string resources, and this CL addresses the remainder, w/ exceptions: 1. Layout XML and other resource files may not have the same compatibility issues, so I've left them unchanged or now; we may need to make a similar change to those files in the future. 2. I left one string, `com.android.internal.R.string.copy`, because I don't think we'd ever want to diverge from the system value and it's currently exported in the frameworks `public-final.xml` resource (so there's no risk of binary-incompatibility issues). In some cases, the resource-sharing wasn't apparent due to file-level imports of `com.android.internal.R`; I removed those imports (so that all the unbundled code loads resources from the `intentresolver` package by default) and converted the non-string resource references to explicitly reference the framework symbols by fully-qualified name. This only addresses string resources and may be inadequate to prevent all regressions in the class of b/270760957, and view ID resources are particularly concerning because it wouldn't be straightforward to fix them by an analogous "hard-fork" process. In fact, an earlier workaround (removed in ag/20065287) had separate cases specifically to address resource sharing for strings vs. view IDs, so we may expect to need some fix there. If we encounter similar regressions based on the view IDs (and don't have any better ideas), we may be able to reinstate the workaround from ag/20065287 (just for the view IDs; strings should never need the old workaround now). Bug: 270760957 Test: `atest IntentResolverUnitTests`, before and after adding a new placeholder string resource at the top of frameworks' `strings.xml`. Prior to this CL, that modification would've caused the tests to start failing unless the framework was rebuilt (e.g. by `mp droid`). Change-Id: Ifaf069124ba677a79517894d7aba847c5d869b74
Diffstat (limited to 'java/tests/src')
-rw-r--r--java/tests/src/com/android/intentresolver/ResolverActivityTest.java57
-rw-r--r--java/tests/src/com/android/intentresolver/UnbundledChooserActivityTest.java4
-rw-r--r--java/tests/src/com/android/intentresolver/UnbundledChooserActivityWorkProfileTest.java3
3 files changed, 32 insertions, 32 deletions
diff --git a/java/tests/src/com/android/intentresolver/ResolverActivityTest.java b/java/tests/src/com/android/intentresolver/ResolverActivityTest.java
index ae1b99f8..e2772423 100644
--- a/java/tests/src/com/android/intentresolver/ResolverActivityTest.java
+++ b/java/tests/src/com/android/intentresolver/ResolverActivityTest.java
@@ -55,7 +55,6 @@ import androidx.test.rule.ActivityTestRule;
import androidx.test.runner.AndroidJUnit4;
import com.android.intentresolver.widget.ResolverDrawerLayout;
-import com.android.internal.R;
import org.junit.Before;
import org.junit.Ignore;
@@ -117,7 +116,7 @@ public class ResolverActivityTest {
ResolveInfo toChoose = resolvedComponentInfos.get(0).getResolveInfoAt(0);
onView(withText(toChoose.activityInfo.name))
.perform(click());
- onView(withId(R.id.button_once))
+ onView(withId(com.android.internal.R.id.button_once))
.perform(click());
waitForIdle();
assertThat(chosen[0], is(toChoose));
@@ -133,13 +132,13 @@ public class ResolverActivityTest {
waitForIdle();
final ResolverWrapperActivity activity = mActivityRule.launchActivity(sendIntent);
- final View viewPager = activity.findViewById(R.id.profile_pager);
+ final View viewPager = activity.findViewById(com.android.internal.R.id.profile_pager);
final int initialResolverHeight = viewPager.getHeight();
activity.runOnUiThread(() -> {
ResolverDrawerLayout layout = (ResolverDrawerLayout)
activity.findViewById(
- R.id.contentPanel);
+ com.android.internal.R.id.contentPanel);
((ResolverDrawerLayout.LayoutParams) viewPager.getLayoutParams()).maxHeight
= initialResolverHeight - 1;
// Force a relayout
@@ -153,7 +152,7 @@ public class ResolverActivityTest {
activity.runOnUiThread(() -> {
ResolverDrawerLayout layout = (ResolverDrawerLayout)
activity.findViewById(
- R.id.contentPanel);
+ com.android.internal.R.id.contentPanel);
((ResolverDrawerLayout.LayoutParams) viewPager.getLayoutParams()).maxHeight
= initialResolverHeight + 1;
// Force a relayout
@@ -175,10 +174,11 @@ public class ResolverActivityTest {
waitForIdle();
final ResolverWrapperActivity activity = mActivityRule.launchActivity(sendIntent);
- final View viewPager = activity.findViewById(R.id.profile_pager);
- final View divider = activity.findViewById(R.id.divider);
+ final View viewPager = activity.findViewById(com.android.internal.R.id.profile_pager);
+ final View divider = activity.findViewById(com.android.internal.R.id.divider);
final RelativeLayout profileView =
- (RelativeLayout) activity.findViewById(R.id.profile_button).getParent();
+ (RelativeLayout) activity.findViewById(com.android.internal.R.id.profile_button)
+ .getParent();
assertThat("Drawer should show at bottom by default",
profileView.getBottom() + divider.getHeight() == viewPager.getTop()
&& profileView.getTop() > 0);
@@ -186,7 +186,7 @@ public class ResolverActivityTest {
activity.runOnUiThread(() -> {
ResolverDrawerLayout layout = (ResolverDrawerLayout)
activity.findViewById(
- R.id.contentPanel);
+ com.android.internal.R.id.contentPanel);
layout.setShowAtTop(true);
});
waitForIdle();
@@ -218,7 +218,7 @@ public class ResolverActivityTest {
return true;
};
- onView(withId(R.id.button_once)).perform(click());
+ onView(withId(com.android.internal.R.id.button_once)).perform(click());
waitForIdle();
assertThat(chosen[0], is(toChoose));
}
@@ -251,7 +251,7 @@ public class ResolverActivityTest {
// We pick the first one as there is another one in the work profile side
onView(first(withText(stableCopy.get(1).getResolveInfoAt(0).activityInfo.name)))
.perform(click());
- onView(withId(R.id.button_once))
+ onView(withId(com.android.internal.R.id.button_once))
.perform(click());
waitForIdle();
assertThat(chosen[0], is(toChoose));
@@ -280,7 +280,7 @@ public class ResolverActivityTest {
};
// Confirm that the button bar is disabled by default
- onView(withId(R.id.button_once)).check(matches(not(isEnabled())));
+ onView(withId(com.android.internal.R.id.button_once)).check(matches(not(isEnabled())));
// Make a stable copy of the components as the original list may be modified
List<ResolvedComponentInfo> stableCopy =
@@ -288,7 +288,7 @@ public class ResolverActivityTest {
onView(withText(stableCopy.get(1).getResolveInfoAt(0).activityInfo.name))
.perform(click());
- onView(withId(R.id.button_once)).perform(click());
+ onView(withId(com.android.internal.R.id.button_once)).perform(click());
waitForIdle();
assertThat(chosen[0], is(toChoose));
}
@@ -321,7 +321,7 @@ public class ResolverActivityTest {
};
// Confirm that the button bar is disabled by default
- onView(withId(R.id.button_once)).check(matches(not(isEnabled())));
+ onView(withId(com.android.internal.R.id.button_once)).check(matches(not(isEnabled())));
// Make a stable copy of the components as the original list may be modified
List<ResolvedComponentInfo> stableCopy =
@@ -329,7 +329,7 @@ public class ResolverActivityTest {
onView(withText(stableCopy.get(1).getResolveInfoAt(0).activityInfo.name))
.perform(click());
- onView(withId(R.id.button_once)).perform(click());
+ onView(withId(com.android.internal.R.id.button_once)).perform(click());
waitForIdle();
assertThat(chosen[0], is(toChoose));
}
@@ -342,7 +342,7 @@ public class ResolverActivityTest {
mActivityRule.launchActivity(sendIntent);
waitForIdle();
- onView(withId(R.id.tabs)).check(matches(isDisplayed()));
+ onView(withId(com.android.internal.R.id.tabs)).check(matches(isDisplayed()));
}
@Test
@@ -352,7 +352,7 @@ public class ResolverActivityTest {
mActivityRule.launchActivity(sendIntent);
waitForIdle();
- onView(withId(R.id.tabs)).check(matches(not(isDisplayed())));
+ onView(withId(com.android.internal.R.id.tabs)).check(matches(not(isDisplayed())));
}
@Test
@@ -447,7 +447,7 @@ public class ResolverActivityTest {
onView(first(allOf(withText(workResolvedComponentInfos.get(0)
.getResolveInfoAt(0).activityInfo.applicationInfo.name), isCompletelyDisplayed())))
.perform(click());
- onView(withId(R.id.button_once))
+ onView(withId(com.android.internal.R.id.button_once))
.perform(click());
waitForIdle();
@@ -484,7 +484,7 @@ public class ResolverActivityTest {
final ResolverWrapperActivity activity = mActivityRule.launchActivity(sendIntent);
waitForIdle();
- TextView headerText = activity.findViewById(R.id.title);
+ TextView headerText = activity.findViewById(com.android.internal.R.id.title);
String initialText = headerText.getText().toString();
assertFalse(initialText.isEmpty(), "Header text is empty.");
assertThat(headerText.getVisibility(), is(View.VISIBLE));
@@ -501,7 +501,7 @@ public class ResolverActivityTest {
final ResolverWrapperActivity activity = mActivityRule.launchActivity(sendIntent);
waitForIdle();
- TextView headerText = activity.findViewById(R.id.title);
+ TextView headerText = activity.findViewById(com.android.internal.R.id.title);
String initialText = headerText.getText().toString();
onView(withText(R.string.resolver_work_tab))
.perform(click());
@@ -539,7 +539,7 @@ public class ResolverActivityTest {
.getResolveInfoAt(0).activityInfo.applicationInfo.name),
isDisplayed())))
.perform(click());
- onView(withId(R.id.button_once))
+ onView(withId(com.android.internal.R.id.button_once))
.perform(click());
waitForIdle();
@@ -563,7 +563,7 @@ public class ResolverActivityTest {
waitForIdle();
onView(withText(R.string.resolver_work_tab)).perform(click());
waitForIdle();
- onView(withId(R.id.contentPanel))
+ onView(withId(com.android.internal.R.id.contentPanel))
.perform(swipeUp());
onView(withText(R.string.resolver_cross_profile_blocked))
@@ -585,7 +585,7 @@ public class ResolverActivityTest {
mActivityRule.launchActivity(sendIntent);
waitForIdle();
- onView(withId(R.id.contentPanel))
+ onView(withId(com.android.internal.R.id.contentPanel))
.perform(swipeUp());
onView(withText(R.string.resolver_work_tab)).perform(click());
waitForIdle();
@@ -607,7 +607,7 @@ public class ResolverActivityTest {
mActivityRule.launchActivity(sendIntent);
waitForIdle();
- onView(withId(R.id.contentPanel))
+ onView(withId(com.android.internal.R.id.contentPanel))
.perform(swipeUp());
onView(withText(R.string.resolver_work_tab)).perform(click());
waitForIdle();
@@ -631,7 +631,7 @@ public class ResolverActivityTest {
mActivityRule.launchActivity(sendIntent);
waitForIdle();
- onView(withId(R.id.contentPanel))
+ onView(withId(com.android.internal.R.id.contentPanel))
.perform(swipeUp());
onView(withText(R.string.resolver_work_tab)).perform(click());
waitForIdle();
@@ -655,7 +655,7 @@ public class ResolverActivityTest {
mActivityRule.launchActivity(sendIntent);
waitForIdle();
- onView(withId(R.id.open_cross_profile)).check(matches(isDisplayed()));
+ onView(withId(com.android.internal.R.id.open_cross_profile)).check(matches(isDisplayed()));
}
@Test
@@ -678,7 +678,8 @@ public class ResolverActivityTest {
private void assertNotMiniResolver() {
try {
- onView(withId(R.id.open_cross_profile)).check(matches(isDisplayed()));
+ onView(withId(com.android.internal.R.id.open_cross_profile))
+ .check(matches(isDisplayed()));
} catch (NoMatchingViewException e) {
return;
}
@@ -699,7 +700,7 @@ public class ResolverActivityTest {
mActivityRule.launchActivity(sendIntent);
waitForIdle();
- onView(withId(R.id.contentPanel))
+ onView(withId(com.android.internal.R.id.contentPanel))
.perform(swipeUp());
onView(withText(R.string.resolver_work_tab)).perform(click());
waitForIdle();
diff --git a/java/tests/src/com/android/intentresolver/UnbundledChooserActivityTest.java b/java/tests/src/com/android/intentresolver/UnbundledChooserActivityTest.java
index 0aab0536..3bf9f1d8 100644
--- a/java/tests/src/com/android/intentresolver/UnbundledChooserActivityTest.java
+++ b/java/tests/src/com/android/intentresolver/UnbundledChooserActivityTest.java
@@ -350,7 +350,7 @@ public class UnbundledChooserActivityTest {
mActivityRule.launchActivity(Intent.createChooser(sendIntent, "chooser test"));
waitForIdle();
onView(withId(android.R.id.title))
- .check(matches(withText(com.android.internal.R.string.whichSendApplication)));
+ .check(matches(withText(R.string.whichSendApplication)));
}
@Test
@@ -362,7 +362,7 @@ public class UnbundledChooserActivityTest {
mActivityRule.launchActivity(Intent.createChooser(sendIntent, null));
waitForIdle();
onView(withId(android.R.id.title))
- .check(matches(withText(com.android.internal.R.string.whichSendApplication)));
+ .check(matches(withText(R.string.whichSendApplication)));
}
@Test
diff --git a/java/tests/src/com/android/intentresolver/UnbundledChooserActivityWorkProfileTest.java b/java/tests/src/com/android/intentresolver/UnbundledChooserActivityWorkProfileTest.java
index 87dc1b9d..6c1edfbc 100644
--- a/java/tests/src/com/android/intentresolver/UnbundledChooserActivityWorkProfileTest.java
+++ b/java/tests/src/com/android/intentresolver/UnbundledChooserActivityWorkProfileTest.java
@@ -49,7 +49,6 @@ import androidx.test.espresso.NoMatchingViewException;
import androidx.test.rule.ActivityTestRule;
import com.android.intentresolver.UnbundledChooserActivityWorkProfileTest.TestCase.Tab;
-import com.android.internal.R;
import junit.framework.AssertionFailedError;
@@ -356,7 +355,7 @@ public class UnbundledChooserActivityWorkProfileTest {
}
});
- onView(withId(R.id.contentPanel))
+ onView(withId(com.android.internal.R.id.contentPanel))
.perform(swipeUp());
waitForIdle();
}