blob: ae215db82112dea67220e7f63bda7350e08ceecb [file] [log] [blame]
Parker Schuhe4a70d62017-12-27 20:10:20 -08001#ifndef _AOS_EVENTS_EVENT_LOOP_PARAM_TEST_H_
2#define _AOS_EVENTS_EVENT_LOOP_PARAM_TEST_H_
3
4#include "aos/events/event-loop.h"
5#include "gtest/gtest.h"
6
7namespace aos {
8namespace testing {
9
10class EventLoopTestFactory {
11 public:
12 virtual ~EventLoopTestFactory() {}
13
14 virtual std::unique_ptr<EventLoop> Make() = 0;
15};
16
17class AbstractEventLoopTest
18 : public ::testing::TestWithParam<std::function<EventLoopTestFactory *()>> {
19 public:
20 AbstractEventLoopTest() { factory_.reset(GetParam()()); }
21
22 std::unique_ptr<EventLoop> Make() { return factory_->Make(); }
23 // You can implement all the usual fixture class members here.
24 // To access the test parameter, call GetParam() from class
25 // TestWithParam<T>.
26 private:
27 std::unique_ptr<EventLoopTestFactory> factory_;
28};
29
30} // namespace testing
31} // namespace aos
32
33#endif // _AOS_EVENTS_EVENT_LOOP_PARAM_TEST_H_