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