]>
Commit | Line | Data |
---|---|---|
8899b155 RN |
1 | #include "wx/wxprec.h" |
2 | #include "wx/cppunit.h" | |
8da7a00a | 3 | |
232fdc63 VZ |
4 | // Custom test macro that is only defined when wxUIActionSimulator is available |
5 | // this allows the tests that do not rely on it to run on platforms that don't | |
6 | // support it. | |
7 | // | |
8 | // FIXME: And while OS X does support it, more or less, too many tests | |
9 | // currently fail under it so disable all interactive tests there. They | |
10 | // should, of course, be reenabled a.s.a.p. | |
11 | #if wxUSE_UIACTIONSIMULATOR && !defined(__WXOSX__) | |
12 | #define WXUISIM_TEST(test) CPPUNIT_TEST(test) | |
13 | #else | |
14 | #define WXUISIM_TEST(test) (void)0 | |
15 | #endif | |
16 | ||
8da7a00a VZ |
17 | // define wxHAVE_U_ESCAPE if the compiler supports \uxxxx character constants |
18 | #if (defined(__VISUALC__) && (__VISUALC__ >= 1300)) || \ | |
19 | (defined(__GNUC__) && (__GNUC__ >= 3)) | |
20 | #define wxHAVE_U_ESCAPE | |
a8f17758 VZ |
21 | |
22 | // and disable warning that using them results in with MSVC 8+ | |
23 | #if wxCHECK_VISUALC_VERSION(8) | |
24 | // universal-character-name encountered in source | |
25 | #pragma warning(disable:4428) | |
26 | #endif | |
8da7a00a | 27 | #endif |
0468a58a VZ |
28 | |
29 | // thrown when assert fails in debug build | |
b33e98f0 VZ |
30 | class TestAssertFailure |
31 | { | |
32 | public: | |
33 | TestAssertFailure(const wxString& file, | |
34 | int line, | |
35 | const wxString& func, | |
36 | const wxString& cond, | |
37 | const wxString& msg) | |
38 | : m_file(file), | |
39 | m_line(line), | |
40 | m_func(func), | |
41 | m_cond(cond), | |
42 | m_msg(msg) | |
43 | { | |
44 | } | |
45 | ||
46 | const wxString m_file; | |
47 | const int m_line; | |
48 | const wxString m_func; | |
49 | const wxString m_cond; | |
50 | const wxString m_msg; | |
51 | ||
52 | wxDECLARE_NO_ASSIGN_CLASS(TestAssertFailure); | |
53 | }; | |
0468a58a VZ |
54 | |
55 | // macro to use for the functions which are supposed to fail an assertion | |
657a8a35 | 56 | #if wxDEBUG_LEVEL |
0468a58a VZ |
57 | // some old cppunit versions don't define CPPUNIT_ASSERT_THROW so roll our |
58 | // own | |
59 | #define WX_ASSERT_FAILS_WITH_ASSERT(cond) \ | |
60 | { \ | |
61 | bool throwsAssert = false; \ | |
62 | try { cond ; } \ | |
63 | catch ( const TestAssertFailure& ) { throwsAssert = true; } \ | |
64 | if ( !throwsAssert ) \ | |
65 | CPPUNIT_FAIL("expected assertion not generated"); \ | |
66 | } | |
67 | #else | |
657a8a35 | 68 | // there are no assertions in this build so just check that it fails |
0468a58a VZ |
69 | #define WX_ASSERT_FAILS_WITH_ASSERT(cond) CPPUNIT_ASSERT(!(cond)) |
70 | #endif | |
71 | ||
1649d288 VZ |
72 | // these functions can be used to hook into wxApp event processing and are |
73 | // currently used by the events propagation test | |
9eab6725 VZ |
74 | class WXDLLIMPEXP_FWD_BASE wxEvent; |
75 | ||
1649d288 VZ |
76 | typedef int (*FilterEventFunc)(wxEvent&); |
77 | typedef bool (*ProcessEventFunc)(wxEvent&); | |
78 | ||
79 | extern void SetFilterEventFunc(FilterEventFunc func); | |
80 | extern void SetProcessEventFunc(ProcessEventFunc func); | |
1f51673b FM |
81 | |
82 | extern bool IsNetworkAvailable(); | |
701aa4d8 FM |
83 | |
84 | // helper class setting the locale to "C" for its lifetime | |
85 | class CLocaleSetter | |
86 | { | |
87 | public: | |
88 | CLocaleSetter() : m_locOld(setlocale(LC_ALL, "C")) { } | |
89 | ~CLocaleSetter() { setlocale(LC_ALL, m_locOld); } | |
90 | ||
91 | private: | |
92 | const char * const m_locOld; | |
93 | wxDECLARE_NO_COPY_CLASS(CLocaleSetter); | |
94 | }; |