Fixes a few asan errors (flutter/engine#33632)
This commit is contained in:
@@ -191,12 +191,13 @@ TEST(MessageLoopTaskQueueMergeUnmerge, MergeInvokesBothWakeables) {
|
||||
|
||||
fml::CountDownLatch latch(2);
|
||||
|
||||
task_queue->SetWakeable(
|
||||
queue_id_1,
|
||||
new TestWakeable([&](fml::TimePoint wake_time) { latch.CountDown(); }));
|
||||
task_queue->SetWakeable(
|
||||
queue_id_2,
|
||||
new TestWakeable([&](fml::TimePoint wake_time) { latch.CountDown(); }));
|
||||
auto wakeable1 = std::make_unique<TestWakeable>(
|
||||
[&](fml::TimePoint wake_time) { latch.CountDown(); });
|
||||
auto wakeable2 = std::make_unique<TestWakeable>(
|
||||
[&](fml::TimePoint wake_time) { latch.CountDown(); });
|
||||
|
||||
task_queue->SetWakeable(queue_id_1, wakeable1.get());
|
||||
task_queue->SetWakeable(queue_id_2, wakeable2.get());
|
||||
|
||||
task_queue->RegisterTask(
|
||||
queue_id_1, []() {}, ChronoTicksSinceEpoch());
|
||||
@@ -217,12 +218,13 @@ TEST(MessageLoopTaskQueueMergeUnmerge,
|
||||
|
||||
fml::AutoResetWaitableEvent latch_1, latch_2;
|
||||
|
||||
task_queue->SetWakeable(
|
||||
queue_id_1,
|
||||
new TestWakeable([&](fml::TimePoint wake_time) { latch_1.Signal(); }));
|
||||
task_queue->SetWakeable(
|
||||
queue_id_2,
|
||||
new TestWakeable([&](fml::TimePoint wake_time) { latch_2.Signal(); }));
|
||||
auto wakeable1 = std::make_unique<TestWakeable>(
|
||||
[&](fml::TimePoint wake_time) { latch_1.Signal(); });
|
||||
auto wakeable2 = std::make_unique<TestWakeable>(
|
||||
[&](fml::TimePoint wake_time) { latch_2.Signal(); });
|
||||
|
||||
task_queue->SetWakeable(queue_id_1, wakeable1.get());
|
||||
task_queue->SetWakeable(queue_id_2, wakeable2.get());
|
||||
|
||||
task_queue->RegisterTask(
|
||||
queue_id_1, []() {}, ChronoTicksSinceEpoch());
|
||||
@@ -250,13 +252,14 @@ TEST(MessageLoopTaskQueueMergeUnmerge, GetTasksToRunNowBlocksMerge) {
|
||||
fml::AutoResetWaitableEvent wake_up_start, wake_up_end, merge_start,
|
||||
merge_end;
|
||||
|
||||
auto wakeable = std::make_unique<TestWakeable>([&](fml::TimePoint wake_time) {
|
||||
wake_up_start.Signal();
|
||||
wake_up_end.Wait();
|
||||
});
|
||||
|
||||
task_queue->RegisterTask(
|
||||
queue_id_1, []() {}, ChronoTicksSinceEpoch());
|
||||
task_queue->SetWakeable(queue_id_1,
|
||||
new TestWakeable([&](fml::TimePoint wake_time) {
|
||||
wake_up_start.Signal();
|
||||
wake_up_end.Wait();
|
||||
}));
|
||||
task_queue->SetWakeable(queue_id_1, wakeable.get());
|
||||
|
||||
std::thread tasks_to_run_now_thread(
|
||||
[&]() { CountRemainingTasks(task_queue, queue_id_1); });
|
||||
@@ -291,12 +294,13 @@ TEST(MessageLoopTaskQueueMergeUnmerge,
|
||||
|
||||
fml::CountDownLatch latch(2);
|
||||
|
||||
task_queue->SetWakeable(
|
||||
queue_id_1,
|
||||
new TestWakeable([&](fml::TimePoint wake_time) { latch.CountDown(); }));
|
||||
task_queue->SetWakeable(
|
||||
queue_id_2,
|
||||
new TestWakeable([&](fml::TimePoint wake_time) { latch.CountDown(); }));
|
||||
auto wakeable1 = std::make_unique<TestWakeable>(
|
||||
[&](fml::TimePoint wake_time) { latch.CountDown(); });
|
||||
auto wakeable2 = std::make_unique<TestWakeable>(
|
||||
[&](fml::TimePoint wake_time) { latch.CountDown(); });
|
||||
|
||||
task_queue->SetWakeable(queue_id_1, wakeable1.get());
|
||||
task_queue->SetWakeable(queue_id_2, wakeable2.get());
|
||||
|
||||
task_queue->RegisterTask(
|
||||
queue_id_2, [&]() { task_queue->Merge(queue_id_1, queue_id_2); },
|
||||
|
||||
@@ -41,10 +41,9 @@ TEST(MessageLoopTaskQueue, RegisterOneTask) {
|
||||
|
||||
auto task_queue = fml::MessageLoopTaskQueues::GetInstance();
|
||||
auto queue_id = task_queue->CreateTaskQueue();
|
||||
task_queue->SetWakeable(queue_id,
|
||||
new TestWakeable([&time](fml::TimePoint wake_time) {
|
||||
ASSERT_TRUE(wake_time == time);
|
||||
}));
|
||||
auto wakeable = std::make_unique<TestWakeable>(
|
||||
[&time](fml::TimePoint wake_time) { ASSERT_TRUE(wake_time == time); });
|
||||
task_queue->SetWakeable(queue_id, wakeable.get());
|
||||
|
||||
task_queue->RegisterTask(
|
||||
queue_id, [] {}, time);
|
||||
@@ -266,9 +265,9 @@ TEST(MessageLoopTaskQueue, WakeUpIndependentOfTime) {
|
||||
auto queue_id = task_queue->CreateTaskQueue();
|
||||
|
||||
int num_wakes = 0;
|
||||
task_queue->SetWakeable(
|
||||
queue_id, new TestWakeable(
|
||||
[&num_wakes](fml::TimePoint wake_time) { ++num_wakes; }));
|
||||
auto wakeable = std::make_unique<TestWakeable>(
|
||||
[&num_wakes](fml::TimePoint wake_time) { ++num_wakes; });
|
||||
task_queue->SetWakeable(queue_id, wakeable.get());
|
||||
|
||||
task_queue->RegisterTask(
|
||||
queue_id, []() {}, ChronoTicksSinceEpoch());
|
||||
@@ -285,11 +284,13 @@ TEST(MessageLoopTaskQueue, WokenUpWithNewerTime) {
|
||||
|
||||
fml::TimePoint expected = fml::TimePoint::Max();
|
||||
|
||||
task_queue->SetWakeable(
|
||||
queue_id, new TestWakeable([&latch, &expected](fml::TimePoint wake_time) {
|
||||
auto wakeable = std::make_unique<TestWakeable>(
|
||||
[&latch, &expected](fml::TimePoint wake_time) {
|
||||
ASSERT_TRUE(wake_time == expected);
|
||||
latch.CountDown();
|
||||
}));
|
||||
});
|
||||
|
||||
task_queue->SetWakeable(queue_id, wakeable.get());
|
||||
|
||||
task_queue->RegisterTask(
|
||||
queue_id, []() {}, fml::TimePoint::Max());
|
||||
@@ -418,16 +419,15 @@ TEST(MessageLoopTaskQueue, RegisterTaskWakesUpOwnerQueue) {
|
||||
|
||||
std::vector<fml::TimePoint> wakes;
|
||||
|
||||
task_queue->SetWakeable(platform_queue,
|
||||
new TestWakeable([&wakes](fml::TimePoint wake_time) {
|
||||
wakes.push_back(wake_time);
|
||||
}));
|
||||
auto wakeable1 = std::make_unique<TestWakeable>(
|
||||
[&wakes](fml::TimePoint wake_time) { wakes.push_back(wake_time); });
|
||||
auto wakeable2 = std::make_unique<TestWakeable>([](fml::TimePoint wake_time) {
|
||||
// The raster queue is owned by the platform queue.
|
||||
ASSERT_FALSE(true);
|
||||
});
|
||||
|
||||
task_queue->SetWakeable(raster_queue,
|
||||
new TestWakeable([](fml::TimePoint wake_time) {
|
||||
// The raster queue is owned by the platform queue.
|
||||
ASSERT_FALSE(true);
|
||||
}));
|
||||
task_queue->SetWakeable(platform_queue, wakeable1.get());
|
||||
task_queue->SetWakeable(raster_queue, wakeable2.get());
|
||||
|
||||
auto time1 = ChronoTicksSinceEpoch() + fml::TimeDelta::FromMilliseconds(1);
|
||||
auto time2 = ChronoTicksSinceEpoch() + fml::TimeDelta::FromMilliseconds(2);
|
||||
|
||||
@@ -3056,7 +3056,7 @@ TEST_F(EmbedderTest, FrameInfoContainsValidWidthAndHeight) {
|
||||
auto engine = builder.LaunchEngine();
|
||||
|
||||
// Send a window metrics events so frames may be scheduled.
|
||||
FlutterWindowMetricsEvent event = {};
|
||||
static FlutterWindowMetricsEvent event = {};
|
||||
event.struct_size = sizeof(event);
|
||||
event.width = 1024;
|
||||
event.height = 600;
|
||||
@@ -3065,7 +3065,7 @@ TEST_F(EmbedderTest, FrameInfoContainsValidWidthAndHeight) {
|
||||
kSuccess);
|
||||
ASSERT_TRUE(engine.is_valid());
|
||||
|
||||
fml::CountDownLatch frame_latch(10);
|
||||
static fml::CountDownLatch frame_latch(10);
|
||||
|
||||
context.AddNativeCallback("SignalNativeTest",
|
||||
CREATE_NATIVE_ENTRY([&](Dart_NativeArguments args) {
|
||||
@@ -3073,7 +3073,7 @@ TEST_F(EmbedderTest, FrameInfoContainsValidWidthAndHeight) {
|
||||
}));
|
||||
|
||||
static_cast<EmbedderTestContextGL&>(context).SetGLGetFBOCallback(
|
||||
[&event, &frame_latch](FlutterFrameInfo frame_info) {
|
||||
[](FlutterFrameInfo frame_info) {
|
||||
// width and height are rotated by 90 deg
|
||||
ASSERT_EQ(frame_info.size.width, event.height);
|
||||
ASSERT_EQ(frame_info.size.height, event.width);
|
||||
@@ -3130,7 +3130,7 @@ TEST_F(EmbedderTest, PresentInfoContainsValidFBOId) {
|
||||
kSuccess);
|
||||
ASSERT_TRUE(engine.is_valid());
|
||||
|
||||
fml::CountDownLatch frame_latch(10);
|
||||
static fml::CountDownLatch frame_latch(10);
|
||||
|
||||
context.AddNativeCallback("SignalNativeTest",
|
||||
CREATE_NATIVE_ENTRY([&](Dart_NativeArguments args) {
|
||||
@@ -3140,7 +3140,7 @@ TEST_F(EmbedderTest, PresentInfoContainsValidFBOId) {
|
||||
const uint32_t window_fbo_id =
|
||||
static_cast<EmbedderTestContextGL&>(context).GetWindowFBOId();
|
||||
static_cast<EmbedderTestContextGL&>(context).SetGLPresentCallback(
|
||||
[window_fbo_id = window_fbo_id, &frame_latch](uint32_t fbo_id) {
|
||||
[window_fbo_id = window_fbo_id](uint32_t fbo_id) {
|
||||
ASSERT_EQ(fbo_id, window_fbo_id);
|
||||
|
||||
frame_latch.CountDown();
|
||||
|
||||
Reference in New Issue
Block a user