119 {
122 const uintptr_t kWarmUpBaton = 0xFFFFFFFF;
123
125 CFTimeInterval timestamp;
126 CFTimeInterval targetTimestamp;
127 size_t baton;
128 };
129 __block std::vector<Entry> entries;
130
132 initWithDisplayLink:displayLink
133 block:^(CFTimeInterval timestamp, CFTimeInterval targetTimestamp,
134 uintptr_t baton) {
135 entries.push_back({timestamp, targetTimestamp, baton});
136 if (baton == kWarmUpBaton) {
137 return;
138 }
140 CFRunLoopStop(CFRunLoopGetCurrent());
141 }];
142
143 __block CFTimeInterval expectedStartUntil;
144
145
146
147 [waiter waitForVSync:kWarmUpBaton];
148 [[NSRunLoop currentRunLoop] performBlock:^{
149 expectedStartUntil = CACurrentMediaTime();
150 }];
151
152
153 CFTimeInterval now = CACurrentMediaTime();
154
157 EXPECT_EQ(displayLink.
paused, YES);
158
159 [waiter waitForVSync:1];
160 CFRunLoopRun();
161
162 [waiter waitForVSync:2];
165 CFRunLoopRun();
166
167 [waiter waitForVSync:3];
170 CFRunLoopRun();
171
172 EXPECT_FALSE(displayLink.
paused);
173
176
177 CFTimeInterval
start = CACurrentMediaTime();
178 while (!displayLink.
paused) {
179
180 CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.02, NO);
181 if (CACurrentMediaTime() -
start > 1.0) {
182 break;
183 }
184 }
185 ASSERT_TRUE(displayLink.
paused);
186
187 EXPECT_EQ(entries.size(), size_t(4));
188
189
190 EXPECT_TRUE(entries[0].timestamp <= expectedStartUntil);
191 EXPECT_TRUE(entries[0].targetTimestamp <= expectedStartUntil);
192 EXPECT_EQ(entries[0].baton, kWarmUpBaton);
193
196 EXPECT_EQ(entries[1].baton, size_t(1));
199 EXPECT_EQ(entries[2].baton, size_t(2));
202 EXPECT_EQ(entries[3].baton, size_t(3));
203}