|
17 | 17 | #include "flutter/fml/time/chrono_timestamp_provider.h"
|
18 | 18 | #include "gtest/gtest.h"
|
19 | 19 |
|
20 |
| -#define TIMESENSITIVE(x) TimeSensitiveTest_##x |
21 | 20 | #if FML_OS_WIN
|
22 | 21 | #define PLATFORM_SPECIFIC_CAPTURE(...) [ __VA_ARGS__, count ]
|
23 | 22 | #else
|
@@ -155,128 +154,6 @@ TEST(MessageLoop, CheckRunsTaskOnCurrentThread) {
|
155 | 154 | thread.join();
|
156 | 155 | }
|
157 | 156 |
|
158 |
| -TEST(MessageLoop, TIMESENSITIVE(SingleDelayedTaskByDelta)) { |
159 |
| -#if defined(OS_FUCHSIA) |
160 |
| - GTEST_SKIP() |
161 |
| - << "This test does not work on Fuchsia. https://fxbug.dev/110020 "; |
162 |
| -#else |
163 |
| - |
164 |
| - bool checked = false; |
165 |
| - std::thread thread([&checked]() { |
166 |
| - fml::MessageLoop::EnsureInitializedForCurrentThread(); |
167 |
| - auto& loop = fml::MessageLoop::GetCurrent(); |
168 |
| - auto begin = fml::ChronoTicksSinceEpoch(); |
169 |
| - loop.GetTaskRunner()->PostDelayedTask( |
170 |
| - [begin, &checked]() { |
171 |
| - auto delta = fml::ChronoTicksSinceEpoch() - begin; |
172 |
| - auto ms = delta.ToMillisecondsF(); |
173 |
| - ASSERT_GE(ms, 3); |
174 |
| - ASSERT_LE(ms, 7); |
175 |
| - checked = true; |
176 |
| - fml::MessageLoop::GetCurrent().Terminate(); |
177 |
| - }, |
178 |
| - fml::TimeDelta::FromMilliseconds(5)); |
179 |
| - loop.Run(); |
180 |
| - }); |
181 |
| - thread.join(); |
182 |
| - ASSERT_TRUE(checked); |
183 |
| -#endif // OS_FUCHSIA |
184 |
| -} |
185 |
| - |
186 |
| -TEST(MessageLoop, TIMESENSITIVE(SingleDelayedTaskForTime)) { |
187 |
| -#if defined(OS_FUCHSIA) |
188 |
| - GTEST_SKIP() |
189 |
| - << "This test does not work on Fuchsia. https://fxbug.dev/110020 "; |
190 |
| -#else |
191 |
| - |
192 |
| - bool checked = false; |
193 |
| - std::thread thread([&checked]() { |
194 |
| - fml::MessageLoop::EnsureInitializedForCurrentThread(); |
195 |
| - auto& loop = fml::MessageLoop::GetCurrent(); |
196 |
| - auto begin = fml::ChronoTicksSinceEpoch(); |
197 |
| - loop.GetTaskRunner()->PostTaskForTime( |
198 |
| - [begin, &checked]() { |
199 |
| - auto delta = fml::ChronoTicksSinceEpoch() - begin; |
200 |
| - auto ms = delta.ToMillisecondsF(); |
201 |
| - ASSERT_GE(ms, 3); |
202 |
| - ASSERT_LE(ms, 7); |
203 |
| - checked = true; |
204 |
| - fml::MessageLoop::GetCurrent().Terminate(); |
205 |
| - }, |
206 |
| - fml::ChronoTicksSinceEpoch() + fml::TimeDelta::FromMilliseconds(5)); |
207 |
| - loop.Run(); |
208 |
| - }); |
209 |
| - thread.join(); |
210 |
| - ASSERT_TRUE(checked); |
211 |
| -#endif // OS_FUCHSIA |
212 |
| -} |
213 |
| - |
214 |
| -TEST(MessageLoop, TIMESENSITIVE(MultipleDelayedTasksWithIncreasingDeltas)) { |
215 |
| -#if defined(OS_FUCHSIA) |
216 |
| - GTEST_SKIP() |
217 |
| - << "This test does not work on Fuchsia. https://fxbug.dev/110020 "; |
218 |
| -#else |
219 |
| - |
220 |
| - const auto count = 10; |
221 |
| - int checked = false; |
222 |
| - std::thread thread(PLATFORM_SPECIFIC_CAPTURE(&checked)() { |
223 |
| - fml::MessageLoop::EnsureInitializedForCurrentThread(); |
224 |
| - auto& loop = fml::MessageLoop::GetCurrent(); |
225 |
| - for (int target_ms = 0 + 2; target_ms < count + 2; target_ms++) { |
226 |
| - auto begin = fml::ChronoTicksSinceEpoch(); |
227 |
| - loop.GetTaskRunner()->PostDelayedTask( |
228 |
| - PLATFORM_SPECIFIC_CAPTURE(begin, target_ms, &checked)() { |
229 |
| - auto delta = fml::ChronoTicksSinceEpoch() - begin; |
230 |
| - auto ms = delta.ToMillisecondsF(); |
231 |
| - ASSERT_GE(ms, target_ms - 2); |
232 |
| - ASSERT_LE(ms, target_ms + 2); |
233 |
| - checked++; |
234 |
| - if (checked == count) { |
235 |
| - fml::MessageLoop::GetCurrent().Terminate(); |
236 |
| - } |
237 |
| - }, |
238 |
| - fml::TimeDelta::FromMilliseconds(target_ms)); |
239 |
| - } |
240 |
| - loop.Run(); |
241 |
| - }); |
242 |
| - thread.join(); |
243 |
| - ASSERT_EQ(checked, count); |
244 |
| -#endif // OS_FUCHSIA |
245 |
| -} |
246 |
| - |
247 |
| -TEST(MessageLoop, TIMESENSITIVE(MultipleDelayedTasksWithDecreasingDeltas)) { |
248 |
| -#if defined(OS_FUCHSIA) |
249 |
| - GTEST_SKIP() |
250 |
| - << "This test does not work on Fuchsia. https://fxbug.dev/110020 "; |
251 |
| -#else |
252 |
| - |
253 |
| - const auto count = 10; |
254 |
| - int checked = false; |
255 |
| - std::thread thread(PLATFORM_SPECIFIC_CAPTURE(&checked)() { |
256 |
| - fml::MessageLoop::EnsureInitializedForCurrentThread(); |
257 |
| - auto& loop = fml::MessageLoop::GetCurrent(); |
258 |
| - for (int target_ms = count + 2; target_ms > 0 + 2; target_ms--) { |
259 |
| - auto begin = fml::ChronoTicksSinceEpoch(); |
260 |
| - loop.GetTaskRunner()->PostDelayedTask( |
261 |
| - PLATFORM_SPECIFIC_CAPTURE(begin, target_ms, &checked)() { |
262 |
| - auto delta = fml::ChronoTicksSinceEpoch() - begin; |
263 |
| - auto ms = delta.ToMillisecondsF(); |
264 |
| - ASSERT_GE(ms, target_ms - 2); |
265 |
| - ASSERT_LE(ms, target_ms + 2); |
266 |
| - checked++; |
267 |
| - if (checked == count) { |
268 |
| - fml::MessageLoop::GetCurrent().Terminate(); |
269 |
| - } |
270 |
| - }, |
271 |
| - fml::TimeDelta::FromMilliseconds(target_ms)); |
272 |
| - } |
273 |
| - loop.Run(); |
274 |
| - }); |
275 |
| - thread.join(); |
276 |
| - ASSERT_EQ(checked, count); |
277 |
| -#endif // OS_FUCHSIA |
278 |
| -} |
279 |
| - |
280 | 157 | TEST(MessageLoop, TaskObserverFire) {
|
281 | 158 | bool started = false;
|
282 | 159 | bool terminated = false;
|
|
0 commit comments