ReactOS 0.4.16-dev-340-g0540c21
broadcast.c File Reference
#include <stdarg.h>
#include <stdio.h>
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "winuser.h"
#include "winnls.h"
#include "wine/test.h"
Include dependency graph for broadcast.c:

Go to the source code of this file.

Typedefs

typedef LONG(WINAPIPBROADCAST) (DWORD, LPDWORD, UINT, WPARAM, LPARAM)
 
typedef LONG(WINAPIPBROADCASTEX) (DWORD, LPDWORD, UINT, WPARAM, LPARAM, PBSMINFO)
 

Functions

static LRESULT WINAPI main_window_procA (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
 
static BOOL init_procs (void)
 
static void test_parameters (PBROADCAST broadcast, const char *functionname)
 
static void test_parametersEx (PBROADCASTEX broadcastex)
 
 START_TEST (broadcast)
 

Variables

static HANDLE hevent
 

Typedef Documentation

◆ PBROADCAST

typedef LONG(WINAPI * PBROADCAST) (DWORD, LPDWORD, UINT, WPARAM, LPARAM)

Definition at line 32 of file broadcast.c.

◆ PBROADCASTEX

typedef LONG(WINAPI * PBROADCASTEX) (DWORD, LPDWORD, UINT, WPARAM, LPARAM, PBSMINFO)

Definition at line 33 of file broadcast.c.

Function Documentation

◆ init_procs()

static BOOL init_procs ( void  )
static

Definition at line 53 of file broadcast.c.

54{
55 WNDCLASSA cls;
56
57 hevent = CreateEventA(NULL, TRUE, FALSE, "Asynchronous checking event");
58
59 cls.style = CS_DBLCLKS;
61 cls.cbClsExtra = 0;
62 cls.cbWndExtra = 0;
64 cls.hIcon = 0;
67 cls.lpszMenuName = NULL;
68 cls.lpszClassName = "MainWindowClass";
69
70 if (!RegisterClassA(&cls))
71 return FALSE;
72
73 if (!CreateWindowExA(0, "MainWindowClass", "Main window", WS_CAPTION | WS_SYSMENU |
74 WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_POPUP, 100, 100, 200,
75 200, 0, 0, GetModuleHandleA(NULL), NULL))
76 return FALSE;
77 return TRUE;
78}
static HANDLE hevent
Definition: broadcast.c:34
static LRESULT WINAPI main_window_procA(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: broadcast.c:36
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
#define WS_CAPTION
Definition: pedump.c:624
#define WS_MAXIMIZEBOX
Definition: pedump.c:632
#define WS_SYSMENU
Definition: pedump.c:629
#define WS_POPUP
Definition: pedump.c:616
#define WS_MINIMIZEBOX
Definition: pedump.c:631
HBRUSH hbrBackground
Definition: winuser.h:3173
HICON hIcon
Definition: winuser.h:3171
HINSTANCE hInstance
Definition: winuser.h:3170
HCURSOR hCursor
Definition: winuser.h:3172
int cbWndExtra
Definition: winuser.h:3169
UINT style
Definition: winuser.h:3166
LPCSTR lpszMenuName
Definition: winuser.h:3174
LPCSTR lpszClassName
Definition: winuser.h:3175
WNDPROC lpfnWndProc
Definition: winuser.h:3167
int cbClsExtra
Definition: winuser.h:3168
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventA(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCSTR lpName OPTIONAL)
Definition: synch.c:637
HGDIOBJ WINAPI GetStockObject(_In_ int)
#define WHITE_BRUSH
Definition: wingdi.h:902
HWND WINAPI CreateWindowExA(_In_ DWORD dwExStyle, _In_opt_ LPCSTR lpClassName, _In_opt_ LPCSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
#define IDC_ARROW
Definition: winuser.h:687
#define CS_DBLCLKS
Definition: winuser.h:651
ATOM WINAPI RegisterClassA(_In_ CONST WNDCLASSA *)
HCURSOR WINAPI LoadCursorA(_In_opt_ HINSTANCE, _In_ LPCSTR)
Definition: cursoricon.c:2142
const char * LPCSTR
Definition: xmlstorage.h:183

Referenced by START_TEST().

◆ main_window_procA()

static LRESULT WINAPI main_window_procA ( HWND  hwnd,
UINT  msg,
WPARAM  wparam,
LPARAM  lparam 
)
static

Definition at line 36 of file broadcast.c.

37{
38 if (msg == WM_NULL)
39 {
40 trace("main_window_procA: Sleeping for %lu ms\n", wparam);
41 if (wparam)
42 {
45 }
46 trace("main_window_procA: Returning WM_NULL with parameter %08lx\n", lparam);
47 return lparam;
48 }
49
51}
@ lparam
Definition: SystemMenu.c:31
@ wparam
Definition: SystemMenu.c:30
#define trace
Definition: atltest.h:70
#define msg(x)
Definition: auth_time.c:54
#define WAIT_TIMEOUT
Definition: dderror.h:14
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
LRESULT WINAPI DefWindowProcA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_NULL
Definition: winuser.h:1610

Referenced by init_procs().

◆ START_TEST()

START_TEST ( broadcast  )

Definition at line 204 of file broadcast.c.

205{
206 if (!init_procs())
207 return;
208
209 trace("Running BroadcastSystemMessageA tests\n");
210 test_parameters(BroadcastSystemMessageA, "BroadcastSystemMessageA");
211
212 trace("Running BroadcastSystemMessageW tests\n");
213 test_parameters(BroadcastSystemMessageW, "BroadcastSystemMessageW");
214
215 trace("Running BroadcastSystemMessageExA tests\n");
217
218 trace("Running BroadcastSystemMessageExW tests\n");
220}
static BOOL init_procs(void)
Definition: broadcast.c:53
static void test_parametersEx(PBROADCASTEX broadcastex)
Definition: broadcast.c:147
static void test_parameters(void)
Definition: shellpath.c:1313
LONG WINAPI BroadcastSystemMessageExW(DWORD dwflags, LPDWORD lpdwRecipients, UINT uiMessage, WPARAM wParam, LPARAM lParam, PBSMINFO pBSMInfo)
Definition: message.c:3439
LONG WINAPI BroadcastSystemMessageA(DWORD dwFlags, LPDWORD lpdwRecipients, UINT uiMessage, WPARAM wParam, LPARAM lParam)
Definition: message.c:3393
LONG WINAPI BroadcastSystemMessageExA(DWORD dwflags, LPDWORD lpdwRecipients, UINT uiMessage, WPARAM wParam, LPARAM lParam, PBSMINFO pBSMInfo)
Definition: message.c:3423
LONG WINAPI BroadcastSystemMessageW(DWORD dwFlags, LPDWORD lpdwRecipients, UINT uiMessage, WPARAM wParam, LPARAM lParam)
Definition: message.c:3408

◆ test_parameters()

static void test_parameters ( PBROADCAST  broadcast,
const char functionname 
)
static

Definition at line 80 of file broadcast.c.

81{
82 LONG ret;
83 DWORD recips;
84
85 SetLastError(0xcafebabe);
86 recips = BSM_APPLICATIONS;
87 ret = broadcast( 0x80000000, &recips, WM_NULL, 0, 0 );
89 {
90 win_skip("%s is not implemented\n", functionname);
91 return;
92 }
93 ok(!ret || broken(ret), "Returned: %d\n", ret);
94 if (!ret) ok(GetLastError() == ERROR_INVALID_PARAMETER, "Last error: %08x\n", GetLastError());
95
96 SetLastError(0xcafebabe);
97 recips = BSM_APPLICATIONS;
98 ret = broadcast( 0x80000000, &recips, WM_NULL, 0, 0 );
99 ok(!ret || broken(ret), "Returned: %d\n", ret);
100 if (!ret) ok(GetLastError() == ERROR_INVALID_PARAMETER, "Last error: %08x\n", GetLastError());
101
102if (0) /* TODO: Check the hang flags */
103{
104 SetLastError(0xcafebabe);
105 recips = BSM_APPLICATIONS;
106 ret = broadcast( BSF_QUERY|(BSF_NOHANG|BSF_FORCEIFHUNG), &recips, WM_NULL, 30000, 0 );
107 ok(0, "Last error: %08x\n", GetLastError());
108 ok(0, "Returned: %d\n", ret);
109
110 SetLastError(0xcafebabe);
111 recips = BSM_APPLICATIONS;
113 ok(0, "Last error: %08x\n", GetLastError());
114 ok(0, "Returned: %d\n", ret);
115
116 SetLastError(0xcafebabe);
117 recips = BSM_APPLICATIONS;
119 ok(0, "Last error: %08x\n", GetLastError());
120 ok(0, "Returned: %d\n", ret);
121
122 SetLastError(0xcafebabe);
123 recips = BSM_APPLICATIONS;
125 ok(0, "Last error: %08x\n", GetLastError());
126 ok(0, "Returned: %d\n", ret);
127}
128
129 SetLastError( 0xdeadbeef );
130 recips = BSM_APPLICATIONS;
131 ret = broadcast( BSF_POSTMESSAGE|BSF_SENDNOTIFYMESSAGE, &recips, WM_NULL, 100, 0 );
132 ok(ret==1, "Returned: %d\n", ret);
133 ok(WaitForSingleObject(hevent, 0) != WAIT_OBJECT_0, "Synchronous message sent instead\n");
135
136 recips = BSM_APPLICATIONS;
137 ret = broadcast( BSF_SENDNOTIFYMESSAGE, &recips, WM_NULL, 100, BROADCAST_QUERY_DENY );
138 ok(ret==1, "Returned: %d\n", ret);
139 ok(WaitForSingleObject(hevent, 0) != WAIT_TIMEOUT, "Asynchronous message sent instead\n");
141}
#define ok(value,...)
Definition: atltest.h:57
#define broken(x)
Definition: atltest.h:178
#define BSF_POSTMESSAGE
Definition: dbt.h:58
#define BSF_NOTIMEOUTIFNOTHUNG
Definition: dbt.h:57
#define BSF_NOHANG
Definition: dbt.h:56
#define BSF_QUERY
Definition: dbt.h:59
#define BSM_APPLICATIONS
Definition: dbt.h:48
#define BSF_FORCEIFHUNG
Definition: dbt.h:54
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:102
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define SetLastError(x)
Definition: compat.h:752
unsigned long DWORD
Definition: ntddk_ex.h:95
long LONG
Definition: pedump.c:60
#define win_skip
Definition: test.h:163
BOOL WINAPI DECLSPEC_HOTPATCH PulseEvent(IN HANDLE hEvent)
Definition: synch.c:695
static const u8_t broadcast[6]
Definition: test_dhcp.c:23
int ret
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define WAIT_OBJECT_0
Definition: winbase.h:432
#define BROADCAST_QUERY_DENY
Definition: winuser.h:178

◆ test_parametersEx()

static void test_parametersEx ( PBROADCASTEX  broadcastex)
static

Definition at line 147 of file broadcast.c.

148{
149 LONG ret;
150 DWORD recips;
151
152 SetLastError(0xcafebabe);
153 recips = BSM_APPLICATIONS;
154 ret = broadcastex( 0x80000000, &recips, WM_NULL, 0, 0, NULL );
155 ok(GetLastError() == ERROR_INVALID_PARAMETER, "Last error: %08x\n", GetLastError());
156 ok(!ret, "Returned: %d\n", ret);
157
158 SetLastError(0xcafebabe);
159 recips = BSM_APPLICATIONS;
160 ret = broadcastex( 0x80000000, &recips, WM_NULL, 0, 0, NULL );
161 ok(GetLastError() == ERROR_INVALID_PARAMETER, "Last error: %08x\n", GetLastError());
162 ok(!ret, "Returned: %d\n", ret);
163
164if (0) /* TODO: Check the hang flags */
165{
166 SetLastError(0xcafebabe);
167 recips = BSM_APPLICATIONS;
168 ret = broadcastex( BSF_QUERY|(BSF_NOHANG|BSF_FORCEIFHUNG), &recips, WM_NULL, 30000, 0, NULL );
169 ok(0, "Last error: %08x\n", GetLastError());
170 ok(0, "Returned: %d\n", ret);
171
172 SetLastError(0xcafebabe);
173 recips = BSM_APPLICATIONS;
174 ret = broadcastex( BSF_QUERY|(BSF_NOHANG|BSF_NOTIMEOUTIFNOTHUNG), &recips, WM_NULL, 30000, 0, NULL );
175 ok(0, "Last error: %08x\n", GetLastError());
176 ok(0, "Returned: %d\n", ret);
177
178 SetLastError(0xcafebabe);
179 recips = BSM_APPLICATIONS;
180 ret = broadcastex( BSF_QUERY|(BSF_NOTIMEOUTIFNOTHUNG|BSF_FORCEIFHUNG), &recips, WM_NULL, 30000, 0, NULL );
181 ok(0, "Last error: %08x\n", GetLastError());
182 ok(0, "Returned: %d\n", ret);
183
184 SetLastError(0xcafebabe);
185 recips = BSM_APPLICATIONS;
186 ret = broadcastex( BSF_POSTMESSAGE|(BSF_NOTIMEOUTIFNOTHUNG|BSF_FORCEIFHUNG), &recips, WM_NULL, 30000, 0, NULL );
187 ok(0, "Last error: %08x\n", GetLastError());
188 ok(0, "Returned: %d\n", ret);
189}
190
191 recips = BSM_APPLICATIONS;
192 ret = broadcastex( BSF_POSTMESSAGE|BSF_SENDNOTIFYMESSAGE, &recips, WM_NULL, 100, 0, NULL );
193 ok(ret==1, "Returned: %d\n", ret);
194 ok(WaitForSingleObject(hevent, 0) != WAIT_OBJECT_0, "Synchronous message sent instead\n");
196
197 recips = BSM_APPLICATIONS;
198 ret = broadcastex( BSF_SENDNOTIFYMESSAGE, &recips, WM_NULL, 100, BROADCAST_QUERY_DENY, NULL );
199 ok(ret==1, "Returned: %d\n", ret);
200 ok(WaitForSingleObject(hevent, 0) != WAIT_TIMEOUT, "Asynchronous message sent instead\n");
202}

Referenced by START_TEST().

Variable Documentation

◆ hevent