explorerframe: Implement SetItemState and GetItemState.
[wine] / dlls / explorerframe / tests / msg.h
1 /* Message Sequence Testing Code
2  *
3  * Copyright (C) 2007 James Hawkins
4  * Copyright (C) 2007 Lei Zhang
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  */
20
21 #include <assert.h>
22 #include <windows.h>
23 #include "wine/test.h"
24
25 /* undocumented SWP flags - from SDK 3.1 */
26 #define SWP_NOCLIENTSIZE        0x0800
27 #define SWP_NOCLIENTMOVE        0x1000
28
29 typedef enum
30 {
31     sent = 0x1,
32     posted = 0x2,
33     parent = 0x4,
34     wparam = 0x8,
35     lparam = 0x10,
36     defwinproc = 0x20,
37     beginpaint = 0x40,
38     optional = 0x80,
39     hook = 0x100,
40     winevent_hook =0x200,
41     id = 0x400
42 } msg_flags_t;
43
44 struct message
45 {
46     UINT message;       /* the WM_* code */
47     msg_flags_t flags;  /* message props */
48     WPARAM wParam;      /* expected value of wParam */
49     LPARAM lParam;      /* expected value of lParam */
50     UINT id;            /* extra message data: id of the window,
51                            notify code etc. */
52 };
53
54 struct msg_sequence
55 {
56     int count;
57     int size;
58     struct message *sequence;
59 };
60
61 static void add_message(struct msg_sequence **seq, int sequence_index,
62     const struct message *msg)
63 {
64     struct msg_sequence *msg_seq = seq[sequence_index];
65
66     if (!msg_seq->sequence)
67     {
68         msg_seq->size = 10;
69         msg_seq->sequence = HeapAlloc(GetProcessHeap(), 0,
70                                       msg_seq->size * sizeof (struct message));
71     }
72
73     if (msg_seq->count == msg_seq->size)
74     {
75         msg_seq->size *= 2;
76         msg_seq->sequence = HeapReAlloc(GetProcessHeap(), 0,
77                                         msg_seq->sequence,
78                                         msg_seq->size * sizeof (struct message));
79     }
80
81     assert(msg_seq->sequence);
82
83     msg_seq->sequence[msg_seq->count].message = msg->message;
84     msg_seq->sequence[msg_seq->count].flags = msg->flags;
85     msg_seq->sequence[msg_seq->count].wParam = msg->wParam;
86     msg_seq->sequence[msg_seq->count].lParam = msg->lParam;
87     msg_seq->sequence[msg_seq->count].id = msg->id;
88
89     msg_seq->count++;
90 }
91
92 static void flush_sequence(struct msg_sequence **seg, int sequence_index)
93 {
94     struct msg_sequence *msg_seq = seg[sequence_index];
95     HeapFree(GetProcessHeap(), 0, msg_seq->sequence);
96     msg_seq->sequence = NULL;
97     msg_seq->count = msg_seq->size = 0;
98 }
99
100 static void flush_sequences(struct msg_sequence **seq, int n)
101 {
102     int i;
103
104     for (i = 0; i < n; i++)
105         flush_sequence(seq, i);
106 }
107
108 /* ok_sequence is stripped out as it is not currently used. */
109
110 static void init_msg_sequences(struct msg_sequence **seq, int n)
111 {
112     int i;
113
114     for (i = 0; i < n; i++)
115         seq[i] = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct msg_sequence));
116 }