mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 20:25:39 +00:00
update the comctl32 wine tests
svn path=/trunk/; revision=22314
This commit is contained in:
parent
64471203f9
commit
0262a2684c
16 changed files with 1950 additions and 141 deletions
236
reactos/regtests/winetests/comctl32/comboex.c
Normal file
236
reactos/regtests/winetests/comctl32/comboex.c
Normal file
|
@ -0,0 +1,236 @@
|
|||
/* Unit test suite for comboex control.
|
||||
*
|
||||
* Copyright 2005 Jason Edmeades
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <windows.h>
|
||||
#include <commctrl.h>
|
||||
|
||||
#include "wine/test.h"
|
||||
|
||||
static HWND hComboExParentWnd;
|
||||
static HINSTANCE hMainHinst;
|
||||
static const char ComboExTestClass[] = "ComboExTestClass";
|
||||
|
||||
#define MAX_CHARS 100
|
||||
static char *textBuffer = NULL;
|
||||
|
||||
static HWND createComboEx(DWORD style) {
|
||||
return CreateWindowExA(0, WC_COMBOBOXEXA, NULL, style, 0, 0, 300, 300,
|
||||
hComboExParentWnd, NULL, hMainHinst, NULL);
|
||||
}
|
||||
|
||||
static LONG addItem(HWND cbex, int idx, LPTSTR text) {
|
||||
COMBOBOXEXITEM cbexItem;
|
||||
memset(&cbexItem, 0x00, sizeof(cbexItem));
|
||||
cbexItem.mask = CBEIF_TEXT;
|
||||
cbexItem.iItem = idx;
|
||||
cbexItem.pszText = text;
|
||||
cbexItem.cchTextMax = 0;
|
||||
return (LONG)SendMessage(cbex, CBEM_INSERTITEM, 0,(LPARAM)&cbexItem);
|
||||
}
|
||||
|
||||
static LONG setItem(HWND cbex, int idx, LPTSTR text) {
|
||||
COMBOBOXEXITEM cbexItem;
|
||||
memset(&cbexItem, 0x00, sizeof(cbexItem));
|
||||
cbexItem.mask = CBEIF_TEXT;
|
||||
cbexItem.iItem = idx;
|
||||
cbexItem.pszText = text;
|
||||
cbexItem.cchTextMax = 0;
|
||||
return (LONG)SendMessage(cbex, CBEM_SETITEM, 0,(LPARAM)&cbexItem);
|
||||
}
|
||||
|
||||
static LONG delItem(HWND cbex, int idx) {
|
||||
return (LONG)SendMessage(cbex, CBEM_DELETEITEM, (LPARAM)idx, 0);
|
||||
}
|
||||
|
||||
static LONG getItem(HWND cbex, int idx, COMBOBOXEXITEM *cbItem) {
|
||||
memset(cbItem, 0x00, sizeof(COMBOBOXEXITEM));
|
||||
cbItem->mask = CBEIF_TEXT;
|
||||
cbItem->pszText = textBuffer;
|
||||
cbItem->iItem = idx;
|
||||
cbItem->cchTextMax = 100;
|
||||
return (LONG)SendMessage(cbex, CBEM_GETITEM, 0, (LPARAM)cbItem);
|
||||
}
|
||||
|
||||
static void test_comboboxex(void) {
|
||||
HWND myHwnd = 0;
|
||||
LONG res = -1;
|
||||
COMBOBOXEXITEM cbexItem;
|
||||
|
||||
#define FIRST_ITEM "First Item"
|
||||
#define SECOND_ITEM "Second Item"
|
||||
#define THIRD_ITEM "Third Item"
|
||||
#define MIDDLE_ITEM "Between First and Second Items"
|
||||
#define REPLACEMENT_ITEM "Between First and Second Items"
|
||||
|
||||
/* Allocate space for result */
|
||||
textBuffer = malloc(MAX_CHARS);
|
||||
|
||||
/* Basic comboboxex test */
|
||||
myHwnd = createComboEx(WS_BORDER | WS_VISIBLE | WS_CHILD | CBS_DROPDOWN);
|
||||
|
||||
/* Add items onto the end of the combobox */
|
||||
res = addItem(myHwnd, -1, FIRST_ITEM);
|
||||
ok(res == 0, "Adding simple item failed (%ld)\n", res);
|
||||
res = addItem(myHwnd, -1, SECOND_ITEM);
|
||||
ok(res == 1, "Adding simple item failed (%ld)\n", res);
|
||||
res = addItem(myHwnd, 2, THIRD_ITEM);
|
||||
ok(res == 2, "Adding simple item failed (%ld)\n", res);
|
||||
res = addItem(myHwnd, 1, MIDDLE_ITEM);
|
||||
ok(res == 1, "Inserting simple item failed (%ld)\n", res);
|
||||
|
||||
/* Add an item completely out of range */
|
||||
res = addItem(myHwnd, 99, "Out Of Range Item");
|
||||
ok(res == -1, "Adding using out of range index worked unexpectedly (%ld)\n", res);
|
||||
res = addItem(myHwnd, 5, "Out Of Range Item");
|
||||
ok(res == -1, "Adding using out of range index worked unexpectedly (%ld)\n", res);
|
||||
/* Removed: Causes traps on Windows XP
|
||||
res = addItem(myHwnd, -2, "Out Of Range Item");
|
||||
ok(res == -1, "Adding out of range worked unexpectedly (%ld)\n", res);
|
||||
*/
|
||||
|
||||
/* Get an item completely out of range */
|
||||
res = getItem(myHwnd, 99, &cbexItem);
|
||||
ok(res == 0, "Getting item using out of range index worked unexpectedly (%ld, %s)\n", res, cbexItem.pszText);
|
||||
res = getItem(myHwnd, 4, &cbexItem);
|
||||
ok(res == 0, "Getting item using out of range index worked unexpectedly (%ld, %s)\n", res, cbexItem.pszText);
|
||||
res = getItem(myHwnd, -2, &cbexItem);
|
||||
ok(res == 0, "Getting item using out of range index worked unexpectedly (%ld, %s)\n", res, cbexItem.pszText);
|
||||
|
||||
/* Get an item in range */
|
||||
res = getItem(myHwnd, 0, &cbexItem);
|
||||
ok(res != 0, "Getting item using valid index failed unexpectedly (%ld)\n", res);
|
||||
ok(strcmp(FIRST_ITEM, cbexItem.pszText) == 0, "Getting item returned wrong string (%s)\n", cbexItem.pszText);
|
||||
|
||||
res = getItem(myHwnd, 1, &cbexItem);
|
||||
ok(res != 0, "Getting item using valid index failed unexpectedly (%ld)\n", res);
|
||||
ok(strcmp(MIDDLE_ITEM, cbexItem.pszText) == 0, "Getting item returned wrong string (%s)\n", cbexItem.pszText);
|
||||
|
||||
res = getItem(myHwnd, 2, &cbexItem);
|
||||
ok(res != 0, "Getting item using valid index failed unexpectedly (%ld)\n", res);
|
||||
ok(strcmp(SECOND_ITEM, cbexItem.pszText) == 0, "Getting item returned wrong string (%s)\n", cbexItem.pszText);
|
||||
|
||||
res = getItem(myHwnd, 3, &cbexItem);
|
||||
ok(res != 0, "Getting item using valid index failed unexpectedly (%ld)\n", res);
|
||||
ok(strcmp(THIRD_ITEM, cbexItem.pszText) == 0, "Getting item returned wrong string (%s)\n", cbexItem.pszText);
|
||||
|
||||
/* Set an item completely out of range */
|
||||
res = setItem(myHwnd, 99, REPLACEMENT_ITEM);
|
||||
ok(res == 0, "Setting item using out of range index worked unexpectedly (%ld)\n", res);
|
||||
res = setItem(myHwnd, 4, REPLACEMENT_ITEM);
|
||||
ok(res == 0, "Setting item using out of range index worked unexpectedly (%ld)\n", res);
|
||||
res = setItem(myHwnd, -2, REPLACEMENT_ITEM);
|
||||
ok(res == 0, "Setting item using out of range index worked unexpectedly (%ld)\n", res);
|
||||
|
||||
/* Set an item in range */
|
||||
res = setItem(myHwnd, 0, REPLACEMENT_ITEM);
|
||||
ok(res != 0, "Setting first item failed (%ld)\n", res);
|
||||
res = setItem(myHwnd, 3, REPLACEMENT_ITEM);
|
||||
ok(res != 0, "Setting last item failed (%ld)\n", res);
|
||||
|
||||
/* Remove items completely out of range (4 items in control at this point) */
|
||||
res = delItem(myHwnd, -1);
|
||||
ok(res == CB_ERR, "Deleting using out of range index worked unexpectedly (%ld)\n", res);
|
||||
res = delItem(myHwnd, 4);
|
||||
ok(res == CB_ERR, "Deleting using out of range index worked unexpectedly (%ld)\n", res);
|
||||
|
||||
/* Remove items in range (4 items in control at this point) */
|
||||
res = delItem(myHwnd, 3);
|
||||
ok(res == 3, "Deleting using out of range index failed (%ld)\n", res);
|
||||
res = delItem(myHwnd, 0);
|
||||
ok(res == 2, "Deleting using out of range index failed (%ld)\n", res);
|
||||
res = delItem(myHwnd, 0);
|
||||
ok(res == 1, "Deleting using out of range index failed (%ld)\n", res);
|
||||
res = delItem(myHwnd, 0);
|
||||
ok(res == 0, "Deleting using out of range index failed (%ld)\n", res);
|
||||
|
||||
/* Remove from an empty box */
|
||||
res = delItem(myHwnd, 0);
|
||||
ok(res == CB_ERR, "Deleting using out of range index worked unexpectedly (%ld)\n", res);
|
||||
|
||||
|
||||
/* Cleanup */
|
||||
free(textBuffer);
|
||||
|
||||
}
|
||||
|
||||
LRESULT CALLBACK ComboExTestWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch(msg) {
|
||||
|
||||
case WM_DESTROY:
|
||||
PostQuitMessage(0);
|
||||
break;
|
||||
|
||||
default:
|
||||
return DefWindowProcA(hWnd, msg, wParam, lParam);
|
||||
}
|
||||
|
||||
return 0L;
|
||||
}
|
||||
|
||||
static void init(void) {
|
||||
WNDCLASSA wc;
|
||||
INITCOMMONCONTROLSEX icex;
|
||||
|
||||
icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
|
||||
icex.dwICC = ICC_USEREX_CLASSES;
|
||||
InitCommonControlsEx(&icex);
|
||||
|
||||
wc.style = CS_HREDRAW | CS_VREDRAW;
|
||||
wc.cbClsExtra = 0;
|
||||
wc.cbWndExtra = 0;
|
||||
wc.hInstance = GetModuleHandleA(NULL);
|
||||
wc.hIcon = NULL;
|
||||
wc.hCursor = LoadCursorA(NULL, MAKEINTRESOURCEA(IDC_ARROW));
|
||||
wc.hbrBackground = GetSysColorBrush(COLOR_WINDOW);
|
||||
wc.lpszMenuName = NULL;
|
||||
wc.lpszClassName = ComboExTestClass;
|
||||
wc.lpfnWndProc = ComboExTestWndProc;
|
||||
RegisterClassA(&wc);
|
||||
|
||||
hComboExParentWnd = CreateWindowExA(0, ComboExTestClass, "ComboEx test", WS_OVERLAPPEDWINDOW,
|
||||
CW_USEDEFAULT, CW_USEDEFAULT, 680, 260, NULL, NULL, GetModuleHandleA(NULL), 0);
|
||||
assert(hComboExParentWnd != NULL);
|
||||
|
||||
hMainHinst = GetModuleHandleA(NULL);
|
||||
|
||||
}
|
||||
|
||||
static void cleanup(void)
|
||||
{
|
||||
MSG msg;
|
||||
|
||||
PostMessageA(hComboExParentWnd, WM_CLOSE, 0, 0);
|
||||
while (GetMessageA(&msg,0,0,0)) {
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessageA(&msg);
|
||||
}
|
||||
|
||||
UnregisterClassA(ComboExTestClass, GetModuleHandleA(NULL));
|
||||
}
|
||||
|
||||
START_TEST(comboex)
|
||||
{
|
||||
init();
|
||||
|
||||
test_comboboxex();
|
||||
|
||||
cleanup();
|
||||
}
|
|
@ -5,9 +5,21 @@
|
|||
<library>ole32</library>
|
||||
<library>comctl32</library>
|
||||
<library>ntdll</library>
|
||||
<library>gdi32</library>
|
||||
<file>comboex.c</file>
|
||||
<file>dpa.c</file>
|
||||
<file>header.c</file>
|
||||
<file>imagelist.c</file>
|
||||
<file>monthcal.c</file>
|
||||
<file>mru.c</file>
|
||||
<file>progress.c</file>
|
||||
<file>propsheet.c</file>
|
||||
<file>subclass.c</file>
|
||||
<file>tab.c</file>
|
||||
<file>testlist.c</file>
|
||||
<file>toolbar.c</file>
|
||||
<file>tooltips.c</file>
|
||||
<file>treeview.c</file>
|
||||
<file>updown.c</file>
|
||||
<file>propsheet.rc</file>
|
||||
</module>
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#define COBJMACROS
|
||||
|
|
550
reactos/regtests/winetests/comctl32/header.c
Normal file
550
reactos/regtests/winetests/comctl32/header.c
Normal file
|
@ -0,0 +1,550 @@
|
|||
/* Unit test suite for header control.
|
||||
*
|
||||
* Copyright 2005 Vijay Kiran Kamuju
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
|
||||
#include <windows.h>
|
||||
#include <commctrl.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "wine/test.h"
|
||||
|
||||
typedef struct tagEXPECTEDNOTIFY
|
||||
{
|
||||
INT iCode;
|
||||
BOOL fUnicode;
|
||||
HDITEMA hdItem;
|
||||
} EXPECTEDNOTIFY;
|
||||
|
||||
EXPECTEDNOTIFY expectedNotify[10];
|
||||
INT nExpectedNotify = 0;
|
||||
INT nReceivedNotify = 0;
|
||||
INT unexpectedNotify[10];
|
||||
INT nUnexpectedNotify = 0;
|
||||
|
||||
static HWND hHeaderParentWnd;
|
||||
static HWND hWndHeader;
|
||||
#define MAX_CHARS 100
|
||||
|
||||
static void expect_notify(INT iCode, BOOL fUnicode, HDITEMA *lpItem)
|
||||
{
|
||||
assert(nExpectedNotify < 10);
|
||||
expectedNotify[nExpectedNotify].iCode = iCode;
|
||||
expectedNotify[nExpectedNotify].fUnicode = fUnicode;
|
||||
expectedNotify[nExpectedNotify].hdItem = *lpItem;
|
||||
nExpectedNotify++;
|
||||
}
|
||||
|
||||
static void dont_expect_notify(INT iCode)
|
||||
{
|
||||
assert(nUnexpectedNotify < 10);
|
||||
unexpectedNotify[nUnexpectedNotify++] = iCode;
|
||||
}
|
||||
|
||||
static BOOL notifies_received()
|
||||
{
|
||||
BOOL fRet = (nExpectedNotify == nReceivedNotify);
|
||||
nExpectedNotify = nReceivedNotify = 0;
|
||||
nUnexpectedNotify = 0;
|
||||
return fRet;
|
||||
}
|
||||
|
||||
static LONG addItem(HWND hdex, int idx, LPCSTR text)
|
||||
{
|
||||
HDITEMA hdItem;
|
||||
hdItem.mask = HDI_TEXT | HDI_WIDTH;
|
||||
hdItem.cxy = 100;
|
||||
hdItem.pszText = (LPSTR)text;
|
||||
hdItem.cchTextMax = 0;
|
||||
return (LONG)SendMessage(hdex, HDM_INSERTITEMA, (WPARAM)idx, (LPARAM)&hdItem);
|
||||
}
|
||||
|
||||
static LONG setItem(HWND hdex, int idx, LPCSTR text, BOOL fCheckNotifies)
|
||||
{
|
||||
LONG ret;
|
||||
HDITEMA hdexItem;
|
||||
hdexItem.mask = HDI_TEXT;
|
||||
hdexItem.pszText = (LPSTR)text;
|
||||
hdexItem.cchTextMax = 0;
|
||||
if (fCheckNotifies)
|
||||
{
|
||||
expect_notify(HDN_ITEMCHANGINGA, FALSE, &hdexItem);
|
||||
expect_notify(HDN_ITEMCHANGEDA, FALSE, &hdexItem);
|
||||
}
|
||||
ret = (LONG)SendMessage(hdex, HDM_SETITEMA, (WPARAM)idx, (LPARAM)&hdexItem);
|
||||
if (fCheckNotifies)
|
||||
ok(notifies_received(), "setItem(): not all expected notifies were received\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
static LONG setItemUnicodeNotify(HWND hdex, int idx, LPCSTR text, LPCWSTR wText)
|
||||
{
|
||||
LONG ret;
|
||||
HDITEMA hdexItem;
|
||||
HDITEMW hdexNotify;
|
||||
hdexItem.mask = HDI_TEXT;
|
||||
hdexItem.pszText = (LPSTR)text;
|
||||
hdexItem.cchTextMax = 0;
|
||||
|
||||
hdexNotify.mask = HDI_TEXT;
|
||||
hdexNotify.pszText = (LPWSTR)wText;
|
||||
|
||||
expect_notify(HDN_ITEMCHANGINGW, TRUE, (HDITEMA*)&hdexNotify);
|
||||
expect_notify(HDN_ITEMCHANGEDW, TRUE, (HDITEMA*)&hdexNotify);
|
||||
ret = (LONG)SendMessage(hdex, HDM_SETITEMA, (WPARAM)idx, (LPARAM)&hdexItem);
|
||||
ok(notifies_received(), "setItemUnicodeNotify(): not all expected notifies were received\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
static LONG delItem(HWND hdex, int idx)
|
||||
{
|
||||
return (LONG)SendMessage(hdex, HDM_DELETEITEM, (WPARAM)idx, 0);
|
||||
}
|
||||
|
||||
static LONG getItemCount(HWND hdex)
|
||||
{
|
||||
return (LONG)SendMessage(hdex, HDM_GETITEMCOUNT, 0, 0);
|
||||
}
|
||||
|
||||
static LONG getItem(HWND hdex, int idx, LPSTR textBuffer)
|
||||
{
|
||||
HDITEMA hdItem;
|
||||
hdItem.mask = HDI_TEXT;
|
||||
hdItem.pszText = textBuffer;
|
||||
hdItem.cchTextMax = MAX_CHARS;
|
||||
return (LONG)SendMessage(hdex, HDM_GETITEMA, (WPARAM)idx, (LPARAM)&hdItem);
|
||||
}
|
||||
|
||||
static void addReadDelItem(HWND hdex, HDITEMA *phdiCreate, int maskRead, HDITEMA *phdiRead)
|
||||
{
|
||||
ok(SendMessage(hdex, HDM_INSERTITEMA, (WPARAM)0, (LPARAM)phdiCreate)!=-1, "Adding item failed\n");
|
||||
ZeroMemory(phdiRead, sizeof(HDITEMA));
|
||||
phdiRead->mask = maskRead;
|
||||
ok(SendMessage(hdex, HDM_GETITEMA, (WPARAM)0, (LPARAM)phdiRead)!=0, "Getting item data failed\n");
|
||||
ok(SendMessage(hdex, HDM_DELETEITEM, (WPARAM)0, (LPARAM)0)!=0, "Deleteing item failed\n");
|
||||
}
|
||||
|
||||
static HWND create_header_control (void)
|
||||
{
|
||||
HWND handle;
|
||||
HDLAYOUT hlayout;
|
||||
RECT rectwin;
|
||||
WINDOWPOS winpos;
|
||||
|
||||
handle = CreateWindowEx(0, WC_HEADER, NULL,
|
||||
WS_CHILD|WS_BORDER|WS_VISIBLE|HDS_BUTTONS|HDS_HORZ,
|
||||
0, 0, 0, 0,
|
||||
hHeaderParentWnd, NULL, NULL, NULL);
|
||||
assert(handle);
|
||||
|
||||
if (winetest_interactive)
|
||||
ShowWindow (hHeaderParentWnd, SW_SHOW);
|
||||
|
||||
GetClientRect(hHeaderParentWnd,&rectwin);
|
||||
hlayout.prc = &rectwin;
|
||||
hlayout.pwpos = &winpos;
|
||||
SendMessageA(handle,HDM_LAYOUT,0,(LPARAM) &hlayout);
|
||||
SetWindowPos(handle, winpos.hwndInsertAfter, winpos.x, winpos.y,
|
||||
winpos.cx, winpos.cy, 0);
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
static void compare_items(INT iCode, HDITEMA *hdi1, HDITEMA *hdi2, BOOL fUnicode)
|
||||
{
|
||||
ok(hdi1->mask == hdi2->mask, "Notify %d mask mismatch (%08x != %08x)\n", iCode, hdi1->mask, hdi2->mask);
|
||||
if (hdi1->mask & HDI_WIDTH)
|
||||
{
|
||||
ok(hdi1->cxy == hdi2->cxy, "Notify %d cxy mismatch (%08x != %08x)\n", iCode, hdi1->cxy, hdi2->cxy);
|
||||
}
|
||||
if (hdi1->mask & HDI_TEXT)
|
||||
{
|
||||
if (hdi1->pszText == LPSTR_TEXTCALLBACKA)
|
||||
{
|
||||
ok(hdi1->pszText == LPSTR_TEXTCALLBACKA, "Notify %d - only one item is LPSTR_TEXTCALLBACK\n", iCode);
|
||||
}
|
||||
else
|
||||
if (fUnicode)
|
||||
{
|
||||
char buf1[260];
|
||||
char buf2[260];
|
||||
WideCharToMultiByte(CP_ACP, 0, (LPCWSTR)hdi1->pszText, -1, buf1, 260, NULL, NULL);
|
||||
WideCharToMultiByte(CP_ACP, 0, (LPCWSTR)hdi2->pszText, -1, buf2, 260, NULL, NULL);
|
||||
ok(lstrcmpW((LPWSTR)hdi1->pszText, (LPWSTR)hdi2->pszText)==0,
|
||||
"Notify %d text mismatch (L\"%s\" vs L\"%s\")\n",
|
||||
iCode, buf1, buf2);
|
||||
}
|
||||
else
|
||||
{
|
||||
ok(strcmp(hdi1->pszText, hdi2->pszText)==0,
|
||||
"Notify %d text mismatch (\"%s\" vs \"%s\")\n",
|
||||
iCode, hdi1->pszText, hdi2->pszText);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static const char *str_items[] =
|
||||
{"First Item", "Second Item", "Third Item", "Fourth Item", "Replace Item", "Out Of Range Item"};
|
||||
|
||||
static const char pszUniTestA[] = "TST";
|
||||
static const WCHAR pszUniTestW[] = {'T','S','T',0};
|
||||
|
||||
|
||||
#define TEST_GET_ITEM(i,c)\
|
||||
{ res = getItem(hWndHeader, i, buffer);\
|
||||
ok(res != 0, "Getting item[%d] using valid index failed unexpectedly (%ld)\n", i, res);\
|
||||
ok(strcmp(str_items[c], buffer) == 0, "Getting item[%d] returned \"%s\" expecting \"%s\"\n", i, buffer, str_items[c]);\
|
||||
}
|
||||
|
||||
#define TEST_GET_ITEMCOUNT(i)\
|
||||
{ res = getItemCount(hWndHeader);\
|
||||
ok(res == i, "Got Item Count as %ld\n", res);\
|
||||
}
|
||||
|
||||
static void check_auto_format(void)
|
||||
{
|
||||
HDITEMA hdiCreate;
|
||||
HDITEMA hdiRead;
|
||||
static CHAR text[] = "Test";
|
||||
ZeroMemory(&hdiCreate, sizeof(HDITEMA));
|
||||
|
||||
/* Windows implicitly sets some format bits in INSERTITEM */
|
||||
|
||||
/* HDF_STRING is automaticaly set and cleared for no text */
|
||||
hdiCreate.mask = HDI_TEXT|HDI_WIDTH|HDI_FORMAT;
|
||||
hdiCreate.pszText = text;
|
||||
hdiCreate.cxy = 100;
|
||||
hdiCreate.fmt=HDF_CENTER;
|
||||
addReadDelItem(hWndHeader, &hdiCreate, HDI_FORMAT, &hdiRead);
|
||||
ok(hdiRead.fmt == (HDF_STRING|HDF_CENTER), "HDF_STRING not set automatically (fmt=%x)\n", hdiRead.fmt);
|
||||
|
||||
hdiCreate.mask = HDI_WIDTH|HDI_FORMAT;
|
||||
hdiCreate.pszText = text;
|
||||
hdiCreate.fmt = HDF_CENTER|HDF_STRING;
|
||||
addReadDelItem(hWndHeader, &hdiCreate, HDI_FORMAT, &hdiRead);
|
||||
ok(hdiRead.fmt == (HDF_CENTER), "HDF_STRING should be automatically cleared (fmt=%x)\n", hdiRead.fmt);
|
||||
|
||||
/* HDF_BITMAP is automatically set and cleared for a NULL bitmap or no bitmap */
|
||||
hdiCreate.mask = HDI_BITMAP|HDI_WIDTH|HDI_FORMAT;
|
||||
hdiCreate.hbm = CreateBitmap(16, 16, 1, 8, NULL);
|
||||
hdiCreate.fmt = HDF_CENTER;
|
||||
addReadDelItem(hWndHeader, &hdiCreate, HDI_FORMAT, &hdiRead);
|
||||
ok(hdiRead.fmt == (HDF_BITMAP|HDF_CENTER), "HDF_BITMAP not set automatically (fmt=%x)\n", hdiRead.fmt);
|
||||
DeleteObject(hdiCreate.hbm);
|
||||
|
||||
hdiCreate.hbm = NULL;
|
||||
hdiCreate.fmt = HDF_CENTER|HDF_BITMAP;
|
||||
addReadDelItem(hWndHeader, &hdiCreate, HDI_FORMAT, &hdiRead);
|
||||
ok(hdiRead.fmt == HDF_CENTER, "HDF_BITMAP not cleared automatically for NULL bitmap (fmt=%x)\n", hdiRead.fmt);
|
||||
|
||||
hdiCreate.mask = HDI_WIDTH|HDI_FORMAT;
|
||||
hdiCreate.fmt = HDF_CENTER|HDF_BITMAP;
|
||||
addReadDelItem(hWndHeader, &hdiCreate, HDI_FORMAT, &hdiRead);
|
||||
ok(hdiRead.fmt == HDF_CENTER, "HDF_BITMAP not cleared automatically for no bitmap (fmt=%x)\n", hdiRead.fmt);
|
||||
|
||||
/* HDF_IMAGE is automatically set but not cleared */
|
||||
hdiCreate.mask = HDI_IMAGE|HDI_WIDTH|HDI_FORMAT;
|
||||
hdiCreate.iImage = 17;
|
||||
addReadDelItem(hWndHeader, &hdiCreate, HDI_FORMAT, &hdiRead);
|
||||
ok(hdiRead.fmt == (HDF_IMAGE|HDF_CENTER), "HDF_IMAGE not set automatically (fmt=%x)\n", hdiRead.fmt);
|
||||
|
||||
hdiCreate.mask = HDI_WIDTH|HDI_FORMAT;
|
||||
hdiCreate.fmt = HDF_CENTER|HDF_IMAGE;
|
||||
hdiCreate.iImage = 0;
|
||||
addReadDelItem(hWndHeader, &hdiCreate, HDI_FORMAT, &hdiRead);
|
||||
ok(hdiRead.fmt == (HDF_CENTER|HDF_IMAGE), "HDF_IMAGE shouldn't be cleared automatically (fmt=%x)\n", hdiRead.fmt);
|
||||
}
|
||||
|
||||
static void check_auto_fields(void)
|
||||
{
|
||||
HDITEMA hdiCreate;
|
||||
HDITEMA hdiRead;
|
||||
static CHAR text[] = "Test";
|
||||
LRESULT res;
|
||||
|
||||
/* Windows stores the format, width, lparam even if they are not in the item's mask */
|
||||
ZeroMemory(&hdiCreate, sizeof(HDITEMA));
|
||||
hdiCreate.mask = HDI_TEXT;
|
||||
hdiCreate.cxy = 100;
|
||||
hdiCreate.pszText = text;
|
||||
addReadDelItem(hWndHeader, &hdiCreate, HDI_WIDTH, &hdiRead);
|
||||
TEST_GET_ITEMCOUNT(6);
|
||||
ok(hdiRead.cxy == hdiCreate.cxy, "cxy should be automatically set\n");
|
||||
|
||||
ZeroMemory(&hdiCreate, sizeof(HDITEMA));
|
||||
hdiCreate.mask = HDI_TEXT;
|
||||
hdiCreate.pszText = text;
|
||||
hdiCreate.lParam = 0x12345678;
|
||||
addReadDelItem(hWndHeader, &hdiCreate, HDI_LPARAM, &hdiRead);
|
||||
TEST_GET_ITEMCOUNT(6);
|
||||
ok(hdiRead.lParam == hdiCreate.lParam, "lParam should be automatically set\n");
|
||||
|
||||
ZeroMemory(&hdiCreate, sizeof(HDITEMA));
|
||||
hdiCreate.mask = HDI_TEXT;
|
||||
hdiCreate.pszText = text;
|
||||
hdiCreate.fmt = HDF_STRING|HDF_CENTER;
|
||||
addReadDelItem(hWndHeader, &hdiCreate, HDI_FORMAT, &hdiRead);
|
||||
TEST_GET_ITEMCOUNT(6);
|
||||
ok(hdiRead.fmt == hdiCreate.fmt, "fmt should be automatically set\n");
|
||||
|
||||
/* others fields are not set */
|
||||
ZeroMemory(&hdiCreate, sizeof(HDITEMA));
|
||||
hdiCreate.mask = HDI_TEXT;
|
||||
hdiCreate.pszText = text;
|
||||
hdiCreate.hbm = CreateBitmap(16, 16, 1, 8, NULL);
|
||||
addReadDelItem(hWndHeader, &hdiCreate, HDI_BITMAP, &hdiRead);
|
||||
TEST_GET_ITEMCOUNT(6);
|
||||
ok(hdiRead.hbm == NULL, "hbm should not be automatically set\n");
|
||||
DeleteObject(hdiCreate.hbm);
|
||||
|
||||
ZeroMemory(&hdiCreate, sizeof(HDITEMA));
|
||||
hdiCreate.mask = HDI_IMAGE;
|
||||
hdiCreate.iImage = 17;
|
||||
hdiCreate.pszText = text;
|
||||
addReadDelItem(hWndHeader, &hdiCreate, HDI_TEXT, &hdiRead);
|
||||
TEST_GET_ITEMCOUNT(6);
|
||||
ok(hdiRead.pszText==NULL, "pszText shouldn't be automatically set\n");
|
||||
|
||||
/* field from comctl >4.0 not tested as the system probably won't touch them */
|
||||
}
|
||||
|
||||
static void check_mask()
|
||||
{
|
||||
HDITEMA hdi;
|
||||
static CHAR text[] = "ABC";
|
||||
LRESULT ret;
|
||||
|
||||
/* don't create items if the mask is zero */
|
||||
ZeroMemory(&hdi, sizeof(hdi));
|
||||
hdi.mask = 0;
|
||||
hdi.cxy = 200;
|
||||
hdi.pszText = text;
|
||||
hdi.fmt = 0;
|
||||
hdi.iOrder = 0;
|
||||
hdi.lParam = 17;
|
||||
hdi.cchTextMax = 260;
|
||||
ret = SendMessage(hWndHeader, HDM_INSERTITEM, (WPARAM)0, (LPARAM)&hdi);
|
||||
ok(ret == -1, "Creating an item with a zero mask should have failed\n");
|
||||
if (ret != -1) SendMessage(hWndHeader, HDM_DELETEITEM, (WPARAM)0, (LPARAM)0);
|
||||
|
||||
/* with a non-zero mask creation will succeed */
|
||||
ZeroMemory(&hdi, sizeof(hdi));
|
||||
hdi.mask = HDI_LPARAM;
|
||||
ret = SendMessage(hWndHeader, HDM_INSERTITEM, (WPARAM)0, (LPARAM)&hdi);
|
||||
ok(ret != -1, "Adding item with non-zero mask failed\n");
|
||||
if (ret != -1)
|
||||
SendMessage(hWndHeader, HDM_DELETEITEM, (WPARAM)0, (LPARAM)0);
|
||||
|
||||
/* in SETITEM if the mask contains a unknown bit, it is ignored */
|
||||
ZeroMemory(&hdi, sizeof(hdi));
|
||||
hdi.mask = 0x08000000 | HDI_LPARAM | HDI_IMAGE;
|
||||
hdi.lParam = 133;
|
||||
hdi.iImage = 17;
|
||||
ret = SendMessage(hWndHeader, HDM_INSERTITEM, (WPARAM)0, (LPARAM)&hdi);
|
||||
ok(ret != -1, "Adding item failed\n");
|
||||
|
||||
if (ret != -1)
|
||||
{
|
||||
/* check result */
|
||||
ZeroMemory(&hdi, sizeof(hdi));
|
||||
hdi.mask = HDI_LPARAM | HDI_IMAGE;
|
||||
SendMessage(hWndHeader, HDM_GETITEM, (WPARAM)0, (LPARAM)&hdi);
|
||||
ok(hdi.lParam == 133, "comctl32 4.0 field not set\n");
|
||||
ok(hdi.iImage == 17, "comctl32 >4.0 field not set\n");
|
||||
|
||||
/* but in GETITEM if an unknown bit is set, comctl32 uses only version 4.0 fields */
|
||||
ZeroMemory(&hdi, sizeof(hdi));
|
||||
hdi.mask = 0x08000000 | HDI_LPARAM | HDI_IMAGE;
|
||||
SendMessage(hWndHeader, HDM_GETITEM, (WPARAM)0, (LPARAM)&hdi);
|
||||
ok(hdi.lParam == 133, "comctl32 4.0 field not read\n");
|
||||
ok(hdi.iImage == 0, "comctl32 >4.0 field shouldn't be read\n");
|
||||
|
||||
SendMessage(hWndHeader, HDM_DELETEITEM, (WPARAM)0, (LPARAM)0);
|
||||
}
|
||||
}
|
||||
|
||||
static void test_header_control (void)
|
||||
{
|
||||
LONG res;
|
||||
static char buffer[MAX_CHARS];
|
||||
int i;
|
||||
|
||||
hWndHeader = create_header_control ();
|
||||
|
||||
for (i = 3; i >= 0; i--)
|
||||
{
|
||||
TEST_GET_ITEMCOUNT(3-i);
|
||||
res = addItem(hWndHeader, 0, str_items[i]);
|
||||
ok(res == 0, "Adding simple item failed (%ld)\n", res);
|
||||
}
|
||||
|
||||
TEST_GET_ITEMCOUNT(4);
|
||||
res = addItem(hWndHeader, 99, str_items[i+1]);
|
||||
ok(res != -1, "Adding Out of Range item should fail with -1 got (%ld)\n", res);
|
||||
TEST_GET_ITEMCOUNT(5);
|
||||
res = addItem(hWndHeader, 5, str_items[i+1]);
|
||||
ok(res != -1, "Adding Out of Range item should fail with -1 got (%ld)\n", res);
|
||||
TEST_GET_ITEMCOUNT(6);
|
||||
|
||||
for (i = 0; i < 4; i++) { TEST_GET_ITEM(i,i); TEST_GET_ITEMCOUNT(6); }
|
||||
|
||||
res=getItem(hWndHeader, 99, buffer);
|
||||
ok(res == 0, "Getting Out of Range item should fail with 0 (%ld), got %s\n", res,buffer);
|
||||
res=getItem(hWndHeader, 5, buffer);
|
||||
ok(res == 1, "Getting Out of Range item should fail with 1 (%ld), got %s\n", res,buffer);
|
||||
res=getItem(hWndHeader, -2, buffer);
|
||||
ok(res == 0, "Getting Out of Range item should fail with 0 (%ld), got %s\n", res,buffer);
|
||||
|
||||
if (winetest_interactive)
|
||||
{
|
||||
UpdateWindow(hHeaderParentWnd);
|
||||
UpdateWindow(hWndHeader);
|
||||
}
|
||||
|
||||
TEST_GET_ITEMCOUNT(6);
|
||||
res=setItem(hWndHeader, 99, str_items[5], FALSE);
|
||||
ok(res == 0, "Setting Out of Range item should fail with 0 (%ld)\n", res);
|
||||
res=setItem(hWndHeader, 5, str_items[5], TRUE);
|
||||
ok(res == 1, "Setting Out of Range item should fail with 1 (%ld)\n", res);
|
||||
res=setItem(hWndHeader, -2, str_items[5], FALSE);
|
||||
ok(res == 0, "Setting Out of Range item should fail with 0 (%ld)\n", res);
|
||||
TEST_GET_ITEMCOUNT(6);
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
res = setItem(hWndHeader, i, str_items[4], TRUE);
|
||||
ok(res != 0, "Setting %d item failed (%ld)\n", i+1, res);
|
||||
TEST_GET_ITEM(i, 4);
|
||||
TEST_GET_ITEMCOUNT(6);
|
||||
}
|
||||
|
||||
SendMessageA(hWndHeader, HDM_SETUNICODEFORMAT, (WPARAM)TRUE, 0);
|
||||
setItemUnicodeNotify(hWndHeader, 3, pszUniTestA, pszUniTestW);
|
||||
SendMessageA(hWndHeader, WM_NOTIFYFORMAT, (WPARAM)hHeaderParentWnd, (LPARAM)NF_REQUERY);
|
||||
setItem(hWndHeader, 3, str_items[4], TRUE);
|
||||
|
||||
dont_expect_notify(HDN_GETDISPINFOA);
|
||||
dont_expect_notify(HDN_GETDISPINFOW);
|
||||
addItem(hWndHeader, 0, LPSTR_TEXTCALLBACKA);
|
||||
setItem(hWndHeader, 0, str_items[4], TRUE);
|
||||
/* unexpected notifies cleared by notifies_received in setItem */
|
||||
dont_expect_notify(HDN_GETDISPINFOA);
|
||||
dont_expect_notify(HDN_GETDISPINFOW);
|
||||
setItem(hWndHeader, 0, LPSTR_TEXTCALLBACKA, TRUE);
|
||||
/* unexpected notifies cleared by notifies_received in setItem */
|
||||
delItem(hWndHeader, 0);
|
||||
|
||||
check_auto_format();
|
||||
TEST_GET_ITEMCOUNT(6);
|
||||
check_auto_fields();
|
||||
TEST_GET_ITEMCOUNT(6);
|
||||
check_mask();
|
||||
TEST_GET_ITEMCOUNT(6);
|
||||
|
||||
res = delItem(hWndHeader, 5);
|
||||
ok(res == 1, "Deleting Out of Range item should fail with 1 (%ld)\n", res);
|
||||
res = delItem(hWndHeader, -2);
|
||||
ok(res == 0, "Deleting Out of Range item should fail with 0 (%ld)\n", res);
|
||||
TEST_GET_ITEMCOUNT(5);
|
||||
|
||||
res = delItem(hWndHeader, 3);
|
||||
ok(res != 0, "Deleting using out of range index failed (%ld)\n", res);
|
||||
TEST_GET_ITEMCOUNT(4);
|
||||
res = delItem(hWndHeader, 0);
|
||||
ok(res != 0, "Deleting using out of range index failed (%ld)\n", res);
|
||||
TEST_GET_ITEMCOUNT(3);
|
||||
res = delItem(hWndHeader, 0);
|
||||
ok(res != 0, "Deleting using out of range index failed (%ld)\n", res);
|
||||
TEST_GET_ITEMCOUNT(2);
|
||||
res = delItem(hWndHeader, 0);
|
||||
ok(res != 0, "Deleting using out of range index failed (%ld)\n", res);
|
||||
TEST_GET_ITEMCOUNT(1);
|
||||
|
||||
DestroyWindow(hWndHeader);
|
||||
}
|
||||
|
||||
|
||||
LRESULT CALLBACK HeaderTestWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch(msg) {
|
||||
|
||||
case WM_NOTIFY:
|
||||
{
|
||||
NMHEADERA *hdr = (NMHEADER *)lParam;
|
||||
EXPECTEDNOTIFY *expected;
|
||||
int i;
|
||||
|
||||
for (i=0; i<nUnexpectedNotify; i++)
|
||||
ok(hdr->hdr.code != unexpectedNotify[i], "Received invalid notify %d\n", hdr->hdr.code);
|
||||
|
||||
if (nReceivedNotify >= nExpectedNotify || hdr->hdr.hwndFrom != hWndHeader )
|
||||
break;
|
||||
|
||||
expected = &expectedNotify[nReceivedNotify];
|
||||
if (hdr->hdr.code != expected->iCode)
|
||||
break;
|
||||
|
||||
nReceivedNotify++;
|
||||
compare_items(hdr->hdr.code, &expected->hdItem, hdr->pitem, expected->fUnicode);
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_DESTROY:
|
||||
PostQuitMessage(0);
|
||||
break;
|
||||
|
||||
default:
|
||||
return DefWindowProcA(hWnd, msg, wParam, lParam);
|
||||
}
|
||||
|
||||
return 0L;
|
||||
}
|
||||
|
||||
static void init(void) {
|
||||
WNDCLASSA wc;
|
||||
INITCOMMONCONTROLSEX icex;
|
||||
|
||||
icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
|
||||
icex.dwICC = ICC_USEREX_CLASSES;
|
||||
InitCommonControlsEx(&icex);
|
||||
|
||||
wc.style = CS_HREDRAW | CS_VREDRAW;
|
||||
wc.cbClsExtra = 0;
|
||||
wc.cbWndExtra = 0;
|
||||
wc.hInstance = GetModuleHandleA(NULL);
|
||||
wc.hIcon = NULL;
|
||||
wc.hCursor = LoadCursorA(NULL, MAKEINTRESOURCEA(IDC_ARROW));
|
||||
wc.hbrBackground = GetSysColorBrush(COLOR_WINDOW);
|
||||
wc.lpszMenuName = NULL;
|
||||
wc.lpszClassName = "HeaderTestClass";
|
||||
wc.lpfnWndProc = HeaderTestWndProc;
|
||||
RegisterClassA(&wc);
|
||||
|
||||
hHeaderParentWnd = CreateWindowExA(0, "HeaderTestClass", "Header test", WS_OVERLAPPEDWINDOW,
|
||||
CW_USEDEFAULT, CW_USEDEFAULT, 680, 260, NULL, NULL, GetModuleHandleA(NULL), 0);
|
||||
assert(hHeaderParentWnd != NULL);
|
||||
}
|
||||
|
||||
START_TEST(header)
|
||||
{
|
||||
init();
|
||||
|
||||
test_header_control();
|
||||
|
||||
DestroyWindow(hHeaderParentWnd);
|
||||
}
|
|
@ -15,12 +15,12 @@
|
|||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <windows.h>
|
||||
#include <wine/commctrl.h>
|
||||
#include <commctrl.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "wine/test.h"
|
||||
|
|
96
reactos/regtests/winetests/comctl32/monthcal.c
Normal file
96
reactos/regtests/winetests/comctl32/monthcal.c
Normal file
|
@ -0,0 +1,96 @@
|
|||
/*
|
||||
* comctl32 month calendar unit tests
|
||||
*
|
||||
* Copyright (C) 2006 Vitaliy Margolen
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "windows.h"
|
||||
|
||||
#include "commctrl.h"
|
||||
|
||||
#include "wine/test.h"
|
||||
|
||||
void test_monthcal(void)
|
||||
{
|
||||
HWND hwnd;
|
||||
SYSTEMTIME st[2], st1[2];
|
||||
INITCOMMONCONTROLSEX ic = {sizeof(INITCOMMONCONTROLSEX), ICC_DATE_CLASSES};
|
||||
int res, month_range;
|
||||
|
||||
InitCommonControlsEx(&ic);
|
||||
hwnd = CreateWindowA(MONTHCAL_CLASSA, "MonthCal", WS_POPUP | WS_VISIBLE, CW_USEDEFAULT,
|
||||
0, 300, 300, 0, 0, NULL, NULL);
|
||||
ok(hwnd != NULL, "Failed to create MonthCal\n");
|
||||
GetSystemTime(&st[0]);
|
||||
st[1] = st[0];
|
||||
|
||||
/* Invalid date/time */
|
||||
st[0].wYear = 2000;
|
||||
/* Time should not matter */
|
||||
st[1].wHour = st[1].wMinute = st[1].wSecond = 70;
|
||||
ok(SendMessage(hwnd, MCM_SETRANGE, GDTR_MAX, (LPARAM)st), "Failed to set MAX limit\n");
|
||||
ok(SendMessage(hwnd, MCM_GETRANGE, 0, (LPARAM)st1) == GDTR_MAX, "No limits should be set\n");
|
||||
ok(st1[0].wYear != 2000, "Lover limit changed\n");
|
||||
|
||||
st[1].wMonth = 0;
|
||||
ok(!SendMessage(hwnd, MCM_SETRANGE, GDTR_MIN | GDTR_MAX, (LPARAM)st), "Should have failed to set limits\n");
|
||||
ok(SendMessage(hwnd, MCM_GETRANGE, 0, (LPARAM)st1) == GDTR_MAX, "No limits should be set\n");
|
||||
ok(st1[0].wYear != 2000, "Lover limit changed\n");
|
||||
ok(!SendMessage(hwnd, MCM_SETRANGE, GDTR_MAX, (LPARAM)st), "Should have failed to set MAX limit\n");
|
||||
ok(SendMessage(hwnd, MCM_GETRANGE, 0, (LPARAM)st1) == GDTR_MAX, "No limits should be set\n");
|
||||
ok(st1[0].wYear != 2000, "Lover limit changed\n");
|
||||
|
||||
GetSystemTime(&st[0]);
|
||||
st[0].wDay = 20;
|
||||
st[0].wMonth = 5;
|
||||
st[1] = st[0];
|
||||
|
||||
month_range = SendMessage(hwnd, MCM_GETMONTHRANGE, GMR_VISIBLE, (LPARAM)st1);
|
||||
st[1].wMonth--;
|
||||
ok(SendMessage(hwnd, MCM_SETRANGE, GDTR_MIN | GDTR_MAX, (LPARAM)st), "Failed to set both min and max limits\n");
|
||||
res = SendMessage(hwnd, MCM_GETMONTHRANGE, GMR_VISIBLE, (LPARAM)st1);
|
||||
ok(res == month_range, "Invalid month range (%d)\n", res);
|
||||
ok(SendMessage(hwnd, MCM_GETRANGE, 0, (LPARAM)st1) == (GDTR_MIN|GDTR_MAX), "Limits should be set\n");
|
||||
|
||||
st[1].wMonth += 2;
|
||||
ok(SendMessage(hwnd, MCM_SETRANGE, GDTR_MIN | GDTR_MAX, (LPARAM)st), "Failed to set both min and max limits\n");
|
||||
res = SendMessage(hwnd, MCM_GETMONTHRANGE, GMR_VISIBLE, (LPARAM)st1);
|
||||
ok(res == month_range, "Invalid month range (%d)\n", res);
|
||||
|
||||
st[1].wYear --;
|
||||
ok(SendMessage(hwnd, MCM_SETRANGE, GDTR_MIN | GDTR_MAX, (LPARAM)st), "Failed to set both min and max limits\n");
|
||||
st[1].wYear += 1;
|
||||
ok(SendMessage(hwnd, MCM_SETRANGE, GDTR_MIN | GDTR_MAX, (LPARAM)st), "Failed to set both min and max limits\n");
|
||||
|
||||
st[1].wMonth -= 3;
|
||||
ok(SendMessage(hwnd, MCM_SETRANGE, GDTR_MAX, (LPARAM)st), "Failed to set max limit\n");
|
||||
ok(SendMessage(hwnd, MCM_GETRANGE, 0, (LPARAM)st1) == GDTR_MAX, "Only MAX limit should be set\n");
|
||||
st[1].wMonth += 4;
|
||||
ok(SendMessage(hwnd, MCM_SETRANGE, GDTR_MAX, (LPARAM)st), "Failed to set max limit\n");
|
||||
st[1].wYear -= 3;
|
||||
ok(SendMessage(hwnd, MCM_SETRANGE, GDTR_MAX, (LPARAM)st), "Failed to set max limit\n");
|
||||
st[1].wYear += 4;
|
||||
ok(SendMessage(hwnd, MCM_SETRANGE, GDTR_MAX, (LPARAM)st), "Failed to set max limit\n");
|
||||
ok(SendMessage(hwnd, MCM_GETRANGE, 0, (LPARAM)st1) == GDTR_MAX, "Only MAX limit should be set\n");
|
||||
}
|
||||
|
||||
START_TEST(monthcal)
|
||||
{
|
||||
test_monthcal();
|
||||
}
|
|
@ -15,7 +15,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
#include <stdarg.h>
|
||||
|
||||
|
|
205
reactos/regtests/winetests/comctl32/progress.c
Normal file
205
reactos/regtests/winetests/comctl32/progress.c
Normal file
|
@ -0,0 +1,205 @@
|
|||
/* Unit tests for the progress bar control.
|
||||
*
|
||||
* Copyright 2005 Michael Kaufmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "wingdi.h"
|
||||
#include "winuser.h"
|
||||
#include "commctrl.h"
|
||||
|
||||
#include "wine/test.h"
|
||||
|
||||
|
||||
HWND hProgressParentWnd, hProgressWnd;
|
||||
static const char progressTestClass[] = "ProgressBarTestClass";
|
||||
|
||||
|
||||
LRESULT CALLBACK ProgressTestWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch(msg) {
|
||||
|
||||
case WM_DESTROY:
|
||||
PostQuitMessage(0);
|
||||
break;
|
||||
|
||||
default:
|
||||
return DefWindowProcA(hWnd, msg, wParam, lParam);
|
||||
}
|
||||
|
||||
return 0L;
|
||||
}
|
||||
|
||||
static WNDPROC progress_wndproc;
|
||||
static BOOL erased;
|
||||
static RECT last_paint_rect;
|
||||
|
||||
LRESULT CALLBACK ProgressSubclassProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
if (msg == WM_PAINT)
|
||||
{
|
||||
GetUpdateRect(hWnd, &last_paint_rect, FALSE);
|
||||
}
|
||||
else if (msg == WM_ERASEBKGND)
|
||||
{
|
||||
erased = TRUE;
|
||||
}
|
||||
return CallWindowProc(progress_wndproc, hWnd, msg, wParam, lParam);
|
||||
}
|
||||
|
||||
|
||||
static void update_window(HWND hWnd)
|
||||
{
|
||||
UpdateWindow(hWnd);
|
||||
ok(!GetUpdateRect(hWnd, NULL, FALSE), "GetUpdateRect must return zero after UpdateWindow\n");
|
||||
}
|
||||
|
||||
|
||||
static void init(void)
|
||||
{
|
||||
WNDCLASSA wc;
|
||||
INITCOMMONCONTROLSEX icex;
|
||||
RECT rect;
|
||||
|
||||
icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
|
||||
icex.dwICC = ICC_PROGRESS_CLASS;
|
||||
InitCommonControlsEx(&icex);
|
||||
|
||||
wc.style = CS_HREDRAW | CS_VREDRAW;
|
||||
wc.cbClsExtra = 0;
|
||||
wc.cbWndExtra = 0;
|
||||
wc.hInstance = GetModuleHandleA(NULL);
|
||||
wc.hIcon = NULL;
|
||||
wc.hCursor = LoadCursorA(NULL, MAKEINTRESOURCEA(IDC_ARROW));
|
||||
wc.hbrBackground = GetSysColorBrush(COLOR_WINDOW);
|
||||
wc.lpszMenuName = NULL;
|
||||
wc.lpszClassName = progressTestClass;
|
||||
wc.lpfnWndProc = ProgressTestWndProc;
|
||||
RegisterClassA(&wc);
|
||||
|
||||
rect.left = 0;
|
||||
rect.top = 0;
|
||||
rect.right = 400;
|
||||
rect.bottom = 20;
|
||||
assert(AdjustWindowRect(&rect, WS_OVERLAPPEDWINDOW, FALSE));
|
||||
|
||||
hProgressParentWnd = CreateWindowExA(0, progressTestClass, "Progress Bar Test", WS_OVERLAPPEDWINDOW,
|
||||
CW_USEDEFAULT, CW_USEDEFAULT, rect.right - rect.left, rect.bottom - rect.top, NULL, NULL, GetModuleHandleA(NULL), 0);
|
||||
assert(hProgressParentWnd != NULL);
|
||||
|
||||
GetClientRect(hProgressParentWnd, &rect);
|
||||
hProgressWnd = CreateWindowEx(0, PROGRESS_CLASS, "", WS_CHILD | WS_VISIBLE,
|
||||
0, 0, rect.right, rect.bottom, hProgressParentWnd, NULL, GetModuleHandleA(NULL), 0);
|
||||
assert(hProgressWnd != NULL);
|
||||
progress_wndproc = (WNDPROC)SetWindowLongPtr(hProgressWnd, GWLP_WNDPROC, (LPARAM)ProgressSubclassProc);
|
||||
|
||||
ShowWindow(hProgressParentWnd, SW_SHOWNORMAL);
|
||||
ok(GetUpdateRect(hProgressParentWnd, NULL, FALSE), "GetUpdateRect: There should be a region that needs to be updated\n");
|
||||
update_window(hProgressParentWnd);
|
||||
}
|
||||
|
||||
|
||||
static void cleanup(void)
|
||||
{
|
||||
MSG msg;
|
||||
|
||||
PostMessageA(hProgressParentWnd, WM_CLOSE, 0, 0);
|
||||
while (GetMessageA(&msg,0,0,0)) {
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessageA(&msg);
|
||||
}
|
||||
|
||||
UnregisterClassA(progressTestClass, GetModuleHandleA(NULL));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Tests if a progress bar repaints itself immediately when it receives
|
||||
* some specific messages.
|
||||
*/
|
||||
static void test_redraw(void)
|
||||
{
|
||||
RECT client_rect;
|
||||
|
||||
SendMessageA(hProgressWnd, PBM_SETRANGE, 0, MAKELPARAM(0, 100));
|
||||
SendMessageA(hProgressWnd, PBM_SETPOS, 10, 0);
|
||||
SendMessageA(hProgressWnd, PBM_SETSTEP, 20, 0);
|
||||
update_window(hProgressWnd);
|
||||
|
||||
/* PBM_SETPOS */
|
||||
ok(SendMessageA(hProgressWnd, PBM_SETPOS, 50, 0) == 10, "PBM_SETPOS must return the previous position\n");
|
||||
ok(!GetUpdateRect(hProgressWnd, NULL, FALSE), "PBM_SETPOS: The progress bar should be redrawn immediately\n");
|
||||
|
||||
/* PBM_DELTAPOS */
|
||||
ok(SendMessageA(hProgressWnd, PBM_DELTAPOS, 15, 0) == 50, "PBM_DELTAPOS must return the previous position\n");
|
||||
ok(!GetUpdateRect(hProgressWnd, NULL, FALSE), "PBM_DELTAPOS: The progress bar should be redrawn immediately\n");
|
||||
|
||||
/* PBM_SETPOS */
|
||||
ok(SendMessageA(hProgressWnd, PBM_SETPOS, 80, 0) == 65, "PBM_SETPOS must return the previous position\n");
|
||||
ok(!GetUpdateRect(hProgressWnd, NULL, FALSE), "PBM_SETPOS: The progress bar should be redrawn immediately\n");
|
||||
|
||||
/* PBM_STEPIT */
|
||||
ok(SendMessageA(hProgressWnd, PBM_STEPIT, 0, 0) == 80, "PBM_STEPIT must return the previous position\n");
|
||||
ok(!GetUpdateRect(hProgressWnd, NULL, FALSE), "PBM_STEPIT: The progress bar should be redrawn immediately\n");
|
||||
ok((UINT)SendMessageA(hProgressWnd, PBM_GETPOS, 0, 0) == 100, "PBM_GETPOS returned a wrong position\n");
|
||||
|
||||
/* PBM_SETRANGE and PBM_SETRANGE32:
|
||||
Usually the progress bar doesn't repaint itself immediately. If the
|
||||
position is not in the new range, it does.
|
||||
Don't test this, it may change in future Windows versions. */
|
||||
|
||||
SendMessage(hProgressWnd, PBM_SETPOS, 0, 0);
|
||||
update_window(hProgressWnd);
|
||||
|
||||
/* increase to 10 - no background erase required */
|
||||
erased = FALSE;
|
||||
SetRectEmpty(&last_paint_rect);
|
||||
SendMessage(hProgressWnd, PBM_SETPOS, 10, 0);
|
||||
GetClientRect(hProgressWnd, &client_rect);
|
||||
ok(EqualRect(&last_paint_rect, &client_rect),
|
||||
"last_paint_rect was { %ld, %ld, %ld, %ld } instead of { %ld, %ld, %ld, %ld }\n",
|
||||
last_paint_rect.left, last_paint_rect.top, last_paint_rect.right, last_paint_rect.bottom,
|
||||
client_rect.left, client_rect.top, client_rect.right, client_rect.bottom);
|
||||
update_window(hProgressWnd);
|
||||
ok(!erased, "Progress bar shouldn't have erased the background\n");
|
||||
|
||||
/* decrease to 0 - background erase will be required */
|
||||
erased = FALSE;
|
||||
SetRectEmpty(&last_paint_rect);
|
||||
SendMessage(hProgressWnd, PBM_SETPOS, 0, 0);
|
||||
GetClientRect(hProgressWnd, &client_rect);
|
||||
ok(EqualRect(&last_paint_rect, &client_rect),
|
||||
"last_paint_rect was { %ld, %ld, %ld, %ld } instead of { %ld, %ld, %ld, %ld }\n",
|
||||
last_paint_rect.left, last_paint_rect.top, last_paint_rect.right, last_paint_rect.bottom,
|
||||
client_rect.left, client_rect.top, client_rect.right, client_rect.bottom);
|
||||
update_window(hProgressWnd);
|
||||
ok(erased, "Progress bar should have erased the background\n");
|
||||
}
|
||||
|
||||
|
||||
START_TEST(progress)
|
||||
{
|
||||
init();
|
||||
|
||||
test_redraw();
|
||||
|
||||
cleanup();
|
||||
}
|
107
reactos/regtests/winetests/comctl32/propsheet.c
Normal file
107
reactos/regtests/winetests/comctl32/propsheet.c
Normal file
|
@ -0,0 +1,107 @@
|
|||
/* Unit test suite for property sheet control.
|
||||
*
|
||||
* Copyright 2006 Huw Davies
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#define NONAMELESSUNION
|
||||
#define NONAMELESSSTRUCT
|
||||
|
||||
#include <windows.h>
|
||||
#include <commctrl.h>
|
||||
|
||||
#include "wine/test.h"
|
||||
|
||||
static int CALLBACK sheet_callback(HWND hwnd, UINT msg, LPARAM lparam)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case PSCB_INITIALIZED:
|
||||
{
|
||||
char caption[256];
|
||||
GetWindowTextA(hwnd, caption, sizeof(caption));
|
||||
ok(!strcmp(caption,"test caption"), "caption: %s\n", caption);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static INT_PTR CALLBACK page_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam,
|
||||
LPARAM lparam)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
{
|
||||
HWND sheet = GetParent(hwnd);
|
||||
char caption[256];
|
||||
GetWindowTextA(sheet, caption, sizeof(caption));
|
||||
ok(!strcmp(caption,"test caption"), "caption: %s\n", caption);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
case WM_NOTIFY:
|
||||
{
|
||||
NMHDR *nmhdr = (NMHDR *)lparam;
|
||||
switch(nmhdr->code)
|
||||
{
|
||||
case PSN_APPLY:
|
||||
return TRUE;
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
static void test_title(void)
|
||||
{
|
||||
HPROPSHEETPAGE hpsp[1];
|
||||
PROPSHEETPAGEA psp;
|
||||
PROPSHEETHEADERA psh;
|
||||
HWND hdlg;
|
||||
|
||||
memset(&psp, 0, sizeof(psp));
|
||||
psp.dwSize = sizeof(psp);
|
||||
psp.dwFlags = 0;
|
||||
psp.hInstance = GetModuleHandleW(NULL);
|
||||
psp.u.pszTemplate = "prop_page1";
|
||||
psp.u2.pszIcon = NULL;
|
||||
psp.pfnDlgProc = page_dlg_proc;
|
||||
psp.lParam = 0;
|
||||
|
||||
hpsp[0] = CreatePropertySheetPageA(&psp);
|
||||
|
||||
memset(&psh, 0, sizeof(psh));
|
||||
psh.dwSize = sizeof(psh);
|
||||
psh.dwFlags = PSH_MODELESS | PSH_USECALLBACK;
|
||||
psh.pszCaption = "test caption";
|
||||
psh.nPages = 1;
|
||||
psh.hwndParent = GetDesktopWindow();
|
||||
psh.u3.phpage = hpsp;
|
||||
psh.pfnCallback = sheet_callback;
|
||||
|
||||
hdlg = (HWND)PropertySheetA(&psh);
|
||||
DestroyWindow(hdlg);
|
||||
}
|
||||
|
||||
START_TEST(propsheet)
|
||||
{
|
||||
test_title();
|
||||
}
|
29
reactos/regtests/winetests/comctl32/propsheet.rc
Normal file
29
reactos/regtests/winetests/comctl32/propsheet.rc
Normal file
|
@ -0,0 +1,29 @@
|
|||
/* Resources for the unit test suite for property sheet control.
|
||||
*
|
||||
* Copyright 2006 Huw Davies
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include "windef.h"
|
||||
#include "winuser.h"
|
||||
|
||||
PROP_PAGE1 DIALOG LOADONCALL MOVEABLE DISCARDABLE 5, 43, 227, 215
|
||||
STYLE WS_POPUP | WS_CAPTION | WS_CLIPSIBLINGS | WS_VISIBLE
|
||||
CAPTION "Page1"
|
||||
FONT 8, "MS Shell Dlg"
|
||||
{
|
||||
LTEXT "Test", -1, 10, 6, 100, 8
|
||||
}
|
|
@ -14,7 +14,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
|
@ -234,7 +234,7 @@ static void test_subclass(void)
|
|||
ok_sequence(Sub_AfterDeletedTest, "After Deleted");
|
||||
|
||||
pSetWindowSubclass(hwnd, WndProcSub, 2, 0);
|
||||
origProc3 = (WNDPROC)SetWindowLong(hwnd, GWL_WNDPROC, (LONG)WndProc3);
|
||||
origProc3 = (WNDPROC)SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG)WndProc3);
|
||||
SendMessage(hwnd, WM_USER, 1, 0);
|
||||
SendMessage(hwnd, WM_USER, 2, 0);
|
||||
ok_sequence(Sub_OldAfterNewTest, "Old after New");
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
|
@ -23,29 +23,43 @@
|
|||
|
||||
#include "wine/test.h"
|
||||
|
||||
#undef VISIBLE
|
||||
|
||||
#define DEFAULT_MIN_TAB_WIDTH 54
|
||||
#define TAB_DEFAULT_WIDTH 96
|
||||
#define TAB_PADDING_X 2
|
||||
#define TAB_PADDING_Y 2
|
||||
#define TAB_PADDING_X 6
|
||||
#define EXTRA_ICON_PADDING 3
|
||||
|
||||
#define TCS_BOTTOM 0x0002
|
||||
#define TabWidthPadded(padd_x, num) (DEFAULT_MIN_TAB_WIDTH - (TAB_PADDING_X - (padd_x)) * num)
|
||||
|
||||
#ifdef VISIBLE
|
||||
#define WAIT Sleep (1000)
|
||||
#define REDRAW(hwnd) RedrawWindow (hwnd, NULL, 0, RDW_UPDATENOW)
|
||||
#define trace_tab(str) trace(str)
|
||||
#else
|
||||
#define WAIT
|
||||
#define REDRAW(hwnd)
|
||||
#define trace_tab(str)
|
||||
#endif
|
||||
#define TabCheckSetSize(hwnd, SetWidth, SetHeight, ExpWidth, ExpHeight, Msg)\
|
||||
SendMessage (hwnd, TCM_SETITEMSIZE, 0,\
|
||||
(LPARAM) MAKELPARAM((SetWidth >= 0) ? SetWidth:0, (SetHeight >= 0) ? SetHeight:0));\
|
||||
if (winetest_interactive) RedrawWindow (hwnd, NULL, 0, RDW_UPDATENOW);\
|
||||
CheckSize(hwnd, ExpWidth, ExpHeight, Msg);
|
||||
|
||||
#define CheckSize(hwnd,width,height,msg)\
|
||||
SendMessage (hwnd, TCM_GETITEMRECT, 0, (LPARAM) &rTab);\
|
||||
if ((width >= 0) && (height < 0))\
|
||||
ok (width == rTab.right - rTab.left, "%s: Expected width [%d] got [%ld]\n",\
|
||||
msg, (int)width, rTab.right - rTab.left);\
|
||||
else if ((height >= 0) && (width < 0))\
|
||||
ok (height == rTab.bottom - rTab.top, "%s: Expected height [%d] got [%ld]\n",\
|
||||
msg, (int)height, rTab.bottom - rTab.top);\
|
||||
else\
|
||||
ok ((width == rTab.right - rTab.left) &&\
|
||||
(height == rTab.bottom - rTab.top ),\
|
||||
"%s: Expected [%d,%d] got [%ld,%ld]\n", msg, (int)width, (int)height,\
|
||||
rTab.right - rTab.left, rTab.bottom - rTab.top);
|
||||
|
||||
static HFONT hFont = 0;
|
||||
|
||||
static HWND
|
||||
create_tabcontrol (DWORD style)
|
||||
create_tabcontrol (DWORD style, DWORD mask)
|
||||
{
|
||||
HWND handle;
|
||||
TCITEM tcNewTab;
|
||||
static char text1[] = "Tab 1",
|
||||
text2[] = "Wide Tab 2",
|
||||
text3[] = "T 3";
|
||||
|
||||
handle = CreateWindow (
|
||||
WC_TABCONTROLA,
|
||||
|
@ -57,143 +71,179 @@ create_tabcontrol (DWORD style)
|
|||
assert (handle);
|
||||
|
||||
SetWindowLong(handle, GWL_STYLE, WS_CLIPSIBLINGS | WS_CLIPCHILDREN | TCS_FOCUSNEVER | style);
|
||||
SendMessage (handle, WM_SETFONT, 0, (LPARAM) hFont);
|
||||
|
||||
tcNewTab.mask = TCIF_TEXT | TCIF_IMAGE;
|
||||
tcNewTab.pszText = "Tab 1";
|
||||
tcNewTab.mask = mask;
|
||||
tcNewTab.pszText = text1;
|
||||
tcNewTab.iImage = 0;
|
||||
SendMessage (handle, TCM_INSERTITEM, 0, (LPARAM) &tcNewTab);
|
||||
tcNewTab.pszText = "Wide Tab 2";
|
||||
tcNewTab.pszText = text2;
|
||||
tcNewTab.iImage = 1;
|
||||
SendMessage (handle, TCM_INSERTITEM, 1, (LPARAM) &tcNewTab);
|
||||
tcNewTab.pszText = "T 3";
|
||||
tcNewTab.pszText = text3;
|
||||
tcNewTab.iImage = 2;
|
||||
SendMessage (handle, TCM_INSERTITEM, 2, (LPARAM) &tcNewTab);
|
||||
|
||||
#ifdef VISIBLE
|
||||
ShowWindow (handle, SW_SHOW);
|
||||
#endif
|
||||
REDRAW(handle);
|
||||
WAIT;
|
||||
if (winetest_interactive)
|
||||
{
|
||||
ShowWindow (handle, SW_SHOW);
|
||||
RedrawWindow (handle, NULL, 0, RDW_UPDATENOW);
|
||||
Sleep (1000);
|
||||
}
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
static void CheckSize(HWND hwnd, INT width, INT height)
|
||||
static void test_tab(INT nMinTabWidth)
|
||||
{
|
||||
RECT rTab, r1;
|
||||
HWND hwTab;
|
||||
RECT rTab;
|
||||
HIMAGELIST himl = ImageList_Create(21, 21, ILC_COLOR, 3, 4);
|
||||
SIZE size;
|
||||
HDC hdc;
|
||||
HFONT hOldFont;
|
||||
INT i;
|
||||
|
||||
r1.left=r1.top=r1.right=r1.bottom=0;
|
||||
SendMessage (hwnd, TCM_GETITEMRECT, 0, (LPARAM) &rTab);
|
||||
SendMessage (hwnd, TCM_ADJUSTRECT, FALSE, (LPARAM) &r1);
|
||||
/* trace ("Got (%ld,%ld)-(%ld,%ld)\n", rTab.left, rTab.top, rTab.right, rTab.bottom); */
|
||||
trace (" (%ld,%ld)-(%ld,%ld)\n", r1.left, r1.top, r1.right, r1.bottom);
|
||||
if ((width >= 0) && (height < 0))
|
||||
ok (width == rTab.right - rTab.left, "Expected [%d] got [%ld]\n", width, rTab.right - rTab.left);
|
||||
else if ((height >= 0) && (width < 0))
|
||||
ok (height == rTab.bottom - rTab.top, "Expected [%d] got [%ld]\n", height, rTab.bottom - rTab.top);
|
||||
else
|
||||
ok ((width == rTab.right - rTab.left) &&
|
||||
(height == rTab.bottom - rTab.top ),
|
||||
"Expected [%d,%d] got [%ld,%ld]\n", width, height, rTab.right - rTab.left, rTab.bottom - rTab.top);
|
||||
}
|
||||
hwTab = create_tabcontrol(TCS_FIXEDWIDTH, TCIF_TEXT|TCIF_IMAGE);
|
||||
SendMessage(hwTab, TCM_SETMINTABWIDTH, 0, nMinTabWidth);
|
||||
|
||||
static void TabCheckSetSize(HWND hwnd, INT SetWidth, INT SetHeight, INT ExpWidth, INT ExpHeight)
|
||||
{
|
||||
SendMessage (hwnd, TCM_SETITEMSIZE, 0,
|
||||
(LPARAM) MAKELPARAM((SetWidth >= 0) ? SetWidth:0, (SetHeight >= 0) ? SetHeight:0));
|
||||
REDRAW(hwnd);
|
||||
CheckSize(hwnd, ExpWidth, ExpHeight);
|
||||
WAIT;
|
||||
hdc = GetDC(hwTab);
|
||||
hOldFont = SelectObject(hdc, (HFONT)SendMessage(hwTab, WM_GETFONT, 0, 0));
|
||||
GetTextExtentPoint32A(hdc, "Tab 1", strlen("Tab 1"), &size);
|
||||
trace("Tab1 text size: size.cx=%ld size.cy=%ld\n", size.cx, size.cy);
|
||||
SelectObject(hdc, hOldFont);
|
||||
ReleaseDC(hwTab, hdc);
|
||||
|
||||
trace (" TCS_FIXEDWIDTH tabs no icon...\n");
|
||||
CheckSize(hwTab, TAB_DEFAULT_WIDTH, -1, "default width");
|
||||
TabCheckSetSize(hwTab, 50, 20, 50, 20, "set size");
|
||||
TabCheckSetSize(hwTab, 0, 1, 0, 1, "min size");
|
||||
|
||||
SendMessage(hwTab, TCM_SETIMAGELIST, 0, (LPARAM)himl);
|
||||
|
||||
trace (" TCS_FIXEDWIDTH tabs with icon...\n");
|
||||
TabCheckSetSize(hwTab, 50, 30, 50, 30, "set size > icon");
|
||||
TabCheckSetSize(hwTab, 20, 20, 25, 20, "set size < icon");
|
||||
TabCheckSetSize(hwTab, 0, 1, 25, 1, "min size");
|
||||
|
||||
DestroyWindow (hwTab);
|
||||
|
||||
hwTab = create_tabcontrol(TCS_FIXEDWIDTH | TCS_BUTTONS, TCIF_TEXT|TCIF_IMAGE);
|
||||
SendMessage(hwTab, TCM_SETMINTABWIDTH, 0, nMinTabWidth);
|
||||
|
||||
trace (" TCS_FIXEDWIDTH buttons no icon...\n");
|
||||
CheckSize(hwTab, TAB_DEFAULT_WIDTH, -1, "default width");
|
||||
TabCheckSetSize(hwTab, 20, 20, 20, 20, "set size 1");
|
||||
TabCheckSetSize(hwTab, 10, 50, 10, 50, "set size 2");
|
||||
TabCheckSetSize(hwTab, 0, 1, 0, 1, "min size");
|
||||
|
||||
SendMessage(hwTab, TCM_SETIMAGELIST, 0, (LPARAM)himl);
|
||||
|
||||
trace (" TCS_FIXEDWIDTH buttons with icon...\n");
|
||||
TabCheckSetSize(hwTab, 50, 30, 50, 30, "set size > icon");
|
||||
TabCheckSetSize(hwTab, 20, 20, 25, 20, "set size < icon");
|
||||
TabCheckSetSize(hwTab, 0, 1, 25, 1, "min size");
|
||||
SendMessage(hwTab, TCM_SETPADDING, 0, MAKELPARAM(4,4));
|
||||
TabCheckSetSize(hwTab, 0, 1, 25, 1, "set padding, min size");
|
||||
|
||||
DestroyWindow (hwTab);
|
||||
|
||||
hwTab = create_tabcontrol(TCS_FIXEDWIDTH | TCS_BOTTOM, TCIF_TEXT|TCIF_IMAGE);
|
||||
SendMessage(hwTab, TCM_SETMINTABWIDTH, 0, nMinTabWidth);
|
||||
|
||||
trace (" TCS_FIXEDWIDTH | TCS_BOTTOM tabs...\n");
|
||||
CheckSize(hwTab, TAB_DEFAULT_WIDTH, -1, "no icon, default width");
|
||||
|
||||
TabCheckSetSize(hwTab, 20, 20, 20, 20, "no icon, set size 1");
|
||||
TabCheckSetSize(hwTab, 10, 50, 10, 50, "no icon, set size 2");
|
||||
TabCheckSetSize(hwTab, 0, 1, 0, 1, "no icon, min size");
|
||||
|
||||
SendMessage(hwTab, TCM_SETIMAGELIST, 0, (LPARAM)himl);
|
||||
|
||||
TabCheckSetSize(hwTab, 50, 30, 50, 30, "with icon, set size > icon");
|
||||
TabCheckSetSize(hwTab, 20, 20, 25, 20, "with icon, set size < icon");
|
||||
TabCheckSetSize(hwTab, 0, 1, 25, 1, "with icon, min size");
|
||||
SendMessage(hwTab, TCM_SETPADDING, 0, MAKELPARAM(4,4));
|
||||
TabCheckSetSize(hwTab, 0, 1, 25, 1, "set padding, min size");
|
||||
|
||||
DestroyWindow (hwTab);
|
||||
|
||||
hwTab = create_tabcontrol(0, TCIF_TEXT|TCIF_IMAGE);
|
||||
SendMessage(hwTab, TCM_SETMINTABWIDTH, 0, nMinTabWidth);
|
||||
|
||||
trace (" non fixed width, with text...\n");
|
||||
CheckSize(hwTab, max(size.cx +TAB_PADDING_X*2, (nMinTabWidth < 0) ? DEFAULT_MIN_TAB_WIDTH : nMinTabWidth), -1,
|
||||
"no icon, default width");
|
||||
for (i=0; i<8; i++)
|
||||
{
|
||||
INT nTabWidth = (nMinTabWidth < 0) ? TabWidthPadded(i, 2) : nMinTabWidth;
|
||||
|
||||
SendMessage(hwTab, TCM_SETIMAGELIST, 0, 0);
|
||||
SendMessage(hwTab, TCM_SETPADDING, 0, MAKELPARAM(i,i));
|
||||
|
||||
TabCheckSetSize(hwTab, 50, 20, max(size.cx + i*2, nTabWidth), 20, "no icon, set size");
|
||||
TabCheckSetSize(hwTab, 0, 1, max(size.cx + i*2, nTabWidth), 1, "no icon, min size");
|
||||
|
||||
SendMessage(hwTab, TCM_SETIMAGELIST, 0, (LPARAM)himl);
|
||||
nTabWidth = (nMinTabWidth < 0) ? TabWidthPadded(i, 3) : nMinTabWidth;
|
||||
|
||||
TabCheckSetSize(hwTab, 50, 30, max(size.cx + 21 + i*3, nTabWidth), 30, "with icon, set size > icon");
|
||||
TabCheckSetSize(hwTab, 20, 20, max(size.cx + 21 + i*3, nTabWidth), 20, "with icon, set size < icon");
|
||||
TabCheckSetSize(hwTab, 0, 1, max(size.cx + 21 + i*3, nTabWidth), 1, "with icon, min size");
|
||||
}
|
||||
DestroyWindow (hwTab);
|
||||
|
||||
hwTab = create_tabcontrol(0, TCIF_IMAGE);
|
||||
SendMessage(hwTab, TCM_SETMINTABWIDTH, 0, nMinTabWidth);
|
||||
|
||||
trace (" non fixed width, no text...\n");
|
||||
CheckSize(hwTab, (nMinTabWidth < 0) ? DEFAULT_MIN_TAB_WIDTH : nMinTabWidth, -1, "no icon, default width");
|
||||
for (i=0; i<8; i++)
|
||||
{
|
||||
INT nTabWidth = (nMinTabWidth < 0) ? TabWidthPadded(i, 2) : nMinTabWidth;
|
||||
|
||||
SendMessage(hwTab, TCM_SETIMAGELIST, 0, 0);
|
||||
SendMessage(hwTab, TCM_SETPADDING, 0, MAKELPARAM(i,i));
|
||||
|
||||
TabCheckSetSize(hwTab, 50, 20, nTabWidth, 20, "no icon, set size");
|
||||
TabCheckSetSize(hwTab, 0, 1, nTabWidth, 1, "no icon, min size");
|
||||
|
||||
SendMessage(hwTab, TCM_SETIMAGELIST, 0, (LPARAM)himl);
|
||||
if (i > 1 && nMinTabWidth > 0 && nMinTabWidth < DEFAULT_MIN_TAB_WIDTH)
|
||||
nTabWidth += EXTRA_ICON_PADDING *(i-1);
|
||||
|
||||
TabCheckSetSize(hwTab, 50, 30, nTabWidth, 30, "with icon, set size > icon");
|
||||
TabCheckSetSize(hwTab, 20, 20, nTabWidth, 20, "with icon, set size < icon");
|
||||
TabCheckSetSize(hwTab, 0, 1, nTabWidth, 1, "with icon, min size");
|
||||
}
|
||||
|
||||
DestroyWindow (hwTab);
|
||||
|
||||
ImageList_Destroy(himl);
|
||||
DeleteObject(hFont);
|
||||
}
|
||||
|
||||
START_TEST(tab)
|
||||
{
|
||||
HWND hwTab;
|
||||
HIMAGELIST himl = ImageList_Create(21, 21, ILC_COLOR, 3, 4);
|
||||
LOGFONTA logfont;
|
||||
|
||||
lstrcpyA(logfont.lfFaceName, "Arial");
|
||||
memset(&logfont, 0, sizeof(logfont));
|
||||
logfont.lfHeight = -12;
|
||||
logfont.lfWeight = FW_NORMAL;
|
||||
logfont.lfCharSet = ANSI_CHARSET;
|
||||
hFont = CreateFontIndirectA(&logfont);
|
||||
|
||||
InitCommonControls();
|
||||
|
||||
|
||||
hwTab = create_tabcontrol(TCS_FIXEDWIDTH);
|
||||
|
||||
trace_tab ("Testing TCS_FIXEDWIDTH tabs no icon...\n");
|
||||
trace_tab (" default width...\n");
|
||||
CheckSize(hwTab, TAB_DEFAULT_WIDTH, -1);
|
||||
trace_tab (" set size...\n");
|
||||
TabCheckSetSize(hwTab, 50, 20, 50, 20);
|
||||
WAIT;
|
||||
trace_tab (" min size...\n");
|
||||
TabCheckSetSize(hwTab, 0, 1, 0, 1);
|
||||
WAIT;
|
||||
|
||||
SendMessage(hwTab, TCM_SETIMAGELIST, 0, (LPARAM)himl);
|
||||
|
||||
trace_tab ("Testing TCS_FIXEDWIDTH tabs with icon...\n");
|
||||
trace_tab (" set size > icon...\n");
|
||||
TabCheckSetSize(hwTab, 50, 30, 50, 30);
|
||||
trace_tab (" set size < icon...\n");
|
||||
TabCheckSetSize(hwTab, 20, 20, 25, 20);
|
||||
trace_tab (" min size...\n");
|
||||
TabCheckSetSize(hwTab, 0, 1, 25, 1);
|
||||
|
||||
DestroyWindow (hwTab);
|
||||
|
||||
trace_tab ("Testing TCS_FIXEDWIDTH buttons no icon...\n");
|
||||
hwTab = create_tabcontrol(TCS_FIXEDWIDTH | TCS_BUTTONS);
|
||||
|
||||
trace_tab (" default width...\n");
|
||||
CheckSize(hwTab, TAB_DEFAULT_WIDTH, -1);
|
||||
trace_tab (" set size 1...\n");
|
||||
TabCheckSetSize(hwTab, 20, 20, 20, 20);
|
||||
trace_tab (" set size 2...\n");
|
||||
TabCheckSetSize(hwTab, 10, 50, 10, 50);
|
||||
trace_tab (" min size...\n");
|
||||
TabCheckSetSize(hwTab, 0, 1, 0, 1);
|
||||
|
||||
SendMessage(hwTab, TCM_SETIMAGELIST, 0, (LPARAM)himl);
|
||||
|
||||
trace_tab ("Testing TCS_FIXEDWIDTH buttons with icon...\n");
|
||||
trace_tab (" set size > icon...\n");
|
||||
TabCheckSetSize(hwTab, 50, 30, 50, 30);
|
||||
trace_tab (" set size < icon...\n");
|
||||
TabCheckSetSize(hwTab, 20, 20, 25, 20);
|
||||
trace_tab (" min size...\n");
|
||||
TabCheckSetSize(hwTab, 0, 1, 25, 1);
|
||||
trace_tab (" Add padding...\n");
|
||||
SendMessage(hwTab, TCM_SETPADDING, 0, MAKELPARAM(4,4));
|
||||
trace_tab (" min size...\n");
|
||||
TabCheckSetSize(hwTab, 0, 1, 25, 1);
|
||||
|
||||
DestroyWindow (hwTab);
|
||||
|
||||
hwTab = create_tabcontrol(TCS_FIXEDWIDTH | TCS_BOTTOM);
|
||||
trace_tab ("Testing TCS_FIXEDWIDTH | TCS_BOTTOM tabs no icon...\n");
|
||||
|
||||
trace_tab (" default width...\n");
|
||||
CheckSize(hwTab, TAB_DEFAULT_WIDTH, -1);
|
||||
trace_tab (" set size 1...\n");
|
||||
TabCheckSetSize(hwTab, 20, 20, 20, 20);
|
||||
trace_tab (" set size 2...\n");
|
||||
TabCheckSetSize(hwTab, 10, 50, 10, 50);
|
||||
trace_tab (" min size...\n");
|
||||
TabCheckSetSize(hwTab, 0, 1, 0, 1);
|
||||
|
||||
SendMessage(hwTab, TCM_SETIMAGELIST, 0, (LPARAM)himl);
|
||||
|
||||
trace_tab ("Testing TCS_FIXEDWIDTH | TCS_BOTTOM tabs with icon...\n");
|
||||
trace_tab (" set size > icon...\n");
|
||||
TabCheckSetSize(hwTab, 50, 30, 50, 30);
|
||||
trace_tab (" set size < icon...\n");
|
||||
TabCheckSetSize(hwTab, 20, 20, 25, 20);
|
||||
trace_tab (" min size...\n");
|
||||
TabCheckSetSize(hwTab, 0, 1, 25, 1);
|
||||
trace_tab (" Add padding...\n");
|
||||
SendMessage(hwTab, TCM_SETPADDING, 0, MAKELPARAM(4,4));
|
||||
trace_tab (" min size...\n");
|
||||
TabCheckSetSize(hwTab, 0, 1, 25, 1);
|
||||
|
||||
DestroyWindow (hwTab);
|
||||
|
||||
|
||||
ImageList_Destroy(himl);
|
||||
trace ("Testing with default MinWidth\n");
|
||||
test_tab(-1);
|
||||
trace ("Testing with MinWidth set to -3\n");
|
||||
test_tab(-3);
|
||||
trace ("Testing with MinWidth set to 24\n");
|
||||
test_tab(24);
|
||||
trace ("Testing with MinWidth set to 54\n");
|
||||
test_tab(54);
|
||||
trace ("Testing with MinWidth set to 94\n");
|
||||
test_tab(94);
|
||||
}
|
||||
|
|
137
reactos/regtests/winetests/comctl32/toolbar.c
Normal file
137
reactos/regtests/winetests/comctl32/toolbar.c
Normal file
|
@ -0,0 +1,137 @@
|
|||
/* Unit tests for treeview.
|
||||
*
|
||||
* Copyright 2005 Krzysztof Foltman
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "wingdi.h"
|
||||
#include "winuser.h"
|
||||
#include "winnls.h"
|
||||
#include "winreg.h"
|
||||
#include "commctrl.h"
|
||||
|
||||
#include "wine/test.h"
|
||||
|
||||
static void MakeButton(TBBUTTON *p, int idCommand, int fsStyle, int nString) {
|
||||
p->iBitmap = -2;
|
||||
p->idCommand = idCommand;
|
||||
p->fsState = TBSTATE_ENABLED;
|
||||
p->fsStyle = fsStyle;
|
||||
p->iString = nString;
|
||||
}
|
||||
|
||||
static LRESULT CALLBACK MyWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch(msg) {
|
||||
|
||||
case WM_CREATE:
|
||||
{
|
||||
TBBUTTON buttons[9];
|
||||
int i;
|
||||
HWND hToolbar;
|
||||
for (i=0; i<9; i++)
|
||||
MakeButton(buttons+i, 1000+i, TBSTYLE_CHECKGROUP, 0);
|
||||
MakeButton(buttons+3, 1003, TBSTYLE_SEP|TBSTYLE_GROUP, 0);
|
||||
MakeButton(buttons+6, 1006, TBSTYLE_SEP, 0);
|
||||
|
||||
hToolbar = CreateToolbarEx(hWnd,
|
||||
WS_VISIBLE | WS_CLIPCHILDREN | CCS_TOP |
|
||||
WS_CHILD | TBSTYLE_LIST,
|
||||
100,
|
||||
0, NULL, (UINT)0,
|
||||
buttons, sizeof(buttons)/sizeof(buttons[0]),
|
||||
0, 0, 20, 16, sizeof(TBBUTTON));
|
||||
ok(hToolbar != NULL, "Toolbar creation\n");
|
||||
|
||||
SendMessage(hToolbar, TB_ADDSTRINGA, 0, (LPARAM)"test\000");
|
||||
|
||||
/* test for exclusion working inside a separator-separated :-) group */
|
||||
SendMessage(hToolbar, TB_CHECKBUTTON, 1000, 1); /* press A1 */
|
||||
ok(SendMessage(hToolbar, TB_ISBUTTONCHECKED, 1000, 0), "A1 pressed\n");
|
||||
ok(!SendMessage(hToolbar, TB_ISBUTTONCHECKED, 1001, 0), "A2 not pressed\n");
|
||||
|
||||
SendMessage(hToolbar, TB_CHECKBUTTON, 1004, 1); /* press A5, release A1 */
|
||||
ok(SendMessage(hToolbar, TB_ISBUTTONCHECKED, 1004, 0), "A5 pressed\n");
|
||||
ok(!SendMessage(hToolbar, TB_ISBUTTONCHECKED, 1000, 0), "A1 not pressed anymore\n");
|
||||
|
||||
SendMessage(hToolbar, TB_CHECKBUTTON, 1005, 1); /* press A6, release A5 */
|
||||
ok(SendMessage(hToolbar, TB_ISBUTTONCHECKED, 1005, 0), "A6 pressed\n");
|
||||
ok(!SendMessage(hToolbar, TB_ISBUTTONCHECKED, 1004, 0), "A5 not pressed anymore\n");
|
||||
|
||||
/* test for inter-group crosstalk, ie. two radio groups interfering with each other */
|
||||
SendMessage(hToolbar, TB_CHECKBUTTON, 1007, 1); /* press B2 */
|
||||
ok(SendMessage(hToolbar, TB_ISBUTTONCHECKED, 1005, 0), "A6 still pressed, no inter-group crosstalk\n");
|
||||
ok(!SendMessage(hToolbar, TB_ISBUTTONCHECKED, 1000, 0), "A1 still not pressed\n");
|
||||
ok(SendMessage(hToolbar, TB_ISBUTTONCHECKED, 1007, 0), "B2 pressed\n");
|
||||
|
||||
SendMessage(hToolbar, TB_CHECKBUTTON, 1000, 1); /* press A1 and ensure B group didn't suffer */
|
||||
ok(!SendMessage(hToolbar, TB_ISBUTTONCHECKED, 1005, 0), "A6 not pressed anymore\n");
|
||||
ok(SendMessage(hToolbar, TB_ISBUTTONCHECKED, 1000, 0), "A1 pressed\n");
|
||||
ok(SendMessage(hToolbar, TB_ISBUTTONCHECKED, 1007, 0), "B2 still pressed\n");
|
||||
|
||||
SendMessage(hToolbar, TB_CHECKBUTTON, 1008, 1); /* press B3, and ensure A group didn't suffer */
|
||||
ok(!SendMessage(hToolbar, TB_ISBUTTONCHECKED, 1005, 0), "A6 pressed\n");
|
||||
ok(SendMessage(hToolbar, TB_ISBUTTONCHECKED, 1000, 0), "A1 pressed\n");
|
||||
ok(!SendMessage(hToolbar, TB_ISBUTTONCHECKED, 1007, 0), "B2 not pressed\n");
|
||||
ok(SendMessage(hToolbar, TB_ISBUTTONCHECKED, 1008, 0), "B3 pressed\n");
|
||||
PostMessage(hWnd, WM_CLOSE, 0, 0);
|
||||
return 0;
|
||||
}
|
||||
case WM_DESTROY:
|
||||
PostQuitMessage(0);
|
||||
break;
|
||||
|
||||
default:
|
||||
return DefWindowProcA(hWnd, msg, wParam, lParam);
|
||||
}
|
||||
return 0L;
|
||||
}
|
||||
|
||||
START_TEST(toolbar)
|
||||
{
|
||||
WNDCLASSA wc;
|
||||
MSG msg;
|
||||
RECT rc;
|
||||
HWND hMainWnd;
|
||||
|
||||
InitCommonControls();
|
||||
|
||||
wc.style = CS_HREDRAW | CS_VREDRAW;
|
||||
wc.cbClsExtra = 0;
|
||||
wc.cbWndExtra = 0;
|
||||
wc.hInstance = GetModuleHandleA(NULL);
|
||||
wc.hIcon = NULL;
|
||||
wc.hCursor = LoadCursorA(NULL, MAKEINTRESOURCEA(IDC_IBEAM));
|
||||
wc.hbrBackground = GetSysColorBrush(COLOR_WINDOW);
|
||||
wc.lpszMenuName = NULL;
|
||||
wc.lpszClassName = "MyTestWnd";
|
||||
wc.lpfnWndProc = MyWndProc;
|
||||
RegisterClassA(&wc);
|
||||
|
||||
hMainWnd = CreateWindowExA(0, "MyTestWnd", "Blah", WS_OVERLAPPEDWINDOW,
|
||||
CW_USEDEFAULT, CW_USEDEFAULT, 680, 260, NULL, NULL, GetModuleHandleA(NULL), 0);
|
||||
GetClientRect(hMainWnd, &rc);
|
||||
|
||||
while(GetMessageA(&msg,0,0,0)) {
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessageA(&msg);
|
||||
}
|
||||
}
|
68
reactos/regtests/winetests/comctl32/tooltips.c
Normal file
68
reactos/regtests/winetests/comctl32/tooltips.c
Normal file
|
@ -0,0 +1,68 @@
|
|||
/*
|
||||
* Copyright 2005 Dmitry Timoshkov
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <windows.h>
|
||||
#include <commctrl.h>
|
||||
|
||||
#include "wine/test.h"
|
||||
|
||||
static void test_create_tooltip(void)
|
||||
{
|
||||
HWND parent, hwnd;
|
||||
DWORD style, exp_style;
|
||||
|
||||
parent = CreateWindowEx(0, "static", NULL, WS_POPUP,
|
||||
0, 0, 0, 0,
|
||||
NULL, NULL, NULL, 0);
|
||||
assert(parent);
|
||||
|
||||
hwnd = CreateWindowEx(0, TOOLTIPS_CLASS, NULL, 0x7fffffff | WS_POPUP,
|
||||
10, 10, 300, 100,
|
||||
parent, NULL, NULL, 0);
|
||||
assert(hwnd);
|
||||
|
||||
style = GetWindowLong(hwnd, GWL_STYLE);
|
||||
trace("style = %08lx\n", style);
|
||||
exp_style = 0x7fffffff | WS_POPUP;
|
||||
exp_style &= ~(WS_CHILD | WS_MAXIMIZE | WS_BORDER | WS_DLGFRAME);
|
||||
ok(style == exp_style,"wrong style %08lx/%08lx\n", style, exp_style);
|
||||
|
||||
DestroyWindow(hwnd);
|
||||
|
||||
hwnd = CreateWindowEx(0, TOOLTIPS_CLASS, NULL, 0,
|
||||
10, 10, 300, 100,
|
||||
parent, NULL, NULL, 0);
|
||||
assert(hwnd);
|
||||
|
||||
style = GetWindowLong(hwnd, GWL_STYLE);
|
||||
trace("style = %08lx\n", style);
|
||||
ok(style == (WS_POPUP | WS_CLIPSIBLINGS | WS_BORDER),
|
||||
"wrong style %08lx\n", style);
|
||||
|
||||
DestroyWindow(hwnd);
|
||||
|
||||
DestroyWindow(parent);
|
||||
}
|
||||
|
||||
START_TEST(tooltips)
|
||||
{
|
||||
InitCommonControls();
|
||||
|
||||
test_create_tooltip();
|
||||
}
|
221
reactos/regtests/winetests/comctl32/treeview.c
Normal file
221
reactos/regtests/winetests/comctl32/treeview.c
Normal file
|
@ -0,0 +1,221 @@
|
|||
/* Unit tests for treeview.
|
||||
*
|
||||
* Copyright 2005 Krzysztof Foltman
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "wingdi.h"
|
||||
#include "winuser.h"
|
||||
#include "winnls.h"
|
||||
#include "winreg.h"
|
||||
#include "commctrl.h"
|
||||
|
||||
#include "wine/test.h"
|
||||
|
||||
static HWND hMainWnd;
|
||||
|
||||
static HWND hTree;
|
||||
static HTREEITEM hRoot, hChild;
|
||||
|
||||
static int pos = 0;
|
||||
static char sequence[256];
|
||||
|
||||
static void Clear(void)
|
||||
{
|
||||
pos = 0;
|
||||
sequence[0] = '\0';
|
||||
}
|
||||
|
||||
static void AddItem(char ch)
|
||||
{
|
||||
sequence[pos++] = ch;
|
||||
sequence[pos] = '\0';
|
||||
}
|
||||
|
||||
static void IdentifyItem(HTREEITEM hItem)
|
||||
{
|
||||
if (hItem == hRoot) {
|
||||
AddItem('R');
|
||||
return;
|
||||
}
|
||||
if (hItem == hChild) {
|
||||
AddItem('C');
|
||||
return;
|
||||
}
|
||||
if (hItem == NULL) {
|
||||
AddItem('n');
|
||||
return;
|
||||
}
|
||||
AddItem('?');
|
||||
}
|
||||
|
||||
static void FillRoot(void)
|
||||
{
|
||||
TVINSERTSTRUCTA ins;
|
||||
static CHAR root[] = "Root",
|
||||
child[] = "Child";
|
||||
|
||||
Clear();
|
||||
AddItem('A');
|
||||
ins.hParent = TVI_ROOT;
|
||||
ins.hInsertAfter = TVI_ROOT;
|
||||
U(ins).item.mask = TVIF_TEXT;
|
||||
U(ins).item.pszText = root;
|
||||
hRoot = TreeView_InsertItem(hTree, &ins);
|
||||
assert(hRoot);
|
||||
|
||||
AddItem('B');
|
||||
ins.hParent = hRoot;
|
||||
ins.hInsertAfter = TVI_FIRST;
|
||||
U(ins).item.mask = TVIF_TEXT;
|
||||
U(ins).item.pszText = child;
|
||||
hChild = TreeView_InsertItem(hTree, &ins);
|
||||
assert(hChild);
|
||||
AddItem('.');
|
||||
|
||||
ok(!strcmp(sequence, "AB."), "Item creation\n");
|
||||
}
|
||||
|
||||
static void DoTest1(void)
|
||||
{
|
||||
BOOL r;
|
||||
r = TreeView_SelectItem(hTree, NULL);
|
||||
Clear();
|
||||
AddItem('1');
|
||||
r = TreeView_SelectItem(hTree, hRoot);
|
||||
AddItem('2');
|
||||
r = TreeView_SelectItem(hTree, hRoot);
|
||||
AddItem('3');
|
||||
r = TreeView_SelectItem(hTree, NULL);
|
||||
AddItem('4');
|
||||
r = TreeView_SelectItem(hTree, NULL);
|
||||
AddItem('5');
|
||||
r = TreeView_SelectItem(hTree, hRoot);
|
||||
AddItem('.');
|
||||
ok(!strcmp(sequence, "1(nR)nR23(Rn)Rn45(nR)nR."), "root-none select test\n");
|
||||
}
|
||||
|
||||
static void DoTest2(void)
|
||||
{
|
||||
BOOL r;
|
||||
r = TreeView_SelectItem(hTree, NULL);
|
||||
Clear();
|
||||
AddItem('1');
|
||||
r = TreeView_SelectItem(hTree, hRoot);
|
||||
AddItem('2');
|
||||
r = TreeView_SelectItem(hTree, hRoot);
|
||||
AddItem('3');
|
||||
r = TreeView_SelectItem(hTree, hChild);
|
||||
AddItem('4');
|
||||
r = TreeView_SelectItem(hTree, hChild);
|
||||
AddItem('5');
|
||||
r = TreeView_SelectItem(hTree, hRoot);
|
||||
AddItem('.');
|
||||
ok(!strcmp(sequence, "1(nR)nR23(RC)RC45(CR)CR."), "root-child select test\n");
|
||||
}
|
||||
|
||||
LRESULT CALLBACK MyWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch(msg) {
|
||||
|
||||
case WM_CREATE:
|
||||
{
|
||||
hTree = CreateWindowExA(WS_EX_CLIENTEDGE, WC_TREEVIEWA, NULL, WS_CHILD|WS_VISIBLE|
|
||||
TVS_LINESATROOT|TVS_HASLINES|TVS_HASBUTTONS,
|
||||
0, 0, 300, 50, hWnd, (HMENU)100, GetModuleHandleA(0), 0);
|
||||
|
||||
SetFocus(hTree);
|
||||
return 0;
|
||||
}
|
||||
case WM_NOTIFY:
|
||||
{
|
||||
NMHDR *pHdr = (NMHDR *)lParam;
|
||||
|
||||
if (pHdr->idFrom == 100) {
|
||||
NMTREEVIEWA *pTreeView = (LPNMTREEVIEWA) lParam;
|
||||
switch(pHdr->code) {
|
||||
case TVN_SELCHANGINGA:
|
||||
AddItem('(');
|
||||
IdentifyItem(pTreeView->itemOld.hItem);
|
||||
IdentifyItem(pTreeView->itemNew.hItem);
|
||||
return 0;
|
||||
case TVN_SELCHANGEDA:
|
||||
AddItem(')');
|
||||
IdentifyItem(pTreeView->itemOld.hItem);
|
||||
IdentifyItem(pTreeView->itemNew.hItem);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
case WM_SIZE:
|
||||
MoveWindow(hTree, 0, 0, LOWORD(lParam), HIWORD(lParam), TRUE);
|
||||
break;
|
||||
|
||||
case WM_DESTROY:
|
||||
PostQuitMessage(0);
|
||||
break;
|
||||
|
||||
default:
|
||||
return DefWindowProcA(hWnd, msg, wParam, lParam);
|
||||
}
|
||||
return 0L;
|
||||
}
|
||||
|
||||
START_TEST(treeview)
|
||||
{
|
||||
WNDCLASSA wc;
|
||||
MSG msg;
|
||||
INITCOMMONCONTROLSEX icex;
|
||||
RECT rc;
|
||||
|
||||
icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
|
||||
icex.dwICC = ICC_TREEVIEW_CLASSES;
|
||||
InitCommonControlsEx(&icex);
|
||||
|
||||
wc.style = CS_HREDRAW | CS_VREDRAW;
|
||||
wc.cbClsExtra = 0;
|
||||
wc.cbWndExtra = 0;
|
||||
wc.hInstance = GetModuleHandleA(NULL);
|
||||
wc.hIcon = NULL;
|
||||
wc.hCursor = LoadCursorA(NULL, MAKEINTRESOURCEA(IDC_IBEAM));
|
||||
wc.hbrBackground = GetSysColorBrush(COLOR_WINDOW);
|
||||
wc.lpszMenuName = NULL;
|
||||
wc.lpszClassName = "MyTestWnd";
|
||||
wc.lpfnWndProc = MyWndProc;
|
||||
RegisterClassA(&wc);
|
||||
|
||||
|
||||
hMainWnd = CreateWindowExA(0, "MyTestWnd", "Blah", WS_OVERLAPPEDWINDOW,
|
||||
CW_USEDEFAULT, CW_USEDEFAULT, 680, 260, NULL, NULL, GetModuleHandleA(NULL), 0);
|
||||
GetClientRect(hMainWnd, &rc);
|
||||
|
||||
FillRoot();
|
||||
DoTest1();
|
||||
DoTest2();
|
||||
|
||||
PostMessageA(hMainWnd, WM_CLOSE, 0, 0);
|
||||
while(GetMessageA(&msg,0,0,0)) {
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessageA(&msg);
|
||||
}
|
||||
}
|
98
reactos/regtests/winetests/comctl32/updown.c
Normal file
98
reactos/regtests/winetests/comctl32/updown.c
Normal file
|
@ -0,0 +1,98 @@
|
|||
/* Unit test suite for updown control.
|
||||
*
|
||||
* Copyright 2005 C. Scott Ananian
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <windows.h>
|
||||
#include <commctrl.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "wine/test.h"
|
||||
|
||||
static HDC desktopDC;
|
||||
static HINSTANCE hinst;
|
||||
|
||||
static HWND create_edit_control (DWORD style, DWORD exstyle)
|
||||
{
|
||||
HWND handle;
|
||||
|
||||
handle = CreateWindowEx(exstyle,
|
||||
"EDIT",
|
||||
NULL,
|
||||
ES_AUTOHSCROLL | ES_AUTOVSCROLL | style,
|
||||
10, 10, 300, 300,
|
||||
NULL, NULL, hinst, NULL);
|
||||
assert (handle);
|
||||
if (winetest_interactive)
|
||||
ShowWindow (handle, SW_SHOW);
|
||||
return handle;
|
||||
}
|
||||
|
||||
static HWND create_updown_control (HWND hWndEdit)
|
||||
{
|
||||
HWND hWndUpDown;
|
||||
|
||||
/* make the control */
|
||||
hWndUpDown = CreateWindowEx
|
||||
(0L, UPDOWN_CLASS, NULL,
|
||||
/* window styles */
|
||||
UDS_SETBUDDYINT | UDS_ALIGNRIGHT |
|
||||
UDS_ARROWKEYS | UDS_NOTHOUSANDS,
|
||||
/* placement */
|
||||
0, 0, 8, 8,
|
||||
/* parent, etc */
|
||||
NULL, NULL, hinst, NULL);
|
||||
assert (hWndUpDown);
|
||||
/* set the buddy. */
|
||||
SendMessage (hWndUpDown, UDM_SETBUDDY, (WPARAM)hWndEdit, 0L );
|
||||
/* set the range. */
|
||||
SendMessage (hWndUpDown, UDM_SETRANGE, 0L, (LPARAM) MAKELONG(32000, 0));
|
||||
/* maybe show it. */
|
||||
if (winetest_interactive)
|
||||
ShowWindow (hWndUpDown, SW_SHOW);
|
||||
return hWndUpDown;
|
||||
}
|
||||
|
||||
static void test_updown_control (void)
|
||||
{
|
||||
HWND hWndUpDown, hWndEdit;
|
||||
int num;
|
||||
|
||||
hWndEdit = create_edit_control (ES_AUTOHSCROLL | ES_NUMBER, 0);
|
||||
hWndUpDown = create_updown_control (hWndEdit);
|
||||
/* before we set a value, it should be '0' */
|
||||
num = SendMessage(hWndUpDown, UDM_GETPOS, 0, 0L);
|
||||
ok(num == 0, "Expected 0 got %d\n", num);
|
||||
/* set a value, check it. */
|
||||
SendMessage(hWndUpDown, UDM_SETPOS, 0L, MAKELONG( 1, 0));
|
||||
num = SendMessage(hWndUpDown, UDM_GETPOS, 0, 0L);
|
||||
ok(num == 1, "Expected 1 got %d\n", num);
|
||||
/* okay, done (short set of tests!) */
|
||||
DestroyWindow(hWndUpDown);
|
||||
DestroyWindow(hWndEdit);
|
||||
}
|
||||
|
||||
START_TEST(updown)
|
||||
{
|
||||
desktopDC=GetDC(NULL);
|
||||
hinst = GetModuleHandleA(NULL);
|
||||
|
||||
InitCommonControls();
|
||||
|
||||
test_updown_control();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue