Parker Schuh | e4a70d6 | 2017-12-27 20:10:20 -0800 | [diff] [blame^] | 1 | #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 | |
| 7 | namespace aos { |
| 8 | namespace testing { |
| 9 | |
| 10 | class EventLoopTestFactory { |
| 11 | public: |
| 12 | virtual ~EventLoopTestFactory() {} |
| 13 | |
| 14 | virtual std::unique_ptr<EventLoop> Make() = 0; |
| 15 | }; |
| 16 | |
| 17 | class 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_ |