Skip to content

Commit

Permalink
Allow disabling initialAwakenScrollBars temporarily
Browse files Browse the repository at this point in the history
To aid in migration of tests in preperation for enabling marking windows visible by default temporarily add a system property to allow disabling initial awaken of scroll bars. This property will be removed after test migration to allow default behavior.

PiperOrigin-RevId: 437291434
  • Loading branch information
paulsowden authored and Copybara-Service committed Apr 13, 2022
1 parent f8eb1a5 commit 0c3233f
Showing 1 changed file with 16 additions and 0 deletions.
Expand Up @@ -48,6 +48,7 @@
import org.robolectric.annotation.Implements;
import org.robolectric.annotation.LooperMode;
import org.robolectric.annotation.RealObject;
import org.robolectric.annotation.ReflectorObject;
import org.robolectric.annotation.Resetter;
import org.robolectric.shadow.api.Shadow;
import org.robolectric.util.ReflectionHelpers;
Expand All @@ -62,6 +63,7 @@
public class ShadowView {

@RealObject protected View realView;
@ReflectorObject protected _View_ viewReflector;
private static final List<View.OnClickListener> globalClickListeners =
new CopyOnWriteArrayList<>();
private static final List<View.OnLongClickListener> globalLongClickListeners =
Expand Down Expand Up @@ -665,6 +667,17 @@ protected void clearAnimation() {
}
}

@Implementation
protected boolean initialAwakenScrollBars() {
// Temporarily allow disabling initial awaken of scroll bars to aid in migration of tests to
// default to window's being marked visible, this will be removed once migration is complete.
if (Boolean.getBoolean("robolectric.disableInitialAwakenScrollBars")) {
return false;
} else {
return viewReflector.initialAwakenScrollBars();
}
}

private class AnimationRunner implements Runnable {
private final Animation animation;
private long startTime, startOffset, elapsedTime;
Expand Down Expand Up @@ -830,6 +843,9 @@ void removeOnAttachStateChangeListener(

@Direct
int getSourceLayoutResId();

@Direct
boolean initialAwakenScrollBars();
}

public void callOnAttachedToWindow() {
Expand Down

0 comments on commit 0c3233f

Please sign in to comment.