[WINESYNC]

- Sync comdlg32, crypt32, gdiplus, inetcomm, jscript, msctf, mshtml, msxml3, rsaenh, schannel, shlwapi, urlmon, usp10, wininet winetests.

svn path=/trunk/; revision=46982
This commit is contained in:
Aleksey Bragin 2010-04-21 20:35:09 +00:00
parent e20b4df9ef
commit 577625f6f8
41 changed files with 7905 additions and 1238 deletions

View file

@ -5,11 +5,13 @@
<include base="comdlg32_winetest">.</include>
<define name="__ROS_LONG64__" />
<file>filedlg.c</file>
<file>fontdlg.c</file>
<file>printdlg.c</file>
<file>testlist.c</file>
<file>rsrc.rc</file>
<library>wine</library>
<library>comdlg32</library>
<library>winspool</library>
<library>user32</library>
<library>gdi32</library>
<library>ntdll</library>

View file

@ -29,6 +29,32 @@
/* ##### */
static int resizesupported = TRUE;
static void toolbarcheck( HWND hDlg)
{
/* test toolbar properties */
/* bug #10532 */
int maxtextrows;
HWND ctrl;
DWORD ret;
char classname[20];
for( ctrl = GetWindow( hDlg, GW_CHILD);
ctrl ; ctrl = GetWindow( ctrl, GW_HWNDNEXT)) {
GetClassName( ctrl, classname, 10);
classname[7] = '\0';
if( !strcmp( classname, "Toolbar")) break;
}
ok( ctrl != NULL, "could not get the toolbar control\n");
ret = SendMessage( ctrl, TB_ADDSTRING, 0, (LPARAM)"winetestwinetest\0\0");
ok( ret == 0, "addstring returned %d (expected 0)\n", ret);
maxtextrows = SendMessage( ctrl, TB_GETTEXTROWS, 0, 0);
ok( maxtextrows == 0 || broken(maxtextrows == 1), /* Win2k and below */
"Get(Max)TextRows returned %d (expected 0)\n", maxtextrows);
}
static UINT_PTR CALLBACK OFNHookProc( HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
LPNMHDR nmh;
@ -49,6 +75,7 @@ static UINT_PTR CALLBACK OFNHookProc( HWND hDlg, UINT msg, WPARAM wParam, LPARAM
ok(ret > 0, "CMD_GETFOLDERIDLIST not implemented\n");
if (ret > 5)
ok(buf[0] == 0x66 && buf[1] == 0x66, "CMD_GETFOLDERIDLIST: The buffer was touched on failure\n");
toolbarcheck( GetParent(hDlg));
}
}
@ -78,26 +105,26 @@ static void test_DialogCancel(void)
ofn.lpstrInitialDir = szInitialDir;
PrintDlgA(NULL);
ok(CDERR_INITIALIZATION == CommDlgExtendedError(), "expected %d, got %d\n",
CDERR_INITIALIZATION, CommDlgExtendedError());
ok(CDERR_INITIALIZATION == CommDlgExtendedError(),
"expected CDERR_INITIALIZATION, got %d\n", CommDlgExtendedError());
result = GetOpenFileNameA(&ofn);
ok(0 == result, "expected %d, got %d\n", 0, result);
ok(0 == CommDlgExtendedError(), "expected %d, got %d\n", 0,
ok(0 == result, "expected 0, got %d\n", result);
ok(0 == CommDlgExtendedError(), "expected 0, got %d\n",
CommDlgExtendedError());
PrintDlgA(NULL);
ok(CDERR_INITIALIZATION == CommDlgExtendedError(), "expected %d, got %d\n",
CDERR_INITIALIZATION, CommDlgExtendedError());
ok(CDERR_INITIALIZATION == CommDlgExtendedError(),
"expected CDERR_INITIALIZATION, got %d\n", CommDlgExtendedError());
result = GetSaveFileNameA(&ofn);
ok(0 == result, "expected %d, got %d\n", 0, result);
ok(0 == CommDlgExtendedError(), "expected %d, got %d\n", 0,
ok(0 == result, "expected 0, got %d\n", result);
ok(0 == CommDlgExtendedError(), "expected 0, got %d\n",
CommDlgExtendedError());
PrintDlgA(NULL);
ok(CDERR_INITIALIZATION == CommDlgExtendedError(), "expected %d, got %d\n",
CDERR_INITIALIZATION, CommDlgExtendedError());
ok(CDERR_INITIALIZATION == CommDlgExtendedError(),
"expected CDERR_INITIALIZATION, got %d\n", CommDlgExtendedError());
/* Before passing the ofn to Unicode functions, remove the ANSI strings */
ofn.lpstrFilter = NULL;
@ -105,8 +132,8 @@ static void test_DialogCancel(void)
ofn.lpstrDefExt = NULL;
PrintDlgA(NULL);
ok(CDERR_INITIALIZATION == CommDlgExtendedError(), "expected %d, got %d\n",
CDERR_INITIALIZATION, CommDlgExtendedError());
ok(CDERR_INITIALIZATION == CommDlgExtendedError(),
"expected CDERR_INITIALIZATION, got %d\n", CommDlgExtendedError());
SetLastError(0xdeadbeef);
result = GetOpenFileNameW((LPOPENFILENAMEW) &ofn);
@ -114,11 +141,10 @@ static void test_DialogCancel(void)
win_skip("GetOpenFileNameW is not implemented\n");
else
{
ok(0 == result, "expected %d, got %d\n", 0, result);
ok(0 == result, "expected 0, got %d\n", result);
ok(0 == CommDlgExtendedError() ||
CDERR_INITIALIZATION == CommDlgExtendedError(), /* win9x */
"expected %d or %d, got %d\n", 0, CDERR_INITIALIZATION,
CommDlgExtendedError());
broken(CDERR_INITIALIZATION == CommDlgExtendedError()), /* win9x */
"expected 0, got %d\n", CommDlgExtendedError());
}
SetLastError(0xdeadbeef);
@ -127,11 +153,10 @@ static void test_DialogCancel(void)
win_skip("GetSaveFileNameW is not implemented\n");
else
{
ok(0 == result, "expected %d, got %d\n", 0, result);
ok(0 == result, "expected 0, got %d\n", result);
ok(0 == CommDlgExtendedError() ||
CDERR_INITIALIZATION == CommDlgExtendedError(), /* win9x */
"expected %d or %d, got %d\n", 0, CDERR_INITIALIZATION,
CommDlgExtendedError());
broken(CDERR_INITIALIZATION == CommDlgExtendedError()), /* win9x */
"expected 0, got %d\n", CommDlgExtendedError());
}
}
@ -177,12 +202,19 @@ static UINT_PTR CALLBACK create_view_window2_hook(HWND dlg, UINT msg, WPARAM wPa
view_params.hwndView = NULL;
hr = IShellView2_CreateViewWindow2(shell_view2, &view_params);
if (hr == E_FAIL)
{
win_skip("CreateViewWindow2 is broken on Vista/W2K8\n");
goto cleanup;
}
ok(SUCCEEDED(hr), "CreateViewWindow2 returned %#x\n", hr);
if (FAILED(hr)) goto cleanup;
hr = IShellView2_GetCurrentInfo(shell_view2, &folder_settings);
ok(SUCCEEDED(hr), "GetCurrentInfo returned %#x\n", hr);
ok(folder_settings.ViewMode == FVM_LIST, "view mode is %d, expected %d\n", folder_settings.ViewMode, FVM_LIST);
ok(folder_settings.ViewMode == FVM_LIST,
"view mode is %d, expected FVM_LIST\n",
folder_settings.ViewMode);
hr = IShellView2_DestroyViewWindow(shell_view2);
ok(SUCCEEDED(hr), "DestroyViewWindow returned %#x\n", hr);
@ -201,7 +233,8 @@ static UINT_PTR CALLBACK create_view_window2_hook(HWND dlg, UINT msg, WPARAM wPa
ok(SUCCEEDED(hr), "GetCurrentInfo returned %#x\n", hr);
ok(folder_settings.ViewMode == FVM_DETAILS ||
broken(folder_settings.ViewMode == FVM_LIST), /* Win9x */
"view mode is %d, expected %d\n", folder_settings.ViewMode, FVM_DETAILS);
"view mode is %d, expected FVM_DETAILS\n",
folder_settings.ViewMode);
cleanup:
if (shell_view2) IShellView2_Release(shell_view2);
@ -241,7 +274,7 @@ static void test_create_view_window2(void)
ofn.lStructSize = sizeof(ofn);
ofn.lpstrFile = filename;
ofn.nMaxFile = 1042;
ofn.nMaxFile = 1024;
ofn.lpfnHook = create_view_window2_hook;
ofn.Flags = OFN_ENABLEHOOK | OFN_EXPLORER;
ret = GetOpenFileNameA(&ofn);
@ -258,7 +291,7 @@ static void test_create_view_template(void)
ofn.lStructSize = sizeof(ofn);
ofn.lpstrFile = filename;
ofn.nMaxFile = 1042;
ofn.nMaxFile = 1024;
ofn.lpfnHook = (LPOFNHOOKPROC)template_hook;
ofn.Flags = OFN_ENABLEHOOK | OFN_EXPLORER| OFN_ENABLETEMPLATE;
ofn.hInstance = GetModuleHandleA(NULL);
@ -270,9 +303,694 @@ static void test_create_view_template(void)
ok(!ret, "CommDlgExtendedError returned %#x\n", ret);
}
/* test cases for resizing of the file dialog */
struct {
DWORD flags;
int resize_folderchange;/* change in CDN_FOLDERCHANGE handler */
int resize_timer1; /* change in first WM_TIMER handler */
int resize_check; /* expected change (in second WM_TIMER handler) */
BOOL todo; /* mark that test todo_wine */
BOOL testcontrols; /* test resizing and moving of the controls */
} resize_testcases[] = {
{ 0 , 10, 10, 20,FALSE,FALSE}, /* 0 */
{ 0 ,-10,-10,-20,FALSE,FALSE},
{ OFN_ENABLESIZING , 0, 0, 0,FALSE,FALSE},
{ OFN_ENABLESIZING , 0,-10, 0,FALSE,FALSE},
{ OFN_ENABLESIZING , 0, 10, 10,FALSE, TRUE},
{ OFN_ENABLESIZING ,-10, 0, 10,FALSE,FALSE}, /* 5 */
{ OFN_ENABLESIZING , 10, 0, 10,FALSE,FALSE},
{ OFN_ENABLESIZING , 0, 10, 20,FALSE,FALSE},
/* mark the end */
{ 0xffffffff }
};
static LONG_PTR WINAPI resize_template_hook(HWND dlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
static RECT initrc, rc;
static int index, count;
static int gotSWP_bottom, gotShowWindow;
HWND parent = GetParent( dlg);
int resize;
#define MAXNRCTRLS 30
static RECT ctrlrcs[MAXNRCTRLS];
static int ctrlids[MAXNRCTRLS];
static HWND ctrls[MAXNRCTRLS];
static int nrctrls;
switch( msg)
{
case WM_INITDIALOG:
{
DWORD style;
index = ((OPENFILENAME*)lParam)->lCustData;
count = 0;
gotSWP_bottom = gotShowWindow = 0;
/* test style */
style = GetWindowLong( parent, GWL_STYLE);
if( resize_testcases[index].flags & OFN_ENABLESIZING)
if( !(style & WS_SIZEBOX)) {
win_skip( "OFN_ENABLESIZING flag not supported.\n");
resizesupported = FALSE;
PostMessage( parent, WM_COMMAND, IDCANCEL, 0);
} else
ok( style & WS_SIZEBOX,
"testid %d: dialog should have a WS_SIZEBOX style.\n", index);
else
ok( !(style & WS_SIZEBOX),
"testid %d: dialog should not have a WS_SIZEBOX style.\n", index);
break;
}
case WM_NOTIFY:
{
if(( (LPNMHDR)lParam)->code == CDN_FOLDERCHANGE){
GetWindowRect( parent, &initrc);
if( (resize = resize_testcases[index].resize_folderchange)){
MoveWindow( parent, initrc.left,initrc.top, initrc.right - initrc.left + resize,
initrc.bottom - initrc.top + resize, TRUE);
}
SetTimer( dlg, 0, 100, 0);
}
break;
}
case WM_TIMER:
{
if( count == 0){
/* store the control rectangles */
if( resize_testcases[index].testcontrols) {
HWND ctrl;
int i;
for( i = 0, ctrl = GetWindow( parent, GW_CHILD);
i < MAXNRCTRLS && ctrl;
i++, ctrl = GetWindow( ctrl, GW_HWNDNEXT)) {
ctrlids[i] = GetDlgCtrlID( ctrl);
GetWindowRect( ctrl, &ctrlrcs[i]);
MapWindowPoints( NULL, parent, (LPPOINT) &ctrlrcs[i], 2);
ctrls[i] = ctrl;
}
nrctrls = i;
}
if( (resize = resize_testcases[index].resize_timer1)){
GetWindowRect( parent, &rc);
MoveWindow( parent, rc.left,rc.top, rc.right - rc.left + resize,
rc.bottom - rc.top + resize, TRUE);
}
} else if( count == 1){
resize = resize_testcases[index].resize_check;
GetWindowRect( parent, &rc);
if( resize_testcases[index].todo){
todo_wine {
ok( resize == rc.right - rc.left - initrc.right + initrc.left,
"testid %d size-x change %d expected %d\n", index,
rc.right - rc.left - initrc.right + initrc.left, resize);
ok( resize == rc.bottom - rc.top - initrc.bottom + initrc.top,
"testid %d size-y change %d expected %d\n", index,
rc.bottom - rc.top - initrc.bottom + initrc.top, resize);
}
}else{
ok( resize == rc.right - rc.left - initrc.right + initrc.left,
"testid %d size-x change %d expected %d\n", index,
rc.right - rc.left - initrc.right + initrc.left, resize);
ok( resize == rc.bottom - rc.top - initrc.bottom + initrc.top,
"testid %d size-y change %d expected %d\n", index,
rc.bottom - rc.top - initrc.bottom + initrc.top, resize);
}
if( resize_testcases[index].testcontrols) {
int i;
RECT rc;
for( i = 0; i < nrctrls; i++) {
GetWindowRect( ctrls[i], &rc);
MapWindowPoints( NULL, parent, (LPPOINT) &rc, 2);
switch( ctrlids[i]){
/* test if RECT R1, moved and sized result in R2 */
#define TESTRECTS( R1, R2, Mx, My, Sx, Sy) \
((R1).left + (Mx) ==(R2).left \
&&(R1).top + (My) ==(R2).top \
&&(R1).right + (Mx) + (Sx) == (R2).right \
&&(R1).bottom + (My) + (Sy) ==(R2).bottom)
/* sized horizontal and moved vertical */
case cmb1:
case edt1:
ok( TESTRECTS( ctrlrcs[i], rc, 0, 10, 10, 0) ||
broken(TESTRECTS( ctrlrcs[i], rc, 0, 10, 0, 0)),/*win98*/
"control id %03x should have sized horizontally and moved vertically, before %d,%d-%d,%d after %d,%d-%d,%d\n",
ctrlids[i], ctrlrcs[i].left, ctrlrcs[i].top,
ctrlrcs[i].right, ctrlrcs[i].bottom,
rc.left, rc.top, rc.right, rc.bottom);
break;
/* sized horizontal and vertical */
case lst2:
ok( TESTRECTS( ctrlrcs[i], rc, 0, 0, 10, 10),
"control id %03x should have sized horizontally and vertically, before %d,%d-%d,%d after %d,%d-%d,%d\n",
ctrlids[i], ctrlrcs[i].left, ctrlrcs[i].top,
ctrlrcs[i].right, ctrlrcs[i].bottom,
rc.left, rc.top, rc.right, rc.bottom);
break;
/* moved horizontal and vertical */
case IDCANCEL:
case pshHelp:
ok( TESTRECTS( ctrlrcs[i], rc, 10, 10, 0, 0) ||
broken(TESTRECTS( ctrlrcs[i], rc, 0, 10, 0, 0)),/*win98*/
"control id %03x should have moved horizontally and vertically, before %d,%d-%d,%d after %d,%d-%d,%d\n",
ctrlids[i], ctrlrcs[i].left, ctrlrcs[i].top,
ctrlrcs[i].right, ctrlrcs[i].bottom,
rc.left, rc.top, rc.right, rc.bottom);
break;
/* moved vertically */
case chx1:
case stc2:
case stc3:
ok( TESTRECTS( ctrlrcs[i], rc, 0, 10, 0, 0),
"control id %03x should have moved vertically, before %d,%d-%d,%d after %d,%d-%d,%d\n",
ctrlids[i], ctrlrcs[i].left, ctrlrcs[i].top,
ctrlrcs[i].right, ctrlrcs[i].bottom,
rc.left, rc.top, rc.right, rc.bottom);
break;
/* resized horizontal */
case cmb2: /* aka IDC_LOOKIN */
ok( TESTRECTS( ctrlrcs[i], rc, 0, 0, 10, 0)||
TESTRECTS( ctrlrcs[i], rc, 0, 0, 0, 0), /* Vista and higher */
"control id %03x should have resized horizontally, before %d,%d-%d,%d after %d,%d-%d,%d\n",
ctrlids[i], ctrlrcs[i].left, ctrlrcs[i].top,
ctrlrcs[i].right, ctrlrcs[i].bottom,
rc.left, rc.top, rc.right, rc.bottom);
break;
/* non moving non sizing controls */
case stc4:
ok( TESTRECTS( rc, ctrlrcs[i], 0, 0, 0, 0),
"control id %03x was moved/resized, before %d,%d-%d,%d after %d,%d-%d,%d\n",
ctrlids[i], ctrlrcs[i].left, ctrlrcs[i].top,
ctrlrcs[i].right, ctrlrcs[i].bottom,
rc.left, rc.top, rc.right, rc.bottom);
break;
/* todo_wine: non moving non sizing controls */
case lst1:
todo_wine
ok( TESTRECTS( rc, ctrlrcs[i], 0, 0, 0, 0),
"control id %03x was moved/resized, before %d,%d-%d,%d after %d,%d-%d,%d\n",
ctrlids[i], ctrlrcs[i].left, ctrlrcs[i].top,
ctrlrcs[i].right, ctrlrcs[i].bottom,
rc.left, rc.top, rc.right, rc.bottom);
break;
/* don't test: id is not unique */
case IDOK:
case stc1:
case 0:
case -1:
break;
default:
trace("untested control id %03x before %d,%d-%d,%d after %d,%d-%d,%d\n",
ctrlids[i], ctrlrcs[i].left, ctrlrcs[i].top,
ctrlrcs[i].right, ctrlrcs[i].bottom,
rc.left, rc.top, rc.right, rc.bottom);
#undef TESTRECTS
#undef MAXNRCTRLS
}
}
}
KillTimer( dlg, 0);
PostMessage( parent, WM_COMMAND, IDCANCEL, 0);
}
count++;
}
break;
case WM_WINDOWPOSCHANGING:
{
WINDOWPOS *pwp = (WINDOWPOS *)lParam;
if( !index && pwp->hwndInsertAfter == HWND_BOTTOM){
gotSWP_bottom = 1;
ok( gotShowWindow == 0, "The WM_WINDOWPOSCHANGING message came after a WM_SHOWWINDOW message\n");
}
}
break;
case WM_SHOWWINDOW:
{
if( !index){
gotShowWindow = 1;
ok( gotSWP_bottom == 1, "No WM_WINDOWPOSCHANGING message came before a WM_SHOWWINDOW message\n");
}
}
break;
}
return 0;
}
static void test_resize(void)
{
OPENFILENAME ofn = { sizeof(OPENFILENAME)};
char filename[1024] = {0};
DWORD ret;
int i;
ofn.lpstrFile = filename;
ofn.nMaxFile = 1024;
ofn.lpfnHook = (LPOFNHOOKPROC) resize_template_hook;
ofn.hInstance = GetModuleHandle(NULL);
ofn.lpTemplateName = "template_sz";
for( i = 0; resize_testcases[i].flags != 0xffffffff; i++) {
ofn.lCustData = i;
ofn.Flags = resize_testcases[i].flags |
OFN_ENABLEHOOK | OFN_EXPLORER| OFN_ENABLETEMPLATE | OFN_SHOWHELP ;
ret = GetOpenFileName(&ofn);
ok(!ret, "GetOpenFileName returned %#x\n", ret);
ret = CommDlgExtendedError();
ok(!ret, "CommDlgExtendedError returned %#x\n", ret);
}
}
/* test cases for control message IDOK */
/* Show case for bug #19079 */
static struct {
int retval; /* return code of the message handler */
BOOL setmsgresult; /* set the result in the DWLP_MSGRESULT */
BOOL usemsgokstr; /* use the FILEOKSTRING message instead of WM_NOTIFY:CDN_FILEOK */
BOOL do_subclass; /* subclass the dialog hook procedure */
BOOL expclose; /* is the dialog expected to close ? */
BOOL actclose; /* has the dialog actually closed ? */
} ok_testcases[] = {
{ 0, FALSE, FALSE, FALSE, TRUE},
{ 0, TRUE, FALSE, FALSE, TRUE},
{ 0, FALSE, FALSE, TRUE, TRUE},
{ 0, TRUE, FALSE, TRUE, TRUE},
{ 1, FALSE, FALSE, FALSE, TRUE},
{ 1, TRUE, FALSE, FALSE, FALSE},
{ 1, FALSE, FALSE, TRUE, FALSE},
{ 1, TRUE, FALSE, TRUE, FALSE},
/* FILEOKSTRING tests */
{ 1, TRUE, TRUE, FALSE, FALSE},
{ 1, FALSE, TRUE, TRUE, FALSE},
/* mark the end */
{ -1 }
};
/* test_ok_wndproc can be used as hook procedure or a subclass
* window proc for the file dialog */
static LONG_PTR WINAPI test_ok_wndproc(HWND dlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
HWND parent = GetParent( dlg);
static int index;
static UINT msgFILEOKSTRING;
if (msg == WM_INITDIALOG)
{
index = ((OPENFILENAME*)lParam)->lCustData;
ok_testcases[index].actclose = TRUE;
msgFILEOKSTRING = RegisterWindowMessageA( FILEOKSTRING);
}
if( msg == WM_NOTIFY) {
if(((LPNMHDR)lParam)->code == CDN_FOLDERCHANGE) {
SetTimer( dlg, 0, 100, 0);
PostMessage( parent, WM_COMMAND, IDOK, 0);
return FALSE;
} else if(((LPNMHDR)lParam)->code == CDN_FILEOK) {
if( ok_testcases[index].usemsgokstr)
return FALSE;
if( ok_testcases[index].setmsgresult)
SetWindowLongPtrA( dlg, DWLP_MSGRESULT, ok_testcases[index].retval);
return ok_testcases[index].retval;
}
}
if( msg == msgFILEOKSTRING) {
if( !ok_testcases[index].usemsgokstr)
return FALSE;
if( ok_testcases[index].setmsgresult)
SetWindowLongPtrA( dlg, DWLP_MSGRESULT, ok_testcases[index].retval);
return ok_testcases[index].retval;
}
if( msg == WM_TIMER) {
/* the dialog did not close automatically */
ok_testcases[index].actclose = FALSE;
KillTimer( dlg, 0);
PostMessage( parent, WM_COMMAND, IDCANCEL, 0);
return FALSE;
}
if( ok_testcases[index].do_subclass)
return DefWindowProc( dlg, msg, wParam, lParam);
return FALSE;
}
static LONG_PTR WINAPI ok_template_hook(HWND dlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
if (msg == WM_SETFONT)
SetWindowLongPtrA( dlg, GWLP_WNDPROC, (LONG_PTR) test_ok_wndproc);
return FALSE;
}
static void test_ok(void)
{
OPENFILENAME ofn = { sizeof(OPENFILENAME)};
char filename[1024] = {0};
char tmpfilename[ MAX_PATH];
char curdir[MAX_PATH];
int i;
DWORD ret;
ok(GetCurrentDirectoryA(sizeof(curdir), curdir) != 0, "Failed to get current dir err %d\n", GetLastError());
if (!GetTempFileNameA(".", "txt", 0, tmpfilename)) {
skip("Failed to create a temporary file name\n");
return;
}
ofn.lpstrFile = filename;
ofn.nMaxFile = 1024;
ofn.hInstance = GetModuleHandle(NULL);
ofn.lpTemplateName = "template1";
ofn.Flags = OFN_ENABLEHOOK | OFN_EXPLORER| OFN_ENABLETEMPLATE ;
for( i = 0; ok_testcases[i].retval != -1; i++) {
strcpy( filename, tmpfilename);
ofn.lCustData = i;
ofn.lpfnHook = ok_testcases[i].do_subclass
? (LPOFNHOOKPROC) ok_template_hook
: (LPOFNHOOKPROC) test_ok_wndproc;
ret = GetOpenFileNameA(&ofn);
ok( ok_testcases[i].expclose == ok_testcases[i].actclose,
"testid %d: Open File dialog should %shave closed.\n", i,
ok_testcases[i].expclose ? "" : "NOT ");
ok(ret == ok_testcases[i].expclose, "testid %d: GetOpenFileName returned %#x\n", i, ret);
ret = CommDlgExtendedError();
ok(!ret, "CommDlgExtendedError returned %#x\n", ret);
ok(SetCurrentDirectoryA(curdir), "Failed to restore current dir err %d\n", GetLastError());
}
ret = DeleteFileA( tmpfilename);
ok( ret, "Failed to delete temporary file %s err %d\n", tmpfilename, GetLastError());
}
/* test arranging with a custom template */
typedef struct {
int x, y; /* left, top coordinates */
int cx, cy; /* width and height */
} posz;
static struct {
int nrcontrols; /* 0: no controls, 1: just the stc32 control 2: with button */
posz poszDlg;
posz poszStc32;
posz poszBtn;
DWORD ofnflags;
} arrange_tests[] = {
/* do not change the first two cases: used to get the uncustomized sizes */
{ 0, {0},{0},{0},0 },
{ 0, {0},{0},{0}, OFN_SHOWHELP},
/* two tests with just a subdialog, no controls */
{ 0, {0, 0, 316, 76},{0},{0},0 },
{ 0, {0, 0, 100, 76},{0},{0}, OFN_SHOWHELP},
/* now with a control with id stc32 */
{ 1, {0, 0, 316, 76} ,{0, 0, 204, 76,},{0},0 }, /* bug #17748*/
{ 1, {0, 0, 316, 76} ,{0, 0, 204, 76,},{0}, OFN_SHOWHELP}, /* bug #17748*/
/* tests with size of the stc32 control higher or wider then the standard dialog */
{ 1, {0, 0, 316, 170} ,{0, 0, 204, 170,},{0},0 },
{ 1, {0, 0, 316, 165} ,{0, 0, 411, 165,},{0}, OFN_SHOWHELP },
/* move the stc32 control around */
{ 1, {0, 0, 300, 100} ,{73, 17, 50, 50,},{0},0 },
/* add control */
{ 2, {0, 0, 280, 100} ,{0, 0, 50, 50,},{300,20,30,30},0 },
/* enable resizing should make the dialog bigger */
{ 0, {0},{0},{0}, OFN_SHOWHELP|OFN_ENABLESIZING},
/* mark the end */
{ -1 }
};
static LONG_PTR WINAPI template_hook_arrange(HWND dlgChild, UINT msg, WPARAM wParam, LPARAM lParam)
{
static int index, fixhelp;
static posz posz0[2];
static RECT clrcParent, clrcChild, rcStc32;
static HWND hwndStc32;
HWND dlgParent;
dlgParent = GetParent( dlgChild);
if (msg == WM_INITDIALOG) {
index = ((OPENFILENAME*)lParam)->lCustData;
/* get the positions before rearrangement */
GetClientRect( dlgParent, &clrcParent);
GetClientRect( dlgChild, &clrcChild);
hwndStc32 = GetDlgItem( dlgChild, stc32);
if( hwndStc32) GetWindowRect( hwndStc32, &rcStc32);
}
if (msg == WM_NOTIFY && ((LPNMHDR)lParam)->code == CDN_FOLDERCHANGE) {
RECT wrcParent;
GetWindowRect( dlgParent, &wrcParent);
/* the fist two "tests" just save the dialogs position, with and without
* help button */
if( index == 0) {
posz0[0].x = wrcParent.left;
posz0[0].y = wrcParent.top;
posz0[0].cx = wrcParent.right - wrcParent.left;
posz0[0].cy = wrcParent.bottom - wrcParent.top;
} else if( index == 1) {
posz0[1].x = wrcParent.left;
posz0[1].y = wrcParent.top;
posz0[1].cx = wrcParent.right - wrcParent.left;
posz0[1].cy = wrcParent.bottom - wrcParent.top;
fixhelp = posz0[1].cy - posz0[0].cy;
} else {
/* the real tests */
int withhelp;
int expectx, expecty;
DWORD style;
withhelp = (arrange_tests[index].ofnflags & OFN_SHOWHELP) != 0;
GetWindowRect( dlgParent, &wrcParent);
if( !hwndStc32) {
/* case with no custom subitem with stc32:
* default to all custom controls below the standard */
expecty = posz0[withhelp].cy + clrcChild.bottom;
expectx = posz0[withhelp].cx;
} else {
/* special case: there is a control with id stc32 */
/* expected height */
expecty = posz0[withhelp].cy;
if( rcStc32.bottom - rcStc32.top > clrcParent.bottom) {
expecty += clrcChild.bottom - clrcParent.bottom;
if( !withhelp) expecty += fixhelp;
}
else
expecty += clrcChild.bottom - ( rcStc32.bottom - rcStc32.top) ;
/* expected width */
expectx = posz0[withhelp].cx;
if( rcStc32.right - rcStc32.left > clrcParent.right) {
expectx += clrcChild.right - clrcParent.right;
}
else
expectx += clrcChild.right - ( rcStc32.right - rcStc32.left) ;
}
style = GetWindowLong( dlgParent, GWL_STYLE);
if( !(style & WS_SIZEBOX)) {
/* without the OFN_ENABLESIZING flag */
ok( wrcParent.bottom - wrcParent.top == expecty,
"Wrong height of dialog %d, expected %d\n",
wrcParent.bottom - wrcParent.top, expecty);
ok( wrcParent.right - wrcParent.left == expectx,
"Wrong width of dialog %d, expected %d\n",
wrcParent.right - wrcParent.left, expectx);
} else todo_wine {
/* with the OFN_ENABLESIZING flag */
ok( wrcParent.bottom - wrcParent.top > expecty,
"Wrong height of dialog %d, expected more than %d\n",
wrcParent.bottom - wrcParent.top, expecty);
ok( wrcParent.right - wrcParent.left > expectx,
"Wrong width of dialog %d, expected more than %d\n",
wrcParent.right - wrcParent.left, expectx);
}
}
PostMessage( dlgParent, WM_COMMAND, IDCANCEL, 0);
}
return 0;
}
static void test_arrange(void)
{
OPENFILENAMEA ofn = {0};
char filename[1024] = {0};
DWORD ret;
HRSRC hRes;
HANDLE hDlgTmpl;
LPBYTE pv;
DLGTEMPLATE *template;
DLGITEMTEMPLATE *itemtemplateStc32, *itemtemplateBtn;
int i;
/* load subdialog template into memory */
hRes = FindResource( GetModuleHandle(NULL), "template_stc32", (LPSTR)RT_DIALOG);
hDlgTmpl = LoadResource( GetModuleHandle(NULL), hRes );
/* get pointers to the structures for the dialog and the controls */
pv = LockResource( hDlgTmpl );
template = (DLGTEMPLATE*)pv;
if( template->x != 11111) {
win_skip("could not find the dialog template\n");
return;
}
/* skip dialog template, menu, class and title */
pv += sizeof(DLGTEMPLATE);
pv += 3 * sizeof(WORD);
/* skip font info */
while( *(WORD*)pv)
pv += sizeof(WORD);
pv += sizeof(WORD);
/* align on 32 bit boundaries */
pv = (LPBYTE)(((UINT_PTR)pv + 3 ) & ~3);
itemtemplateStc32 = (DLGITEMTEMPLATE*)pv;
if( itemtemplateStc32->x != 22222) {
win_skip("could not find the first item template\n");
return;
}
/* skip itemtemplate, class, title and creation data */
pv += sizeof(DLGITEMTEMPLATE);
pv += 4 * sizeof(WORD);
/* align on 32 bit boundaries */
pv = (LPBYTE)(((UINT_PTR)pv + 3 ) & ~3);
itemtemplateBtn = (DLGITEMTEMPLATE*)pv;
if( itemtemplateBtn->x != 12345) {
win_skip("could not find the second item template\n");
return;
}
ofn.lStructSize = sizeof(ofn);
ofn.lpstrFile = filename;
ofn.nMaxFile = 1024;
ofn.lpfnHook = (LPOFNHOOKPROC)template_hook_arrange;
ofn.hInstance = hDlgTmpl;
ofn.lpstrFilter="text\0*.txt\0All\0*\0\0";
for( i = 0; arrange_tests[i].nrcontrols != -1; i++) {
ofn.lCustData = i;
ofn.Flags = OFN_ENABLEHOOK | OFN_EXPLORER| OFN_ENABLETEMPLATEHANDLE | OFN_HIDEREADONLY |
arrange_tests[i].ofnflags;
template->cdit = arrange_tests[i].nrcontrols;
template->x = arrange_tests[i].poszDlg.x;
template->y = arrange_tests[i].poszDlg.y;
template->cx = arrange_tests[i].poszDlg.cx;
template->cy = arrange_tests[i].poszDlg.cy;
itemtemplateStc32->x = arrange_tests[i].poszStc32.x;
itemtemplateStc32->y = arrange_tests[i].poszStc32.y;
itemtemplateStc32->cx = arrange_tests[i].poszStc32.cx;
itemtemplateStc32->cy = arrange_tests[i].poszStc32.cy;
itemtemplateBtn->x = arrange_tests[i].poszBtn.x;
itemtemplateBtn->y = arrange_tests[i].poszBtn.y;
itemtemplateBtn->cx = arrange_tests[i].poszBtn.cx;
itemtemplateBtn->cy = arrange_tests[i].poszBtn.cy;
ret = GetOpenFileNameA(&ofn);
ok(!ret, "GetOpenFileNameA returned %#x\n", ret);
ret = CommDlgExtendedError();
ok(!ret, "CommDlgExtendedError returned %#x\n", ret);
}
}
static CHAR SYSDIR[MAX_PATH];
static UINT_PTR CALLBACK path_hook_proc( HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
LPNMHDR nmh;
if( msg == WM_NOTIFY)
{
nmh = (LPNMHDR) lParam;
if( nmh->code == CDN_INITDONE)
{
PostMessage( GetParent(hDlg), WM_COMMAND, IDCANCEL, FALSE);
}
else if ( nmh->code == CDN_FOLDERCHANGE)
{
char buf[1024];
int ret;
memset(buf, 0x66, sizeof(buf));
ret = SendMessageA( GetParent(hDlg), CDM_GETFOLDERPATH, sizeof(buf), (LPARAM)buf);
ok(!lstrcmpiA(SYSDIR, buf), "Expected '%s', got '%s'\n", SYSDIR, buf);
ok(lstrlenA(SYSDIR) + 1 == ret, "Expected %d, got %d\n", lstrlenA(SYSDIR) + 1, ret);
}
}
return 0;
}
static void test_getfolderpath(void)
{
OPENFILENAMEA ofn;
BOOL result;
char szFileName[MAX_PATH] = "";
char szInitialDir[MAX_PATH];
/* We need to pick a different directory as the other tests because of new
* Windows 7 behavior.
*/
GetSystemDirectory(szInitialDir, MAX_PATH);
lstrcpyA(SYSDIR, szInitialDir);
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = NULL;
ofn.lpstrFilter = "Text Files (*.txt)\0*.txt\0All Files (*.*)\0*.*\0";
ofn.lpstrFile = szFileName;
ofn.nMaxFile = MAX_PATH;
ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_ENABLEHOOK;
ofn.lpstrDefExt = "txt";
ofn.lpfnHook = path_hook_proc;
ofn.lpstrInitialDir = szInitialDir;
result = GetOpenFileNameA(&ofn);
ok(0 == result, "expected 0, got %d\n", result);
ok(0 == CommDlgExtendedError(), "expected 0, got %d\n",
CommDlgExtendedError());
result = GetSaveFileNameA(&ofn);
ok(0 == result, "expected 0, got %d\n", result);
ok(0 == CommDlgExtendedError(), "expected 0, got %d\n",
CommDlgExtendedError());
}
static void test_resizable2(void)
{
OPENFILENAMEA ofn = {0};
char filename[1024] = "pls press Enter if sizable, Esc otherwise";
DWORD ret;
/* interactive because there is no hook function */
if( !winetest_interactive) {
skip( "some interactive resizable dialog tests (set WINETEST_INTERACTIVE=1)\n");
return;
}
ofn.lStructSize = sizeof(ofn);
ofn.lpstrFile = filename;
ofn.nMaxFile = 1024;
ofn.lpfnHook = NULL;
ofn.hInstance = GetModuleHandleA(NULL);
ofn.lpTemplateName = "template1";
ofn.Flags = OFN_EXPLORER;
#define ISSIZABLE 1
ret = GetOpenFileNameA(&ofn);
ok( ret == ISSIZABLE, "File Dialog should have been sizable\n");
ret = CommDlgExtendedError();
ok(!ret, "CommDlgExtendedError returned %#x\n", ret);
ofn.Flags = OFN_EXPLORER | OFN_ENABLETEMPLATE;
ret = GetOpenFileNameA(&ofn);
ok( ret != ISSIZABLE, "File Dialog should NOT have been sizable\n");
ret = CommDlgExtendedError();
ok(!ret, "CommDlgExtendedError returned %#x\n", ret);
ofn.Flags = OFN_EXPLORER | OFN_ENABLETEMPLATEHANDLE;
ofn.hInstance = LoadResource( GetModuleHandle(NULL), FindResource( GetModuleHandle(NULL), "template1", (LPSTR)RT_DIALOG));
ofn.lpTemplateName = NULL;
ret = GetOpenFileNameA(&ofn);
ok( ret != ISSIZABLE, "File Dialog should NOT have been sizable\n");
ret = CommDlgExtendedError();
ok(!ret, "CommDlgExtendedError returned %#x\n", ret);
ofn.Flags = OFN_EXPLORER | OFN_ENABLEHOOK;
ret = GetOpenFileNameA(&ofn);
ok( ret != ISSIZABLE, "File Dialog should NOT have been sizable\n");
ret = CommDlgExtendedError();
ok(!ret, "CommDlgExtendedError returned %#x\n", ret);
#undef ISSIZABLE
}
START_TEST(filedlg)
{
test_DialogCancel();
test_create_view_window2();
test_create_view_template();
test_arrange();
test_resize();
test_ok();
test_getfolderpath();
if( resizesupported) test_resizable2();
}

View file

@ -0,0 +1,150 @@
/*
* Unit test suite for comdlg32 API functions: font dialogs
*
* Copyright 2009 Vincent Povirk for CodeWeavers
*
* 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 "windef.h"
#include "winbase.h"
#include "winerror.h"
#include "wingdi.h"
#include "winspool.h"
#include "winuser.h"
#include "objbase.h"
#include "commdlg.h"
#include "wine/test.h"
static int get_dpiy(void)
{
HDC hdc;
int result;
hdc = GetDC(0);
result = GetDeviceCaps(hdc, LOGPIXELSY);
ReleaseDC(0, hdc);
return result;
}
static HDC get_printer_ic(void)
{
PRINTER_INFO_2A *info;
DWORD info_size, num_printers=0;
BOOL ret;
HDC result=NULL;
EnumPrintersA(PRINTER_ENUM_LOCAL, NULL, 2, NULL, 0, &info_size, &num_printers);
if (info_size == 0)
return NULL;
info = HeapAlloc(GetProcessHeap(), 0, info_size);
ret = EnumPrintersA(PRINTER_ENUM_LOCAL, NULL, 2, (LPBYTE)info, info_size, &info_size, &num_printers);
if (ret)
result = CreateICA(info->pDriverName, info->pPrinterName, NULL, NULL);
HeapFree(GetProcessHeap(), 0, info);
return result;
}
static UINT_PTR CALLBACK CFHookProcOK(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam)
{
switch (msg)
{
case WM_INITDIALOG:
PostMessageA(hdlg, WM_COMMAND, IDOK, FALSE);
return 0;
default:
return 0;
}
}
static void test_ChooseFontA(void)
{
LOGFONTA lfa;
CHOOSEFONTA cfa;
BOOL ret;
int dpiy = get_dpiy();
int expected_pointsize, expected_lfheight;
HDC printer_ic;
memset(&lfa, 0, sizeof(LOGFONTA));
lfa.lfHeight = -16;
lfa.lfWeight = FW_NORMAL;
strcpy(lfa.lfFaceName, "Symbol");
memset(&cfa, 0, sizeof(CHOOSEFONTA));
cfa.lStructSize = sizeof(cfa);
cfa.lpLogFont = &lfa;
cfa.Flags = CF_ENABLEHOOK|CF_INITTOLOGFONTSTRUCT|CF_SCREENFONTS;
cfa.lpfnHook = CFHookProcOK;
ret = ChooseFontA(&cfa);
expected_pointsize = MulDiv(16, 72, dpiy) * 10;
expected_lfheight = -MulDiv(expected_pointsize, dpiy, 720);
ok(ret == TRUE, "ChooseFontA returned FALSE\n");
ok(cfa.iPointSize == expected_pointsize, "Expected %i, got %i\n", expected_pointsize, cfa.iPointSize);
ok(lfa.lfHeight == expected_lfheight, "Expected %i, got %i\n", expected_lfheight, lfa.lfHeight);
ok(lfa.lfWeight == FW_NORMAL, "Expected FW_NORMAL, got %i\n", lfa.lfWeight);
ok(strcmp(lfa.lfFaceName, "Symbol") == 0, "Expected Symbol, got %s\n", lfa.lfFaceName);
printer_ic = get_printer_ic();
if (!printer_ic)
skip("can't get a DC for a local printer\n");
else
{
memset(&lfa, 0, sizeof(LOGFONTA));
lfa.lfHeight = -16;
lfa.lfWeight = FW_NORMAL;
strcpy(lfa.lfFaceName, "Symbol");
memset(&cfa, 0, sizeof(CHOOSEFONTA));
cfa.lStructSize = sizeof(cfa);
cfa.lpLogFont = &lfa;
cfa.Flags = CF_ENABLEHOOK|CF_INITTOLOGFONTSTRUCT|CF_PRINTERFONTS;
cfa.hDC = printer_ic;
cfa.lpfnHook = CFHookProcOK;
ret = ChooseFontA(&cfa);
expected_pointsize = MulDiv(16, 72, dpiy) * 10;
expected_lfheight = -MulDiv(expected_pointsize, dpiy, 720);
ok(ret == TRUE, "ChooseFontA returned FALSE\n");
ok(cfa.iPointSize == expected_pointsize, "Expected %i, got %i\n", expected_pointsize, cfa.iPointSize);
ok(lfa.lfHeight == expected_lfheight, "Expected %i, got %i\n", expected_lfheight, lfa.lfHeight);
ok(lfa.lfWeight == FW_NORMAL, "Expected FW_NORMAL, got %i\n", lfa.lfWeight);
ok(strcmp(lfa.lfFaceName, "Symbol") == 0, "Expected Symbol, got %s\n", lfa.lfFaceName);
DeleteDC(printer_ic);
}
}
START_TEST(fontdlg)
{
test_ChooseFontA();
}

View file

@ -246,6 +246,11 @@ static void test_PrintDlgExW(void)
PrintDlg(NULL);
SetLastError(0xdeadbeef);
res = pPrintDlgExW(NULL);
if(res == E_NOTIMPL)
{
win_skip("PrintDlgExW returns not implemented\n");
return;
}
ok( (res == E_INVALIDARG),
"got 0x%x with %u and %u (expected 'E_INVALIDARG')\n",
res, GetLastError(), CommDlgExtendedError());
@ -318,6 +323,8 @@ static void test_abort_proc(void)
ok(DeleteFileA(filename), "Failed to delete temporary file\n");
return;
}
GlobalFree(pd.hDevMode);
GlobalFree(pd.hDevNames);
ok(pd.hDC != NULL, "PrintDlg didn't return a DC.\n");
if (!(print_dc = pd.hDC))
@ -346,25 +353,19 @@ static void test_abort_proc(void)
goto end;
}
ok(abort_proc_called, "AbortProc didn't get called by StartDoc.\n");
abort_proc_called = FALSE;
/* StartDoc may or may not call abort proc */
abort_proc_called = FALSE;
ok(StartPage(print_dc) > 0, "StartPage failed\n");
ok(!abort_proc_called, "AbortProc got called unexpectedly by StartPage.\n");
abort_proc_called = FALSE;
/* following functions sometimes call abort proc too */
ok(FillRect(print_dc, &rect, (HBRUSH)(COLOR_BACKGROUND + 1)), "FillRect failed\n");
ok(!abort_proc_called, "AbortProc got called unexpectedly by StretchBlt.\n");
abort_proc_called = FALSE;
ok(EndPage(print_dc) > 0, "EndPage failed\n");
ok(!abort_proc_called, "AbortProc got called unexpectedly by EndPage.\n");
abort_proc_called = FALSE;
ok(EndDoc(print_dc) > 0, "EndDoc failed\n");
ok(!abort_proc_called, "AbortProc got called unexpectedly by EndDoc.\n");
abort_proc_called = FALSE;
abort_proc_called = FALSE;
ok(DeleteDC(print_dc), "DeleteDC failed\n");
ok(!abort_proc_called, "AbortProc got called unexpectedly by DeleteDC.\n");
abort_proc_called = FALSE;

View file

@ -32,3 +32,28 @@ FONT 8, "MS Shell Dlg"
LTEXT "",-1,28,16,204,31
EDITTEXT 56,65,2,200,12,ES_AUTOHSCROLL
}
/* Used by the resize file dialog tests.
* Keep this template small or get failures
* resizing on small desk tops.
* This will work with 640x480 pixels
*/
TEMPLATE_SZ DIALOG LOADONCALL MOVEABLE DISCARDABLE 5, 43, 300, 40
STYLE WS_CHILD | WS_CLIPSIBLINGS
FONT 8, "MS Shell Dlg"
{
LTEXT "Path:",-1,28,4,36,8
LTEXT "Text1",-1,4,16,20,40
LTEXT "Text2",-1,232,20,65,8
LTEXT "",-1,28,16,204,31
EDITTEXT 56,65,2,200,12,ES_AUTOHSCROLL
}
/* note: the test program will modify coordinates and nr of controls in this template */
TEMPLATE_STC32 DIALOG LOADONCALL MOVEABLE DISCARDABLE 11111, 0, 316, 76
STYLE WS_CHILD | WS_CLIPSIBLINGS
FONT 8, "MS Shell Dlg"
{
LTEXT "", 1119, 22222, 0, 204, 76
PUSHBUTTON "TEST", -1, 12345, 0, 20, 20
}

View file

@ -58,6 +58,8 @@ static VOID (WINAPI *pCertFreeCertificateChain)(PCCERT_CHAIN_CONTEXT);
static VOID (WINAPI *pCertFreeCertificateChainEngine)(HCERTCHAINENGINE);
static BOOL (WINAPI *pCertVerifyCertificateChainPolicy)(LPCSTR,PCCERT_CHAIN_CONTEXT,PCERT_CHAIN_POLICY_PARA,PCERT_CHAIN_POLICY_STATUS);
#define IS_INTOID(x) (((ULONG_PTR)(x) >> 16) == 0)
static void testCreateCertChainEngine(void)
{
@ -3883,19 +3885,19 @@ static void checkChainPolicyStatus(LPCSTR policy, const ChainPolicyCheck *check,
if (check->todo & TODO_POLICY)
todo_wine ok(ret,
"%s[%d]: CertVerifyCertificateChainPolicy failed: %08x\n",
HIWORD(policy) ? policy : num_to_str(LOWORD(policy)),
IS_INTOID(policy) ? num_to_str(LOWORD(policy)) : policy,
testIndex, GetLastError());
else
{
if (!ret && GetLastError() == ERROR_FILE_NOT_FOUND)
{
skip("%d: missing policy %s, skipping test\n", testIndex,
HIWORD(policy) ? policy : num_to_str(LOWORD(policy)));
IS_INTOID(policy) ? num_to_str(LOWORD(policy)) : policy);
pCertFreeCertificateChain(chain);
return;
}
ok(ret, "%s[%d]: CertVerifyCertificateChainPolicy failed: %08x\n",
HIWORD(policy) ? policy : num_to_str(LOWORD(policy)), testIndex,
IS_INTOID(policy) ? num_to_str(LOWORD(policy)) : policy, testIndex,
GetLastError());
}
if (ret)
@ -3906,7 +3908,7 @@ static void checkChainPolicyStatus(LPCSTR policy, const ChainPolicyCheck *check,
(check->brokenStatus && broken(policyStatus.dwError ==
check->brokenStatus->dwError)),
"%s[%d]: expected %08x, got %08x\n",
HIWORD(policy) ? policy : num_to_str(LOWORD(policy)),
IS_INTOID(policy) ? num_to_str(LOWORD(policy)) : policy,
testIndex, check->status.dwError, policyStatus.dwError);
else
ok(policyStatus.dwError == check->status.dwError ||
@ -3914,12 +3916,12 @@ static void checkChainPolicyStatus(LPCSTR policy, const ChainPolicyCheck *check,
(check->brokenStatus && broken(policyStatus.dwError ==
check->brokenStatus->dwError)),
"%s[%d]: expected %08x, got %08x\n",
HIWORD(policy) ? policy : num_to_str(LOWORD(policy)),
IS_INTOID(policy) ? num_to_str(LOWORD(policy)) : policy,
testIndex, check->status.dwError, policyStatus.dwError);
if (policyStatus.dwError != check->status.dwError)
{
skip("%s[%d]: error %08x doesn't match expected %08x, not checking indexes\n",
HIWORD(policy) ? policy : num_to_str(LOWORD(policy)),
IS_INTOID(policy) ? num_to_str(LOWORD(policy)) : policy,
testIndex, policyStatus.dwError, check->status.dwError);
pCertFreeCertificateChain(chain);
return;
@ -3930,7 +3932,7 @@ static void checkChainPolicyStatus(LPCSTR policy, const ChainPolicyCheck *check,
(check->brokenStatus && broken(policyStatus.lChainIndex ==
check->brokenStatus->lChainIndex)),
"%s[%d]: expected %d, got %d\n",
HIWORD(policy) ? policy : num_to_str(LOWORD(policy)),
IS_INTOID(policy) ? num_to_str(LOWORD(policy)) : policy,
testIndex, check->status.lChainIndex,
policyStatus.lChainIndex);
else
@ -3938,7 +3940,7 @@ static void checkChainPolicyStatus(LPCSTR policy, const ChainPolicyCheck *check,
(check->brokenStatus && broken(policyStatus.lChainIndex ==
check->brokenStatus->lChainIndex)),
"%s[%d]: expected %d, got %d\n",
HIWORD(policy) ? policy : num_to_str(LOWORD(policy)),
IS_INTOID(policy) ? num_to_str(LOWORD(policy)) : policy,
testIndex,
check->status.lChainIndex, policyStatus.lChainIndex);
if (check->todo & TODO_ELEMENTS)
@ -3947,7 +3949,7 @@ static void checkChainPolicyStatus(LPCSTR policy, const ChainPolicyCheck *check,
(check->brokenStatus && broken(policyStatus.lElementIndex ==
check->brokenStatus->lElementIndex)),
"%s[%d]: expected %d, got %d\n",
HIWORD(policy) ? policy : num_to_str(LOWORD(policy)),
IS_INTOID(policy) ? num_to_str(LOWORD(policy)) : policy,
testIndex,
check->status.lElementIndex, policyStatus.lElementIndex);
else
@ -3955,7 +3957,7 @@ static void checkChainPolicyStatus(LPCSTR policy, const ChainPolicyCheck *check,
(check->brokenStatus && broken(policyStatus.lElementIndex ==
check->brokenStatus->lElementIndex)),
"%s[%d]: expected %d, got %d\n",
HIWORD(policy) ? policy : num_to_str(LOWORD(policy)),
IS_INTOID(policy) ? num_to_str(LOWORD(policy)) : policy,
testIndex,
check->status.lElementIndex, policyStatus.lElementIndex);
}

View file

@ -254,10 +254,8 @@ static void test_cryptTls(void)
ret = pI_CryptFreeTls(index, 0);
ok(ret, "I_CryptFreeTls failed: %08x\n", GetLastError());
ret = pI_CryptFreeTls(index, 0);
/* Not sure if this fails because TlsFree should fail, so leave as
* todo for now.
*/
todo_wine ok(!ret && GetLastError() == E_INVALIDARG,
ok(!ret, "I_CryptFreeTls succeeded\n");
ok(GetLastError() == E_INVALIDARG,
"Expected E_INVALIDARG, got %08x\n", GetLastError());
}
/* Similar pass, check I_CryptDetachTls */

View file

@ -2572,8 +2572,8 @@ static void test_decode_msg_get_param(void)
sizeof(signedKeyIdEmptyContent), TRUE);
if (!ret && GetLastError() == OSS_DATA_ERROR)
{
/* Subsequent tests crashes on some Win9x, so bail out */
CryptMsgClose(msg);
win_skip("Subsequent tests crash on some Win9x\n");
return;
}
ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError());

View file

@ -646,6 +646,61 @@ static void test_linelinearblend(void)
expect(Ok, status);
}
static void test_gradientsurroundcolorcount(void)
{
GpStatus status;
GpPathGradient *grad;
ARGB *color;
INT count = 3;
status = GdipCreatePathGradient(blendcount_ptf, 2, WrapModeClamp, &grad);
expect(Ok, status);
color = GdipAlloc(sizeof(ARGB[3]));
status = GdipSetPathGradientSurroundColorsWithCount(grad, color, &count);
expect(InvalidParameter, status);
GdipFree(color);
count = 2;
color = GdipAlloc(sizeof(ARGB[2]));
color[0] = 0x00ff0000;
color[1] = 0x0000ff00;
status = GdipSetPathGradientSurroundColorsWithCount(NULL, color, &count);
expect(InvalidParameter, status);
status = GdipSetPathGradientSurroundColorsWithCount(grad, NULL, &count);
expect(InvalidParameter, status);
/* WinXP crashes on this test */
if(0)
{
status = GdipSetPathGradientSurroundColorsWithCount(grad, color, NULL);
expect(InvalidParameter, status);
}
status = GdipSetPathGradientSurroundColorsWithCount(grad, color, &count);
todo_wine expect(Ok, status);
expect(2, count);
status = GdipGetPathGradientSurroundColorCount(NULL, &count);
expect(InvalidParameter, status);
status = GdipGetPathGradientSurroundColorCount(grad, NULL);
expect(InvalidParameter, status);
count = 0;
status = GdipGetPathGradientSurroundColorCount(grad, &count);
todo_wine expect(Ok, status);
todo_wine expect(2, count);
GdipFree(color);
GdipDeleteBrush((GpBrush*)grad);
}
START_TEST(brush)
{
struct GdiplusStartupInput gdiplusStartupInput;
@ -669,6 +724,7 @@ START_TEST(brush)
test_gradientgetrect();
test_lineblend();
test_linelinearblend();
test_gradientsurroundcolorcount();
GdiplusShutdown(gdiplusToken);
}

View file

@ -18,11 +18,14 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <math.h>
#include "windows.h"
#include "gdiplus.h"
#include "wine/test.h"
#define expect(expected, got) ok(got == expected, "Expected %.8x, got %.8x\n", expected, got)
#define expectf(expected, got) ok(fabs(expected - got) < 0.0001, "Expected %.2f, got %.2f\n", expected, got)
static const WCHAR arial[] = {'A','r','i','a','l','\0'};
static const WCHAR nonexistent[] = {'T','h','i','s','F','o','n','t','s','h','o','u','l','d','N','o','t','E','x','i','s','t','\0'};
@ -189,12 +192,9 @@ static void test_fontfamily (void)
expect (FontFamilyNotFound, stat);
/* Bitmap fonts are not found */
todo_wine
{
stat = GdipCreateFontFamilyFromName (MSSansSerif, NULL, &family);
expect (FontFamilyNotFound, stat);
if(stat == Ok) GdipDeleteFontFamily(family);
}
stat = GdipCreateFontFamilyFromName (arial, NULL, &family);
if(stat == FontFamilyNotFound)
@ -345,6 +345,78 @@ static void test_installedfonts (void)
ok (collection != NULL, "got NULL font collection\n");
}
static void test_heightgivendpi(void)
{
GpStatus stat;
GpFont* font = NULL;
GpFontFamily* fontfamily = NULL;
REAL height;
stat = GdipCreateFontFamilyFromName(arial, NULL, &fontfamily);
if(stat == FontFamilyNotFound)
{
skip("Arial not installed\n");
return;
}
expect(Ok, stat);
stat = GdipCreateFont(fontfamily, 30, FontStyleRegular, UnitPixel, &font);
expect(Ok, stat);
stat = GdipGetFontHeightGivenDPI(NULL, 96, &height);
expect(InvalidParameter, stat);
stat = GdipGetFontHeightGivenDPI(font, 96, NULL);
expect(InvalidParameter, stat);
stat = GdipGetFontHeightGivenDPI(font, 96, &height);
expect(Ok, stat);
expectf((REAL)34.497070, height);
GdipDeleteFont(font);
height = 12345;
stat = GdipCreateFont(fontfamily, 30, FontStyleRegular, UnitWorld, &font);
expect(Ok, stat);
stat = GdipGetFontHeightGivenDPI(font, 96, &height);
expect(Ok, stat);
expectf((REAL)34.497070, height);
GdipDeleteFont(font);
height = 12345;
stat = GdipCreateFont(fontfamily, 30, FontStyleRegular, UnitPoint, &font);
expect(Ok, stat);
stat = GdipGetFontHeightGivenDPI(font, 96, &height);
expect(Ok, stat);
expectf((REAL)45.996094, height);
GdipDeleteFont(font);
height = 12345;
stat = GdipCreateFont(fontfamily, 30, FontStyleRegular, UnitInch, &font);
expect(Ok, stat);
stat = GdipGetFontHeightGivenDPI(font, 96, &height);
expect(Ok, stat);
expectf((REAL)3311.718750, height);
GdipDeleteFont(font);
height = 12345;
stat = GdipCreateFont(fontfamily, 30, FontStyleRegular, UnitDocument, &font);
expect(Ok, stat);
stat = GdipGetFontHeightGivenDPI(font, 96, &height);
expect(Ok, stat);
expectf((REAL)11.039062, height);
GdipDeleteFont(font);
height = 12345;
stat = GdipCreateFont(fontfamily, 30, FontStyleRegular, UnitMillimeter, &font);
expect(Ok, stat);
stat = GdipGetFontHeightGivenDPI(font, 96, &height);
expect(Ok, stat);
expectf((REAL)130.382614, height);
GdipDeleteFont(font);
GdipDeleteFontFamily(fontfamily);
}
START_TEST(font)
{
struct GdiplusStartupInput gdiplusStartupInput;
@ -363,6 +435,7 @@ START_TEST(font)
test_fontfamily_properties();
test_getgenerics();
test_installedfonts();
test_heightgivendpi();
GdiplusShutdown(gdiplusToken);
}

View file

@ -25,14 +25,17 @@
#include <math.h>
#define expect(expected, got) ok(got == expected, "Expected %.8x, got %.8x\n", expected, got)
#define expectf(expected, got) ok(fabs(expected - got) < 0.0001, "Expected %.2f, got %.2f\n", expected, got)
#define expectf_(expected, got, precision) ok(fabs(expected - got) < precision, "Expected %.2f, got %.2f\n", expected, got)
#define expectf(expected, got) expectf_(expected, got, 0.0001)
#define TABLE_LEN (23)
static HWND hwnd;
static void test_constructor_destructor(void)
{
GpStatus stat;
GpGraphics *graphics = NULL;
HDC hdc = GetDC(0);
HDC hdc = GetDC( hwnd );
stat = GdipCreateFromHDC(NULL, &graphics);
expect(OutOfMemory, stat);
@ -56,7 +59,7 @@ static void test_constructor_destructor(void)
stat = GdipDeleteGraphics(NULL);
expect(InvalidParameter, stat);
ReleaseDC(0, hdc);
ReleaseDC(hwnd, hdc);
}
typedef struct node{
@ -115,7 +118,7 @@ static void test_save_restore(void)
InterpolationMode mode;
GpGraphics *graphics1, *graphics2;
node * state_log = NULL;
HDC hdc = GetDC(0);
HDC hdc = GetDC( hwnd );
state_a = state_b = state_c = 0xdeadbeef;
/* Invalid saving. */
@ -224,7 +227,7 @@ static void test_save_restore(void)
todo_wine
check_no_duplicates(state_log);
ReleaseDC(0, hdc);
ReleaseDC(hwnd, hdc);
}
static void test_GdipDrawArc(void)
@ -232,7 +235,7 @@ static void test_GdipDrawArc(void)
GpStatus status;
GpGraphics *graphics = NULL;
GpPen *pen = NULL;
HDC hdc = GetDC(0);
HDC hdc = GetDC( hwnd );
/* make a graphics object and pen object */
ok(hdc != NULL, "Expected HDC to be initialized\n");
@ -268,7 +271,7 @@ static void test_GdipDrawArc(void)
GdipDeletePen(pen);
GdipDeleteGraphics(graphics);
ReleaseDC(0, hdc);
ReleaseDC(hwnd, hdc);
}
static void test_GdipDrawArcI(void)
@ -276,7 +279,7 @@ static void test_GdipDrawArcI(void)
GpStatus status;
GpGraphics *graphics = NULL;
GpPen *pen = NULL;
HDC hdc = GetDC(0);
HDC hdc = GetDC( hwnd );
/* make a graphics object and pen object */
ok(hdc != NULL, "Expected HDC to be initialized\n");
@ -312,7 +315,7 @@ static void test_GdipDrawArcI(void)
GdipDeletePen(pen);
GdipDeleteGraphics(graphics);
ReleaseDC(0, hdc);
ReleaseDC(hwnd, hdc);
}
static void test_BeginContainer2(void)
@ -334,7 +337,7 @@ static void test_BeginContainer2(void)
GpStatus status;
GpGraphics *graphics = NULL;
HDC hdc = GetDC(0);
HDC hdc = GetDC( hwnd );
ok(hdc != NULL, "Expected HDC to be initialized\n");
@ -497,7 +500,7 @@ static void test_BeginContainer2(void)
expect(Ok, status);
GdipDeleteGraphics(graphics);
ReleaseDC(0, hdc);
ReleaseDC(hwnd, hdc);
}
static void test_GdipDrawBezierI(void)
@ -505,7 +508,7 @@ static void test_GdipDrawBezierI(void)
GpStatus status;
GpGraphics *graphics = NULL;
GpPen *pen = NULL;
HDC hdc = GetDC(0);
HDC hdc = GetDC( hwnd );
/* make a graphics object and pen object */
ok(hdc != NULL, "Expected HDC to be initialized\n");
@ -535,7 +538,7 @@ static void test_GdipDrawBezierI(void)
GdipDeletePen(pen);
GdipDeleteGraphics(graphics);
ReleaseDC(0, hdc);
ReleaseDC(hwnd, hdc);
}
static void test_GdipDrawCurve3(void)
@ -543,7 +546,7 @@ static void test_GdipDrawCurve3(void)
GpStatus status;
GpGraphics *graphics = NULL;
GpPen *pen = NULL;
HDC hdc = GetDC(0);
HDC hdc = GetDC( hwnd );
GpPointF points[3];
points[0].X = 0;
@ -615,7 +618,7 @@ static void test_GdipDrawCurve3(void)
GdipDeletePen(pen);
GdipDeleteGraphics(graphics);
ReleaseDC(0, hdc);
ReleaseDC(hwnd, hdc);
}
static void test_GdipDrawCurve3I(void)
@ -623,7 +626,7 @@ static void test_GdipDrawCurve3I(void)
GpStatus status;
GpGraphics *graphics = NULL;
GpPen *pen = NULL;
HDC hdc = GetDC(0);
HDC hdc = GetDC( hwnd );
GpPoint points[3];
points[0].X = 0;
@ -695,7 +698,7 @@ static void test_GdipDrawCurve3I(void)
GdipDeletePen(pen);
GdipDeleteGraphics(graphics);
ReleaseDC(0, hdc);
ReleaseDC(hwnd, hdc);
}
static void test_GdipDrawCurve2(void)
@ -703,7 +706,7 @@ static void test_GdipDrawCurve2(void)
GpStatus status;
GpGraphics *graphics = NULL;
GpPen *pen = NULL;
HDC hdc = GetDC(0);
HDC hdc = GetDC( hwnd );
GpPointF points[3];
points[0].X = 0;
@ -762,7 +765,7 @@ static void test_GdipDrawCurve2(void)
GdipDeletePen(pen);
GdipDeleteGraphics(graphics);
ReleaseDC(0, hdc);
ReleaseDC(hwnd, hdc);
}
static void test_GdipDrawCurve2I(void)
@ -770,7 +773,7 @@ static void test_GdipDrawCurve2I(void)
GpStatus status;
GpGraphics *graphics = NULL;
GpPen *pen = NULL;
HDC hdc = GetDC(0);
HDC hdc = GetDC( hwnd );
GpPoint points[3];
points[0].X = 0;
@ -829,7 +832,7 @@ static void test_GdipDrawCurve2I(void)
GdipDeletePen(pen);
GdipDeleteGraphics(graphics);
ReleaseDC(0, hdc);
ReleaseDC(hwnd, hdc);
}
static void test_GdipDrawCurve(void)
@ -837,7 +840,7 @@ static void test_GdipDrawCurve(void)
GpStatus status;
GpGraphics *graphics = NULL;
GpPen *pen = NULL;
HDC hdc = GetDC(0);
HDC hdc = GetDC( hwnd );
GpPointF points[3];
points[0].X = 0;
@ -890,7 +893,7 @@ static void test_GdipDrawCurve(void)
GdipDeletePen(pen);
GdipDeleteGraphics(graphics);
ReleaseDC(0, hdc);
ReleaseDC(hwnd, hdc);
}
static void test_GdipDrawCurveI(void)
@ -898,7 +901,7 @@ static void test_GdipDrawCurveI(void)
GpStatus status;
GpGraphics *graphics = NULL;
GpPen *pen = NULL;
HDC hdc = GetDC(0);
HDC hdc = GetDC( hwnd );
GpPoint points[3];
points[0].X = 0;
@ -951,7 +954,7 @@ static void test_GdipDrawCurveI(void)
GdipDeletePen(pen);
GdipDeleteGraphics(graphics);
ReleaseDC(0, hdc);
ReleaseDC(hwnd, hdc);
}
static void test_GdipDrawLineI(void)
@ -959,7 +962,7 @@ static void test_GdipDrawLineI(void)
GpStatus status;
GpGraphics *graphics = NULL;
GpPen *pen = NULL;
HDC hdc = GetDC(0);
HDC hdc = GetDC( hwnd );
/* make a graphics object and pen object */
ok(hdc != NULL, "Expected HDC to be initialized\n");
@ -989,7 +992,7 @@ static void test_GdipDrawLineI(void)
GdipDeletePen(pen);
GdipDeleteGraphics(graphics);
ReleaseDC(0, hdc);
ReleaseDC(hwnd, hdc);
}
static void test_GdipDrawLinesI(void)
@ -998,7 +1001,7 @@ static void test_GdipDrawLinesI(void)
GpGraphics *graphics = NULL;
GpPen *pen = NULL;
GpPoint *ptf = NULL;
HDC hdc = GetDC(0);
HDC hdc = GetDC( hwnd );
/* make a graphics object and pen object */
ok(hdc != NULL, "Expected HDC to be initialized\n");
@ -1041,7 +1044,7 @@ static void test_GdipDrawLinesI(void)
GdipDeletePen(pen);
GdipDeleteGraphics(graphics);
ReleaseDC(0, hdc);
ReleaseDC(hwnd, hdc);
}
static void test_Get_Release_DC(void)
@ -1051,7 +1054,7 @@ static void test_Get_Release_DC(void)
GpPen *pen;
GpSolidFill *brush;
GpPath *path;
HDC hdc = GetDC(0);
HDC hdc = GetDC( hwnd );
HDC retdc;
REAL r;
CompositingQuality quality;
@ -1345,14 +1348,14 @@ static void test_Get_Release_DC(void)
GdipDeleteMatrix(m);
DeleteObject(hrgn);
ReleaseDC(0, hdc);
ReleaseDC(hwnd, hdc);
}
static void test_transformpoints(void)
{
GpStatus status;
GpGraphics *graphics = NULL;
HDC hdc = GetDC(0);
HDC hdc = GetDC( hwnd );
GpPointF ptf[2];
GpPoint pt[2];
@ -1465,14 +1468,14 @@ static void test_transformpoints(void)
expect(18, pt[1].Y);
GdipDeleteGraphics(graphics);
ReleaseDC(0, hdc);
ReleaseDC(hwnd, hdc);
}
static void test_get_set_clip(void)
{
GpStatus status;
GpGraphics *graphics = NULL;
HDC hdc = GetDC(0);
HDC hdc = GetDC( hwnd );
GpRegion *clip;
GpRectF rect;
BOOL res;
@ -1544,14 +1547,14 @@ static void test_get_set_clip(void)
GdipDeleteRegion(clip);
GdipDeleteGraphics(graphics);
ReleaseDC(0, hdc);
ReleaseDC(hwnd, hdc);
}
static void test_isempty(void)
{
GpStatus status;
GpGraphics *graphics = NULL;
HDC hdc = GetDC(0);
HDC hdc = GetDC( hwnd );
GpRegion *clip;
BOOL res;
@ -1578,7 +1581,7 @@ static void test_isempty(void)
GdipDeleteRegion(clip);
GdipDeleteGraphics(graphics);
ReleaseDC(0, hdc);
ReleaseDC(hwnd, hdc);
}
static void test_clear(void)
@ -1592,7 +1595,7 @@ static void test_clear(void)
static void test_textcontrast(void)
{
GpStatus status;
HDC hdc = GetDC(0);
HDC hdc = GetDC( hwnd );
GpGraphics *graphics;
UINT contrast;
@ -1608,7 +1611,7 @@ static void test_textcontrast(void)
expect(4, contrast);
GdipDeleteGraphics(graphics);
ReleaseDC(0, hdc);
ReleaseDC(hwnd, hdc);
}
static void test_GdipDrawString(void)
@ -1620,7 +1623,7 @@ static void test_GdipDrawString(void)
GpStringFormat *format;
GpBrush *brush;
LOGFONTA logfont;
HDC hdc = GetDC(0);
HDC hdc = GetDC( hwnd );
static const WCHAR string[] = {'T','e','s','t',0};
memset(&logfont,0,sizeof(logfont));
@ -1658,7 +1661,7 @@ static void test_GdipDrawString(void)
GdipDeleteFont(fnt);
GdipDeleteStringFormat(format);
ReleaseDC(0, hdc);
ReleaseDC(hwnd, hdc);
}
static void test_GdipGetVisibleClipBounds_screen(void)
@ -1758,36 +1761,10 @@ static void test_GdipGetVisibleClipBounds_window(void)
GpGraphics *graphics = NULL;
GpRectF rectf, window, exp, clipr;
GpRect recti;
HWND hwnd;
WNDCLASSA class;
HDC hdc;
PAINTSTRUCT ps;
HINSTANCE hInstance = GetModuleHandle(NULL);
RECT wnd_rect;
window.X = 0;
window.Y = 0;
window.Width = 200;
window.Height = 300;
class.lpszClassName = "ClipBoundsTestClass";
class.style = CS_HREDRAW | CS_VREDRAW;
class.lpfnWndProc = DefWindowProcA;
class.hInstance = hInstance;
class.hIcon = LoadIcon(0, IDI_APPLICATION);
class.hCursor = LoadCursor(NULL, IDC_ARROW);
class.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
class.lpszMenuName = 0;
class.cbClsExtra = 0;
class.cbWndExtra = 0;
RegisterClass(&class);
hwnd = CreateWindow(class.lpszClassName, "ClipboundsTest",
WS_OVERLAPPEDWINDOW, window.X, window.Y, window.Width, window.Height,
NULL, NULL, hInstance, NULL);
ok(hwnd != NULL, "Expected window to be created\n");
/* get client area size */
ok(GetClientRect(hwnd, &wnd_rect), "GetClientRect should have succeeded\n");
window.X = wnd_rect.left;
@ -1870,7 +1847,6 @@ static void test_GdipGetVisibleClipBounds_window(void)
GdipDeleteGraphics(graphics);
EndPaint(hwnd, &ps);
DestroyWindow(hwnd);
}
static void test_GdipGetVisibleClipBounds(void)
@ -1878,7 +1854,7 @@ static void test_GdipGetVisibleClipBounds(void)
GpGraphics* graphics = NULL;
GpRectF rectf;
GpRect rect;
HDC hdc = GetDC(0);
HDC hdc = GetDC( hwnd );
GpStatus status;
status = GdipCreateFromHDC(hdc, &graphics);
@ -1899,7 +1875,7 @@ static void test_GdipGetVisibleClipBounds(void)
expect(InvalidParameter, status);
GdipDeleteGraphics(graphics);
ReleaseDC(0, hdc);
ReleaseDC(hwnd, hdc);
test_GdipGetVisibleClipBounds_screen();
test_GdipGetVisibleClipBounds_window();
@ -1933,7 +1909,7 @@ static void test_GdipIsVisiblePoint(void)
{
GpStatus status;
GpGraphics *graphics = NULL;
HDC hdc = GetDC(0);
HDC hdc = GetDC( hwnd );
REAL x, y;
BOOL val;
@ -2105,14 +2081,14 @@ static void test_GdipIsVisiblePoint(void)
ok(val == FALSE, "After clipping, expected (%.2f, %.2f) not to be visible\n", x, y);
GdipDeleteGraphics(graphics);
ReleaseDC(0, hdc);
ReleaseDC(hwnd, hdc);
}
static void test_GdipIsVisibleRect(void)
{
GpStatus status;
GpGraphics *graphics = NULL;
HDC hdc = GetDC(0);
HDC hdc = GetDC( hwnd );
REAL x, y, width, height;
BOOL val;
@ -2267,7 +2243,7 @@ static void test_GdipIsVisibleRect(void)
ok(val == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, width, height);
GdipDeleteGraphics(graphics);
ReleaseDC(0, hdc);
ReleaseDC(hwnd, hdc);
}
static void test_GdipGetNearestColor(void)
@ -2276,7 +2252,7 @@ static void test_GdipGetNearestColor(void)
GpGraphics *graphics;
GpBitmap *bitmap;
ARGB color = 0xdeadbeef;
HDC hdc = GetDC(0);
HDC hdc = GetDC( hwnd );
/* create a graphics object */
ok(hdc != NULL, "Expected HDC to be initialized\n");
@ -2415,17 +2391,269 @@ static void test_GdipGetNearestColor(void)
expect(Ok, status);
status = GdipGetNearestColor(graphics, &color);
expect(Ok, status);
todo_wine expect(0xffa8b8e8, color);
todo_wine
ok(color == 0xffa8b8e8 ||
broken(color == 0xffa0b8e0), /* Win98/WinMe */
"Expected ffa8b8e8, got %.8x\n", color);
GdipDeleteGraphics(graphics);
GdipDisposeImage((GpImage*)bitmap);
ReleaseDC(0, hdc);
ReleaseDC(hwnd, hdc);
}
static void test_string_functions(void)
{
GpStatus status;
GpGraphics *graphics;
GpFontFamily *family;
GpFont *font;
RectF rc, char_bounds, bounds;
GpBrush *brush;
ARGB color = 0xff000000;
HDC hdc = GetDC( hwnd );
const WCHAR fontname[] = {'C','o','u','r','i','e','r',' ','N','e','w',0};
const WCHAR fontname2[] = {'C','o','u','r','i','e','r',0};
const WCHAR teststring[] = {'o','o',' ','o','\n','o',0};
REAL char_width, char_height;
INT codepointsfitted, linesfilled;
GpStringFormat *format;
CharacterRange ranges[3] = {{0, 1}, {1, 3}, {5, 1}};
GpRegion *regions[4] = {0};
BOOL region_isempty[4];
int i;
ok(hdc != NULL, "Expected HDC to be initialized\n");
status = GdipCreateFromHDC(hdc, &graphics);
expect(Ok, status);
ok(graphics != NULL, "Expected graphics to be initialized\n");
status = GdipCreateFontFamilyFromName(fontname, NULL, &family);
if (status != Ok)
{
/* Wine doesn't have Courier New? */
todo_wine expect(Ok, status);
status = GdipCreateFontFamilyFromName(fontname2, NULL, &family);
}
expect(Ok, status);
status = GdipCreateFont(family, 10.0, FontStyleRegular, UnitPixel, &font);
expect(Ok, status);
status = GdipCreateSolidFill(color, (GpSolidFill**)&brush);
expect(Ok, status);
status = GdipCreateStringFormat(0, LANG_NEUTRAL, &format);
expect(Ok, status);
rc.X = 0;
rc.Y = 0;
rc.Width = 100.0;
rc.Height = 100.0;
status = GdipDrawString(NULL, teststring, 6, font, &rc, NULL, brush);
expect(InvalidParameter, status);
status = GdipDrawString(graphics, NULL, 6, font, &rc, NULL, brush);
expect(InvalidParameter, status);
status = GdipDrawString(graphics, teststring, 6, NULL, &rc, NULL, brush);
expect(InvalidParameter, status);
status = GdipDrawString(graphics, teststring, 6, font, NULL, NULL, brush);
expect(InvalidParameter, status);
status = GdipDrawString(graphics, teststring, 6, font, &rc, NULL, NULL);
expect(InvalidParameter, status);
status = GdipDrawString(graphics, teststring, 6, font, &rc, NULL, brush);
expect(Ok, status);
status = GdipMeasureString(NULL, teststring, 6, font, &rc, NULL, &bounds, &codepointsfitted, &linesfilled);
expect(InvalidParameter, status);
status = GdipMeasureString(graphics, NULL, 6, font, &rc, NULL, &bounds, &codepointsfitted, &linesfilled);
expect(InvalidParameter, status);
status = GdipMeasureString(graphics, teststring, 6, NULL, &rc, NULL, &bounds, &codepointsfitted, &linesfilled);
expect(InvalidParameter, status);
status = GdipMeasureString(graphics, teststring, 6, font, NULL, NULL, &bounds, &codepointsfitted, &linesfilled);
expect(InvalidParameter, status);
status = GdipMeasureString(graphics, teststring, 6, font, &rc, NULL, NULL, &codepointsfitted, &linesfilled);
expect(InvalidParameter, status);
status = GdipMeasureString(graphics, teststring, 6, font, &rc, NULL, &bounds, NULL, &linesfilled);
expect(Ok, status);
status = GdipMeasureString(graphics, teststring, 6, font, &rc, NULL, &bounds, &codepointsfitted, NULL);
expect(Ok, status);
status = GdipMeasureString(graphics, teststring, 1, font, &rc, NULL, &char_bounds, &codepointsfitted, &linesfilled);
expect(Ok, status);
expectf(0.0, char_bounds.X);
expectf(0.0, char_bounds.Y);
ok(char_bounds.Width > 0, "got %0.2f\n", bounds.Width);
ok(char_bounds.Height > 0, "got %0.2f\n", bounds.Height);
expect(1, codepointsfitted);
expect(1, linesfilled);
status = GdipMeasureString(graphics, teststring, 2, font, &rc, NULL, &bounds, &codepointsfitted, &linesfilled);
expect(Ok, status);
expectf(0.0, bounds.X);
expectf(0.0, bounds.Y);
ok(bounds.Width > char_bounds.Width, "got %0.2f, expected at least %0.2f\n", bounds.Width, char_bounds.Width);
expectf(char_bounds.Height, bounds.Height);
expect(2, codepointsfitted);
expect(1, linesfilled);
char_width = bounds.Width - char_bounds.Width;
status = GdipMeasureString(graphics, teststring, 6, font, &rc, NULL, &bounds, &codepointsfitted, &linesfilled);
expect(Ok, status);
expectf(0.0, bounds.X);
expectf(0.0, bounds.Y);
expectf_(char_bounds.Width + char_width * 3, bounds.Width, 0.01);
ok(bounds.Height > char_bounds.Height, "got %0.2f, expected at least %0.2f\n", bounds.Height, char_bounds.Height);
expect(6, codepointsfitted);
expect(2, linesfilled);
char_height = bounds.Height - char_bounds.Height;
/* Cut off everything after the first space. */
rc.Width = char_bounds.Width + char_width * 2.5;
status = GdipMeasureString(graphics, teststring, 6, font, &rc, NULL, &bounds, &codepointsfitted, &linesfilled);
expect(Ok, status);
expectf(0.0, bounds.X);
expectf(0.0, bounds.Y);
expectf_(char_bounds.Width + char_width, bounds.Width, 0.01);
expectf_(char_bounds.Height + char_height * 2, bounds.Height, 0.01);
expect(6, codepointsfitted);
expect(3, linesfilled);
/* Cut off everything including the first space. */
rc.Width = char_bounds.Width + char_width * 1.5;
status = GdipMeasureString(graphics, teststring, 6, font, &rc, NULL, &bounds, &codepointsfitted, &linesfilled);
expect(Ok, status);
expectf(0.0, bounds.X);
expectf(0.0, bounds.Y);
expectf_(char_bounds.Width + char_width, bounds.Width, 0.01);
expectf_(char_bounds.Height + char_height * 2, bounds.Height, 0.01);
expect(6, codepointsfitted);
expect(3, linesfilled);
/* Cut off everything after the first character. */
rc.Width = char_bounds.Width + char_width * 0.5;
status = GdipMeasureString(graphics, teststring, 6, font, &rc, NULL, &bounds, &codepointsfitted, &linesfilled);
expect(Ok, status);
expectf(0.0, bounds.X);
expectf(0.0, bounds.Y);
expectf_(char_bounds.Width, bounds.Width, 0.01);
todo_wine expectf_(char_bounds.Height + char_height * 3, bounds.Height, 0.05);
expect(6, codepointsfitted);
todo_wine expect(4, linesfilled);
status = GdipSetStringFormatMeasurableCharacterRanges(format, 3, ranges);
expect(Ok, status);
rc.Width = 100.0;
for (i=0; i<4; i++)
{
status = GdipCreateRegion(&regions[i]);
expect(Ok, status);
}
status = GdipMeasureCharacterRanges(NULL, teststring, 6, font, &rc, format, 3, regions);
expect(InvalidParameter, status);
status = GdipMeasureCharacterRanges(graphics, NULL, 6, font, &rc, format, 3, regions);
expect(InvalidParameter, status);
status = GdipMeasureCharacterRanges(graphics, teststring, 6, NULL, &rc, format, 3, regions);
expect(InvalidParameter, status);
status = GdipMeasureCharacterRanges(graphics, teststring, 6, font, NULL, format, 3, regions);
expect(InvalidParameter, status);
if (0)
{
/* Crashes on Windows XP */
status = GdipMeasureCharacterRanges(graphics, teststring, 6, font, &rc, NULL, 3, regions);
expect(InvalidParameter, status);
}
status = GdipMeasureCharacterRanges(graphics, teststring, 6, font, &rc, format, 3, NULL);
expect(InvalidParameter, status);
status = GdipMeasureCharacterRanges(graphics, teststring, 6, font, &rc, format, 2, regions);
expect(InvalidParameter, status);
status = GdipMeasureCharacterRanges(graphics, teststring, 6, font, &rc, format, 4, regions);
expect(Ok, status);
for (i=0; i<4; i++)
{
status = GdipIsEmptyRegion(regions[i], graphics, &region_isempty[i]);
expect(Ok, status);
}
ok(!region_isempty[0], "region shouldn't be empty\n");
ok(!region_isempty[1], "region shouldn't be empty\n");
ok(!region_isempty[2], "region shouldn't be empty\n");
ok(!region_isempty[3], "region shouldn't be empty\n");
/* Cut off everything after the first space, and the second line. */
rc.Width = char_bounds.Width + char_width * 2.5;
rc.Height = char_bounds.Height + char_height * 0.5;
status = GdipMeasureCharacterRanges(graphics, teststring, 6, font, &rc, format, 3, regions);
expect(Ok, status);
for (i=0; i<4; i++)
{
status = GdipIsEmptyRegion(regions[i], graphics, &region_isempty[i]);
expect(Ok, status);
}
ok(!region_isempty[0], "region shouldn't be empty\n");
ok(!region_isempty[1], "region shouldn't be empty\n");
ok(region_isempty[2], "region should be empty\n");
ok(!region_isempty[3], "region shouldn't be empty\n");
for (i=0; i<4; i++)
GdipDeleteRegion(regions[i]);
GdipDeleteStringFormat(format);
GdipDeleteBrush(brush);
GdipDeleteFont(font);
GdipDeleteFontFamily(family);
GdipDeleteGraphics(graphics);
ReleaseDC(hwnd, hdc);
}
START_TEST(graphics)
{
struct GdiplusStartupInput gdiplusStartupInput;
ULONG_PTR gdiplusToken;
WNDCLASSA class;
memset( &class, 0, sizeof(class) );
class.lpszClassName = "gdiplus_test";
class.style = CS_HREDRAW | CS_VREDRAW;
class.lpfnWndProc = DefWindowProcA;
class.hInstance = GetModuleHandleA(0);
class.hIcon = LoadIcon(0, IDI_APPLICATION);
class.hCursor = LoadCursor(NULL, IDC_ARROW);
class.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
RegisterClassA( &class );
hwnd = CreateWindowA( "gdiplus_test", "graphics test", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
CW_USEDEFAULT, CW_USEDEFAULT, 200, 200, 0, 0, GetModuleHandleA(0), 0 );
ok(hwnd != NULL, "Expected window to be created\n");
gdiplusStartupInput.GdiplusVersion = 1;
gdiplusStartupInput.DebugEventCallback = NULL;
@ -2460,6 +2688,8 @@ START_TEST(graphics)
test_clear();
test_textcontrast();
test_fromMemoryBitmap();
test_string_functions();
GdiplusShutdown(gdiplusToken);
DestroyWindow( hwnd );
}

View file

@ -226,10 +226,23 @@ static void test_GdipImageGetFrameDimensionsCount(void)
stat = GdipImageGetFrameDimensionsList((GpImage*)bm, &dimension, 0);
expect(InvalidParameter, stat);
stat = GdipImageGetFrameCount(NULL, &dimension, &count);
expect(InvalidParameter, stat);
/* WinXP crashes on this test */
if(0)
{
stat = GdipImageGetFrameCount((GpImage*)bm, &dimension, NULL);
expect(InvalidParameter, stat);
}
stat = GdipImageGetFrameCount((GpImage*)bm, NULL, &count);
expect(Ok, stat);
count = 12345;
stat = GdipImageGetFrameCount((GpImage*)bm, &dimension, &count);
todo_wine expect(Ok, stat);
todo_wine expect(1, count);
expect(Ok, stat);
expect(1, count);
GdipBitmapSetPixel(bm, 0, 0, 0xffffffff);
@ -793,6 +806,26 @@ static const unsigned char jpgimage[285] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xda,0x00,0x0c,0x03,0x01,
0x00,0x02,0x11,0x03,0x11,0x00,0x3f,0x00,0xb2,0xc0,0x07,0xff,0xd9
};
/* 1x1 pixel tiff */
static const unsigned char tiffimage[] = {
0x49,0x49,0x2a,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0xfe,0x00,
0x04,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x03,0x00,0x01,0x00,
0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x01,0x03,0x00,0x01,0x00,0x00,0x00,0x01,0x00,
0x00,0x00,0x02,0x01,0x03,0x00,0x03,0x00,0x00,0x00,0xd2,0x00,0x00,0x00,0x03,0x01,
0x03,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x06,0x01,0x03,0x00,0x01,0x00,
0x00,0x00,0x02,0x00,0x00,0x00,0x0d,0x01,0x02,0x00,0x1b,0x00,0x00,0x00,0xd8,0x00,
0x00,0x00,0x11,0x01,0x04,0x00,0x01,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x12,0x01,
0x03,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x15,0x01,0x03,0x00,0x01,0x00,
0x00,0x00,0x03,0x00,0x00,0x00,0x16,0x01,0x03,0x00,0x01,0x00,0x00,0x00,0x40,0x00,
0x00,0x00,0x17,0x01,0x04,0x00,0x01,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x1a,0x01,
0x05,0x00,0x01,0x00,0x00,0x00,0xf4,0x00,0x00,0x00,0x1b,0x01,0x05,0x00,0x01,0x00,
0x00,0x00,0xfc,0x00,0x00,0x00,0x1c,0x01,0x03,0x00,0x01,0x00,0x00,0x00,0x01,0x00,
0x00,0x00,0x28,0x01,0x03,0x00,0x01,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x2f,0x68,0x6f,0x6d,0x65,0x2f,0x6d,0x65,
0x68,0x2f,0x44,0x65,0x73,0x6b,0x74,0x6f,0x70,0x2f,0x74,0x65,0x73,0x74,0x2e,0x74,
0x69,0x66,0x00,0x00,0x00,0x00,0x00,0x48,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x48,
0x00,0x00,0x00,0x01
};
/* 320x320 twip wmf */
static const unsigned char wmfimage[180] = {
0xd7,0xcd,0xc6,0x9a,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x01,0x40,0x01,0xa0,0x05,
@ -814,6 +847,7 @@ static void test_getrawformat(void)
test_bufferrawformat((void*)gifimage, sizeof(gifimage), &ImageFormatGIF, __LINE__, FALSE);
test_bufferrawformat((void*)bmpimage, sizeof(bmpimage), &ImageFormatBMP, __LINE__, FALSE);
test_bufferrawformat((void*)jpgimage, sizeof(jpgimage), &ImageFormatJPEG, __LINE__, FALSE);
test_bufferrawformat((void*)tiffimage, sizeof(tiffimage), &ImageFormatTIFF, __LINE__, FALSE);
test_bufferrawformat((void*)wmfimage, sizeof(wmfimage), &ImageFormatWMF, __LINE__, FALSE);
}
@ -828,6 +862,7 @@ static void test_loadwmf(void)
GpRectF bounds;
GpUnit unit;
REAL res = 12345.0;
MetafileHeader header;
hglob = GlobalAlloc (0, sizeof(wmfimage));
data = GlobalLock (hglob);
@ -863,6 +898,27 @@ static void test_loadwmf(void)
expect(Ok, stat);
todo_wine expectf(1440.0, res);
memset(&header, 0, sizeof(header));
stat = GdipGetMetafileHeaderFromMetafile((GpMetafile*)img, &header);
expect(Ok, stat);
if (stat == Ok)
{
todo_wine expect(MetafileTypeWmfPlaceable, header.Type);
todo_wine expect(sizeof(wmfimage)-sizeof(WmfPlaceableFileHeader), header.Size);
todo_wine expect(0x300, header.Version);
expect(0, header.EmfPlusFlags);
todo_wine expectf(1440.0, header.DpiX);
todo_wine expectf(1440.0, header.DpiY);
expect(0, header.X);
expect(0, header.Y);
todo_wine expect(320, header.Width);
todo_wine expect(320, header.Height);
todo_wine expect(1, U(header).WmfHeader.mtType);
expect(0, header.EmfPlusHeaderSize);
expect(0, header.LogicalDpiX);
expect(0, header.LogicalDpiY);
}
GdipDisposeImage(img);
}
@ -874,6 +930,7 @@ static void test_createfromwmf(void)
GpRectF bounds;
GpUnit unit;
REAL res = 12345.0;
MetafileHeader header;
hwmf = SetMetaFileBitsEx(sizeof(wmfimage)-sizeof(WmfPlaceableFileHeader),
wmfimage+sizeof(WmfPlaceableFileHeader));
@ -885,11 +942,11 @@ static void test_createfromwmf(void)
stat = GdipGetImageBounds(img, &bounds, &unit);
expect(Ok, stat);
todo_wine expect(UnitPixel, unit);
expect(UnitPixel, unit);
expectf(0.0, bounds.X);
expectf(0.0, bounds.Y);
todo_wine expectf(320.0, bounds.Width);
todo_wine expectf(320.0, bounds.Height);
expectf(320.0, bounds.Width);
expectf(320.0, bounds.Height);
stat = GdipGetImageHorizontalResolution(img, &res);
expect(Ok, stat);
@ -899,6 +956,27 @@ static void test_createfromwmf(void)
expect(Ok, stat);
expectf(1440.0, res);
memset(&header, 0, sizeof(header));
stat = GdipGetMetafileHeaderFromMetafile((GpMetafile*)img, &header);
expect(Ok, stat);
if (stat == Ok)
{
todo_wine expect(MetafileTypeWmfPlaceable, header.Type);
todo_wine expect(sizeof(wmfimage)-sizeof(WmfPlaceableFileHeader), header.Size);
todo_wine expect(0x300, header.Version);
expect(0, header.EmfPlusFlags);
todo_wine expectf(1440.0, header.DpiX);
todo_wine expectf(1440.0, header.DpiY);
expect(0, header.X);
expect(0, header.Y);
todo_wine expect(320, header.Width);
todo_wine expect(320, header.Height);
todo_wine expect(1, U(header).WmfHeader.mtType);
expect(0, header.EmfPlusHeaderSize);
expect(0, header.LogicalDpiX);
expect(0, header.LogicalDpiY);
}
GdipDisposeImage(img);
}
@ -1544,7 +1622,7 @@ static void test_multiframegif(void)
count = 12345;
stat = GdipImageGetFrameCount((GpImage*)bmp, &dimension, &count);
todo_wine expect(Ok, stat);
expect(Ok, stat);
todo_wine expect(2, count);
/* SelectActiveFrame overwrites our current data */
@ -1618,8 +1696,8 @@ static void test_multiframegif(void)
count = 12345;
stat = GdipImageGetFrameCount((GpImage*)bmp, &dimension, &count);
todo_wine expect(Ok, stat);
todo_wine expect(1, count);
expect(Ok, stat);
expect(1, count);
GdipDisposeImage((GpImage*)bmp);
IStream_Release(stream);
@ -1641,30 +1719,30 @@ static void test_rotateflip(void)
expect(Ok, stat);
stat = GdipImageRotateFlip(bitmap, Rotate90FlipNone);
todo_wine expect(Ok, stat);
expect(Ok, stat);
stat = GdipGetImageWidth(bitmap, &width);
expect(Ok, stat);
stat = GdipGetImageHeight(bitmap, &height);
expect(Ok, stat);
todo_wine expect(2, width);
todo_wine expect(3, height);
expect(2, width);
expect(3, height);
stat = GdipBitmapGetPixel((GpBitmap*)bitmap, 0, 0, &color);
expect(Ok, stat);
todo_wine expect(0xff00ffff, color);
expect(0xff00ffff, color);
stat = GdipBitmapGetPixel((GpBitmap*)bitmap, 1, 0, &color);
expect(Ok, stat);
todo_wine expect(0xffff0000, color);
expect(0xffff0000, color);
stat = GdipBitmapGetPixel((GpBitmap*)bitmap, 0, 2, &color);
todo_wine expect(Ok, stat);
todo_wine expect(0xffffff00, color);
expect(Ok, stat);
expect(0xffffff00, color);
stat = GdipBitmapGetPixel((GpBitmap*)bitmap, 1, 2, &color);
todo_wine expect(Ok, stat);
todo_wine expect(0xff0000ff, color);
expect(Ok, stat);
expect(0xff0000ff, color);
expect(0, bits[0]);
expect(0, bits[1]);
@ -1677,7 +1755,7 @@ static void test_rotateflip(void)
expect(Ok, stat);
stat = GdipImageRotateFlip(bitmap, RotateNoneFlipX);
todo_wine expect(Ok, stat);
expect(Ok, stat);
stat = GdipGetImageWidth(bitmap, &width);
expect(Ok, stat);
@ -1688,19 +1766,19 @@ static void test_rotateflip(void)
stat = GdipBitmapGetPixel((GpBitmap*)bitmap, 0, 0, &color);
expect(Ok, stat);
todo_wine expect(0xff0000ff, color);
expect(0xff0000ff, color);
stat = GdipBitmapGetPixel((GpBitmap*)bitmap, 2, 0, &color);
expect(Ok, stat);
todo_wine expect(0xffff0000, color);
expect(0xffff0000, color);
stat = GdipBitmapGetPixel((GpBitmap*)bitmap, 0, 1, &color);
expect(Ok, stat);
todo_wine expect(0xffffff00, color);
expect(0xffffff00, color);
stat = GdipBitmapGetPixel((GpBitmap*)bitmap, 2, 1, &color);
expect(Ok, stat);
todo_wine expect(0xff00ffff, color);
expect(0xff00ffff, color);
expect(0, bits[0]);
expect(0, bits[1]);
@ -1713,7 +1791,7 @@ static void test_rotateflip(void)
expect(Ok, stat);
stat = GdipImageRotateFlip(bitmap, RotateNoneFlipY);
todo_wine expect(Ok, stat);
expect(Ok, stat);
stat = GdipGetImageWidth(bitmap, &width);
expect(Ok, stat);
@ -1724,19 +1802,19 @@ static void test_rotateflip(void)
stat = GdipBitmapGetPixel((GpBitmap*)bitmap, 0, 0, &color);
expect(Ok, stat);
todo_wine expect(0xff00ffff, color);
expect(0xff00ffff, color);
stat = GdipBitmapGetPixel((GpBitmap*)bitmap, 2, 0, &color);
expect(Ok, stat);
todo_wine expect(0xffffff00, color);
expect(0xffffff00, color);
stat = GdipBitmapGetPixel((GpBitmap*)bitmap, 0, 1, &color);
expect(Ok, stat);
todo_wine expect(0xffff0000, color);
expect(0xffff0000, color);
stat = GdipBitmapGetPixel((GpBitmap*)bitmap, 2, 1, &color);
expect(Ok, stat);
todo_wine expect(0xff0000ff, color);
expect(0xff0000ff, color);
expect(0, bits[0]);
expect(0, bits[1]);
@ -1801,7 +1879,7 @@ static void test_remaptable(void)
stat = GdipBitmapGetPixel(bitmap2, 0, 0, &color);
expect(Ok, stat);
todo_wine ok(color_match(0xffff00ff, color, 1), "Expected ffff00ff, got %.8x\n", color);
ok(color_match(0xffff00ff, color, 1), "Expected ffff00ff, got %.8x\n", color);
GdipDeleteGraphics(graphics);
GdipDisposeImage((GpImage*)bitmap1);

View file

@ -156,7 +156,7 @@ static void test_charset(void)
hr = MimeOleGetInternat(&internat);
ok(hr == S_OK, "ret %08x\n", hr);
hr = IMimeInternational_FindCharset(internat, "non-existent", &hcs);
hr = IMimeInternational_FindCharset(internat, "nonexistent", &hcs);
ok(hr == MIME_E_NOT_FOUND, "got %08x\n", hr);
hr = IMimeInternational_FindCharset(internat, "windows-1252", &hcs_windows_1252);

View file

@ -113,6 +113,7 @@ ok(typeof(m) === "object", "typeof m is not object");
ok(m.length === 2, "m.length is not 2");
ok(m["0"] === "ab", "m[0] is not \"ab\"");
ok(m["1"] === "ab", "m[1] is not \"ab\"");
/* ok(m.input === "abcabc", "m.input = " + m.input); */
m = "abcabc".match(/Ab/g);
ok(typeof(m) === "object", "typeof m is not object");
@ -167,6 +168,32 @@ ok(m["0"] === "ab", "m[0] is not \"ab\"");
m = "abcabc".match();
ok(m === null, "m is not null");
m = "abcabc".match(/(a)(b)cabc/);
ok(typeof(m) === "object", "typeof m is not object");
ok(m.length === 3, "m.length is not 3");
ok(m[0] === "abcabc", "m[0] is not \"abc\"");
ok(m[1] === "a", "m[1] is not \"a\"");
ok(m[2] === "b", "m[2] is not \"b\"");
re = /(a)bcabc/;
re.lastIndex = -3;
m = "abcabc".match(re);
ok(typeof(m) === "object", "typeof m is not object");
ok(m.length === 2, "m.length = " + m.length + "expected 3");
ok(m[0] === "abcabc", "m[0] is not \"abc\"");
ok(m[1] === "a", "m[1] is not \"a\"");
ok(re.lastIndex === 6, "re.lastIndex = " + re.lastIndex);
re = /(a)bcabc/;
re.lastIndex = 2;
m = "abcabcxxx".match(re);
ok(typeof(m) === "object", "typeof m is not object");
ok(m.length === 2, "m.length = " + m.length + "expected 3");
ok(m[0] === "abcabc", "m[0] is not \"abc\"");
ok(m[1] === "a", "m[1] is not \"a\"");
ok(m.input === "abcabcxxx", "m.input = " + m.input);
ok(re.lastIndex === 6, "re.lastIndex = " + re.lastIndex);
r = "- [test] -".replace(re = /\[([^\[]+)\]/g, "success");
ok(r === "- success -", "r = " + r + " expected '- success -'");
ok(re.lastIndex === 8, "re.lastIndex = " + re.lastIndex);
@ -410,6 +437,19 @@ m = re.exec(" ");
ok(re.lastIndex === 0, "re.lastIndex = " + re.lastIndex + " expected 0");
ok(m === null, "m = " + m + " expected null");
re = /a/;
re.lastIndex = -3;
ok(re.lastIndex === -3, "re.lastIndex = " + re.lastIndex + " expected -3");
m = re.exec(" a a ");
ok(re.lastIndex === 2, "re.lastIndex = " + re.lastIndex + " expected 0");
ok(m.index === 1, "m = " + m + " expected 1");
re.lastIndex = -1;
ok(re.lastIndex === -1, "re.lastIndex = " + re.lastIndex + " expected -1");
m = re.exec(" ");
ok(re.lastIndex === 0, "re.lastIndex = " + re.lastIndex + " expected 0");
ok(m === null, "m = " + m + " expected null");
re = /aa/g;
i = 'baacd'.search(re);
ok(i === 1, "'baacd'.search(re) = " + i);

File diff suppressed because it is too large Load diff

View file

@ -3173,6 +3173,16 @@ static void test_navigator(IHTMLDocument2 *doc)
ok(!strcmp_wa(bstr, buf), "userAgent returned %s, expected \"%s\"\n", wine_dbgstr_w(bstr), buf);
SysFreeString(bstr);
if(!strncmp(buf, "Mozilla/", 8)) {
bstr = NULL;
hres = IOmNavigator_get_appVersion(navigator, &bstr);
ok(hres == S_OK, "get_appVersion failed: %08x\n", hres);
ok(!strcmp_wa(bstr, buf+8), "appVersion returned %s, expected \"%s\"\n", wine_dbgstr_w(bstr), buf+8);
SysFreeString(bstr);
}else {
skip("nonstandard user agent\n");
}
ref = IOmNavigator_Release(navigator);
ok(!ref, "navigator should be destroyed here\n");
}
@ -3185,8 +3195,6 @@ static void test_screen(IHTMLWindow2 *window)
HDC hdc;
HRESULT hres;
static const WCHAR displayW[] = {'D','I','S','P','L','A','Y',0};
screen = NULL;
hres = IHTMLWindow2_get_screen(window, &screen);
ok(hres == S_OK, "get_screen failed: %08x\n", hres);
@ -3206,7 +3214,7 @@ static void test_screen(IHTMLWindow2 *window)
IDispatchEx_Release(dispex);
}
hdc = CreateICW(displayW, NULL, NULL, NULL);
hdc = CreateICA("DISPLAY", NULL, NULL, NULL);
exl = GetDeviceCaps(hdc, HORZRES);
l = 0xdeadbeef;

View file

@ -67,6 +67,8 @@ DEFINE_EXPECT(div_onclick_disp);
DEFINE_EXPECT(iframe_onreadystatechange_loading);
DEFINE_EXPECT(iframe_onreadystatechange_interactive);
DEFINE_EXPECT(iframe_onreadystatechange_complete);
DEFINE_EXPECT(iframedoc_onreadystatechange);
DEFINE_EXPECT(img_onload);
static HWND container_hwnd = NULL;
static IHTMLWindow2 *window;
@ -92,7 +94,10 @@ static const char click_doc_str[] =
"</body></html>";
static const char readystate_doc_str[] =
"<<html><body><iframe id=\"iframe\"></iframe></body></html>";
"<html><body><iframe id=\"iframe\"></iframe></body></html>";
static const char img_doc_str[] =
"<html><body><img id=\"imgid\"></img></body></html>";
static const char *debugstr_guid(REFIID riid)
{
@ -879,14 +884,46 @@ static HRESULT WINAPI body_onclick(IDispatchEx *iface, DISPID id, LCID lcid, WOR
EVENT_HANDLER_FUNC_OBJ(body_onclick);
static HRESULT WINAPI img_onload(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
{
CHECK_EXPECT(img_onload);
test_event_args(&DIID_DispHTMLImg, id, wFlags, pdp, pvarRes, pei, pspCaller);
test_event_src("IMG");
return S_OK;
}
EVENT_HANDLER_FUNC_OBJ(img_onload);
static HRESULT WINAPI iframedoc_onreadystatechange(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
{
IHTMLEventObj *event = NULL;
HRESULT hres;
CHECK_EXPECT2(iframedoc_onreadystatechange);
test_event_args(&DIID_DispHTMLDocument, id, wFlags, pdp, pvarRes, pei, pspCaller);
event = (void*)0xdeadbeef;
hres = IHTMLWindow2_get_event(window, &event);
ok(hres == S_OK, "get_event failed: %08x\n", hres);
ok(!event, "event = %p\n", event);
return S_OK;
}
EVENT_HANDLER_FUNC_OBJ(iframedoc_onreadystatechange);
static HRESULT WINAPI iframe_onreadystatechange(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
{
IHTMLWindow2 *iframe_window;
IHTMLDocument2 *iframe_doc;
IHTMLFrameBase2 *iframe;
IHTMLElement2 *elem2;
IHTMLElement *elem;
VARIANT v;
BSTR str;
BSTR str, str2;
HRESULT hres;
test_event_args(&DIID_DispHTMLIFrame, id, wFlags, pdp, pvarRes, pei, pspCaller);
@ -913,15 +950,33 @@ static HRESULT WINAPI iframe_onreadystatechange(IDispatchEx *iface, DISPID id, L
ok(!lstrcmpW(str, V_BSTR(&v)), "ready states differ\n");
VariantClear(&v);
if(!strcmp_wa(str, "loading"))
hres = IHTMLFrameBase2_get_contentWindow(iframe, &iframe_window);
ok(hres == S_OK, "get_contentDocument failed: %08x\n", hres);
hres = IHTMLWindow2_get_document(iframe_window, &iframe_doc);
IHTMLWindow2_Release(iframe_window);
ok(hres == S_OK, "get_document failed: %08x\n", hres);
hres = IHTMLDocument2_get_readyState(iframe_doc, &str2);
ok(!lstrcmpW(str, str2), "unexpected document readyState %s\n", wine_dbgstr_w(str2));
SysFreeString(str2);
if(!strcmp_wa(str, "loading")) {
CHECK_EXPECT(iframe_onreadystatechange_loading);
else if(!strcmp_wa(str, "interactive"))
V_VT(&v) = VT_DISPATCH;
V_DISPATCH(&v) = (IDispatch*)&iframedoc_onreadystatechange_obj;
hres = IHTMLDocument2_put_onreadystatechange(iframe_doc, v);
ok(hres == S_OK, "put_onreadystatechange: %08x\n", hres);
}else if(!strcmp_wa(str, "interactive"))
CHECK_EXPECT(iframe_onreadystatechange_interactive);
else if(!strcmp_wa(str, "complete"))
CHECK_EXPECT(iframe_onreadystatechange_complete);
else
ok(0, "unexpected state %s\n", wine_dbgstr_w(str));
IHTMLDocument2_Release(iframe_doc);
IHTMLFrameBase2_Release(iframe);
return S_OK;
}
@ -1307,17 +1362,60 @@ static void test_onreadystatechange(IHTMLDocument2 *doc)
ok(hres == S_OK, "put_src failed: %08x\n", hres);
SET_EXPECT(iframe_onreadystatechange_loading);
SET_EXPECT(iframedoc_onreadystatechange);
SET_EXPECT(iframe_onreadystatechange_interactive);
SET_EXPECT(iframe_onreadystatechange_complete);
pump_msgs(&called_iframe_onreadystatechange_complete);
todo_wine
CHECK_CALLED(iframe_onreadystatechange_loading);
CHECK_CALLED(iframedoc_onreadystatechange);
CHECK_CALLED(iframe_onreadystatechange_interactive);
CHECK_CALLED(iframe_onreadystatechange_complete);
IHTMLFrameBase_Release(iframe);
}
static void test_imgload(IHTMLDocument2 *doc)
{
IHTMLImgElement *img;
IHTMLElement *elem;
VARIANT v;
BSTR str;
HRESULT hres;
elem = get_elem_id(doc, "imgid");
hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLImgElement, (void**)&img);
IHTMLElement_Release(elem);
ok(hres == S_OK, "Could not get IHTMLImgElement iface: %08x\n", hres);
V_VT(&v) = VT_EMPTY;
hres = IHTMLImgElement_get_onload(img, &v);
ok(hres == S_OK, "get_onload failed: %08x\n", hres);
ok(V_VT(&v) == VT_NULL, "V_VT(onload) = %d\n", V_VT(&v));
V_VT(&v) = VT_DISPATCH;
V_DISPATCH(&v) = (IDispatch*)&img_onload_obj;
hres = IHTMLImgElement_put_onload(img, v);
ok(hres == S_OK, "put_onload failed: %08x\n", hres);
V_VT(&v) = VT_EMPTY;
hres = IHTMLImgElement_get_onload(img, &v);
ok(hres == S_OK, "get_onload failed: %08x\n", hres);
ok(V_VT(&v) == VT_DISPATCH, "V_VT(onload) = %d\n", V_VT(&v));
ok(V_DISPATCH(&v) == (IDispatch*)&img_onload_obj, "V_DISPATCH(onload) != onloadkFunc\n");
VariantClear(&v);
str = a2bstr("http://www.winehq.org/images/winehq_logo_text.png");
hres = IHTMLImgElement_put_src(img, str);
ok(hres == S_OK, "put_src failed: %08x\n", hres);
SysFreeString(str);
SET_EXPECT(img_onload);
pump_msgs(&called_img_onload);
CHECK_CALLED(img_onload);
IHTMLImgElement_Release(img);
}
static void test_timeout(IHTMLDocument2 *doc)
{
IHTMLWindow3 *win3;
@ -1957,6 +2055,7 @@ START_TEST(events)
run_test(empty_doc_str, test_timeout);
run_test(click_doc_str, test_onclick);
run_test(readystate_doc_str, test_onreadystatechange);
run_test(img_doc_str, test_imgload);
DestroyWindow(container_hwnd);
CoUninitialize();

View file

@ -5,12 +5,30 @@ function ok(b,m) {
return external.ok(b, m);
}
function test_removeAttribute(e) {
ok(e.removeAttribute('nonexisting') === false, "removeAttribute('nonexisting') didn't return false");
e.title = "title";
ok(e.removeAttribute('title') === true, "removeAttribute('title') didn't return true");
ok(e.title === "", "e.title = " + e.title);
ok(("title" in e) === true, "title is not in e");
e["myattr"] = "test";
ok(e.removeAttribute('myattr') === true, "removeAttribute('myattr') didn't return true");
ok(e["myattr"] === undefined, "e['myattr'] = " + e['myattr']);
ok(("myattr" in e) === false, "myattr is in e");
}
function runTest() {
obj = new Object();
ok(obj === window.obj, "obj !== window.obj");
ok(typeof(divid) === "object", "typeof(divid) = " + typeof(divid));
test_removeAttribute(document.getElementById("divid"));
test_removeAttribute(document.body);
external.reportSuccess();
}
</script>

View file

@ -1050,12 +1050,22 @@ static HRESULT QueryInterface(REFIID riid, void **ppv)
static IHTMLDocument2 *create_document(void)
{
IHTMLDocument2 *doc;
IHTMLDocument5 *doc5;
HRESULT hres;
hres = CoCreateInstance(&CLSID_HTMLDocument, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
&IID_IHTMLDocument2, (void**)&doc);
ok(hres == S_OK, "CoCreateInstance failed: %08x\n", hres);
if (hres != S_OK) return NULL;
hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument5, (void**)&doc5);
if(FAILED(hres)) {
win_skip("Could not get IHTMLDocument5, probably too old IE\n");
IHTMLDocument2_Release(doc);
return NULL;
}
IHTMLDocument5_Release(doc5);
return doc;
}

View file

@ -535,6 +535,7 @@ static void test_domdoc( void )
BSTR str;
LONG code;
LONG nLength = 0;
WCHAR buff[100];
r = CoCreateInstance( &CLSID_DOMDocument, NULL,
CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument, (LPVOID*)&doc );
@ -543,6 +544,12 @@ static void test_domdoc( void )
test_disp((IUnknown*)doc);
if (0)
{
/* crashes on native */
r = IXMLDOMDocument_loadXML( doc, (BSTR)0x1, NULL );
}
/* try some stupid things */
r = IXMLDOMDocument_loadXML( doc, NULL, NULL );
ok( r == S_FALSE, "loadXML failed\n");
@ -601,6 +608,15 @@ static void test_domdoc( void )
ok( r == S_FALSE, "should be no document element\n");
ok( element == NULL, "Element should be NULL\n");
/* test for BSTR handling, pass broken BSTR */
memcpy(&buff[2], szComplete1, sizeof(szComplete1));
/* just a big length */
*(DWORD*)buff = 0xf0f0;
b = VARIANT_FALSE;
r = IXMLDOMDocument_loadXML( doc, &buff[2], &b );
ok( r == S_OK, "loadXML failed\n");
ok( b == VARIANT_TRUE, "failed to load XML string\n");
/* try to load something valid */
b = VARIANT_FALSE;
str = SysAllocString( szComplete1 );
@ -2734,6 +2750,12 @@ static void test_XMLHTTP(void)
SysFreeString(str2);
hr = IXMLHttpRequest_send(pXMLHttpRequest, varbody);
if (hr == INET_E_RESOURCE_NOT_FOUND)
{
skip("No connection could be made with crossover.codeweavers.com\n");
IXMLHttpRequest_Release(pXMLHttpRequest);
return;
}
todo_wine ok(hr == S_OK, "IXMLHttpRequest_send should have succeeded instead of failing with 0x%08x\n", hr);
VariantClear(&varbody);

View file

@ -128,16 +128,28 @@ static int init_base_environment(DWORD dwKeyFlags)
hProv = (HCRYPTPROV)INVALID_HANDLE_VALUE;
result = CryptAcquireContext(&hProv, szContainer, szProvider, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT);
ok(!result && GetLastError()==NTE_BAD_FLAGS, "%d, %08x\n", result, GetLastError());
ok(!result && (GetLastError()==NTE_BAD_FLAGS ||
broken(GetLastError() == NTE_KEYSET_NOT_DEF /* Win9x/NT4 */)),
"%d, %08x\n", result, GetLastError());
if (!CryptAcquireContext(&hProv, szContainer, szProvider, PROV_RSA_FULL, 0))
{
ok(GetLastError()==NTE_BAD_KEYSET, "%08x\n", GetLastError());
if (GetLastError()!=NTE_BAD_KEYSET) return 0;
ok(GetLastError()==NTE_BAD_KEYSET ||
broken(GetLastError() == NTE_KEYSET_NOT_DEF /* Win9x/NT4 */),
"%08x\n", GetLastError());
if (GetLastError()!=NTE_BAD_KEYSET)
{
win_skip("RSA full provider not available\n");
return 0;
}
result = CryptAcquireContext(&hProv, szContainer, szProvider, PROV_RSA_FULL,
CRYPT_NEWKEYSET);
ok(result, "%08x\n", GetLastError());
if (!result) return 0;
if (!result)
{
win_skip("Couldn't create crypto provider\n");
return 0;
}
result = CryptGenKey(hProv, AT_KEYEXCHANGE, dwKeyFlags, &hKey);
ok(result, "%08x\n", GetLastError());
if (result) CryptDestroyKey(hKey);
@ -275,7 +287,6 @@ static BOOL derive_key(ALG_ID aiAlgid, HCRYPTKEY *phKey, DWORD len)
return FALSE;
}
ok(result, "%08x\n", GetLastError());
if (!result) return FALSE;
result = CryptHashData(hHash, pbData, sizeof(pbData), 0);
ok(result, "%08x\n", GetLastError());
if (!result) return FALSE;
@ -309,8 +320,9 @@ static void test_hashes(void)
unsigned char pbData[2048];
BOOL result;
HCRYPTHASH hHash, hHashClone;
HCRYPTPROV prov;
BYTE pbHashValue[36];
DWORD hashlen, len;
DWORD hashlen, len, error;
int i;
for (i=0; i<2048; i++) pbData[i] = (unsigned char)i;
@ -441,6 +453,74 @@ static void test_hashes(void)
result = CryptDestroyHash(hHash);
ok(result, "%08x\n", GetLastError());
/* The SHA-2 variants aren't supported in the RSA full provider */
result = CryptCreateHash(hProv, CALG_SHA_256, 0, 0, &hHash);
ok(!result && GetLastError() == NTE_BAD_ALGID,
"expected NTE_BAD_ALGID, got %08x\n", GetLastError());
result = CryptCreateHash(hProv, CALG_SHA_384, 0, 0, &hHash);
ok(!result && GetLastError() == NTE_BAD_ALGID,
"expected NTE_BAD_ALGID, got %08x\n", GetLastError());
result = CryptCreateHash(hProv, CALG_SHA_512, 0, 0, &hHash);
ok(!result && GetLastError() == NTE_BAD_ALGID,
"expected NTE_BAD_ALGID, got %08x\n", GetLastError());
result = CryptAcquireContextA(&prov, NULL, szProvider, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT);
ok(result, "CryptAcquireContext failed 0x%08x\n", GetLastError());
result = CryptCreateHash(prov, CALG_SHA1, 0, 0, &hHash);
ok(result, "CryptCreateHash failed 0x%08x\n", GetLastError());
/* release provider before using the hash */
result = CryptReleaseContext(prov, 0);
ok(result, "CryptReleaseContext failed 0x%08x\n", GetLastError());
SetLastError(0xdeadbeef);
result = CryptHashData(hHash, (const BYTE *)"data", sizeof("data"), 0);
error = GetLastError();
ok(!result, "CryptHashData succeeded\n");
ok(error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER got %u\n", error);
SetLastError(0xdeadbeef);
result = CryptDestroyHash(hHash);
error = GetLastError();
ok(!result, "CryptDestroyHash succeeded\n");
ok(error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER got %u\n", error);
if (!pCryptDuplicateHash)
{
win_skip("CryptDuplicateHash is not available\n");
return;
}
result = CryptAcquireContextA(&prov, NULL, szProvider, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT);
ok(result, "CryptAcquireContext failed 0x%08x\n", GetLastError());
result = CryptCreateHash(hProv, CALG_SHA1, 0, 0, &hHash);
ok(result, "CryptCreateHash failed 0x%08x\n", GetLastError());
result = CryptHashData(hHash, (const BYTE *)"data", sizeof("data"), 0);
ok(result, "CryptHashData failed 0x%08x\n", GetLastError());
result = pCryptDuplicateHash(hHash, NULL, 0, &hHashClone);
ok(result, "CryptDuplicateHash failed 0x%08x\n", GetLastError());
len = 20;
result = CryptGetHashParam(hHashClone, HP_HASHVAL, pbHashValue, &len, 0);
ok(result, "CryptGetHashParam failed 0x%08x\n", GetLastError());
/* add data after duplicating the hash */
result = CryptHashData(hHash, (const BYTE *)"more data", sizeof("more data"), 0);
ok(result, "CryptHashData failed 0x%08x\n", GetLastError());
result = CryptDestroyHash(hHash);
ok(result, "CryptDestroyHash failed 0x%08x\n", GetLastError());
result = CryptDestroyHash(hHashClone);
ok(result, "CryptDestroyHash failed 0x%08x\n", GetLastError());
result = CryptReleaseContext(prov, 0);
ok(result, "CryptReleaseContext failed 0x%08x\n", GetLastError());
}
static void test_block_cipher_modes(void)
@ -471,6 +551,10 @@ static void test_block_cipher_modes(void)
result = CryptSetKeyParam(hKey, KP_MODE, (BYTE*)&dwMode, 0);
ok(result, "%08x\n", GetLastError());
result = CryptGetKeyParam(hKey, KP_SALT, NULL, &dwLen, 0);
ok(result, "%08x\n", GetLastError());
ok(dwLen == 11 || broken(dwLen == 0 /* Win9x/NT4 */), "unexpected salt length %d\n", dwLen);
dwLen = 23;
result = CryptEncrypt(hKey, 0, TRUE, 0, NULL, &dwLen, 24);
ok(result, "CryptEncrypt failed: %08x\n", GetLastError());
@ -716,6 +800,11 @@ static void test_aes(int keylen)
for (i=0; i<sizeof(pbData); i++) pbData[i] = (unsigned char)i;
/* AES provider doesn't support salt */
result = CryptGetKeyParam(hKey, KP_SALT, NULL, &dwLen, 0);
ok(!result && (GetLastError() == NTE_BAD_KEY || GetLastError() == ERROR_NO_TOKEN /* Win7 */),
"expected NTE_BAD_KEY or ERROR_NO_TOKEN, got %08x\n", GetLastError());
dwLen = 13;
result = CryptEncrypt(hKey, 0, TRUE, 0, pbData, &dwLen, 16);
ok(result, "%08x\n", GetLastError());
@ -747,6 +836,108 @@ static void test_aes(int keylen)
ok(result, "%08x\n", GetLastError());
}
static void test_sha2(void)
{
static const unsigned char sha256hash[32] = {
0x10, 0xfc, 0x3c, 0x51, 0xa1, 0x52, 0xe9, 0x0e, 0x5b, 0x90,
0x31, 0x9b, 0x60, 0x1d, 0x92, 0xcc, 0xf3, 0x72, 0x90, 0xef,
0x53, 0xc3, 0x5f, 0xf9, 0x25, 0x07, 0x68, 0x7d, 0x8a, 0x91,
0x1a, 0x08
};
static const unsigned char sha384hash[48] = {
0x98, 0xd3, 0x3f, 0x89, 0x0b, 0x23, 0x33, 0x44, 0x61, 0x32,
0x5a, 0x7c, 0xa3, 0x03, 0x89, 0xb5, 0x11, 0xd7, 0x41, 0xc8,
0x54, 0x6b, 0x12, 0x0c, 0x40, 0x15, 0xb6, 0x2a, 0x03, 0x43,
0xe5, 0x64, 0x7f, 0x10, 0x1e, 0xae, 0x47, 0xa9, 0x39, 0x05,
0x6f, 0x40, 0x60, 0x94, 0xd6, 0xad, 0x80, 0x55
};
static const unsigned char sha512hash[64] = {
0x37, 0x86, 0x0e, 0x7d, 0x25, 0xd9, 0xf9, 0x84, 0x3e, 0x3d,
0xc7, 0x13, 0x95, 0x73, 0x42, 0x04, 0xfd, 0x13, 0xad, 0x23,
0x39, 0x16, 0x32, 0x5f, 0x99, 0x3e, 0x3c, 0xee, 0x3f, 0x11,
0x36, 0xf9, 0xc9, 0x66, 0x08, 0x70, 0xcc, 0x49, 0xd8, 0xe0,
0x7d, 0xa1, 0x57, 0x62, 0x71, 0xa6, 0xc9, 0xa4, 0x24, 0x60,
0xfc, 0xde, 0x9d, 0xb2, 0xf1, 0xd2, 0xc2, 0xfb, 0x2d, 0xbf,
0xb7, 0xf4, 0x81, 0xd4
};
unsigned char pbData[2048];
BOOL result;
HCRYPTHASH hHash;
BYTE pbHashValue[64];
DWORD hashlen, len;
int i;
for (i=0; i<2048; i++) pbData[i] = (unsigned char)i;
/* SHA-256 hash */
SetLastError(0xdeadbeef);
result = CryptCreateHash(hProv, CALG_SHA_256, 0, 0, &hHash);
if (!result && GetLastError() == NTE_BAD_ALGID) {
win_skip("SHA-256/384/512 hashes are not supported before Windows XP SP3\n");
return;
}
ok(result, "%08x\n", GetLastError());
if (result) {
len = sizeof(DWORD);
result = CryptGetHashParam(hHash, HP_HASHSIZE, (BYTE*)&hashlen, &len, 0);
ok(result && (hashlen == 32), "%08x, hashlen: %d\n", GetLastError(), hashlen);
result = CryptHashData(hHash, pbData, sizeof(pbData), 0);
ok(result, "%08x\n", GetLastError());
len = 32;
result = CryptGetHashParam(hHash, HP_HASHVAL, pbHashValue, &len, 0);
ok(result, "%08x\n", GetLastError());
ok(!memcmp(pbHashValue, sha256hash, 32), "Wrong SHA-256 hash!\n");
result = CryptDestroyHash(hHash);
ok(result, "%08x\n", GetLastError());
}
/* SHA-384 hash */
result = CryptCreateHash(hProv, CALG_SHA_384, 0, 0, &hHash);
ok(result, "%08x\n", GetLastError());
if (result) {
len = sizeof(DWORD);
result = CryptGetHashParam(hHash, HP_HASHSIZE, (BYTE*)&hashlen, &len, 0);
ok(result && (hashlen == 48), "%08x, hashlen: %d\n", GetLastError(), hashlen);
result = CryptHashData(hHash, pbData, sizeof(pbData), 0);
ok(result, "%08x\n", GetLastError());
len = 48;
result = CryptGetHashParam(hHash, HP_HASHVAL, pbHashValue, &len, 0);
ok(result, "%08x\n", GetLastError());
ok(!memcmp(pbHashValue, sha384hash, 48), "Wrong SHA-384 hash!\n");
result = CryptDestroyHash(hHash);
ok(result, "%08x\n", GetLastError());
}
/* SHA-512 hash */
result = CryptCreateHash(hProv, CALG_SHA_512, 0, 0, &hHash);
ok(result, "%08x\n", GetLastError());
if (result) {
len = sizeof(DWORD);
result = CryptGetHashParam(hHash, HP_HASHSIZE, (BYTE*)&hashlen, &len, 0);
ok(result && (hashlen == 64), "%08x, hashlen: %d\n", GetLastError(), hashlen);
result = CryptHashData(hHash, pbData, sizeof(pbData), 0);
ok(result, "%08x\n", GetLastError());
len = 64;
result = CryptGetHashParam(hHash, HP_HASHVAL, pbHashValue, &len, 0);
ok(result, "%08x\n", GetLastError());
ok(!memcmp(pbHashValue, sha512hash, 64), "Wrong SHA-512 hash!\n");
result = CryptDestroyHash(hHash);
ok(result, "%08x\n", GetLastError());
}
}
static void test_rc2(void)
{
static const BYTE rc2_40_encrypted[16] = {
@ -820,8 +1011,13 @@ static void test_rc2(void)
result = CryptGetKeyParam(hKey, KP_SALT, NULL, &dwLen, 0);
ok(result, "%08x\n", GetLastError());
/* The default salt length is always 11... */
ok(dwLen == 11, "unexpected salt length %d\n", dwLen);
/* and the default salt is always empty. */
pbTemp = HeapAlloc(GetProcessHeap(), 0, dwLen);
CryptGetKeyParam(hKey, KP_SALT, pbTemp, &dwLen, 0);
for (i=0; i<dwLen; i++)
ok(!pbTemp[i], "unexpected salt value %02x @ %d\n", pbTemp[i], i);
HeapFree(GetProcessHeap(), 0, pbTemp);
dwLen = sizeof(DWORD);
@ -845,6 +1041,16 @@ static void test_rc2(void)
result = CryptDecrypt(hKey, 0, TRUE, 0, pbData, &dwDataLen);
ok(result, "%08x\n", GetLastError());
/* Setting the salt also succeeds... */
result = CryptSetKeyParam(hKey, KP_SALT, pbData, 0);
ok(result, "setting salt failed: %08x\n", GetLastError());
/* but the resulting salt length is now zero? */
dwLen = 0;
result = CryptGetKeyParam(hKey, KP_SALT, NULL, &dwLen, 0);
ok(result, "%08x\n", GetLastError());
ok(dwLen == 0 ||
broken(dwLen == 11), /* Win9x/WinMe/NT4 */
"unexpected salt length %d\n", dwLen);
/* What sizes salt can I set? */
salt.pbData = pbData;
for (i=0; i<24; i++)
@ -852,6 +1058,10 @@ static void test_rc2(void)
salt.cbData = i;
result = CryptSetKeyParam(hKey, KP_SALT_EX, (BYTE *)&salt, 0);
ok(result, "setting salt failed for size %d: %08x\n", i, GetLastError());
/* The returned salt length is the same as the set salt length */
result = CryptGetKeyParam(hKey, KP_SALT, NULL, &dwLen, 0);
ok(result, "%08x\n", GetLastError());
ok(dwLen == i, "size %d: unexpected salt length %d\n", i, dwLen);
}
salt.cbData = 25;
SetLastError(0xdeadbeef);
@ -999,6 +1209,16 @@ static void test_rc4(void)
result = CryptDecrypt(hKey, 0, TRUE, 0, pbData, &dwDataLen);
ok(result, "%08x\n", GetLastError());
/* Setting the salt also succeeds... */
result = CryptSetKeyParam(hKey, KP_SALT, pbData, 0);
ok(result, "setting salt failed: %08x\n", GetLastError());
/* but the resulting salt length is now zero? */
dwLen = 0;
result = CryptGetKeyParam(hKey, KP_SALT, NULL, &dwLen, 0);
ok(result, "%08x\n", GetLastError());
ok(dwLen == 0 ||
broken(dwLen == 11), /* Win9x/WinMe/NT4 */
"unexpected salt length %d\n", dwLen);
/* What sizes salt can I set? */
salt.pbData = pbData;
for (i=0; i<24; i++)
@ -1006,6 +1226,10 @@ static void test_rc4(void)
salt.cbData = i;
result = CryptSetKeyParam(hKey, KP_SALT_EX, (BYTE *)&salt, 0);
ok(result, "setting salt failed for size %d: %08x\n", i, GetLastError());
/* The returned salt length is the same as the set salt length */
result = CryptGetKeyParam(hKey, KP_SALT, NULL, &dwLen, 0);
ok(result, "%08x\n", GetLastError());
ok(dwLen == i, "size %d: unexpected salt length %d\n", i, dwLen);
}
salt.cbData = 25;
SetLastError(0xdeadbeef);
@ -1577,6 +1801,11 @@ static void test_rsa_encrypt(void)
"expected CRYPT_MAC|CRYPT_WRITE|CRYPT_READ|CRYPT_DECRYPT|CRYPT_ENCRYPT,"
" got %08x\n", dwVal);
/* An RSA key doesn't support salt */
result = CryptGetKeyParam(hRSAKey, KP_SALT, NULL, &dwLen, 0);
ok(!result && GetLastError() == NTE_BAD_KEY,
"expected NTE_BAD_KEY, got %08x\n", GetLastError());
/* The key exchange key's public key may be exported.. */
result = CryptExportKey(hRSAKey, 0, PUBLICKEYBLOB, 0, NULL, &dwLen);
ok(result, "%08x\n", GetLastError());
@ -2570,5 +2799,6 @@ START_TEST(rsaenh)
test_aes(128);
test_aes(192);
test_aes(256);
test_sha2();
clean_up_aes_environment();
}

View file

@ -37,7 +37,13 @@
SetContextAttributes)
#define SECPKG_FUNCTION_TABLE_SIZE_2 FIELD_OFFSET(SECPKG_FUNCTION_TABLE, \
SetCredentialsAttributes)
#define SECPKG_FUNCTION_TABLE_SIZE_3 sizeof(SECPKG_FUNCTION_TABLE)
#define SECPKG_FUNCTION_TABLE_SIZE_3 FIELD_OFFSET(SECPKG_FUNCTION_TABLE, \
ChangeAccountPassword)
#define SECPKG_FUNCTION_TABLE_SIZE_4 FIELD_OFFSET(SECPKG_FUNCTION_TABLE, \
QueryMetaData)
#define SECPKG_FUNCTION_TABLE_SIZE_5 FIELD_OFFSET(SECPKG_FUNCTION_TABLE, \
ValidateTargetInfo)
#define SECPKG_FUNCTION_TABLE_SIZE_6 sizeof(SECPKG_FUNCTION_TABLE)
static NTSTATUS (NTAPI *pSpLsaModeInitialize)(ULONG, PULONG,
PSECPKG_FUNCTION_TABLE*, PULONG);
@ -121,6 +127,7 @@ static PSECPKG_FUNCTION_TABLE getNextSecPkgTable(PSECPKG_FUNCTION_TABLE pTable,
ULONG Version)
{
size_t size;
PSECPKG_FUNCTION_TABLE pNextTable;
if (Version == SECPKG_INTERFACE_VERSION)
size = SECPKG_FUNCTION_TABLE_SIZE_1;
@ -128,12 +135,32 @@ static PSECPKG_FUNCTION_TABLE getNextSecPkgTable(PSECPKG_FUNCTION_TABLE pTable,
size = SECPKG_FUNCTION_TABLE_SIZE_2;
else if (Version == SECPKG_INTERFACE_VERSION_3)
size = SECPKG_FUNCTION_TABLE_SIZE_3;
else if (Version == SECPKG_INTERFACE_VERSION_4)
size = SECPKG_FUNCTION_TABLE_SIZE_4;
else if (Version == SECPKG_INTERFACE_VERSION_5)
size = SECPKG_FUNCTION_TABLE_SIZE_5;
else if (Version == SECPKG_INTERFACE_VERSION_6)
size = SECPKG_FUNCTION_TABLE_SIZE_6;
else {
ok(FALSE, "Unknown package version 0x%x\n", Version);
return NULL;
}
return (PSECPKG_FUNCTION_TABLE)((PBYTE)pTable + size);
pNextTable = (PSECPKG_FUNCTION_TABLE)((PBYTE)pTable + size);
/* Win7 function tables appear to be SECPKG_INTERFACE_VERSION_6 format,
but unfortunately SpLsaModeInitialize returns SECPKG_INTERFACE_VERSION_3.
We detect that by comparing the "Initialize" pointer from the old table
to the "FreeCredentialsHandle" pointer of the new table. These functions
have different numbers of arguments, so they can't possibly point to the
same implementation */
if (broken((void *) pTable->Initialize == (void *) pNextTable->FreeCredentialsHandle &&
pNextTable->FreeCredentialsHandle != NULL))
{
win_skip("Invalid function pointers for next package\n");
return NULL;
}
return pNextTable;
}
static void testGetInfo(void)
@ -181,7 +208,9 @@ static void testGetInfo(void)
PackageInfo.fCapabilities);
ok(PackageInfo.wVersion == 1, "wVersion: %d\n", PackageInfo.wVersion);
ok(PackageInfo.wRPCID == 14, "wRPCID: %d\n", PackageInfo.wRPCID);
ok(PackageInfo.cbMaxToken == 0x4000, "cbMaxToken: 0x%x\n",
ok(PackageInfo.cbMaxToken == 0x4000 ||
PackageInfo.cbMaxToken == 0x6000, /* Win7 */
"cbMaxToken: 0x%x\n",
PackageInfo.cbMaxToken);
}
}

View file

@ -56,42 +56,103 @@
* Test helper macros
*/
#ifdef _WIN64
#define TEST_TYPE_SIZE(type, size) C_ASSERT(sizeof(type) == size);
# define TEST_TYPE_SIZE(type, size)
#ifdef TYPE_ALIGNMENT
# define TEST_TYPE_ALIGN(type, align) C_ASSERT(TYPE_ALIGNMENT(type) == align);
#else
# define TEST_TYPE_ALIGN(type, align)
#endif
#ifdef _TYPE_ALIGNMENT
# define TEST_TARGET_ALIGN(type, align) C_ASSERT(_TYPE_ALIGNMENT(*(type)0) == align);
# define TEST_FIELD_ALIGN(type, field, align) C_ASSERT(_TYPE_ALIGNMENT(((type*)0)->field) == align);
#else
# define TEST_TARGET_ALIGN(type, align)
# define TEST_FIELD_ALIGN(type, field, align)
# define TEST_FIELD_OFFSET(type, field, offset)
#else
# define TEST_TYPE_SIZE(type, size) C_ASSERT(sizeof(type) == size);
# ifdef TYPE_ALIGNMENT
# define TEST_TYPE_ALIGN(type, align) C_ASSERT(TYPE_ALIGNMENT(type) == align);
# else
# define TEST_TYPE_ALIGN(type, align)
# endif
# ifdef _TYPE_ALIGNMENT
# define TEST_TARGET_ALIGN(type, align) C_ASSERT(_TYPE_ALIGNMENT(*(type)0) == align);
# define TEST_FIELD_ALIGN(type, field, align) C_ASSERT(_TYPE_ALIGNMENT(((type*)0)->field) == align);
# else
# define TEST_TARGET_ALIGN(type, align)
# define TEST_FIELD_ALIGN(type, field, align)
# endif
# define TEST_FIELD_OFFSET(type, field, offset) C_ASSERT(FIELD_OFFSET(type, field) == offset);
#endif
#define TEST_FIELD_OFFSET(type, field, offset) C_ASSERT(FIELD_OFFSET(type, field) == offset);
#define TEST_TARGET_SIZE(type, size) TEST_TYPE_SIZE(*(type)0, size)
#define TEST_FIELD_SIZE(type, field, size) TEST_TYPE_SIZE((((type*)0)->field), size)
#define TEST_TYPE_SIGNED(type) C_ASSERT((type) -1 < 0);
#define TEST_TYPE_UNSIGNED(type) C_ASSERT((type) -1 > 0);
#ifdef _WIN64
static void test_pack_ASSOCF(void)
{
/* ASSOCF */
TEST_TYPE_SIZE (ASSOCF, 4)
TEST_TYPE_ALIGN (ASSOCF, 4)
TEST_TYPE_UNSIGNED(ASSOCF)
}
static void test_pack_DLLGETVERSIONPROC(void)
{
/* DLLGETVERSIONPROC */
TEST_TYPE_SIZE (DLLGETVERSIONPROC, 8)
TEST_TYPE_ALIGN (DLLGETVERSIONPROC, 8)
}
static void test_pack_DLLVERSIONINFO(void)
{
/* DLLVERSIONINFO (pack 8) */
TEST_TYPE_SIZE (DLLVERSIONINFO, 20)
TEST_TYPE_ALIGN (DLLVERSIONINFO, 4)
TEST_FIELD_SIZE (DLLVERSIONINFO, cbSize, 4)
TEST_FIELD_ALIGN (DLLVERSIONINFO, cbSize, 4)
TEST_FIELD_OFFSET(DLLVERSIONINFO, cbSize, 0)
TEST_FIELD_SIZE (DLLVERSIONINFO, dwMajorVersion, 4)
TEST_FIELD_ALIGN (DLLVERSIONINFO, dwMajorVersion, 4)
TEST_FIELD_OFFSET(DLLVERSIONINFO, dwMajorVersion, 4)
TEST_FIELD_SIZE (DLLVERSIONINFO, dwMinorVersion, 4)
TEST_FIELD_ALIGN (DLLVERSIONINFO, dwMinorVersion, 4)
TEST_FIELD_OFFSET(DLLVERSIONINFO, dwMinorVersion, 8)
TEST_FIELD_SIZE (DLLVERSIONINFO, dwBuildNumber, 4)
TEST_FIELD_ALIGN (DLLVERSIONINFO, dwBuildNumber, 4)
TEST_FIELD_OFFSET(DLLVERSIONINFO, dwBuildNumber, 12)
TEST_FIELD_SIZE (DLLVERSIONINFO, dwPlatformID, 4)
TEST_FIELD_ALIGN (DLLVERSIONINFO, dwPlatformID, 4)
TEST_FIELD_OFFSET(DLLVERSIONINFO, dwPlatformID, 16)
}
static void test_pack_DLLVERSIONINFO2(void)
{
/* DLLVERSIONINFO2 (pack 8) */
TEST_TYPE_SIZE (DLLVERSIONINFO2, 32)
TEST_TYPE_ALIGN (DLLVERSIONINFO2, 8)
TEST_FIELD_SIZE (DLLVERSIONINFO2, info1, 20)
TEST_FIELD_ALIGN (DLLVERSIONINFO2, info1, 4)
TEST_FIELD_OFFSET(DLLVERSIONINFO2, info1, 0)
TEST_FIELD_SIZE (DLLVERSIONINFO2, dwFlags, 4)
TEST_FIELD_ALIGN (DLLVERSIONINFO2, dwFlags, 4)
TEST_FIELD_OFFSET(DLLVERSIONINFO2, dwFlags, 20)
TEST_FIELD_SIZE (DLLVERSIONINFO2, ullVersion, 8)
TEST_FIELD_ALIGN (DLLVERSIONINFO2, ullVersion, 8)
TEST_FIELD_OFFSET(DLLVERSIONINFO2, ullVersion, 24)
}
static void test_pack_HUSKEY(void)
{
/* HUSKEY */
TEST_TYPE_SIZE (HUSKEY, 8)
TEST_TYPE_ALIGN (HUSKEY, 8)
}
static void test_pack_PHUSKEY(void)
{
/* PHUSKEY */
TEST_TYPE_SIZE (PHUSKEY, 8)
TEST_TYPE_ALIGN (PHUSKEY, 8)
TEST_TARGET_SIZE (PHUSKEY, 8)
TEST_TARGET_ALIGN(PHUSKEY, 8)
}
#else /* _WIN64 */
static void test_pack_ASSOCF(void)
{
/* ASSOCF */
@ -161,6 +222,8 @@ static void test_pack_PHUSKEY(void)
TEST_TARGET_ALIGN(PHUSKEY, 4)
}
#endif /* _WIN64 */
static void test_pack(void)
{
test_pack_ASSOCF();
@ -173,9 +236,5 @@ static void test_pack(void)
START_TEST(generated)
{
#ifdef _WIN64
ok(0, "The type size / alignment tests don't support Win64 yet\n");
#else
test_pack();
#endif
}

View file

@ -208,12 +208,16 @@ static void test_SHCreateStreamOnFileA(DWORD mode, DWORD stgm)
/* invalid arguments */
stream = NULL;
/* NT: ERROR_PATH_NOT_FOUND, 9x: ERROR_BAD_PATHNAME */
ret = (*pSHCreateStreamOnFileA)(NULL, mode | stgm, &stream);
ok(ret == HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND) ||
ret == HRESULT_FROM_WIN32(ERROR_BAD_PATHNAME),
"SHCreateStreamOnFileA: expected HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND)"
"or HRESULT_FROM_WIN32(ERROR_BAD_PATHNAME), got 0x%08x\n", ret);
if (ret == E_INVALIDARG) /* Win98 SE */ {
win_skip("Not supported\n");
return;
}
ok(ret == HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND) /* NT */ ||
ret == HRESULT_FROM_WIN32(ERROR_BAD_PATHNAME) /* 9x */,
"SHCreateStreamOnFileA: expected HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND) "
"or HRESULT_FROM_WIN32(ERROR_BAD_PATHNAME), got 0x%08x\n", ret);
ok(stream == NULL, "SHCreateStreamOnFileA: expected a NULL IStream object, got %p\n", stream);
#if 0 /* This test crashes on WinXP SP2 */
@ -342,6 +346,11 @@ static void test_SHCreateStreamOnFileW(DWORD mode, DWORD stgm)
stream = NULL;
ret = (*pSHCreateStreamOnFileW)(test_file, mode | STGM_FAILIFTHERE | stgm, &stream);
if (ret == E_INVALIDARG) /* Win98 SE */ {
win_skip("Not supported\n");
return;
}
ok(ret == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), "SHCreateStreamOnFileW: expected HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), got 0x%08x\n", ret);
ok(stream == NULL, "SHCreateStreamOnFileW: expected a NULL IStream object, got %p\n", stream);
@ -423,6 +432,11 @@ static void test_SHCreateStreamOnFileEx(DWORD mode, DWORD stgm)
stream = NULL;
ret = (*pSHCreateStreamOnFileEx)(test_file, mode, 0, FALSE, template, &stream);
if (ret == HRESULT_FROM_WIN32(ERROR_ACCESS_DENIED)) {
win_skip("File probably locked by Anti-Virus/Spam software, trying again\n");
Sleep(1000);
ret = (*pSHCreateStreamOnFileEx)(test_file, mode, 0, FALSE, template, &stream);
}
ok( ret == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) ||
ret == HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER),
"SHCreateStreamOnFileEx: expected HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) or "
@ -482,6 +496,11 @@ static void test_SHCreateStreamOnFileEx(DWORD mode, DWORD stgm)
stream = NULL;
ret = (*pSHCreateStreamOnFileEx)(test_file, mode | STGM_CREATE | stgm, 0, FALSE, NULL, &stream);
if (ret == HRESULT_FROM_WIN32(ERROR_ACCESS_DENIED)) {
win_skip("File probably locked by Anti-Virus/Spam software, trying again\n");
Sleep(1000);
ret = (*pSHCreateStreamOnFileEx)(test_file, mode | STGM_CREATE | stgm, 0, FALSE, NULL, &stream);
}
ok(ret == S_OK, "SHCreateStreamOnFileEx: expected S_OK, got 0x%08x\n", ret);
ok(stream != NULL, "SHCreateStreamOnFileEx: expected a valid IStream object, got NULL\n");
@ -498,6 +517,11 @@ static void test_SHCreateStreamOnFileEx(DWORD mode, DWORD stgm)
stream = NULL;
ret = (*pSHCreateStreamOnFileEx)(test_file, mode | STGM_CREATE | stgm, 0, TRUE, NULL, &stream);
if (ret == HRESULT_FROM_WIN32(ERROR_ACCESS_DENIED)) {
win_skip("File probably locked by Anti-Virus/Spam software, trying again\n");
Sleep(1000);
ret = (*pSHCreateStreamOnFileEx)(test_file, mode | STGM_CREATE | stgm, 0, TRUE, NULL, &stream);
}
ok(ret == S_OK, "SHCreateStreamOnFileEx: expected S_OK, got 0x%08x\n", ret);
ok(stream != NULL, "SHCreateStreamOnFileEx: expected a valid IStream object, got NULL\n");

File diff suppressed because it is too large Load diff

View file

@ -28,12 +28,12 @@
#include "shlwapi.h"
#include "wininet.h"
static HMODULE hShlwapi;
static HRESULT (WINAPI *pPathIsValidCharA)(char,DWORD);
static HRESULT (WINAPI *pPathIsValidCharW)(WCHAR,DWORD);
static LPWSTR (WINAPI *pPathCombineW)(LPWSTR, LPCWSTR, LPCWSTR);
static HRESULT (WINAPI *pPathCreateFromUrlA)(LPCSTR, LPSTR, LPDWORD, DWORD);
static HRESULT (WINAPI *pPathCreateFromUrlW)(LPCWSTR, LPWSTR, LPDWORD, DWORD);
static BOOL (WINAPI *pPathAppendA)(LPSTR, LPCSTR);
/* ################ */
@ -300,6 +300,15 @@ static void test_PathIsValidCharA(void)
BOOL ret;
unsigned int c;
/* For whatever reason, PathIsValidCharA and PathAppendA share the same
* ordinal number in some native versions. Check this to prevent a crash.
*/
if (!pPathIsValidCharA || pPathIsValidCharA == (void*)pPathAppendA)
{
win_skip("PathIsValidCharA isn't available\n");
return;
}
for (c = 0; c < 0x7f; c++)
{
ret = pPathIsValidCharA( c, ~0U );
@ -318,6 +327,12 @@ static void test_PathIsValidCharW(void)
BOOL ret;
unsigned int c;
if (!pPathIsValidCharW)
{
win_skip("PathIsValidCharW isn't available\n");
return;
}
for (c = 0; c < 0x7f; c++)
{
ret = pPathIsValidCharW( c, ~0U );
@ -392,7 +407,13 @@ static void test_PathCombineW(void)
WCHAR wbuf[MAX_PATH+1], wstr1[MAX_PATH] = {'C',':','\\',0}, wstr2[MAX_PATH];
static const WCHAR expout[] = {'C',':','\\','A','A',0};
int i;
if (!pPathCombineW)
{
win_skip("PathCombineW isn't available\n");
return;
}
wszString2 = HeapAlloc(GetProcessHeap(), 0, MAX_PATH * sizeof(WCHAR));
/* NULL test */
@ -1312,43 +1333,60 @@ static void test_PathUnquoteSpaces(void)
}
}
static void test_PathGetDriveNumber(void)
{
static const CHAR test1A[] = "a:\\test.file";
static const CHAR test2A[] = "file:////b:\\test.file";
static const CHAR test3A[] = "file:///c:\\test.file";
static const CHAR test4A[] = "file:\\\\c:\\test.file";
int ret;
SetLastError(0xdeadbeef);
ret = PathGetDriveNumberA(NULL);
ok(ret == -1, "got %d\n", ret);
ok(GetLastError() == 0xdeadbeef, "got %d\n", GetLastError());
ret = PathGetDriveNumberA(test1A);
ok(ret == 0, "got %d\n", ret);
ret = PathGetDriveNumberA(test2A);
ok(ret == -1, "got %d\n", ret);
ret = PathGetDriveNumberA(test3A);
ok(ret == -1, "got %d\n", ret);
ret = PathGetDriveNumberA(test4A);
ok(ret == -1, "got %d\n", ret);
}
/* ################ */
START_TEST(path)
{
hShlwapi = GetModuleHandleA("shlwapi.dll");
pPathCreateFromUrlA = (void*)GetProcAddress(hShlwapi, "PathCreateFromUrlA");
pPathCreateFromUrlW = (void*)GetProcAddress(hShlwapi, "PathCreateFromUrlW");
HMODULE hShlwapi = GetModuleHandleA("shlwapi.dll");
test_PathSearchAndQualify();
test_PathCreateFromUrl();
test_PathIsUrl();
pPathCreateFromUrlA = (void*)GetProcAddress(hShlwapi, "PathCreateFromUrlA");
pPathCreateFromUrlW = (void*)GetProcAddress(hShlwapi, "PathCreateFromUrlW");
pPathCombineW = (void*)GetProcAddress(hShlwapi, "PathCombineW");
pPathIsValidCharA = (void*)GetProcAddress(hShlwapi, (LPSTR)455);
pPathIsValidCharW = (void*)GetProcAddress(hShlwapi, (LPSTR)456);
pPathAppendA = (void*)GetProcAddress(hShlwapi, "PathAppendA");
test_PathAddBackslash();
test_PathMakePretty();
test_PathMatchSpec();
test_PathSearchAndQualify();
test_PathCreateFromUrl();
test_PathIsUrl();
test_PathAddBackslash();
test_PathMakePretty();
test_PathMatchSpec();
/* For whatever reason, PathIsValidCharA and PathAppendA share the same
* ordinal number in some native versions. Check this to prevent a crash.
*/
pPathIsValidCharA = (void*)GetProcAddress(hShlwapi, (LPSTR)455);
if (pPathIsValidCharA && pPathIsValidCharA != (void*)GetProcAddress(hShlwapi, "PathAppendA"))
{
test_PathIsValidCharA();
test_PathIsValidCharW();
pPathIsValidCharW = (void*)GetProcAddress(hShlwapi, (LPSTR)456);
if (pPathIsValidCharW) test_PathIsValidCharW();
}
pPathCombineW = (void*)GetProcAddress(hShlwapi, "PathCombineW");
if (pPathCombineW)
test_PathCombineW();
test_PathCombineA();
test_PathAppendA();
test_PathCanonicalizeA();
test_PathFindExtensionA();
test_PathBuildRootA();
test_PathCommonPrefixA();
test_PathUnquoteSpaces();
test_PathCombineA();
test_PathAppendA();
test_PathCanonicalizeA();
test_PathFindExtensionA();
test_PathBuildRootA();
test_PathCommonPrefixA();
test_PathUnquoteSpaces();
test_PathGetDriveNumber();
}

View file

@ -3,7 +3,7 @@
<group>
<module name="shlwapi_winetest" type="win32cui" installbase="bin" installname="shlwapi_winetest.exe" allowwarnings="true">
<include base="shlwapi_winetest">.</include>
<define name="__ROS_LONG64__" />
<define name="__ROS_LONG64__" />
<file>assoc.c</file>
<file>clist.c</file>
<file>clsid.c</file>
@ -21,6 +21,7 @@
<library>advapi32</library>
<library>ole32</library>
<library>oleaut32</library>
<library>user32</library>
<library>ntdll</library>
</module>
</group>

View file

@ -863,6 +863,33 @@ static void test_StrXXX_overflows(void)
else
win_skip("StrCatBuffA() is not available\n");
if (0)
{
/* crashes on XP */
StrCpyNW(wbuf, (LPCWSTR)0x1, 10);
StrCpyNW((LPWSTR)0x1, wstr1, 10);
}
memset(wbuf, 0xbf, sizeof(wbuf));
expect_eq(StrCpyNW(wbuf, (LPCWSTR)0x1, 1), wbuf, PWCHAR, "%p");
expect_eq(wbuf[0], 0, WCHAR, "%x");
expect_eq(wbuf[1], (WCHAR)0xbfbf, WCHAR, "%x");
memset(wbuf, 0xbf, sizeof(wbuf));
expect_eq(StrCpyNW(wbuf, 0, 10), wbuf, PWCHAR, "%p");
expect_eq(wbuf[0], 0, WCHAR, "%x");
expect_eq(wbuf[1], (WCHAR)0xbfbf, WCHAR, "%x");
memset(wbuf, 0xbf, sizeof(wbuf));
expect_eq(StrCpyNW(wbuf, 0, 0), wbuf, PWCHAR, "%p");
expect_eq(wbuf[0], (WCHAR)0xbfbf, WCHAR, "%x");
expect_eq(wbuf[1], (WCHAR)0xbfbf, WCHAR, "%x");
memset(wbuf, 0xbf, sizeof(wbuf));
expect_eq(StrCpyNW(wbuf, wstr1, 0), wbuf, PWCHAR, "%p");
expect_eq(wbuf[0], (WCHAR)0xbfbf, WCHAR, "%x");
expect_eq(wbuf[1], (WCHAR)0xbfbf, WCHAR, "%x");
memset(wbuf, 0xbf, sizeof(wbuf));
expect_eq(StrCpyNW(wbuf, wstr1, 10), wbuf, PWCHAR, "%p");
expect_eq(wbuf[9], 0, WCHAR, "%x");

View file

@ -160,6 +160,7 @@ static const TEST_URL_CANONICALIZE TEST_CANONICALIZE[] = {
{"A", 0, S_OK, "A", FALSE},
{"/uri-res/N2R?urn:sha1:B3K", URL_DONT_ESCAPE_EXTRA_INFO | URL_WININET_COMPATIBILITY /*0x82000000*/, S_OK, "/uri-res/N2R?urn:sha1:B3K", FALSE} /*LimeWire online installer calls this*/,
{"http:www.winehq.org/dir/../index.html", 0, S_OK, "http:www.winehq.org/index.html"},
{"http://localhost/test.html", URL_FILE_USE_PATHURL, S_OK, "http://localhost/test.html"}
};
/* ################ */
@ -278,6 +279,11 @@ static const TEST_URL_COMBINE TEST_COMBINE[] = {
{"http://www.winehq.org/tests/../tests/", "/tests10/..", URL_DONT_SIMPLIFY, S_OK, "http://www.winehq.org/tests10/.."},
{"http://www.winehq.org/tests/../", "tests11", URL_DONT_SIMPLIFY, S_OK, "http://www.winehq.org/tests/../tests11"},
{"file:///C:\\dir\\file.txt", "test.txt", 0, S_OK, "file:///C:/dir/test.txt"},
{"file:///C:\\dir\\file.txt#hash\\hash", "test.txt", 0, S_OK, "file:///C:/dir/file.txt#hash/test.txt"},
{"file:///C:\\dir\\file.html#hash\\hash", "test.html", 0, S_OK, "file:///C:/dir/test.html"},
{"file:///C:\\dir\\file.htm#hash\\hash", "test.htm", 0, S_OK, "file:///C:/dir/test.htm"},
{"file:///C:\\dir\\file.hTmL#hash\\hash", "test.hTmL", 0, S_OK, "file:///C:/dir/test.hTmL"},
{"file:///C:\\dir.html\\file.txt#hash\\hash", "test.txt", 0, S_OK, "file:///C:/dir.html/file.txt#hash/test.txt"},
{"C:\\winehq\\winehq.txt", "C:\\Test\\test.txt", 0, S_OK, "file:///C:/Test/test.txt"},
{"http://www.winehq.org/test/", "test%20file.txt", 0, S_OK, "http://www.winehq.org/test/test%20file.txt"},
{"http://www.winehq.org/test/", "test%20file.txt", URL_FILE_USE_PATHURL, S_OK, "http://www.winehq.org/test/test%20file.txt"},
@ -537,6 +543,13 @@ static void test_url_part(const char* szUrl, DWORD dwPart, DWORD dwFlags, const
HRESULT res;
DWORD dwSize;
dwSize = 1;
res = pUrlGetPartA(szUrl, szPart, &dwSize, dwPart, dwFlags);
ok(res == E_POINTER, "UrlGetPart for \"%s\" gave: 0x%08x\n", szUrl, res);
ok(dwSize == strlen(szExpected)+1 ||
(*szExpected == '?' && dwSize == strlen(szExpected)),
"UrlGetPart for \"%s\" gave size: %u\n", szUrl, dwSize);
dwSize = INTERNET_MAX_URL_LENGTH;
res = pUrlGetPartA(szUrl, szPart, &dwSize, dwPart, dwFlags);
ok(res == S_OK,
@ -570,6 +583,7 @@ static void test_UrlGetPart(void)
{
const char* file_url = "file://h o s t/c:/windows/file";
const char* http_url = "http://user:pass 123@www.wine hq.org";
const char* res_url = "res://some.dll/find.dlg";
const char* about_url = "about:blank";
CHAR szPart[INTERNET_MAX_URL_LENGTH];
@ -581,20 +595,38 @@ static void test_UrlGetPart(void)
return;
}
res = pUrlGetPartA(NULL, NULL, NULL, URL_PART_SCHEME, 0);
ok(res == E_INVALIDARG, "null params gave: 0x%08x\n", res);
res = pUrlGetPartA(NULL, szPart, &dwSize, URL_PART_SCHEME, 0);
ok(res == E_INVALIDARG, "null URL gave: 0x%08x\n", res);
res = pUrlGetPartA(res_url, NULL, &dwSize, URL_PART_SCHEME, 0);
ok(res == E_INVALIDARG, "null szPart gave: 0x%08x\n", res);
res = pUrlGetPartA(res_url, szPart, NULL, URL_PART_SCHEME, 0);
ok(res == E_INVALIDARG, "null URL gave: 0x%08x\n", res);
dwSize = 0;
szPart[0]='x'; szPart[1]=0;
res = pUrlGetPartA("hi", szPart, &dwSize, URL_PART_SCHEME, 0);
ok(res == E_INVALIDARG, "UrlGetPartA(*pcchOut = 0) returned %08X\n", res);
ok(szPart[0] == 'x' && szPart[1] == 0, "UrlGetPartA(*pcchOut = 0) modified szPart: \"%s\"\n", szPart);
ok(dwSize == 0, "dwSize = %d\n", dwSize);
dwSize = sizeof szPart;
szPart[0]='x'; szPart[1]=0;
res = pUrlGetPartA("hi", szPart, &dwSize, URL_PART_SCHEME, 0);
todo_wine {
ok (res==S_FALSE, "UrlGetPartA(\"hi\") returned %08X\n", res);
ok(szPart[0]==0, "UrlGetPartA(\"hi\") return \"%s\" instead of \"\"\n", szPart);
}
ok(dwSize == 0, "dwSize = %d\n", dwSize);
dwSize = sizeof szPart;
szPart[0]='x'; szPart[1]=0;
res = pUrlGetPartA("hi", szPart, &dwSize, URL_PART_QUERY, 0);
todo_wine {
ok (res==S_FALSE, "UrlGetPartA(\"hi\") returned %08X\n", res);
ok(szPart[0]==0, "UrlGetPartA(\"hi\") return \"%s\" instead of \"\"\n", szPart);
}
ok(dwSize == 0, "dwSize = %d\n", dwSize);
test_url_part(TEST_URL_3, URL_PART_HOSTNAME, 0, "localhost");
test_url_part(TEST_URL_3, URL_PART_PORT, 0, "21");
@ -614,9 +646,20 @@ static void test_UrlGetPart(void)
res = pUrlGetPartA(about_url, szPart, &dwSize, URL_PART_HOSTNAME, 0);
ok(res==E_FAIL, "returned %08x\n", res);
test_url_part(res_url, URL_PART_SCHEME, 0, "res");
test_url_part("http://www.winehq.org", URL_PART_HOSTNAME, URL_PARTFLAG_KEEPSCHEME, "http:www.winehq.org");
dwSize = sizeof szPart;
szPart[0]='x'; szPart[1]=0;
res = pUrlGetPartA(res_url, szPart, &dwSize, URL_PART_QUERY, 0);
ok(res==S_FALSE, "UrlGetPartA returned %08X\n", res);
ok(szPart[0]==0, "UrlGetPartA gave \"%s\" instead of \"\"\n", szPart);
ok(dwSize == 0, "dwSize = %d\n", dwSize);
dwSize = sizeof(szPart);
res = pUrlGetPartA("file://c:\\index.htm", szPart, &dwSize, URL_PART_HOSTNAME, 0);
ok(res==S_FALSE, "returned %08x\n", res);
ok(dwSize == 0, "dwSize = %d\n", dwSize);
dwSize = sizeof(szPart);
szPart[0] = 'x'; szPart[1] = '\0';
@ -624,6 +667,11 @@ static void test_UrlGetPart(void)
ok(res==S_FALSE, "returned %08x\n", res);
ok(szPart[0] == '\0', "szPart[0] = %c\n", szPart[0]);
ok(dwSize == 0, "dwSize = %d\n", dwSize);
dwSize = sizeof(szPart);
szPart[0] = 'x'; szPart[1] = '\0';
res = pUrlGetPartA("index.htm", szPart, &dwSize, URL_PART_HOSTNAME, 0);
ok(res==E_FAIL, "returned %08x\n", res);
}
/* ########################### */
@ -1000,6 +1048,15 @@ static void test_UrlCreateFromPath(void)
/* ########################### */
static void test_UrlIs_null(DWORD flag)
{
BOOL ret;
ret = pUrlIsA(NULL, flag);
ok(ret == FALSE, "pUrlIsA(NULL, %d) failed\n", flag);
ret = pUrlIsW(NULL, flag);
ok(ret == FALSE, "pUrlIsW(NULL, %d) failed\n", flag);
}
static void test_UrlIs(void)
{
BOOL ret;
@ -1011,6 +1068,14 @@ static void test_UrlIs(void)
return;
}
test_UrlIs_null(URLIS_APPLIABLE);
test_UrlIs_null(URLIS_DIRECTORY);
test_UrlIs_null(URLIS_FILEURL);
test_UrlIs_null(URLIS_HASQUERY);
test_UrlIs_null(URLIS_NOHISTORY);
test_UrlIs_null(URLIS_OPAQUE);
test_UrlIs_null(URLIS_URL);
for(i = 0; i < sizeof(TEST_PATH_IS_URL) / sizeof(TEST_PATH_IS_URL[0]); i++) {
MultiByteToWideChar(CP_ACP, 0, TEST_PATH_IS_URL[i].path, -1, wurl, 80);

View file

@ -54,45 +54,289 @@
* Test helper macros
*/
#ifdef _WIN64
#define TEST_TYPE_SIZE(type, size) C_ASSERT(sizeof(type) == size);
# define TEST_TYPE_SIZE(type, size)
#ifdef TYPE_ALIGNMENT
# define TEST_TYPE_ALIGN(type, align) C_ASSERT(TYPE_ALIGNMENT(type) == align);
#else
# define TEST_TYPE_ALIGN(type, align)
#endif
#ifdef _TYPE_ALIGNMENT
# define TEST_TARGET_ALIGN(type, align) C_ASSERT(_TYPE_ALIGNMENT(*(type)0) == align);
# define TEST_FIELD_ALIGN(type, field, align) C_ASSERT(_TYPE_ALIGNMENT(((type*)0)->field) == align);
#else
# define TEST_TARGET_ALIGN(type, align)
# define TEST_FIELD_ALIGN(type, field, align)
# define TEST_FIELD_OFFSET(type, field, offset)
#else
# define TEST_TYPE_SIZE(type, size) C_ASSERT(sizeof(type) == size);
# ifdef TYPE_ALIGNMENT
# define TEST_TYPE_ALIGN(type, align) C_ASSERT(TYPE_ALIGNMENT(type) == align);
# else
# define TEST_TYPE_ALIGN(type, align)
# endif
# ifdef _TYPE_ALIGNMENT
# define TEST_TARGET_ALIGN(type, align) C_ASSERT(_TYPE_ALIGNMENT(*(type)0) == align);
# define TEST_FIELD_ALIGN(type, field, align) C_ASSERT(_TYPE_ALIGNMENT(((type*)0)->field) == align);
# else
# define TEST_TARGET_ALIGN(type, align)
# define TEST_FIELD_ALIGN(type, field, align)
# endif
# define TEST_FIELD_OFFSET(type, field, offset) C_ASSERT(FIELD_OFFSET(type, field) == offset);
#endif
#define TEST_FIELD_OFFSET(type, field, offset) C_ASSERT(FIELD_OFFSET(type, field) == offset);
#define TEST_TARGET_SIZE(type, size) TEST_TYPE_SIZE(*(type)0, size)
#define TEST_FIELD_SIZE(type, field, size) TEST_TYPE_SIZE((((type*)0)->field), size)
#define TEST_TYPE_SIGNED(type) C_ASSERT((type) -1 < 0);
#define TEST_TYPE_UNSIGNED(type) C_ASSERT((type) -1 > 0);
#ifdef _WIN64
static void test_pack_BINDINFO(void)
{
/* BINDINFO (pack 4) */
/* BINDINFO */
TEST_FIELD_SIZE (BINDINFO, cbSize, 4)
TEST_FIELD_ALIGN (BINDINFO, cbSize, 4)
TEST_FIELD_OFFSET(BINDINFO, cbSize, 0)
TEST_FIELD_SIZE (BINDINFO, szExtraInfo, 8)
TEST_FIELD_ALIGN (BINDINFO, szExtraInfo, 8)
TEST_FIELD_OFFSET(BINDINFO, szExtraInfo, 8)
}
static void test_pack_IBindHost(void)
{
/* IBindHost */
}
static void test_pack_IBindHostVtbl(void)
{
/* IBindHostVtbl */
}
static void test_pack_IBindStatusCallback(void)
{
/* IBindStatusCallback */
}
static void test_pack_IBindStatusCallbackVtbl(void)
{
/* IBindStatusCallbackVtbl */
}
static void test_pack_IBinding(void)
{
/* IBinding */
}
static void test_pack_IBindingVtbl(void)
{
/* IBindingVtbl */
}
static void test_pack_IInternetProtocolInfo(void)
{
/* IInternetProtocolInfo */
}
static void test_pack_IInternetProtocolInfoVtbl(void)
{
/* IInternetProtocolInfoVtbl */
}
static void test_pack_IInternetSession(void)
{
/* IInternetSession */
}
static void test_pack_IInternetSessionVtbl(void)
{
/* IInternetSessionVtbl */
}
static void test_pack_IPersistMoniker(void)
{
/* IPersistMoniker */
}
static void test_pack_IPersistMonikerVtbl(void)
{
/* IPersistMonikerVtbl */
}
static void test_pack_IWinInetHttpInfo(void)
{
/* IWinInetHttpInfo */
}
static void test_pack_IWinInetHttpInfoVtbl(void)
{
/* IWinInetHttpInfoVtbl */
}
static void test_pack_IWinInetInfo(void)
{
/* IWinInetInfo */
}
static void test_pack_IWinInetInfoVtbl(void)
{
/* IWinInetInfoVtbl */
}
static void test_pack_LPBINDHOST(void)
{
/* LPBINDHOST */
TEST_TYPE_SIZE (LPBINDHOST, 8)
TEST_TYPE_ALIGN (LPBINDHOST, 8)
}
static void test_pack_LPBINDING(void)
{
/* LPBINDING */
TEST_TYPE_SIZE (LPBINDING, 8)
TEST_TYPE_ALIGN (LPBINDING, 8)
}
static void test_pack_LPBINDSTATUSCALLBACK(void)
{
/* LPBINDSTATUSCALLBACK */
TEST_TYPE_SIZE (LPBINDSTATUSCALLBACK, 8)
TEST_TYPE_ALIGN (LPBINDSTATUSCALLBACK, 8)
}
static void test_pack_LPIINTERNETPROTOCOLINFO(void)
{
/* LPIINTERNETPROTOCOLINFO */
TEST_TYPE_SIZE (LPIINTERNETPROTOCOLINFO, 8)
TEST_TYPE_ALIGN (LPIINTERNETPROTOCOLINFO, 8)
}
static void test_pack_LPIINTERNETSESSION(void)
{
/* LPIINTERNETSESSION */
TEST_TYPE_SIZE (LPIINTERNETSESSION, 8)
TEST_TYPE_ALIGN (LPIINTERNETSESSION, 8)
}
static void test_pack_LPPERSISTMONIKER(void)
{
/* LPPERSISTMONIKER */
TEST_TYPE_SIZE (LPPERSISTMONIKER, 8)
TEST_TYPE_ALIGN (LPPERSISTMONIKER, 8)
}
static void test_pack_LPREMFORMATETC(void)
{
/* LPREMFORMATETC */
TEST_TYPE_SIZE (LPREMFORMATETC, 8)
TEST_TYPE_ALIGN (LPREMFORMATETC, 8)
}
static void test_pack_LPREMSECURITY_ATTRIBUTES(void)
{
/* LPREMSECURITY_ATTRIBUTES */
TEST_TYPE_SIZE (LPREMSECURITY_ATTRIBUTES, 8)
TEST_TYPE_ALIGN (LPREMSECURITY_ATTRIBUTES, 8)
}
static void test_pack_LPWININETHTTPINFO(void)
{
/* LPWININETHTTPINFO */
TEST_TYPE_SIZE (LPWININETHTTPINFO, 8)
TEST_TYPE_ALIGN (LPWININETHTTPINFO, 8)
}
static void test_pack_LPWININETINFO(void)
{
/* LPWININETINFO */
TEST_TYPE_SIZE (LPWININETINFO, 8)
TEST_TYPE_ALIGN (LPWININETINFO, 8)
}
static void test_pack_PREMSECURITY_ATTRIBUTES(void)
{
/* PREMSECURITY_ATTRIBUTES */
TEST_TYPE_SIZE (PREMSECURITY_ATTRIBUTES, 8)
TEST_TYPE_ALIGN (PREMSECURITY_ATTRIBUTES, 8)
}
static void test_pack_REMSECURITY_ATTRIBUTES(void)
{
/* REMSECURITY_ATTRIBUTES */
TEST_TYPE_SIZE (REMSECURITY_ATTRIBUTES, 12)
TEST_TYPE_ALIGN (REMSECURITY_ATTRIBUTES, 4)
TEST_FIELD_SIZE (REMSECURITY_ATTRIBUTES, nLength, 4)
TEST_FIELD_ALIGN (REMSECURITY_ATTRIBUTES, nLength, 4)
TEST_FIELD_OFFSET(REMSECURITY_ATTRIBUTES, nLength, 0)
TEST_FIELD_SIZE (REMSECURITY_ATTRIBUTES, lpSecurityDescriptor, 4)
TEST_FIELD_ALIGN (REMSECURITY_ATTRIBUTES, lpSecurityDescriptor, 4)
TEST_FIELD_OFFSET(REMSECURITY_ATTRIBUTES, lpSecurityDescriptor, 4)
TEST_FIELD_SIZE (REMSECURITY_ATTRIBUTES, bInheritHandle, 4)
TEST_FIELD_ALIGN (REMSECURITY_ATTRIBUTES, bInheritHandle, 4)
TEST_FIELD_OFFSET(REMSECURITY_ATTRIBUTES, bInheritHandle, 8)
}
static void test_pack_RemBINDINFO(void)
{
/* RemBINDINFO */
TEST_TYPE_SIZE (RemBINDINFO, 96)
TEST_TYPE_ALIGN (RemBINDINFO, 8)
TEST_FIELD_SIZE (RemBINDINFO, cbSize, 4)
TEST_FIELD_ALIGN (RemBINDINFO, cbSize, 4)
TEST_FIELD_OFFSET(RemBINDINFO, cbSize, 0)
TEST_FIELD_SIZE (RemBINDINFO, szExtraInfo, 8)
TEST_FIELD_ALIGN (RemBINDINFO, szExtraInfo, 8)
TEST_FIELD_OFFSET(RemBINDINFO, szExtraInfo, 8)
TEST_FIELD_SIZE (RemBINDINFO, grfBindInfoF, 4)
TEST_FIELD_ALIGN (RemBINDINFO, grfBindInfoF, 4)
TEST_FIELD_OFFSET(RemBINDINFO, grfBindInfoF, 16)
TEST_FIELD_SIZE (RemBINDINFO, dwBindVerb, 4)
TEST_FIELD_ALIGN (RemBINDINFO, dwBindVerb, 4)
TEST_FIELD_OFFSET(RemBINDINFO, dwBindVerb, 20)
TEST_FIELD_SIZE (RemBINDINFO, szCustomVerb, 8)
TEST_FIELD_ALIGN (RemBINDINFO, szCustomVerb, 8)
TEST_FIELD_OFFSET(RemBINDINFO, szCustomVerb, 24)
TEST_FIELD_SIZE (RemBINDINFO, cbstgmedData, 4)
TEST_FIELD_ALIGN (RemBINDINFO, cbstgmedData, 4)
TEST_FIELD_OFFSET(RemBINDINFO, cbstgmedData, 32)
TEST_FIELD_SIZE (RemBINDINFO, dwOptions, 4)
TEST_FIELD_ALIGN (RemBINDINFO, dwOptions, 4)
TEST_FIELD_OFFSET(RemBINDINFO, dwOptions, 36)
TEST_FIELD_SIZE (RemBINDINFO, dwOptionsFlags, 4)
TEST_FIELD_ALIGN (RemBINDINFO, dwOptionsFlags, 4)
TEST_FIELD_OFFSET(RemBINDINFO, dwOptionsFlags, 40)
TEST_FIELD_SIZE (RemBINDINFO, dwCodePage, 4)
TEST_FIELD_ALIGN (RemBINDINFO, dwCodePage, 4)
TEST_FIELD_OFFSET(RemBINDINFO, dwCodePage, 44)
TEST_FIELD_SIZE (RemBINDINFO, securityAttributes, 12)
TEST_FIELD_ALIGN (RemBINDINFO, securityAttributes, 4)
TEST_FIELD_OFFSET(RemBINDINFO, securityAttributes, 48)
TEST_FIELD_SIZE (RemBINDINFO, iid, 16)
TEST_FIELD_ALIGN (RemBINDINFO, iid, 4)
TEST_FIELD_OFFSET(RemBINDINFO, iid, 60)
TEST_FIELD_SIZE (RemBINDINFO, pUnk, 8)
TEST_FIELD_ALIGN (RemBINDINFO, pUnk, 8)
TEST_FIELD_OFFSET(RemBINDINFO, pUnk, 80)
TEST_FIELD_SIZE (RemBINDINFO, dwReserved, 4)
TEST_FIELD_ALIGN (RemBINDINFO, dwReserved, 4)
TEST_FIELD_OFFSET(RemBINDINFO, dwReserved, 88)
}
static void test_pack_RemFORMATETC(void)
{
/* RemFORMATETC */
TEST_TYPE_SIZE (RemFORMATETC, 20)
TEST_TYPE_ALIGN (RemFORMATETC, 4)
TEST_FIELD_SIZE (RemFORMATETC, cfFormat, 4)
TEST_FIELD_ALIGN (RemFORMATETC, cfFormat, 4)
TEST_FIELD_OFFSET(RemFORMATETC, cfFormat, 0)
TEST_FIELD_SIZE (RemFORMATETC, ptd, 4)
TEST_FIELD_ALIGN (RemFORMATETC, ptd, 4)
TEST_FIELD_OFFSET(RemFORMATETC, ptd, 4)
TEST_FIELD_SIZE (RemFORMATETC, dwAspect, 4)
TEST_FIELD_ALIGN (RemFORMATETC, dwAspect, 4)
TEST_FIELD_OFFSET(RemFORMATETC, dwAspect, 8)
TEST_FIELD_SIZE (RemFORMATETC, lindex, 4)
TEST_FIELD_ALIGN (RemFORMATETC, lindex, 4)
TEST_FIELD_OFFSET(RemFORMATETC, lindex, 12)
TEST_FIELD_SIZE (RemFORMATETC, tymed, 4)
TEST_FIELD_ALIGN (RemFORMATETC, tymed, 4)
TEST_FIELD_OFFSET(RemFORMATETC, tymed, 16)
}
#else /* _WIN64 */
static void test_pack_BINDINFO(void)
{
/* BINDINFO */
TEST_FIELD_SIZE (BINDINFO, cbSize, 4)
TEST_FIELD_ALIGN (BINDINFO, cbSize, 4)
TEST_FIELD_OFFSET(BINDINFO, cbSize, 0)
@ -108,7 +352,7 @@ static void test_pack_IBindHost(void)
static void test_pack_IBindHostVtbl(void)
{
/* IBindHostVtbl (pack 4) */
/* IBindHostVtbl */
}
static void test_pack_IBindStatusCallback(void)
@ -118,7 +362,7 @@ static void test_pack_IBindStatusCallback(void)
static void test_pack_IBindStatusCallbackVtbl(void)
{
/* IBindStatusCallbackVtbl (pack 4) */
/* IBindStatusCallbackVtbl */
}
static void test_pack_IBinding(void)
@ -128,7 +372,7 @@ static void test_pack_IBinding(void)
static void test_pack_IBindingVtbl(void)
{
/* IBindingVtbl (pack 4) */
/* IBindingVtbl */
}
static void test_pack_IInternetProtocolInfo(void)
@ -138,7 +382,7 @@ static void test_pack_IInternetProtocolInfo(void)
static void test_pack_IInternetProtocolInfoVtbl(void)
{
/* IInternetProtocolInfoVtbl (pack 4) */
/* IInternetProtocolInfoVtbl */
}
static void test_pack_IInternetSession(void)
@ -148,7 +392,7 @@ static void test_pack_IInternetSession(void)
static void test_pack_IInternetSessionVtbl(void)
{
/* IInternetSessionVtbl (pack 4) */
/* IInternetSessionVtbl */
}
static void test_pack_IPersistMoniker(void)
@ -158,7 +402,7 @@ static void test_pack_IPersistMoniker(void)
static void test_pack_IPersistMonikerVtbl(void)
{
/* IPersistMonikerVtbl (pack 4) */
/* IPersistMonikerVtbl */
}
static void test_pack_IWinInetHttpInfo(void)
@ -168,7 +412,7 @@ static void test_pack_IWinInetHttpInfo(void)
static void test_pack_IWinInetHttpInfoVtbl(void)
{
/* IWinInetHttpInfoVtbl (pack 4) */
/* IWinInetHttpInfoVtbl */
}
static void test_pack_IWinInetInfo(void)
@ -178,7 +422,7 @@ static void test_pack_IWinInetInfo(void)
static void test_pack_IWinInetInfoVtbl(void)
{
/* IWinInetInfoVtbl (pack 4) */
/* IWinInetInfoVtbl */
}
static void test_pack_LPBINDHOST(void)
@ -260,7 +504,7 @@ static void test_pack_PREMSECURITY_ATTRIBUTES(void)
static void test_pack_REMSECURITY_ATTRIBUTES(void)
{
/* REMSECURITY_ATTRIBUTES (pack 4) */
/* REMSECURITY_ATTRIBUTES */
TEST_TYPE_SIZE (REMSECURITY_ATTRIBUTES, 12)
TEST_TYPE_ALIGN (REMSECURITY_ATTRIBUTES, 4)
TEST_FIELD_SIZE (REMSECURITY_ATTRIBUTES, nLength, 4)
@ -276,7 +520,7 @@ static void test_pack_REMSECURITY_ATTRIBUTES(void)
static void test_pack_RemBINDINFO(void)
{
/* RemBINDINFO (pack 4) */
/* RemBINDINFO */
TEST_TYPE_SIZE (RemBINDINFO, 72)
TEST_TYPE_ALIGN (RemBINDINFO, 4)
TEST_FIELD_SIZE (RemBINDINFO, cbSize, 4)
@ -322,7 +566,7 @@ static void test_pack_RemBINDINFO(void)
static void test_pack_RemFORMATETC(void)
{
/* RemFORMATETC (pack 4) */
/* RemFORMATETC */
TEST_TYPE_SIZE (RemFORMATETC, 20)
TEST_TYPE_ALIGN (RemFORMATETC, 4)
TEST_FIELD_SIZE (RemFORMATETC, cfFormat, 4)
@ -342,6 +586,8 @@ static void test_pack_RemFORMATETC(void)
TEST_FIELD_OFFSET(RemFORMATETC, tymed, 16)
}
#endif /* _WIN64 */
static void test_pack(void)
{
test_pack_BINDINFO();
@ -379,9 +625,5 @@ static void test_pack(void)
START_TEST(generated)
{
#ifdef _WIN64
ok(0, "The type size / alignment tests don't support Win64 yet\n");
#else
test_pack();
#endif
}

View file

@ -63,6 +63,8 @@ DEFINE_EXPECT(QI_IInternetProtocolInfo);
DEFINE_EXPECT(CreateInstance);
DEFINE_EXPECT(unk_Release);
static HRESULT (WINAPI *pCoInternetCompareUrl)(LPCWSTR, LPCWSTR, DWORD);
static void test_CreateFormatEnum(void)
{
IEnumFORMATETC *fenum = NULL, *fenum2 = NULL;
@ -363,13 +365,18 @@ static void test_CoInternetCompareUrl(void)
{
HRESULT hres;
hres = CoInternetCompareUrl(url1, url1, 0);
if (!pCoInternetCompareUrl) {
win_skip("CoInternetCompareUrl not found\n");
return;
}
hres = pCoInternetCompareUrl(url1, url1, 0);
ok(hres == S_OK, "CoInternetParseUrl failed: %08x\n", hres);
hres = CoInternetCompareUrl(url1, url3, 0);
hres = pCoInternetCompareUrl(url1, url3, 0);
ok(hres == S_FALSE, "CoInternetParseUrl failed: %08x\n", hres);
hres = CoInternetCompareUrl(url3, url1, 0);
hres = pCoInternetCompareUrl(url3, url1, 0);
ok(hres == S_FALSE, "CoInternetParseUrl failed: %08x\n", hres);
}
@ -1402,10 +1409,15 @@ static void test_IsValidURL(void)
START_TEST(misc)
{
HMODULE hurlmon;
OleInitialize(NULL);
register_protocols();
hurlmon = GetModuleHandle("urlmon.dll");
pCoInternetCompareUrl = (void *) GetProcAddress(hurlmon, "CoInternetCompareUrl");
test_CreateFormatEnum();
test_RegisterFormatEnumerator();
test_CoInternetParseUrl();

View file

@ -1,6 +1,6 @@
/*
* Copyright 2005-2006 Jacek Caban for CodeWeavers
* Copyright 2009 Detlef Riekenberg
* Copyright 2009-2010 Detlef Riekenberg
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -35,21 +35,22 @@
#include "initguid.h"
static HRESULT (WINAPI *pCoInternetGetSecurityUrl)(LPCWSTR, LPWSTR*, PSUACTION, DWORD);
static const WCHAR url1[] = {'r','e','s',':','/','/','m','s','h','t','m','l','.','d','l','l',
'/','b','l','a','n','k','.','h','t','m',0};
static const WCHAR url2[] = {'i','n','d','e','x','.','h','t','m',0};
static const WCHAR url3[] = {'f','i','l','e',':','/','/','c',':','\\','I','n','d','e','x','.','h','t','m',0};
static const WCHAR url4[] = {'f','i','l','e',':','s','o','m','e','%','2','0','f','i','l','e',
'%','2','e','j','p','g',0};
static const WCHAR url5[] = {'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q',
'.','o','r','g',0};
static const WCHAR url5[] = {'h','t','t','p',':','/','/','w','w','w','.','z','o','n','e','3',
'.','w','i','n','e','t','e','s','t',0};
static const WCHAR url6[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
static const WCHAR url7[] = {'f','t','p',':','/','/','w','i','n','e','h','q','.','o','r','g','/',
'f','i','l','e','.','t','e','s','t',0};
static const WCHAR url7[] = {'f','t','p',':','/','/','z','o','n','e','3',
'.','w','i','n','e','t','e','s','t','/','f','i','l','e','.','t','e','s','t',0};
static const WCHAR url8[] = {'t','e','s','t',':','1','2','3','a','b','c',0};
static const WCHAR url9[] =
{'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q','.','o','r','g',
'/','s','i','t','e','/','a','b','o','u','t',0};
static const WCHAR url9[] = {'h','t','t','p',':','/','/','w','w','w','.','z','o','n','e','3',
'.','w','i','n','e','t','e','s','t', '/','s','i','t','e','/','a','b','o','u','t',0};
static const WCHAR url10[] = {'f','i','l','e',':','/','/','s','o','m','e','%','2','0','f','i','l','e',
'.','j','p','g',0};
@ -58,11 +59,11 @@ static const WCHAR url4e[] = {'f','i','l','e',':','s','o','m','e',' ','f','i','l
static const BYTE secid1[] = {'f','i','l','e',':',0,0,0,0};
static const BYTE secid5[] = {'h','t','t','p',':','w','w','w','.','w','i','n','e','h','q',
'.','o','r','g',3,0,0,0};
static const BYTE secid5[] = {'h','t','t','p',':','w','w','w','.','z','o','n','e','3',
'.','w','i','n','e','t','e','s','t',3,0,0,0};
static const BYTE secid6[] = {'a','b','o','u','t',':','b','l','a','n','k',3,0,0,0};
static const BYTE secid7[] = {'f','t','p',':','w','i','n','e','h','q','.','o','r','g',
3,0,0,0};
static const BYTE secid7[] = {'f','t','p',':','z','o','n','e','3',
'.','w','i','n','e','t','e','s','t',3,0,0,0};
static const BYTE secid10[] =
{'f','i','l','e',':','s','o','m','e','%','2','0','f','i','l','e','.','j','p','g',3,0,0,0};
static const BYTE secid10_2[] =
@ -632,7 +633,9 @@ static void test_InternetSecurityMarshalling(void)
ok(hres == S_OK, "CreateStreamOnHGlobal returned: %08x\n", hres);
hres = CoMarshalInterface(stream, &IID_IInternetSecurityManager, unk, MSHCTX_INPROC, NULL, MSHLFLAGS_NORMAL);
ok(hres == S_OK, "CoMarshalInterface returned: %08x\n", hres);
/* Not supported in W98 */
ok(hres == S_OK || broken(hres == REGDB_E_IIDNOTREG),
"CoMarshalInterface returned: %08x\n", hres);
IStream_Release(stream);
IUnknown_Release(unk);
@ -641,8 +644,9 @@ static void test_InternetSecurityMarshalling(void)
static void test_InternetGetSecurityUrl(void)
{
const WCHAR url5_out[] = {'h','t','t','p',':','w','w','w','.','w','i','n','e','h','q','.','o','r','g',0};
const WCHAR url7_out[] = {'f','t','p',':','w','i','n','e','h','q','.','o','r','g',0};
const WCHAR url5_out[] = {'h','t','t','p',':','w','w','w','.','z','o','n','e','3',
'.','w','i','n','e','t','e','s','t',0};
const WCHAR url7_out[] = {'f','t','p',':','z','o','n','e','3','.','w','i','n','e','t','e','s','t',0};
const WCHAR *in[] = {url2, url3, url4, url5, url7, url8, url9, url10};
const WCHAR *out_default[] = {url2, url3, url4, url5_out, url7_out, url8, url5_out, url10};
@ -652,8 +656,13 @@ static void test_InternetGetSecurityUrl(void)
DWORD i;
HRESULT hres;
if (!pCoInternetGetSecurityUrl) {
win_skip("CoInternetGetSecurityUrl not found\n");
return;
}
for(i=0; i<sizeof(in)/sizeof(WCHAR*); i++) {
hres = CoInternetGetSecurityUrl(in[i], &sec, PSU_DEFAULT, 0);
hres = pCoInternetGetSecurityUrl(in[i], &sec, PSU_DEFAULT, 0);
ok(hres == S_OK, "(%d) CoInternetGetSecurityUrl returned: %08x\n", i, hres);
if(hres == S_OK) {
ok(!strcmp_w(sec, out_default[i]), "(%d) Got %s, expected %s\n",
@ -661,7 +670,7 @@ static void test_InternetGetSecurityUrl(void)
CoTaskMemFree(sec);
}
hres = CoInternetGetSecurityUrl(in[i], &sec, PSU_SECURITY_URL_ONLY, 0);
hres = pCoInternetGetSecurityUrl(in[i], &sec, PSU_SECURITY_URL_ONLY, 0);
ok(hres == S_OK, "(%d) CoInternetGetSecurityUrl returned: %08x\n", i, hres);
if(hres == S_OK) {
ok(!strcmp_w(sec, out_securl[i]), "(%d) Got %s, expected %s\n",
@ -674,8 +683,13 @@ static void test_InternetGetSecurityUrl(void)
START_TEST(sec_mgr)
{
HMODULE hurlmon;
OleInitialize(NULL);
hurlmon = GetModuleHandle("urlmon.dll");
pCoInternetGetSecurityUrl = (void*) GetProcAddress(hurlmon, "CoInternetGetSecurityUrl");
test_InternetGetSecurityUrl();
test_SecurityManager();
test_polices();

View file

@ -1388,7 +1388,7 @@ static HRESULT WINAPI statusclb_OnProgress(IBindStatusCallbackEx *iface, ULONG u
CHECK_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE);
else
todo_wine CHECK_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE);
hr = CLSIDFromString((LPOLESTR)szStatusText, &clsid);
hr = CLSIDFromString((LPCOLESTR)szStatusText, &clsid);
ok(hr == S_OK, "CLSIDFromString failed with error 0x%08x\n", hr);
ok(IsEqualCLSID(&clsid, &CLSID_HTMLDocument),
"Expected clsid to be CLSID_HTMLDocument instead of %s\n", debugstr_guid(&clsid));

View file

@ -3,6 +3,7 @@
*
* Copyright 2006 Jeff Latimer
* Copyright 2006 Hans Leidekker
* Copyright 2010 CodeWeavers, Aric Stewart
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -30,24 +31,272 @@
#include <windows.h>
#include <usp10.h>
static void test_ScriptShape(HDC hdc)
static void test_ScriptItemize( void )
{
static const WCHAR test1[] = {'t', 'e', 's', 't',0};
BOOL ret;
static const WCHAR test2[] = {'1','2','3','-','5','2',0x064a,0x064f,0x0633,0x0627,0x0648,0x0650,0x064a,'7','1','.',0};
static const WCHAR test3[] =
{0x0e04,0x0e27,0x0e32,0x0e21,0x0e1e,0x0e22,0x0e32,0x0e22,0x0e32, 0x0e21
,0x0e2d,0x0e22,0x0e39,0x0e48,0x0e17,0x0e35,0x0e48,0x0e44,0x0e2b,0x0e19
,0x0e04,0x0e27,0x0e32,0x0e21,0x0e2a, 0x0e33,0x0e40,0x0e23,0x0e47,0x0e08,
0x0e2d,0x0e22,0x0e39,0x0e48,0x0e17,0x0e35,0x0e48,0x0e19,0x0e31,0x0e48,0x0e19,0};
static const WCHAR test4[] = {'1','2','3','-','5','2',' ','i','s',' ','7','1','.',0};
static const WCHAR test5[] =
{0x0627,0x0644,0x0635,0x0651,0x0650,0x062d,0x0629,0x064f,' ',0x062a,0x064e,
0x0627,0x062c,0x064c,' ',0x0639,0x064e,0x0644,0x0649,' ',
0x0631,0x064f,0x0624,0x0648,0x0633,0x0650,' ',0x0627,0x0644
,0x0623,0x0635,0x0650,0x062d,0x0651,0x064e,0x0627,0x0621,0x0650,0};
SCRIPT_ITEM items[10];
SCRIPT_CONTROL Control;
SCRIPT_STATE State;
HRESULT hr;
int nItems;
memset(&Control, 0, sizeof(Control));
memset(&State, 0, sizeof(State));
hr = ScriptItemize(NULL, 4, 10, &Control, &State, items, NULL);
ok (hr == E_INVALIDARG, "ScriptItemize should return E_INVALIDARG if pwcInChars is NULL\n");
hr = ScriptItemize(test1, 4, 10, &Control, &State, NULL, NULL);
ok (hr == E_INVALIDARG, "ScriptItemize should return E_INVALIDARG if pItems is NULL\n");
hr = ScriptItemize(test1, 4, 1, &Control, &State, items, NULL);
ok (hr == E_INVALIDARG, "ScriptItemize should return E_INVALIDARG if cMaxItems < 2.");
hr = ScriptItemize(test1, 0, 10, NULL, NULL, items, &nItems);
ok (hr == E_INVALIDARG, "ScriptItemize should return E_INVALIDARG if cInChars is 0\n");
hr = ScriptItemize(test1, 4, 10, NULL, NULL, items, &nItems);
ok(!hr, "ScriptItemize should return S_OK not %08x\n", hr);
ok(nItems == 1, "Wrong number of items\n");
ok(items[0].iCharPos == 0, "Wrong CharPos \n");
ok(items[0].a.fRTL == 0, "Wrong fRTL\n");
ok(items[0].a.fLayoutRTL == 0, "Wrong fLayoutRTL\n");
ok(items[0].a.s.uBidiLevel == 0, "Wrong BidiLevel\n");
State.uBidiLevel = 0;
hr = ScriptItemize(test1, 4, 10, &Control, &State, items, &nItems);
ok(!hr, "ScriptItemize should return S_OK not %08x\n", hr);
ok(nItems == 1, "Wrong number of items\n");
ok(items[0].iCharPos == 0, "Wrong CharPos \n");
ok(items[0].a.fRTL == 0, "Wrong fRTL\n");
ok(items[0].a.fLayoutRTL == 0, "Wrong fLayoutRTL\n");
ok(items[0].a.s.uBidiLevel == 0, "Wrong BidiLevel\n");
State.uBidiLevel = 1;
hr = ScriptItemize(test1, 4, 10, &Control, &State, items, &nItems);
ok(!hr, "ScriptItemize should return S_OK not %08x\n", hr);
ok(nItems == 1, "Wrong number of items\n");
ok(items[0].iCharPos == 0, "Wrong CharPos \n");
ok(items[0].a.fRTL == 0, "Wrong fRTL\n");
ok(items[0].a.fLayoutRTL == 0, "Wrong fLayoutRTL\n");
todo_wine ok(items[0].a.s.uBidiLevel == 2, "Wrong BidiLevel\n");
hr = ScriptItemize(test2, 16, 10, NULL, NULL, items, &nItems);
ok(!hr, "ScriptItemize should return S_OK not %08x\n", hr);
ok(nItems == 6, "Wrong number of items\n");
ok(items[0].iCharPos == 0, "Wrong CharPos \n");
ok(items[0].a.fRTL == 0, "Wrong fRTL\n");
ok(items[0].a.fLayoutRTL == 0, "Wrong fLayoutRTL\n");
ok(items[0].a.s.uBidiLevel == 0, "Wrong BidiLevel\n");
ok(items[1].iCharPos == 3, "Wrong CharPos \n");
ok(items[1].a.fRTL == 0, "Wrong fRTL\n");
ok(items[1].a.fLayoutRTL == 0, "Wrong fLayoutRTL\n");
ok(items[1].a.s.uBidiLevel == 0, "Wrong BidiLevel\n");
ok(items[2].iCharPos == 4, "Wrong CharPos \n");
ok(items[2].a.fRTL == 0, "Wrong fRTL\n");
ok(items[2].a.fLayoutRTL == 0, "Wrong fLayoutRTL\n");
ok(items[2].a.s.uBidiLevel == 0, "Wrong BidiLevel\n");
ok(items[3].iCharPos == 6, "Wrong CharPos \n");
ok(items[3].a.fRTL == 1, "Wrong fRTL\n");
ok(items[3].a.fLayoutRTL == 1, "Wrong fLayoutRTL\n");
ok(items[3].a.s.uBidiLevel == 1, "Wrong BidiLevel\n");
ok(items[4].iCharPos == 13, "Wrong CharPos \n");
ok(items[4].a.fRTL == 0, "Wrong fRTL\n");
ok(items[4].a.fLayoutRTL == 0, "Wrong fLayoutRTL\n");
ok(items[4].a.s.uBidiLevel == 0, "Wrong BidiLevel\n");
ok(items[5].iCharPos == 15, "Wrong CharPos \n");
ok(items[5].a.fRTL == 0, "Wrong fRTL\n");
ok(items[5].a.fLayoutRTL == 0, "Wrong fLayoutRTL\n");
ok(items[5].a.s.uBidiLevel == 0, "Wrong BidiLevel\n");
State.uBidiLevel = 0;
hr = ScriptItemize(test2, 16, 10, &Control, &State, items, &nItems);
ok(!hr, "ScriptItemize should return S_OK not %08x\n", hr);
ok(nItems == 4, "Wrong number of items\n");
ok(items[0].iCharPos == 0, "Wrong CharPos \n");
ok(items[0].a.fRTL == 0, "Wrong fRTL\n");
ok(items[0].a.fLayoutRTL == 0, "Wrong fLayoutRTL\n");
todo_wine ok(items[0].a.s.uBidiLevel == 2, "Wrong BidiLevel\n");
ok(items[1].iCharPos == 6, "Wrong CharPos \n");
ok(items[1].a.fRTL == 1, "Wrong fRTL\n");
ok(items[1].a.fLayoutRTL == 1, "Wrong fLayoutRTL\n");
ok(items[1].a.s.uBidiLevel == 1, "Wrong BidiLevel\n");
ok(items[2].iCharPos == 13, "Wrong CharPos \n");
ok(items[2].a.fRTL == 0, "Wrong fRTL\n");
todo_wine ok(items[2].a.fLayoutRTL == 1, "Wrong fLayoutRTL\n");
ok(items[2].a.s.uBidiLevel == 2, "Wrong BidiLevel\n");
ok(items[3].iCharPos == 15, "Wrong CharPos \n");
ok(items[3].a.fRTL == 0, "Wrong fRTL\n");
ok(items[3].a.fLayoutRTL == 0, "Wrong fLayoutRTL\n");
ok(items[3].a.s.uBidiLevel == 0, "Wrong BidiLevel\n");
State.uBidiLevel = 1;
hr = ScriptItemize(test2, 16, 10, &Control, &State, items, &nItems);
ok(!hr, "ScriptItemize should return S_OK not %08x\n", hr);
ok(nItems == 4, "Wrong number of items\n");
ok(items[0].iCharPos == 0, "Wrong CharPos \n");
ok(items[0].a.fRTL == 0, "Wrong fRTL\n");
todo_wine ok(items[0].a.fLayoutRTL == 1, "Wrong fLayoutRTL\n");
ok(items[0].a.s.uBidiLevel == 2, "Wrong BidiLevel\n");
ok(items[1].iCharPos == 6, "Wrong CharPos \n");
ok(items[1].a.fRTL == 1, "Wrong fRTL\n");
ok(items[1].a.fLayoutRTL == 1, "Wrong fLayoutRTL\n");
ok(items[1].a.s.uBidiLevel == 1, "Wrong BidiLevel\n");
ok(items[2].iCharPos == 13, "Wrong CharPos \n");
ok(items[2].a.fRTL == 0, "Wrong fRTL\n");
todo_wine ok(items[2].a.fLayoutRTL == 1, "Wrong fLayoutRTL\n");
ok(items[2].a.s.uBidiLevel == 2, "Wrong BidiLevel\n");
ok(items[3].iCharPos == 15, "Wrong CharPos \n");
ok(items[3].a.fRTL == 1, "Wrong fRTL\n");
ok(items[3].a.fLayoutRTL == 1, "Wrong fLayoutRTL\n");
ok(items[3].a.s.uBidiLevel == 1, "Wrong BidiLevel\n");
hr = ScriptItemize(test3, 41, 10, NULL, NULL, items, &nItems);
ok(!hr, "ScriptItemize should return S_OK not %08x\n", hr);
ok(nItems == 1, "Wrong number of items\n");
ok(items[0].iCharPos == 0, "Wrong CharPos \n");
ok(items[0].a.fRTL == 0, "Wrong fRTL\n");
ok(items[0].a.fLayoutRTL == 0, "Wrong fLayoutRTL\n");
ok(items[0].a.s.uBidiLevel == 0, "Wrong BidiLevel\n");
State.uBidiLevel = 0;
hr = ScriptItemize(test3, 41, 10, &Control, &State, items, &nItems);
ok(!hr, "ScriptItemize should return S_OK not %08x\n", hr);
ok(nItems == 1, "Wrong number of items\n");
ok(items[0].iCharPos == 0, "Wrong CharPos \n");
ok(items[0].a.fRTL == 0, "Wrong fRTL\n");
ok(items[0].a.fLayoutRTL == 0, "Wrong fLayoutRTL\n");
ok(items[0].a.s.uBidiLevel == 0, "Wrong BidiLevel\n");
State.uBidiLevel = 1;
hr = ScriptItemize(test3, 41, 10, &Control, &State, items, &nItems);
ok(!hr, "ScriptItemize should return S_OK not %08x\n", hr);
ok(nItems == 1, "Wrong number of items\n");
ok(items[0].iCharPos == 0, "Wrong CharPos \n");
ok(items[0].a.fRTL == 0, "Wrong fRTL\n");
ok(items[0].a.fLayoutRTL == 0, "Wrong fLayoutRTL\n");
todo_wine ok(items[0].a.s.uBidiLevel == 2, "Wrong BidiLevel\n");
hr = ScriptItemize(test4, 12, 10, NULL, NULL, items, &nItems);
ok(!hr, "ScriptItemize should return S_OK not %08x\n", hr);
ok(nItems == 5, "Wrong number of items\n");
ok(items[0].iCharPos == 0, "Wrong CharPos \n");
ok(items[0].a.fRTL == 0, "Wrong fRTL\n");
ok(items[0].a.fLayoutRTL == 0, "Wrong fLayoutRTL\n");
ok(items[0].a.s.uBidiLevel == 0, "Wrong BidiLevel\n");
ok(items[1].iCharPos == 3, "Wrong CharPos \n");
ok(items[1].a.fRTL == 0, "Wrong fRTL\n");
ok(items[1].a.fLayoutRTL == 0, "Wrong fLayoutRTL\n");
ok(items[1].a.s.uBidiLevel == 0, "Wrong BidiLevel\n");
ok(items[2].iCharPos == 4, "Wrong CharPos \n");
ok(items[2].a.fRTL == 0, "Wrong fRTL\n");
ok(items[2].a.fLayoutRTL == 0, "Wrong fLayoutRTL\n");
ok(items[2].a.s.uBidiLevel == 0, "Wrong BidiLevel\n");
ok(items[3].iCharPos == 7, "Wrong CharPos \n");
ok(items[3].a.fRTL == 0, "Wrong fRTL\n");
ok(items[3].a.fLayoutRTL == 0, "Wrong fLayoutRTL\n");
ok(items[3].a.s.uBidiLevel == 0, "Wrong BidiLevel\n");
ok(items[4].iCharPos == 10, "Wrong CharPos \n");
ok(items[4].a.fRTL == 0, "Wrong fRTL\n");
ok(items[4].a.fLayoutRTL == 0, "Wrong fLayoutRTL\n");
ok(items[4].a.s.uBidiLevel == 0, "Wrong BidiLevel\n");
State.uBidiLevel = 0;
hr = ScriptItemize(test4, 12, 10, &Control, &State, items, &nItems);
ok(!hr, "ScriptItemize should return S_OK not %08x\n", hr);
ok(nItems == 5, "Wrong number of items\n");
ok(items[0].iCharPos == 0, "Wrong CharPos \n");
ok(items[0].a.fRTL == 0, "Wrong fRTL\n");
ok(items[0].a.fLayoutRTL == 0, "Wrong fLayoutRTL\n");
ok(items[0].a.s.uBidiLevel == 0, "Wrong BidiLevel\n");
ok(items[1].iCharPos == 3, "Wrong CharPos \n");
ok(items[1].a.fRTL == 0, "Wrong fRTL\n");
ok(items[1].a.fLayoutRTL == 0, "Wrong fLayoutRTL\n");
ok(items[1].a.s.uBidiLevel == 0, "Wrong BidiLevel\n");
ok(items[2].iCharPos == 4, "Wrong CharPos \n");
ok(items[2].a.fRTL == 0, "Wrong fRTL\n");
ok(items[2].a.fLayoutRTL == 0, "Wrong fLayoutRTL\n");
ok(items[2].a.s.uBidiLevel == 0, "Wrong BidiLevel\n");
ok(items[3].iCharPos == 7, "Wrong CharPos \n");
ok(items[3].a.fRTL == 0, "Wrong fRTL\n");
ok(items[3].a.fLayoutRTL == 0, "Wrong fLayoutRTL\n");
ok(items[3].a.s.uBidiLevel == 0, "Wrong BidiLevel\n");
ok(items[4].iCharPos == 10, "Wrong CharPos \n");
ok(items[4].a.fRTL == 0, "Wrong fRTL\n");
ok(items[4].a.fLayoutRTL == 0, "Wrong fLayoutRTL\n");
ok(items[4].a.s.uBidiLevel == 0, "Wrong BidiLevel\n");
State.uBidiLevel = 1;
hr = ScriptItemize(test4, 12, 10, &Control, &State, items, &nItems);
ok(!hr, "ScriptItemize should return S_OK not %08x\n", hr);
todo_wine ok(nItems == 4, "Wrong number of items\n");
ok(items[0].iCharPos == 0, "Wrong CharPos \n");
ok(items[0].a.fRTL == 0, "Wrong fRTL\n");
todo_wine ok(items[0].a.fLayoutRTL == 1, "Wrong fLayoutRTL\n");
ok(items[0].a.s.uBidiLevel == 2, "Wrong BidiLevel\n");
ok(items[1].iCharPos == 6, "Wrong CharPos \n");
ok(items[1].a.fRTL == 1, "Wrong fRTL\n");
ok(items[1].a.fLayoutRTL == 1, "Wrong fLayoutRTL\n");
ok(items[1].a.s.uBidiLevel == 1, "Wrong BidiLevel\n");
ok(items[2].iCharPos == 7, "Wrong CharPos \n");
ok(items[2].a.fRTL == 0, "Wrong fRTL\n");
ok(items[2].a.fLayoutRTL == 0, "Wrong fLayoutRTL\n");
ok(items[2].a.s.uBidiLevel == 2, "Wrong BidiLevel\n");
todo_wine ok(items[3].iCharPos == 10, "Wrong CharPos \n");
ok(items[3].a.fRTL == 0, "Wrong fRTL\n");
ok(items[3].a.fLayoutRTL == 0, "Wrong fLayoutRTL\n");
todo_wine ok(items[3].a.s.uBidiLevel == 2, "Wrong BidiLevel\n");
hr = ScriptItemize(test5, 38, 10, NULL, NULL, items, &nItems);
ok(!hr, "ScriptItemize should return S_OK not %08x\n", hr);
ok(nItems == 1, "Wrong number of items\n");
ok(items[0].iCharPos == 0, "Wrong CharPos \n");
ok(items[0].a.fRTL == 1, "Wrong fRTL\n");
ok(items[0].a.fLayoutRTL == 1, "Wrong fLayoutRTL\n");
ok(items[0].a.s.uBidiLevel == 1, "Wrong BidiLevel\n");
State.uBidiLevel = 0;
hr = ScriptItemize(test5, 38, 10, &Control, &State, items, &nItems);
ok(!hr, "ScriptItemize should return S_OK not %08x\n", hr);
ok(nItems == 1, "Wrong number of items\n");
ok(items[0].iCharPos == 0, "Wrong CharPos \n");
ok(items[0].a.fRTL == 1, "Wrong fRTL\n");
ok(items[0].a.fLayoutRTL == 1, "Wrong fLayoutRTL\n");
ok(items[0].a.s.uBidiLevel == 1, "Wrong BidiLevel\n");
State.uBidiLevel = 1;
hr = ScriptItemize(test5, 38, 10, &Control, &State, items, &nItems);
ok(!hr, "ScriptItemize should return S_OK not %08x\n", hr);
ok(nItems == 1, "Wrong number of items\n");
ok(items[0].iCharPos == 0, "Wrong CharPos \n");
ok(items[0].a.fRTL == 1, "Wrong fRTL\n");
ok(items[0].a.fLayoutRTL == 1, "Wrong fLayoutRTL\n");
ok(items[0].a.s.uBidiLevel == 1, "Wrong BidiLevel\n");
}
static void test_ScriptShape(HDC hdc)
{
static const WCHAR test1[] = {'w', 'i', 'n', 'e',0};
static const WCHAR test2[] = {0x202B, 'i', 'n', 0x202C,0};
HRESULT hr;
SCRIPT_CACHE sc = NULL;
WORD glyphs[4], logclust[4];
WORD glyphs[4], glyphs2[4], logclust[4];
SCRIPT_VISATTR attrs[4];
SCRIPT_ITEM items[2];
int nb, widths[4];
GOFFSET offset[4];
ABC abc[4];
hr = ScriptItemize(NULL, 4, 2, NULL, NULL, items, NULL);
ok(hr == E_INVALIDARG, "ScriptItemize should return E_INVALIDARG not %08x\n", hr);
hr = ScriptItemize(test1, 4, 2, NULL, NULL, NULL, NULL);
ok(hr == E_INVALIDARG, "ScriptItemize should return E_INVALIDARG not %08x\n", hr);
int nb;
hr = ScriptItemize(test1, 4, 2, NULL, NULL, items, NULL);
ok(!hr, "ScriptItemize should return S_OK not %08x\n", hr);
@ -73,8 +322,122 @@ static void test_ScriptShape(HDC hdc)
ok(!hr, "ScriptShape should return S_OK not %08x\n", hr);
ok(items[0].a.fNoGlyphIndex == FALSE, "fNoGlyphIndex TRUE\n");
memset(glyphs,-1,sizeof(glyphs));
memset(logclust,-1,sizeof(logclust));
memset(attrs,-1,sizeof(attrs));
hr = ScriptShape(NULL, &sc, test1, 4, 4, &items[0].a, glyphs, logclust, attrs, &nb);
ok(!hr, "ScriptShape should return S_OK not %08x\n", hr);
ok(nb == 4, "Wrong number of items\n");
ok(logclust[0] == 0, "clusters out of order\n");
ok(logclust[1] == 1, "clusters out of order\n");
ok(logclust[2] == 2, "clusters out of order\n");
ok(logclust[3] == 3, "clusters out of order\n");
ok(attrs[0].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
ok(attrs[1].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
ok(attrs[2].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
ok(attrs[3].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
ok(attrs[0].fClusterStart == 1, "fClusterStart incorrect\n");
ok(attrs[1].fClusterStart == 1, "fClusterStart incorrect\n");
ok(attrs[2].fClusterStart == 1, "fClusterStart incorrect\n");
ok(attrs[3].fClusterStart == 1, "fClusterStart incorrect\n");
ok(attrs[0].fDiacritic == 0, "fDiacritic incorrect\n");
ok(attrs[1].fDiacritic == 0, "fDiacritic incorrect\n");
ok(attrs[2].fDiacritic == 0, "fDiacritic incorrect\n");
ok(attrs[3].fDiacritic == 0, "fDiacritic incorrect\n");
ok(attrs[0].fZeroWidth == 0, "fZeroWidth incorrect\n");
ok(attrs[1].fZeroWidth == 0, "fZeroWidth incorrect\n");
ok(attrs[2].fZeroWidth == 0, "fZeroWidth incorrect\n");
ok(attrs[3].fZeroWidth == 0, "fZeroWidth incorrect\n");
ScriptFreeCache(&sc);
sc = NULL;
memset(glyphs2,-1,sizeof(glyphs2));
memset(logclust,-1,sizeof(logclust));
memset(attrs,-1,sizeof(attrs));
hr = ScriptShape(hdc, &sc, test2, 4, 4, &items[0].a, glyphs2, logclust, attrs, &nb);
ok(hr == S_OK, "ScriptShape should return S_OK not %08x\n", hr);
ok(nb == 4, "Wrong number of items\n");
ok(glyphs2[0] == 0, "Incorrect glyph for 0x202B\n");
ok(glyphs2[3] == 0, "Incorrect glyph for 0x202C\n");
ok(logclust[0] == 0, "clusters out of order\n");
ok(logclust[1] == 1, "clusters out of order\n");
ok(logclust[2] == 2, "clusters out of order\n");
ok(logclust[3] == 3, "clusters out of order\n");
ok(attrs[0].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
ok(attrs[1].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
ok(attrs[2].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
ok(attrs[3].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
ok(attrs[0].fClusterStart == 1, "fClusterStart incorrect\n");
ok(attrs[1].fClusterStart == 1, "fClusterStart incorrect\n");
ok(attrs[2].fClusterStart == 1, "fClusterStart incorrect\n");
ok(attrs[3].fClusterStart == 1, "fClusterStart incorrect\n");
ok(attrs[0].fDiacritic == 0, "fDiacritic incorrect\n");
ok(attrs[1].fDiacritic == 0, "fDiacritic incorrect\n");
ok(attrs[2].fDiacritic == 0, "fDiacritic incorrect\n");
ok(attrs[3].fDiacritic == 0, "fDiacritic incorrect\n");
ok(attrs[0].fZeroWidth == 0, "fZeroWidth incorrect\n");
ok(attrs[1].fZeroWidth == 0, "fZeroWidth incorrect\n");
ok(attrs[2].fZeroWidth == 0, "fZeroWidth incorrect\n");
ok(attrs[3].fZeroWidth == 0, "fZeroWidth incorrect\n");
/* modify LTR to RTL */
items[0].a.fRTL = 1;
memset(glyphs2,-1,sizeof(glyphs2));
memset(logclust,-1,sizeof(logclust));
memset(attrs,-1,sizeof(attrs));
hr = ScriptShape(hdc, &sc, test1, 4, 4, &items[0].a, glyphs2, logclust, attrs, &nb);
ok(!hr, "ScriptShape should return S_OK not %08x\n", hr);
ok(nb == 4, "Wrong number of items\n");
ok(glyphs2[0] == glyphs[3], "Glyphs not reordered properly\n");
ok(glyphs2[1] == glyphs[2], "Glyphs not reordered properly\n");
ok(glyphs2[2] == glyphs[1], "Glyphs not reordered properly\n");
ok(glyphs2[3] == glyphs[0], "Glyphs not reordered properly\n");
ok(logclust[0] == 3, "clusters out of order\n");
ok(logclust[1] == 2, "clusters out of order\n");
ok(logclust[2] == 1, "clusters out of order\n");
ok(logclust[3] == 0, "clusters out of order\n");
ok(attrs[0].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
ok(attrs[1].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
ok(attrs[2].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
ok(attrs[3].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
ok(attrs[0].fClusterStart == 1, "fClusterStart incorrect\n");
ok(attrs[1].fClusterStart == 1, "fClusterStart incorrect\n");
ok(attrs[2].fClusterStart == 1, "fClusterStart incorrect\n");
ok(attrs[3].fClusterStart == 1, "fClusterStart incorrect\n");
ok(attrs[0].fDiacritic == 0, "fDiacritic incorrect\n");
ok(attrs[1].fDiacritic == 0, "fDiacritic incorrect\n");
ok(attrs[2].fDiacritic == 0, "fDiacritic incorrect\n");
ok(attrs[3].fDiacritic == 0, "fDiacritic incorrect\n");
ok(attrs[0].fZeroWidth == 0, "fZeroWidth incorrect\n");
ok(attrs[1].fZeroWidth == 0, "fZeroWidth incorrect\n");
ok(attrs[2].fZeroWidth == 0, "fZeroWidth incorrect\n");
ok(attrs[3].fZeroWidth == 0, "fZeroWidth incorrect\n");
ScriptFreeCache(&sc);
}
static void test_ScriptPlace(HDC hdc)
{
static const WCHAR test1[] = {'t', 'e', 's', 't',0};
BOOL ret;
HRESULT hr;
SCRIPT_CACHE sc = NULL;
WORD glyphs[4], logclust[4];
SCRIPT_VISATTR attrs[4];
SCRIPT_ITEM items[2];
int nb, widths[4];
GOFFSET offset[4];
ABC abc[4];
hr = ScriptItemize(test1, 4, 2, NULL, NULL, items, NULL);
ok(!hr, "ScriptItemize should return S_OK not %08x\n", hr);
ok(items[0].a.fNoGlyphIndex == FALSE, "fNoGlyphIndex TRUE\n");
hr = ScriptShape(hdc, &sc, test1, 4, 4, &items[0].a, glyphs, logclust, attrs, &nb);
ok(!hr, "ScriptShape should return S_OK not %08x\n", hr);
ok(items[0].a.fNoGlyphIndex == FALSE, "fNoGlyphIndex TRUE\n");
hr = ScriptPlace(hdc, &sc, glyphs, 4, NULL, &items[0].a, widths, NULL, NULL);
ok(hr == E_INVALIDARG, "ScriptPlace should return E_INVALIDARG not %08x\n", hr);
@ -143,28 +506,6 @@ static void test_ScriptItemIzeShapePlace(HDC hdc, unsigned short pwOutGlyphs[256
ok( ppSp[5]->langid == 9, "Langid[5] not = to 9\n"); /* Check a known value to ensure */
/* ptrs work */
/* This set of tests are to check that the various edits in ScriptIemize work */
cInChars = 5; /* Length of test without NULL */
cMaxItems = 1; /* Check threshold value */
hr = ScriptItemize(TestItem1, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
ok (hr == E_INVALIDARG, "ScriptItemize should return E_INVALIDARG if cMaxItems < 2. Was %d\n",
cMaxItems);
cInChars = 5;
cMaxItems = 255;
hr = ScriptItemize(NULL, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
ok (hr == E_INVALIDARG, "ScriptItemize should return E_INVALIDARG if pwcInChars is NULL\n");
cInChars = 5;
cMaxItems = 255;
hr = ScriptItemize(TestItem1, 0, cMaxItems, NULL, NULL, pItem, &pcItems);
ok (hr == E_INVALIDARG, "ScriptItemize should return E_INVALIDARG if cInChars is 0\n");
cInChars = 5;
cMaxItems = 255;
hr = ScriptItemize(TestItem1, cInChars, cMaxItems, NULL, NULL, NULL, &pcItems);
ok (hr == E_INVALIDARG, "ScriptItemize should return E_INVALIDARG if pItems is NULL\n");
/* This is a valid test that will cause parsing to take place */
cInChars = 5;
cMaxItems = 255;
@ -636,6 +977,78 @@ static void test_ScriptTextOut2(HDC hdc)
}
}
static void test_ScriptTextOut3(HDC hdc)
{
HRESULT hr;
int cInChars;
int cMaxItems;
SCRIPT_ITEM pItem[255];
int pcItems;
WCHAR TestItem1[] = {' ','\r', 0};
SCRIPT_CACHE psc;
int cChars;
int cMaxGlyphs;
unsigned short pwOutGlyphs1[256];
WORD pwLogClust[256];
SCRIPT_VISATTR psva[256];
int pcGlyphs;
int piAdvance[256];
GOFFSET pGoffset[256];
ABC pABC[256];
RECT rect;
/* This is to ensure that non exisiting glyphs are translated into a valid glyph number */
cInChars = 2;
cMaxItems = 255;
hr = ScriptItemize(TestItem1, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
ok (hr == 0, "ScriptItemize should return 0, returned %08x\n", hr);
/* This test is for the interim operation of ScriptItemize where only one SCRIPT_ITEM is *
* returned. */
ok (pcItems > 0, "The number of SCRIPT_ITEMS should be greater than 0\n");
if (pcItems > 0)
ok (pItem[0].iCharPos == 0 && pItem[2].iCharPos == cInChars,
"Start pos not = 0 (%d) or end pos not = %d (%d)\n",
pItem[0].iCharPos, cInChars, pItem[2].iCharPos);
/* It would appear that we have a valid SCRIPT_ANALYSIS and can continue
* ie. ScriptItemize has succeeded and that pItem has been set */
cInChars = 2;
cMaxItems = 255;
if (hr == 0) {
psc = NULL; /* must be null on first call */
cChars = cInChars;
cMaxGlyphs = cInChars;
cMaxGlyphs = 256;
hr = ScriptShape(hdc, &psc, TestItem1, cChars,
cMaxGlyphs, &pItem[0].a,
pwOutGlyphs1, pwLogClust, psva, &pcGlyphs);
ok (hr == 0, "ScriptShape should return 0 not (%08x)\n", hr);
ok (psc != NULL, "psc should not be null and have SCRIPT_CACHE buffer address\n");
ok (pcGlyphs == cChars, "Chars in (%d) should equal Glyphs out (%d)\n", cChars, pcGlyphs);
if (hr ==0) {
/* Note hdc is needed as glyph info is not yet in psc */
hr = ScriptPlace(hdc, &psc, pwOutGlyphs1, pcGlyphs, psva, &pItem[0].a, piAdvance,
pGoffset, pABC);
ok (hr == 0, "Should return 0 not (%08x)\n", hr);
/* Test Rect Rgn is acceptable */
rect.top = 10;
rect.bottom = 20;
rect.left = 10;
rect.right = 40;
hr = ScriptTextOut(hdc, &psc, 0, 0, 0, &rect, &pItem[0].a, NULL, 0, pwOutGlyphs1, pcGlyphs,
piAdvance, NULL, pGoffset);
ok (hr == 0, "ScriptTextOut should return 0 not (%08x)\n", hr);
}
/* Clean up and go */
ScriptFreeCache(&psc);
ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
}
}
static void test_ScriptXtoX(void)
/****************************************************************************************
* This routine tests the ScriptXtoCP and ScriptCPtoX functions using static variables *
@ -1078,20 +1491,55 @@ static void test_ScriptGetGlyphABCWidth(HDC hdc)
static void test_ScriptLayout(void)
{
HRESULT hr;
static const BYTE levels[][5] =
static const BYTE levels[][10] =
{
{ 0, 0, 0, 0, 0 },
{ 1, 1, 1, 1, 1 },
{ 2, 2, 2, 2, 2 },
{ 3, 3, 3, 3, 3 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
{ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 },
{ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
{ 0, 0, 0, 0, 0, 1, 1, 1, 1, 1},
{ 1, 1, 1, 2, 2, 2, 1, 1, 1, 1 },
{ 2, 2, 2, 1, 1, 1, 2, 2, 2, 2 },
{ 0, 0, 1, 1, 2, 2, 1, 1, 0, 0 },
{ 1, 1, 2, 2, 3, 3, 2, 2, 1, 1 },
{ 0, 0, 1, 1, 2, 2, 1, 1, 0, 1 },
{ 1, 0, 1, 2, 2, 1, 2, 1, 0, 1 },
};
static const int expect[][5] =
static const int expect_l2v[][10] =
{
{ 0, 1, 2, 3, 4 },
{ 4, 3, 2, 1, 0 },
{ 0, 1, 2, 3, 4 },
{ 4, 3, 2, 1, 0 }
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 },
{ 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 },
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 },
{ 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 },
{ 0, 1, 2, 3, 4, 9, 8 ,7 ,6, 5},
/**/ { 9, 8, 7, 4, 5, 6, 3 ,2 ,1, 0},
/**/ { 7, 8, 9, 6, 5, 4, 0 ,1 ,2, 3},
{ 0, 1, 7, 6, 4, 5, 3 ,2 ,8, 9},
{ 9, 8, 2, 3, 5, 4, 6 ,7 ,1, 0},
{ 0, 1, 7, 6, 4, 5, 3 ,2 ,8, 9},
/**/ { 0, 1, 7, 5, 6, 4, 3 ,2 ,8, 9},
};
static const int expect_v2l[][10] =
{
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 },
{ 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 },
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 },
{ 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 },
{ 0, 1, 2, 3, 4, 9, 8 ,7 ,6, 5},
{ 9, 8, 7, 6, 3, 4, 5 ,2 ,1, 0},
{ 6, 7, 8, 9, 5, 4, 3 ,0 ,1, 2},
{ 0, 1, 7, 6, 4, 5, 3 ,2 ,8, 9},
{ 9, 8, 2, 3, 5, 4, 6 ,7 ,1, 0},
{ 0, 1, 7, 6, 4, 5, 3 ,2 ,8, 9},
{ 0, 1, 7, 6, 5, 3, 4 ,2 ,8, 9},
};
int i, j, vistolog[sizeof(levels[0])], logtovis[sizeof(levels[0])];
hr = ScriptLayout(sizeof(levels[0]), NULL, vistolog, logtovis);
@ -1107,14 +1555,14 @@ static void test_ScriptLayout(void)
for (j = 0; j < sizeof(levels[i]); j++)
{
ok(expect[i][j] == vistolog[j],
ok(expect_v2l[i][j] == vistolog[j],
"failure: levels[%d][%d] = %d, vistolog[%d] = %d\n",
i, j, levels[i][j], j, vistolog[j] );
}
for (j = 0; j < sizeof(levels[i]); j++)
{
ok(expect[i][j] == logtovis[j],
ok(expect_l2v[i][j] == logtovis[j],
"failure: levels[%d][%d] = %d, logtovis[%d] = %d\n",
i, j, levels[i][j], j, logtovis[j] );
}
@ -1325,15 +1773,18 @@ START_TEST(usp10)
hfont = SelectObject(hdc, CreateFontIndirectA(&lf));
test_ScriptItemize();
test_ScriptItemIzeShapePlace(hdc,pwOutGlyphs);
test_ScriptGetCMap(hdc, pwOutGlyphs);
test_ScriptCacheGetHeight(hdc);
test_ScriptGetGlyphABCWidth(hdc);
test_ScriptShape(hdc);
test_ScriptPlace(hdc);
test_ScriptGetFontProperties(hdc);
test_ScriptTextOut(hdc);
test_ScriptTextOut2(hdc);
test_ScriptTextOut3(hdc);
test_ScriptXtoX();
test_ScriptString(hdc);
test_ScriptStringXtoCP_CPtoX(hdc);

View file

@ -42,6 +42,7 @@
static BOOL (WINAPI *pFtpCommandA)(HINTERNET,BOOL,DWORD,LPCSTR,DWORD_PTR,HINTERNET*);
static INTERNET_STATUS_CALLBACK (WINAPI *pInternetSetStatusCallbackA)(HINTERNET,INTERNET_STATUS_CALLBACK);
static void test_getfile_no_open(void)
@ -360,6 +361,20 @@ static void test_getfile(HINTERNET hFtp, HINTERNET hConnect)
"Expected ERROR_INTERNET_INCORRECT_HANDLE_TYPE, got %d\n", GetLastError());
}
static void trace_extended_error(DWORD error)
{
DWORD code, buflen = 0;
if (error != ERROR_INTERNET_EXTENDED_ERROR) return;
if (!InternetGetLastResponseInfoA(&code, NULL, &buflen) && GetLastError() == ERROR_INSUFFICIENT_BUFFER)
{
char *text = HeapAlloc(GetProcessHeap(), 0, ++buflen);
InternetGetLastResponseInfoA(&code, text, &buflen);
trace("%u %s\n", code, text);
HeapFree(GetProcessHeap(), 0, text);
}
}
static void test_openfile(HINTERNET hFtp, HINTERNET hConnect)
{
HINTERNET hOpenFile;
@ -414,34 +429,41 @@ static void test_openfile(HINTERNET hFtp, HINTERNET hConnect)
if (hOpenFile)
{
BOOL bRet;
DWORD error;
HINTERNET hOpenFile2;
HANDLE hFile;
/* We have a handle so all ftp calls should fail (TODO: Put all ftp-calls in here) */
SetLastError(0xdeadbeef);
bRet = FtpCreateDirectoryA(hFtp, "new_directory_deadbeef");
error = GetLastError();
ok ( bRet == FALSE, "Expected FtpCreateDirectoryA to fail\n");
ok ( GetLastError() == ERROR_FTP_TRANSFER_IN_PROGRESS,
"Expected ERROR_FTP_TRANSFER_IN_PROGRESS, got %d\n", GetLastError());
ok ( error == ERROR_FTP_TRANSFER_IN_PROGRESS || broken(error == ERROR_INTERNET_EXTENDED_ERROR),
"Expected ERROR_FTP_TRANSFER_IN_PROGRESS, got %d\n", error);
trace_extended_error(error);
SetLastError(0xdeadbeef);
bRet = FtpDeleteFileA(hFtp, "non_existent_file_deadbeef");
error = GetLastError();
ok ( bRet == FALSE, "Expected FtpDeleteFileA to fail\n");
ok ( GetLastError() == ERROR_FTP_TRANSFER_IN_PROGRESS,
"Expected ERROR_FTP_TRANSFER_IN_PROGRESS, got %d\n", GetLastError());
ok ( error == ERROR_FTP_TRANSFER_IN_PROGRESS || broken(error == ERROR_INTERNET_EXTENDED_ERROR),
"Expected ERROR_FTP_TRANSFER_IN_PROGRESS, got %d\n", error);
trace_extended_error(error);
SetLastError(0xdeadbeef);
bRet = FtpGetFileA(hFtp, "welcome.msg", "should_be_non_existing_deadbeef", FALSE, FILE_ATTRIBUTE_NORMAL, FTP_TRANSFER_TYPE_UNKNOWN, 0);
ok ( bRet == FALSE, "Expected FtpGetFileA to fail\n");
ok ( GetLastError() == ERROR_FTP_TRANSFER_IN_PROGRESS,
"Expected ERROR_FTP_TRANSFER_IN_PROGRESS, got %d\n", GetLastError());
error = GetLastError();
ok ( bRet == FALSE || broken(bRet == TRUE), "Expected FtpGetFileA to fail\n");
ok ( error == ERROR_FTP_TRANSFER_IN_PROGRESS || broken(error == ERROR_SUCCESS),
"Expected ERROR_FTP_TRANSFER_IN_PROGRESS, got %d\n", error);
DeleteFileA("should_be_non_existing_deadbeef"); /* Just in case */
SetLastError(0xdeadbeef);
hOpenFile2 = FtpOpenFileA(hFtp, "welcome.msg", GENERIC_READ, FTP_TRANSFER_TYPE_ASCII, 0);
ok ( bRet == FALSE, "Expected FtpOpenFileA to fail\n");
ok ( GetLastError() == ERROR_FTP_TRANSFER_IN_PROGRESS,
"Expected ERROR_FTP_TRANSFER_IN_PROGRESS, got %d\n", GetLastError());
error = GetLastError();
ok ( bRet == FALSE || broken(bRet == TRUE), "Expected FtpOpenFileA to fail\n");
ok ( error == ERROR_FTP_TRANSFER_IN_PROGRESS || broken(error == ERROR_SUCCESS),
"Expected ERROR_FTP_TRANSFER_IN_PROGRESS, got %d\n", error);
InternetCloseHandle(hOpenFile2); /* Just in case */
/* Create a temporary local file */
@ -451,22 +473,25 @@ static void test_openfile(HINTERNET hFtp, HINTERNET hConnect)
CloseHandle(hFile);
SetLastError(0xdeadbeef);
bRet = FtpPutFileA(hFtp, "now_existing_local", "non_existing_remote", FTP_TRANSFER_TYPE_UNKNOWN, 0);
error = GetLastError();
ok ( bRet == FALSE, "Expected FtpPutFileA to fail\n");
ok ( GetLastError() == ERROR_FTP_TRANSFER_IN_PROGRESS,
"Expected ERROR_FTP_TRANSFER_IN_PROGRESS, got %d\n", GetLastError());
ok ( error == ERROR_FTP_TRANSFER_IN_PROGRESS || broken(error == ERROR_INTERNET_EXTENDED_ERROR),
"Expected ERROR_FTP_TRANSFER_IN_PROGRESS, got %d\n", error);
DeleteFileA("now_existing_local");
SetLastError(0xdeadbeef);
bRet = FtpRemoveDirectoryA(hFtp, "should_be_non_existing_deadbeef_dir");
error = GetLastError();
ok ( bRet == FALSE, "Expected FtpRemoveDirectoryA to fail\n");
ok ( GetLastError() == ERROR_FTP_TRANSFER_IN_PROGRESS,
"Expected ERROR_FTP_TRANSFER_IN_PROGRESS, got %d\n", GetLastError());
ok ( error == ERROR_FTP_TRANSFER_IN_PROGRESS || broken(error == ERROR_INTERNET_EXTENDED_ERROR),
"Expected ERROR_FTP_TRANSFER_IN_PROGRESS, got %d\n", error);
SetLastError(0xdeadbeef);
bRet = FtpRenameFileA(hFtp , "should_be_non_existing_deadbeef", "new");
error = GetLastError();
ok ( bRet == FALSE, "Expected FtpRenameFileA to fail\n");
ok ( GetLastError() == ERROR_FTP_TRANSFER_IN_PROGRESS,
"Expected ERROR_FTP_TRANSFER_IN_PROGRESS, got %d\n", GetLastError());
ok ( error == ERROR_FTP_TRANSFER_IN_PROGRESS || broken(error == ERROR_INTERNET_EXTENDED_ERROR),
"Expected ERROR_FTP_TRANSFER_IN_PROGRESS, got %d\n", error);
}
InternetCloseHandle(hOpenFile);
@ -728,6 +753,7 @@ static void test_find_first_file(HINTERNET hFtp, HINTERNET hConnect)
HINTERNET hSearch;
HINTERNET hSearch2;
HINTERNET hOpenFile;
DWORD error;
/* NULL as the search file ought to return the first file in the directory */
SetLastError(0xdeadbeef);
@ -773,10 +799,17 @@ static void test_find_first_file(HINTERNET hFtp, HINTERNET hConnect)
/* This should fail as the OpenFile handle wasn't closed */
SetLastError(0xdeadbeef);
hSearch = FtpFindFirstFileA(hFtp, "welcome.msg", &findData, 0, 0);
ok ( hSearch == NULL, "Expected FtpFindFirstFileA to fail\n" );
ok ( GetLastError() == ERROR_FTP_TRANSFER_IN_PROGRESS,
"Expected ERROR_FTP_TRANSFER_IN_PROGRESS, got %d\n", GetLastError() );
InternetCloseHandle(hSearch); /* Just in case */
error = GetLastError();
ok ( hSearch == NULL || broken(hSearch != NULL), /* win2k */
"Expected FtpFindFirstFileA to fail\n" );
if (!hSearch)
ok ( error == ERROR_FTP_TRANSFER_IN_PROGRESS || broken(error == ERROR_INTERNET_EXTENDED_ERROR),
"Expected ERROR_FTP_TRANSFER_IN_PROGRESS, got %d\n", error );
else
{
ok( error == ERROR_SUCCESS, "wrong error %u on success\n", GetLastError() );
InternetCloseHandle(hSearch);
}
InternetCloseHandle(hOpenFile);
@ -889,6 +922,51 @@ static void test_get_current_dir(HINTERNET hFtp, HINTERNET hConnect)
ok ( GetLastError() == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got: %d\n", GetLastError());
}
static void WINAPI status_callback(HINTERNET handle, DWORD_PTR ctx, DWORD status, LPVOID info, DWORD info_len)
{
switch (status)
{
case INTERNET_STATUS_RESOLVING_NAME:
case INTERNET_STATUS_NAME_RESOLVED:
case INTERNET_STATUS_CONNECTING_TO_SERVER:
case INTERNET_STATUS_CONNECTED_TO_SERVER:
trace("%p %lx %u %s %u\n", handle, ctx, status, (char *)info, info_len);
break;
default:
break;
}
}
static void test_status_callbacks(HINTERNET hInternet)
{
INTERNET_STATUS_CALLBACK cb;
HINTERNET hFtp;
BOOL ret;
if (!pInternetSetStatusCallbackA)
{
win_skip("InternetSetStatusCallbackA() is not available, skipping test\n");
return;
}
cb = pInternetSetStatusCallbackA(hInternet, status_callback);
ok(cb == NULL, "expected NULL got %p\n", cb);
hFtp = InternetConnect(hInternet, "ftp.winehq.org", INTERNET_DEFAULT_FTP_PORT, "anonymous", NULL,
INTERNET_SERVICE_FTP, INTERNET_FLAG_PASSIVE, 1);
if (!hFtp)
{
skip("No ftp connection could be made to ftp.winehq.org %u\n", GetLastError());
return;
}
ret = InternetCloseHandle(hFtp);
ok(ret, "InternetCloseHandle failed %u\n", GetLastError());
cb = pInternetSetStatusCallbackA(hInternet, NULL);
ok(cb == status_callback, "expected check_status got %p\n", cb);
}
START_TEST(ftp)
{
HMODULE hWininet;
@ -896,6 +974,7 @@ START_TEST(ftp)
hWininet = GetModuleHandleA("wininet.dll");
pFtpCommandA = (void*)GetProcAddress(hWininet, "FtpCommandA");
pInternetSetStatusCallbackA = (void*)GetProcAddress(hWininet, "InternetSetStatusCallbackA");
SetLastError(0xdeadbeef);
hInternet = InternetOpen("winetest", 0, NULL, NULL, 0);
@ -937,6 +1016,7 @@ START_TEST(ftp)
test_command(hFtp, hHttp);
test_find_first_file(hFtp, hHttp);
test_get_current_dir(hFtp, hHttp);
test_status_callbacks(hInternet);
InternetCloseHandle(hHttp);
InternetCloseHandle(hFtp);

File diff suppressed because it is too large Load diff

View file

@ -105,6 +105,35 @@ static CHAR status_string[MAX_INTERNET_STATUS][MAX_STATUS_NAME];
static HANDLE hCompleteEvent;
#define TESTF_REDIRECT 0x01
#define TESTF_COMPRESSED 0x02
#define TESTF_ALLOW_COOKIE 0x04
typedef struct {
const char *url;
const char *redirected_url;
const char *host;
const char *path;
DWORD flags;
} test_data_t;
static const test_data_t test_data[] = {
{
"http://test.winehq.org/testredirect",
"http://test.winehq.org/hello.html",
"test.winehq.org",
"/testredirect",
TESTF_REDIRECT
},
{
"http://www.codeweavers.com/",
"http://www.codeweavers.com/",
"www.codeweavers.com",
"",
TESTF_COMPRESSED|TESTF_ALLOW_COOKIE
}
};
static INTERNET_STATUS_CALLBACK (WINAPI *pInternetSetStatusCallbackA)(HINTERNET ,INTERNET_STATUS_CALLBACK);
@ -239,7 +268,7 @@ static VOID WINAPI callback(
}
}
static void InternetReadFile_test(int flags)
static void InternetReadFile_test(int flags, const test_data_t *test)
{
BOOL res;
CHAR buffer[4000];
@ -250,10 +279,11 @@ static void InternetReadFile_test(int flags)
hCompleteEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
trace("Starting InternetReadFile test with flags 0x%x\n",flags);
trace("Starting InternetReadFile test with flags 0x%x on url %s\n",flags,test->url);
trace("InternetOpenA <--\n");
hi = InternetOpenA("", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, flags);
hi = InternetOpenA((test->flags & TESTF_COMPRESSED) ? "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)" : "",
INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, flags);
ok((hi != 0x0),"InternetOpen failed with error %u\n", GetLastError());
trace("InternetOpenA -->\n");
@ -264,7 +294,7 @@ static void InternetReadFile_test(int flags)
SET_EXPECT(INTERNET_STATUS_HANDLE_CREATED);
trace("InternetConnectA <--\n");
hic=InternetConnectA(hi, "test.winehq.org", INTERNET_INVALID_PORT_NUMBER,
hic=InternetConnectA(hi, test->host, INTERNET_INVALID_PORT_NUMBER,
NULL, NULL, INTERNET_SERVICE_HTTP, 0x0, 0xdeadbeef);
ok((hic != 0x0),"InternetConnect failed with error %u\n", GetLastError());
trace("InternetConnectA -->\n");
@ -275,7 +305,7 @@ static void InternetReadFile_test(int flags)
SET_EXPECT(INTERNET_STATUS_HANDLE_CREATED);
trace("HttpOpenRequestA <--\n");
hor = HttpOpenRequestA(hic, "GET", "/testredirect", NULL, NULL, types,
hor = HttpOpenRequestA(hic, "GET", test->path, NULL, NULL, types,
INTERNET_FLAG_KEEP_CONNECTION | INTERNET_FLAG_RESYNCHRONIZE,
0xdeadbead);
if (hor == 0x0 && GetLastError() == ERROR_INTERNET_NAME_NOT_RESOLVED) {
@ -295,7 +325,7 @@ static void InternetReadFile_test(int flags)
length = sizeof(buffer);
res = InternetQueryOptionA(hor, INTERNET_OPTION_URL, buffer, &length);
ok(res, "InternetQueryOptionA(INTERNET_OPTION_URL) failed: %u\n", GetLastError());
ok(!strcmp(buffer, "http://test.winehq.org/testredirect"), "Wrong URL %s\n", buffer);
ok(!strcmp(buffer, test->url), "Wrong URL %s, expected %s\n", buffer, test->url);
length = sizeof(buffer);
res = HttpQueryInfoA(hor, HTTP_QUERY_RAW_HEADERS, buffer, &length, 0x0);
@ -306,6 +336,10 @@ static void InternetReadFile_test(int flags)
CHECK_NOTIFIED(INTERNET_STATUS_HANDLE_CREATED);
CHECK_NOT_NOTIFIED(INTERNET_STATUS_RESOLVING_NAME);
CHECK_NOT_NOTIFIED(INTERNET_STATUS_NAME_RESOLVED);
if(test->flags & TESTF_ALLOW_COOKIE) {
SET_OPTIONAL(INTERNET_STATUS_COOKIE_SENT);
SET_OPTIONAL(INTERNET_STATUS_COOKIE_RECEIVED);
}
if (first_connection_to_test_url)
{
SET_EXPECT(INTERNET_STATUS_RESOLVING_NAME);
@ -322,12 +356,14 @@ static void InternetReadFile_test(int flags)
SET_EXPECT(INTERNET_STATUS_CONNECTING_TO_SERVER);
SET_WINE_ALLOW(INTERNET_STATUS_CONNECTED_TO_SERVER);
SET_EXPECT(INTERNET_STATUS_CONNECTED_TO_SERVER);
SET_EXPECT2(INTERNET_STATUS_SENDING_REQUEST, 2);
SET_EXPECT2(INTERNET_STATUS_REQUEST_SENT, 2);
SET_EXPECT2(INTERNET_STATUS_RECEIVING_RESPONSE, 2);
SET_EXPECT2(INTERNET_STATUS_RESPONSE_RECEIVED, 2);
SET_OPTIONAL2(INTERNET_STATUS_CLOSING_CONNECTION, 2);
SET_OPTIONAL2(INTERNET_STATUS_CONNECTION_CLOSED, 2);
SET_EXPECT2(INTERNET_STATUS_SENDING_REQUEST, (test->flags & TESTF_REDIRECT) ? 2 : 1);
SET_EXPECT2(INTERNET_STATUS_REQUEST_SENT, (test->flags & TESTF_REDIRECT) ? 2 : 1);
SET_EXPECT2(INTERNET_STATUS_RECEIVING_RESPONSE, (test->flags & TESTF_REDIRECT) ? 2 : 1);
SET_EXPECT2(INTERNET_STATUS_RESPONSE_RECEIVED, (test->flags & TESTF_REDIRECT) ? 2 : 1);
if(test->flags & TESTF_REDIRECT) {
SET_OPTIONAL2(INTERNET_STATUS_CLOSING_CONNECTION, 2);
SET_OPTIONAL2(INTERNET_STATUS_CONNECTION_CLOSED, 2);
}
SET_EXPECT(INTERNET_STATUS_REDIRECT);
SET_OPTIONAL(INTERNET_STATUS_CONNECTING_TO_SERVER);
SET_OPTIONAL(INTERNET_STATUS_CONNECTED_TO_SERVER);
@ -336,9 +372,19 @@ static void InternetReadFile_test(int flags)
else
SET_WINE_ALLOW(INTERNET_STATUS_REQUEST_COMPLETE);
if(test->flags & TESTF_COMPRESSED) {
BOOL b = TRUE;
res = InternetSetOption(hor, INTERNET_OPTION_HTTP_DECODING, &b, sizeof(b));
ok(res || broken(!res && GetLastError() == ERROR_INTERNET_INVALID_OPTION),
"InternetSetOption failed: %u\n", GetLastError());
if(!res)
goto abort;
}
trace("HttpSendRequestA -->\n");
SetLastError(0xdeadbeef);
res = HttpSendRequestA(hor, "", -1, NULL, 0);
res = HttpSendRequestA(hor, (test->flags & TESTF_COMPRESSED) ? "Accept-Encoding: gzip, deflate" : "", -1, NULL, 0);
if (flags & INTERNET_FLAG_ASYNC)
ok(!res && (GetLastError() == ERROR_IO_PENDING),
"Asynchronous HttpSendRequest NOT returning 0 with error ERROR_IO_PENDING\n");
@ -350,6 +396,10 @@ static void InternetReadFile_test(int flags)
if (flags & INTERNET_FLAG_ASYNC)
WaitForSingleObject(hCompleteEvent, INFINITE);
if(test->flags & TESTF_ALLOW_COOKIE) {
CLEAR_NOTIFIED(INTERNET_STATUS_COOKIE_SENT);
CLEAR_NOTIFIED(INTERNET_STATUS_COOKIE_RECEIVED);
}
if (first_connection_to_test_url)
{
CHECK_NOTIFIED(INTERNET_STATUS_RESOLVING_NAME);
@ -360,11 +410,12 @@ static void InternetReadFile_test(int flags)
CHECK_NOT_NOTIFIED(INTERNET_STATUS_RESOLVING_NAME);
CHECK_NOT_NOTIFIED(INTERNET_STATUS_NAME_RESOLVED);
}
CHECK_NOTIFIED2(INTERNET_STATUS_SENDING_REQUEST, 2);
CHECK_NOTIFIED2(INTERNET_STATUS_REQUEST_SENT, 2);
CHECK_NOTIFIED2(INTERNET_STATUS_RECEIVING_RESPONSE, 2);
CHECK_NOTIFIED2(INTERNET_STATUS_RESPONSE_RECEIVED, 2);
CHECK_NOTIFIED(INTERNET_STATUS_REDIRECT);
CHECK_NOTIFIED2(INTERNET_STATUS_SENDING_REQUEST, (test->flags & TESTF_REDIRECT) ? 2 : 1);
CHECK_NOTIFIED2(INTERNET_STATUS_REQUEST_SENT, (test->flags & TESTF_REDIRECT) ? 2 : 1);
CHECK_NOTIFIED2(INTERNET_STATUS_RECEIVING_RESPONSE, (test->flags & TESTF_REDIRECT) ? 2 : 1);
CHECK_NOTIFIED2(INTERNET_STATUS_RESPONSE_RECEIVED, (test->flags & TESTF_REDIRECT) ? 2 : 1);
if(test->flags & TESTF_REDIRECT)
CHECK_NOTIFIED(INTERNET_STATUS_REDIRECT);
if (flags & INTERNET_FLAG_ASYNC)
CHECK_NOTIFIED(INTERNET_STATUS_REQUEST_COMPLETE);
else
@ -389,16 +440,24 @@ static void InternetReadFile_test(int flags)
length = sizeof(buffer);
res = InternetQueryOptionA(hor, INTERNET_OPTION_URL, buffer, &length);
ok(res, "InternetQueryOptionA(INTERNET_OPTION_URL) failed: %u\n", GetLastError());
ok(!strcmp(buffer, "http://test.winehq.org/hello.html"), "Wrong URL %s\n", buffer);
ok(!strcmp(buffer, test->redirected_url), "Wrong URL %s\n", buffer);
length = 16;
res = HttpQueryInfoA(hor,HTTP_QUERY_CONTENT_LENGTH,&buffer,&length,0x0);
trace("Option 0x5 -> %i %s (%u)\n",res,buffer,GetLastError());
trace("Option HTTP_QUERY_CONTENT_LENGTH -> %i %s (%u)\n",res,buffer,GetLastError());
if(test->flags & TESTF_COMPRESSED)
ok(!res && GetLastError() == ERROR_HTTP_HEADER_NOT_FOUND,
"expected ERROR_HTTP_HEADER_NOT_FOUND, got %x (%u)\n", res, GetLastError());
length = 100;
res = HttpQueryInfoA(hor,HTTP_QUERY_CONTENT_TYPE,buffer,&length,0x0);
buffer[length]=0;
trace("Option 0x1 -> %i %s\n",res,buffer);
trace("Option HTTP_QUERY_CONTENT_TYPE -> %i %s\n",res,buffer);
length = 100;
res = HttpQueryInfoA(hor,HTTP_QUERY_CONTENT_ENCODING,buffer,&length,0x0);
buffer[length]=0;
trace("Option HTTP_QUERY_CONTENT_ENCODING -> %i %s\n",res,buffer);
SetLastError(0xdeadbeef);
res = InternetReadFile(NULL, buffer, 100, &length);
@ -447,8 +506,10 @@ static void InternetReadFile_test(int flags)
if (length == 0)
break;
}
CHECK_NOTIFIED2(INTERNET_STATUS_CLOSING_CONNECTION, 2);
CHECK_NOTIFIED2(INTERNET_STATUS_CONNECTION_CLOSED, 2);
if(test->flags & TESTF_REDIRECT) {
CHECK_NOTIFIED2(INTERNET_STATUS_CLOSING_CONNECTION, 2);
CHECK_NOTIFIED2(INTERNET_STATUS_CONNECTION_CLOSED, 2);
}
abort:
trace("aborting\n");
SET_EXPECT2(INTERNET_STATUS_HANDLE_CLOSING, (hor != 0x0) + (hic != 0x0));
@ -493,6 +554,114 @@ abort:
first_connection_to_test_url = FALSE;
}
static void InternetReadFile_chunked_test(void)
{
BOOL res;
CHAR buffer[4000];
DWORD length;
const char *types[2] = { "*", NULL };
HINTERNET hi, hic = 0, hor = 0;
trace("Starting InternetReadFile chunked test\n");
trace("InternetOpenA <--\n");
hi = InternetOpenA("", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
ok((hi != 0x0),"InternetOpen failed with error %u\n", GetLastError());
trace("InternetOpenA -->\n");
if (hi == 0x0) goto abort;
trace("InternetConnectA <--\n");
hic=InternetConnectA(hi, "test.winehq.org", INTERNET_INVALID_PORT_NUMBER,
NULL, NULL, INTERNET_SERVICE_HTTP, 0x0, 0xdeadbeef);
ok((hic != 0x0),"InternetConnect failed with error %u\n", GetLastError());
trace("InternetConnectA -->\n");
if (hic == 0x0) goto abort;
trace("HttpOpenRequestA <--\n");
hor = HttpOpenRequestA(hic, "GET", "/testchunked", NULL, NULL, types,
INTERNET_FLAG_KEEP_CONNECTION | INTERNET_FLAG_RESYNCHRONIZE,
0xdeadbead);
if (hor == 0x0 && GetLastError() == ERROR_INTERNET_NAME_NOT_RESOLVED) {
/*
* If the internet name can't be resolved we are probably behind
* a firewall or in some other way not directly connected to the
* Internet. Not enough reason to fail the test. Just ignore and
* abort.
*/
} else {
ok((hor != 0x0),"HttpOpenRequest failed with error %u\n", GetLastError());
}
trace("HttpOpenRequestA -->\n");
if (hor == 0x0) goto abort;
trace("HttpSendRequestA -->\n");
SetLastError(0xdeadbeef);
res = HttpSendRequestA(hor, "", -1, NULL, 0);
ok(res || (GetLastError() == ERROR_INTERNET_NAME_NOT_RESOLVED),
"Synchronous HttpSendRequest returning 0, error %u\n", GetLastError());
trace("HttpSendRequestA <--\n");
length = 100;
res = HttpQueryInfoA(hor,HTTP_QUERY_CONTENT_TYPE,buffer,&length,0x0);
buffer[length]=0;
trace("Option CONTENT_TYPE -> %i %s\n",res,buffer);
SetLastError( 0xdeadbeef );
length = 100;
res = HttpQueryInfoA(hor,HTTP_QUERY_TRANSFER_ENCODING,buffer,&length,0x0);
buffer[length]=0;
trace("Option TRANSFER_ENCODING -> %i %s\n",res,buffer);
ok( res, "Failed to get TRANSFER_ENCODING option, error %u\n", GetLastError() );
ok( !strcmp( buffer, "chunked" ), "Wrong transfer encoding '%s'\n", buffer );
SetLastError( 0xdeadbeef );
length = 16;
res = HttpQueryInfoA(hor,HTTP_QUERY_CONTENT_LENGTH,&buffer,&length,0x0);
ok( !res, "Found CONTENT_LENGTH option '%s'\n", buffer );
ok( GetLastError() == ERROR_HTTP_HEADER_NOT_FOUND, "Wrong error %u\n", GetLastError() );
length = 100;
trace("Entering Query loop\n");
while (TRUE)
{
res = InternetQueryDataAvailable(hor,&length,0x0,0x0);
ok(!(!res && length != 0),"InternetQueryDataAvailable failed with non-zero length\n");
ok(res, "InternetQueryDataAvailable failed, error %d\n", GetLastError());
trace("got %u available\n",length);
if (length)
{
DWORD got;
char *buffer = HeapAlloc(GetProcessHeap(),0,length+1);
res = InternetReadFile(hor,buffer,length,&got);
buffer[got]=0;
trace("ReadFile -> %i %i\n",res,got);
ok( length == got, "only got %u of %u available\n", got, length );
ok( buffer[got-1] == '\n', "received partial line '%s'\n", buffer );
HeapFree(GetProcessHeap(),0,buffer);
if (!got) break;
}
if (length == 0)
break;
}
abort:
trace("aborting\n");
if (hor != 0x0) {
res = InternetCloseHandle(hor);
ok (res, "InternetCloseHandle of handle opened by HttpOpenRequestA failed\n");
}
if (hi != 0x0) {
res = InternetCloseHandle(hi);
ok (res, "InternetCloseHandle of handle opened by InternetOpenA failed\n");
}
}
static void InternetReadFileExA_test(int flags)
{
DWORD rc;
@ -802,8 +971,7 @@ static void HttpSendRequestEx_test(void)
HINTERNET hRequest;
INTERNET_BUFFERS BufferIn;
DWORD dwBytesWritten;
DWORD dwBytesRead;
DWORD dwBytesWritten, dwBytesRead, error;
CHAR szBuffer[256];
int i;
BOOL ret;
@ -839,8 +1007,11 @@ static void HttpSendRequestEx_test(void)
BufferIn.dwOffsetLow = 0;
BufferIn.dwOffsetHigh = 0;
SetLastError(0xdeadbeef);
ret = HttpSendRequestEx(hRequest, &BufferIn, NULL, 0 ,0);
ok(ret, "HttpSendRequestEx Failed with error %u\n", GetLastError());
error = GetLastError();
ok(ret, "HttpSendRequestEx Failed with error %u\n", error);
ok(error == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", error);
for (i = 3; szPostData[i]; i++)
ok(InternetWriteFile(hRequest, &szPostData[i], 1, &dwBytesWritten),
@ -942,7 +1113,7 @@ static void test_http_cache(void)
size = sizeof(url);
ret = InternetQueryOptionA(request, INTERNET_OPTION_URL, url, &size);
ok(ret, "InternetQueryOptionA(INTERNET_OPTION_url) failed: %u\n", GetLastError());
ok(ret, "InternetQueryOptionA(INTERNET_OPTION_URL) failed: %u\n", GetLastError());
ok(!strcmp(url, "http://test.winehq.org/hello.html"), "Wrong URL %s\n", url);
size = sizeof(file_name);
@ -977,7 +1148,7 @@ static void test_http_cache(void)
file = CreateFile(file_name, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL, NULL);
todo_wine ok(file != INVALID_HANDLE_VALUE, "CreateFile succeeded\n");
ok(file != INVALID_HANDLE_VALUE, "Could not create file: %u\n", GetLastError());
CloseHandle(file);
request = HttpOpenRequestA(connect, NULL, "/", NULL, NULL, types, INTERNET_FLAG_NO_CACHE_WRITE, 0);
@ -993,13 +1164,20 @@ static void test_http_cache(void)
ok(ret, "HttpSendRequest failed: %u\n", GetLastError());
size = sizeof(file_name);
file_name[0] = 0;
ret = InternetQueryOptionA(request, INTERNET_OPTION_DATAFILE_NAME, file_name, &size);
todo_wine ok(ret, "InternetQueryOptionA(INTERNET_OPTION_DATAFILE_NAME) failed %u\n", GetLastError());
file = CreateFile(file_name, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING,
if (ret)
{
file = CreateFile(file_name, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL, NULL);
todo_wine ok(file != INVALID_HANDLE_VALUE, "CreateFile succeeded\n");
CloseHandle(file);
ok(file != INVALID_HANDLE_VALUE, "Could not create file: %u\n", GetLastError());
CloseHandle(file);
}
else
{
/* < IE8 */
ok(file_name[0] == 0, "Didn't expect a file name\n");
}
ok(InternetCloseHandle(request), "Close request handle failed\n");
ok(InternetCloseHandle(connect), "Close connect handle failed\n");
@ -1284,15 +1462,47 @@ static void HttpHeaders_test(void)
ok(index == 1, "Index was not incremented\n");
ok(strcmp(buffer,"value")==0, "incorrect string was returned(%s)\n",buffer);
/* Ensure that malformed header separators are ignored and don't cause a failure */
ok(HttpAddRequestHeaders(hRequest,"\r\rMalformedTest:value\n\nMalformedTestTwo: value2\rMalformedTestThree: value3\n\n\r\r\n",-1, HTTP_ADDREQ_FLAG_ADD|HTTP_ADDREQ_FLAG_REPLACE),
"Failed to add header with malformed entries in list\n");
index = 0;
len = sizeof(buffer);
strcpy(buffer,"MalformedTest");
ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index),"Unable to query header\n");
ok(index == 1, "Index was not incremented\n");
ok(strcmp(buffer,"value")==0, "incorrect string was returned(%s)\n",buffer);
index = 0;
len = sizeof(buffer);
strcpy(buffer,"MalformedTestTwo");
ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index),"Unable to query header\n");
ok(index == 1, "Index was not incremented\n");
ok(strcmp(buffer,"value2")==0, "incorrect string was returned(%s)\n",buffer);
index = 0;
len = sizeof(buffer);
strcpy(buffer,"MalformedTestThree");
ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index),"Unable to query header\n");
ok(index == 1, "Index was not incremented\n");
ok(strcmp(buffer,"value3")==0, "incorrect string was returned(%s)\n",buffer);
ok(InternetCloseHandle(hRequest), "Close request handle failed\n");
done:
ok(InternetCloseHandle(hConnect), "Close connect handle failed\n");
ok(InternetCloseHandle(hSession), "Close session handle failed\n");
}
static const char garbagemsg[] =
"Garbage: Header\r\n";
static const char contmsg[] =
"HTTP/1.1 100 Continue\r\n";
static const char expandcontmsg[] =
"HTTP/1.1 100 Continue\r\n"
"Server: winecontinue\r\n"
"Tag: something witty\r\n"
"\r\n";
static const char okmsg[] =
"HTTP/1.1 200 OK\r\n"
"Server: winetest\r\n"
@ -1518,6 +1728,19 @@ static DWORD CALLBACK server_thread(LPVOID param)
send(c, page1, sizeof page1-1, 0);
last_request = 1;
}
if (strstr(buffer, "GET /testF"))
{
send(c, expandcontmsg, sizeof expandcontmsg-1, 0);
send(c, garbagemsg, sizeof garbagemsg-1, 0);
send(c, contmsg, sizeof contmsg-1, 0);
send(c, garbagemsg, sizeof garbagemsg-1, 0);
send(c, okmsg, sizeof okmsg-1, 0);
send(c, page1, sizeof page1-1, 0);
}
if (strstr(buffer, "GET /testG"))
{
send(c, page1, sizeof page1-1, 0);
}
shutdown(c, 2);
closesocket(c);
@ -1558,6 +1781,32 @@ static void test_basic_request(int port, const char *verb, const char *url)
InternetCloseHandle(hi);
}
static void test_last_error(int port)
{
HINTERNET hi, hc, hr;
DWORD error;
BOOL r;
hi = InternetOpen(NULL, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
ok(hi != NULL, "open failed\n");
hc = InternetConnect(hi, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
ok(hc != NULL, "connect failed\n");
hr = HttpOpenRequest(hc, NULL, "/test1", NULL, NULL, NULL, 0, 0);
ok(hr != NULL, "HttpOpenRequest failed\n");
SetLastError(0xdeadbeef);
r = HttpSendRequest(hr, NULL, 0, NULL, 0);
error = GetLastError();
ok(r, "HttpSendRequest failed\n");
ok(error == ERROR_SUCCESS || broken(error != ERROR_SUCCESS), "expected ERROR_SUCCESS, got %u\n", error);
InternetCloseHandle(hr);
InternetCloseHandle(hc);
InternetCloseHandle(hi);
}
static void test_proxy_indirect(int port)
{
HINTERNET hi, hc, hr;
@ -1578,7 +1827,12 @@ static void test_proxy_indirect(int port)
sz = sizeof buffer;
r = HttpQueryInfo(hr, HTTP_QUERY_PROXY_AUTHENTICATE, buffer, &sz, NULL);
ok(r, "HttpQueryInfo failed\n");
ok(r || GetLastError() == ERROR_HTTP_HEADER_NOT_FOUND, "HttpQueryInfo failed: %d\n", GetLastError());
if (!r)
{
skip("missing proxy header, not testing remaining proxy headers\n");
goto out;
}
ok(!strcmp(buffer, "Basic realm=\"placebo\""), "proxy auth info wrong\n");
sz = sizeof buffer;
@ -1611,6 +1865,7 @@ static void test_proxy_indirect(int port)
ok(GetLastError() == ERROR_HTTP_HEADER_NOT_FOUND, "HttpQueryInfo should fail\n");
ok(r == FALSE, "HttpQueryInfo failed\n");
out:
InternetCloseHandle(hr);
InternetCloseHandle(hc);
InternetCloseHandle(hi);
@ -1829,7 +2084,6 @@ static void test_http1_1(int port)
ok(req != NULL, "HttpOpenRequest failed\n");
ret = HttpSendRequest(req, NULL, 0, NULL, 0);
todo_wine
ok(ret, "HttpSendRequest failed\n");
}
@ -1995,6 +2249,69 @@ static void test_invalid_response_headers(int port)
InternetCloseHandle(session);
}
static void test_response_without_headers(int port)
{
HINTERNET hi, hc, hr;
DWORD r, count, size, status;
char buffer[1024];
SetLastError(0xdeadbeef);
hi = InternetOpen(NULL, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
ok(hi != NULL, "open failed %u\n", GetLastError());
SetLastError(0xdeadbeef);
hc = InternetConnect(hi, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
ok(hc != NULL, "connect failed %u\n", GetLastError());
SetLastError(0xdeadbeef);
hr = HttpOpenRequest(hc, NULL, "/testG", NULL, NULL, NULL, 0, 0);
ok(hr != NULL, "HttpOpenRequest failed %u\n", GetLastError());
SetLastError(0xdeadbeef);
r = HttpSendRequest(hr, NULL, 0, NULL, 0);
ok(r, "HttpSendRequest failed %u\n", GetLastError());
count = 0;
memset(buffer, 0, sizeof buffer);
SetLastError(0xdeadbeef);
r = InternetReadFile(hr, buffer, sizeof buffer, &count);
ok(r, "InternetReadFile failed %u\n", GetLastError());
todo_wine ok(count == sizeof page1 - 1, "count was wrong\n");
todo_wine ok(!memcmp(buffer, page1, sizeof page1), "http data wrong\n");
status = 0;
size = sizeof(status);
SetLastError(0xdeadbeef);
r = HttpQueryInfo(hr, HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER, &status, &size, NULL );
todo_wine ok(r, "HttpQueryInfo failed %u\n", GetLastError());
todo_wine ok(status == 200, "expected status 200 got %u\n", status);
buffer[0] = 0;
size = sizeof(buffer);
SetLastError(0xdeadbeef);
r = HttpQueryInfo(hr, HTTP_QUERY_STATUS_TEXT, buffer, &size, NULL );
ok(r, "HttpQueryInfo failed %u\n", GetLastError());
ok(!strcmp(buffer, "OK"), "expected OK got: \"%s\"\n", buffer);
buffer[0] = 0;
size = sizeof(buffer);
SetLastError(0xdeadbeef);
r = HttpQueryInfo(hr, HTTP_QUERY_VERSION, buffer, &size, NULL);
ok(r, "HttpQueryInfo failed %u\n", GetLastError());
ok(!strcmp(buffer, "HTTP/1.0"), "expected HTTP/1.0 got: \"%s\"\n", buffer);
buffer[0] = 0;
size = sizeof(buffer);
SetLastError(0xdeadbeef);
r = HttpQueryInfo(hr, HTTP_QUERY_RAW_HEADERS, buffer, &size, NULL);
ok(r, "HttpQueryInfo failed %u\n", GetLastError());
ok(!strcmp(buffer, "HTTP/1.0 200 OK"), "raw headers wrong: \"%s\"\n", buffer);
InternetCloseHandle(hr);
InternetCloseHandle(hc);
InternetCloseHandle(hi);
}
static void test_HttpQueryInfo(int port)
{
HINTERNET hi, hc, hr;
@ -2124,13 +2441,16 @@ static void test_http_connection(void)
test_basic_request(si.port, "RPC_IN_DATA", "/test5");
test_basic_request(si.port, "RPC_OUT_DATA", "/test5");
test_basic_request(si.port, "GET", "/test6");
test_basic_request(si.port, "GET", "/testF");
test_connection_header(si.port);
test_http1_1(si.port);
test_cookie_header(si.port);
test_basic_authentication(si.port);
test_invalid_response_headers(si.port);
test_response_without_headers(si.port);
test_HttpQueryInfo(si.port);
test_HttpSendRequestW(si.port);
test_last_error(si.port);
/* send the basic request again to shutdown the server thread */
test_basic_request(si.port, "GET", "/quit");
@ -2321,6 +2641,7 @@ struct notification
unsigned int status; /* status received */
int async; /* delivered from another thread? */
int todo;
int optional;
};
struct info
@ -2356,6 +2677,13 @@ static void CALLBACK check_notification( HINTERNET handle, DWORD_PTR context, DW
return;
}
while (info->test[i].status != status && info->test[i].optional &&
i < info->count - 1 &&
info->test[i].function == info->test[i + 1].function)
{
i++;
}
status_ok = (info->test[i].status == status);
function_ok = (info->test[i].function == info->function);
@ -2375,7 +2703,7 @@ static void CALLBACK check_notification( HINTERNET handle, DWORD_PTR context, DW
todo_wine ok( function_ok, "%u: expected function %u got %u\n", info->line, info->test[i].function, info->function );
}
if (i == info->count - 1 || info->test[i].function != info->test[i + 1].function) SetEvent( info->wait );
info->index++;
info->index = i+1;
LeaveCriticalSection( &notification_cs );
}
@ -2390,6 +2718,7 @@ static const struct notification async_send_request_ex_test[] =
{
{ internet_connect, INTERNET_STATUS_HANDLE_CREATED, 0 },
{ http_open_request, INTERNET_STATUS_HANDLE_CREATED, 0 },
{ http_send_request_ex, INTERNET_STATUS_DETECTING_PROXY, 1, 0, 1 },
{ http_send_request_ex, INTERNET_STATUS_RESOLVING_NAME, 1 },
{ http_send_request_ex, INTERNET_STATUS_NAME_RESOLVED, 1 },
{ http_send_request_ex, INTERNET_STATUS_CONNECTING_TO_SERVER, 1 },
@ -2493,6 +2822,7 @@ static void test_async_HttpSendRequestEx(void)
InternetCloseHandle( ses );
WaitForSingleObject( info.wait, 10000 );
Sleep(100);
CloseHandle( info.wait );
}
@ -2548,8 +2878,11 @@ START_TEST(http)
else
{
init_status_tests();
InternetReadFile_test(INTERNET_FLAG_ASYNC);
InternetReadFile_test(0);
InternetReadFile_test(INTERNET_FLAG_ASYNC, &test_data[0]);
InternetReadFile_test(0, &test_data[0]);
first_connection_to_test_url = TRUE;
InternetReadFile_test(INTERNET_FLAG_ASYNC, &test_data[1]);
InternetReadFile_test(0, &test_data[1]);
InternetReadFileExA_test(INTERNET_FLAG_ASYNC);
test_open_url_async();
test_async_HttpSendRequestEx();
@ -2557,9 +2890,10 @@ START_TEST(http)
InternetOpenRequest_test();
test_http_cache();
InternetOpenUrlA_test();
HttpSendRequestEx_test();
HttpHeaders_test();
test_http_connection();
test_user_agent_header();
test_bogus_accept_types_array();
InternetReadFile_chunked_test();
HttpSendRequestEx_test();
}

View file

@ -24,6 +24,7 @@
#include "winbase.h"
#include "wininet.h"
#include "winerror.h"
#include "winreg.h"
#include "wine/test.h"
@ -36,6 +37,18 @@ static BOOL (WINAPI *pInternetTimeFromSystemTimeW)(CONST SYSTEMTIME *,DWORD ,LPW
static BOOL (WINAPI *pInternetTimeToSystemTimeA)(LPCSTR ,SYSTEMTIME *,DWORD);
static BOOL (WINAPI *pInternetTimeToSystemTimeW)(LPCWSTR ,SYSTEMTIME *,DWORD);
static BOOL (WINAPI *pIsDomainLegalCookieDomainW)(LPCWSTR, LPCWSTR);
static DWORD (WINAPI *pPrivacyGetZonePreferenceW)(DWORD, DWORD, LPDWORD, LPWSTR, LPDWORD);
static DWORD (WINAPI *pPrivacySetZonePreferenceW)(DWORD, DWORD, DWORD, LPCWSTR);
/* Win9x and WinMe don't have lstrcmpW */
static int strcmp_ww(const WCHAR *str1, const WCHAR *str2)
{
DWORD len1 = lstrlenW(str1);
DWORD len2 = lstrlenW(str2);
if (len1 != len2) return 1;
return memcmp(str1, str2, len1 * sizeof(WCHAR));
}
/* ############################### */
@ -182,7 +195,7 @@ static void test_InternetQueryOptionA(void)
if (retval)
{
ok(!strcmp(useragent,buffer),"Got wrong user agent string %s instead of %s\n",buffer,useragent);
todo_wine ok(len == strlen(useragent),"Got wrong user agent length %d instead of %d\n",len,lstrlenA(useragent));
ok(len == strlen(useragent),"Got wrong user agent length %d instead of %d\n",len,lstrlenA(useragent));
}
ok(err == 0xdeadbeef, "Got wrong error code %d\n",err);
HeapFree(GetProcessHeap(),0,buffer);
@ -229,7 +242,7 @@ static void test_InternetQueryOptionA(void)
len=0;
retval=InternetQueryOptionA(hinet,INTERNET_OPTION_USER_AGENT,NULL,&len);
err=GetLastError();
todo_wine ok(len == 1,"Got wrong user agent length %d instead of %d\n",len,1);
ok(len == 1,"Got wrong user agent length %d instead of %d\n",len,1);
ok(retval == 0,"Got wrong return value %d\n",retval);
ok(err == ERROR_INSUFFICIENT_BUFFER, "Got wrong error code%d\n",err);
@ -463,7 +476,7 @@ static void test_null(void)
ok( sz == 1 + lstrlenW(buffer) || sz == lstrlenW(buffer), "sz wrong %d\n", sz);
/* before XP SP2, buffer is "server; server" */
ok( !lstrcmpW(szExpect, buffer) || !lstrcmpW(szServer, buffer), "cookie data wrong\n");
ok( !strcmp_ww(szExpect, buffer) || !strcmp_ww(szServer, buffer), "cookie data wrong\n");
sz = sizeof(buffer);
r = InternetQueryOptionA(NULL, INTERNET_OPTION_CONNECTED_STATE, buffer, &sz);
@ -742,8 +755,9 @@ static void test_IsDomainLegalCookieDomainW(void)
error = GetLastError();
ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
ok(error == ERROR_SXS_KEY_NOT_FOUND ||
error == ERROR_SUCCESS || /* IE8 on W2K3 */
error == 0xdeadbeef, /* up to IE7 */
"got %u expected ERROR_SXS_KEY_NOT_FOUND or 0xdeadbeef\n", error);
"unexpected error: %u\n", error);
ret = pIsDomainLegalCookieDomainW(gmail_com, gmail_com);
ok(ret, "IsDomainLegalCookieDomainW failed\n");
@ -754,9 +768,9 @@ static void test_IsDomainLegalCookieDomainW(void)
ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
ok(error == ERROR_SXS_KEY_NOT_FOUND || /* IE8 on XP */
error == ERROR_FILE_NOT_FOUND || /* IE8 on Vista */
error == ERROR_SUCCESS || /* IE8 on W2K3 */
error == 0xdeadbeef, /* up to IE7 */
"got %u expected ERROR_SXS_KEY_NOT_FOUND, ERROR_FILE_NOT_FOUND or "
"0xdeadbeef\n", error);
"unexpected error: %u\n", error);
ret = pIsDomainLegalCookieDomainW(uk, co_uk);
ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
@ -794,6 +808,273 @@ static void test_IsDomainLegalCookieDomainW(void)
ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
}
static void test_PrivacyGetSetZonePreferenceW(void)
{
DWORD ret, zone, type, template, old_template;
zone = 3;
type = 0;
ret = pPrivacyGetZonePreferenceW(zone, type, NULL, NULL, NULL);
ok(ret == 0, "expected ret == 0, got %u\n", ret);
old_template = 0;
ret = pPrivacyGetZonePreferenceW(zone, type, &old_template, NULL, NULL);
ok(ret == 0, "expected ret == 0, got %u\n", ret);
template = 5;
ret = pPrivacySetZonePreferenceW(zone, type, template, NULL);
ok(ret == 0, "expected ret == 0, got %u\n", ret);
template = 0;
ret = pPrivacyGetZonePreferenceW(zone, type, &template, NULL, NULL);
ok(ret == 0, "expected ret == 0, got %u\n", ret);
ok(template == 5, "expected template == 5, got %u\n", template);
template = 5;
ret = pPrivacySetZonePreferenceW(zone, type, old_template, NULL);
ok(ret == 0, "expected ret == 0, got %u\n", ret);
}
static void test_Option_Policy(void)
{
HINTERNET hinet;
BOOL ret;
hinet = InternetOpen(NULL, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
ok(hinet != 0, "InternetOpen failed: 0x%08x\n", GetLastError());
SetLastError(0xdeadbeef);
ret = InternetSetOptionW(hinet, INTERNET_OPTION_POLICY, NULL, 0);
ok(ret == FALSE, "InternetSetOption should've failed\n");
ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError should've "
"given ERROR_INVALID_PARAMETER, gave: 0x%08x\n", GetLastError());
SetLastError(0xdeadbeef);
ret = InternetQueryOptionW(hinet, INTERNET_OPTION_POLICY, NULL, 0);
ok(ret == FALSE, "InternetQueryOption should've failed\n");
ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError should've "
"given ERROR_INVALID_PARAMETER, gave: 0x%08x\n", GetLastError());
ret = InternetCloseHandle(hinet);
ok(ret == TRUE, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
}
#define verifyProxyEnable(e) r_verifyProxyEnable(__LINE__, e)
static void r_verifyProxyEnable(LONG l, DWORD exp)
{
HKEY hkey;
DWORD type, val, size = sizeof(DWORD);
LONG ret;
static const CHAR szInternetSettings[] = "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings";
static const CHAR szProxyEnable[] = "ProxyEnable";
ret = RegOpenKeyA(HKEY_CURRENT_USER, szInternetSettings, &hkey);
ok_(__FILE__,l) (!ret, "RegOpenKeyA failed: 0x%08x\n", ret);
ret = RegQueryValueExA(hkey, szProxyEnable, 0, &type, (BYTE*)&val, &size);
ok_(__FILE__,l) (!ret, "RegQueryValueExA failed: 0x%08x\n", ret);
ok_(__FILE__,l) (type == REG_DWORD, "Expected regtype to be REG_DWORD, was: %d\n", type);
ok_(__FILE__,l) (val == exp, "Expected ProxyEnabled to be %d, got: %d\n", exp, val);
ret = RegCloseKey(hkey);
ok_(__FILE__,l) (!ret, "RegCloseKey failed: 0x%08x\n", ret);
}
static void test_Option_PerConnectionOption(void)
{
BOOL ret;
DWORD size = sizeof(INTERNET_PER_CONN_OPTION_LISTW);
INTERNET_PER_CONN_OPTION_LISTW list = {size};
INTERNET_PER_CONN_OPTIONW *orig_settings;
static WCHAR proxy_srvW[] = {'p','r','o','x','y','.','e','x','a','m','p','l','e',0};
/* get the global IE proxy server info, to restore later */
list.dwOptionCount = 2;
list.pOptions = HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONW));
list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
list.pOptions[1].dwOption = INTERNET_PER_CONN_FLAGS;
ret = InternetQueryOptionW(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
&list, &size);
ok(ret == TRUE, "InternetQueryOption should've succeeded\n");
orig_settings = list.pOptions;
/* set the global IE proxy server */
list.dwOptionCount = 2;
list.pOptions = HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONW));
list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
list.pOptions[0].Value.pszValue = proxy_srvW;
list.pOptions[1].dwOption = INTERNET_PER_CONN_FLAGS;
list.pOptions[1].Value.dwValue = PROXY_TYPE_PROXY;
ret = InternetSetOptionW(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
&list, size);
ok(ret == TRUE, "InternetSetOption should've succeeded\n");
HeapFree(GetProcessHeap(), 0, list.pOptions);
/* get & verify the global IE proxy server */
list.dwOptionCount = 2;
list.dwOptionError = 0;
list.pOptions = HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONW));
list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
list.pOptions[1].dwOption = INTERNET_PER_CONN_FLAGS;
ret = InternetQueryOptionW(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
&list, &size);
ok(ret == TRUE, "InternetQueryOption should've succeeded\n");
ok(!strcmp_ww(list.pOptions[0].Value.pszValue, proxy_srvW),
"Retrieved proxy server should've been %s, was: %s\n",
wine_dbgstr_w(proxy_srvW), wine_dbgstr_w(list.pOptions[0].Value.pszValue));
ok(list.pOptions[1].Value.dwValue == PROXY_TYPE_PROXY,
"Retrieved flags should've been PROXY_TYPE_PROXY, was: %d\n",
list.pOptions[1].Value.dwValue);
verifyProxyEnable(1);
HeapFree(GetProcessHeap(), 0, list.pOptions[0].Value.pszValue);
HeapFree(GetProcessHeap(), 0, list.pOptions);
/* disable the proxy server */
list.dwOptionCount = 1;
list.pOptions = HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONW));
list.pOptions[0].dwOption = INTERNET_PER_CONN_FLAGS;
list.pOptions[0].Value.dwValue = PROXY_TYPE_DIRECT;
ret = InternetSetOptionW(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
&list, size);
ok(ret == TRUE, "InternetSetOption should've succeeded\n");
HeapFree(GetProcessHeap(), 0, list.pOptions);
/* verify that the proxy is disabled */
list.dwOptionCount = 1;
list.dwOptionError = 0;
list.pOptions = HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONW));
list.pOptions[0].dwOption = INTERNET_PER_CONN_FLAGS;
ret = InternetQueryOptionW(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
&list, &size);
ok(ret == TRUE, "InternetQueryOption should've succeeded\n");
ok(list.pOptions[0].Value.dwValue == PROXY_TYPE_DIRECT,
"Retrieved flags should've been PROXY_TYPE_DIRECT, was: %d\n",
list.pOptions[0].Value.dwValue);
verifyProxyEnable(0);
HeapFree(GetProcessHeap(), 0, list.pOptions);
/* set the proxy flags to 'invalid' value */
list.dwOptionCount = 1;
list.pOptions = HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONW));
list.pOptions[0].dwOption = INTERNET_PER_CONN_FLAGS;
list.pOptions[0].Value.dwValue = PROXY_TYPE_PROXY | PROXY_TYPE_DIRECT;
ret = InternetSetOptionW(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
&list, size);
ok(ret == TRUE, "InternetSetOption should've succeeded\n");
HeapFree(GetProcessHeap(), 0, list.pOptions);
/* verify that the proxy is enabled */
list.dwOptionCount = 1;
list.dwOptionError = 0;
list.pOptions = HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONW));
list.pOptions[0].dwOption = INTERNET_PER_CONN_FLAGS;
ret = InternetQueryOptionW(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
&list, &size);
ok(ret == TRUE, "InternetQueryOption should've succeeded\n");
todo_wine ok(list.pOptions[0].Value.dwValue == (PROXY_TYPE_PROXY | PROXY_TYPE_DIRECT),
"Retrieved flags should've been PROXY_TYPE_PROXY | PROXY_TYPE_DIRECT, was: %d\n",
list.pOptions[0].Value.dwValue);
verifyProxyEnable(1);
HeapFree(GetProcessHeap(), 0, list.pOptions);
/* restore original settings */
list.dwOptionCount = 2;
list.pOptions = orig_settings;
ret = InternetSetOptionW(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
&list, size);
ok(ret == TRUE, "InternetSetOption should've succeeded\n");
HeapFree(GetProcessHeap(), 0, list.pOptions);
}
static void test_Option_PerConnectionOptionA(void)
{
BOOL ret;
DWORD size = sizeof(INTERNET_PER_CONN_OPTION_LISTA);
INTERNET_PER_CONN_OPTION_LISTA list = {size};
INTERNET_PER_CONN_OPTIONA *orig_settings;
char proxy_srv[] = "proxy.example";
/* get the global IE proxy server info, to restore later */
list.dwOptionCount = 2;
list.pOptions = HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONA));
list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
list.pOptions[1].dwOption = INTERNET_PER_CONN_FLAGS;
ret = InternetQueryOptionA(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
&list, &size);
ok(ret == TRUE, "InternetQueryOption should've succeeded\n");
orig_settings = list.pOptions;
/* set the global IE proxy server */
list.dwOptionCount = 2;
list.pOptions = HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONA));
list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
list.pOptions[0].Value.pszValue = proxy_srv;
list.pOptions[1].dwOption = INTERNET_PER_CONN_FLAGS;
list.pOptions[1].Value.dwValue = PROXY_TYPE_PROXY;
ret = InternetSetOptionA(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
&list, size);
ok(ret == TRUE, "InternetSetOption should've succeeded\n");
HeapFree(GetProcessHeap(), 0, list.pOptions);
/* get & verify the global IE proxy server */
list.dwOptionCount = 2;
list.dwOptionError = 0;
list.pOptions = HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONA));
list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
list.pOptions[1].dwOption = INTERNET_PER_CONN_FLAGS;
ret = InternetQueryOptionA(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
&list, &size);
ok(ret == TRUE, "InternetQueryOption should've succeeded\n");
ok(!lstrcmpA(list.pOptions[0].Value.pszValue, "proxy.example"),
"Retrieved proxy server should've been \"%s\", was: \"%s\"\n",
proxy_srv, list.pOptions[0].Value.pszValue);
ok(list.pOptions[1].Value.dwValue == PROXY_TYPE_PROXY,
"Retrieved flags should've been PROXY_TYPE_PROXY, was: %d\n",
list.pOptions[1].Value.dwValue);
HeapFree(GetProcessHeap(), 0, list.pOptions[0].Value.pszValue);
HeapFree(GetProcessHeap(), 0, list.pOptions);
/* restore original settings */
list.dwOptionCount = 2;
list.pOptions = orig_settings;
ret = InternetSetOptionA(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
&list, size);
ok(ret == TRUE, "InternetSetOption should've succeeded\n");
HeapFree(GetProcessHeap(), 0, list.pOptions);
}
/* ############################### */
START_TEST(internet)
@ -807,6 +1088,8 @@ START_TEST(internet)
pInternetTimeToSystemTimeA = (void*)GetProcAddress(hdll, "InternetTimeToSystemTimeA");
pInternetTimeToSystemTimeW = (void*)GetProcAddress(hdll, "InternetTimeToSystemTimeW");
pIsDomainLegalCookieDomainW = (void*)GetProcAddress(hdll, (LPCSTR)117);
pPrivacyGetZonePreferenceW = (void*)GetProcAddress(hdll, "PrivacyGetZonePreferenceW");
pPrivacySetZonePreferenceW = (void*)GetProcAddress(hdll, "PrivacySetZonePreferenceW");
test_InternetCanonicalizeUrlA();
test_InternetQueryOptionA();
@ -814,6 +1097,9 @@ START_TEST(internet)
test_complicated_cookie();
test_version();
test_null();
test_Option_Policy();
test_Option_PerConnectionOption();
test_Option_PerConnectionOptionA();
if (!pInternetTimeFromSystemTimeA)
win_skip("skipping the InternetTime tests\n");
@ -832,4 +1118,9 @@ START_TEST(internet)
win_skip("IsDomainLegalCookieDomainW (or ordinal 117) is not available\n");
else
test_IsDomainLegalCookieDomainW();
if (pPrivacyGetZonePreferenceW && pPrivacySetZonePreferenceW)
test_PrivacyGetSetZonePreferenceW();
else
win_skip("Privacy[SG]etZonePreferenceW are not available\n");
}

View file

@ -23,21 +23,16 @@
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "windef.h"
#include "winbase.h"
#include "winnls.h"
#include "wininet.h"
#include "wine/test.h"
#define TEST_URL "http://www.winehq.org/site/about"
#define TEST_URL_HOST "www.winehq.org"
#define TEST_URL_PATH "/site/about"
#define TEST_URL2 "http://www.myserver.com/myscript.php?arg=1"
#define TEST_URL2_SERVER "www.myserver.com"
#define TEST_URL2_PATH "/myscript.php"
#define TEST_URL2_PATHEXTRA "/myscript.php?arg=1"
#define TEST_URL2_EXTRA "?arg=1"
#define TEST_URL "http://www.winehq.org/site/about#hi"
#define TEST_URL3 "file:///C:/Program%20Files/Atmel/AVR%20Tools/STK500/STK500.xml"
#define CREATE_URL1 "http://username:password@www.winehq.org/site/about"
@ -94,6 +89,190 @@ static void zero_compsA(
SetLastError(0xfaceabad);
}
typedef struct {
const char *url;
int scheme_off;
int scheme_len;
INTERNET_SCHEME scheme;
int host_off;
int host_len;
int host_skip_broken;
INTERNET_PORT port;
int user_off;
int user_len;
int pass_off;
int pass_len;
int path_off;
int path_len;
int extra_off;
int extra_len;
} crack_url_test_t;
static const crack_url_test_t crack_url_tests[] = {
{"http://www.winehq.org/site/about#hi",
0, 4, INTERNET_SCHEME_HTTP, 7, 14, -1, 80, -1, 0, -1, 0, 21, 11, 32, 3},
{"http://www.myserver.com/myscript.php?arg=1",
0, 4, INTERNET_SCHEME_HTTP, 7, 16, -1, 80, -1, 0, -1, 0, 23, 13, 36, 6},
{"http://www.winehq.org?test=123",
0, 4, INTERNET_SCHEME_HTTP, 7, 14, 23, 80, -1, 0, -1, 0, 21, 0, 21, 9},
{"file:///C:/Program%20Files/Atmel/AVR%20Tools/STK500/STK500.xml",
0, 4, INTERNET_SCHEME_FILE, -1, 0, -1, 0, -1, 0, -1, 0, 7, 55, -1, 0},
{"fide:///C:/Program%20Files/Atmel/AVR%20Tools/STK500/STK500.xml",
0, 4, INTERNET_SCHEME_UNKNOWN, 7, 0, -1, 0, -1, 0, -1, 0, 7, 55, -1, 0},
{"file://C:/Program%20Files/Atmel/AVR%20Tools/STK500/STK500.xml",
0, 4, INTERNET_SCHEME_FILE, -1, 0, -1, 0, -1, 0, -1, 0, 7, 54, -1, 0},
};
static void test_crack_url(const crack_url_test_t *test)
{
WCHAR buf[INTERNET_MAX_URL_LENGTH];
URL_COMPONENTSW urlw;
URL_COMPONENTSA url;
BOOL b;
zero_compsA(&url, 1, 1, 1, 1, 1, 1);
b = InternetCrackUrlA(test->url, strlen(test->url), 0, &url);
ok(b, "InternetCrackUrl failed with error %d\n", GetLastError());
if(test->scheme_off == -1)
ok(!url.lpszScheme, "[%s] url.lpszScheme = %p, expected NULL\n", test->url, url.lpszScheme);
else
ok(url.lpszScheme == test->url+test->scheme_off, "[%s] url.lpszScheme = %p, expected %p\n",
test->url, url.lpszScheme, test->url+test->scheme_off);
ok(url.dwSchemeLength == test->scheme_len, "[%s] url.lpszSchemeLength = %d, expected %d\n",
test->url, url.dwSchemeLength, test->scheme_len);
ok(url.nScheme == test->scheme, "[%s] url.nScheme = %d, expected %d\n", test->url, url.nScheme, test->scheme);
if(test->host_off == -1)
ok(!url.lpszHostName, "[%s] url.lpszHostName = %p, expected NULL\n", test->url, url.lpszHostName);
else
ok(url.lpszHostName == test->url+test->host_off, "[%s] url.lpszHostName = %p, expected %p\n",
test->url, url.lpszHostName, test->url+test->host_off);
if(test->host_skip_broken != -1 && url.dwHostNameLength == test->host_skip_broken) {
win_skip("skipping broken dwHostNameLength result\n");
return;
}
ok(url.dwHostNameLength == test->host_len, "[%s] url.lpszHostNameLength = %d, expected %d\n",
test->url, url.dwHostNameLength, test->host_len);
ok(url.nPort == test->port, "[%s] nPort = %d, expected %d\n", test->url, url.nPort, test->port);
if(test->user_off == -1)
ok(!url.lpszUserName, "[%s] url.lpszUserName = %p\n", test->url, url.lpszUserName);
else
ok(url.lpszUserName == test->url+test->user_off, "[%s] url.lpszUserName = %p, expected %p\n",
test->url, url.lpszUserName, test->url+test->user_off);
ok(url.dwUserNameLength == test->user_len, "[%s] url.lpszUserNameLength = %d, expected %d\n",
test->url, url.dwUserNameLength, test->user_len);
if(test->pass_off == -1)
ok(!url.lpszPassword, "[%s] url.lpszPassword = %p\n", test->url, url.lpszPassword);
else
ok(url.lpszPassword == test->url+test->pass_off, "[%s] url.lpszPassword = %p, expected %p\n",
test->url, url.lpszPassword, test->url+test->pass_off);
ok(url.dwPasswordLength == test->pass_len, "[%s] url.lpszPasswordLength = %d, expected %d\n",
test->url, url.dwPasswordLength, test->pass_len);
if(test->path_off == -1)
ok(!url.lpszUrlPath, "[%s] url.lpszPath = %p, expected NULL\n", test->url, url.lpszUrlPath);
else
ok(url.lpszUrlPath == test->url+test->path_off, "[%s] url.lpszPath = %p, expected %p\n",
test->url, url.lpszUrlPath, test->url+test->path_off);
ok(url.dwUrlPathLength == test->path_len, "[%s] url.lpszUrlPathLength = %d, expected %d\n",
test->url, url.dwUrlPathLength, test->path_len);
if(test->extra_off == -1)
ok(!url.lpszExtraInfo, "[%s] url.lpszExtraInfo = %p, expected NULL\n", test->url, url.lpszExtraInfo);
else
ok(url.lpszExtraInfo == test->url+test->extra_off, "[%s] url.lpszExtraInfo = %p, expected %p\n",
test->url, url.lpszExtraInfo, test->url+test->extra_off);
ok(url.dwExtraInfoLength == test->extra_len, "[%s] url.lpszExtraInfoLength = %d, expected %d\n",
test->url, url.dwExtraInfoLength, test->extra_len);
memset(&urlw, 0, sizeof(URL_COMPONENTSW));
urlw.dwStructSize = sizeof(URL_COMPONENTSW);
urlw.dwSchemeLength = 1;
urlw.dwHostNameLength = 1;
urlw.dwUserNameLength = 1;
urlw.dwPasswordLength = 1;
urlw.dwUrlPathLength = 1;
urlw.dwExtraInfoLength = 1;
MultiByteToWideChar(CP_ACP, 0, test->url, -1, buf, sizeof(buf));
b = InternetCrackUrlW(buf, lstrlenW(buf), 0, &urlw);
if(!b && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED) {
win_skip("InternetCrackUrlW is not implemented\n");
return;
}
ok(b, "InternetCrackUrl failed with error %d\n", GetLastError());
if(test->scheme_off == -1)
ok(!urlw.lpszScheme, "[%s] urlw.lpszScheme = %p, expected NULL\n", test->url, urlw.lpszScheme);
else
ok(urlw.lpszScheme == buf+test->scheme_off, "[%s] urlw.lpszScheme = %p, expected %p\n",
test->url, urlw.lpszScheme, buf+test->scheme_off);
ok(urlw.dwSchemeLength == test->scheme_len, "[%s] urlw.lpszSchemeLength = %d, expected %d\n",
test->url, urlw.dwSchemeLength, test->scheme_len);
ok(urlw.nScheme == test->scheme, "[%s] urlw.nScheme = %d, expected %d\n", test->url, urlw.nScheme, test->scheme);
if(test->host_off == -1) {
ok(!urlw.lpszHostName, "[%s] urlw.lpszHostName = %p, expected NULL\n", test->url, urlw.lpszHostName);
ok(urlw.dwHostNameLength == 0 || broken(urlw.dwHostNameLength == 1), "[%s] urlw.lpszHostNameLength = %d, expected %d\n",
test->url, urlw.dwHostNameLength, test->host_len);
}else {
ok(urlw.lpszHostName == buf+test->host_off, "[%s] urlw.lpszHostName = %p, expected %p\n",
test->url, urlw.lpszHostName, test->url+test->host_off);
ok(urlw.dwHostNameLength == test->host_len, "[%s] urlw.lpszHostNameLength = %d, expected %d\n",
test->url, urlw.dwHostNameLength, test->host_len);
}
ok(urlw.nPort == test->port, "[%s] nPort = %d, expected %d\n", test->url, urlw.nPort, test->port);
if(test->user_off == -1) {
ok(!urlw.lpszUserName, "[%s] urlw.lpszUserName = %p\n", test->url, urlw.lpszUserName);
ok(urlw.dwUserNameLength == 0 || broken(urlw.dwUserNameLength == 1), "[%s] urlw.lpszUserNameLength = %d, expected %d\n",
test->url, urlw.dwUserNameLength, test->user_len);
}else {
ok(urlw.lpszUserName == buf+test->user_off, "[%s] urlw.lpszUserName = %p, expected %p\n",
test->url, urlw.lpszUserName, buf+test->user_off);
ok(urlw.dwUserNameLength == test->user_len, "[%s] urlw.lpszUserNameLength = %d, expected %d\n",
test->url, urlw.dwUserNameLength, test->user_len);
}
if(test->pass_off == -1) {
ok(!urlw.lpszPassword, "[%s] urlw.lpszPassword = %p\n", test->url, urlw.lpszPassword);
ok(urlw.dwPasswordLength == 0 || broken(urlw.dwPasswordLength), "[%s] urlw.lpszPasswordLength = %d, expected %d\n",
test->url, urlw.dwPasswordLength, test->pass_len);
}else {
ok(urlw.lpszPassword == buf+test->pass_off, "[%s] urlw.lpszPassword = %p, expected %p\n",
test->url, urlw.lpszPassword, buf+test->pass_off);
ok(urlw.dwPasswordLength == test->pass_len, "[%s] urlw.lpszPasswordLength = %d, expected %d\n",
test->url, urlw.dwPasswordLength, test->pass_len);
}
if(test->path_off == -1)
ok(!urlw.lpszUrlPath, "[%s] urlw.lpszPath = %p, expected NULL\n", test->url, urlw.lpszUrlPath);
else
ok(urlw.lpszUrlPath == buf+test->path_off, "[%s] urlw.lpszPath = %p, expected %p\n",
test->url, urlw.lpszUrlPath, buf+test->path_off);
ok(urlw.dwUrlPathLength == test->path_len, "[%s] urlw.lpszUrlPathLength = %d, expected %d\n",
test->url, urlw.dwUrlPathLength, test->path_len);
if(test->extra_off == -1) {
ok(!urlw.lpszExtraInfo, "[%s] url.lpszExtraInfo = %p, expected NULL\n", test->url, urlw.lpszExtraInfo);
ok(urlw.dwExtraInfoLength == 0 || broken(urlw.dwExtraInfoLength == 1), "[%s] urlw.lpszExtraInfoLength = %d, expected %d\n",
test->url, urlw.dwExtraInfoLength, test->extra_len);
}else {
ok(urlw.lpszExtraInfo == buf+test->extra_off, "[%s] urlw.lpszExtraInfo = %p, expected %p\n",
test->url, urlw.lpszExtraInfo, buf+test->extra_off);
ok(urlw.dwExtraInfoLength == test->extra_len, "[%s] urlw.lpszExtraInfoLength = %d, expected %d\n",
test->url, urlw.dwExtraInfoLength, test->extra_len);
}
}
static void InternetCrackUrl_test(void)
{
URL_COMPONENTSA urlSrc, urlComponents;
@ -111,51 +290,6 @@ static void InternetCrackUrl_test(void)
urlSrc.lpszUrlPath = path;
urlSrc.lpszExtraInfo = extra;
copy_compsA(&urlSrc, &urlComponents, 32, 1024, 1024, 1024, 2048, 1024);
ret = InternetCrackUrl(TEST_URL, 0,0,&urlComponents);
ok( ret, "InternetCrackUrl failed, error %d\n",GetLastError());
ok((strcmp(TEST_URL_PATH,path) == 0),"path cracked wrong\n");
/* Bug 1805: Confirm the returned lengths are correct: */
/* 1. When extra info split out explicitly */
zero_compsA(&urlComponents, 0, 1, 0, 0, 1, 1);
ok(InternetCrackUrlA(TEST_URL2, 0, 0, &urlComponents),"InternetCrackUrl failed, error %d\n", GetLastError());
ok(urlComponents.dwUrlPathLength == strlen(TEST_URL2_PATH),".dwUrlPathLength should be %d, but is %d\n", (DWORD)strlen(TEST_URL2_PATH), urlComponents.dwUrlPathLength);
ok(!strncmp(urlComponents.lpszUrlPath,TEST_URL2_PATH,strlen(TEST_URL2_PATH)),"lpszUrlPath should be %s but is %s\n", TEST_URL2_PATH, urlComponents.lpszUrlPath);
ok(urlComponents.dwHostNameLength == strlen(TEST_URL2_SERVER),".dwHostNameLength should be %d, but is %d\n", (DWORD)strlen(TEST_URL2_SERVER), urlComponents.dwHostNameLength);
ok(!strncmp(urlComponents.lpszHostName,TEST_URL2_SERVER,strlen(TEST_URL2_SERVER)),"lpszHostName should be %s but is %s\n", TEST_URL2_SERVER, urlComponents.lpszHostName);
ok(urlComponents.dwExtraInfoLength == strlen(TEST_URL2_EXTRA),".dwExtraInfoLength should be %d, but is %d\n", (DWORD)strlen(TEST_URL2_EXTRA), urlComponents.dwExtraInfoLength);
ok(!strncmp(urlComponents.lpszExtraInfo,TEST_URL2_EXTRA,strlen(TEST_URL2_EXTRA)),"lpszExtraInfo should be %s but is %s\n", TEST_URL2_EXTRA, urlComponents.lpszHostName);
/* 2. When extra info is not split out explicitly and is in url path */
zero_compsA(&urlComponents, 0, 1, 0, 0, 1, 0);
ok(InternetCrackUrlA(TEST_URL2, 0, 0, &urlComponents),"InternetCrackUrl failed with GLE %d\n",GetLastError());
ok(urlComponents.dwUrlPathLength == strlen(TEST_URL2_PATHEXTRA),".dwUrlPathLength should be %d, but is %d\n", (DWORD)strlen(TEST_URL2_PATHEXTRA), urlComponents.dwUrlPathLength);
ok(!strncmp(urlComponents.lpszUrlPath,TEST_URL2_PATHEXTRA,strlen(TEST_URL2_PATHEXTRA)),"lpszUrlPath should be %s but is %s\n", TEST_URL2_PATHEXTRA, urlComponents.lpszUrlPath);
ok(urlComponents.dwHostNameLength == strlen(TEST_URL2_SERVER),".dwHostNameLength should be %d, but is %d\n", (DWORD)strlen(TEST_URL2_SERVER), urlComponents.dwHostNameLength);
ok(!strncmp(urlComponents.lpszHostName,TEST_URL2_SERVER,strlen(TEST_URL2_SERVER)),"lpszHostName should be %s but is %s\n", TEST_URL2_SERVER, urlComponents.lpszHostName);
ok(urlComponents.nPort == INTERNET_DEFAULT_HTTP_PORT,"urlComponents->nPort should have been 80 instead of %d\n", urlComponents.nPort);
ok(urlComponents.nScheme == INTERNET_SCHEME_HTTP,"urlComponents->nScheme should have been INTERNET_SCHEME_HTTP instead of %d\n", urlComponents.nScheme);
zero_compsA(&urlComponents, 1, 1, 1, 1, 1, 1);
ok(InternetCrackUrlA(TEST_URL, strlen(TEST_URL), 0, &urlComponents),"InternetCrackUrl failed with GLE %d\n",GetLastError());
ok(urlComponents.dwUrlPathLength == strlen(TEST_URL_PATH),".dwUrlPathLength should be %d, but is %d\n", lstrlenA(TEST_URL_PATH), urlComponents.dwUrlPathLength);
ok(!strncmp(urlComponents.lpszUrlPath,TEST_URL_PATH,strlen(TEST_URL_PATH)),"lpszUrlPath should be %s but is %s\n", TEST_URL_PATH, urlComponents.lpszUrlPath);
ok(urlComponents.dwHostNameLength == strlen(TEST_URL_HOST),".dwHostNameLength should be %d, but is %d\n", lstrlenA(TEST_URL_HOST), urlComponents.dwHostNameLength);
ok(!strncmp(urlComponents.lpszHostName,TEST_URL_HOST,strlen(TEST_URL_HOST)),"lpszHostName should be %s but is %s\n", TEST_URL_HOST, urlComponents.lpszHostName);
ok(urlComponents.nPort == INTERNET_DEFAULT_HTTP_PORT,"urlComponents->nPort should have been 80 instead of %d\n", urlComponents.nPort);
ok(urlComponents.nScheme == INTERNET_SCHEME_HTTP,"urlComponents->nScheme should have been INTERNET_SCHEME_HTTP instead of %d\n", urlComponents.nScheme);
ok(!urlComponents.lpszUserName, ".lpszUserName should have been set to NULL\n");
ok(!urlComponents.lpszPassword, ".lpszPassword should have been set to NULL\n");
ok(!urlComponents.lpszExtraInfo, ".lpszExtraInfo should have been set to NULL\n");
ok(!urlComponents.dwUserNameLength,".dwUserNameLength should be 0, but is %d\n", urlComponents.dwUserNameLength);
ok(!urlComponents.dwPasswordLength,".dwPasswordLength should be 0, but is %d\n", urlComponents.dwPasswordLength);
ok(!urlComponents.dwExtraInfoLength,".dwExtraInfoLength should be 0, but is %d\n", urlComponents.dwExtraInfoLength);
/*3. Check for %20 */
copy_compsA(&urlSrc, &urlComponents, 32, 1024, 1024, 1024, 2048, 1024);
ok(InternetCrackUrlA(TEST_URL3, 0, ICU_DECODE, &urlComponents),"InternetCrackUrl failed with GLE %d\n",GetLastError());
/* Tests for lpsz* members pointing to real strings while
* some corresponding length members are set to zero.
* As of IE7 (wininet 7.0*?) all members are checked. So we
@ -810,6 +944,11 @@ static void InternetCreateUrlA_test(void)
START_TEST(url)
{
int i;
for(i=0; i < sizeof(crack_url_tests)/sizeof(*crack_url_tests); i++)
test_crack_url(crack_url_tests+i);
InternetCrackUrl_test();
InternetCrackUrlW_test();
InternetCreateUrlA_test();

View file

@ -25,15 +25,18 @@
#include "windef.h"
#include "winbase.h"
#include "wininet.h"
#include "winineti.h"
#include "wine/test.h"
#define TEST_URL "http://urlcachetest.winehq.org/index.html"
#define TEST_URL1 "Visited: user@http://urlcachetest.winehq.org/index.html"
static BOOL (WINAPI *pDeleteUrlCacheEntryA)(LPCSTR);
static BOOL (WINAPI *pUnlockUrlCacheEntryFileA)(LPCSTR,DWORD);
static char filenameA[MAX_PATH + 1];
static char filenameA1[MAX_PATH + 1];
static void check_cache_entry_infoA(const char *returnedfrom, LPINTERNET_CACHE_ENTRY_INFO lpCacheEntryInfo)
{
@ -53,6 +56,7 @@ static void test_find_url_cache_entriesA(void)
LPINTERNET_CACHE_ENTRY_INFO lpCacheEntryInfo;
cbCacheEntryInfo = 0;
SetLastError(0xdeadbeef);
hEnumHandle = FindFirstUrlCacheEntry(NULL, NULL, &cbCacheEntryInfo);
ok(!hEnumHandle, "FindFirstUrlCacheEntry should have failed\n");
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "FindFirstUrlCacheEntry should have set last error to ERROR_INSUFFICIENT_BUFFER instead of %d\n", GetLastError());
@ -67,6 +71,7 @@ static void test_find_url_cache_entriesA(void)
found = TRUE;
break;
}
SetLastError(0xdeadbeef);
cbCacheEntryInfo = cbCacheEntryInfoSaved;
ret = FindNextUrlCacheEntry(hEnumHandle, lpCacheEntryInfo, &cbCacheEntryInfo);
if (!ret)
@ -94,19 +99,37 @@ static void test_GetUrlCacheEntryInfoExA(void)
DWORD cbCacheEntryInfo;
LPINTERNET_CACHE_ENTRY_INFO lpCacheEntryInfo;
SetLastError(0xdeadbeef);
ret = GetUrlCacheEntryInfoEx(NULL, NULL, NULL, NULL, NULL, NULL, 0);
ok(!ret, "GetUrlCacheEntryInfoEx with NULL URL and NULL args should have failed\n");
ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetUrlCacheEntryInfoEx with NULL URL and NULL args should have set last error to ERROR_INVALID_PARAMETER instead of %d\n", GetLastError());
ok(GetLastError() == ERROR_INVALID_PARAMETER,
"GetUrlCacheEntryInfoEx with NULL URL and NULL args should have set last error to ERROR_INVALID_PARAMETER instead of %d\n", GetLastError());
cbCacheEntryInfo = sizeof(INTERNET_CACHE_ENTRY_INFO);
SetLastError(0xdeadbeef);
ret = GetUrlCacheEntryInfoEx("", NULL, &cbCacheEntryInfo, NULL, NULL, NULL, 0);
ok(!ret, "GetUrlCacheEntryInfoEx with zero-length buffer should fail\n");
ok(GetLastError() == ERROR_FILE_NOT_FOUND,
"GetUrlCacheEntryInfoEx should have set last error to ERROR_FILE_NOT_FOUND instead of %d\n", GetLastError());
ret = GetUrlCacheEntryInfoEx(TEST_URL, NULL, NULL, NULL, NULL, NULL, 0);
ok(ret, "GetUrlCacheEntryInfoEx with NULL args failed with error %d\n", GetLastError());
cbCacheEntryInfo = 0;
SetLastError(0xdeadbeef);
ret = GetUrlCacheEntryInfoEx(TEST_URL, NULL, &cbCacheEntryInfo, NULL, NULL, NULL, 0);
ok(!ret, "GetUrlCacheEntryInfoEx with zero-length buffer should fail\n");
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "GetUrlCacheEntryInfoEx should have set last error to ERROR_INSUFFICIENT_BUFFER instead of %d\n", GetLastError());
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER,
"GetUrlCacheEntryInfoEx should have set last error to ERROR_INSUFFICIENT_BUFFER instead of %d\n", GetLastError());
lpCacheEntryInfo = HeapAlloc(GetProcessHeap(), 0, cbCacheEntryInfo);
SetLastError(0xdeadbeef);
ret = GetUrlCacheEntryInfoEx(TEST_URL, lpCacheEntryInfo, &cbCacheEntryInfo, NULL, NULL, NULL, 0x200);
ok(!ret, "GetUrlCacheEntryInfoEx succeeded\n");
ok(GetLastError() == ERROR_FILE_NOT_FOUND,
"GetUrlCacheEntryInfoEx should have set last error to ERROR_FILE_NOT_FOUND instead of %d\n", GetLastError());
ret = GetUrlCacheEntryInfoEx(TEST_URL, lpCacheEntryInfo, &cbCacheEntryInfo, NULL, NULL, NULL, 0);
ok(ret, "GetUrlCacheEntryInfoEx failed with error %d\n", GetLastError());
@ -161,6 +184,11 @@ static void test_urlcacheA(void)
ret = CreateUrlCacheEntry(TEST_URL, 0, "html", filenameA, 0);
ok(ret, "CreateUrlCacheEntry failed with error %d\n", GetLastError());
ret = CreateUrlCacheEntry(TEST_URL, 0, "html", filenameA1, 0);
ok(ret, "CreateUrlCacheEntry failed with error %d\n", GetLastError());
ok(lstrcmpiA(filenameA, filenameA1), "expected a different file name\n");
hFile = CreateFileA(filenameA, GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE,
NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
ok(hFile != INVALID_HANDLE_VALUE, "CreateFileA failed with error %d\n", GetLastError());
@ -170,13 +198,21 @@ static void test_urlcacheA(void)
CloseHandle(hFile);
ret = CommitUrlCacheEntry(TEST_URL1, NULL, filetime_zero, filetime_zero, NORMAL_CACHE_ENTRY|URLHISTORY_CACHE_ENTRY, NULL, 0, NULL, NULL);
ok(ret, "CommitUrlCacheEntry failed with error %d\n", GetLastError());
ret = CommitUrlCacheEntry(TEST_URL1, NULL, filetime_zero, filetime_zero, NORMAL_CACHE_ENTRY|URLHISTORY_CACHE_ENTRY, NULL, 0, NULL, NULL);
ok(ret, "CommitUrlCacheEntry failed with error %d\n", GetLastError());
ret = CommitUrlCacheEntry(TEST_URL, filenameA, filetime_zero, filetime_zero, NORMAL_CACHE_ENTRY, NULL, 0, "html", NULL);
ok(ret, "CommitUrlCacheEntry failed with error %d\n", GetLastError());
cbCacheEntryInfo = 0;
SetLastError(0xdeadbeef);
ret = RetrieveUrlCacheEntryFile(TEST_URL, NULL, &cbCacheEntryInfo, 0);
ok(!ret, "RetrieveUrlCacheEntryFile should have failed\n");
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "RetrieveUrlCacheEntryFile should have set last error to ERROR_INSUFFICIENT_BUFFER instead of %d\n", GetLastError());
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER,
"RetrieveUrlCacheEntryFile should have set last error to ERROR_INSUFFICIENT_BUFFER instead of %d\n", GetLastError());
lpCacheEntryInfo = HeapAlloc(GetProcessHeap(), 0, cbCacheEntryInfo);
ret = RetrieveUrlCacheEntryFile(TEST_URL, lpCacheEntryInfo, &cbCacheEntryInfo, 0);
@ -186,6 +222,13 @@ static void test_urlcacheA(void)
HeapFree(GetProcessHeap(), 0, lpCacheEntryInfo);
cbCacheEntryInfo = 0;
SetLastError(0xdeadbeef);
ret = RetrieveUrlCacheEntryFile(TEST_URL1, NULL, &cbCacheEntryInfo, 0);
ok(!ret, "RetrieveUrlCacheEntryFile should have failed\n");
ok(GetLastError() == ERROR_INVALID_DATA,
"RetrieveUrlCacheEntryFile should have set last error to ERROR_INVALID_DATA instead of %d\n", GetLastError());
if (pUnlockUrlCacheEntryFileA)
{
ret = pUnlockUrlCacheEntryFileA(TEST_URL, 0);
@ -202,8 +245,11 @@ static void test_urlcacheA(void)
{
ret = pDeleteUrlCacheEntryA(TEST_URL);
ok(ret, "DeleteUrlCacheEntryA failed with error %d\n", GetLastError());
ret = pDeleteUrlCacheEntryA(TEST_URL1);
ok(ret, "DeleteUrlCacheEntryA failed with error %d\n", GetLastError());
}
SetLastError(0xdeadbeef);
ret = DeleteFile(filenameA);
todo_wine
ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, "local file should no longer exist\n");
@ -213,12 +259,54 @@ static void test_FindCloseUrlCache(void)
{
BOOL r;
DWORD err;
SetLastError(0xdeadbeef);
r = FindCloseUrlCache(NULL);
err = GetLastError();
ok(0 == r, "expected 0, got %d\n", r);
ok(ERROR_INVALID_HANDLE == err, "expected %d, got %d\n", ERROR_INVALID_HANDLE, err);
}
static void test_GetDiskInfoA(void)
{
BOOL ret;
DWORD error, cluster_size;
DWORDLONG free, total;
char path[MAX_PATH], *p;
GetSystemDirectoryA(path, MAX_PATH);
if ((p = strchr(path, '\\'))) *++p = 0;
ret = GetDiskInfoA(path, &cluster_size, &free, &total);
ok(ret, "GetDiskInfoA failed %u\n", GetLastError());
ret = GetDiskInfoA(path, &cluster_size, &free, NULL);
ok(ret, "GetDiskInfoA failed %u\n", GetLastError());
ret = GetDiskInfoA(path, &cluster_size, NULL, NULL);
ok(ret, "GetDiskInfoA failed %u\n", GetLastError());
ret = GetDiskInfoA(path, NULL, NULL, NULL);
ok(ret, "GetDiskInfoA failed %u\n", GetLastError());
SetLastError(0xdeadbeef);
strcpy(p, "\\non\\existing\\path");
ret = GetDiskInfoA(path, NULL, NULL, NULL);
error = GetLastError();
ok(!ret ||
broken(ret), /* < IE7 */
"GetDiskInfoA succeeded\n");
ok(error == ERROR_PATH_NOT_FOUND ||
broken(error == 0xdeadbeef), /* < IE7 */
"got %u expected ERROR_PATH_NOT_FOUND\n", error);
SetLastError(0xdeadbeef);
ret = GetDiskInfoA(NULL, NULL, NULL, NULL);
error = GetLastError();
ok(!ret, "GetDiskInfoA succeeded\n");
ok(error == ERROR_INVALID_PARAMETER, "got %u expected ERROR_INVALID_PARAMETER\n", error);
}
START_TEST(urlcache)
{
HMODULE hdll;
@ -227,4 +315,5 @@ START_TEST(urlcache)
pUnlockUrlCacheEntryFileA = (void*)GetProcAddress(hdll, "UnlockUrlCacheEntryFileA");
test_urlcacheA();
test_FindCloseUrlCache();
test_GetDiskInfoA();
}

View file

@ -3,10 +3,11 @@
<group>
<module name="wininet_winetest" type="win32cui" installbase="bin" installname="wininet_winetest.exe" allowwarnings="true">
<include base="wininet_winetest">.</include>
<define name="__ROS_LONG64__" />
<define name="__ROS_LONG64__" />
<library>wine</library>
<library>wininet</library>
<library>ws2_32</library>
<library>advapi32</library>
<library>ntdll</library>
<file>ftp.c</file>
<file>generated.c</file>