diff options
Diffstat (limited to 'src/tests/testSignals.cc')
-rw-r--r-- | src/tests/testSignals.cc | 24 |
1 files changed, 23 insertions, 1 deletions
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 | } |