summaryrefslogtreecommitdiff
path: root/java/tests
diff options
context:
space:
mode:
Diffstat (limited to 'java/tests')
-rw-r--r--java/tests/src/com/android/intentresolver/UnbundledChooserActivityTest.java31
1 files changed, 26 insertions, 5 deletions
diff --git a/java/tests/src/com/android/intentresolver/UnbundledChooserActivityTest.java b/java/tests/src/com/android/intentresolver/UnbundledChooserActivityTest.java
index de5498db..acced89f 100644
--- a/java/tests/src/com/android/intentresolver/UnbundledChooserActivityTest.java
+++ b/java/tests/src/com/android/intentresolver/UnbundledChooserActivityTest.java
@@ -81,6 +81,7 @@ import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
+import android.graphics.Rect;
import android.graphics.drawable.Icon;
import android.net.Uri;
import android.os.Bundle;
@@ -92,6 +93,7 @@ import android.util.HashedStringCache;
import android.util.Pair;
import android.util.SparseArray;
import android.view.View;
+import android.view.WindowManager;
import androidx.annotation.CallSuper;
import androidx.annotation.NonNull;
@@ -959,7 +961,7 @@ public class UnbundledChooserActivityTest {
Intent sendIntent = createSendUriIntentWithPreview(uris);
ChooserActivityOverrideData.getInstance().imageLoader =
- createImageLoader(uri, createBitmap());
+ createImageLoader(uri, createWideBitmap());
ChooserActivityOverrideData.getInstance().isImageType = true;
List<ResolvedComponentInfo> resolvedComponentInfos = createResolvedComponentsForTest(2);
@@ -975,9 +977,14 @@ public class UnbundledChooserActivityTest {
RecyclerView recyclerView = (RecyclerView) view;
assertThat(recyclerView.getAdapter().getItemCount(), is(1));
assertThat(recyclerView.getChildCount(), is(1));
+ View imageView = recyclerView.getChildAt(0);
+ Rect rect = new Rect();
+ boolean isPartiallyVisible = imageView.getGlobalVisibleRect(rect);
assertThat(
- "image preview view is fully visible",
- isDisplayed().matches(recyclerView.getChildAt(0)));
+ "image preview view is not fully visible",
+ isPartiallyVisible
+ && rect.width() == imageView.getWidth()
+ && rect.height() == imageView.getHeight());
});
}
@@ -2785,8 +2792,22 @@ public class UnbundledChooserActivityTest {
}
private Bitmap createBitmap() {
- int width = 200;
- int height = 200;
+ return createBitmap(200, 200);
+ }
+
+ private Bitmap createWideBitmap() {
+ WindowManager windowManager = InstrumentationRegistry.getInstrumentation()
+ .getTargetContext()
+ .getSystemService(WindowManager.class);
+ int width = 3000;
+ if (windowManager != null) {
+ Rect bounds = windowManager.getMaximumWindowMetrics().getBounds();
+ width = bounds.width() + 200;
+ }
+ return createBitmap(width, 100);
+ }
+
+ private Bitmap createBitmap(int width, int height) {
Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);