Flutter Engine
thread_unittests.cc File Reference
#include "flutter/fml/thread.h"
#include "gtest/gtest.h"

Go to the source code of this file.

Functions

 TEST (Thread, CanStartAndEnd)
 
 TEST (Thread, CanStartAndEndWithExplicitJoin)
 
 TEST (Thread, HasARunningMessageLoop)
 

Function Documentation

◆ TEST() [1/3]

TEST ( Thread  ,
CanStartAndEnd   
)

Definition at line 9 of file thread_unittests.cc.

References fml::Thread::GetTaskRunner().

9  {
10  fml::Thread thread;
11  ASSERT_TRUE(thread.GetTaskRunner());
12 }
fml::RefPtr< fml::TaskRunner > GetTaskRunner() const
Definition: thread.cc:45

◆ TEST() [2/3]

TEST ( Thread  ,
CanStartAndEndWithExplicitJoin   
)

Definition at line 14 of file thread_unittests.cc.

References fml::Thread::GetTaskRunner(), and fml::Thread::Join().

14  {
15  fml::Thread thread;
16  ASSERT_TRUE(thread.GetTaskRunner());
17  thread.Join();
18 }
fml::RefPtr< fml::TaskRunner > GetTaskRunner() const
Definition: thread.cc:45
void Join()
Definition: thread.cc:49

◆ TEST() [3/3]

TEST ( Thread  ,
HasARunningMessageLoop   
)

Definition at line 20 of file thread_unittests.cc.

References fml::Thread::GetTaskRunner(), fml::Thread::Join(), and fml::TaskRunner::PostTask().

20  {
21  fml::Thread thread;
22  bool done = false;
23  thread.GetTaskRunner()->PostTask([&done]() { done = true; });
24  thread.Join();
25  ASSERT_TRUE(done);
26 }
fml::RefPtr< fml::TaskRunner > GetTaskRunner() const
Definition: thread.cc:45
virtual void PostTask(const fml::closure &task)
Definition: task_runner.cc:24
void Join()
Definition: thread.cc:49