Flutter Engine
flutter::testing::PendingTests Class Reference
Inheritance diagram for flutter::testing::PendingTests:

Public Member Functions

 ~PendingTests ()=default
 
void OnTestBegin (const std::string &test_name, fml::TimePoint test_time)
 
void OnTestEnd (const std::string &test_name)
 
void CheckTimedOutTests () const
 

Static Public Member Functions

static std::shared_ptr< PendingTestsCreate (fml::RefPtr< fml::TaskRunner > host_task_runner, fml::TimeDelta timeout)
 

Detailed Description

Definition at line 13 of file test_timeout_listener.cc.

Constructor & Destructor Documentation

◆ ~PendingTests()

flutter::testing::PendingTests::~PendingTests ( )
default

Referenced by Create().

Member Function Documentation

◆ CheckTimedOutTests()

void flutter::testing::PendingTests::CheckTimedOutTests ( ) const
inline

Definition at line 40 of file test_timeout_listener.cc.

References FML_CHECK, fml::TimePoint::Now(), and fml::TimeDelta::ToSeconds().

40  {
41  const auto now = fml::TimePoint::Now();
42 
43  for (const auto& test : tests_) {
44  auto delay = now - test.second;
45  FML_CHECK(delay < timeout_)
46  << "Test " << test.first << " did not complete in "
47  << timeout_.ToSeconds()
48  << " seconds and is assumed to be hung. Killing the test harness.";
49  }
50  }
constexpr int64_t ToSeconds() const
Definition: time_delta.h:64
#define FML_CHECK(condition)
Definition: logging.h:68
static TimePoint Now()
Definition: time_point.cc:26

◆ Create()

static std::shared_ptr<PendingTests> flutter::testing::PendingTests::Create ( fml::RefPtr< fml::TaskRunner host_task_runner,
fml::TimeDelta  timeout 
)
inlinestatic

Definition at line 15 of file test_timeout_listener.cc.

References ~PendingTests().

17  {
18  return std::shared_ptr<PendingTests>(
19  new PendingTests(std::move(host_task_runner), timeout));
20  }

◆ OnTestBegin()

void flutter::testing::PendingTests::OnTestBegin ( const std::string &  test_name,
fml::TimePoint  test_time 
)
inline

Definition at line 24 of file test_timeout_listener.cc.

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

24  {
25  FML_CHECK(tests_.find(test_name) == tests_.end())
26  << "Attempting to start a test that is already pending.";
27  tests_[test_name] = test_time;
28 
29  host_task_runner_->PostDelayedTask(
30  [weak = weak_from_this()] {
31  if (auto strong = weak.lock()) {
32  strong->CheckTimedOutTests();
33  }
34  },
35  timeout_);
36  }
#define FML_CHECK(condition)
Definition: logging.h:68
virtual void PostDelayedTask(const fml::closure &task, fml::TimeDelta delay)
Definition: task_runner.cc:33

◆ OnTestEnd()

void flutter::testing::PendingTests::OnTestEnd ( const std::string &  test_name)
inline

Definition at line 38 of file test_timeout_listener.cc.

38 { tests_.erase(test_name); }

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