ReactOS 0.4.16-dev-41-ge8c7597
static.c
Go to the documentation of this file.
1/* Unit test suite for static controls.
2 *
3 * Copyright 2007 Google (Mikolaj Zalewski)
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
18 */
19
20#include <stdarg.h>
21#include <stdio.h>
22
23#define STRICT
24#define WIN32_LEAN_AND_MEAN
25#include <windows.h>
26#include "commctrl.h"
27
28#include "wine/test.h"
29
30#include "v6util.h"
31
32#define TODO_COUNT 1
33
34#define CTRL_ID 1995
35
38
39/* try to make sure pending X events have been processed before continuing */
40static void flush_events(void)
41{
42 MSG msg;
43 int diff = 200;
44 int min_timeout = 100;
45 DWORD time = GetTickCount() + diff;
46
47 while (diff > 0)
48 {
49 if (MsgWaitForMultipleObjects( 0, NULL, FALSE, min_timeout, QS_ALLINPUT ) == WAIT_TIMEOUT) break;
50 while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageA( &msg );
51 diff = time - GetTickCount();
52 }
53}
54
56{
57 return CreateWindowA(WC_STATICA, "Test", WS_VISIBLE|WS_CHILD|style, 5, 5, 100, 100, hMainWnd, (HMENU)CTRL_ID, NULL, 0);
58}
59
61{
62 switch (msg)
63 {
65 {
66 HDC hdc = (HDC)wparam;
67 HRGN hrgn = CreateRectRgn(0, 0, 1, 1);
68 ok(GetClipRgn(hdc, hrgn) == 1, "Static controls during a WM_CTLCOLORSTATIC must have a clipping region\n");
72 }
73 break;
74 }
75
77}
78
79static void test_updates(int style, int flags)
80{
81 HWND hStatic = create_static(style);
82 RECT r1 = {20, 20, 30, 30};
83 int exp;
84
87 /* during each update parent WndProc will test the WM_CTLCOLORSTATIC message */
92 InvalidateRect(hStatic, &r1, FALSE);
93 UpdateWindow(hStatic);
94 InvalidateRect(hStatic, NULL, FALSE);
95 UpdateWindow(hStatic);
96
97 if ((style & SS_TYPEMASK) == SS_BITMAP)
98 {
99 HDC hdc = GetDC(hStatic);
100 COLORREF colour = GetPixel(hdc, 10, 10);
102 ok(colour == 0, "Unexpected pixel color.\n");
103 ReleaseDC(hStatic, hdc);
104 }
105
107 exp = 4;
108 else
109 exp = 1; /* SS_ETCHED* seems to send WM_CTLCOLORSTATIC only sometimes */
110
111 if (flags & TODO_COUNT)
113 ok(g_nReceivedColorStatic == exp, "Unexpected WM_CTLCOLORSTATIC value %d\n", g_nReceivedColorStatic);
114 else if ((style & SS_TYPEMASK) == SS_ICON || (style & SS_TYPEMASK) == SS_BITMAP)
115 ok(g_nReceivedColorStatic == exp, "Unexpected %u got %u\n", exp, g_nReceivedColorStatic);
116 else
117 ok(g_nReceivedColorStatic == exp, "Unexpected WM_CTLCOLORSTATIC value %d\n", g_nReceivedColorStatic);
118 DestroyWindow(hStatic);
119}
120
121static void test_set_text(void)
122{
123 HWND hStatic = create_static(SS_SIMPLE);
124 char buffA[10];
125
126 GetWindowTextA(hStatic, buffA, sizeof(buffA));
127 ok(!strcmp(buffA, "Test"), "got wrong text %s\n", buffA);
128
129 SetWindowTextA(hStatic, NULL);
130 GetWindowTextA(hStatic, buffA, sizeof(buffA));
131 ok(buffA[0] == 0, "got wrong text %s\n", buffA);
132
133 DestroyWindow(hStatic);
134}
135
137{
138 static const char classname[] = "testclass";
139 WNDCLASSEXA wndclass;
140 ULONG_PTR ctx_cookie;
141 HANDLE hCtx;
142
143 if (!load_v6_module(&ctx_cookie, &hCtx))
144 return;
145
146 wndclass.cbSize = sizeof(wndclass);
147 wndclass.style = CS_HREDRAW | CS_VREDRAW;
148 wndclass.lpfnWndProc = WndProc;
149 wndclass.cbClsExtra = 0;
150 wndclass.cbWndExtra = 0;
151 wndclass.hInstance = GetModuleHandleA(NULL);
156 wndclass.lpszClassName = classname;
157 wndclass.lpszMenuName = NULL;
158 RegisterClassExA(&wndclass);
159
160 hMainWnd = CreateWindowA(classname, "Test", WS_OVERLAPPEDWINDOW, 0, 0, 500, 500, NULL, NULL,
163
164 test_updates(0, 0);
174
176
177 unload_v6_module(ctx_cookie, hCtx);
178}
static HRGN hrgn
@ lparam
Definition: SystemMenu.c:31
@ wparam
Definition: SystemMenu.c:30
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
Arabic default style
Definition: afstyles.h:94
#define ok(value,...)
Definition: atltest.h:57
#define START_TEST(x)
Definition: atltest.h:75
#define msg(x)
Definition: auth_time.c:54
DWORD GetPixel(LPDIRECTDRAWSURFACE7 Surface, UINT x, UINT y)
Definition: blt.cpp:2
#define WAIT_TIMEOUT
Definition: dderror.h:14
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define CALLBACK
Definition: compat.h:35
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
DWORD WINAPI GetTickCount(VOID)
Definition: time.c:455
unsigned long DWORD
Definition: ntddk_ex.h:95
pKey DeleteObject()
GLbitfield flags
Definition: glext.h:7161
__u16 time
Definition: mkdosfs.c:8
HDC hdc
Definition: main.c:9
static HDC
Definition: imagelist.c:88
#define TODO_COUNT
Definition: static.c:32
static int g_nReceivedColorStatic
Definition: static.c:37
static HWND hMainWnd
Definition: static.c:36
#define CTRL_ID
Definition: static.c:34
static HWND create_static(DWORD style)
Definition: static.c:55
static void flush_events(void)
Definition: static.c:40
static void test_set_text(void)
Definition: static.c:121
static void test_updates(int style, int flags)
Definition: static.c:79
static LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: static.c:60
static DNS_RECORDW r1
Definition: record.c:37
#define todo_wine
Definition: custom.c:79
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:63
DWORD exp
Definition: msg.c:16058
unsigned int UINT
Definition: ndis.h:50
#define SS_WHITERECT
Definition: pedump.c:698
#define WS_CHILD
Definition: pedump.c:617
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
#define SS_BLACKRECT
Definition: pedump.c:696
#define SS_SIMPLE
Definition: pedump.c:702
#define WS_VISIBLE
Definition: pedump.c:620
#define SS_BITMAP
Definition: pedump.c:704
#define SS_ICON
Definition: pedump.c:695
#define WC_STATICA
Definition: commctrl.h:4684
WCHAR classname[128]
Definition: startup.c:15
int cbClsExtra
Definition: winuser.h:3207
HINSTANCE hInstance
Definition: winuser.h:3209
HCURSOR hCursor
Definition: winuser.h:3211
LPCSTR lpszMenuName
Definition: winuser.h:3213
HICON hIconSm
Definition: winuser.h:3215
UINT style
Definition: winuser.h:3205
int cbWndExtra
Definition: winuser.h:3208
UINT cbSize
Definition: winuser.h:3204
WNDPROC lpfnWndProc
Definition: winuser.h:3206
LPCSTR lpszClassName
Definition: winuser.h:3214
HICON hIcon
Definition: winuser.h:3210
HBRUSH hbrBackground
Definition: winuser.h:3212
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
uint32_t ULONG_PTR
Definition: typedefs.h:65
static BOOL load_v6_module(ULONG_PTR *pcookie, HANDLE *hCtx)
Definition: v6util.h:73
static void unload_v6_module(ULONG_PTR cookie, HANDLE hCtx)
Definition: v6util.h:65
int WINAPI GetWindowTextA(HWND hWnd, LPSTR lpString, int nMaxCount)
Definition: window.c:1302
_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
DWORD COLORREF
Definition: windef.h:300
HGDIOBJ WINAPI GetStockObject(_In_ int)
HRGN WINAPI CreateRectRgn(_In_ int, _In_ int, _In_ int, _In_ int)
int WINAPI GetClipRgn(_In_ HDC, _In_ HRGN)
#define WHITE_BRUSH
Definition: wingdi.h:902
#define BLACK_BRUSH
Definition: wingdi.h:896
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
#define CS_VREDRAW
Definition: winuser.h:658
LRESULT WINAPI DispatchMessageA(_In_ const MSG *)
#define WM_CTLCOLORSTATIC
Definition: winuser.h:1775
BOOL WINAPI SetWindowTextA(_In_ HWND, _In_opt_ LPCSTR)
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
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:4318
#define CS_HREDRAW
Definition: winuser.h:653
#define IDC_ARROW
Definition: winuser.h:687
#define QS_ALLINPUT
Definition: winuser.h:906
#define SS_ETCHEDHORZ
Definition: winuser.h:343
#define SS_CENTERIMAGE
Definition: winuser.h:339
DWORD WINAPI MsgWaitForMultipleObjects(_In_ DWORD nCount, _In_reads_opt_(nCount) CONST HANDLE *pHandles, _In_ BOOL fWaitAll, _In_ DWORD dwMilliseconds, _In_ DWORD dwWakeMask)
#define SS_ETCHEDVERT
Definition: winuser.h:344
#define IDI_APPLICATION
Definition: winuser.h:704
#define SS_TYPEMASK
Definition: winuser.h:362
ATOM WINAPI RegisterClassExA(_In_ CONST WNDCLASSEXA *)
HICON WINAPI LoadIconA(_In_opt_ HINSTANCE hInstance, _In_ LPCSTR lpIconName)
Definition: cursoricon.c:2104
#define PM_REMOVE
Definition: winuser.h:1199
BOOL WINAPI UpdateWindow(_In_ HWND)
HDC WINAPI GetDC(_In_opt_ HWND)
BOOL WINAPI PeekMessageA(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT, _In_ UINT)
#define SW_SHOW
Definition: winuser.h:778
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
BOOL WINAPI DestroyWindow(_In_ HWND)
HCURSOR WINAPI LoadCursorA(_In_opt_ HINSTANCE, _In_ LPCSTR)
Definition: cursoricon.c:2134
const char * LPCSTR
Definition: xmlstorage.h:183