Add coverage for Choreographer preferred timeline.

(SDK Choreographer)

Bug: 220030332
Test: atest ChoreographerTest
Change-Id: Ib71bd64327deea9f7fef092986d1580acd6dfb4d
diff --git a/tests/tests/view/src/android/view/cts/ChoreographerTest.java b/tests/tests/view/src/android/view/cts/ChoreographerTest.java
index c74b4a1..6d2933a 100644
--- a/tests/tests/view/src/android/view/cts/ChoreographerTest.java
+++ b/tests/tests/view/src/android/view/cts/ChoreographerTest.java
@@ -38,6 +38,7 @@
 import org.mockito.ArgumentCaptor;
 
 import java.util.HashSet;
+import java.util.Set;
 
 @MediumTest
 @RunWith(AndroidJUnit4.class)
@@ -337,6 +338,26 @@
     }
 
     @Test
+    public void testPostVsyncCallbackFrameDataPreferredFrameTimelineValid() {
+        final Choreographer.VsyncCallback addedCallback = mock(
+                Choreographer.VsyncCallback.class);
+        long postTimeNanos = System.nanoTime();
+        mChoreographer.postVsyncCallback(addedCallback);
+
+        ArgumentCaptor<Choreographer.FrameData> captor = ArgumentCaptor.forClass(
+                Choreographer.FrameData.class);
+        verify(addedCallback, timeout(NOMINAL_VSYNC_PERIOD * 10).times(1)).onVsync(
+                captor.capture());
+
+        Choreographer.FrameData frameData = captor.getValue();
+        assertTrue("Number of frame timelines should be greater than 0",
+                frameData.getFrameTimelines().length > 0);
+        Set<Choreographer.FrameTimeline> frameTimelines = Set.of(frameData.getFrameTimelines());
+        assertTrue("Preferred frame timeline is not included in frame timelines",
+                frameTimelines.contains(frameData.getPreferredFrameTimeline()));
+    }
+
+    @Test
     public void testPostVsyncCallbackFrameDataVsyncIdValid() {
         final Choreographer.VsyncCallback addedCallback = mock(
                 Choreographer.VsyncCallback.class);