diff options
Diffstat (limited to 'hostsidetests/inputmethodservice/hostside/src/android/inputmethodservice/cts/hostside/InputMethodServiceLifecycleTest.java')
-rw-r--r-- | hostsidetests/inputmethodservice/hostside/src/android/inputmethodservice/cts/hostside/InputMethodServiceLifecycleTest.java | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/hostsidetests/inputmethodservice/hostside/src/android/inputmethodservice/cts/hostside/InputMethodServiceLifecycleTest.java b/hostsidetests/inputmethodservice/hostside/src/android/inputmethodservice/cts/hostside/InputMethodServiceLifecycleTest.java index 846c31f01cc..4064ff5f158 100644 --- a/hostsidetests/inputmethodservice/hostside/src/android/inputmethodservice/cts/hostside/InputMethodServiceLifecycleTest.java +++ b/hostsidetests/inputmethodservice/hostside/src/android/inputmethodservice/cts/hostside/InputMethodServiceLifecycleTest.java @@ -26,6 +26,7 @@ import static android.inputmethodservice.cts.common.DeviceEventConstants.RECEIVE import static org.junit.Assert.assertTrue; import static org.junit.Assume.assumeTrue; +import android.inputmethodservice.cts.common.ComponentNameUtils; import android.inputmethodservice.cts.common.EditTextAppConstants; import android.inputmethodservice.cts.common.EventProviderConstants.EventTableConstants; import android.inputmethodservice.cts.common.Ime1Constants; @@ -36,6 +37,7 @@ import android.inputmethodservice.cts.common.test.TestInfo; import android.platform.test.annotations.AppModeFull; import android.platform.test.annotations.AppModeInstant; +import com.android.compatibility.common.util.FeatureUtil; import com.android.tradefed.testtype.DeviceJUnit4ClassRunner; import com.android.tradefed.testtype.junit4.BaseHostJUnit4Test; @@ -56,6 +58,8 @@ public class InputMethodServiceLifecycleTest extends BaseHostJUnit4Test { private static final long WAIT_TIMEOUT = TimeUnit.SECONDS.toMillis(1); private static final long PACKAGE_OP_TIMEOUT = TimeUnit.SECONDS.toMillis(7); private static final long POLLING_INTERVAL = 100; + private static final String COMPAT_CHANGE_DO_NOT_DOWNSCALE_TO_1080P_ON_TV = + "DO_NOT_DOWNSCALE_TO_1080P_ON_TV"; /** * {@code true} if {@link #tearDown()} needs to be fully executed. @@ -126,6 +130,25 @@ public class InputMethodServiceLifecycleTest extends BaseHostJUnit4Test { private void installImePackageSync(String apkFileName, String imeId) throws Exception { installPackage(apkFileName, "-r"); waitUntilImesAreAvailable(imeId); + + // Compatibility scaling may affect how watermarks are rendered in such a way so that we + // won't be able to detect them on screenshots. + disableAppCompatScalingForPackageIfNeeded(ComponentNameUtils.retrievePackageName(imeId)); + } + + private void disableAppCompatScalingForPackageIfNeeded(String packageName) throws Exception { + if (FeatureUtil.isTV(getDevice())) { + // On 4K TV devices packages that target API levels below S run in a compat mode where + // they render UI to a 1080p surface which then gets scaled up x2 (to the device's + // "native" 4K resolution). + // When a test IME package runs in such compatibility mode, the watermarks it renders + // would be scaled up x2 as well, thus we won't be able detect them on (4K) screenshots + // we take during tests. + // Note, that this command will have no effect if the device is not a 4K TV, or if the + // package's "targetSdk" level is S or above. + shell(ShellCommandUtils.enableCompatChange( + COMPAT_CHANGE_DO_NOT_DOWNSCALE_TO_1080P_ON_TV, packageName)); + } } private void installPossibleInstantPackage( |