Skip to content

Commit

Permalink
Added an event loop unit test for the Monitor class
Browse files Browse the repository at this point in the history
  • Loading branch information
gansm committed Aug 13, 2023
1 parent 515826f commit ed9bbcb
Show file tree
Hide file tree
Showing 6 changed files with 264 additions and 15 deletions.
8 changes: 8 additions & 0 deletions final/eventloop/eventloop.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include <array>

#include "final/eventloop/monitor.h"
#include "final/util/fstring.h"

namespace finalcut
{
Expand All @@ -50,6 +51,9 @@ class EventLoop
// Constructor
EventLoop() = default;

// Accessor
auto getClassName() const -> FString;

// Methods
auto run() -> int;
void leave();
Expand Down Expand Up @@ -77,6 +81,10 @@ class EventLoop
};

// EventLoop inline functions
//----------------------------------------------------------------------
inline auto EventLoop::getClassName() const -> FString
{ return "EventLoop"; }

//----------------------------------------------------------------------
inline void EventLoop::leave()
{ running = false; }
Expand Down
9 changes: 9 additions & 0 deletions final/eventloop/io_monitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#define IO_MONITOR_H

#include "final/eventloop/monitor.h"
#include "final/util/fstring.h"

namespace finalcut
{
Expand All @@ -62,12 +63,20 @@ class IoMonitor final : public Monitor
// Destructor
~IoMonitor() noexcept override;

// Accessor
auto getClassName() const -> FString;

// Method
void init (int, short, handler_t, void*);
auto operator = (const IoMonitor&) -> IoMonitor& = delete;
auto operator = (const IoMonitor&&) -> IoMonitor& = delete;
};

// IoMonitor inline functions
//----------------------------------------------------------------------
inline auto IoMonitor::getClassName() const -> FString
{ return "IoMonitor"; }

} // namespace finalcut

#endif // IO_MONITOR_H
7 changes: 7 additions & 0 deletions final/eventloop/monitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
#include <stdexcept>
#include <string>

#include "final/util/fstring.h"

namespace finalcut
{

Expand Down Expand Up @@ -94,6 +96,7 @@ class Monitor
virtual ~Monitor();

// Accessors
auto getClassName() const -> FString;
auto getEvents() const -> short;
auto getFileDescriptor() const -> int;
auto getUserContext() const -> void*;
Expand Down Expand Up @@ -143,6 +146,10 @@ class Monitor
};

// Monitor inline functions
//----------------------------------------------------------------------
inline auto Monitor::getClassName() const -> FString
{ return "Monitor"; }

//----------------------------------------------------------------------
inline auto Monitor::getEvents() const -> short
{ return events; }
Expand Down
9 changes: 9 additions & 0 deletions final/eventloop/signal_monitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include <memory>

#include "final/eventloop/monitor.h"
#include "final/util/fstring.h"

namespace finalcut
{
Expand All @@ -66,6 +67,9 @@ class SignalMonitor final : public Monitor
// Destructor
~SignalMonitor() noexcept override;

// Accessor
auto getClassName() const -> FString;

// Methods
void init (int, handler_t, void*);
void trigger (short) override;
Expand All @@ -91,6 +95,11 @@ class SignalMonitor final : public Monitor
std::unique_ptr<SigactionImpl> impl;
};

// SignalMonitor inline functions
//----------------------------------------------------------------------
inline auto SignalMonitor::getClassName() const -> FString
{ return "SignalMonitor"; }

} // namespace finalcut

#endif // SIGNAL_MONITOR_H
33 changes: 18 additions & 15 deletions test/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ AM_LDFLAGS = -L$(top_builddir)/final/.libs
AM_CPPFLAGS = -I$(top_srcdir)/final -Wall -Werror -std=c++14

