Merge "Fix LauncherInstrumentation for OOP tests from gradle" into tm-qpr-dev am: 4298b36ef4

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/19865266

Change-Id: I86224b7d685f495d91c2a6245d6f1ed5462b5332
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
TreeHugger Robot
2022-09-21 23:20:43 +00:00
committed by Automerger Merge Worker
@@ -239,7 +239,7 @@ public final class LauncherInstrumentation {
// Launcher package. As during inproc tests the tested launcher may not be selected as the
// current launcher, choosing target package for inproc. For out-of-proc, use the installed
// launcher package.
mLauncherPackage = testPackage.equals(targetPackage)
mLauncherPackage = testPackage.equals(targetPackage) || isGradleInstrumentation()
? getLauncherPackageName()
: targetPackage;
@@ -286,6 +286,20 @@ public final class LauncherInstrumentation {
}
}
/**
* Gradle only supports out of process instrumentation. The test package is automatically
* generated by appending `.test` to the target package.
*/
private boolean isGradleInstrumentation() {
final String testPackage = getContext().getPackageName();
final String targetPackage = mInstrumentation.getTargetContext().getPackageName();
final String testSuffix = ".test";
return testPackage.endsWith(testSuffix) && testPackage.length() > testSuffix.length()
&& testPackage.substring(0, testPackage.length() - testSuffix.length())
.equals(targetPackage);
}
public void enableCheckEventsForSuccessfulGestures() {
mCheckEventsForSuccessfulGestures = true;
}