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

Commit 9fc8d287 authored by Jeff Sharkey's avatar Jeff Sharkey Committed by Android (Google) Code Review
Browse files

Merge "Improve `UriPermissionTest` flakiness." into main

parents 78262c81 5c528c03
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -33,8 +33,10 @@ import static com.android.server.uri.UriPermission.STRENGTH_PERSISTABLE;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;

import android.os.SystemClock;
import android.platform.test.ravenwood.RavenwoodRule;

import org.junit.Before;
@@ -154,10 +156,12 @@ public class UriPermissionTest {
            assertEquals(FLAG_WRITE, perm.persistableModeFlags);
            assertEquals(FLAG_WRITE, perm.persistedModeFlags);

            // Attempting to take a second time should be a no-op
            // Attempting to take a second time should "touch" timestamp, per public API
            // docs on ContentResolver.takePersistableUriPermission()
            final long createTime = perm.persistedCreateTime;
            SystemClock.sleep(10);
            assertFalse(perm.takePersistableModes(FLAG_WRITE));
            assertEquals(createTime, perm.persistedCreateTime);
            assertNotEquals(createTime, perm.persistedCreateTime);

            assertTrue(perm.releasePersistableModes(FLAG_WRITE));
            assertEquals(FLAG_WRITE, perm.persistableModeFlags);