Flutter Engine
flutter::testing::TestIOManager Class Referencefinal
Inheritance diagram for flutter::testing::TestIOManager:
flutter::IOManager

Public Member Functions

 TestIOManager (fml::RefPtr< fml::TaskRunner > task_runner, bool has_gpu_context=true)
 
 ~TestIOManager () override
 
fml::WeakPtr< IOManagerGetWeakIOManager () const override
 
fml::WeakPtr< GrDirectContext > GetResourceContext () const override
 
fml::RefPtr< flutter::SkiaUnrefQueueGetSkiaUnrefQueue () const override
 
std::shared_ptr< fml::SyncSwitchGetIsGpuDisabledSyncSwitch () override
 
- Public Member Functions inherited from flutter::IOManager
virtual ~IOManager ()=default
 

Public Attributes

bool did_access_is_gpu_disabled_sync_switch_ = false
 

Detailed Description

Definition at line 24 of file image_decoder_unittests.cc.

Constructor & Destructor Documentation

◆ TestIOManager()

flutter::testing::TestIOManager::TestIOManager ( fml::RefPtr< fml::TaskRunner task_runner,
bool  has_gpu_context = true 
)
inlineexplicit

Definition at line 26 of file image_decoder_unittests.cc.

References FML_CHECK, and fml::TaskRunner::RunsTasksOnCurrentThread().

28  : gl_surface_(SkISize::Make(1, 1)),
29  gl_context_(has_gpu_context ? gl_surface_.CreateGrContext() : nullptr),
30  weak_gl_context_factory_(
31  has_gpu_context
32  ? std::make_unique<fml::WeakPtrFactory<GrDirectContext>>(
33  gl_context_.get())
34  : nullptr),
35  unref_queue_(fml::MakeRefCounted<SkiaUnrefQueue>(
36  task_runner,
38  runner_(task_runner),
39  is_gpu_disabled_sync_switch_(std::make_shared<fml::SyncSwitch>()),
40  weak_factory_(this) {
41  FML_CHECK(task_runner->RunsTasksOnCurrentThread())
42  << "The IO manager must be initialized its primary task runner. The "
43  "test harness may not be setup correctly/safely.";
44  weak_prototype_ = weak_factory_.GetWeakPtr();
45  }
sk_sp< GrDirectContext > CreateGrContext()
static constexpr TimeDelta FromNanoseconds(int64_t nanos)
Definition: time_delta.h:40
#define FML_CHECK(condition)
Definition: logging.h:68
virtual bool RunsTasksOnCurrentThread()
Definition: task_runner.cc:43

◆ ~TestIOManager()

flutter::testing::TestIOManager::~TestIOManager ( )
inlineoverride

Definition at line 47 of file image_decoder_unittests.cc.

References fml::TaskRunner::RunNowOrPostTask(), fml::AutoResetWaitableEvent::Signal(), and fml::AutoResetWaitableEvent::Wait().

47  {
50  [&latch, queue = unref_queue_]() {
51  queue->Drain();
52  latch.Signal();
53  });
54  latch.Wait();
55  }
static void RunNowOrPostTask(fml::RefPtr< fml::TaskRunner > runner, const fml::closure &task)
Definition: task_runner.cc:55

Member Function Documentation

◆ GetIsGpuDisabledSyncSwitch()

std::shared_ptr<fml::SyncSwitch> flutter::testing::TestIOManager::GetIsGpuDisabledSyncSwitch ( )
inlineoverridevirtual

Implements flutter::IOManager.

Definition at line 74 of file image_decoder_unittests.cc.

References did_access_is_gpu_disabled_sync_switch_.

74  {
76  return is_gpu_disabled_sync_switch_;
77  }

◆ GetResourceContext()

fml::WeakPtr<GrDirectContext> flutter::testing::TestIOManager::GetResourceContext ( ) const
inlineoverridevirtual

Implements flutter::IOManager.

Definition at line 63 of file image_decoder_unittests.cc.

63  {
64  return weak_gl_context_factory_ ? weak_gl_context_factory_->GetWeakPtr()
66  }

◆ GetSkiaUnrefQueue()

fml::RefPtr<flutter::SkiaUnrefQueue> flutter::testing::TestIOManager::GetSkiaUnrefQueue ( ) const
inlineoverridevirtual

Implements flutter::IOManager.

Definition at line 69 of file image_decoder_unittests.cc.

69  {
70  return unref_queue_;
71  }

◆ GetWeakIOManager()

fml::WeakPtr<IOManager> flutter::testing::TestIOManager::GetWeakIOManager ( ) const
inlineoverridevirtual

Implements flutter::IOManager.

Definition at line 58 of file image_decoder_unittests.cc.

58  {
59  return weak_prototype_;
60  }

Member Data Documentation

◆ did_access_is_gpu_disabled_sync_switch_

bool flutter::testing::TestIOManager::did_access_is_gpu_disabled_sync_switch_ = false

Definition at line 79 of file image_decoder_unittests.cc.

Referenced by GetIsGpuDisabledSyncSwitch().


The documentation for this class was generated from the following file: