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

Commit a43da04f authored by Siarhei Vishniakou's avatar Siarhei Vishniakou
Browse files

Use Duration instead of TimeUnit for waiting on windows

This is easier to use than TimeUnit-based approach.

Bug: 354277284
Test: build only
Flag: TEST_ONLY
Merged-In: Ie818959dbbfdf74ea9f379d241503caa15de8ae8
Change-Id: Ie818959dbbfdf74ea9f379d241503caa15de8ae8
parent db25f3d3
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -66,6 +66,7 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TestName;

import java.time.Duration;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;

@@ -131,7 +132,7 @@ public class ScreenshotTests {
        assertTrue("Failed to wait for transaction to get committed",
                countDownLatch.await(WAIT_TIME_S, TimeUnit.SECONDS));
        assertTrue("Failed to wait for stable geometry",
                waitForStableWindowGeometry(WAIT_TIME_S, TimeUnit.SECONDS));
                waitForStableWindowGeometry(Duration.ofSeconds(WAIT_TIME_S)));

        ScreenCapture.LayerCaptureArgs args = new ScreenCapture.LayerCaptureArgs.Builder(secureSC)
                .setCaptureSecureLayers(true)
@@ -212,7 +213,7 @@ public class ScreenshotTests {
        assertTrue("Failed to wait for transaction to get committed",
                countDownLatch.await(WAIT_TIME_S, TimeUnit.SECONDS));
        assertTrue("Failed to wait for stable geometry",
                waitForStableWindowGeometry(WAIT_TIME_S, TimeUnit.SECONDS));
                waitForStableWindowGeometry(Duration.ofSeconds(WAIT_TIME_S)));

        ScreenshotHardwareBuffer[] screenCapture = new ScreenshotHardwareBuffer[1];
        Bitmap screenshot = null;
+3 −2
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TestName;

import java.time.Duration;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;

@@ -144,7 +145,7 @@ public class TrustedOverlayTests {
                        }
                    }
                    return false;
                }, TIMEOUT_S, TimeUnit.SECONDS);
                }, Duration.ofSeconds(TIMEOUT_S));

        assertAndDumpWindowState(TAG, "Failed to find window or was not marked trusted",
                foundTrusted[0]);
@@ -209,7 +210,7 @@ public class TrustedOverlayTests {
                        }
                    }
                    return foundTrusted[0] && foundTrusted[1];
                }, TIMEOUT_S, TimeUnit.SECONDS);
                }, Duration.ofSeconds(TIMEOUT_S));

        if (!foundTrusted[0] || !foundTrusted[1]) {
            CtsWindowInfoUtils.dumpWindowsOnScreen(TAG, mName.getMethodName());
+2 −2
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@ import androidx.test.uiautomator.Until
import com.android.cts.input.DebugInputRule
import com.android.cts.input.UinputTouchScreen

import java.util.concurrent.TimeUnit
import java.time.Duration

import org.junit.After
import org.junit.Assert.assertEquals
@@ -193,6 +193,6 @@ class AnrTest {
        val flags = " -W -n "
        val startCmd = "am start $flags $PACKAGE_NAME/.UnresponsiveGestureMonitorActivity"
        instrumentation.uiAutomation.executeShellCommand(startCmd)
        waitForStableWindowGeometry(5L, TimeUnit.SECONDS)
        waitForStableWindowGeometry(Duration.ofSeconds(5))
    }
}