1 | // |
2 | // BasicEventTest.h |
3 | // |
4 | // Tests for BasicEvent |
5 | // |
6 | // Copyright (c) 2006, Applied Informatics Software Engineering GmbH. |
7 | // and Contributors. |
8 | // |
9 | // SPDX-License-Identifier: BSL-1.0 |
10 | // |
11 | |
12 | |
13 | #ifndef BasicEventTest_INCLUDED |
14 | #define BasicEventTest_INCLUDED |
15 | |
16 | |
17 | #include "Poco/Foundation.h" |
18 | #include "Poco/CppUnit/TestCase.h" |
19 | #include "Poco/BasicEvent.h" |
20 | #include "Poco/EventArgs.h" |
21 | |
22 | |
23 | class BasicEventTest: public CppUnit::TestCase |
24 | { |
25 | Poco::BasicEvent<void> Void; |
26 | Poco::BasicEvent<int> Simple; |
27 | Poco::BasicEvent<std::string> SimpleString; |
28 | Poco::BasicEvent<const std::string> ConstString; |
29 | Poco::BasicEvent<const int> ConstSimple; |
30 | Poco::BasicEvent<Poco::EventArgs*> Complex; |
31 | Poco::BasicEvent<Poco::EventArgs> Complex2; |
32 | Poco::BasicEvent<const Poco::EventArgs*> ConstComplex; |
33 | Poco::BasicEvent<const Poco::EventArgs * const> Const2Complex; |
34 | |
35 | public: |
36 | BasicEventTest(const std::string& name); |
37 | ~BasicEventTest(); |
38 | |
39 | void testNoDelegate(); |
40 | void testSingleDelegate(); |
41 | void testDuplicateRegister(); |
42 | void testDuplicateUnregister(); |
43 | void testDisabling(); |
44 | void testExpire(); |
45 | void testExpireReRegister(); |
46 | void testReturnParams(); |
47 | void testOverwriteDelegate(); |
48 | void testAsyncNotify(); |
49 | void testNullMutex(); |
50 | void testLambda(); |
51 | |
52 | void setUp(); |
53 | void tearDown(); |
54 | static CppUnit::Test* suite(); |
55 | |
56 | protected: |
57 | |
58 | static void onStaticVoid(const void* pSender); |
59 | |
60 | void onVoid(const void* pSender); |
61 | |
62 | static void onStaticSimple(const void* pSender, int& i); |
63 | static void onStaticSimple2(void* pSender, int& i); |
64 | static void onStaticSimple3(int& i); |
65 | |
66 | void onSimpleNoSender(int& i); |
67 | void onSimple(const void* pSender, int& i); |
68 | void onSimpleOther(const void* pSender, int& i); |
69 | void onConstSimple(const void* pSender, const int& i); |
70 | void (const void* pSender, std::string& i); |
71 | void onConstString(const void* pSender, const std::string& i); |
72 | void onComplex(const void* pSender, Poco::EventArgs* & i); |
73 | void onComplex2(const void* pSender, Poco::EventArgs & i); |
74 | void onConstComplex(const void* pSender, const Poco::EventArgs*& i); |
75 | void onConst2Complex(const void* pSender, const Poco::EventArgs * const & i); |
76 | void onAsync(const void* pSender, int& i); |
77 | |
78 | int getCount() const; |
79 | private: |
80 | int _count; |
81 | std::string _str; |
82 | }; |
83 | |
84 | |
85 | #endif // BasicEventTest_INCLUDED |
86 | |