5#include "flutter/testing/test_timeout_listener.h"
13class PendingTests :
public std::enable_shared_from_this<PendingTests> {
15 static std::shared_ptr<PendingTests>
Create(
18 return std::shared_ptr<PendingTests>(
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;
30 [weak = weak_from_this()] {
31 if (
auto strong = weak.lock()) {
32 strong->CheckTimedOutTests();
38 void OnTestEnd(
const std::string& test_name) { tests_.erase(test_name); }
43 for (
const auto&
test : tests_) {
44 auto delay = now -
test.second;
46 <<
"Test " <<
test.first <<
" did not complete in "
48 <<
" seconds and is assumed to be hung. Killing the test harness.";
53 using TestData = std::map<std::string, fml::TimePoint>;
61 : host_task_runner_(
std::move(host_task_runner)), timeout_(
timeout) {}
63 FML_DISALLOW_COPY_AND_ASSIGN(PendingTests);
68 return std::weak_ptr<T>{pointer};
73 listener_thread_(
"test_timeout_listener"),
74 listener_thread_runner_(listener_thread_.GetTaskRunner()),
77 <<
" seconds per test case will be enforced.";
82 [
tests = std::move(pending_tests_)]()
mutable {
tests.reset(); });
92 if (
auto type_param =
test_info.type_param()) {
93 stream <<
"/" << type_param;
95 if (
auto value_param =
test_info.value_param()) {
96 stream <<
"/" << value_param;
102void TestTimeoutListener::OnTestStart(const ::testing::TestInfo&
test_info) {
103 listener_thread_runner_->
PostTask([weak_tests =
WeakPtr(pending_tests_),
106 if (
auto tests = weak_tests.lock()) {
107 tests->OnTestBegin(name, now);
113void TestTimeoutListener::OnTestEnd(const ::testing::TestInfo&
test_info) {
115 [weak_tests =
WeakPtr(pending_tests_),
117 if (
auto tests = weak_tests.lock()) {
118 tests->OnTestEnd(name);
static void test_info(skiatest::Reporter *r, Codec *codec, const SkImageInfo &info, SkCodec::Result expectedResult, const SkMD5::Digest *goodDigest)
static sk_sp< Effect > Create()
void OnTestEnd(const std::string &test_name)
void OnTestBegin(const std::string &test_name, fml::TimePoint test_time)
static std::shared_ptr< PendingTests > Create(fml::RefPtr< fml::TaskRunner > host_task_runner, fml::TimeDelta timeout)
void CheckTimedOutTests() const
TestTimeoutListener(fml::TimeDelta timeout)
virtual void PostTask(const fml::closure &task) override
virtual void PostDelayedTask(const fml::closure &task, fml::TimeDelta delay)
constexpr int64_t ToSeconds() const
#define FML_LOG(severity)
#define FML_CHECK(condition)
auto WeakPtr(std::shared_ptr< T > pointer)
static std::string GetTestNameFromTestInfo(const ::testing::TestInfo &test_info)
DEF_SWITCHES_START aot vmservice shared library name
def timeout(deadline, cmd)