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

Commit 7a84b190 authored by George Mount's avatar George Mount
Browse files

Fix ViewFrameRateTest

There were two broken tests when certain flags were enabled.
* toolkit_frame_rate_velocity_mapping_read_only
* toolkit_frame_rate_small_uses_percent_read_only
* toolkit_frame_rate_view_enabling_read_only

Test: ViewFrameRateTest
Change-Id: I9d26b1b47217b21c12e28f52bf2bb2b07868674b
parent 53667488
Loading
Loading
Loading
Loading
+8 −6
Original line number Diff line number Diff line
@@ -33942,7 +33942,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
            return; // can't vote if not connected
        }
        float velocity = mFrameContentVelocity;
        float frameRate = mPreferredFrameRate;
        final float frameRate = mPreferredFrameRate;
        ViewParent parent = mParent;
        if (velocity <= 0 && Float.isNaN(frameRate)) {
            // The most common case is when nothing is set, so this special case is called
@@ -33982,13 +33982,15 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
            }
            if (velocityFrameRate > 0f || frameRate > 0f) {
                int compatibility;
                float frameRateToSet;
                if (frameRate >= velocityFrameRate) {
                    compatibility = FRAME_RATE_COMPATIBILITY_FIXED_SOURCE;
                    frameRateToSet = frameRate;
                } else {
                    compatibility = FRAME_RATE_COMPATIBILITY_GTE;
                    frameRate = velocityFrameRate;
                    frameRateToSet = velocityFrameRate;
                }
                viewRootImpl.votePreferredFrameRate(frameRate, compatibility);
                viewRootImpl.votePreferredFrameRate(frameRateToSet, compatibility);
            }
        }
@@ -34052,7 +34054,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     */
    @FlaggedApi(FLAG_VIEW_VELOCITY_API)
    public void setFrameContentVelocity(float pixelsPerSecond) {
        if (viewVelocityApi()) {
        if (mAttachInfo != null && mAttachInfo.mViewVelocityApi) {
            mFrameContentVelocity = Math.abs(pixelsPerSecond);
            if (sToolkitMetricsForFrameRateDecisionFlagValue) {
@@ -34070,8 +34072,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     */
    @FlaggedApi(FLAG_VIEW_VELOCITY_API)
    public float getFrameContentVelocity() {
        if (viewVelocityApi()) {
            return (mFrameContentVelocity < 0f) ? 0f : mFrameContentVelocity;
        if (mAttachInfo != null && mAttachInfo.mViewVelocityApi) {
            return Math.max(mFrameContentVelocity, 0f);
        }
        return 0;
    }
+1 −0
Original line number Diff line number Diff line
@@ -183,6 +183,7 @@ public class ViewFrameRateTest {
        mActivityRule.runOnUiThread(() -> {
            frameLayout.setFrameContentVelocity(1f);
            mMovingView.offsetTopAndBottom(100);
            frameLayout.invalidate();
            runAfterDraw(() -> assertEquals(60f, mViewRoot.getLastPreferredFrameRate(), 0f));
        });
        waitForAfterDraw();