ReactOS 0.4.15-dev-7924-g5949c20
finddlg.c File Reference
#include "windows.h"
#include "commdlg.h"
#include "cderr.h"
#include "wine/test.h"
Include dependency graph for finddlg.c:

Go to the source code of this file.

Macros

#define CHECK_FIND_OR_REPLACE(FUNC, FAIL, ERR_CODE)
 
#define CHECK_FIND_FAIL(ERR_CODE)    CHECK_FIND_OR_REPLACE(FindTextA, TRUE, ERR_CODE)
 
#define CHECK_FIND_SUCCEED()    CHECK_FIND_OR_REPLACE(FindTextA, FALSE, 0)
 
#define CHECK_REPLACE_FAIL(ERR_CODE)    CHECK_FIND_OR_REPLACE(ReplaceTextA, TRUE, ERR_CODE)
 
#define CHECK_REPLACE_SUCCEED()    CHECK_FIND_OR_REPLACE(ReplaceTextA, FALSE, 0)
 
#define CHECK_FINDREPLACE_FAIL(ERR_CODE)
 

Functions

static LRESULT handle_findmsg (FINDREPLACEA *fr)
 
static LRESULT CALLBACK OwnerWndProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
 
static void test_param_check (void)
 
 START_TEST (finddlg)
 

Variables

static UINT ID_FINDMSGSTRING
 

Macro Definition Documentation

◆ CHECK_FIND_FAIL

#define CHECK_FIND_FAIL (   ERR_CODE)     CHECK_FIND_OR_REPLACE(FindTextA, TRUE, ERR_CODE)

◆ CHECK_FIND_OR_REPLACE