noinst_PROGRAMS = \
char_ringbuffer_test \
eventloop_monitor_test \
fcallback_test \
fcolorpair_test \
fdata_test \
fevent_test \
char_ringbuffer_test \
fkeyboard_test \
flogger_test \
fmouse_test \
Expand All @@ -24,15 +25,15 @@ noinst_PROGRAMS = \
fpoint_test \
frect_test \
fsize_test \
fstringstream_test \
fstring_test \
fstringstream_test \
fstyle_test \
ftermcapquirks_test \
fterm_functions_test \
ftermcap_test \
ftermcapquirks_test \
ftermdata_test \
ftermdetection_test \
ftermfreebsd_test \
fterm_functions_test \
ftermlinux_test \
ftermopenbsd_test \
ftimer_test \
Expand All @@ -41,11 +42,12 @@ noinst_PROGRAMS = \
fvtermbuffer_test \
fwidget_test

char_ringbuffer_test_SOURCES = char_ringbuffer-test.cpp
eventloop_monitor_test_SOURCES = eventloop-monitor-test.cpp
fcallback_test_SOURCES = fcallback-test.cpp
fcolorpair_test_SOURCES = fcolorpair-test.cpp
fdata_test_SOURCES = fdata-test.cpp
fevent_test_SOURCES = fevent-test.cpp
char_ringbuffer_test_SOURCES = char_ringbuffer-test.cpp
fkeyboard_test_SOURCES = fkeyboard-test.cpp
flogger_test_SOURCES = flogger-test.cpp
fmouse_test_SOURCES = fmouse-test.cpp
Expand All @@ -55,32 +57,33 @@ foptimove_test_SOURCES = foptimove-test.cpp
fpoint_test_SOURCES = fpoint-test.cpp
frect_test_SOURCES = frect-test.cpp
fsize_test_SOURCES = fsize-test.cpp
fstringstream_test_SOURCES = fstringstream-test.cpp
fstring_test_SOURCES = fstring-test.cpp
fstringstream_test_SOURCES = fstringstream-test.cpp
fstyle_test_SOURCES = fstyle-test.cpp
ftermcapquirks_test_SOURCES = ftermcapquirks-test.cpp
fterm_functions_test_SOURCES = fterm_functions-test.cpp
ftermcap_test_SOURCES = ftermcap-test.cpp
ftermcapquirks_test_SOURCES = ftermcapquirks-test.cpp
ftermdata_test_SOURCES = ftermdata-test.cpp
ftermdetection_test_SOURCES = ftermdetection-test.cpp
ftermfreebsd_test_SOURCES = ftermfreebsd-test.cpp
ftermfreebsd_test_LDADD = @TERMCAP_LIB@
fterm_functions_test_SOURCES = fterm_functions-test.cpp
ftermlinux_test_SOURCES = ftermlinux-test.cpp
ftermfreebsd_test_SOURCES = ftermfreebsd-test.cpp
ftermlinux_test_LDADD = @TERMCAP_LIB@
ftermopenbsd_test_SOURCES = ftermopenbsd-test.cpp
ftermlinux_test_SOURCES = ftermlinux-test.cpp
ftermopenbsd_test_LDADD = @TERMCAP_LIB@
ftermopenbsd_test_SOURCES = ftermopenbsd-test.cpp
ftimer_test_SOURCES = ftimer-test.cpp
fvterm_test_SOURCES = fvterm-test.cpp
fvtermattribute_test_SOURCES = fvtermattribute-test.cpp
fvtermbuffer_test_SOURCES = fvtermbuffer-test.cpp
fwidget_test_SOURCES = fwidget-test.cpp

TESTS = \
char_ringbuffer_test \
eventloop_monitor_test \
fcallback_test \
fcolorpair_test \
fdata_test \
fevent_test \
char_ringbuffer_test \
fkeyboard_test \
flogger_test \
fmouse_test \
Expand All @@ -90,15 +93,15 @@ TESTS = \
fpoint_test \
frect_test \
fsize_test \
fstringstream_test \
fstring_test \
fstringstream_test \
fstyle_test \
ftermcapquirks_test \
fterm_functions_test \
ftermcap_test \
ftermcapquirks_test \
ftermdata_test \
ftermdetection_test \
ftermfreebsd_test \
fterm_functions_test \
ftermlinux_test \
ftermopenbsd_test \
ftimer_test \
Expand Down
Loading

0 comments on commit ed9bbcb

Please sign in to comment.