[NTFS]
[reactos.git] / rostests / apitests / user32 / helper.h
1
2 typedef enum _MSG_TYPE
3 {
4 SENT,
5 POST,
6 HOOK,
7 EVENT
8 } MSG_TYPE;
9
10 typedef struct _MSG_ENTRY
11 {
12 int iwnd;
13 UINT msg;
14 MSG_TYPE type;
15 int param1;
16 int param2;
17 } MSG_ENTRY;
18
19 typedef struct _MSG_CACHE
20 {
21 MSG_ENTRY last_post_message;
22 MSG_ENTRY message_cache[100];
23 int count;
24 } MSG_CACHE;
25
26 extern MSG_ENTRY empty_chain[];
27 extern MSG_CACHE default_cache;
28
29 void record_message(MSG_CACHE* cache, int iwnd, UINT message, MSG_TYPE type, int param1,int param2);
30 void compare_cache(MSG_CACHE* cache, const char* file, int line, MSG_ENTRY *msg_chain);
31 void trace_cache(MSG_CACHE* cache, const char* file, int line);
32 void empty_message_cache(MSG_CACHE* cache);
33
34 ATOM RegisterSimpleClass(WNDPROC lpfnWndProc, LPCWSTR lpszClassName);
35
36 /* filter messages that are affected by dwm */
37 static inline BOOL IsDWmMsg(UINT msg)
38 {
39 switch(msg)
40 {
41 case WM_NCPAINT:
42 case WM_ERASEBKGND:
43 case WM_PAINT:
44 case 0x031f: /*WM_DWMNCRENDERINGCHANGED*/
45 return TRUE;
46 }
47 return FALSE;
48 }
49
50 static inline BOOL IseKeyMsg(UINT msg)
51 {
52 return (msg == WM_KEYUP || msg == WM_KEYDOWN);
53 }
54
55 #define COMPARE_CACHE(msg_chain) compare_cache(&default_cache, __FILE__, __LINE__, msg_chain)
56 #define TRACE_CACHE() trace_cache(&default_cache, __FILE__, __LINE__)
57 #define EMPTY_CACHE() empty_message_cache(&default_cache);
58 #define RECOND_MESSAGE(...) record_message(&default_cache, ##__VA_ARGS__);
59
60 #define COMPARE_CACHE_(cache, msg_chain) compare_cache(cache, __FILE__, __LINE__, msg_chain)
61 #define TRACE_CACHE_(cache) trace_cache(cache, __FILE__, __LINE__)
62 #define EMPTY_CACHE_(cache) empty_message_cache(cache);
63
64 #define EXPECT_QUEUE_STATUS(expected, notexpected) \
65 { \
66 DWORD status = HIWORD(GetQueueStatus(QS_ALLEVENTS)); \
67 ok(((status) & (expected))== (expected),"wrong queue status. expected %li, and got %li\n", (DWORD)(expected), status); \
68 if(notexpected) \
69 ok((status & (notexpected))!=(notexpected), "wrong queue status. got non expected %li\n", (DWORD)(notexpected)); \
70 }