1 #include <gmock/gmock.h>
2 #include <gtest/gtest.h>
3 
4 #include "VkQsriTimeline.h"
5 
6 namespace gfxstream {
7 namespace vk {
8 namespace {
9 using ::testing::InSequence;
10 using ::testing::MockFunction;
11 
TEST(VkQsriTImelineTest,signalFirstRegisterCallbackLater)12 TEST(VkQsriTImelineTest, signalFirstRegisterCallbackLater) {
13     MockFunction<void()> mockCallback1, mockCallback2;
14     VkQsriTimeline qsriTimeline;
15     {
16         InSequence s;
17         EXPECT_CALL(mockCallback1, Call()).Times(1);
18         EXPECT_CALL(mockCallback2, Call()).Times(1);
19     }
20     qsriTimeline.signalNextPresentAndPoll();
21     qsriTimeline.signalNextPresentAndPoll();
22     qsriTimeline.registerCallbackForNextPresentAndPoll(mockCallback1.AsStdFunction());
23     qsriTimeline.registerCallbackForNextPresentAndPoll(mockCallback2.AsStdFunction());
24 }
25 
TEST(VkQsriTImelineTest,registerCallbackFirstSignalLater)26 TEST(VkQsriTImelineTest, registerCallbackFirstSignalLater) {
27     MockFunction<void()> mockCallback1, mockCallback2, beforeSignal;
28     VkQsriTimeline qsriTimeline;
29     {
30         InSequence s;
31         EXPECT_CALL(beforeSignal, Call()).Times(1);
32         EXPECT_CALL(mockCallback1, Call()).Times(1);
33         EXPECT_CALL(mockCallback2, Call()).Times(1);
34     }
35     qsriTimeline.registerCallbackForNextPresentAndPoll(mockCallback1.AsStdFunction());
36     qsriTimeline.registerCallbackForNextPresentAndPoll(mockCallback2.AsStdFunction());
37     beforeSignal.Call();
38     qsriTimeline.signalNextPresentAndPoll();
39     qsriTimeline.signalNextPresentAndPoll();
40 }
41 
42 }  // namespace
43 }  // namespace vk
44 }  // namespace gfxstream