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 | |
Neil Balch | 229001a | 2018-01-07 18:22:52 -0800 | [diff] [blame] | 4 | #include <vector> |
| 5 | |
Parker Schuh | e4a70d6 | 2017-12-27 20:10:20 -0800 | [diff] [blame] | 6 | #include "aos/events/event-loop.h" |
| 7 | #include "gtest/gtest.h" |
| 8 | |
| 9 | namespace aos { |
| 10 | namespace testing { |
| 11 | |
| 12 | class EventLoopTestFactory { |
| 13 | public: |
| 14 | virtual ~EventLoopTestFactory() {} |
| 15 | |
| 16 | virtual std::unique_ptr<EventLoop> Make() = 0; |
| 17 | }; |
| 18 | |
| 19 | class AbstractEventLoopTest |
| 20 | : public ::testing::TestWithParam<std::function<EventLoopTestFactory *()>> { |
| 21 | public: |
| 22 | AbstractEventLoopTest() { factory_.reset(GetParam()()); } |
| 23 | |
| 24 | std::unique_ptr<EventLoop> Make() { return factory_->Make(); } |
| 25 | // You can implement all the usual fixture class members here. |
| 26 | // To access the test parameter, call GetParam() from class |
| 27 | // TestWithParam<T>. |
| 28 | private: |
| 29 | std::unique_ptr<EventLoopTestFactory> factory_; |
| 30 | }; |
| 31 | |
| 32 | } // namespace testing |
| 33 | } // namespace aos |
| 34 | |
| 35 | #endif // _AOS_EVENTS_EVENT_LOOP_PARAM_TEST_H_ |