diff options
Diffstat (limited to 'src/tests')
-rw-r--r-- | src/tests/Makefile | 4 | ||||
-rw-r--r-- | src/tests/testSignals.cc | 24 |
2 files changed, 25 insertions, 3 deletions
diff --git a/src/tests/Makefile b/src/tests/Makefile index 668126e..dd329e6 100644 --- a/src/tests/Makefile +++ b/src/tests/Makefile | |||
@@ -1,5 +1,5 @@ | |||
1 | CXX=g++ | 1 | CXX=g++ |
2 | CXXFLAGS= -I.. -I../FbTk -I../.. -DDEBUG -DUSE_XFT -Wall -g -O2 ../FbTk/libFbTk.a | 2 | CXXFLAGS= -I.. -I../FbTk -I../.. -DDEBUG -DUSE_XFT -Wall -g -O2 -fno-inline |
3 | LIBS= | 3 | LIBS= |
4 | XFLAGS= -I/usr/X11R6/include | 4 | XFLAGS= -I/usr/X11R6/include |
5 | XLIBS= -L/usr/X11R6/lib -lX11 -lXft -lXpm -lImlib2 | 5 | XLIBS= -L/usr/X11R6/lib -lX11 -lXft -lXpm -lImlib2 |
@@ -17,7 +17,7 @@ glxtest: ../FbTk/App.hh glxtest.cc | |||
17 | ${CXX} glxtest.cc ${CXXFLAGS} ${XLIBS} -lGL -lGLU -lXpm -o glxtest | 17 | ${CXX} glxtest.cc ${CXXFLAGS} ${XLIBS} -lGL -lGLU -lXpm -o glxtest |
18 | 18 | ||
19 | testSignals: testSignals.o ../FbTk/Signal.hh ../FbTk/MemFun.hh | 19 | testSignals: testSignals.o ../FbTk/Signal.hh ../FbTk/MemFun.hh |
20 | $(CXX) $(LIBS) testSignals.o -o testSignals | 20 | $(CXX) $(LIBS) testSignals.o -o testSignals ../FbTk/libFbTk.a |
21 | 21 | ||
22 | testStringUtil: StringUtiltest.o | 22 | testStringUtil: StringUtiltest.o |
23 | $(CXX) $(LIBS) StringUtiltest.o ../FbTk/libFbTk.a -o testStringUtil | 23 | $(CXX) $(LIBS) StringUtiltest.o ../FbTk/libFbTk.a -o testStringUtil |
diff --git a/src/tests/testSignals.cc b/src/tests/testSignals.cc index 6d68d3a..f382289 100644 --- a/src/tests/testSignals.cc +++ b/src/tests/testSignals.cc | |||
@@ -3,6 +3,9 @@ using namespace std; | |||
3 | 3 | ||
4 | #include "../FbTk/Signal.hh" | 4 | #include "../FbTk/Signal.hh" |
5 | #include "../FbTk/MemFun.hh" | 5 | #include "../FbTk/MemFun.hh" |
6 | #include "../FbTk/RelaySignal.hh" | ||
7 | #include "../FbTk/Observer.hh" | ||
8 | #include "../FbTk/Subject.hh" | ||
6 | 9 | ||
7 | #include <string> | 10 | #include <string> |
8 | 11 | ||
@@ -138,5 +141,24 @@ int main() { | |||
138 | 2.9); | 141 | 2.9); |
139 | 142 | ||
140 | } | 143 | } |
141 | 144 | // Test relay new signals to old | |
145 | { | ||
146 | cout << "---------- Testing relay of signals" << endl; | ||
147 | struct Observer: public FbTk::Observer { | ||
148 | void update(FbTk::Subject* subj) { | ||
149 | cout << "Observer called." << endl; | ||
150 | } | ||
151 | }; | ||
152 | // setup old subject->observer listening | ||
153 | FbTk::Subject destination; | ||
154 | Observer obs; | ||
155 | destination.attach(&obs); | ||
156 | // create a new signal and relay it to the | ||
157 | // old subject | ||
158 | FbTk::Signal<void, string> source; | ||
159 | FbTk::relaySignal(source, destination); | ||
160 | // the new signal should now make the old | ||
161 | // subject notify its observers | ||
162 | source.emit("hello world"); | ||
163 | } | ||
142 | } | 164 | } |