ReactOS 0.4.15-dev-8245-gd24675b
finddlg.c
Go to the documentation of this file.
1/*
2 * Unit test suite for comdlg32 API functions: find/replace dialogs
3 *
4 * Copyright 2010 by Dylan Smith
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
22#include "windows.h"
23#include "commdlg.h"
24#include "cderr.h"
25#include "wine/test.h"
26
28
30{
31 return 0;
32}
33
35{
36 if(msg == ID_FINDMSGSTRING) {
38 }
40}
41
42static void test_param_check(void)
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}
142
144{
146
148}
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define START_TEST(x)
Definition: atltest.h:75
#define msg(x)
Definition: auth_time.c:54
#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
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define FR_ENABLETEMPLATEHANDLE
Definition: commdlg.h:130
#define FINDMSGSTRINGA
Definition: commdlg.h:21
#define FR_ENABLEHOOK
Definition: commdlg.h:128
#define FR_ENABLETEMPLATE
Definition: commdlg.h:129
#define NULL
Definition: types.h:112
#define CALLBACK
Definition: compat.h:35
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
#define CHECK_REPLACE_FAIL(ERR_CODE)
#define CHECK_FINDREPLACE_FAIL(ERR_CODE)
static LRESULT handle_findmsg(FINDREPLACEA *fr)
Definition: finddlg.c:29
static UINT ID_FINDMSGSTRING
Definition: finddlg.c:27
static void test_param_check(void)
Definition: finddlg.c:42
#define CHECK_REPLACE_SUCCEED()
static LRESULT CALLBACK OwnerWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: finddlg.c:34
#define CHECK_FIND_SUCCEED()
unsigned int UINT
Definition: ndis.h:50
#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
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
LONG_PTR LPARAM
Definition: windef.h:208
LONG_PTR LRESULT
Definition: windef.h:209
UINT_PTR WPARAM
Definition: windef.h:207
UINT WINAPI RegisterWindowMessageA(_In_ LPCSTR)
LRESULT WINAPI DefWindowProcA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#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)