ReactOS  0.4.13-dev-651-g5dbc677
static.c File Reference
#include <stdarg.h>
#include <stdio.h>
#include <windows.h>
#include "wine/test.h"
Include dependency graph for static.c:

Go to the source code of this file.

Macros

#define STRICT
 
#define WIN32_LEAN_AND_MEAN
 
#define TODO_COUNT   1
 
#define CTRL_ID   1995
 
#define expect_eq(expr, value, type, fmt)   { type val = expr; ok(val == (value), #expr " expected " fmt " got " fmt "\n", (value), val); }
 

Functions

static void flush_events (void)
 
static HWND build_static (DWORD style)
 
static LRESULT CALLBACK WndProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
 
static void test_updates (int style, int flags)
 
static void test_set_text (void)
 
 START_TEST (static)
 

Variables

static HWND hMainWnd
 
static int g_nReceivedColorStatic = 0
 

Macro Definition Documentation

◆ CTRL_ID

#define CTRL_ID   1995

Definition at line 31 of file static.c.

◆ expect_eq

#define expect_eq (   expr,
  value,
  type,
  fmt 
)    { type val = expr; ok(val == (value), #expr " expected " fmt " got " fmt "\n", (value), val); }

Definition at line 35 of file static.c.

◆ STRICT

#define STRICT

Definition at line 23 of file static.c.

◆ TODO_COUNT

#define TODO_COUNT   1

Definition at line 29 of file static.c.

◆ WIN32_LEAN_AND_MEAN

#define WIN32_LEAN_AND_MEAN

Definition at line 24 of file static.c.

Function Documentation

◆ build_static()

static HWND build_static ( DWORD  style)
static

Definition at line 55 of file static.c.

56 {
57  return CreateWindowA("static", "Test", WS_VISIBLE|WS_CHILD|style, 5, 5, 100, 100, hMainWnd, (HMENU)CTRL_ID, NULL, 0);
58 }
#define WS_CHILD
Definition: pedump.c:617
#define CreateWindowA(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4216
smooth NULL
Definition: ftsmooth.c:416
#define CTRL_ID
Definition: static.c:31
static HWND hMainWnd
Definition: static.c:33
Arabic default style
Definition: afstyles.h:93
#define WS_VISIBLE
Definition: pedump.c:620
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60

Referenced by test_set_text(), and test_updates().

◆ flush_events()

static void flush_events ( void  )
static

Definition at line 40 of file static.c.

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 }
LRESULT WINAPI DispatchMessageA(_In_ const MSG *)
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
DWORD WINAPI GetTickCount(VOID)
Definition: time.c:445
__u16 time
Definition: mkdosfs.c:366
BOOL WINAPI PeekMessageA(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT, _In_ UINT)
smooth NULL
Definition: ftsmooth.c:416
unsigned long DWORD
Definition: ntddk_ex.h:95
#define WAIT_TIMEOUT
Definition: dderror.h:14
DWORD WINAPI MsgWaitForMultipleObjects(_In_ DWORD nCount, _In_reads_opt_(nCount) CONST HANDLE *pHandles, _In_ BOOL fWaitAll, _In_ DWORD dwMilliseconds, _In_ DWORD dwWakeMask)
#define QS_ALLINPUT
Definition: winuser.h:874
#define msg(x)
Definition: auth_time.c:54
#define PM_REMOVE
Definition: winuser.h:1182

Referenced by test_updates().

◆ START_TEST()

START_TEST ( static  )

Definition at line 133 of file static.c.

134 {
135  static const char szClassName[] = "testclass";
136  WNDCLASSEXA wndclass;
137 
138  wndclass.cbSize = sizeof(wndclass);
139  wndclass.style = CS_HREDRAW | CS_VREDRAW;
140  wndclass.lpfnWndProc = WndProc;
141  wndclass.cbClsExtra = 0;
142  wndclass.cbWndExtra = 0;
143  wndclass.hInstance = GetModuleHandleA(NULL);
144  wndclass.hIcon = LoadIconA(NULL, (LPCSTR)IDI_APPLICATION);
146  wndclass.hCursor = LoadCursorA(NULL, (LPCSTR)IDC_ARROW);
148  wndclass.lpszClassName = szClassName;
149  wndclass.lpszMenuName = NULL;
150  RegisterClassExA(&wndclass);
151 
154 
155  test_updates(0, 0);
157  test_updates(SS_ICON, 0);
164  test_set_text();
165 
167 }
HGDIOBJ WINAPI GetStockObject(_In_ int)
UINT style
Definition: winuser.h:3176
LPCSTR lpszMenuName
Definition: winuser.h:3184
static void test_updates(int style, int flags)
Definition: static.c:79
HCURSOR hCursor
Definition: winuser.h:3182
WNDPROC lpfnWndProc
Definition: winuser.h:3177
LPCSTR lpszClassName
Definition: winuser.h:3185
#define SS_BLACKRECT
Definition: pedump.c:696
static void test_set_text(void)
Definition: static.c:118
#define CS_HREDRAW
Definition: winuser.h:648
#define WHITE_BRUSH
Definition: wingdi.h:901
#define IDI_APPLICATION
Definition: winuser.h:699
#define TODO_COUNT
Definition: static.c:29
HICON hIconSm
Definition: winuser.h:3186
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
BOOL WINAPI DestroyWindow(_In_ HWND)
HICON WINAPI LoadIconA(_In_opt_ HINSTANCE, _In_ LPCSTR)
Definition: cursoricon.c:2029
#define SS_BITMAP
Definition: pedump.c:704
HINSTANCE hInstance
Definition: winuser.h:3180
#define CreateWindowA(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4216
smooth NULL
Definition: ftsmooth.c:416
UINT cbSize
Definition: winuser.h:3175
const char * LPCSTR
Definition: xmlstorage.h:183
#define SW_SHOW
Definition: winuser.h:769
HBRUSH hbrBackground
Definition: winuser.h:3183
static LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: static.c:60
#define CS_VREDRAW
Definition: winuser.h:653
#define SS_ETCHEDHORZ
Definition: winuser.h:343
static const WCHAR szClassName[]
Definition: clipbrd.c:11
int cbWndExtra
Definition: winuser.h:3179
HICON hIcon
Definition: winuser.h:3181
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:819
ATOM WINAPI RegisterClassExA(_In_ CONST WNDCLASSEXA *)
HCURSOR WINAPI LoadCursorA(_In_opt_ HINSTANCE, _In_ LPCSTR)
Definition: cursoricon.c:2059
#define SS_CENTERIMAGE
Definition: winuser.h:339
static HWND hMainWnd
Definition: static.c:33
#define SS_SIMPLE
Definition: pedump.c:702
int cbClsExtra
Definition: winuser.h:3178
#define SS_ETCHEDVERT
Definition: winuser.h:344
#define IDC_ARROW
Definition: winuser.h:682
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
#define SS_ICON
Definition: pedump.c:695
#define SS_WHITERECT
Definition: pedump.c:698

◆ test_set_text()

static void test_set_text ( void  )
static

Definition at line 118 of file static.c.

119 {
120  HWND hStatic = build_static(SS_SIMPLE);
121  char buffA[10];
122 
123  GetWindowTextA(hStatic, buffA, sizeof(buffA));
124  ok(!strcmp(buffA, "Test"), "got wrong text %s\n", buffA);
125 
126  SetWindowTextA(hStatic, NULL);
127  GetWindowTextA(hStatic, buffA, sizeof(buffA));
128  ok(buffA[0] == 0, "got wrong text %s\n", buffA);
129 
130  DestroyWindow(hStatic);
131 }
int WINAPI GetWindowTextA(HWND hWnd, LPSTR lpString, int nMaxCount)
Definition: window.c:1296
BOOL WINAPI DestroyWindow(_In_ HWND)
static HWND build_static(DWORD style)
Definition: static.c:55
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI SetWindowTextA(_In_ HWND, _In_opt_ LPCSTR)
#define SS_SIMPLE
Definition: pedump.c:702
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469

Referenced by START_TEST().

◆ test_updates()

static void test_updates ( int  style,
int  flags 
)
static

Definition at line 79 of file static.c.

80 {
81  RECT r1 = {20, 20, 30, 30};
82  HWND hStatic = build_static(style);
83  int exp;
84 
85  flush_events();
86  trace("Testing style 0x%x\n", style);
88  /* during each update parent WndProc will test the WM_CTLCOLORSTATIC message */
93  InvalidateRect(hStatic, &r1, FALSE);
94  UpdateWindow(hStatic);
95  InvalidateRect(hStatic, NULL, FALSE);
96  UpdateWindow(hStatic);
97 
98  if( (style & SS_TYPEMASK) == SS_BITMAP) {
99  HDC hdc = GetDC( hStatic);
100  COLORREF colour = GetPixel( hdc, 10, 10);
101  ok ( colour != 0, "pixel should NOT be painted black!\n");
102  ReleaseDC(hStatic, hdc);
103  }
104  if (style != SS_ETCHEDHORZ && style != SS_ETCHEDVERT)
105  exp = 4;
106  else
107  exp = 1; /* SS_ETCHED* seems to send WM_CTLCOLORSTATIC only sometimes */
108 
109  if (flags & TODO_COUNT)
111  else if ((style & SS_TYPEMASK) == SS_ICON || (style & SS_TYPEMASK) == SS_BITMAP)
112  ok( g_nReceivedColorStatic == exp, "expected %u got %u\n", exp, g_nReceivedColorStatic );
113  else
114  expect_eq(g_nReceivedColorStatic, exp, int, "%d");
115  DestroyWindow(hStatic);
116 }
#define trace(...)
Definition: kmt_test.h:217
#define expect_eq(expr, value, type, fmt)
Definition: static.c:35
HDC WINAPI GetDC(_In_opt_ HWND)
#define SS_TYPEMASK
Definition: winuser.h:362
static HDC
Definition: imagelist.c:92
static void flush_events(void)
Definition: static.c:40
static DNS_RECORDW r1
Definition: record.c:37
BOOL WINAPI UpdateWindow(_In_ HWND)
#define TODO_COUNT
Definition: static.c:29
DWORD GetPixel(LPDIRECTDRAWSURFACE7 Surface, UINT x, UINT y)
Definition: blt.cpp:2
BOOL WINAPI DestroyWindow(_In_ HWND)
#define SS_BITMAP
Definition: pedump.c:704
static HWND build_static(DWORD style)
Definition: static.c:55
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
#define SS_ETCHEDHORZ
Definition: winuser.h:343
DWORD COLORREF
Definition: windef.h:285
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
GLbitfield flags
Definition: glext.h:7161
#define todo_wine
Definition: test.h:154
HDC hdc
Definition: main.c:9
static HWND hMainWnd
Definition: static.c:33
#define SS_ETCHEDVERT
Definition: winuser.h:344
DWORD exp
Definition: msg.c:15681
static int g_nReceivedColorStatic
Definition: static.c:37
Arabic default style
Definition: afstyles.h:93
#define SS_ICON
Definition: pedump.c:695

Referenced by START_TEST().

◆ WndProc()

static LRESULT CALLBACK WndProc ( HWND  hwnd,
UINT  msg,
WPARAM  wparam,
LPARAM  lparam 
)
static

Definition at line 60 of file static.c.

61 {
62  switch (msg)
63  {
64  case WM_CTLCOLORSTATIC:
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 
76  return DefWindowProcA(hwnd, msg, wparam, lparam);
77 }
HGDIOBJ WINAPI GetStockObject(_In_ int)
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define WM_CTLCOLORSTATIC
Definition: winuser.h:1754
static HDC
Definition: imagelist.c:92
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
static UINT WPARAM LPARAM lparam
Definition: combo.c:716
#define ok(value,...)
HRGN WINAPI CreateRectRgn(_In_ int, _In_ int, _In_ int, _In_ int)
#define BLACK_BRUSH
Definition: wingdi.h:895
HDC hdc
Definition: main.c:9
static HRGN hrgn
Definition: win.c:55
LRESULT WINAPI DefWindowProcA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
static int g_nReceivedColorStatic
Definition: static.c:37
#define msg(x)
Definition: auth_time.c:54
int WINAPI GetClipRgn(_In_ HDC, _In_ HRGN)
LONG_PTR LRESULT
Definition: windef.h:209
static UINT WPARAM wparam
Definition: combo.c:716

Referenced by START_TEST().

Variable Documentation

◆ g_nReceivedColorStatic

int g_nReceivedColorStatic = 0
static

Definition at line 37 of file static.c.

Referenced by test_updates(), and WndProc().

◆ hMainWnd

HWND hMainWnd
static

Definition at line 33 of file static.c.

Referenced by build_static(), START_TEST(), and test_updates().