Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1ad52118 authored by Mark Renouf's avatar Mark Renouf
Browse files

Clean up and expand long screenshots test coverage

This combines two nearly duplicate sets of tests into a single reusable
base test class and adds test coverage for ListViewCaptureHelper and
WebViewCaptureHelperTest.

The tests cover scrolling, bounds checking and clipping and ensure
the captured region is centered vertically within the visible bounds.

Bug: 195109744
Test: atest ListViewCaptureHelperTest RecyclerViewCaptureHelperTest \
      ScrollViewCaptureHelperTest WebViewCaptureHelperTest
Change-Id: Ia533d38238d2a0e0f44358d2033394ad1d70487f
parent 9f7e10b7
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -38,6 +38,12 @@ public class ListViewCaptureHelper implements ScrollCaptureViewHelper<ListView>
    private boolean mScrollBarWasEnabled;
    private int mOverScrollMode;

    @Override
    public boolean onAcceptSession(@NonNull ListView view) {
        return view.isVisibleToUser()
                && (view.canScrollVertically(UP) || view.canScrollVertically(DOWN));
    }

    @Override
    public void onPrepareForStart(@NonNull ListView view, Rect scrollBounds) {
        mScrollDelta = 0;
@@ -114,7 +120,6 @@ public class ListViewCaptureHelper implements ScrollCaptureViewHelper<ListView>
        return result;
    }


    @Override
    public void onPrepareForEnd(@NonNull ListView listView) {
        // Restore original position and state
+6 −0
Original line number Diff line number Diff line
@@ -43,6 +43,12 @@ public class RecyclerViewCaptureHelper implements ScrollCaptureViewHelper<ViewGr
    private boolean mScrollBarWasEnabled;
    private int mOverScrollMode;

    @Override
    public boolean onAcceptSession(@NonNull ViewGroup view) {
        return view.isVisibleToUser()
                && (view.canScrollVertically(UP) || view.canScrollVertically(DOWN));
    }

    @Override
    public void onPrepareForStart(@NonNull ViewGroup view, Rect scrollBounds) {
        mScrollDelta = 0;
+1 −4
Original line number Diff line number Diff line
@@ -67,10 +67,7 @@ public interface ScrollCaptureViewHelper<V extends View> {
     * @param view the view being captured
     * @return true if the callback should respond to a request with scroll bounds
     */
    default boolean onAcceptSession(@NonNull V view) {
        return view.isVisibleToUser()
                && (view.canScrollVertically(UP) || view.canScrollVertically(DOWN));
    }
    boolean onAcceptSession(@NonNull V view);

    /**
     * Given a scroll capture request for a view, adjust the provided rect to cover the scrollable
+5 −0
Original line number Diff line number Diff line
@@ -43,6 +43,11 @@ public class ScrollViewCaptureHelper implements ScrollCaptureViewHelper<ViewGrou
    private boolean mScrollBarEnabled;
    private int mOverScrollMode;

    public boolean onAcceptSession(@NonNull ViewGroup view) {
        return view.isVisibleToUser()
                && (view.canScrollVertically(UP) || view.canScrollVertically(DOWN));
    }

    public void onPrepareForStart(@NonNull ViewGroup view, Rect scrollBounds) {
        mStartScrollY = view.getScrollY();
        mOverScrollMode = view.getOverScrollMode();
+1 −1
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@ import android.webkit.WebView;
/**
 * ScrollCapture for WebView.
 */
class WebViewCaptureHelper implements ScrollCaptureViewHelper<WebView> {
public class WebViewCaptureHelper implements ScrollCaptureViewHelper<WebView> {
    private static final String TAG = "WebViewScrollCapture";

    private final Rect mRequestWebViewLocal = new Rect();
Loading