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

Commit dfff81e4 authored by Daniel Hsieh's avatar Daniel Hsieh
Browse files

Fixes flaky tests

The CountDownLatch should be put at the last line to avoid making
CountDownLatch#await passed without updating values.

Bug: 224717753
Test: atest WindowMagnificationControllerTest
Change-Id: I29530a02780291d684a30e31b4811f2b95fe0faf
parent 1b43c023
Loading
Loading
Loading
Loading
+3 −1
Original line number Original line Diff line number Diff line
@@ -44,11 +44,13 @@ public class MockMagnificationAnimationCallback extends IRemoteMagnificationAnim


    @Override
    @Override
    public void onResult(boolean success) throws RemoteException {
    public void onResult(boolean success) throws RemoteException {
        mCountDownLatch.countDown();
        if (success) {
        if (success) {
            mSuccessCount.getAndIncrement();
            mSuccessCount.getAndIncrement();
        } else {
        } else {
            mFailedCount.getAndIncrement();
            mFailedCount.getAndIncrement();
        }
        }
        // It should be put at the last line to avoid making CountDownLatch#await passed without
        // updating values.
        mCountDownLatch.countDown();
    }
    }
}
}
+0 −3
Original line number Original line Diff line number Diff line
@@ -80,7 +80,6 @@ import com.android.systemui.utils.os.FakeHandler;


import org.junit.After;
import org.junit.After;
import org.junit.Before;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runner.RunWith;
import org.mockito.Answers;
import org.mockito.Answers;
@@ -319,7 +318,6 @@ public class WindowMagnificationControllerTest extends SysuiTestCase {
        verify(mSfVsyncFrameProvider, atLeastOnce()).postFrameCallback(any());
        verify(mSfVsyncFrameProvider, atLeastOnce()).postFrameCallback(any());
    }
    }


    @Ignore("b/224717753")
    @Test
    @Test
    public void moveWindowMagnifierToPositionWithAnimation_expectedValuesAndInvokeCallback()
    public void moveWindowMagnifierToPositionWithAnimation_expectedValuesAndInvokeCallback()
            throws InterruptedException {
            throws InterruptedException {
@@ -354,7 +352,6 @@ public class WindowMagnificationControllerTest extends SysuiTestCase {
        assertEquals(mWindowMagnificationController.getCenterY(), targetCenterY, 0);
        assertEquals(mWindowMagnificationController.getCenterY(), targetCenterY, 0);
    }
    }


    @Ignore("b/224717753")
    @Test
    @Test
    public void moveWindowMagnifierToPositionMultipleTimes_expectedValuesAndInvokeCallback()
    public void moveWindowMagnifierToPositionMultipleTimes_expectedValuesAndInvokeCallback()
            throws InterruptedException {
            throws InterruptedException {