Fixed errors introduced in landing of fml changes for Windows. (flutter/engine#4431)

This commit is contained in:
Ben Konyi
2017-12-08 11:17:48 -08:00
committed by GitHub
parent 5ff8528682
commit d023506388

View File

@@ -75,7 +75,12 @@ TEST(MessageLoop, NonDelayedTasksAreRunInOrder) {
auto& loop = fml::MessageLoop::GetCurrent();
size_t current = 0;
for (size_t i = 0; i < count; i++) {
loop.GetTaskRunner()->PostTask([&terminated, i, &current, count]() {
loop.GetTaskRunner()->PostTask([&terminated, i, &current
#if OS_WIN
,
count
#endif
]() {
ASSERT_EQ(current, i);
current++;
if (count == i + 1) {
@@ -105,7 +110,12 @@ TEST(MessageLoop, DelayedTasksAtSameTimeAreRunInOrder) {
fxl::TimePoint::Now() + fxl::TimeDelta::FromMilliseconds(2);
for (size_t i = 0; i < count; i++) {
loop.GetTaskRunner()->PostTaskForTime(
[&terminated, i, &current, count]() {
[&terminated, i, &current
#if OS_WIN
,
count
#endif
]() {
ASSERT_EQ(current, i);
current++;
if (count == i + 1) {
@@ -187,13 +197,23 @@ TEST(MessageLoop, TIME_SENSITIVE(SingleDelayedTaskForTime)) {
TEST(MessageLoop, TIME_SENSITIVE(MultipleDelayedTasksWithIncreasingDeltas)) {
const auto count = 10;
int checked = false;
std::thread thread([&checked, count]() {
std::thread thread([&checked
#if OS_WIN
,
count
#endif
]() {
fml::MessageLoop::EnsureInitializedForCurrentThread();
auto& loop = fml::MessageLoop::GetCurrent();
for (int target_ms = 0 + 2; target_ms < count + 2; target_ms++) {
auto begin = fxl::TimePoint::Now();
loop.GetTaskRunner()->PostDelayedTask(
[begin, target_ms, &checked, count]() {
[begin, target_ms, &checked
#if OS_WIN
,
count
#endif
]() {
auto delta = fxl::TimePoint::Now() - begin;
auto ms = delta.ToMillisecondsF();
ASSERT_GE(ms, target_ms - 2);
@@ -214,13 +234,23 @@ TEST(MessageLoop, TIME_SENSITIVE(MultipleDelayedTasksWithIncreasingDeltas)) {
TEST(MessageLoop, TIME_SENSITIVE(MultipleDelayedTasksWithDecreasingDeltas)) {
const auto count = 10;
int checked = false;
std::thread thread([&checked, count]() {
std::thread thread([&checked
#if OS_WIN
,
count
#endif
]() {
fml::MessageLoop::EnsureInitializedForCurrentThread();
auto& loop = fml::MessageLoop::GetCurrent();
for (int target_ms = count + 2; target_ms > 0 + 2; target_ms--) {
auto begin = fxl::TimePoint::Now();
loop.GetTaskRunner()->PostDelayedTask(
[begin, target_ms, &checked, count]() {
[begin, target_ms, &checked
#if OS_WIN
,
count
#endif
]() {
auto delta = fxl::TimePoint::Now() - begin;
auto ms = delta.ToMillisecondsF();
ASSERT_GE(ms, target_ms - 2);
@@ -263,9 +293,19 @@ TEST(MessageLoop, TaskObserverFire) {
auto& loop = fml::MessageLoop::GetCurrent();
size_t task_count = 0;
size_t obs_count = 0;
CustomTaskObserver obs([&obs_count, count]() { obs_count++; });
CustomTaskObserver obs([&obs_count
#if OS_WIN
,
count
#endif
]() { obs_count++; });
for (size_t i = 0; i < count; i++) {
loop.GetTaskRunner()->PostTask([&terminated, i, &task_count, count]() {
loop.GetTaskRunner()->PostTask([&terminated, i, &task_count
#if OS_WIN
,
count
#endif
]() {
ASSERT_EQ(task_count, i);
task_count++;
if (count == i + 1) {