summaryrefslogtreecommitdiff
path: root/test/libtest/test.h
diff options
context:
space:
mode:
authorSebastian Fricke <sebastian.fricke@posteo.net>2021-01-26 19:48:52 +0100
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2021-02-04 21:00:38 +0200
commitc440c828bc071effb76e60968c9d4a4a74c134df (patch)
treedc1cd84c3e2c0fe82189d06961d253806ad626a1 /test/libtest/test.h
parent11a946bc22212abd9eef467633e8ab359df57299 (diff)
libcamera: bayer_format: Overload ==/!= operators for BayerFormats
Enable to test two Bayer formats for equality by checking if the order of the color channels, the bit depth of the pattern, and the packing scheme match. Additionally, add the reverse operation (!=), which negates the equality test result. Signed-off-by: Sebastian Fricke <sebastian.fricke@posteo.net> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'test/libtest/test.h')
0 files changed, 0 insertions, 0 deletions
ass="hl pps">"test.h" using namespace libcamera; using namespace std; using namespace std::chrono_literals; class TimeoutHandler : public Object { public: TimeoutHandler() : timer_(this), timeout_(false) { timer_.timeout.connect(this, &TimeoutHandler::timeoutHandler); timer_.start(100ms); } void restart() { timeout_ = false; timer_.start(100ms); } bool timeout() const { return timeout_; } private: void timeoutHandler() { timeout_ = true; } Timer timer_; bool timeout_; }; class TimerThreadTest : public Test { protected: int init() { thread_.start(); timeout_.moveToThread(&thread_); return TestPass; } int run() { /* * Test that the timer expires and emits the timeout signal in * the thread it belongs to. */ this_thread::sleep_for(chrono::milliseconds(200)); if (!timeout_.timeout()) { cout << "Timer expiration test failed" << endl; return TestFail; } /* * Test that starting the timer from another thread fails. We * need to interrupt the event dispatcher to make sure we don't * succeed simply because the event dispatcher hasn't noticed * the timer restart. */ timeout_.restart(); thread_.eventDispatcher()->interrupt(); this_thread::sleep_for(chrono::milliseconds(200)); if (timeout_.timeout()) { cout << "Timer restart test failed" << endl; return TestFail; } return TestPass; } void cleanup() { /* Must stop thread before destroying timeout. */ thread_.exit(0); thread_.wait(); } private: TimeoutHandler timeout_; Thread thread_; }; TEST_REGISTER(TimerThreadTest)