diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2021-10-09 23:00:40 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2021-10-09 23:00:40 +0000 |
commit | 115b6e1c7a394302ee5ac74c048e8bcdc8f8ec30 (patch) | |
tree | d245545323fc5b2e56e54afa4a35210c56fa9c5e | |
parent | e63731bbb0b15c45bddee379c21be94edd19120f (diff) | |
parent | 051439cfb504b68e6b7970edf241592cd82d1d15 (diff) | |
download | cts-115b6e1c7a394302ee5ac74c048e8bcdc8f8ec30.tar.gz |
Snap for 7809314 from 051439cfb504b68e6b7970edf241592cd82d1d15 to sc-qpr1-d-release
Change-Id: Iae2986b31f6791fb8b8f768cef6180a1f7644927
-rw-r--r-- | tests/translation/src/android/translation/cts/UiTranslationManagerTest.java | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/translation/src/android/translation/cts/UiTranslationManagerTest.java b/tests/translation/src/android/translation/cts/UiTranslationManagerTest.java index 477c1dfb249..34ceb720a4a 100644 --- a/tests/translation/src/android/translation/cts/UiTranslationManagerTest.java +++ b/tests/translation/src/android/translation/cts/UiTranslationManagerTest.java @@ -240,6 +240,39 @@ public class UiTranslationManagerTest { } @Test + public void testPauseUiTranslationThenStartUiTranslation() throws Throwable { + final Pair<List<AutofillId>, ContentCaptureContext> result = + enableServicesAndStartActivityForTranslation(); + + final CharSequence originalText = mTextView.getText(); + final List<AutofillId> views = result.first; + final ContentCaptureContext contentCaptureContext = result.second; + + final String translatedText = "success"; + final UiObject2 helloText = Helper.findObjectByResId(Helper.ACTIVITY_PACKAGE, + SimpleActivity.HELLO_TEXT_ID); + assertThat(helloText).isNotNull(); + // Set response + final TranslationResponse response = + createViewsTranslationResponse(views, translatedText); + sTranslationReplier.addResponse(response); + + startUiTranslation(/* shouldPadContent */ false, views, contentCaptureContext); + + assertThat(helloText.getText()).isEqualTo(translatedText); + + pauseUiTranslation(contentCaptureContext); + + assertThat(helloText.getText()).isEqualTo(originalText.toString()); + + sTranslationReplier.addResponse(createViewsTranslationResponse(views, translatedText)); + + startUiTranslation(/* shouldPadContent */ false, views, contentCaptureContext); + + assertThat(helloText.getText()).isEqualTo(translatedText); + } + + @Test public void testUiTranslation_CustomViewTranslationCallback() throws Throwable { final Pair<List<AutofillId>, ContentCaptureContext> result = enableServicesAndStartActivityForTranslation(); |