~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Wine Cross Reference
wine/dlls/user32/tests/static.c

Version: ~ [ wine-1.5.30 ] ~ [ wine-1.5.29 ] ~ [ wine-1.5.28 ] ~ [ wine-1.5.27 ] ~ [ wine-1.5.26 ] ~ [ wine-1.5.25 ] ~ [ wine-1.5.24 ] ~ [ wine-1.5.23 ] ~ [ wine-1.5.22 ] ~ [ wine-1.5.21 ] ~ [ wine-1.5.20 ] ~ [ wine-1.5.19 ] ~ [ wine-1.5.18 ] ~ [ wine-1.5.17 ] ~ [ wine-1.5.16 ] ~ [ wine-1.5.15 ] ~ [ wine-1.5.14 ] ~ [ wine-1.5.13 ] ~ [ wine-1.5.12 ] ~ [ wine-1.5.11 ] ~ [ wine-1.5.10 ] ~ [ wine-1.5.9 ] ~ [ wine-1.5.8 ] ~ [ wine-1.5.7 ] ~ [ wine-1.4.1 ] ~ [ wine-1.5.6 ] ~ [ wine-1.5.5 ] ~ [ wine-1.5.4 ] ~ [ wine-1.5.3 ] ~ [ wine-1.5.2 ] ~ [ wine-1.5.1 ] ~ [ wine-1.5.0 ] ~ [ wine-1.4 ] ~ [ wine-1.4-rc6 ] ~ [ wine-1.4-rc5 ] ~ [ wine-1.4-rc4 ] ~ [ wine-1.4-rc3 ] ~ [ wine-1.4-rc2 ] ~ [ wine-1.4-rc1 ] ~ [ wine-1.3.37 ] ~ [ wine-1.3.36 ] ~ [ wine-1.3.35 ] ~ [ wine-1.3.34 ] ~ [ wine-1.3.33 ] ~ [ wine-1.3.32 ] ~ [ wine-1.3.31 ] ~ [ wine-1.3.30 ] ~ [ wine-1.3.29 ] ~ [ wine-1.3.28 ] ~ [ wine-1.3.27 ] ~ [ wine-1.3.26 ] ~ [ wine-1.3.25 ] ~ [ wine-1.3.24 ] ~ [ wine-1.3.23 ] ~ [ wine-1.3.22 ] ~ [ wine-1.3.21 ] ~ [ wine-1.3.20 ] ~ [ wine-1.3.19 ] ~ [ wine-1.3.18 ] ~ [ wine-1.2.3 ] ~ [ wine-1.3.17 ] ~ [ wine-1.3.16 ] ~ [ wine-1.3.15 ] ~ [ wine-1.3.14 ] ~ [ wine-1.3.13 ] ~ [ wine-1.3.12 ] ~ [ wine-1.3.11 ] ~ [ wine-1.3.10 ] ~ [ wine-1.3.9 ] ~ [ wine-1.2.2 ] ~ [ wine-1.3.8 ] ~ [ wine-1.3.7 ] ~ [ wine-1.3.6 ] ~ [ wine-1.3.5 ] ~ [ wine-1.2.1 ] ~ [ wine-1.3.4 ] ~ [ wine-1.3.3 ] ~ [ wine-1.3.2 ] ~ [ wine-1.3.1 ] ~ [ wine-1.3.0 ] ~ [ wine-1.2 ] ~ [ wine-1.2-rc7 ] ~ [ wine-1.2-rc6 ] ~ [ wine-1.2-rc5 ] ~ [ wine-1.2-rc4 ] ~ [ wine-1.2-rc3 ] ~ [ wine-1.2-rc2 ] ~ [ wine-1.2-rc1 ] ~ [ wine-1.1.44 ] ~ [ wine-1.1.43 ] ~ [ wine-1.1.42 ] ~ [ wine-1.1.41 ] ~ [ wine-1.1.40 ] ~ [ wine-1.1.39 ] ~ [ wine-1.1.38 ] ~ [ wine-1.1.37 ] ~ [ wine-1.1.36 ] ~ [ wine-1.1.35 ] ~ [ wine-1.1.34 ] ~ [ wine-1.1.33 ] ~ [ wine-1.1.32 ] ~ [ wine-1.1.31 ] ~ [ wine-1.1.30 ] ~ [ wine-1.1.29 ] ~ [ wine-1.1.28 ] ~ [ wine-1.1.27 ] ~ [ wine-1.1.26 ] ~ [ wine-1.1.25 ] ~ [ wine-1.1.24 ] ~ [ wine-1.1.23 ] ~ [ wine-1.1.22 ] ~ [ wine-1.1.21 ] ~ [ wine-1.1.20 ] ~ [ wine-1.1.19 ] ~ [ wine-1.1.18 ] ~ [ wine-1.1.17 ] ~ [ wine-1.1.16 ] ~ [ wine-1.1.15 ] ~ [ wine-1.1.14 ] ~ [ wine-1.1.13 ] ~ [ wine-1.1.12 ] ~ [ wine-1.1.11 ] ~ [ wine-1.1.10 ] ~ [ wine-1.1.9 ] ~ [ wine-1.1.8 ] ~ [ wine-1.1.7 ] ~ [ wine-1.0.1 ] ~ [ wine-1.1.6 ] ~ [ wine-1.1.5 ] ~ [ wine-1.1.4 ] ~ [ wine-1.1.3 ] ~ [ wine-1.1.2 ] ~ [ wine-1.1.1 ] ~ [ wine-1.1.0 ] ~ [ wine-1.0 ] ~

  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 
 27 #include "wine/test.h"
 28 
 29 #define TODO_COUNT 1
 30 
 31 #define CTRL_ID 1995
 32 
 33 static HWND hMainWnd;
 34 
 35 #define expect_eq(expr, value, type, fmt) { type val = expr; ok(val == (value), #expr " expected " fmt " got " fmt "\n", (value), val); }
 36 #define expect_rect(r, _left, _top, _right, _bottom) ok(r.left == _left && r.top == _top && \
 37     r.bottom == _bottom && r.right == _right, "Invalid rect (%d,%d) (%d,%d) vs (%d,%d) (%d,%d)\n", \
 38     r.left, r.top, r.right, r.bottom, _left, _top, _right, _bottom);
 39 
 40 static int g_nReceivedColorStatic = 0;
 41 
 42 /* try to make sure pending X events have been processed before continuing */
 43 static void flush_events(void)
 44 {
 45     MSG msg;
 46     int diff = 200;
 47     int min_timeout = 100;
 48     DWORD time = GetTickCount() + diff;
 49 
 50     while (diff > 0)
 51     {
 52         if (MsgWaitForMultipleObjects( 0, NULL, FALSE, min_timeout, QS_ALLINPUT ) == WAIT_TIMEOUT) break;
 53         while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
 54         diff = time - GetTickCount();
 55     }
 56 }
 57 
 58 static HWND build_static(DWORD style)
 59 {
 60     return CreateWindow("static", "Test", WS_VISIBLE|WS_CHILD|style, 5, 5, 100, 100, hMainWnd, (HMENU)CTRL_ID, NULL, 0);
 61 }
 62 
 63 static LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
 64 {
 65     switch (msg)
 66     {
 67     case WM_CTLCOLORSTATIC:
 68         {
 69             HDC hdc = (HDC)wparam;
 70             HRGN hrgn = CreateRectRgn(0, 0, 1, 1);
 71             ok(GetClipRgn(hdc, hrgn) == 1, "Static controls during a WM_CTLCOLORSTATIC must have a clipping region\n");
 72             DeleteObject(hrgn);
 73             g_nReceivedColorStatic++;
 74             return (LRESULT) GetStockObject(BLACK_BRUSH);
 75         }
 76         break;
 77     }
 78 
 79     return DefWindowProc(hwnd, msg, wparam, lparam);
 80 }
 81 
 82 static void test_updates(int style, int flags)
 83 {
 84     RECT r1 = {20, 20, 30, 30};
 85     HWND hStatic = build_static(style);
 86     int exp;
 87 
 88     flush_events();
 89     trace("Testing style 0x%x\n", style);
 90     g_nReceivedColorStatic = 0;
 91     /* during each update parent WndProc will test the WM_CTLCOLORSTATIC message */
 92     InvalidateRect(hMainWnd, NULL, FALSE);
 93     UpdateWindow(hMainWnd);
 94     InvalidateRect(hMainWnd, &r1, FALSE);
 95     UpdateWindow(hMainWnd);
 96     InvalidateRect(hStatic, &r1, FALSE);
 97     UpdateWindow(hStatic);
 98     InvalidateRect(hStatic, NULL, FALSE);
 99     UpdateWindow(hStatic);
100 
101     if( (style & SS_TYPEMASK) == SS_BITMAP) {
102         HDC hdc = GetDC( hStatic);
103         COLORREF colour = GetPixel( hdc, 10, 10);
104         ok ( colour != 0, "pixel should NOT be painted black!\n");
105     }
106     if (style != SS_ETCHEDHORZ && style != SS_ETCHEDVERT)
107         exp = 4;
108     else
109         exp = 1; /* SS_ETCHED* seems to send WM_CTLCOLORSTATIC only sometimes */
110 
111     if (flags & TODO_COUNT)
112         todo_wine { expect_eq(g_nReceivedColorStatic, exp, int, "%d"); }
113     else if ((style & SS_TYPEMASK) == SS_ICON || (style & SS_TYPEMASK) == SS_BITMAP)
114         ok( g_nReceivedColorStatic == exp, "expected %u got %u\n", exp, g_nReceivedColorStatic );
115     else
116         expect_eq(g_nReceivedColorStatic, exp, int, "%d");
117     DestroyWindow(hStatic);
118 }
119 
120 START_TEST(static)
121 {
122     static char szClassName[] = "testclass";
123     WNDCLASSEX  wndclass;
124 
125     wndclass.cbSize         = sizeof(wndclass);
126     wndclass.style          = CS_HREDRAW | CS_VREDRAW;
127     wndclass.lpfnWndProc    = WndProc;
128     wndclass.cbClsExtra     = 0;
129     wndclass.cbWndExtra     = 0;
130     wndclass.hInstance      = GetModuleHandle(NULL);
131     wndclass.hIcon          = LoadIcon(NULL, IDI_APPLICATION);
132     wndclass.hIconSm        = LoadIcon(NULL, IDI_APPLICATION);
133     wndclass.hCursor        = LoadCursor(NULL, IDC_ARROW);
134     wndclass.hbrBackground  = GetStockObject(WHITE_BRUSH);
135     wndclass.lpszClassName  = szClassName;
136     wndclass.lpszMenuName   = NULL;
137     RegisterClassEx(&wndclass);
138 
139     hMainWnd = CreateWindow(szClassName, "Test", WS_OVERLAPPEDWINDOW, 0, 0, 500, 500, NULL, NULL, GetModuleHandle(NULL), NULL);
140     ShowWindow(hMainWnd, SW_SHOW);
141 
142     test_updates(0, 0);
143     test_updates(SS_SIMPLE, 0);
144     test_updates(SS_ICON, 0);
145     test_updates(SS_BITMAP, 0);
146     test_updates(SS_BITMAP | SS_CENTERIMAGE, 0);
147     test_updates(SS_BLACKRECT, TODO_COUNT);
148     test_updates(SS_WHITERECT, TODO_COUNT);
149     test_updates(SS_ETCHEDHORZ, TODO_COUNT);
150     test_updates(SS_ETCHEDVERT, TODO_COUNT);
151 
152     DestroyWindow(hMainWnd);
153 }
154 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.