#define CHECK_FIND_OR_REPLACE (   FUNC,
  FAIL,
  ERR_CODE 
)
Value:
do { \
HWND hwnd = FUNC(pFr); \
BOOL is_ok = !!hwnd == !FAIL; \
ok(is_ok, "%s should%s fail\n", #FUNC, FAIL ? "" : "n't"); \
if (FAIL && is_ok) { \
DWORD ext_err = CommDlgExtendedError(); \
ok(ext_err == ERR_CODE, "expected err %x got %x\n", \
ERR_CODE, ext_err); \
} else { \
DestroyWindow(hwnd); \
} \
} while (0)
DWORD WINAPI CommDlgExtendedError(void)
Definition: cdlg32.c:148
void FAIL(int i)
Definition: ehthrow.cxx:27
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
#define FUNC
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023

◆ CHECK_FIND_SUCCEED

#define CHECK_FIND_SUCCEED ( )     CHECK_FIND_OR_REPLACE(FindTextA, FALSE, 0)

◆ CHECK_FINDREPLACE_FAIL

#define CHECK_FINDREPLACE_FAIL (   ERR_CODE)
Value:
do { \
CHECK_FIND_FAIL(ERR_CODE); \
CHECK_REPLACE_FAIL(ERR_CODE); \
} while (0)

◆ CHECK_REPLACE_FAIL

#define CHECK_REPLACE_FAIL (   ERR_CODE)     CHECK_FIND_OR_REPLACE(ReplaceTextA, TRUE, ERR_CODE)

◆ CHECK_REPLACE_SUCCEED

#define CHECK_REPLACE_SUCCEED ( )     CHECK_FIND_OR_REPLACE(ReplaceTextA, FALSE, 0)

Function Documentation

◆ handle_findmsg()

static LRESULT handle_findmsg ( FINDREPLACEA fr)
static

Definition at line 29 of file finddlg.c.

30{
31 return 0;
32}

Referenced by OwnerWndProc().

◆ OwnerWndProc()

static LRESULT CALLBACK OwnerWndProc ( HWND  hwnd,
UINT  msg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 34 of file finddlg.c.

35{
36 if(msg == ID_FINDMSGSTRING) {
38 }
40}
#define msg(x)
Definition: auth_time.c:54
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
static LRESULT handle_findmsg(FINDREPLACEA *fr)
Definition: finddlg.c:29
static UINT ID_FINDMSGSTRING
Definition: finddlg.c:27
LRESULT WINAPI DefWindowProcA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by test_param_check().

◆ START_TEST()

START_TEST ( finddlg  )

Definition at line 143 of file finddlg.c.

144{
146
148}
#define FINDMSGSTRINGA
Definition: commdlg.h:21
static void test_param_check(void)
Definition: finddlg.c:42
UINT WINAPI RegisterWindowMessageA(_In_ LPCSTR)

◆ test_param_check()

static void test_param_check ( void  )
static

Definition at line 42 of file finddlg.c.

43{
44 char findbuffer[64];
45 char replacebuffer[64];
46 FINDREPLACEA fr, *pFr;
47 WNDCLASSA wc;
48
49 ZeroMemory(&wc, sizeof(wc));
51 wc.lpszClassName = "test_param_check";
52 RegisterClassA(&wc);
53
54#define CHECK_FIND_OR_REPLACE(FUNC, FAIL, ERR_CODE) \
55 do { \
56 HWND hwnd = FUNC(pFr); \
57 BOOL is_ok = !!hwnd == !FAIL; \
58 ok(is_ok, "%s should%s fail\n", #FUNC, FAIL ? "" : "n't"); \
59 if (FAIL && is_ok) { \
60 DWORD ext_err = CommDlgExtendedError(); \
61 ok(ext_err == ERR_CODE, "expected err %x got %x\n", \
62 ERR_CODE, ext_err); \
63 } else { \
64 DestroyWindow(hwnd); \
65 } \
66 } while (0)
67
68#define CHECK_FIND_FAIL(ERR_CODE) \
69 CHECK_FIND_OR_REPLACE(FindTextA, TRUE, ERR_CODE)
70
71#define CHECK_FIND_SUCCEED() \
72 CHECK_FIND_OR_REPLACE(FindTextA, FALSE, 0)
73
74#define CHECK_REPLACE_FAIL(ERR_CODE) \
75 CHECK_FIND_OR_REPLACE(ReplaceTextA, TRUE, ERR_CODE)
76
77#define CHECK_REPLACE_SUCCEED() \
78 CHECK_FIND_OR_REPLACE(ReplaceTextA, FALSE, 0)
79
80#define CHECK_FINDREPLACE_FAIL(ERR_CODE) \
81 do { \
82 CHECK_FIND_FAIL(ERR_CODE); \
83 CHECK_REPLACE_FAIL(ERR_CODE); \
84 } while (0)
85
86 pFr = NULL;
88 pFr = &fr;
89
90 ZeroMemory(&fr, sizeof(fr));
91 /* invalid lStructSize (0) */
93 fr.lStructSize = sizeof(fr);
94
95 /* invalid hwndOwner (NULL) */
97 fr.hwndOwner = CreateWindowA(wc.lpszClassName, NULL, WS_VISIBLE, 0, 0, 200, 100,
99
100 /* invalid wFindWhatLen (0) */
102 fr.wFindWhatLen = sizeof(findbuffer);
103
104 /* invalid lpstrFindWhat (NULL) */
106 fr.lpstrFindWhat = findbuffer;
107 strcpy(findbuffer, "abc");
108
109 /* invalid lpstrReplaceWith (NULL) for ReplaceText */
112 fr.lpstrReplaceWith = replacebuffer;
113 strcpy(replacebuffer, "def");
114
115 /* wReplaceWithLen may be 0, even for ReplaceText */
118 fr.wReplaceWithLen = sizeof(replacebuffer);
119
120 /* invalid lpfnHook (NULL) when Flags has FR_ENABLEHOOK */
121 fr.Flags = FR_ENABLEHOOK;
123
124 /* invalid hInstance (NULL)
125 * when Flags has FR_ENABLETEMPLATE or FR_ENABLETEMPLATEHANDLE */
131
132 /* invalid lpTemplateName (NULL) when Flags has FR_ENABLETEMPLATE */
135 fr.Flags = 0;
136
139
141}
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define CDERR_NOHINSTANCE
Definition: cderr.h:9
#define CDERR_NOHOOK
Definition: cderr.h:16
#define CDERR_INITIALIZATION
Definition: cderr.h:7
#define CDERR_FINDRESFAILURE
Definition: cderr.h:11
#define FRERR_BUFFERLENGTHZERO
Definition: cderr.h:39
#define CDERR_DIALOGFAILURE
Definition: cderr.h:4
#define CDERR_STRUCTSIZE
Definition: cderr.h:6
#define FR_ENABLETEMPLATEHANDLE
Definition: commdlg.h:130
#define FR_ENABLEHOOK
Definition: commdlg.h:128
#define FR_ENABLETEMPLATE
Definition: commdlg.h:129
#define NULL
Definition: types.h:112
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
#define CHECK_REPLACE_FAIL(ERR_CODE)
#define CHECK_FINDREPLACE_FAIL(ERR_CODE)
#define CHECK_REPLACE_SUCCEED()
static LRESULT CALLBACK OwnerWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: finddlg.c:34
#define CHECK_FIND_SUCCEED()
#define WS_VISIBLE
Definition: pedump.c:620
DWORD lStructSize
Definition: commdlg.h:303
LPSTR lpstrFindWhat
Definition: commdlg.h:307
HINSTANCE hInstance
Definition: commdlg.h:305
LPSTR lpstrReplaceWith
Definition: commdlg.h:308
WORD wReplaceWithLen
Definition: commdlg.h:310
DWORD Flags
Definition: commdlg.h:306
WORD wFindWhatLen
Definition: commdlg.h:309
HWND hwndOwner
Definition: commdlg.h:304
LPCSTR lpszClassName
Definition: winuser.h:3172
WNDPROC lpfnWndProc
Definition: winuser.h:3164
#define ZeroMemory
Definition: winbase.h:1712
#define CreateWindowA(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4315
ATOM WINAPI RegisterClassA(_In_ CONST WNDCLASSA *)
BOOL WINAPI DestroyWindow(_In_ HWND)

Referenced by START_TEST().

Variable Documentation

◆ ID_FINDMSGSTRING

UINT ID_FINDMSGSTRING
static

Definition at line 27 of file finddlg.c.

Referenced by OwnerWndProc(), and START_TEST().