5#include "flutter/flow/skia_gpu_object.h"
10#include "flutter/fml/message_loop.h"
11#include "flutter/fml/synchronization/waitable_event.h"
12#include "flutter/fml/task_runner.h"
13#include "flutter/testing/thread_test.h"
14#include "gtest/gtest.h"
25 : latch_(
std::move(latch)), dtor_task_queue_id_(dtor_task_queue_id) {}
28 if (dtor_task_queue_id_) {
35 std::shared_ptr<fml::AutoResetWaitableEvent> latch_;
56 fml::TimeDelta::FromSeconds(0))),
59 fml::TimeDelta::FromSeconds(3))) {
63 std::promise<bool> queues_created;
64 unref_task_runner_->
PostTask([
this, &queues_created]() {
65 unref_queue_ = fml::MakeRefCounted<SkiaUnrefQueue>(
67 delayed_unref_queue_ = fml::MakeRefCounted<SkiaUnrefQueue>(
69 queues_created.set_value(
true);
71 queues_created.get_future().wait();
72 ::testing::FLAGS_gtest_death_test_style =
"threadsafe";
76 return unref_task_runner_;
80 return delayed_unref_queue_;
90 std::shared_ptr<fml::AutoResetWaitableEvent> latch =
91 std::make_shared<fml::AutoResetWaitableEvent>();
95 unref_queue()->Unref(ref_object);
97 ASSERT_EQ(dtor_task_queue_id, unref_task_runner()->GetTaskQueueId());
101 std::shared_ptr<fml::AutoResetWaitableEvent> latch =
102 std::make_shared<fml::AutoResetWaitableEvent>();
104 auto object = sk_make_sp<TestSkObject>(latch, &dtor_task_queue_id);
111 ASSERT_EQ(dtor_task_queue_id, unref_task_runner()->GetTaskQueueId());
115 std::shared_ptr<fml::AutoResetWaitableEvent> latch =
116 std::make_shared<fml::AutoResetWaitableEvent>();
119 sk_make_sp<TestSkObject>(latch, &dtor_task_queue_id), unref_queue());
124 ASSERT_EQ(dtor_task_queue_id, unref_task_runner()->GetTaskQueueId());
128 std::shared_ptr<fml::AutoResetWaitableEvent> latch =
129 std::make_shared<fml::AutoResetWaitableEvent>();
132 sk_make_sp<TestSkObject>(latch, &dtor_task_queue_id), unref_queue());
140 ASSERT_EQ(dtor_task_queue_id, unref_task_runner()->GetTaskQueueId());
144 std::shared_ptr<fml::AutoResetWaitableEvent> latch =
145 std::make_shared<fml::AutoResetWaitableEvent>();
148 unref_task_runner()->PostTask([&]() {
149 auto resource_context =
150 sk_make_sp<TestResourceContext>(latch, &dtor_task_queue_id);
151 unref_queue = fml::MakeRefCounted<UnrefQueue<TestResourceContext>>(
153 std::move(resource_context));
160 unref_queue =
nullptr;
163 ASSERT_EQ(dtor_task_queue_id, unref_task_runner()->GetTaskQueueId());
sk_sp< SkiaObjectType > skia_object() const
fml::RefPtr< fml::TaskRunner > unref_task_runner()
fml::RefPtr< SkiaUnrefQueue > unref_queue()
fml::RefPtr< SkiaUnrefQueue > delayed_unref_queue()
void flushAndSubmit(GrSyncCpu sync)
void deleteBackendTexture(const GrBackendTexture &texture)
TestResourceContext(std::shared_ptr< fml::AutoResetWaitableEvent > latch, fml::TaskQueueId *dtor_task_queue_id)
~TestResourceContext()=default
void performDeferredCleanup(std::chrono::milliseconds msNotUsed)
TestSkObject(std::shared_ptr< fml::AutoResetWaitableEvent > latch, fml::TaskQueueId *dtor_task_queue_id)
A fixture that creates threads with running message loops that are terminated when the test is done (...
fml::RefPtr< fml::TaskRunner > CreateNewThread(const std::string &name="")
Creates a new thread, initializes a message loop on it, and, returns its task runner to the unit-test...
static TaskQueueId GetCurrentTaskQueueId()
virtual void PostTask(const fml::closure &task) override
static constexpr TimeDelta FromSeconds(int64_t seconds)
TEST_F(DisplayListTest, Defaults)
RefPtr< T > MakeRefCounted(Args &&... args)