• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include <gtest/gtest.h>
18 
19 #include <binder/Parcel.h>
20 
21 #include <gui/VsyncEventData.h>
22 
23 namespace android {
24 
25 using gui::ParcelableVsyncEventData;
26 using gui::VsyncEventData;
27 using FrameTimeline = gui::VsyncEventData::FrameTimeline;
28 
29 namespace test {
30 
TEST(ParcelableVsyncEventData,Parcelling)31 TEST(ParcelableVsyncEventData, Parcelling) {
32     ParcelableVsyncEventData data;
33     data.vsync.frameInterval = 789;
34     data.vsync.preferredFrameTimelineIndex = 1;
35     FrameTimeline timeline0 = FrameTimeline{1, 2, 3};
36     FrameTimeline timeline1 = FrameTimeline{4, 5, 6};
37     data.vsync.frameTimelines[0] = timeline0;
38     data.vsync.frameTimelines[1] = timeline1;
39 
40     Parcel p;
41     data.writeToParcel(&p);
42     p.setDataPosition(0);
43 
44     ParcelableVsyncEventData data2;
45     data2.readFromParcel(&p);
46     ASSERT_EQ(data.vsync.frameInterval, data2.vsync.frameInterval);
47     ASSERT_EQ(data.vsync.preferredFrameTimelineIndex, data2.vsync.preferredFrameTimelineIndex);
48     for (int i = 0; i < VsyncEventData::kFrameTimelinesLength; i++) {
49         ASSERT_EQ(data.vsync.frameTimelines[i].vsyncId, data2.vsync.frameTimelines[i].vsyncId);
50         ASSERT_EQ(data.vsync.frameTimelines[i].deadlineTimestamp,
51                   data2.vsync.frameTimelines[i].deadlineTimestamp);
52         ASSERT_EQ(data.vsync.frameTimelines[i].expectedPresentationTime,
53                   data2.vsync.frameTimelines[i].expectedPresentationTime);
54     }
55 }
56 
57 } // namespace test
58 } // namespace android
59