Flutter Engine
 
Loading...
Searching...
No Matches
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 12 of file test_timeout_listener.cc.

Constructor & Destructor Documentation

◆ ~PendingTests()

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

Member Function Documentation

◆ CheckTimedOutTests()

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

Definition at line 39 of file test_timeout_listener.cc.

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

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

◆ Create()

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

Definition at line 14 of file test_timeout_listener.cc.

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

◆ OnTestBegin()

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

Definition at line 23 of file test_timeout_listener.cc.

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

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

◆ OnTestEnd()

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

Definition at line 37 of file test_timeout_listener.cc.

37{ tests_.erase(test_name); }

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