- Sync wine tests with Wine 1.1.21

svn path=/trunk/; revision=40949
This commit is contained in:
Dmitry Chapyshev 2009-05-17 07:05:22 +00:00
parent 03ac7b5446
commit 471e010d18
178 changed files with 22374 additions and 5609 deletions

View file

@ -238,7 +238,13 @@ static void test_generic(void)
new_cred.UserName = (char *)"winetest";
ret = pCredWriteA(&new_cred, 0);
ok(ret, "CredWriteA failed with error %d\n", GetLastError());
ok(ret || broken(GetLastError() == ERROR_NO_SUCH_LOGON_SESSION),
"CredWriteA failed with error %d\n", GetLastError());
if (!ret)
{
skip("couldn't write generic credentials, skipping tests\n");
return;
}
ret = pCredEnumerateA(NULL, 0, &count, &creds);
ok(ret, "CredEnumerateA failed with error %d\n", GetLastError());
@ -345,7 +351,7 @@ START_TEST(cred)
if (!pCredEnumerateA || !pCredFree || !pCredWriteA || !pCredDeleteA ||
!pCredReadA)
{
skip("credentials functions not present in advapi32.dll\n");
win_skip("credentials functions not present in advapi32.dll\n");
return;
}

View file

@ -331,7 +331,7 @@ static void test_incorrect_api_usage(void)
GetLastError() == ERROR_CALL_NOT_IMPLEMENTED), "%d\n", GetLastError());
}
else
skip("CryptSignHashW is not available\n");
win_skip("CryptSignHashW is not available\n");
result = pCryptSetKeyParam(hKey, 0, &temp, 1);
ok (!result && GetLastError() == ERROR_INVALID_PARAMETER, "%d\n", GetLastError());
@ -349,7 +349,7 @@ static void test_incorrect_api_usage(void)
GetLastError() == ERROR_CALL_NOT_IMPLEMENTED), "%d\n", GetLastError());
}
else
skip("CryptVerifySignatureW is not available\n");
win_skip("CryptVerifySignatureW is not available\n");
result = pCryptDestroyHash(hHash);
ok (!result && GetLastError() == ERROR_INVALID_PARAMETER, "%d\n", GetLastError());
@ -394,7 +394,7 @@ static void test_verify_sig(void)
if (!pCryptVerifySignatureW)
{
skip("CryptVerifySignatureW is not available\n");
win_skip("CryptVerifySignatureW is not available\n");
return;
}
@ -402,7 +402,7 @@ static void test_verify_sig(void)
ret = pCryptVerifySignatureW(0, NULL, 0, 0, NULL, 0);
if (!ret && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
{
skip("CryptVerifySignatureW is not implemented\n");
win_skip("CryptVerifySignatureW is not implemented\n");
return;
}
ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
@ -497,13 +497,13 @@ static void test_enum_providers(void)
if(!pCryptEnumProvidersA)
{
skip("CryptEnumProvidersA is not available\n");
win_skip("CryptEnumProvidersA is not available\n");
return;
}
if (!FindProvRegVals(dwIndex, &dwType, &pszProvName, &cbName, &provCount))
{
skip("Could not find providers in registry\n");
win_skip("Could not find providers in registry\n");
return;
}
@ -643,7 +643,7 @@ static void test_enum_provider_types(void)
if(!pCryptEnumProviderTypesA)
{
skip("CryptEnumProviderTypesA is not available\n");
win_skip("CryptEnumProviderTypesA is not available\n");
return;
}
@ -784,7 +784,7 @@ static void test_get_default_provider(void)
if(!pCryptGetDefaultProviderA)
{
skip("CryptGetDefaultProviderA is not available\n");
win_skip("CryptGetDefaultProviderA is not available\n");
return;
}
@ -858,7 +858,7 @@ static void test_set_provider_ex(void)
if(!pCryptGetDefaultProviderA || !pCryptSetProviderExA)
{
skip("CryptGetDefaultProviderA and/or CryptSetProviderExA are not available\n");
win_skip("CryptGetDefaultProviderA and/or CryptSetProviderExA are not available\n");
return;
}

View file

@ -43,8 +43,8 @@ typedef VOID (WINAPI *fnSystemFunction006)( PCSTR passwd, PSTR lmhash );
typedef NTSTATUS (WINAPI *fnSystemFunction008)(const BYTE *, const BYTE *, LPBYTE);
typedef NTSTATUS (WINAPI *fnSystemFunction009)(const BYTE *, const BYTE *, LPBYTE);
typedef int (WINAPI *descrypt)(unsigned char *, unsigned char *, unsigned char *);
typedef NTSTATUS (WINAPI *fnSystemFunction030)(void*, void*);
typedef NTSTATUS (WINAPI *fnSystemFunction032)(struct ustring *, struct ustring *);
typedef NTSTATUS (WINAPI *fnSystemFunction030)(const void*, const void*);
typedef NTSTATUS (WINAPI *fnSystemFunction032)(struct ustring *, const struct ustring *);
fnSystemFunction001 pSystemFunction001;
fnSystemFunction002 pSystemFunction002;
@ -413,7 +413,7 @@ static void test_SystemFunction_encrypt(descrypt func, int num)
if (!func)
{
skip("SystemFunction%03d is not available\n", num);
win_skip("SystemFunction%03d is not available\n", num);
return;
}
@ -434,7 +434,7 @@ static void test_SystemFunction_decrypt(descrypt func, int num)
if (!func)
{
skip("SystemFunction%03d is not available\n", num);
win_skip("SystemFunction%03d is not available\n", num);
return;
}
@ -460,7 +460,7 @@ static void test_SystemFunction_enc32(descrypt func, int num)
if (!func)
{
skip("SystemFunction%03d is not available\n", num);
win_skip("SystemFunction%03d is not available\n", num);
return;
}
@ -482,7 +482,7 @@ static void test_SystemFunction_dec32(descrypt func, int num)
if (!func)
{
skip("SystemFunction%03d is not available\n", num);
win_skip("SystemFunction%03d is not available\n", num);
return;
}
@ -504,7 +504,7 @@ static void test_memcmpfunc(memcmpfunc fn)
if (!fn)
{
skip("function is not available\n");
win_skip("function is not available\n");
return;
}
@ -549,49 +549,49 @@ START_TEST(crypt_lmhash)
if (pSystemFunction001)
test_SystemFunction001();
else
skip("SystemFunction001 is not available\n");
win_skip("SystemFunction001 is not available\n");
pSystemFunction002 = (fnSystemFunction002)GetProcAddress( module, "SystemFunction002" );
if (pSystemFunction002)
test_SystemFunction002();
else
skip("SystemFunction002 is not available\n");
win_skip("SystemFunction002 is not available\n");
pSystemFunction003 = (fnSystemFunction003)GetProcAddress( module, "SystemFunction003" );
if (pSystemFunction003)
test_SystemFunction003();
else
skip("SystemFunction002 is not available\n");
win_skip("SystemFunction002 is not available\n");
pSystemFunction004 = (fnSystemFunction004)GetProcAddress( module, "SystemFunction004" );
if (pSystemFunction004)
test_SystemFunction004();
else
skip("SystemFunction004 is not available\n");
win_skip("SystemFunction004 is not available\n");
pSystemFunction005 = (fnSystemFunction005)GetProcAddress( module, "SystemFunction005" );
if (pSystemFunction005)
test_SystemFunction005();
else
skip("SystemFunction005 is not available\n");
win_skip("SystemFunction005 is not available\n");
pSystemFunction006 = (fnSystemFunction006)GetProcAddress( module, "SystemFunction006" );
if (pSystemFunction006)
test_SystemFunction006();
else
skip("SystemFunction006 is not available\n");
win_skip("SystemFunction006 is not available\n");
pSystemFunction008 = (fnSystemFunction008)GetProcAddress( module, "SystemFunction008" );
if (pSystemFunction008)
test_SystemFunction008();
else
skip("SystemFunction008 is not available\n");
win_skip("SystemFunction008 is not available\n");
pSystemFunction009 = (fnSystemFunction009)GetProcAddress( module, "SystemFunction009" );
if (pSystemFunction009)
test_SystemFunction009();
else
skip("SystemFunction009 is not available\n");
win_skip("SystemFunction009 is not available\n");
pSystemFunction012 = (descrypt) GetProcAddress( module, "SystemFunction012");
pSystemFunction013 = (descrypt) GetProcAddress( module, "SystemFunction013");
@ -645,5 +645,5 @@ START_TEST(crypt_lmhash)
if (pSystemFunction032)
test_SystemFunction032();
else
skip("SystemFunction032 is not available\n");
win_skip("SystemFunction032 is not available\n");
}

View file

@ -156,23 +156,23 @@ START_TEST(crypt_md4)
if (pMD4Init && pMD4Update && pMD4Final)
test_md4_ctx();
else
skip("MD4Init and/or MD4Update and/or MD4Final are not available\n");
win_skip("MD4Init and/or MD4Update and/or MD4Final are not available\n");
pSystemFunction007 = (fnSystemFunction007)GetProcAddress( module, "SystemFunction007" );
if (pSystemFunction007)
test_SystemFunction007();
else
skip("SystemFunction007 is not available\n");
win_skip("SystemFunction007 is not available\n");
pSystemFunction010 = (md4hashfunc)GetProcAddress( module, "SystemFunction010" );
if (pSystemFunction010)
test_md4hashfunc(pSystemFunction010);
else
skip("SystemFunction010 is not available\n");
win_skip("SystemFunction010 is not available\n");
pSystemFunction011 = (md4hashfunc)GetProcAddress( module, "SystemFunction011" );
if (pSystemFunction011)
test_md4hashfunc(pSystemFunction011);
else
skip("SystemFunction011 is not available\n");
win_skip("SystemFunction011 is not available\n");
}

View file

@ -85,7 +85,7 @@ static void test_md5_ctx(void)
if (!pMD5Init || !pMD5Update || !pMD5Final)
{
skip("Needed functions are not available\n");
win_skip("Needed functions are not available\n");
return;
}

View file

@ -53,7 +53,7 @@ static void test_sha_ctx(void)
if (!pA_SHAInit || !pA_SHAUpdate || !pA_SHAFinal)
{
skip("A_SHAInit and/or A_SHAUpdate and/or A_SHAFinal are not available\n");
win_skip("A_SHAInit and/or A_SHAUpdate and/or A_SHAFinal are not available\n");
return;
}

View file

@ -182,7 +182,7 @@ static void test_lsa(void)
START_TEST(lsa)
{
if (!init()) {
skip("Needed functions are not available\n");
win_skip("Needed functions are not available\n");
return;
}

View file

@ -47,9 +47,9 @@ static DWORD (WINAPI *pRegDeleteTreeA)(HKEY,LPCSTR);
static char *get_temp_buffer( int size )
{
static char *list[32];
static long pos;
static UINT pos;
char *ret;
int idx;
UINT idx;
idx = ++pos % (sizeof(list)/sizeof(list[0]));
if ((ret = realloc( list[idx], size ))) list[idx] = ret;

View file

@ -857,7 +857,7 @@ static void test_AccessCheck(void)
GetProcAddress(NtDllModule, "RtlAdjustPrivilege");
if (!pRtlAdjustPrivilege)
{
skip("missing RtlAdjustPrivilege, skipping test\n");
win_skip("missing RtlAdjustPrivilege, skipping test\n");
return;
}
@ -1128,7 +1128,7 @@ static void test_AccessCheck(void)
ok(ret, "AddAccessAllowedAceEx failed with error %d\n", GetLastError());
}
else
skip("AddAccessAllowedAceEx is not available\n");
win_skip("AddAccessAllowedAceEx is not available\n");
ret = AccessCheck(SecurityDescriptor, Token, KEY_READ, &Mapping,
PrivSet, &PrivSetLen, &Access, &AccessStatus);
@ -1176,27 +1176,29 @@ static void test_AccessCheck(void)
static void test_token_attr(void)
{
HANDLE Token, ImpersonationToken;
DWORD Size;
DWORD Size, Size2;
TOKEN_PRIVILEGES *Privileges;
TOKEN_GROUPS *Groups;
TOKEN_USER *User;
TOKEN_DEFAULT_DACL *Dacl;
BOOL ret;
DWORD i, GLE;
LPSTR SidString;
SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
ACL *acl;
/* cygwin-like use case */
SetLastError(0xdeadbeef);
ret = OpenProcessToken(GetCurrentProcess(), MAXIMUM_ALLOWED, &Token);
if(!ret && (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED))
{
skip("OpenProcessToken is not implemented\n");
win_skip("OpenProcessToken is not implemented\n");
return;
}
ok(ret, "OpenProcessToken failed with error %d\n", GetLastError());
if (ret)
{
BYTE buf[1024];
DWORD buf[256]; /* GetTokenInformation wants a dword-aligned buffer */
Size = sizeof(buf);
ret = GetTokenInformation(Token, TokenUser,(void*)buf, Size, &Size);
ok(ret, "GetTokenInformation failed with error %d\n", GetLastError());
@ -1209,12 +1211,12 @@ static void test_token_attr(void)
if(!pConvertSidToStringSidA)
{
skip("ConvertSidToStringSidA is not available\n");
win_skip("ConvertSidToStringSidA is not available\n");
return;
}
SetLastError(0xdeadbeef);
ret = OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY|TOKEN_DUPLICATE, &Token);
ret = OpenProcessToken(GetCurrentProcess(), TOKEN_ALL_ACCESS, &Token);
ok(ret, "OpenProcessToken failed with error %d\n", GetLastError());
/* groups */
@ -1283,6 +1285,49 @@ static void test_token_attr(void)
ok(ImpersonationLevel == SecurityAnonymous, "ImpersonationLevel should have been SecurityAnonymous instead of %d\n", ImpersonationLevel);
CloseHandle(ImpersonationToken);
/* default dacl */
ret = GetTokenInformation(Token, TokenDefaultDacl, NULL, 0, &Size);
ok(!ret && (GetLastError() == ERROR_INSUFFICIENT_BUFFER),
"GetTokenInformation(TokenDefaultDacl) failed with error %u\n", GetLastError());
Dacl = HeapAlloc(GetProcessHeap(), 0, Size);
ret = GetTokenInformation(Token, TokenDefaultDacl, Dacl, Size, &Size);
ok(ret, "GetTokenInformation(TokenDefaultDacl) failed with error %u\n", GetLastError());
SetLastError(0xdeadbeef);
ret = SetTokenInformation(Token, TokenDefaultDacl, NULL, 0);
GLE = GetLastError();
ok(!ret, "SetTokenInformation(TokenDefaultDacl) succeeded\n");
ok(GLE == ERROR_BAD_LENGTH, "expected ERROR_BAD_LENGTH got %u\n", GLE);
SetLastError(0xdeadbeef);
ret = SetTokenInformation(Token, TokenDefaultDacl, NULL, Size);
GLE = GetLastError();
ok(!ret, "SetTokenInformation(TokenDefaultDacl) succeeded\n");
ok(GLE == ERROR_NOACCESS, "expected ERROR_NOACCESS got %u\n", GLE);
acl = Dacl->DefaultDacl;
Dacl->DefaultDacl = NULL;
ret = SetTokenInformation(Token, TokenDefaultDacl, Dacl, Size);
ok(ret, "SetTokenInformation(TokenDefaultDacl) succeeded\n");
Size2 = 0;
Dacl->DefaultDacl = (ACL *)0xdeadbeef;
ret = GetTokenInformation(Token, TokenDefaultDacl, Dacl, Size, &Size2);
ok(ret, "GetTokenInformation(TokenDefaultDacl) failed with error %u\n", GetLastError());
ok(Dacl->DefaultDacl == NULL, "expected NULL, got %p\n", Dacl->DefaultDacl);
ok(Size2 == sizeof(TOKEN_DEFAULT_DACL), "got %u expected sizeof(TOKEN_DEFAULT_DACL)\n", Size2);
Dacl->DefaultDacl = acl;
ret = SetTokenInformation(Token, TokenDefaultDacl, Dacl, Size);
ok(ret, "SetTokenInformation(TokenDefaultDacl) failed with error %u\n", GetLastError());
ret = GetTokenInformation(Token, TokenDefaultDacl, Dacl, Size, &Size2);
ok(ret, "GetTokenInformation(TokenDefaultDacl) failed with error %u\n", GetLastError());
HeapFree(GetProcessHeap(), 0, Dacl);
CloseHandle(Token);
}
@ -1354,15 +1399,36 @@ struct well_known_sid_value
static void test_CreateWellKnownSid(void)
{
SID_IDENTIFIER_AUTHORITY ident = { SECURITY_NT_AUTHORITY };
PSID domainsid;
PSID domainsid, sid;
DWORD size, error;
BOOL ret;
int i;
if (!pCreateWellKnownSid)
{
skip("CreateWellKnownSid not available\n");
win_skip("CreateWellKnownSid not available\n");
return;
}
size = 0;
SetLastError(0xdeadbeef);
ret = pCreateWellKnownSid(WinInteractiveSid, NULL, NULL, &size);
error = GetLastError();
ok(!ret, "CreateWellKnownSid succeeded\n");
ok(error == ERROR_INSUFFICIENT_BUFFER, "expected ERROR_INSUFFICIENT_BUFFER, got %u\n", error);
ok(size, "expected size > 0\n");
SetLastError(0xdeadbeef);
ret = pCreateWellKnownSid(WinInteractiveSid, NULL, NULL, &size);
error = GetLastError();
ok(!ret, "CreateWellKnownSid succeeded\n");
ok(error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", error);
sid = HeapAlloc(GetProcessHeap(), 0, size);
ret = pCreateWellKnownSid(WinInteractiveSid, NULL, sid, &size);
ok(ret, "CreateWellKnownSid failed %u\n", GetLastError());
HeapFree(GetProcessHeap(), 0, sid);
/* a domain sid usually have three subauthorities but we test that CreateWellKnownSid doesn't check it */
AllocateAndInitializeSid(&ident, 6, SECURITY_NT_NON_UNIQUE, 12, 23, 34, 45, 56, 0, 0, &domainsid);
@ -1410,8 +1476,8 @@ static void test_CreateWellKnownSid(void)
static void test_LookupAccountSid(void)
{
SID_IDENTIFIER_AUTHORITY SIDAuthNT = { SECURITY_NT_AUTHORITY };
CHAR accountA[MAX_PATH], domainA[MAX_PATH];
DWORD acc_sizeA, dom_sizeA;
CHAR accountA[MAX_PATH], domainA[MAX_PATH], usernameA[MAX_PATH];
DWORD acc_sizeA, dom_sizeA, user_sizeA;
DWORD real_acc_sizeA, real_dom_sizeA;
WCHAR accountW[MAX_PATH], domainW[MAX_PATH];
DWORD acc_sizeW, dom_sizeW;
@ -1419,10 +1485,12 @@ static void test_LookupAccountSid(void)
PSID pUsersSid = NULL;
SID_NAME_USE use;
BOOL ret;
DWORD size;
DWORD size,cbti = 0;
MAX_SID max_sid;
CHAR *str_sidA;
int i;
HANDLE hToken;
PTOKEN_USER ptiUser = NULL;
/* native windows crashes if account size, domain size, or name use is NULL */
@ -1581,6 +1649,26 @@ static void test_LookupAccountSid(void)
FreeSid(pUsersSid);
/* Test LookupAccountSid with Sid retrieved from token information.
This assumes this process is running under the account of the current user.*/
ret = OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY|TOKEN_DUPLICATE, &hToken);
ret = GetTokenInformation(hToken, TokenUser, NULL, 0, &cbti);
ptiUser = (PTOKEN_USER) HeapAlloc(GetProcessHeap(), 0, cbti);
if (GetTokenInformation(hToken, TokenUser, ptiUser, cbti, &cbti))
{
acc_sizeA = dom_sizeA = MAX_PATH;
ret = LookupAccountSidA(NULL, ptiUser->User.Sid, accountA, &acc_sizeA, domainA, &dom_sizeA, &use);
ok(ret, "LookupAccountSidA() Expected TRUE, got FALSE\n");
user_sizeA = MAX_PATH;
ret = GetUserNameA(usernameA , &user_sizeA);
ok(ret, "GetUserNameA() Expected TRUE, got FALSE\n");
todo_wine
{
ok(lstrcmpA(usernameA, accountA) == 0, "LookupAccountSidA() Expected account name: %s got: %s\n", usernameA, accountA );
}
}
HeapFree(GetProcessHeap(), 0, ptiUser);
if (pCreateWellKnownSid && pConvertSidToStringSidA)
{
trace("Well Known SIDs:\n");
@ -1684,7 +1772,7 @@ static void test_LookupAccountSid(void)
}
}
static void get_sid_info(PSID psid, LPSTR *user, LPSTR *dom)
static BOOL get_sid_info(PSID psid, LPSTR *user, LPSTR *dom)
{
static CHAR account[UNLEN + 1];
static CHAR domain[UNLEN + 1];
@ -1697,7 +1785,65 @@ static void get_sid_info(PSID psid, LPSTR *user, LPSTR *dom)
size = dom_size = UNLEN + 1;
account[0] = '\0';
domain[0] = '\0';
LookupAccountSidA(NULL, psid, account, &size, domain, &dom_size, &use);
SetLastError(0xdeadbeef);
return LookupAccountSidA(NULL, psid, account, &size, domain, &dom_size, &use);
}
static void check_wellknown_name(const char* name, WELL_KNOWN_SID_TYPE result)
{
SID_IDENTIFIER_AUTHORITY ident = { SECURITY_NT_AUTHORITY };
PSID domainsid;
char wk_sid[SECURITY_MAX_SID_SIZE];
DWORD cb;
DWORD sid_size, domain_size;
SID_NAME_USE sid_use;
LPSTR domain, account, sid_domain, wk_domain, wk_account;
PSID psid;
BOOL ret ,ret2;
sid_size = 0;
domain_size = 0;
ret = LookupAccountNameA(NULL, name, NULL, &sid_size, NULL, &domain_size, &sid_use);
psid = HeapAlloc(GetProcessHeap(),0,sid_size);
domain = HeapAlloc(GetProcessHeap(),0,domain_size);
ret = LookupAccountNameA(NULL, name, psid, &sid_size, domain, &domain_size, &sid_use);
if (!result)
{
ok(!ret, " %s Should have failed to lookup account name\n",name);
goto cleanup;
}
AllocateAndInitializeSid(&ident, 6, SECURITY_NT_NON_UNIQUE, 12, 23, 34, 45, 56, 0, 0, &domainsid);
cb = sizeof(wk_sid);
if (!pCreateWellKnownSid(result, domainsid, wk_sid, &cb))
{
win_skip("SID %i is not available on the system\n",result);
goto cleanup;
}
ret2 = get_sid_info(wk_sid, &wk_account, &wk_domain);
if (!ret2 && GetLastError() == ERROR_NONE_MAPPED)
{
win_skip("CreateWellKnownSid() succeeded but the account '%s' is not present (W2K)\n", name);
goto cleanup;
}
get_sid_info(psid, &account, &sid_domain);
ok(ret, "Failed to lookup account name %s\n",name);
ok(sid_size != 0, "sid_size was zero\n");
ok(EqualSid(psid,wk_sid),"(%s) Sids fail to match well known sid!\n",name);
ok(!lstrcmp(account, wk_account), "Expected %s , got %s\n", account, wk_account);
ok(!lstrcmp(domain, wk_domain), "Expected %s, got %s\n", wk_domain, domain);
ok(sid_use == SidTypeWellKnownGroup , "Expected Use (5), got %d\n", sid_use);
cleanup:
HeapFree(GetProcessHeap(),0,psid);
HeapFree(GetProcessHeap(),0,domain);
}
static void test_LookupAccountName(void)
@ -1737,7 +1883,7 @@ static void test_LookupAccountName(void)
ret = LookupAccountNameA(NULL, user_name, NULL, &sid_size, NULL, &domain_size, &sid_use);
if(!ret && (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED))
{
skip("LookupAccountNameA is not implemented\n");
win_skip("LookupAccountNameA is not implemented\n");
return;
}
ok(!ret, "Expected 0, got %d\n", ret);
@ -1884,6 +2030,7 @@ static void test_LookupAccountName(void)
domain_size = 0;
ret = LookupAccountNameA(NULL, computer_name, NULL, &sid_size, NULL, &domain_size, &sid_use);
ok(!ret && (GetLastError() == ERROR_INSUFFICIENT_BUFFER ||
GetLastError() == ERROR_NONE_MAPPED /* in a domain */ ||
broken(GetLastError() == ERROR_TRUSTED_DOMAIN_FAILURE) ||
broken(GetLastError() == ERROR_TRUSTED_RELATIONSHIP_FAILURE)),
"LookupAccountNameA failed: %d\n", GetLastError());
@ -1897,6 +2044,47 @@ static void test_LookupAccountName(void)
HeapFree(GetProcessHeap(), 0, domain);
HeapFree(GetProcessHeap(), 0, psid);
}
/* Well Known names */
if (!pCreateWellKnownSid)
{
win_skip("CreateWellKnownSid not available\n");
return;
}
if (PRIMARYLANGID(LANGIDFROMLCID(GetThreadLocale())) != LANG_ENGLISH)
{
skip("Non-english locale (skipping well known name creation tests)\n");
return;
}
check_wellknown_name("LocalService", WinLocalServiceSid);
check_wellknown_name("Local Service", WinLocalServiceSid);
/* 2 spaces */
check_wellknown_name("Local Service", 0);
check_wellknown_name("NetworkService", WinNetworkServiceSid);
check_wellknown_name("Network Service", WinNetworkServiceSid);
/* example of some names where the spaces are not optional */
check_wellknown_name("Terminal Server User", WinTerminalServerSid);
check_wellknown_name("TerminalServer User", 0);
check_wellknown_name("TerminalServerUser", 0);
check_wellknown_name("Terminal ServerUser", 0);
check_wellknown_name("enterprise domain controllers",WinEnterpriseControllersSid);
check_wellknown_name("enterprisedomain controllers", 0);
check_wellknown_name("enterprise domaincontrollers", 0);
check_wellknown_name("enterprisedomaincontrollers", 0);
/* case insensitivity */
check_wellknown_name("lOCAlServICE", WinLocalServiceSid);
/* fully qualified account names */
check_wellknown_name("NT AUTHORITY\\LocalService", WinLocalServiceSid);
check_wellknown_name("nt authority\\Network Service", WinNetworkServiceSid);
check_wellknown_name("nt authority test\\Network Service", 0);
check_wellknown_name("Dummy\\Network Service", 0);
check_wellknown_name("ntauthority\\Network Service", 0);
}
static void test_security_descriptor(void)
@ -1912,7 +2100,7 @@ static void test_security_descriptor(void)
ret = InitializeSecurityDescriptor(&sd, SECURITY_DESCRIPTOR_REVISION);
if (ret && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
{
skip("InitializeSecurityDescriptor is not implemented\n");
win_skip("InitializeSecurityDescriptor is not implemented\n");
return;
}
@ -2005,7 +2193,7 @@ static void test_process_security(void)
res = InitializeAcl(Acl, 256, ACL_REVISION);
if (!res && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
{
skip("ACLs not implemented - skipping tests\n");
win_skip("ACLs not implemented - skipping tests\n");
HeapFree(GetProcessHeap(), 0, Acl);
return;
}
@ -2183,14 +2371,14 @@ static void test_impersonation_level(void)
pDuplicateTokenEx = (fnDuplicateTokenEx) GetProcAddress(hmod, "DuplicateTokenEx");
if( !pDuplicateTokenEx ) {
skip("DuplicateTokenEx is not available\n");
win_skip("DuplicateTokenEx is not available\n");
return;
}
SetLastError(0xdeadbeef);
ret = ImpersonateSelf(SecurityAnonymous);
if(!ret && (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED))
{
skip("ImpersonateSelf is not implemented\n");
win_skip("ImpersonateSelf is not implemented\n");
return;
}
ok(ret, "ImpersonateSelf(SecurityAnonymous) failed with error %d\n", GetLastError());
@ -2408,7 +2596,7 @@ static void test_GetNamedSecurityInfoA(void)
if (!pGetNamedSecurityInfoA)
{
skip("GetNamedSecurityInfoA is not available\n");
win_skip("GetNamedSecurityInfoA is not available\n");
return;
}
@ -2421,7 +2609,7 @@ static void test_GetNamedSecurityInfoA(void)
NULL, NULL, NULL, NULL, &pSecDesc);
if (error != ERROR_SUCCESS && (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED))
{
skip("GetNamedSecurityInfoA is not implemented\n");
win_skip("GetNamedSecurityInfoA is not implemented\n");
return;
}
ok(!error, "GetNamedSecurityInfo failed with error %d\n", error);
@ -2449,7 +2637,7 @@ static void test_ConvertStringSecurityDescriptor(void)
if (!pConvertStringSecurityDescriptorToSecurityDescriptorA)
{
skip("ConvertStringSecurityDescriptorToSecurityDescriptor is not available\n");
win_skip("ConvertStringSecurityDescriptorToSecurityDescriptor is not available\n");
return;
}
@ -2600,12 +2788,12 @@ static void test_ConvertSecurityDescriptorToString(void)
if (!pConvertSecurityDescriptorToStringSecurityDescriptorA)
{
skip("ConvertSecurityDescriptorToStringSecurityDescriptor is not available\n");
win_skip("ConvertSecurityDescriptorToStringSecurityDescriptor is not available\n");
return;
}
if (!pCreateWellKnownSid)
{
skip("CreateWellKnownSid is not available\n");
win_skip("CreateWellKnownSid is not available\n");
return;
}
@ -2800,7 +2988,7 @@ static void test_PrivateObjectSecurity(void)
if (!pConvertStringSecurityDescriptorToSecurityDescriptorA)
{
skip("ConvertStringSecurityDescriptorToSecurityDescriptor is not available\n");
win_skip("ConvertStringSecurityDescriptorToSecurityDescriptor is not available\n");
return;
}
@ -2810,8 +2998,7 @@ static void test_PrivateObjectSecurity(void)
"D:(A;NP;GAGXGWGR;;;SU)(A;IOID;CCDC;;;SU)"
"(D;OICI;0xffffffff;;;S-1-5-21-93476-23408-4576)"
"S:(AU;OICINPIOIDSAFA;CCDCLCSWRPRC;;;SU)(AU;NPSA;0x12019f;;;SU)",
SDDL_REVISION_1, &sec, &dwDescSize), "Creating descriptor failed\n"); // FIXME: ConvertStringSecurityDescriptorToSecurityDescriptor fails and 'sec' isn't set
SDDL_REVISION_1, &sec, &dwDescSize), "Creating descriptor failed\n");
test_SetSecurityDescriptorControl(sec);
@ -2883,7 +3070,7 @@ static void test_acls(void)
ret = InitializeAcl(pAcl, sizeof(ACL) - 1, ACL_REVISION);
if (!ret && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
{
skip("InitializeAcl is not implemented\n");
win_skip("InitializeAcl is not implemented\n");
return;
}
@ -2976,7 +3163,6 @@ static void test_GetSecurityInfo(void)
/* If we don't ask for the security descriptor, Windows will still give us
the other stuff, leaving us no way to free it. */
dacl = NULL;
ret = pGetSecurityInfo(obj, SE_FILE_OBJECT,
OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION,
&owner, &group, &dacl, NULL, NULL);
@ -2984,11 +3170,7 @@ static void test_GetSecurityInfo(void)
ok(owner != NULL, "GetSecurityInfo\n");
ok(group != NULL, "GetSecurityInfo\n");
ok(dacl != NULL, "GetSecurityInfo\n");
if (dacl != NULL)
{
ok(IsValidAcl(dacl), "GetSecurityInfo\n");
}
CloseHandle(obj);
}

View file

@ -307,7 +307,8 @@ static void test_create_delete_svc(void)
svc_handle1 = CreateServiceA(scm_handle, servicename, NULL, GENERIC_ALL, SERVICE_WIN32_OWN_PROCESS | SERVICE_INTERACTIVE_PROCESS,
SERVICE_DISABLED, 0, pathname, NULL, NULL, NULL, account, password);
ok(!svc_handle1, "Expected failure\n");
ok(GetLastError() == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
ok(GetLastError() == ERROR_INVALID_PARAMETER || GetLastError() == ERROR_INVALID_SERVICE_ACCOUNT,
"Expected ERROR_INVALID_PARAMETER or ERROR_INVALID_SERVICE_ACCOUNT, got %d\n", GetLastError());
/* Illegal (start-type is not a mask and should only be one of the possibilities)
* Remark : 'OR'-ing them could result in a valid possibility (but doesn't make sense as
@ -1762,10 +1763,7 @@ static void test_sequence(void)
SetLastError(0xdeadbeef);
ret = QueryServiceConfigA(svc_handle, config, given, &needed);
ok(ret, "Expected success, got error %u\n", GetLastError());
todo_wine
{
ok(given == needed, "Expected the given (%d) and needed (%d) buffersizes to be equal\n", given, needed);
}
ok(config->lpBinaryPathName && config->lpLoadOrderGroup && config->lpDependencies && config->lpServiceStartName &&
config->lpDisplayName, "Expected all string struct members to be non-NULL\n");
ok(config->dwServiceType == (SERVICE_INTERACTIVE_PROCESS | SERVICE_WIN32_OWN_PROCESS),
@ -1829,7 +1827,7 @@ static void test_queryconfig2(void)
if(!pQueryServiceConfig2A)
{
skip("function QueryServiceConfig2A not present\n");
win_skip("function QueryServiceConfig2A not present\n");
return;
}
@ -1933,7 +1931,7 @@ static void test_queryconfig2(void)
if(!pChangeServiceConfig2A)
{
skip("function ChangeServiceConfig2A not present\n");
win_skip("function ChangeServiceConfig2A not present\n");
goto cleanup;
}
@ -1971,7 +1969,7 @@ static void test_queryconfig2(void)
if(!pQueryServiceConfig2W)
{
skip("function QueryServiceConfig2W not present\n");
win_skip("function QueryServiceConfig2W not present\n");
goto cleanup;
}
SetLastError(0xdeadbeef);
@ -2107,7 +2105,7 @@ START_TEST(service)
if (!scm_handle && (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED))
{
skip("OpenSCManagerA is not implemented, we are most likely on win9x\n");
win_skip("OpenSCManagerA is not implemented, we are most likely on win9x\n");
return;
}
CloseServiceHandle(scm_handle);

View file

@ -83,7 +83,7 @@ static BOOL init_function_pointers(void)
if (!pCloseINFEngine || !pDelNode || !pGetVersionFromFile ||
!pOpenINFEngine || !pSetPerUserSecValues || !pTranslateInfString)
{
skip("Needed functions are not available\n");
win_skip("Needed functions are not available\n");
FreeLibrary(hAdvPack);
return FALSE;
}
@ -272,6 +272,11 @@ static void translateinfstring_test(void)
buffer[0] = 0;
hr = pTranslateInfString(inf_file, "idontexist", "Options.NTx86",
"InstallDir", buffer, MAX_PATH, &dwSize, NULL);
if (hr == E_ACCESSDENIED)
{
skip("TranslateInfString is broken\n");
return;
}
ok(hr == S_OK, "Expected S_OK, got 0x%08x\n", (UINT)hr);
ok(!strcmp(buffer, TEST_STRING2), "Expected %s, got %s\n", TEST_STRING2, buffer);
ok(dwSize == 25, "Expected size 25, got %d\n", dwSize);
@ -328,7 +333,7 @@ static void translateinfstringex_test(void)
hr = pOpenINFEngine(inf_file, NULL, 0, &hinf, NULL);
if (hr == E_UNEXPECTED)
{
skip("Skipping tests on win9x because of brokenness\n");
win_skip("Skipping tests on win9x because of brokenness\n");
return;
}
@ -591,6 +596,11 @@ static void setperusersecvalues_test(void)
/* set initial values */
lstrcpy(peruser.szGUID, "guid");
hr = pSetPerUserSecValues(&peruser);
if (hr == E_FAIL)
{
skip("SetPerUserSecValues is broken\n");
return;
}
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
ok(OPEN_GUID_KEY(), "Expected guid key to exist\n");
ok(check_reg_str(guid, NULL, "displayname"), "Expected displayname\n");

View file

@ -133,8 +133,13 @@ static void test_AddDelBackupEntry(void)
/* create the INF file */
res = pAddDelBackupEntry("one\0two\0three\0", "c:\\", "basename", AADBE_ADD_ENTRY);
ok(res == S_OK, "Expected S_OK, got %d\n", res);
if (GetFileAttributes(path) != INVALID_FILE_ATTRIBUTES)
{
ok(check_ini_file_attr(path), "Expected ini file to be hidden\n");
ok(DeleteFileA(path), "Expected path to exist\n");
}
else
win_skip("Test file could not be created\n");
lstrcpyA(path, CURR_DIR);
lstrcatA(path, "\\backup\\basename.INI");

View file

@ -187,7 +187,7 @@ static void test_WM_LBUTTONDOWN(void)
pGetComboBoxInfo = (void*)GetProcAddress(GetModuleHandleA("user32.dll"), "GetComboBoxInfo");
if (!pGetComboBoxInfo){
skip("GetComboBoxInfo is not available\n");
win_skip("GetComboBoxInfo is not available\n");
return;
}
@ -314,7 +314,7 @@ static int init(void)
pInitCommonControlsEx = (void*)GetProcAddress(hComctl32, "InitCommonControlsEx");
if (!pInitCommonControlsEx)
{
skip("InitCommonControlsEx() is missing. Skipping the tests\n");
win_skip("InitCommonControlsEx() is missing. Skipping the tests\n");
return 0;
}
iccex.dwSize = sizeof(iccex);

View file

@ -10,6 +10,7 @@
<file>dpa.c</file>
<file>header.c</file>
<file>imagelist.c</file>
<file>ipaddress.c</file>
<file>listview.c</file>
<file>misc.c</file>
<file>monthcal.c</file>

View file

@ -140,7 +140,7 @@ struct subclass_info
static LRESULT WINAPI datetime_subclass_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
struct subclass_info *info = (struct subclass_info *)GetWindowLongPtrA(hwnd, GWLP_USERDATA);
static long defwndproc_counter = 0;
static LONG defwndproc_counter = 0;
LRESULT ret;
struct message msg;

View file

@ -373,7 +373,7 @@ static void test_dpa(void)
if(pDPA_EnumCallback)
{
nEnum = 0;
pDPA_EnumCallback(dpa2, CB_EnumFirstThree, (PVOID)dpa2);
pDPA_EnumCallback(dpa2, CB_EnumFirstThree, dpa2);
rc=CheckDPA(dpa2, 0x777456, &dw2);
ok(rc, "dw=0x%x\n", dw2);
ok(nEnum == 3, "nEnum=%d\n", nEnum);

View file

@ -404,7 +404,7 @@ struct subclass_info
static LRESULT WINAPI header_subclass_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
struct subclass_info *info = (struct subclass_info *)GetWindowLongPtrA(hwnd, GWLP_USERDATA);
static long defwndproc_counter = 0;
static LONG defwndproc_counter = 0;
LRESULT ret;
struct message msg;
@ -425,7 +425,7 @@ static LRESULT WINAPI header_subclass_proc(HWND hwnd, UINT message, WPARAM wPara
static LRESULT WINAPI parent_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static long defwndproc_counter = 0;
static LONG defwndproc_counter = 0;
LRESULT ret;
struct message msg;
@ -1159,10 +1159,10 @@ static void test_hdm_index_messages(HWND hParent)
flush_sequences(sequences, NUM_MSG_SEQUENCES);
iSize = SendMessage(hChild, HDM_GETITEMCOUNT, 0, (LPARAM) &hdItem);
retVal = SendMessage(hChild, HDM_SETORDERARRAY, (WPARAM) iSize , (LPARAM) (LPINT) lpiarray );
retVal = SendMessage(hChild, HDM_SETORDERARRAY, iSize, (LPARAM) lpiarray);
ok(retVal == TRUE, "Setting header items order should return TRUE, got %d\n", retVal);
retVal = SendMessage(hChild, HDM_GETORDERARRAY, (WPARAM) iSize, (LPARAM) (LPINT) lpiarrayReceived );
retVal = SendMessage(hChild, HDM_GETORDERARRAY, iSize, (LPARAM) lpiarrayReceived);
ok(retVal == TRUE, "Getting header items order should return TRUE, got %d\n", retVal);
ok_sequence(sequences, HEADER_SEQ_INDEX, orderArray_seq, "set_get_orderArray sequence testing", FALSE);

View file

@ -0,0 +1,90 @@
/* Unit test suite for IP Address control.
*
* Copyright 2009 Nikolay Sivov
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <windows.h>
#include <commctrl.h>
#include <assert.h>
#include "wine/test.h"
#define expect(expected, got) ok(expected == got, "expected %d, got %d\n", expected,got)
static HWND create_ipaddress_control (void)
{
HWND handle;
handle = CreateWindowEx(0, WC_IPADDRESS, NULL,
WS_BORDER|WS_VISIBLE, 0, 0, 0, 0,
NULL, NULL, NULL, NULL);
assert(handle);
return handle;
}
static void test_get_set_text(void)
{
HWND hwnd;
CHAR ip[16];
INT r;
hwnd = create_ipaddress_control();
/* check text just after creation */
r = GetWindowText(hwnd, ip, sizeof(ip)/sizeof(CHAR));
expect(7, r);
ok(strcmp(ip, "0.0.0.0") == 0, "Expected null IP address, got %s\n", ip);
SendMessage(hwnd, IPM_SETADDRESS, 0, MAKEIPADDRESS(127, 0, 0, 1));
r = GetWindowText(hwnd, ip, sizeof(ip)/sizeof(CHAR));
expect(9, r);
ok(strcmp(ip, "127.0.0.1") == 0, "Expected 127.0.0.1, got %s\n", ip);
DestroyWindow(hwnd);
}
static int init(void)
{
HMODULE hComctl32;
BOOL (WINAPI *pInitCommonControlsEx)(const INITCOMMONCONTROLSEX*);
INITCOMMONCONTROLSEX iccex;
hComctl32 = GetModuleHandleA("comctl32.dll");
pInitCommonControlsEx = (void*)GetProcAddress(hComctl32, "InitCommonControlsEx");
if (!pInitCommonControlsEx)
{
win_skip("InitCommonControlsEx() is missing.\n");
return 0;
}
iccex.dwSize = sizeof(iccex);
/* W2K and below need ICC_INTERNET_CLASSES for the IP Address Control */
iccex.dwICC = ICC_INTERNET_CLASSES;
pInitCommonControlsEx(&iccex);
return 1;
}
START_TEST(ipaddress)
{
if (!init())
return;
test_get_set_text();
}

File diff suppressed because it is too large Load diff

View file

@ -53,7 +53,8 @@ static const struct message create_parent_window_seq[] = {
{ WM_SHOWWINDOW, sent|wparam, 1 },
{ WM_WINDOWPOSCHANGING, sent|wparam, 0 },
{ WM_QUERYNEWPALETTE, sent|optional },
{ WM_WINDOWPOSCHANGING, sent|wparam, 0 },
{ WM_WINDOWPOSCHANGING, sent|wparam|optional, 0 },
{ WM_WINDOWPOSCHANGED, sent|optional },
{ WM_ACTIVATEAPP, sent|wparam, 1 },
{ WM_NCACTIVATE, sent|wparam, 1 },
{ WM_ACTIVATE, sent|wparam, 1 },
@ -377,7 +378,7 @@ static void test_monthcal(void)
static LRESULT WINAPI parent_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static long defwndproc_counter = 0;
static LONG defwndproc_counter = 0;
LRESULT ret;
struct message msg;
@ -447,7 +448,7 @@ static HWND create_parent_window(void)
assert(hwnd);
/* check for message sequences */
ok_sequence(sequences, PARENT_SEQ_INDEX, create_parent_window_seq, "create parent window", TRUE);
ok_sequence(sequences, PARENT_SEQ_INDEX, create_parent_window_seq, "create parent window", FALSE);
return hwnd;
}
@ -455,7 +456,7 @@ static HWND create_parent_window(void)
static LRESULT WINAPI monthcal_subclass_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
struct subclass_info *info = (struct subclass_info *)GetWindowLongPtrA(hwnd, GWLP_USERDATA);
static long defwndproc_counter = 0;
static LONG defwndproc_counter = 0;
LRESULT ret;
struct message msg;

View file

@ -512,7 +512,7 @@ static void dump_client(HWND hRebar)
RECT r;
BOOL notify;
GetWindowRect(hRebar, &r);
MapWindowPoints(HWND_DESKTOP, hMainWnd, (LPPOINT)&r, 2);
MapWindowPoints(HWND_DESKTOP, hMainWnd, &r, 2);
if (height_change_notify_rect.top != -1)
{
RECT rcClient;

View file

@ -40,6 +40,10 @@ static WNDPROC g_status_wndproc;
static RECT g_rcCreated;
static HWND g_hMainWnd;
static int g_wmsize_count = 0;
static DWORD g_ysize;
static DWORD g_dpisize;
static int g_wmdrawitm_ctr;
static WNDPROC g_wndproc_saved;
static HWND create_status_control(DWORD style, DWORD exstyle)
{
@ -78,7 +82,7 @@ static LRESULT WINAPI create_test_wndproc(HWND hwnd, UINT msg, WPARAM wParam, LP
return ret;
}
static void register_subclass()
static void register_subclass(void)
{
WNDCLASSEX cls;
@ -91,7 +95,7 @@ static void register_subclass()
ok(RegisterClassEx(&cls), "RegisterClassEx failed\n");
}
static void test_create()
static void test_create(void)
{
RECT rc;
HWND hwnd;
@ -113,10 +117,16 @@ static int CALLBACK check_height_font_enumproc(ENUMLOGFONTEX *enumlf, NEWTEXTMET
{
HWND hwndStatus = (HWND)lParam;
HDC hdc = GetDC(NULL);
static const int sizes[] = {8, 9, 10, 12, 16, 22, 28, 36, 48, 72};
int i;
static const int sizes[] = { 6, 7, 8, 9, 10, 11, 12, 13, 15, 16,
20, 22, 28, 36, 48, 72};
DWORD i;
DWORD y;
LPSTR facename = (CHAR *)enumlf->elfFullName;
/* on win9x, enumlf->elfFullName is only valid for truetype fonts */
if (type != TRUETYPE_FONTTYPE)
facename = enumlf->elfLogFont.lfFaceName;
trace("Font %s\n", enumlf->elfFullName);
for (i = 0; i < sizeof(sizes)/sizeof(sizes[0]); i++)
{
HFONT hFont;
@ -132,7 +142,11 @@ static int CALLBACK check_height_font_enumproc(ENUMLOGFONTEX *enumlf, NEWTEXTMET
GetClientRect(hwndStatus, &rcCtrl);
GetTextMetrics(hdc, &tm);
expect(max(tm.tmHeight + (tm.tmInternalLeading ? tm.tmInternalLeading : 2) + 4, 20), rcCtrl.bottom);
y = tm.tmHeight + (tm.tmInternalLeading ? tm.tmInternalLeading : 2) + 4;
ok( (rcCtrl.bottom == max(y, g_ysize)) || (rcCtrl.bottom == max(y, g_dpisize)),
"got %d (expected %d or %d) for %s #%d\n",
rcCtrl.bottom, max(y, g_ysize), max(y, g_dpisize), facename, sizes[i]);
SelectObject(hdc, hOldFont);
SendMessage(hwndStatus, WM_SETFONT, (WPARAM)hCtrlFont, TRUE);
@ -213,7 +227,19 @@ static void test_height(void)
ZeroMemory(&lf, sizeof(lf));
SendMessage(hwndStatus, SB_SETMINHEIGHT, 0, 0);
hdc = GetDC(NULL);
trace("dpi=%d\n", GetDeviceCaps(hdc, LOGPIXELSY));
/* used only for some fonts (tahoma as example) */
g_ysize = GetSystemMetrics(SM_CYSIZE) + 2;
if (g_ysize & 1) g_ysize--; /* The min height is always even */
g_dpisize = MulDiv(18, GetDeviceCaps(hdc, LOGPIXELSY), 96) + 2;
if (g_dpisize & 1) g_dpisize--; /* The min height is always even */
trace("dpi=%d (min height: %d or %d) SM_CYSIZE: %d\n",
GetDeviceCaps(hdc, LOGPIXELSY), g_ysize, g_dpisize,
GetSystemMetrics(SM_CYSIZE));
EnumFontFamiliesEx(hdc, &lf, (FONTENUMPROC)check_height_family_enumproc, (LPARAM)hwndStatus, 0);
ReleaseDC(NULL, hdc);
@ -232,6 +258,8 @@ static void test_status_control(void)
RECT rc;
CHAR charArray[20];
HICON hIcon;
char ch;
char chstr[10] = "Inval id";
hWndStatus = create_status_control(WS_VISIBLE, 0);
@ -281,7 +309,7 @@ static void test_status_control(void)
/* Test resetting text with different characters */
r = SendMessage(hWndStatus, SB_SETTEXT, 0, (LPARAM)"First@Again");
expect(TRUE,r);
r = SendMessage(hWndStatus, SB_SETTEXT, 1, (LPARAM)"InvalidChars\\7\7");
r = SendMessage(hWndStatus, SB_SETTEXT, 1, (LPARAM)"Invalid\tChars\\7\7");
expect(TRUE,r);
r = SendMessage(hWndStatus, SB_SETTEXT, 2, (LPARAM)"InvalidChars\\n\n");
expect(TRUE,r);
@ -292,20 +320,28 @@ static void test_status_control(void)
expect(11,LOWORD(r));
expect(0,HIWORD(r));
r = SendMessage(hWndStatus, SB_GETTEXT, 1, (LPARAM) charArray);
todo_wine
{
ok(strcmp(charArray,"InvalidChars\\7 ") == 0, "Expected InvalidChars\\7 , got %s\n", charArray);
}
expect(15,LOWORD(r));
ok(strcmp(charArray,"Invalid\tChars\\7 ") == 0, "Expected Invalid\tChars\\7 , got %s\n", charArray);
expect(16,LOWORD(r));
expect(0,HIWORD(r));
r = SendMessage(hWndStatus, SB_GETTEXT, 2, (LPARAM) charArray);
todo_wine
{
ok(strcmp(charArray,"InvalidChars\\n ") == 0, "Expected InvalidChars\\n , got %s\n", charArray);
}
expect(15,LOWORD(r));
expect(0,HIWORD(r));
/* test more nonprintable chars */
for(ch = 0x00; ch < 0x7F; ch++) {
chstr[5] = ch;
r = SendMessage(hWndStatus, SB_SETTEXT, 0, (LPARAM)chstr);
expect(TRUE,r);
r = SendMessage(hWndStatus, SB_GETTEXT, 0, (LPARAM)charArray);
/* substitution with single space */
if (ch > 0x00 && ch < 0x20 && ch != '\t')
chstr[5] = ' ';
ok(strcmp(charArray, chstr) == 0, "Expected %s, got %s\n", chstr, charArray);
}
/* Set background color */
r = SendMessage(hWndStatus, SB_SETBKCOLOR , 0, RGB(255,0,0));
ok(r == CLR_DEFAULT ||
@ -383,6 +419,53 @@ static void test_status_control(void)
DestroyWindow(hWndStatus);
}
static LRESULT WINAPI ownerdraw_test_wndproc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
LRESULT ret;
if (msg == WM_DRAWITEM)
g_wmdrawitm_ctr++;
ret = CallWindowProc(g_wndproc_saved, hwnd, msg, wParam, lParam);
return ret;
}
static void test_status_ownerdraw(void)
{
HWND hWndStatus;
int r;
const char* statustext = "STATUS TEXT";
LONG oldstyle;
/* subclass the main window and make sure it is visible */
g_wndproc_saved = (WNDPROC) SetWindowLongPtr( g_hMainWnd, GWLP_WNDPROC,
(LONG_PTR)ownerdraw_test_wndproc );
ok( g_wndproc_saved != 0, "failed to set the WndProc\n");
SetWindowPos( g_hMainWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE);
oldstyle = GetWindowLong( g_hMainWnd, GWL_STYLE);
SetWindowLong( g_hMainWnd, GWL_STYLE, oldstyle | WS_VISIBLE);
/* create a status child window */
ok((hWndStatus = CreateWindowA(SUBCLASS_NAME, "", WS_CHILD|WS_VISIBLE, 0, 0, 100, 100,
g_hMainWnd, NULL, NULL, 0)) != NULL, "CreateWindowA failed\n");
/* set text */
g_wmdrawitm_ctr = 0;
r = SendMessage(hWndStatus, SB_SETTEXT, 0, (LPARAM)statustext);
ok( r == TRUE, "Sendmessage returned %d, expected 1\n", r);
ok( 0 == g_wmdrawitm_ctr, "got %d drawitem messages expected none\n", g_wmdrawitm_ctr);
/* set same text, with ownerdraw flag */
g_wmdrawitm_ctr = 0;
r = SendMessage(hWndStatus, SB_SETTEXT, SBT_OWNERDRAW, (LPARAM)statustext);
ok( r == TRUE, "Sendmessage returned %d, expected 1\n", r);
ok( 1 == g_wmdrawitm_ctr, "got %d drawitem messages expected 1\n", g_wmdrawitm_ctr);
/* ;and again */
g_wmdrawitm_ctr = 0;
r = SendMessage(hWndStatus, SB_SETTEXT, SBT_OWNERDRAW, (LPARAM)statustext);
ok( r == TRUE, "Sendmessage returned %d, expected 1\n", r);
ok( 1 == g_wmdrawitm_ctr, "got %d drawitem messages expected 1\n", g_wmdrawitm_ctr);
/* clean up */
DestroyWindow(hWndStatus);
SetWindowLong( g_hMainWnd, GWL_STYLE, oldstyle);
SetWindowLongPtr( g_hMainWnd, GWLP_WNDPROC, (LONG_PTR)g_wndproc_saved );
}
START_TEST(status)
{
hinst = GetModuleHandleA(NULL);
@ -399,4 +482,5 @@ START_TEST(status)
test_status_control();
test_create();
test_height();
test_status_ownerdraw();
}

View file

@ -310,7 +310,7 @@ create_tabcontrol (DWORD style, DWORD mask)
static LRESULT WINAPI parentWindowProcess(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static long defwndproc_counter = 0;
static LONG defwndproc_counter = 0;
LRESULT ret;
struct message msg;
@ -378,7 +378,7 @@ struct subclass_info
static LRESULT WINAPI tabSubclassProcess(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
struct subclass_info *info = (struct subclass_info *)GetWindowLongPtrA(hwnd, GWLP_USERDATA);
static long defwndproc_counter = 0;
static LONG defwndproc_counter = 0;
LRESULT ret;
struct message msg;
@ -492,7 +492,7 @@ static HWND create_tooltip (HWND hTab, char toolTipText[])
ti.rect = rect;
/* Add toolinfo structure to the tooltip control */
SendMessage(hwndTT, TTM_ADDTOOL, 0, (LPARAM) (LPTOOLINFO) &ti);
SendMessage(hwndTT, TTM_ADDTOOL, 0, (LPARAM) &ti);
return hwndTT;
}
@ -727,6 +727,7 @@ static void test_getters_setters(HWND parent_wnd, INT nTabs)
{
INT selectionIndex;
INT focusIndex;
TCITEM tcItem;
flush_sequences(sequences, NUM_MSG_SEQUENCES);
@ -756,6 +757,15 @@ static void test_getters_setters(HWND parent_wnd, INT nTabs)
ok_sequence(sequences, TAB_SEQ_INDEX, getset_cur_sel_seq, "Getset curSel test sequence", FALSE);
ok_sequence(sequences, PARENT_SEQ_INDEX, empty_sequence, "Getset curSel test parent sequence", FALSE);
/* selected item should have TCIS_BUTTONPRESSED state
It doesn't depend on button state */
memset(&tcItem, 0, sizeof(TCITEM));
tcItem.mask = TCIF_STATE;
tcItem.dwStateMask = TCIS_BUTTONPRESSED;
selectionIndex = SendMessage(hTab, TCM_GETCURSEL, 0, 0);
SendMessage(hTab, TCM_GETITEM, selectionIndex, (LPARAM) &tcItem);
ok (tcItem.dwState & TCIS_BUTTONPRESSED, "Selected item should have TCIS_BUTTONPRESSED\n");
}
/* Testing ExtendedStyle */
@ -771,9 +781,7 @@ static void test_getters_setters(HWND parent_wnd, INT nTabs)
expect(extendedStyle, prevExtendedStyle);
extendedStyle = SendMessage(hTab, TCM_GETEXTENDEDSTYLE, 0, 0);
todo_wine{
expect(TCS_EX_FLATSEPARATORS, extendedStyle);
}
/* Testing Register Drop */
prevExtendedStyle = SendMessage(hTab, TCM_SETEXTENDEDSTYLE, 0, TCS_EX_REGISTERDROP);
@ -833,6 +841,29 @@ static void test_getters_setters(HWND parent_wnd, INT nTabs)
ok_sequence(sequences, TAB_SEQ_INDEX, getset_item_seq, "Getset item test sequence", FALSE);
ok_sequence(sequences, PARENT_SEQ_INDEX, empty_sequence, "Getset item test parent sequence", FALSE);
/* TCIS_BUTTONPRESSED doesn't depend on tab style */
memset(&tcItem, 0, sizeof(tcItem));
tcItem.mask = TCIF_STATE;
tcItem.dwStateMask = TCIS_BUTTONPRESSED;
tcItem.dwState = TCIS_BUTTONPRESSED;
ok ( SendMessage(hTab, TCM_SETITEM, 0, (LPARAM) &tcItem), "Setting new item failed.\n");
tcItem.dwState = 0;
ok ( SendMessage(hTab, TCM_GETITEM, 0, (LPARAM) &tcItem), "Getting item failed.\n");
ok (tcItem.dwState == TCIS_BUTTONPRESSED, "TCIS_BUTTONPRESSED should be set.\n");
/* next highlight item, test that dwStateMask actually masks */
tcItem.mask = TCIF_STATE;
tcItem.dwStateMask = TCIS_HIGHLIGHTED;
tcItem.dwState = TCIS_HIGHLIGHTED;
ok ( SendMessage(hTab, TCM_SETITEM, 0, (LPARAM) &tcItem), "Setting new item failed.\n");
tcItem.dwState = 0;
ok ( SendMessage(hTab, TCM_GETITEM, 0, (LPARAM) &tcItem), "Getting item failed.\n");
ok (tcItem.dwState == TCIS_HIGHLIGHTED, "TCIS_HIGHLIGHTED should be set.\n");
tcItem.mask = TCIF_STATE;
tcItem.dwStateMask = TCIS_BUTTONPRESSED;
tcItem.dwState = 0;
ok ( SendMessage(hTab, TCM_GETITEM, 0, (LPARAM) &tcItem), "Getting item failed.\n");
ok (tcItem.dwState == TCIS_BUTTONPRESSED, "TCIS_BUTTONPRESSED should be set.\n");
}
/* Testing GetSet ToolTip */
@ -984,6 +1015,69 @@ static void test_delete_focus(HWND parent_wnd)
DestroyWindow(hTab);
}
static void test_removeimage(HWND parent_wnd)
{
static const BYTE bits[32];
HWND hwTab;
INT i;
TCITEM item;
HICON hicon;
HIMAGELIST himl = ImageList_Create(16, 16, ILC_COLOR, 3, 4);
hicon = CreateIcon(NULL, 16, 16, 1, 1, bits, bits);
ImageList_AddIcon(himl, hicon);
ImageList_AddIcon(himl, hicon);
ImageList_AddIcon(himl, hicon);
hwTab = create_tabcontrol(TCS_FIXEDWIDTH, TCIF_TEXT|TCIF_IMAGE);
SendMessage(hwTab, TCM_SETIMAGELIST, 0, (LPARAM)himl);
memset(&item, 0, sizeof(TCITEM));
item.mask = TCIF_IMAGE;
for(i = 0; i < 3; i++) {
SendMessage(hwTab, TCM_GETITEM, i, (LPARAM)&item);
expect(i, item.iImage);
}
/* remove image middle image */
SendMessage(hwTab, TCM_REMOVEIMAGE, 1, 0);
expect(2, ImageList_GetImageCount(himl));
item.iImage = -1;
SendMessage(hwTab, TCM_GETITEM, 0, (LPARAM)&item);
expect(0, item.iImage);
item.iImage = 0;
SendMessage(hwTab, TCM_GETITEM, 1, (LPARAM)&item);
expect(-1, item.iImage);
item.iImage = 0;
SendMessage(hwTab, TCM_GETITEM, 2, (LPARAM)&item);
expect(1, item.iImage);
/* remove first image */
SendMessage(hwTab, TCM_REMOVEIMAGE, 0, 0);
expect(1, ImageList_GetImageCount(himl));
item.iImage = 0;
SendMessage(hwTab, TCM_GETITEM, 0, (LPARAM)&item);
expect(-1, item.iImage);
item.iImage = 0;
SendMessage(hwTab, TCM_GETITEM, 1, (LPARAM)&item);
expect(-1, item.iImage);
item.iImage = -1;
SendMessage(hwTab, TCM_GETITEM, 2, (LPARAM)&item);
expect(0, item.iImage);
/* remove the last one */
SendMessage(hwTab, TCM_REMOVEIMAGE, 0, 0);
expect(0, ImageList_GetImageCount(himl));
for(i = 0; i < 3; i++) {
item.iImage = 0;
SendMessage(hwTab, TCM_GETITEM, i, (LPARAM)&item);
expect(-1, item.iImage);
}
DestroyWindow(hwTab);
ImageList_Destroy(himl);
DestroyIcon(hicon);
}
START_TEST(tab)
{
HWND parent_wnd;
@ -1021,6 +1115,7 @@ START_TEST(tab)
test_insert_focus(parent_wnd);
test_delete_focus(parent_wnd);
test_removeimage(parent_wnd);
DestroyWindow(parent_wnd);
}

View file

@ -27,6 +27,7 @@ extern void func_tooltips(void);
extern void func_trackbar(void);
extern void func_treeview(void);
extern void func_updown(void);
extern void func_ipaddress(void);
const struct test winetest_testlist[] =
{
@ -51,5 +52,6 @@ const struct test winetest_testlist[] =
{ "trackbar", func_trackbar },
{ "treeview", func_treeview },
{ "updown", func_updown },
{ "ipaddress", func_ipaddress },
{ 0, 0 }
};

View file

@ -777,7 +777,7 @@ static TBBUTTON buttons3[] = {
static void test_sizes(void)
{
HWND hToolbar = NULL;
HIMAGELIST himl;
HIMAGELIST himl, himl2;
TBBUTTONINFO tbinfo;
int style;
int i;
@ -928,9 +928,13 @@ static void test_sizes(void)
ok(SendMessageA(hToolbar, TB_GETBUTTONSIZE, 0, 0) == MAKELONG(100, 21), "Unexpected button size\n");
SendMessageA(hToolbar, TB_SETBUTTONSIZE, 0, MAKELONG(100, 100));
ok(SendMessageA(hToolbar, TB_GETBUTTONSIZE, 0, 0) == MAKELONG(100, 100), "Unexpected button size\n");
/* But there are no update when we change imagelist, and image sizes are the same */
himl2 = ImageList_LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_BITMAP_128x15), 20, 2, CLR_NONE, IMAGE_BITMAP, LR_DEFAULTCOLOR);
ok(SendMessageA(hToolbar, TB_SETIMAGELIST, 0, (LRESULT)himl2) == (LRESULT)himl, "TB_SETIMAGELIST failed\n");
ok(SendMessageA(hToolbar, TB_GETBUTTONSIZE, 0, 0) == MAKELONG(100, 100), "Unexpected button size\n");
SendMessageA(hToolbar, TB_SETBUTTONSIZE, 0, MAKELONG(1, 1));
ok(SendMessageA(hToolbar, TB_GETBUTTONSIZE, 0, 0) == MAKELONG(27, 21), "Unexpected button size\n");
ok(SendMessageA(hToolbar, TB_SETIMAGELIST, 0, 0) == (LRESULT)himl, "TB_SETIMAGELIST failed\n");
ok(SendMessageA(hToolbar, TB_SETIMAGELIST, 0, 0) == (LRESULT)himl2, "TB_SETIMAGELIST failed\n");
ok(SendMessageA(hToolbar, TB_GETBUTTONSIZE, 0, 0) == MAKELONG(27, 7), "Unexpected button size\n");
SendMessageA(hToolbar, TB_SETBUTTONSIZE, 0, MAKELONG(1, 1));
ok(SendMessageA(hToolbar, TB_GETBUTTONSIZE, 0, 0) == MAKELONG(8, 7), "Unexpected button size\n");
@ -999,6 +1003,108 @@ static void test_sizes(void)
DestroyWindow(hToolbar);
}
/* Toolbar control has two ways of reacting to a change. We call them a
* relayout and recalc. A recalc forces a recompute of values like button size
* and top margin (the latter in comctl32 <v6), while a relayout uses the cached
* values. This functions creates a flat toolbar with a top margin of a non-flat
* toolbar. We will notice a recalc, as it will recompte the top margin and
* change it to zero*/
static void prepare_recalc_test(HWND *phToolbar)
{
RECT rect;
rebuild_toolbar_with_buttons(phToolbar);
SetWindowLong(*phToolbar, GWL_STYLE,
GetWindowLong(*phToolbar, GWL_STYLE) | TBSTYLE_FLAT);
SendMessage(*phToolbar, TB_GETITEMRECT, 1, (LPARAM)&rect);
ok(rect.top == 2, "Test will make no sense because initial top is %d instead of 2\n",
rect.top);
}
static BOOL did_recalc(HWND hToolbar)
{
RECT rect;
SendMessage(hToolbar, TB_GETITEMRECT, 1, (LPARAM)&rect);
ok(rect.top == 2 || rect.top == 0, "Unexpected top margin %d in recalc test\n",
rect.top);
return (rect.top == 0);
}
/* call after a recalc did happen to return to an unstable state */
static void restore_recalc_state(HWND hToolbar)
{
RECT rect;
/* return to style with a 2px top margin */
SetWindowLong(hToolbar, GWL_STYLE,
GetWindowLong(hToolbar, GWL_STYLE) & ~TBSTYLE_FLAT);
/* recalc */
SendMessage(hToolbar, TB_ADDBUTTONS, 1, (LPARAM)&buttons3[3]);
/* top margin will be 0px if a recalc occurs */
SetWindowLong(hToolbar, GWL_STYLE,
GetWindowLong(hToolbar, GWL_STYLE) | TBSTYLE_FLAT);
/* safety check */
SendMessage(hToolbar, TB_GETITEMRECT, 1, (LPARAM)&rect);
ok(rect.top == 2, "Test will make no sense because initial top is %d instead of 2\n",
rect.top);
}
static void test_recalc(void)
{
HWND hToolbar;
TBBUTTONINFO bi;
CHAR test[] = "Test";
const int EX_STYLES_COUNT = 5;
int i;
/* Like TB_ADDBUTTONS tested in test_sized, inserting a button without text
* results in a relayout, while adding one with text forces a recalc */
prepare_recalc_test(&hToolbar);
SendMessage(hToolbar, TB_INSERTBUTTON, 1, (LPARAM)&buttons3[0]);
ok(!did_recalc(hToolbar), "Unexpected recalc - adding button without text\n");
prepare_recalc_test(&hToolbar);
SendMessage(hToolbar, TB_INSERTBUTTON, 1, (LPARAM)&buttons3[3]);
ok(did_recalc(hToolbar), "Expected a recalc - adding button with text\n");
/* TB_SETBUTTONINFO, even when adding a text, results only in a relayout */
prepare_recalc_test(&hToolbar);
bi.cbSize = sizeof(bi);
bi.dwMask = TBIF_TEXT;
bi.pszText = test;
SendMessage(hToolbar, TB_SETBUTTONINFO, 1, (LPARAM)&bi);
ok(!did_recalc(hToolbar), "Unexpected recalc - setting a button text\n");
/* most extended styled doesn't force a recalc (testing all the bits gives
* the same results, but prints some ERRs while testing) */
for (i = 0; i < EX_STYLES_COUNT; i++)
{
if (i == 1 || i == 3) /* an undoc style and TBSTYLE_EX_MIXEDBUTTONS */
continue;
prepare_recalc_test(&hToolbar);
expect(0, (int)SendMessage(hToolbar, TB_GETEXTENDEDSTYLE, 0, 0));
SendMessage(hToolbar, TB_SETEXTENDEDSTYLE, 0, (1 << i));
ok(!did_recalc(hToolbar), "Unexpected recalc - setting bit %d\n", i);
SendMessage(hToolbar, TB_SETEXTENDEDSTYLE, 0, 0);
ok(!did_recalc(hToolbar), "Unexpected recalc - clearing bit %d\n", i);
expect(0, (int)SendMessage(hToolbar, TB_GETEXTENDEDSTYLE, 0, 0));
}
/* TBSTYLE_EX_MIXEDBUTTONS does a recalc on change */
prepare_recalc_test(&hToolbar);
SendMessage(hToolbar, TB_SETEXTENDEDSTYLE, 0, TBSTYLE_EX_MIXEDBUTTONS);
ok(did_recalc(hToolbar), "Expected a recalc - setting TBSTYLE_EX_MIXEDBUTTONS\n");
restore_recalc_state(hToolbar);
SendMessage(hToolbar, TB_SETEXTENDEDSTYLE, 0, TBSTYLE_EX_MIXEDBUTTONS);
ok(!did_recalc(hToolbar), "Unexpected recalc - setting TBSTYLE_EX_MIXEDBUTTONS again\n");
restore_recalc_state(hToolbar);
SendMessage(hToolbar, TB_SETEXTENDEDSTYLE, 0, 0);
ok(did_recalc(hToolbar), "Expected a recalc - clearing TBSTYLE_EX_MIXEDBUTTONS\n");
/* undocumented exstyle 0x2 seems to changes the top margin, what
* interferes with these tests */
DestroyWindow(hToolbar);
}
static void test_getbuttoninfo(void)
{
HWND hToolbar = NULL;
@ -1224,6 +1330,7 @@ START_TEST(toolbar)
test_add_string();
test_hotitem();
test_sizes();
test_recalc();
test_getbuttoninfo();
test_createtoolbarex();
test_dispinfo();

View file

@ -291,11 +291,14 @@ static void test_gettext(void)
r = SendMessageW(hwnd, TTM_ADDTOOL, 0, (LPARAM)&toolinfoW);
ok(r, "Adding the tool to the tooltip failed\n");
if (0) /* crashes on NT4 */
{
toolinfoW.hwnd = NULL;
toolinfoW.uId = 0x1234ABCD;
toolinfoW.lpszText = bufW;
SendMessageW(hwnd, TTM_GETTEXTW, 0, (LPARAM)&toolinfoW);
ok(toolinfoW.lpszText[0] == 0, "lpszText should be an empty string\n");
}
DestroyWindow(hwnd);
}

View file

@ -392,7 +392,7 @@ struct subclass_info
};
static LRESULT WINAPI parent_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam){
static long defwndproc_counter = 0;
static LONG defwndproc_counter = 0;
LRESULT ret;
struct message msg;
@ -453,7 +453,7 @@ static HWND create_parent_window(void){
static LRESULT WINAPI trackbar_subclass_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam){
struct subclass_info *info = (struct subclass_info *) GetWindowLongPtrA(hwnd, GWLP_USERDATA);
static long defwndproc_counter = 0;
static LONG defwndproc_counter = 0;
LRESULT ret;
struct message msg;
@ -511,7 +511,7 @@ static void test_trackbar_buddy(HWND hWndTrackbar){
flush_sequences(sequences, NUM_MSG_SEQUENCE);
hWndLeftBuddy = (HWND) CreateWindowEx(0, STATUSCLASSNAME, NULL, 0,
hWndLeftBuddy = CreateWindowEx(0, STATUSCLASSNAME, NULL, 0,
0,0,300,20, NULL, NULL, NULL, NULL);
ok(hWndLeftBuddy != NULL, "Expected non NULL value\n");
@ -524,7 +524,7 @@ static void test_trackbar_buddy(HWND hWndTrackbar){
} else
skip ("left buddy control not present?\n");
hWndRightBuddy = (HWND) CreateWindowEx(0, STATUSCLASSNAME, NULL, 0,
hWndRightBuddy = CreateWindowEx(0, STATUSCLASSNAME, NULL, 0,
0,0,300,20,NULL,NULL, NULL, NULL);
ok(hWndRightBuddy != NULL, "expected non NULL value\n");
@ -588,12 +588,26 @@ static void test_page_size(HWND hWndTrackbar){
/* test TBM_GETPAGESIZE */
r = SendMessage(hWndTrackbar, TBM_GETPAGESIZE, 0,0);
todo_wine{
expect(20, r);
}
ok_sequence(sequences, TRACKBAR_SEQ_INDEX, page_size_test_seq, "page size test sequence", FALSE);
ok_sequence(sequences, PARENT_SEQ_INDEX, parent_empty_test_seq, "parent page size test sequence", FALSE);
/* check for zero page size */
r = SendMessage(hWndTrackbar, TBM_SETPAGESIZE, 0, 0);
expect(20, r);
r = SendMessage(hWndTrackbar, TBM_GETPAGESIZE, 0, 0);
expect(0, r);
/* revert to default */
r = SendMessage(hWndTrackbar, TBM_SETPAGESIZE, 0, -1);
expect(0, r);
r = SendMessage(hWndTrackbar, TBM_GETPAGESIZE, 0, 0);
expect(20, r);
/* < -1 */
r = SendMessage(hWndTrackbar, TBM_SETPAGESIZE, 0, -2);
expect(20, r);
r = SendMessage(hWndTrackbar, TBM_GETPAGESIZE, 0, 0);
expect(-2, r);
}
static void test_position(HWND hWndTrackbar){

View file

@ -32,6 +32,8 @@
#include "wine/test.h"
#include "msg.h"
const char *TEST_CALLBACK_TEXT = "callback_text";
#define NUM_MSG_SEQUENCES 1
#define LISTVIEW_SEQ_INDEX 0
@ -264,6 +266,64 @@ static void FillRoot(void)
ok(!strcmp(sequence, "AB."), "Item creation\n");
}
static void TestCallback(void)
{
HTREEITEM hRoot;
HTREEITEM hItem1, hItem2;
TVINSERTSTRUCTA ins;
TVITEM tvi;
CHAR test_string[] = "Test_string";
CHAR buf[128];
LRESULT ret;
TreeView_DeleteAllItems(hTree);
ins.hParent = TVI_ROOT;
ins.hInsertAfter = TVI_ROOT;
U(ins).item.mask = TVIF_TEXT;
U(ins).item.pszText = LPSTR_TEXTCALLBACK;
hRoot = TreeView_InsertItem(hTree, &ins);
assert(hRoot);
tvi.hItem = hRoot;
tvi.mask = TVIF_TEXT;
tvi.pszText = buf;
tvi.cchTextMax = sizeof(buf)/sizeof(buf[0]);
ret = TreeView_GetItem(hTree, &tvi);
ok(ret == 1, "ret\n");
ok(strcmp(tvi.pszText, TEST_CALLBACK_TEXT) == 0, "Callback item text mismatch %s vs %s\n",
tvi.pszText, TEST_CALLBACK_TEXT);
ins.hParent = hRoot;
ins.hInsertAfter = TVI_FIRST;
U(ins).item.mask = TVIF_TEXT;
U(ins).item.pszText = test_string;
hItem1 = TreeView_InsertItem(hTree, &ins);
assert(hItem1);
tvi.hItem = hItem1;
TreeView_GetItem(hTree, &tvi);
ok(strcmp(tvi.pszText, test_string) == 0, "Item text mismatch %s vs %s\n",
tvi.pszText, test_string);
/* undocumented: pszText of NULL also means LPSTR_CALLBACK: */
tvi.pszText = NULL;
ret = TreeView_SetItem(hTree, &tvi);
ok(ret == 1, "Expected SetItem return 1, got %ld\n", ret);
tvi.pszText = buf;
TreeView_GetItem(hTree, &tvi);
ok(strcmp(tvi.pszText, TEST_CALLBACK_TEXT) == 0, "Item text mismatch %s vs %s\n",
tvi.pszText, TEST_CALLBACK_TEXT);
U(ins).item.pszText = NULL;
hItem2 = TreeView_InsertItem(hTree, &ins);
assert(hItem2);
tvi.hItem = hItem2;
memset(buf, 0, sizeof(buf));
TreeView_GetItem(hTree, &tvi);
ok(strcmp(tvi.pszText, TEST_CALLBACK_TEXT) == 0, "Item text mismatch %s vs %s\n",
tvi.pszText, TEST_CALLBACK_TEXT);
}
static void DoTest1(void)
{
BOOL r;
@ -367,11 +427,9 @@ static void TestGetSetBkColor(void)
{
COLORREF crColor = RGB(0,0,0);
todo_wine{
/* If the value is -1, the control is using the system color for the background color. */
crColor = (COLORREF)SendMessage( hTree, TVM_GETBKCOLOR, 0, 0 );
ok(crColor == -1, "Default background color reported as 0x%.8x\n", crColor);
}
/* Test for black background */
SendMessage( hTree, TVM_SETBKCOLOR, 0, (LPARAM)RGB(0,0,0) );
@ -607,7 +665,7 @@ static void TestGetSet(void)
/* This function hooks in and records all messages to the treeview control */
static LRESULT WINAPI TreeviewWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static long defwndproc_counter = 0;
static LONG defwndproc_counter = 0;
LRESULT ret;
struct message msg;
WNDPROC lpOldProc = (WNDPROC)GetWindowLongPtrA(hwnd, GWLP_USERDATA);
@ -664,6 +722,13 @@ static LRESULT CALLBACK MyWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPa
IdentifyItem(pTreeView->itemOld.hItem);
IdentifyItem(pTreeView->itemNew.hItem);
return 0;
case TVN_GETDISPINFOA: {
NMTVDISPINFOA *disp = (NMTVDISPINFOA *)lParam;
if (disp->item.mask & TVIF_TEXT) {
lstrcpyn(disp->item.pszText, TEST_CALLBACK_TEXT, disp->item.cchTextMax);
}
return 0;
}
}
}
return 0;
@ -683,6 +748,76 @@ static LRESULT CALLBACK MyWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPa
return 0L;
}
static void TestExpandInvisible(void)
{
static CHAR nodeText[][5] = {"0", "1", "2", "3", "4"};
TVINSERTSTRUCTA ins;
HTREEITEM node[5];
RECT dummyRect;
BOOL nodeVisible;
/* The test builds the following tree and expands then node 1, while node 0 is collapsed.
*
* 0
* |- 1
* | |- 2
* | |- 3
* |- 4
*
*/
TreeView_DeleteAllItems(hTree);
ins.hParent = TVI_ROOT;
ins.hInsertAfter = TVI_ROOT;
U(ins).item.mask = TVIF_TEXT;
U(ins).item.pszText = nodeText[0];
node[0] = TreeView_InsertItem(hTree, &ins);
assert(node[0]);
ins.hInsertAfter = TVI_LAST;
U(ins).item.mask = TVIF_TEXT;
ins.hParent = node[0];
U(ins).item.pszText = nodeText[1];
node[1] = TreeView_InsertItem(hTree, &ins);
assert(node[1]);
U(ins).item.pszText = nodeText[4];
node[4] = TreeView_InsertItem(hTree, &ins);
assert(node[4]);
ins.hParent = node[1];
U(ins).item.pszText = nodeText[2];
node[2] = TreeView_InsertItem(hTree, &ins);
assert(node[2]);
U(ins).item.pszText = nodeText[3];
node[3] = TreeView_InsertItem(hTree, &ins);
assert(node[3]);
nodeVisible = TreeView_GetItemRect(hTree, node[1], &dummyRect, FALSE);
ok(!nodeVisible, "Node 1 should not be visible.\n");
nodeVisible = TreeView_GetItemRect(hTree, node[2], &dummyRect, FALSE);
ok(!nodeVisible, "Node 2 should not be visible.\n");
nodeVisible = TreeView_GetItemRect(hTree, node[3], &dummyRect, FALSE);
ok(!nodeVisible, "Node 3 should not be visible.\n");
nodeVisible = TreeView_GetItemRect(hTree, node[4], &dummyRect, FALSE);
ok(!nodeVisible, "Node 4 should not be visible.\n");
ok(TreeView_Expand(hTree, node[1], TVE_EXPAND), "Expand of node 1 failed.\n");
nodeVisible = TreeView_GetItemRect(hTree, node[1], &dummyRect, FALSE);
ok(!nodeVisible, "Node 1 should not be visible.\n");
nodeVisible = TreeView_GetItemRect(hTree, node[2], &dummyRect, FALSE);
ok(!nodeVisible, "Node 2 should not be visible.\n");
nodeVisible = TreeView_GetItemRect(hTree, node[3], &dummyRect, FALSE);
ok(!nodeVisible, "Node 3 should not be visible.\n");
nodeVisible = TreeView_GetItemRect(hTree, node[4], &dummyRect, FALSE);
ok(!nodeVisible, "Node 4 should not be visible.\n");
}
START_TEST(treeview)
{
HMODULE hComctl32;
@ -746,6 +881,12 @@ START_TEST(treeview)
/* Sequences tested inside due to number */
TestGetSet();
/* Clears all the previous items */
TestCallback();
/* Clears all the previous items */
TestExpandInvisible();
PostMessageA(hMainWnd, WM_CLOSE, 0, 0);
while(GetMessageA(&msg,0,0,0)) {
TranslateMessage(&msg);

View file

@ -193,7 +193,7 @@ static const struct message test_updown_destroy_seq[] = {
static LRESULT WINAPI parent_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static long defwndproc_counter = 0;
static LONG defwndproc_counter = 0;
LRESULT ret;
struct message msg;
@ -262,7 +262,7 @@ struct subclass_info
static LRESULT WINAPI edit_subclass_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
struct subclass_info *info = (struct subclass_info *)GetWindowLongPtrA(hwnd, GWLP_USERDATA);
static long defwndproc_counter = 0;
static LONG defwndproc_counter = 0;
LRESULT ret;
struct message msg;
@ -310,7 +310,7 @@ static HWND create_edit_control(void)
static LRESULT WINAPI updown_subclass_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
struct subclass_info *info = (struct subclass_info *)GetWindowLongPtrA(hwnd, GWLP_USERDATA);
static long defwndproc_counter = 0;
static LONG defwndproc_counter = 0;
LRESULT ret;
struct message msg;

View file

@ -29,7 +29,7 @@
/* ##### */
static UINT CALLBACK OFNHookProc( HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
static UINT_PTR CALLBACK OFNHookProc( HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
LPNMHDR nmh;
@ -111,7 +111,7 @@ static void test_DialogCancel(void)
SetLastError(0xdeadbeef);
result = GetOpenFileNameW((LPOPENFILENAMEW) &ofn);
if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
skip("GetOpenFileNameW is not implemented\n");
win_skip("GetOpenFileNameW is not implemented\n");
else
{
ok(0 == result, "expected %d, got %d\n", 0, result);
@ -124,7 +124,7 @@ static void test_DialogCancel(void)
SetLastError(0xdeadbeef);
result = GetSaveFileNameW((LPOPENFILENAMEW) &ofn);
if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
skip("GetSaveFileNameW is not implemented\n");
win_skip("GetSaveFileNameW is not implemented\n");
else
{
ok(0 == result, "expected %d, got %d\n", 0, result);
@ -135,7 +135,7 @@ static void test_DialogCancel(void)
}
}
static UINT CALLBACK create_view_window2_hook(HWND dlg, UINT msg, WPARAM wParam, LPARAM lParam)
static UINT_PTR CALLBACK create_view_window2_hook(HWND dlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
if (msg == WM_NOTIFY)
{
@ -156,7 +156,7 @@ static UINT CALLBACK create_view_window2_hook(HWND dlg, UINT msg, WPARAM wParam,
hr = IShellView_QueryInterface(shell_view, &IID_IShellView2, (void **)&shell_view2);
if (hr == E_NOINTERFACE)
{
skip("IShellView2 not supported\n");
win_skip("IShellView2 not supported\n");
goto cleanup;
}
ok(SUCCEEDED(hr), "QueryInterface returned %#x\n", hr);

View file

@ -298,6 +298,7 @@ static void test_abort_proc(void)
DOCINFOA doc_info = {0};
PRINTDLGA pd = {0};
char filename[MAX_PATH];
int job_id;
if (!GetTempFileNameA(".", "prn", 0, filename))
{
@ -333,7 +334,18 @@ static void test_abort_proc(void)
doc_info.lpszDocName = "Some document";
doc_info.lpszOutput = filename;
ok(StartDocA(print_dc, &doc_info) > 0, "StartDocA failed\n");
job_id = StartDocA(print_dc, &doc_info);
ok(job_id > 0 ||
GetLastError() == ERROR_SPL_NO_STARTDOC, /* Vista can fail with this error when using the XPS driver */
"StartDocA failed ret %d gle %d\n", job_id, GetLastError());
if(job_id <= 0)
{
skip("StartDoc failed\n");
goto end;
}
ok(abort_proc_called, "AbortProc didn't get called by StartDoc.\n");
abort_proc_called = FALSE;
@ -357,6 +369,7 @@ static void test_abort_proc(void)
ok(!abort_proc_called, "AbortProc got called unexpectedly by DeleteDC.\n");
abort_proc_called = FALSE;
end:
ok(DeleteFileA(filename), "Failed to delete temporary file\n");
}
@ -374,7 +387,7 @@ START_TEST(printdlg)
/* PrintDlgEx not present before w2k */
if (ptr) {
skip("%s\n", ptr);
win_skip("%s\n", ptr);
return;
}

View file

@ -1184,9 +1184,10 @@ static void checkElementStatus(const CERT_TRUST_STATUS *expected,
ok(got->dwErrorStatus == expected->dwErrorStatus ||
broken((got->dwErrorStatus & ~ignore->dwErrorStatus) ==
(expected->dwErrorStatus & ~ignore->dwErrorStatus)),
"Chain %d, element [%d,%d]: expected error %08x, got %08x\n",
"Chain %d, element [%d,%d]: expected error %08x, got %08x. %08x is "
"expected if no valid Verisign root certificate is available.\n",
testIndex, chainIndex, elementIndex, expected->dwErrorStatus,
got->dwErrorStatus);
got->dwErrorStatus, CERT_TRUST_IS_UNTRUSTED_ROOT);
if (got->dwInfoStatus == expected->dwInfoStatus)
ok(got->dwInfoStatus == expected->dwInfoStatus,
"Chain %d, element [%d,%d]: expected info %08x, got %08x\n",
@ -1264,9 +1265,10 @@ static void checkChainStatus(PCCERT_CHAIN_CONTEXT chain,
~chainStatus->statusToIgnore.dwErrorStatus) ==
(chainStatus->status.dwErrorStatus &
~chainStatus->statusToIgnore.dwErrorStatus)),
"Chain %d: expected error %08x, got %08x\n",
"Chain %d: expected error %08x, got %08x. %08x is expected if no valid "
"Verisign root certificate is available.\n",
testIndex, chainStatus->status.dwErrorStatus,
chain->TrustStatus.dwErrorStatus);
chain->TrustStatus.dwErrorStatus, CERT_TRUST_IS_UNTRUSTED_ROOT);
if (todo & TODO_INFO &&
chain->TrustStatus.dwInfoStatus != chainStatus->status.dwInfoStatus)
todo_wine ok(chain->TrustStatus.dwInfoStatus ==

View file

@ -29,7 +29,8 @@
#include "wine/test.h"
static BOOL have_nt;
static BOOL have_nt = TRUE;
static BOOL old_crypt32 = FALSE;
static char oid_rsa_md5[] = szOID_RSA_MD5;
static BOOL (WINAPI * pCryptAcquireContextA)
@ -196,7 +197,7 @@ static void test_msg_get_param(void)
ret = CryptMsgGetParam(msg, CMSG_TYPE_PARAM, 0, &value, &size);
ok(ret, "CryptMsgGetParam failed: %x\n", GetLastError());
ok(value == CMSG_DATA, "Expected CMSG_DATA, got %d\n", value);
for (i = CMSG_CONTENT_PARAM; have_nt && (i <= CMSG_CMS_SIGNER_INFO_PARAM); i++)
for (i = CMSG_CONTENT_PARAM; !old_crypt32 && (i <= CMSG_CMS_SIGNER_INFO_PARAM); i++)
{
size = 0;
ret = CryptMsgGetParam(msg, i, 0, NULL, &size);
@ -211,7 +212,7 @@ static void test_msg_get_param(void)
ret = CryptMsgGetParam(msg, CMSG_TYPE_PARAM, 0, &value, &size);
ok(ret, "CryptMsgGetParam failed: %x\n", GetLastError());
ok(value == CMSG_ENVELOPED, "Expected CMSG_ENVELOPED, got %d\n", value);
for (i = CMSG_CONTENT_PARAM; have_nt && (i <= CMSG_CMS_SIGNER_INFO_PARAM); i++)
for (i = CMSG_CONTENT_PARAM; !old_crypt32 && (i <= CMSG_CMS_SIGNER_INFO_PARAM); i++)
{
size = 0;
ret = CryptMsgGetParam(msg, i, 0, NULL, &size);
@ -226,7 +227,7 @@ static void test_msg_get_param(void)
ret = CryptMsgGetParam(msg, CMSG_TYPE_PARAM, 0, &value, &size);
ok(ret, "CryptMsgGetParam failed: %x\n", GetLastError());
ok(value == CMSG_HASHED, "Expected CMSG_HASHED, got %d\n", value);
for (i = CMSG_CONTENT_PARAM; have_nt && (i <= CMSG_CMS_SIGNER_INFO_PARAM); i++)
for (i = CMSG_CONTENT_PARAM; !old_crypt32 && (i <= CMSG_CMS_SIGNER_INFO_PARAM); i++)
{
size = 0;
ret = CryptMsgGetParam(msg, i, 0, NULL, &size);
@ -241,7 +242,7 @@ static void test_msg_get_param(void)
ret = CryptMsgGetParam(msg, CMSG_TYPE_PARAM, 0, &value, &size);
ok(ret, "CryptMsgGetParam failed: %x\n", GetLastError());
ok(value == CMSG_SIGNED, "Expected CMSG_SIGNED, got %d\n", value);
for (i = CMSG_CONTENT_PARAM; have_nt && (i <= CMSG_CMS_SIGNER_INFO_PARAM); i++)
for (i = CMSG_CONTENT_PARAM; !old_crypt32 && (i <= CMSG_CMS_SIGNER_INFO_PARAM); i++)
{
size = 0;
ret = CryptMsgGetParam(msg, i, 0, NULL, &size);
@ -295,7 +296,14 @@ static void check_param(LPCSTR test, HCRYPTMSG msg, DWORD param,
size = 0xdeadbeef;
ret = CryptMsgGetParam(msg, param, 0, NULL, &size);
ok(ret, "%s: CryptMsgGetParam failed: %08x\n", test, GetLastError());
ok(ret || broken(GetLastError() == OSS_LIMITED /* Win9x */ ||
GetLastError() == CRYPT_E_INVALID_MSG_TYPE /* Win9x, for some params */),
"%s: CryptMsgGetParam failed: %08x\n", test, GetLastError());
if (!ret)
{
win_skip("parameter %d not supported, skipping tests\n", param);
return;
}
buf = HeapAlloc(GetProcessHeap(), 0, size);
ret = CryptMsgGetParam(msg, param, 0, buf, &size);
ok(ret, "%s: CryptMsgGetParam failed: %08x\n", test, GetLastError());
@ -400,20 +408,32 @@ static void test_data_msg_update(void)
msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, CMSG_DETACHED_FLAG,
CMSG_DATA, NULL, NULL, NULL);
/* Doesn't appear to be able to update CMSG-DATA with non-final updates */
if (have_nt)
{
/* Doesn't appear to be able to update CMSG-DATA with non-final updates.
* On Win9x, this sometimes succeeds, sometimes fails with
* GetLastError() == 0, so it's not worth checking there.
*/
SetLastError(0xdeadbeef);
ret = CryptMsgUpdate(msg, NULL, 0, FALSE);
ok(!ret && GetLastError() == E_INVALIDARG,
ok(!ret &&
(GetLastError() == E_INVALIDARG ||
broken(GetLastError() == ERROR_SUCCESS)), /* Older NT4 */
"Expected E_INVALIDARG, got %x\n", GetLastError());
SetLastError(0xdeadbeef);
ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE);
ok(!ret && GetLastError() == E_INVALIDARG,
ok(!ret &&
(GetLastError() == E_INVALIDARG ||
broken(GetLastError() == ERROR_SUCCESS)), /* Older NT4 */
"Expected E_INVALIDARG, got %x\n", GetLastError());
}
else
skip("not updating CMSG_DATA with a non-final update\n");
ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE);
ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError());
CryptMsgClose(msg);
if (have_nt)
if (!old_crypt32)
{
/* Calling update after opening with an empty stream info (with a bogus
* output function) yields an error:
@ -481,11 +501,11 @@ static void test_data_msg_get_param(void)
NULL, &streamInfo);
SetLastError(0xdeadbeef);
ret = CryptMsgGetParam(msg, CMSG_BARE_CONTENT_PARAM, 0, NULL, &size);
ok(!ret && GetLastError() == E_INVALIDARG,
ok((!ret && GetLastError() == E_INVALIDARG) || broken(ret /* Win9x */),
"Expected E_INVALIDARG, got %x\n", GetLastError());
SetLastError(0xdeadbeef);
ret = CryptMsgGetParam(msg, CMSG_CONTENT_PARAM, 0, NULL, &size);
ok(!ret && GetLastError() == E_INVALIDARG,
ok((!ret && GetLastError() == E_INVALIDARG) || broken(ret /* Win9x */),
"Expected E_INVALIDARG, got %x\n", GetLastError());
CryptMsgClose(msg);
}
@ -798,15 +818,19 @@ static void test_hash_msg_get_param(void)
/* Content and bare content are always gettable for non-streamed messages */
size = 0;
ret = CryptMsgGetParam(msg, CMSG_CONTENT_PARAM, 0, NULL, &size);
ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError());
ok(ret || broken(GetLastError() == OSS_LIMITED /* Win9x */),
"CryptMsgGetParam failed: %08x\n", GetLastError());
size = 0;
ret = CryptMsgGetParam(msg, CMSG_BARE_CONTENT_PARAM, 0, NULL, &size);
ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError());
ok(ret || broken(GetLastError() == OSS_LIMITED /* Win9x */),
"CryptMsgGetParam failed: %08x\n", GetLastError());
/* For an encoded hash message, the hash data aren't available */
SetLastError(0xdeadbeef);
ret = CryptMsgGetParam(msg, CMSG_HASH_DATA_PARAM, 0, NULL, &size);
ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE,
"Expected CRYPT_E_INVALID_MSG_TYPE, got %08x\n", GetLastError());
ok(!ret && (GetLastError() == CRYPT_E_INVALID_MSG_TYPE ||
GetLastError() == OSS_LIMITED /* Win9x */),
"Expected CRYPT_E_INVALID_MSG_TYPE or OSS_LIMITED, got %08x\n",
GetLastError());
/* The hash is also available. */
size = 0;
ret = CryptMsgGetParam(msg, CMSG_COMPUTED_HASH_PARAM, 0, NULL, &size);
@ -821,7 +845,8 @@ static void test_hash_msg_get_param(void)
ok(!ret &&
(GetLastError() == NTE_BAD_HASH_STATE /* NT */ ||
GetLastError() == NTE_BAD_ALGID /* 9x */ ||
GetLastError() == CRYPT_E_MSG_ERROR /* Vista */),
GetLastError() == CRYPT_E_MSG_ERROR /* Vista */ ||
broken(GetLastError() == ERROR_SUCCESS) /* Some Win9x */),
"Expected NTE_BAD_HASH_STATE or NTE_BAD_ALGID or CRYPT_E_MSG_ERROR, got 0x%x\n", GetLastError());
/* Even after a final update, the hash data aren't available */
@ -832,10 +857,13 @@ static void test_hash_msg_get_param(void)
/* The version is also available, and should be zero for this message. */
size = 0;
ret = CryptMsgGetParam(msg, CMSG_VERSION_PARAM, 0, NULL, &size);
ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError());
ok(ret || broken(GetLastError() == CRYPT_E_INVALID_MSG_TYPE /* Win9x */),
"CryptMsgGetParam failed: %08x\n", GetLastError());
size = sizeof(value);
ret = CryptMsgGetParam(msg, CMSG_VERSION_PARAM, 0, &value, &size);
ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError());
ok(ret || broken(GetLastError() == CRYPT_E_INVALID_MSG_TYPE /* Win9x */),
"CryptMsgGetParam failed: %08x\n", GetLastError());
if (ret)
ok(value == 0, "Expected version 0, got %d\n", value);
/* As usual, the type isn't available. */
ret = CryptMsgGetParam(msg, CMSG_TYPE_PARAM, 0, NULL, &size);
@ -847,12 +875,14 @@ static void test_hash_msg_get_param(void)
/* Streamed messages don't allow you to get the content or bare content. */
SetLastError(0xdeadbeef);
ret = CryptMsgGetParam(msg, CMSG_CONTENT_PARAM, 0, NULL, &size);
ok(!ret && GetLastError() == E_INVALIDARG,
"Expected E_INVALIDARG, got %x\n", GetLastError());
ok(!ret && (GetLastError() == E_INVALIDARG ||
GetLastError() == OSS_LIMITED /* Win9x */),
"Expected E_INVALIDARG or OSS_LIMITED, got %x\n", GetLastError());
SetLastError(0xdeadbeef);
ret = CryptMsgGetParam(msg, CMSG_BARE_CONTENT_PARAM, 0, NULL, &size);
ok(!ret && GetLastError() == E_INVALIDARG,
"Expected E_INVALIDARG, got %x\n", GetLastError());
ok(!ret && (GetLastError() == E_INVALIDARG ||
GetLastError() == OSS_LIMITED /* Win9x */),
"Expected E_INVALIDARG or OSS_LIMITED, got %x\n", GetLastError());
/* The hash is still available. */
size = 0;
ret = CryptMsgGetParam(msg, CMSG_COMPUTED_HASH_PARAM, 0, NULL, &size);
@ -870,7 +900,8 @@ static void test_hash_msg_get_param(void)
ok(!ret &&
(GetLastError() == NTE_BAD_HASH_STATE /* NT */ ||
GetLastError() == NTE_BAD_ALGID /* 9x */ ||
GetLastError() == CRYPT_E_MSG_ERROR /* Vista */),
GetLastError() == CRYPT_E_MSG_ERROR /* Vista */ ||
broken(GetLastError() == ERROR_SUCCESS) /* Some Win9x */),
"Expected NTE_BAD_HASH_STATE or NTE_BAD_ALGID or CRYPT_E_MSG_ERROR, got 0x%x\n", GetLastError());
CryptMsgClose(msg);
@ -1055,26 +1086,31 @@ static void test_signed_msg_open(void)
SetLastError(0xdeadbeef);
msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, &signInfo,
NULL, NULL);
/* NT: E_INVALIDARG, 9x: unchanged */
ok(!msg && (GetLastError() == E_INVALIDARG || GetLastError() == 0xdeadbeef),
"Expected E_INVALIDARG or 0xdeadbeef, got 0x%x\n", GetLastError());
/* NT: E_INVALIDARG, 9x: unchanged or CRYPT_E_UNKNOWN_ALGO */
ok(!msg && (GetLastError() == E_INVALIDARG || GetLastError() == 0xdeadbeef
|| GetLastError() == CRYPT_E_UNKNOWN_ALGO),
"Expected E_INVALIDARG or 0xdeadbeef or CRYPT_E_UNKNOWN_ALGO, got 0x%x\n",
GetLastError());
certInfo.SerialNumber.cbData = sizeof(serialNum);
certInfo.SerialNumber.pbData = serialNum;
SetLastError(0xdeadbeef);
msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, &signInfo,
NULL, NULL);
/* NT: E_INVALIDARG, 9x: unchanged */
ok(!msg && (GetLastError() == E_INVALIDARG || GetLastError() == 0xdeadbeef),
"Expected E_INVALIDARG or 0xdeadbeef, got 0x%x\n", GetLastError());
/* NT: E_INVALIDARG, 9x: unchanged or CRYPT_E_UNKNOWN_ALGO */
ok(!msg && (GetLastError() == E_INVALIDARG || GetLastError() == 0xdeadbeef
|| GetLastError() == CRYPT_E_UNKNOWN_ALGO),
"Expected E_INVALIDARG or 0xdeadbeef or CRYPT_E_UNKNOWN_ALGO, got 0x%x\n",
GetLastError());
certInfo.Issuer.cbData = sizeof(encodedCommonName);
certInfo.Issuer.pbData = encodedCommonName;
SetLastError(0xdeadbeef);
msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, &signInfo,
NULL, NULL);
ok(!msg && GetLastError() == E_INVALIDARG,
"Expected E_INVALIDARG, got %x\n", GetLastError());
ok(!msg && (GetLastError() == E_INVALIDARG ||
GetLastError() == CRYPT_E_UNKNOWN_ALGO),
"Expected E_INVALIDARG or CRYPT_E_UNKNOWN_ALGO, got %x\n", GetLastError());
/* The signer's hCryptProv must be set to something. Whether it's usable
* or not will be checked after the hash algorithm is checked (see next
@ -1211,8 +1247,10 @@ static void test_signed_msg_update(void)
*/
SetLastError(0xdeadbeef);
ret = CryptMsgUpdate(msg, NULL, 0, TRUE);
ok(!ret && (GetLastError() == NTE_BAD_KEYSET ||
GetLastError() == NTE_NO_KEY),
ok(!ret &&
(GetLastError() == NTE_BAD_KEYSET ||
GetLastError() == NTE_NO_KEY ||
broken(GetLastError() == ERROR_SUCCESS)), /* Some Win9x */
"Expected NTE_BAD_KEYSET or NTE_NO_KEY, got %x\n", GetLastError());
ret = CryptImportKey(signer.hCryptProv, privKey, sizeof(privKey),
0, 0, &key);
@ -1656,7 +1694,8 @@ static void test_signed_msg_encoding(void)
detachedSignedContent, sizeof(detachedSignedContent));
SetLastError(0xdeadbeef);
ret = CryptMsgGetParam(msg, CMSG_COMPUTED_HASH_PARAM, 1, NULL, &size);
ok(!ret && GetLastError() == CRYPT_E_INVALID_INDEX,
ok(!ret && (GetLastError() == CRYPT_E_INVALID_INDEX ||
broken(GetLastError() == CRYPT_E_INVALID_MSG_TYPE /* Win9x */)),
"Expected CRYPT_E_INVALID_INDEX, got %x\n", GetLastError());
check_param("detached signed encoded signer", msg, CMSG_ENCODED_SIGNER,
signedEncodedSigner, sizeof(signedEncodedSigner));
@ -1808,7 +1847,13 @@ static void test_signed_msg_get_param(void)
/* Content and bare content are always gettable */
size = 0;
ret = CryptMsgGetParam(msg, CMSG_CONTENT_PARAM, 0, NULL, &size);
ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError());
ok(ret || broken(!ret /* Win9x */), "CryptMsgGetParam failed: %08x\n",
GetLastError());
if (!ret)
{
skip("message parameters are broken, skipping tests\n");
return;
}
size = 0;
ret = CryptMsgGetParam(msg, CMSG_BARE_CONTENT_PARAM, 0, NULL, &size);
ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError());
@ -1913,7 +1958,9 @@ static void test_signed_msg_get_param(void)
*/
size = sizeof(value);
ret = CryptMsgGetParam(msg, CMSG_VERSION_PARAM, 0, &value, &size);
ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError());
ok(ret || broken(GetLastError() == CRYPT_E_INVALID_MSG_TYPE),
"CryptMsgGetParam failed: %08x\n", GetLastError());
if (ret)
ok(value == CMSG_SIGNED_DATA_V1, "expected version 1, got %d\n", value);
/* Apparently the encoded signer can be retrieved.. */
ret = CryptMsgGetParam(msg, CMSG_ENCODED_SIGNER, 0, NULL, &size);
@ -1950,6 +1997,8 @@ static void test_signed_msg_get_param(void)
ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError());
size = sizeof(value);
ret = CryptMsgGetParam(msg, CMSG_VERSION_PARAM, 0, &value, &size);
ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError());
if (ret)
ok(value == CMSG_SIGNED_DATA_V3, "expected version 3, got %d\n", value);
/* Even for a CMS message, the signer can be retrieved.. */
ret = CryptMsgGetParam(msg, CMSG_ENCODED_SIGNER, 0, NULL, &size);
@ -2026,7 +2075,7 @@ static void test_decode_msg_update(void)
ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError());
CryptMsgClose(msg);
if (have_nt)
if (!old_crypt32)
{
msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, &streamInfo);
/* Updating a message that has a NULL stream callback fails */
@ -2084,16 +2133,20 @@ static void test_decode_msg_update(void)
msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, NULL);
SetLastError(0xdeadbeef);
ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE);
ok(!ret && GetLastError() == CRYPT_E_ASN1_BADTAG,
"Expected CRYPT_E_ASN1_BADTAG, got %x\n", GetLastError());
ok(!ret && (GetLastError() == CRYPT_E_ASN1_BADTAG ||
GetLastError() == OSS_PDU_MISMATCH /* Win9x */),
"Expected CRYPT_E_ASN1_BADTAG or OSS_PDU_MISMATCH, got %x\n",
GetLastError());
CryptMsgClose(msg);
/* and as the final update in streaming mode.. */
streamInfo.pfnStreamOutput = nop_stream_output;
msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, &streamInfo);
SetLastError(0xdeadbeef);
ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE);
ok(!ret && GetLastError() == CRYPT_E_ASN1_BADTAG,
"Expected CRYPT_E_ASN1_BADTAG, got %x\n", GetLastError());
ok(!ret && (GetLastError() == CRYPT_E_ASN1_BADTAG ||
GetLastError() == OSS_PDU_MISMATCH /* Win9x */),
"Expected CRYPT_E_ASN1_BADTAG or OSS_PDU_MISMATCH, got %x\n",
GetLastError());
CryptMsgClose(msg);
/* and even as a non-final update in streaming mode. */
streamInfo.pfnStreamOutput = nop_stream_output;
@ -2101,8 +2154,10 @@ static void test_decode_msg_update(void)
SetLastError(0xdeadbeef);
ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE);
todo_wine
ok(!ret && GetLastError() == CRYPT_E_ASN1_BADTAG,
"Expected CRYPT_E_ASN1_BADTAG, got %x\n", GetLastError());
ok(!ret && (GetLastError() == CRYPT_E_ASN1_BADTAG ||
GetLastError() == OSS_PDU_MISMATCH /* Win9x */),
"Expected CRYPT_E_ASN1_BADTAG or OSS_PDU_MISMATCH, got %x\n",
GetLastError());
CryptMsgClose(msg);
/* An empty message can be opened with undetermined type.. */
@ -2117,8 +2172,10 @@ static void test_decode_msg_update(void)
SetLastError(0xdeadbeef);
ret = CryptMsgUpdate(msg, dataEmptyContent, sizeof(dataEmptyContent),
TRUE);
ok(!ret && GetLastError() == CRYPT_E_ASN1_BADTAG,
"Expected CRYPT_E_ASN1_BADTAG, got %x\n", GetLastError());
ok(!ret && (GetLastError() == CRYPT_E_ASN1_BADTAG ||
GetLastError() == OSS_PDU_MISMATCH /* Win9x */),
"Expected CRYPT_E_ASN1_BADTAG or OSS_PDU_MISMATCH, got %x\n",
GetLastError());
CryptMsgClose(msg);
/* On the other hand, decoding the bare content of an empty message fails
* with unspecified type..
@ -2127,8 +2184,10 @@ static void test_decode_msg_update(void)
SetLastError(0xdeadbeef);
ret = CryptMsgUpdate(msg, dataEmptyBareContent,
sizeof(dataEmptyBareContent), TRUE);
ok(!ret && GetLastError() == CRYPT_E_ASN1_BADTAG,
"Expected CRYPT_E_ASN1_BADTAG, got %x\n", GetLastError());
ok(!ret && (GetLastError() == CRYPT_E_ASN1_BADTAG ||
GetLastError() == OSS_PDU_MISMATCH /* Win9x */),
"Expected CRYPT_E_ASN1_BADTAG or OSS_PDU_MISMATCH, got %x\n",
GetLastError());
CryptMsgClose(msg);
/* but succeeds with explicit type. */
msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_DATA, 0, NULL,
@ -2150,15 +2209,19 @@ static void test_decode_msg_update(void)
msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, NULL);
SetLastError(0xdeadbeef);
ret = CryptMsgUpdate(msg, hashEmptyContent, sizeof(hashEmptyContent), TRUE);
ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError());
ok(ret || broken(GetLastError() == OSS_DATA_ERROR /* Win9x */),
"CryptMsgUpdate failed: %08x\n", GetLastError());
CryptMsgClose(msg);
/* while with specified type it fails. */
msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_HASHED, 0, NULL,
NULL);
SetLastError(0xdeadbeef);
ret = CryptMsgUpdate(msg, hashEmptyContent, sizeof(hashEmptyContent), TRUE);
ok(!ret && GetLastError() == CRYPT_E_ASN1_BADTAG,
"Expected CRYPT_E_ASN1_BADTAG, got %x\n", GetLastError());
ok(!ret && (GetLastError() == CRYPT_E_ASN1_BADTAG ||
GetLastError() == OSS_PDU_MISMATCH /* some Win9x */ ||
GetLastError() == OSS_DATA_ERROR /* some Win9x */),
"Expected CRYPT_E_ASN1_BADTAG or OSS_PDU_MISMATCH or OSS_DATA_ERROR, got %x\n",
GetLastError());
CryptMsgClose(msg);
/* On the other hand, decoding the bare content of an empty hash message
* fails with unspecified type..
@ -2167,15 +2230,19 @@ static void test_decode_msg_update(void)
SetLastError(0xdeadbeef);
ret = CryptMsgUpdate(msg, hashEmptyBareContent,
sizeof(hashEmptyBareContent), TRUE);
ok(!ret && GetLastError() == CRYPT_E_ASN1_BADTAG,
"Expected CRYPT_E_ASN1_BADTAG, got %x\n", GetLastError());
ok(!ret && (GetLastError() == CRYPT_E_ASN1_BADTAG ||
GetLastError() == OSS_PDU_MISMATCH /* some Win9x */ ||
GetLastError() == OSS_DATA_ERROR /* some Win9x */),
"Expected CRYPT_E_ASN1_BADTAG or OSS_PDU_MISMATCH or OSS_DATA_ERROR, got %x\n",
GetLastError());
CryptMsgClose(msg);
/* but succeeds with explicit type. */
msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_HASHED, 0, NULL,
NULL);
ret = CryptMsgUpdate(msg, hashEmptyBareContent,
sizeof(hashEmptyBareContent), TRUE);
ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError());
ok(ret || broken(GetLastError() == OSS_DATA_ERROR /* win9x */),
"CryptMsgUpdate failed: %x\n", GetLastError());
CryptMsgClose(msg);
/* And again, opening a (non-empty) hash message with unspecified type
@ -2191,8 +2258,11 @@ static void test_decode_msg_update(void)
NULL);
SetLastError(0xdeadbeef);
ret = CryptMsgUpdate(msg, hashContent, sizeof(hashContent), TRUE);
ok(!ret && GetLastError() == CRYPT_E_ASN1_BADTAG,
"Expected CRYPT_E_ASN1_BADTAG, got %x\n", GetLastError());
ok(!ret && (GetLastError() == CRYPT_E_ASN1_BADTAG ||
GetLastError() == OSS_PDU_MISMATCH /* some Win9x */ ||
GetLastError() == OSS_DATA_ERROR /* some Win9x */),
"Expected CRYPT_E_ASN1_BADTAG or OSS_PDU_MISMATCH or OSS_DATA_ERROR, got %x\n",
GetLastError());
CryptMsgClose(msg);
/* and decoding the bare content of a non-empty hash message fails with
* unspecified type..
@ -2200,8 +2270,11 @@ static void test_decode_msg_update(void)
msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, NULL);
SetLastError(0xdeadbeef);
ret = CryptMsgUpdate(msg, hashBareContent, sizeof(hashBareContent), TRUE);
ok(!ret && GetLastError() == CRYPT_E_ASN1_BADTAG,
"Expected CRYPT_E_ASN1_BADTAG, got %x\n", GetLastError());
ok(!ret && (GetLastError() == CRYPT_E_ASN1_BADTAG ||
GetLastError() == OSS_PDU_MISMATCH /* some Win9x */ ||
GetLastError() == OSS_DATA_ERROR /* some Win9x */),
"Expected CRYPT_E_ASN1_BADTAG or OSS_PDU_MISMATCH or OSS_DATA_ERROR, got %x\n",
GetLastError());
CryptMsgClose(msg);
/* but succeeds with explicit type. */
msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_HASHED, 0, NULL,
@ -2227,8 +2300,10 @@ static void test_decode_msg_update(void)
SetLastError(0xdeadbeef);
ret = CryptMsgUpdate(msg, signedWithCertAndCrlBareContent,
sizeof(signedWithCertAndCrlBareContent), TRUE);
ok(!ret && GetLastError() == CRYPT_E_ASN1_BADTAG,
"Expected CRYPT_E_ASN1_BADTAG, got %08x\n", GetLastError());
ok(!ret && (GetLastError() == CRYPT_E_ASN1_BADTAG ||
GetLastError() == OSS_DATA_ERROR /* Win9x */),
"Expected CRYPT_E_ASN1_BADTAG or OSS_DATA_ERROR, got %08x\n",
GetLastError());
CryptMsgClose(msg);
msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, 0, NULL,
NULL);
@ -2378,12 +2453,16 @@ static void test_decode_msg_get_param(void)
sizeof(hashParam));
check_param("hash computed hash", msg, CMSG_COMPUTED_HASH_PARAM,
hashParam, sizeof(hashParam));
/* Curiously, getting the hash of index 1 succeeds, even though there's
* only one hash.
/* Curiously, on NT-like systems, getting the hash of index 1 succeeds,
* even though there's only one hash.
*/
ret = CryptMsgGetParam(msg, CMSG_COMPUTED_HASH_PARAM, 1, NULL, &size);
ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError());
ok(ret || GetLastError() == OSS_DATA_ERROR /* Win9x */,
"CryptMsgGetParam failed: %08x\n", GetLastError());
if (ret)
buf = CryptMemAlloc(size);
else
buf = NULL;
if (buf)
{
ret = CryptMsgGetParam(msg, CMSG_COMPUTED_HASH_PARAM, 1, buf, &size);
@ -2412,7 +2491,8 @@ static void test_decode_msg_get_param(void)
ok(value == 1, "Expected 1 signer, got %d\n", value);
size = 0;
ret = CryptMsgGetParam(msg, CMSG_SIGNER_INFO_PARAM, 0, NULL, &size);
ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError());
ok(ret || broken(GetLastError() == OSS_DATA_ERROR /* Win9x */),
"CryptMsgGetParam failed: %08x\n", GetLastError());
if (ret)
buf = CryptMemAlloc(size);
else
@ -2434,7 +2514,8 @@ static void test_decode_msg_get_param(void)
/* Getting the CMS signer info of a PKCS7 message is possible. */
size = 0;
ret = CryptMsgGetParam(msg, CMSG_CMS_SIGNER_INFO_PARAM, 0, NULL, &size);
ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError());
ok(ret || broken(GetLastError() == CRYPT_E_INVALID_MSG_TYPE /* Win9x */),
"CryptMsgGetParam failed: %08x\n", GetLastError());
if (ret)
buf = CryptMemAlloc(size);
else
@ -2589,7 +2670,7 @@ static void test_msg_control(void)
msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_DATA, NULL, NULL,
NULL);
/* either with no prior update.. */
for (i = 1; have_nt && (i <= CMSG_CTRL_ADD_CMS_SIGNER_INFO); i++)
for (i = 1; !old_crypt32 && (i <= CMSG_CTRL_ADD_CMS_SIGNER_INFO); i++)
{
SetLastError(0xdeadbeef);
ret = CryptMsgControl(msg, 0, i, NULL);
@ -2598,7 +2679,7 @@ static void test_msg_control(void)
}
ret = CryptMsgUpdate(msg, NULL, 0, TRUE);
/* or after an update. */
for (i = 1; have_nt && (i <= CMSG_CTRL_ADD_CMS_SIGNER_INFO); i++)
for (i = 1; !old_crypt32 && (i <= CMSG_CTRL_ADD_CMS_SIGNER_INFO); i++)
{
SetLastError(0xdeadbeef);
ret = CryptMsgControl(msg, 0, i, NULL);
@ -2613,7 +2694,7 @@ static void test_msg_control(void)
msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_HASHED, &hashInfo,
NULL, NULL);
/* either with no prior update.. */
for (i = 1; have_nt && (i <= CMSG_CTRL_ADD_CMS_SIGNER_INFO); i++)
for (i = 1; !old_crypt32 && (i <= CMSG_CTRL_ADD_CMS_SIGNER_INFO); i++)
{
SetLastError(0xdeadbeef);
ret = CryptMsgControl(msg, 0, i, NULL);
@ -2622,7 +2703,7 @@ static void test_msg_control(void)
}
ret = CryptMsgUpdate(msg, NULL, 0, TRUE);
/* or after an update. */
for (i = 1; have_nt && (i <= CMSG_CTRL_ADD_CMS_SIGNER_INFO); i++)
for (i = 1; !old_crypt32 && (i <= CMSG_CTRL_ADD_CMS_SIGNER_INFO); i++)
{
SetLastError(0xdeadbeef);
ret = CryptMsgControl(msg, 0, i, NULL);
@ -2636,7 +2717,7 @@ static void test_msg_control(void)
msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, &signInfo,
NULL, NULL);
/* either before an update.. */
for (i = 1; have_nt && (i <= CMSG_CTRL_ADD_CMS_SIGNER_INFO); i++)
for (i = 1; !old_crypt32 && (i <= CMSG_CTRL_ADD_CMS_SIGNER_INFO); i++)
{
SetLastError(0xdeadbeef);
ret = CryptMsgControl(msg, 0, i, NULL);
@ -2645,7 +2726,7 @@ static void test_msg_control(void)
}
ret = CryptMsgUpdate(msg, NULL, 0, TRUE);
/* or after an update. */
for (i = 1; have_nt && (i <= CMSG_CTRL_ADD_CMS_SIGNER_INFO); i++)
for (i = 1; !old_crypt32 && (i <= CMSG_CTRL_ADD_CMS_SIGNER_INFO); i++)
{
SetLastError(0xdeadbeef);
ret = CryptMsgControl(msg, 0, i, NULL);
@ -2679,7 +2760,7 @@ static void test_msg_control(void)
"Expected CRYPT_E_INVALID_MSG_TYPE, got %08x\n", GetLastError());
CryptMsgClose(msg);
if (have_nt)
if (!old_crypt32)
{
msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_HASHED, 0, NULL,
NULL);
@ -2788,8 +2869,10 @@ static void test_msg_control(void)
*/
SetLastError(0xdeadbeef);
ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_SIGNATURE, &certInfo);
ok(!ret && GetLastError() == CRYPT_E_SIGNER_NOT_FOUND,
"Expected CRYPT_E_SIGNER_NOT_FOUND, got %08x\n", GetLastError());
ok(!ret && (GetLastError() == CRYPT_E_SIGNER_NOT_FOUND ||
GetLastError() == OSS_DATA_ERROR /* Win9x */),
"Expected CRYPT_E_SIGNER_NOT_FOUND or OSS_DATA_ERROR, got %08x\n",
GetLastError());
/* The cert info is expected to have an issuer, serial number, and public
* key info set.
*/
@ -2799,8 +2882,9 @@ static void test_msg_control(void)
certInfo.Issuer.pbData = encodedCommonName;
SetLastError(0xdeadbeef);
ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_SIGNATURE, &certInfo);
ok(!ret && GetLastError() == CRYPT_E_ASN1_EOD,
"Expected CRYPT_E_ASN1_EOD, got %08x\n", GetLastError());
ok(!ret && (GetLastError() == CRYPT_E_ASN1_EOD ||
GetLastError() == OSS_DATA_ERROR /* Win9x */),
"Expected CRYPT_E_ASN1_EOD or OSS_DATA_ERROR, got %08x\n", GetLastError());
CryptMsgClose(msg);
/* This cert has a public key, but it's not in a usable form */
msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, 0, NULL,
@ -2876,7 +2960,8 @@ static void test_msg_control(void)
CryptMsgUpdate(msg, signedWithCertWithValidPubKeyContent,
sizeof(signedWithCertWithValidPubKeyContent), TRUE);
ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_SIGNATURE, &certInfo);
ok(ret, "CryptMsgControl failed: %08x\n", GetLastError());
ok(ret || broken(GetLastError() == OSS_DATA_ERROR /* Win9x */),
"CryptMsgControl failed: %08x\n", GetLastError());
CryptMsgClose(msg);
/* Test verifying signature of a detached signed message */
@ -2888,15 +2973,19 @@ static void test_msg_control(void)
/* Can't verify the sig without having updated the data */
SetLastError(0xdeadbeef);
ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_SIGNATURE, &certInfo);
ok(!ret && GetLastError() == NTE_BAD_SIGNATURE,
"expected NTE_BAD_SIGNATURE, got %08x\n", GetLastError());
ok(!ret && (GetLastError() == NTE_BAD_SIGNATURE ||
GetLastError() == OSS_DATA_ERROR /* Win9x */),
"expected NTE_BAD_SIGNATURE or OSS_DATA_ERROR, got %08x\n",
GetLastError());
/* Now that the signature's been checked, can't do the final update */
SetLastError(0xdeadbeef);
ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE);
todo_wine
ok(!ret &&
ok((!ret &&
(GetLastError() == NTE_BAD_HASH_STATE ||
GetLastError() == NTE_BAD_ALGID || /* Win9x */
GetLastError() == CRYPT_E_MSG_ERROR), /* Vista */
GetLastError() == CRYPT_E_MSG_ERROR)) || /* Vista */
broken(ret), /* Win9x */
"expected NTE_BAD_HASH_STATE or NTE_BAD_ALGID or CRYPT_E_MSG_ERROR, "
"got %08x\n", GetLastError());
CryptMsgClose(msg);
@ -2911,7 +3000,8 @@ static void test_msg_control(void)
ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE);
ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError());
ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_SIGNATURE, &certInfo);
ok(ret, "CryptMsgControl failed: %08x\n", GetLastError());
ok(ret || broken(GetLastError() == OSS_DATA_ERROR /* Win9x */),
"CryptMsgControl failed: %08x\n", GetLastError());
CryptMsgClose(msg);
}
@ -3013,16 +3103,21 @@ static void test_msg_get_and_verify_signer(void)
CryptMsgUpdate(msg, signedWithCertWithValidPubKeyContent,
sizeof(signedWithCertWithValidPubKeyContent), TRUE);
ret = CryptMsgGetAndVerifySigner(msg, 0, NULL, 0, NULL, NULL);
ok(ret, "CryptMsgGetAndVerifySigner failed: 0x%08x\n", GetLastError());
ok(ret || broken(GetLastError() == OSS_DATA_ERROR /* Win9x */),
"CryptMsgGetAndVerifySigner failed: 0x%08x\n", GetLastError());
/* the signer index can be retrieved, .. */
signerIndex = 0xdeadbeef;
ret = CryptMsgGetAndVerifySigner(msg, 0, NULL, 0, NULL, &signerIndex);
ok(ret, "CryptMsgGetAndVerifySigner failed: 0x%08x\n", GetLastError());
ok(ret || broken(GetLastError() == OSS_DATA_ERROR /* Win9x */),
"CryptMsgGetAndVerifySigner failed: 0x%08x\n", GetLastError());
if (ret)
ok(signerIndex == 0, "expected 0, got %d\n", signerIndex);
/* as can the signer cert. */
signer = (PCCERT_CONTEXT)0xdeadbeef;
ret = CryptMsgGetAndVerifySigner(msg, 0, NULL, 0, &signer, NULL);
ok(ret, "CryptMsgGetAndVerifySigner failed: 0x%08x\n", GetLastError());
ok(ret || broken(GetLastError() == OSS_DATA_ERROR /* Win9x */),
"CryptMsgGetAndVerifySigner failed: 0x%08x\n", GetLastError());
if (ret)
ok(signer != NULL && signer != (PCCERT_CONTEXT)0xdeadbeef,
"expected a valid signer\n");
if (signer && signer != (PCCERT_CONTEXT)0xdeadbeef)
@ -3041,7 +3136,8 @@ static void test_msg_get_and_verify_signer(void)
SetLastError(0xdeadbeef);
ret = CryptMsgGetAndVerifySigner(msg, 0, NULL, CMSG_TRUSTED_SIGNER_FLAG,
NULL, NULL);
ok(!ret && GetLastError() == CRYPT_E_NO_TRUSTED_SIGNER,
ok(!ret && (GetLastError() == CRYPT_E_NO_TRUSTED_SIGNER ||
broken(GetLastError() == OSS_DATA_ERROR /* Win9x */)),
"expected CRYPT_E_NO_TRUSTED_SIGNER, got 0x%08x\n", GetLastError());
/* Specifying CMSG_TRUSTED_SIGNER_FLAG and an empty cert store also causes
* the message signer not to be found.
@ -3051,20 +3147,22 @@ static void test_msg_get_and_verify_signer(void)
SetLastError(0xdeadbeef);
ret = CryptMsgGetAndVerifySigner(msg, 1, &store, CMSG_TRUSTED_SIGNER_FLAG,
NULL, NULL);
ok(!ret && GetLastError() == CRYPT_E_NO_TRUSTED_SIGNER,
ok(!ret && (GetLastError() == CRYPT_E_NO_TRUSTED_SIGNER ||
broken(GetLastError() == OSS_DATA_ERROR /* Win9x */)),
"expected CRYPT_E_NO_TRUSTED_SIGNER, got 0x%08x\n", GetLastError());
ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING,
v1CertWithValidPubKey, sizeof(v1CertWithValidPubKey),
CERT_STORE_ADD_ALWAYS, NULL);
ok(ret, "CertAddEncodedCertificateToStore failed: 0x%08x\n",
GetLastError());
ok(ret || broken(GetLastError() == OSS_DATA_ERROR /* Win98 */),
"CertAddEncodedCertificateToStore failed: 0x%08x\n", GetLastError());
/* Specifying CMSG_TRUSTED_SIGNER_FLAG with a cert store that contains
* the signer succeeds.
*/
SetLastError(0xdeadbeef);
ret = CryptMsgGetAndVerifySigner(msg, 1, &store, CMSG_TRUSTED_SIGNER_FLAG,
NULL, NULL);
ok(ret, "CryptMsgGetAndVerifySigner failed: 0x%08x\n", GetLastError());
ok(ret || broken(GetLastError() == OSS_DATA_ERROR /* Win9x */),
"CryptMsgGetAndVerifySigner failed: 0x%08x\n", GetLastError());
CertCloseStore(store, 0);
CryptMsgClose(msg);
}
@ -3076,6 +3174,13 @@ START_TEST(msg)
if (!have_nt)
win_skip("Win9x crashes on some parameter checks\n");
/* I_CertUpdateStore can be used for verification if crypt32 is new enough */
if (!GetProcAddress(GetModuleHandleA("crypt32.dll"), "I_CertUpdateStore"))
{
win_skip("Some tests will crash on older crypt32 implementations\n");
old_crypt32 = TRUE;
}
/* Basic parameter checking tests */
test_msg_open_to_encode();
test_msg_open_to_decode();

View file

@ -306,7 +306,7 @@ static struct _tagASSEMBLY
},
/* IMAGE_OPTIONAL_HEADER32 */
{
IMAGE_NT_OPTIONAL_HDR_MAGIC, /* Magic */
IMAGE_NT_OPTIONAL_HDR32_MAGIC, /* Magic */
8, /* MajorLinkerVersion */
0, /* MinorLinkerVersion */
0x400, /* SizeOfCode */

View file

@ -240,11 +240,19 @@ static BOOL enum_gac_assemblies(struct list *assemblies, int depth, LPSTR path)
if (depth == 0)
{
sprintf(parent, "%s, ", ffd.cFileName);
lstrcpyA(parent, ffd.cFileName);
}
else if (depth == 1)
{
char culture[MAX_PATH];
char dll[MAX_PATH], exe[MAX_PATH];
/* Directories with no dll or exe will not be enumerated */
sprintf(dll, "%s\\%s\\%s.dll", path, ffd.cFileName, parent);
sprintf(exe, "%s\\%s\\%s.exe", path, ffd.cFileName, parent);
if (GetFileAttributesA(dll) == INVALID_FILE_ATTRIBUTES &&
GetFileAttributesA(exe) == INVALID_FILE_ATTRIBUTES)
continue;
ptr = strstr(ffd.cFileName, "_");
*ptr = '\0';
@ -260,7 +268,7 @@ static BOOL enum_gac_assemblies(struct list *assemblies, int depth, LPSTR path)
ptr = strchr(ptr, '_');
ptr++;
sprintf(buf, "Version=%s, Culture=%s, PublicKeyToken=%s",
sprintf(buf, ", Version=%s, Culture=%s, PublicKeyToken=%s",
ffd.cFileName, culture, ptr);
lstrcpyA(disp, parent);
lstrcatA(disp, buf);
@ -434,8 +442,7 @@ static void test_enumerate_name(void)
hr = IAssemblyName_GetDisplayName(next, buf, &size, 0);
to_multibyte(disp, buf);
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
ok(!lstrcmpA(disp, exp[0]) ||
!lstrcmpA(disp, exp[1]),
ok(!lstrcmpA(disp, exp[0]),
"Expected \"%s\" or \"%s\", got \"%s\"\n", exp[0], exp[1], disp);
IAssemblyName_Release(next);
@ -450,7 +457,7 @@ static void test_enumerate_name(void)
to_multibyte(disp, buf);
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
ok(!lstrcmpA(disp, exp[1]) ||
!lstrcmpA(disp, exp[2]),
!lstrcmpA(disp, exp[2]), /* Win98 */
"Expected \"%s\" or \"%s\", got \"%s\"\n", exp[1], exp[2], disp);
IAssemblyName_Release(next);
@ -464,7 +471,9 @@ static void test_enumerate_name(void)
hr = IAssemblyName_GetDisplayName(next, buf, &size, 0);
to_multibyte(disp, buf);
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
ok(!lstrcmpA(disp, exp[2]), "Expected \"%s\", got \"%s\"\n", exp[2], disp);
ok(!lstrcmpA(disp, exp[2]) ||
!lstrcmpA(disp, exp[1]), /* Win98 */
"Expected \"%s\" or \"%s\", got \"%s\"\n", exp[2], exp[1], disp);
IAssemblyName_Release(next);
@ -498,7 +507,9 @@ static void test_enumerate_name(void)
hr = IAssemblyName_GetDisplayName(next, buf, &size, 0);
to_multibyte(disp, buf);
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
ok(!lstrcmpA(disp, exp[4]), "Expected \"%s\", got \"%s\"\n", exp[4], disp);
ok(!lstrcmpA(disp, exp[4]) ||
!lstrcmpA(disp, exp[5]), /* Win98 */
"Expected \"%s\" or \"%s\", got \"%s\"\n", exp[4], exp[5], disp);
IAssemblyName_Release(next);
@ -511,7 +522,9 @@ static void test_enumerate_name(void)
hr = IAssemblyName_GetDisplayName(next, buf, &size, 0);
to_multibyte(disp, buf);
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
ok(!lstrcmpA(disp, exp[5]), "Expected \"%s\", got \"%s\"\n", exp[5], disp);
ok(!lstrcmpA(disp, exp[5]) ||
!lstrcmpA(disp, exp[4]), /* Win98 */
"Expected \"%s\" or \"%s\", got \"%s\"\n", exp[5], exp[4], disp);
IAssemblyName_Release(next);
@ -606,7 +619,7 @@ static void test_enumerate_name(void)
to_multibyte(disp, buf);
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
ok(!lstrcmpA(disp, exp[1]) ||
!lstrcmpA(disp, exp[2]),
!lstrcmpA(disp, exp[2]), /* Win98 */
"Expected \"%s\" or \"%s\", got \"%s\"\n", exp[1], exp[2], disp);
IAssemblyName_Release(next);
@ -620,9 +633,9 @@ static void test_enumerate_name(void)
hr = IAssemblyName_GetDisplayName(next, buf, &size, 0);
to_multibyte(disp, buf);
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
ok(!lstrcmpA(disp, exp[1]) ||
!lstrcmpA(disp, exp[2]),
"Expected \"%s\" or \"%s\", got \"%s\"\n", exp[1], exp[2], disp);
ok(!lstrcmpA(disp, exp[2]) ||
!lstrcmpA(disp, exp[1]), /* Win98 */
"Expected \"%s\" or \"%s\", got \"%s\"\n", exp[2], exp[1], disp);
IAssemblyName_Release(next);

View file

@ -417,7 +417,8 @@ static void test_CreateAssemblyNameObject(void)
size = MAX_PATH;
hr = IAssemblyName_GetDisplayName(name, str, &size, ASM_DISPLAYF_FULL);
ok(hr == FUSION_E_INVALID_NAME,
ok(hr == FUSION_E_INVALID_NAME ||
broken(hr == E_INVALIDARG), /* .NET 1.x */
"Expected FUSION_E_INVALID_NAME, got %08x\n", hr);
size = MAX_PATH;
@ -430,11 +431,16 @@ static void test_CreateAssemblyNameObject(void)
hi = 0xbeefcace;
lo = 0xcafebabe;
hr = IAssemblyName_GetVersion(name, &hi, &lo);
ok(hr == FUSION_E_INVALID_NAME,
ok(hr == FUSION_E_INVALID_NAME ||
broken(hr == S_OK), /* .NET 1.x */
"Expected FUSION_E_INVALID_NAME, got %08x\n", hr);
ok(hi == 0, "Expected 0, got %08x\n", hi);
ok(lo == 0, "Expected 0, got %08x\n", lo);
if (hr == S_OK)
win_skip(".NET 1.x doesn't handle ASM_NAME_PROCESSOR_ID_ARRAY"
" and ASM_NAME_OSINFO_ARRAY correctly\n");
else
test_assembly_name_props(name, defaults);
IAssemblyName_Release(name);
@ -447,7 +453,8 @@ static void test_CreateAssemblyNameObject(void)
size = MAX_PATH;
hr = IAssemblyName_GetDisplayName(name, str, &size, ASM_DISPLAYF_FULL);
ok(hr == FUSION_E_INVALID_NAME,
ok(hr == FUSION_E_INVALID_NAME ||
broken(hr == S_OK), /* .NET 1.x */
"Expected FUSION_E_INVALID_NAME, got %08x\n", hr);
size = MAX_PATH;
@ -460,11 +467,16 @@ static void test_CreateAssemblyNameObject(void)
hi = 0xbeefcace;
lo = 0xcafebabe;
hr = IAssemblyName_GetVersion(name, &hi, &lo);
ok(hr == FUSION_E_INVALID_NAME,
ok(hr == FUSION_E_INVALID_NAME ||
broken(hr == S_OK), /* .NET 1.x */
"Expected FUSION_E_INVALID_NAME, got %08x\n", hr);
ok(hi == 0, "Expected 0, got %08x\n", hi);
ok(lo == 0, "Expected 0, got %08x\n", lo);
if (hr == S_OK)
win_skip(".NET 1.x doesn't handle ASM_NAME_PROCESSOR_ID_ARRAY"
" and ASM_NAME_OSINFO_ARRAY correctly\n");
else
test_assembly_name_props(name, emptyname);
IAssemblyName_Release(name);
@ -492,11 +504,16 @@ static void test_CreateAssemblyNameObject(void)
hi = 0xbeefcace;
lo = 0xcafebabe;
hr = IAssemblyName_GetVersion(name, &hi, &lo);
ok(hr == FUSION_E_INVALID_NAME,
ok(hr == FUSION_E_INVALID_NAME ||
broken(hr == S_OK), /* .NET 1.x */
"Expected FUSION_E_INVALID_NAME, got %08x\n", hr);
ok(hi == 0, "Expected 0, got %08x\n", hi);
ok(lo == 0, "Expected 0, got %08x\n", lo);
if (hr == S_OK)
win_skip(".NET 1.x doesn't handle ASM_NAME_PROCESSOR_ID_ARRAY"
" and ASM_NAME_OSINFO_ARRAY correctly\n");
else
test_assembly_name_props(name, winename);
IAssemblyName_Release(name);
@ -526,7 +543,8 @@ static void test_CreateAssemblyNameObject(void)
hi = 0xbeefcace;
lo = 0xcafebabe;
hr = IAssemblyName_GetVersion(name, &hi, &lo);
ok(hr == FUSION_E_INVALID_NAME,
ok(hr == FUSION_E_INVALID_NAME ||
broken(hr == S_OK), /* .NET 1.x */
"Expected FUSION_E_INVALID_NAME, got %08x\n", hr);
ok(hi == 0, "Expected 0, got %08x\n", hi);
ok(lo == 0, "Expected 0, got %08x\n", lo);
@ -589,9 +607,12 @@ static void test_CreateAssemblyNameObject(void)
hi = 0xbeefcace;
lo = 0xcafebabe;
hr = IAssemblyName_GetVersion(name, &hi, &lo);
ok(hr == FUSION_E_INVALID_NAME,
ok(hr == FUSION_E_INVALID_NAME ||
broken(hr == S_OK), /* .NET 1.x */
"Expected FUSION_E_INVALID_NAME, got %08x\n", hr);
ok(hi == 0, "Expected 0, got %08x\n", hi);
ok(hi == 0 ||
broken(hi == 0x10005), /* .NET 1.x */
"Expected 0, got %08x\n", hi);
ok(lo == 0, "Expected 0, got %08x\n", lo);
test_assembly_name_props(name, badvername);
@ -621,7 +642,8 @@ static void test_CreateAssemblyNameObject(void)
hi = 0xbeefcace;
lo = 0xcafebabe;
hr = IAssemblyName_GetVersion(name, &hi, &lo);
ok(hr == FUSION_E_INVALID_NAME,
ok(hr == FUSION_E_INVALID_NAME ||
broken(hr == S_OK), /* .NET 1.x */
"Expected FUSION_E_INVALID_NAME, got %08x\n", hr);
ok(hi == 0, "Expected 0, got %08x\n", hi);
ok(lo == 0, "Expected 0, got %08x\n", lo);
@ -653,7 +675,8 @@ static void test_CreateAssemblyNameObject(void)
hi = 0xbeefcace;
lo = 0xcafebabe;
hr = IAssemblyName_GetVersion(name, &hi, &lo);
ok(hr == FUSION_E_INVALID_NAME,
ok(hr == FUSION_E_INVALID_NAME ||
broken(hr == S_OK), /* .NET 1.x */
"Expected FUSION_E_INVALID_NAME, got %08x\n", hr);
ok(hi == 0, "Expected 0, got %08x\n", hi);
ok(lo == 0, "Expected 0, got %08x\n", lo);
@ -685,7 +708,8 @@ static void test_CreateAssemblyNameObject(void)
hi = 0xbeefcace;
lo = 0xcafebabe;
hr = IAssemblyName_GetVersion(name, &hi, &lo);
ok(hr == FUSION_E_INVALID_NAME,
ok(hr == FUSION_E_INVALID_NAME ||
broken(hr == S_OK), /* .NET 1.x */
"Expected FUSION_E_INVALID_NAME, got %08x\n", hr);
ok(hi == 0, "Expected 0, got %08x\n", hi);
ok(lo == 0, "Expected 0, got %08x\n", lo);
@ -694,10 +718,52 @@ static void test_CreateAssemblyNameObject(void)
IAssemblyName_Release(name);
/* invalid property */
to_widechar(namestr, "wine, BadProp=42");
name = NULL;
hr = pCreateAssemblyNameObject(&name, namestr, CANOF_PARSE_DISPLAY_NAME, NULL);
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
ok(name != NULL, "Expected non-NULL name\n");
size = MAX_PATH;
hr = IAssemblyName_GetDisplayName(name, str, &size, ASM_DISPLAYF_FULL);
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
todo_wine
{
ok_aw("wine", str);
ok(size == 5, "Expected 5, got %d\n", size);
}
size = MAX_PATH;
str[0] = '\0';
hr = IAssemblyName_GetName(name, &size, str);
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
ok_aw("wine", str);
ok(size == 5, "Expected 5, got %d\n", size);
hi = 0xbeefcace;
lo = 0xcafebabe;
hr = IAssemblyName_GetVersion(name, &hi, &lo);
ok(hr == FUSION_E_INVALID_NAME ||
broken(hr == S_OK), /* .NET 1.x */
"Expected FUSION_E_INVALID_NAME, got %08x\n", hr);
ok(hi == 0, "Expected 0, got %08x\n", hi);
ok(lo == 0, "Expected 0, got %08x\n", lo);
test_assembly_name_props(name, winename);
IAssemblyName_Release(name);
/* PublicKeyToken is not 16 chars long */
to_widechar(namestr, "wine, PublicKeyToken=567890abcdef");
name = (IAssemblyName *)0xdeadbeef;
hr = pCreateAssemblyNameObject(&name, namestr, CANOF_PARSE_DISPLAY_NAME, NULL);
if (hr == S_OK && name != (IAssemblyName *)0xdeadbeef)
{
win_skip(".NET 1.x doesn't check PublicKeyToken correctly\n");
IAssemblyName_Release(name);
return;
}
ok(hr == FUSION_E_INVALID_NAME,
"Expected FUSION_E_INVALID_NAME, got %08x\n", hr);
ok(name == (IAssemblyName *)0xdeadbeef, "Expected 0xdeadbeef, got %p\n", name);
@ -736,41 +802,6 @@ static void test_CreateAssemblyNameObject(void)
ok(hr == FUSION_E_INVALID_NAME,
"Expected FUSION_E_INVALID_NAME, got %08x\n", hr);
ok(name == (IAssemblyName *)0xdeadbeef, "Expected 0xdeadbeef, got %p\n", name);
/* invalid property */
to_widechar(namestr, "wine, BadProp=42");
name = NULL;
hr = pCreateAssemblyNameObject(&name, namestr, CANOF_PARSE_DISPLAY_NAME, NULL);
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
ok(name != NULL, "Expected non-NULL name\n");
size = MAX_PATH;
hr = IAssemblyName_GetDisplayName(name, str, &size, ASM_DISPLAYF_FULL);
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
todo_wine
{
ok_aw("wine", str);
ok(size == 5, "Expected 5, got %d\n", size);
}
size = MAX_PATH;
str[0] = '\0';
hr = IAssemblyName_GetName(name, &size, str);
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
ok_aw("wine", str);
ok(size == 5, "Expected 5, got %d\n", size);
hi = 0xbeefcace;
lo = 0xcafebabe;
hr = IAssemblyName_GetVersion(name, &hi, &lo);
ok(hr == FUSION_E_INVALID_NAME,
"Expected FUSION_E_INVALID_NAME, got %08x\n", hr);
ok(hi == 0, "Expected 0, got %08x\n", hi);
ok(lo == 0, "Expected 0, got %08x\n", lo);
test_assembly_name_props(name, winename);
IAssemblyName_Release(name);
}
START_TEST(asmname)

View file

@ -72,7 +72,7 @@ static void test_bitmap_info(HBITMAP hbm, INT expected_depth, const BITMAPINFOHE
BITMAP bm;
BITMAP bma[2];
INT ret, width_bytes;
char buf[512], buf_cmp[512];
BYTE buf[512], buf_cmp[512];
DWORD gle;
ret = GetObject(hbm, sizeof(bm), &bm);
@ -101,7 +101,9 @@ static void test_bitmap_info(HBITMAP hbm, INT expected_depth, const BITMAPINFOHE
memset(buf, 0xAA, sizeof(buf));
ret = GetBitmapBits(hbm, sizeof(buf), buf);
ok(ret == bm.bmWidthBytes * bm.bmHeight, "%d != %d\n", ret, bm.bmWidthBytes * bm.bmHeight);
ok(!memcmp(buf, buf_cmp, sizeof(buf)), "buffers do not match\n");
ok(!memcmp(buf, buf_cmp, sizeof(buf)) ||
broken(memcmp(buf, buf_cmp, sizeof(buf))), /* win9x doesn't init the bitmap bits */
"buffers do not match, depth %d\n", bmih->biBitCount);
/* test various buffer sizes for GetObject */
ret = GetObject(hbm, sizeof(*bma) * 2, bma);
@ -143,6 +145,11 @@ static void test_createdibitmap(void)
bmih.biBitCount = 32;
bmih.biCompression = BI_RGB;
hbm = CreateDIBitmap(hdc, NULL, CBM_INIT, NULL, NULL, 0);
ok(hbm == NULL, "CreateDIBitmap should fail\n");
hbm = CreateDIBitmap(hdc, NULL, 0, NULL, NULL, 0);
ok(hbm == NULL, "CreateDIBitmap should fail\n");
/* First create an un-initialised bitmap. The depth of the bitmap
should match that of the hdc and not that supplied in bmih.
*/
@ -339,7 +346,7 @@ static void test_dib_info(HBITMAP hbm, const void *bits, const BITMAPINFOHEADER
/* test various buffer sizes for GetObject */
ret = GetObject(hbm, 0, NULL);
ok(ret == sizeof(bm), "wrong size %d\n", ret);
ok(ret == sizeof(bm) || broken(ret == sizeof(DIBSECTION) /* Win9x */), "wrong size %d\n", ret);
ret = GetObject(hbm, sizeof(*dsa) * 2, dsa);
ok(ret == sizeof(*dsa) || broken(ret == sizeof(*dsa) * 2 /* Win9x */), "wrong size %d\n", ret);
@ -367,7 +374,7 @@ static void test_dib_info(HBITMAP hbm, const void *bits, const BITMAPINFOHEADER
memset(&ds, 0xAA, sizeof(ds));
ret = GetObject(hbm, sizeof(ds) - 4, &ds);
ok(ret == sizeof(ds.dsBm), "wrong size %d\n", ret);
ok(ret == sizeof(ds.dsBm) || broken(ret == (sizeof(ds) - 4) /* Win9x */), "wrong size %d\n", ret);
ok(ds.dsBm.bmWidth == bmih->biWidth, "%u != %u\n", ds.dsBmih.biWidth, bmih->biWidth);
ok(ds.dsBm.bmHeight == bmih->biHeight, "%u != %u\n", ds.dsBmih.biHeight, bmih->biHeight);
ok(ds.dsBm.bmBits == bits, "%p != %p\n", ds.dsBm.bmBits, bits);
@ -376,7 +383,7 @@ static void test_dib_info(HBITMAP hbm, const void *bits, const BITMAPINFOHEADER
ok(ret == 0, "%d != 0\n", ret);
ret = GetObject(hbm, 1, &ds);
ok(ret == 0, "%d != 0\n", ret);
ok(ret == 0 || broken(ret == 1 /* Win9x */), "%d != 0\n", ret);
}
#define test_color_todo(got, exp, txt, todo) \
@ -396,6 +403,64 @@ static void test_dib_info(HBITMAP hbm, const void *bits, const BITMAPINFOHEADER
test_color_todo(c, exp, GetPixel, todo_getp); \
}
static void test_dib_bits_access( HBITMAP hdib, void *bits )
{
MEMORY_BASIC_INFORMATION info;
char bmibuf[sizeof(BITMAPINFO) + 256 * sizeof(RGBQUAD)];
DWORD data[256];
BITMAPINFO *pbmi = (BITMAPINFO *)bmibuf;
HDC hdc = GetDC(0);
char filename[MAX_PATH];
HANDLE file;
DWORD written;
INT ret;
ok(VirtualQuery(bits, &info, sizeof(info)) == sizeof(info),
"VirtualQuery failed\n");
ok(info.BaseAddress == bits, "%p != %p\n", info.BaseAddress, bits);
ok(info.AllocationBase == bits, "%p != %p\n", info.AllocationBase, bits);
ok(info.AllocationProtect == PAGE_READWRITE, "%x != PAGE_READWRITE\n", info.AllocationProtect);
ok(info.State == MEM_COMMIT, "%x != MEM_COMMIT\n", info.State);
ok(info.Protect == PAGE_READWRITE, "%x != PAGE_READWRITE\n", info.Protect);
ok(info.Type == MEM_PRIVATE, "%x != MEM_PRIVATE\n", info.Type);
memset( pbmi, 0, sizeof(bmibuf) );
memset( data, 0xcc, sizeof(data) );
pbmi->bmiHeader.biSize = sizeof(pbmi->bmiHeader);
pbmi->bmiHeader.biHeight = 16;
pbmi->bmiHeader.biWidth = 16;
pbmi->bmiHeader.biBitCount = 32;
pbmi->bmiHeader.biPlanes = 1;
pbmi->bmiHeader.biCompression = BI_RGB;
ret = SetDIBits( hdc, hdib, 0, 16, data, pbmi, DIB_RGB_COLORS );
ok(ret == 16 ||
broken(ret == 0), /* win9x */
"SetDIBits failed: expected 16 got %d\n", ret);
ok(VirtualQuery(bits, &info, sizeof(info)) == sizeof(info),
"VirtualQuery failed\n");
ok(info.BaseAddress == bits, "%p != %p\n", info.BaseAddress, bits);
ok(info.AllocationBase == bits, "%p != %p\n", info.AllocationBase, bits);
ok(info.AllocationProtect == PAGE_READWRITE, "%x != PAGE_READWRITE\n", info.AllocationProtect);
ok(info.State == MEM_COMMIT, "%x != MEM_COMMIT\n", info.State);
ok(info.Type == MEM_PRIVATE, "%x != MEM_PRIVATE\n", info.Type);
/* it has been protected now */
todo_wine ok(info.Protect == PAGE_READWRITE, "%x != PAGE_READWRITE\n", info.Protect);
/* try writing protected bits to a file */
GetTempFileNameA( ".", "dib", 0, filename );
file = CreateFileA( filename, GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL,
CREATE_ALWAYS, 0, 0 );
ok( file != INVALID_HANDLE_VALUE, "failed to open %s error %u\n", filename, GetLastError() );
ret = WriteFile( file, bits, 8192, &written, NULL );
ok( ret, "WriteFile failed error %u\n", GetLastError() );
if (ret) ok( written == 8192, "only wrote %u bytes\n", written );
CloseHandle( file );
DeleteFileA( filename );
}
static void test_dibsections(void)
{
HDC hdc, hdcmem, hdcmem2;
@ -455,6 +520,8 @@ static void test_dibsections(void)
ok(info.Protect == PAGE_READWRITE, "%x != PAGE_READWRITE\n", info.Protect);
ok(info.Type == MEM_PRIVATE, "%x != MEM_PRIVATE\n", info.Type);
test_dib_bits_access( hdib, bits );
test_dib_info(hdib, bits, &pbmi->bmiHeader);
DeleteObject(hdib);
@ -658,7 +725,8 @@ static void test_dibsections(void)
hdib = CreateDIBSection(hdc, pbmi, DIB_PAL_COLORS, (void**)&bits, NULL, 0);
ok(hdib != NULL, "CreateDIBSection failed\n");
ok(GetObject(hdib, sizeof(DIBSECTION), &dibsec) != 0, "GetObject failed for DIB Section\n");
ok(dibsec.dsBmih.biClrUsed == 2,
ok(dibsec.dsBmih.biClrUsed == 2 ||
broken(dibsec.dsBmih.biClrUsed == 0), /* win9x */
"created DIBSection: wrong biClrUsed field: %u, should be: %u\n", dibsec.dsBmih.biClrUsed, 2);
/* The colour table has already been grabbed from the dc, so we select back the
@ -750,7 +818,8 @@ static void test_dibsections(void)
hdib = CreateDIBSection(hdc, pbmi, DIB_PAL_COLORS, (void**)&bits, NULL, 0);
ok(hdib != NULL, "CreateDIBSection failed\n");
ok(GetObject(hdib, sizeof(DIBSECTION), &dibsec) != 0, "GetObject failed for DIB Section\n");
ok(dibsec.dsBmih.biClrUsed == 256,
ok(dibsec.dsBmih.biClrUsed == 256 ||
broken(dibsec.dsBmih.biClrUsed == 0), /* win9x */
"created DIBSection: wrong biClrUsed field: %u, should be: %u\n", dibsec.dsBmih.biClrUsed, 256);
test_dib_info(hdib, bits, &pbmi->bmiHeader);
@ -1018,9 +1087,12 @@ static void test_bitmap(void)
SetLastError(0xdeadbeef);
hbmp = CreateBitmap(0x7ffffff + 1, 1, 1, 1, NULL);
ok(!hbmp, "CreateBitmap should fail\n");
ok(!hbmp || broken(hbmp != NULL /* Win9x */), "CreateBitmap should fail\n");
if (!hbmp)
ok(GetLastError() == ERROR_INVALID_PARAMETER,
"expected ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
else
DeleteObject(hbmp);
hbmp = CreateBitmap(15, 15, 1, 1, NULL);
assert(hbmp != NULL);
@ -1040,7 +1112,8 @@ static void test_bitmap(void)
assert(sizeof(buf) == sizeof(buf_cmp));
ret = GetBitmapBits(hbmp, 0, NULL);
ok(ret == bm.bmWidthBytes * bm.bmHeight, "%d != %d\n", ret, bm.bmWidthBytes * bm.bmHeight);
ok(ret == bm.bmWidthBytes * bm.bmHeight || broken(ret == 0 /* Win9x */),
"%d != %d\n", ret, bm.bmWidthBytes * bm.bmHeight);
memset(buf_cmp, 0xAA, sizeof(buf_cmp));
memset(buf_cmp, 0, bm.bmWidthBytes * bm.bmHeight);
@ -1048,7 +1121,9 @@ static void test_bitmap(void)
memset(buf, 0xAA, sizeof(buf));
ret = GetBitmapBits(hbmp, sizeof(buf), buf);
ok(ret == bm.bmWidthBytes * bm.bmHeight, "%d != %d\n", ret, bm.bmWidthBytes * bm.bmHeight);
ok(!memcmp(buf, buf_cmp, sizeof(buf)), "buffers do not match\n");
ok(!memcmp(buf, buf_cmp, sizeof(buf)) ||
broken(memcmp(buf, buf_cmp, sizeof(buf))), /* win9x doesn't init the bitmap bits */
"buffers do not match\n");
hbmp_old = SelectObject(hdc, hbmp);
@ -1066,7 +1141,9 @@ static void test_bitmap(void)
memset(buf, 0xAA, sizeof(buf));
ret = GetBitmapBits(hbmp, sizeof(buf), buf);
ok(ret == bm.bmWidthBytes * bm.bmHeight, "%d != %d\n", ret, bm.bmWidthBytes * bm.bmHeight);
ok(!memcmp(buf, buf_cmp, sizeof(buf)), "buffers do not match\n");
ok(!memcmp(buf, buf_cmp, sizeof(buf)) ||
broken(memcmp(buf, buf_cmp, sizeof(buf))), /* win9x doesn't init the bitmap bits */
"buffers do not match\n");
hbmp_old = SelectObject(hdc, hbmp_old);
ok(hbmp_old == hbmp, "wrong old bitmap %p\n", hbmp_old);
@ -1323,6 +1400,8 @@ static void test_GetDIBits_selected_DDB(BOOL monochrome)
/* Get the palette indices */
res = GetDIBits(dc, ddb, 0, 0, NULL, info2, DIB_PAL_COLORS);
if (res == 0 && GetLastError() == ERROR_INVALID_PARAMETER) /* Win9x */
res = GetDIBits(dc, ddb, 0, height, NULL, info2, DIB_PAL_COLORS);
ok(res, "GetDIBits failed\n");
for (i=0;i < 1 << info->bmiHeader.biSizeImage; i++)
@ -1367,6 +1446,13 @@ static void test_GetDIBits(void)
0,0,0,0, 0xff,0xff,0,0, 0,0,0,0, 0xff,0xff,0,0,
0,0,0,0, 0xff,0xff,0,0, 0,0,0,0, 0xff,0xff,0,0
};
static const BYTE dib_bits_1_9x[16 * 4] =
{
0,0,0xaa,0xaa, 0xff,0xff,0xaa,0xaa, 0,0,0xaa,0xaa, 0xff,0xff,0xaa,0xaa,
0,0,0xaa,0xaa, 0xff,0xff,0xaa,0xaa, 0,0,0xaa,0xaa, 0xff,0xff,0xaa,0xaa,
0,0,0xaa,0xaa, 0xff,0xff,0xaa,0xaa, 0,0,0xaa,0xaa, 0xff,0xff,0xaa,0xaa,
0,0,0xaa,0xaa, 0xff,0xff,0xaa,0xaa, 0,0,0xaa,0xaa, 0xff,0xff,0xaa,0xaa
};
/* 2-bytes aligned 24-bit bitmap data: 16x16 */
static const BYTE bmp_bits_24[16 * 16*3] =
{
@ -1465,7 +1551,7 @@ static void test_GetDIBits(void)
ok(!bm.bmBits, "wrong bmBits %p\n", bm.bmBits);
bytes = GetBitmapBits(hbmp, 0, NULL);
ok(bytes == sizeof(bmp_bits_1), "expected 16*2 got %d bytes\n", bytes);
ok(bytes == sizeof(bmp_bits_1) || broken(bytes == 0 /* Win9x */), "expected 16*2 got %d bytes\n", bytes);
bytes = GetBitmapBits(hbmp, sizeof(buf), buf);
ok(bytes == sizeof(bmp_bits_1), "expected 16*2 got %d bytes\n", bytes);
ok(!memcmp(buf, bmp_bits_1, sizeof(bmp_bits_1)), "bitmap bits don't match\n");
@ -1483,7 +1569,9 @@ static void test_GetDIBits(void)
SetLastError(0xdeadbeef);
lines = GetDIBits(0, hbmp, 0, bm.bmHeight, buf, bi, DIB_RGB_COLORS);
ok(lines == 0, "GetDIBits copied %d lines with hdc = 0\n", lines);
ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError());
ok(GetLastError() == ERROR_INVALID_PARAMETER ||
broken(GetLastError() == 0xdeadbeef), /* winnt */
"wrong error %u\n", GetLastError());
ok(bi->bmiHeader.biSizeImage == 0, "expected 0, got %u\n", bi->bmiHeader.biSizeImage);
memset(buf, 0xAA, sizeof(buf));
@ -1491,7 +1579,9 @@ static void test_GetDIBits(void)
lines = GetDIBits(hdc, hbmp, 0, bm.bmHeight, buf, bi, DIB_RGB_COLORS);
ok(lines == bm.bmHeight, "GetDIBits copied %d lines of %d, error %u\n",
lines, bm.bmHeight, GetLastError());
ok(bi->bmiHeader.biSizeImage == sizeof(dib_bits_1), "expected 16*4, got %u\n", bi->bmiHeader.biSizeImage);
ok(bi->bmiHeader.biSizeImage == sizeof(dib_bits_1) ||
broken(bi->bmiHeader.biSizeImage == 0), /* win9x */
"expected 16*4, got %u\n", bi->bmiHeader.biSizeImage);
/* the color table consists of black and white */
ok(bi->bmiColors[0].rgbRed == 0 && bi->bmiColors[0].rgbGreen == 0 &&
@ -1514,16 +1604,21 @@ static void test_GetDIBits(void)
}
/* returned bits are DWORD aligned and upside down */
todo_wine
ok(!memcmp(buf, dib_bits_1, sizeof(dib_bits_1)), "DIB bits don't match\n");
ok(!memcmp(buf, dib_bits_1, sizeof(dib_bits_1)) ||
broken(!memcmp(buf, dib_bits_1_9x, sizeof(dib_bits_1_9x))), /* Win9x, WinME */
"DIB bits don't match\n");
/* Test the palette indices */
memset(bi->bmiColors, 0xAA, sizeof(RGBQUAD) * 256);
SetLastError(0xdeadbeef);
lines = GetDIBits(hdc, hbmp, 0, 0, NULL, bi, DIB_PAL_COLORS);
if (lines == 0 && GetLastError() == ERROR_INVALID_PARAMETER)
win_skip("Win9x/WinMe doesn't handle 0 for the number of scan lines\n");
else
{
ok(((WORD*)bi->bmiColors)[0] == 0, "Color 0 is %d\n", ((WORD*)bi->bmiColors)[0]);
ok(((WORD*)bi->bmiColors)[1] == 1, "Color 1 is %d\n", ((WORD*)bi->bmiColors)[1]);
}
for (i = 2; i < 256; i++)
ok(((WORD*)bi->bmiColors)[i] == 0xAAAA, "Color %d is %d\n", i, ((WORD*)bi->bmiColors)[1]);
@ -1542,7 +1637,9 @@ todo_wine
lines = GetDIBits(hdc, hbmp, 0, bm.bmHeight, buf, bi, DIB_RGB_COLORS);
ok(lines == bm.bmHeight, "GetDIBits copied %d lines of %d, error %u\n",
lines, bm.bmHeight, GetLastError());
ok(bi->bmiHeader.biSizeImage == sizeof(dib_bits_24), "expected 16*16*3, got %u\n", bi->bmiHeader.biSizeImage);
ok(bi->bmiHeader.biSizeImage == sizeof(dib_bits_24) ||
broken(bi->bmiHeader.biSizeImage == 0), /* win9x */
"expected 16*16*3, got %u\n", bi->bmiHeader.biSizeImage);
/* the color table doesn't exist for 24-bit images */
for (i = 0; i < 256; i++)
@ -1570,7 +1667,9 @@ todo_wine
memset(&bm, 0xAA, sizeof(bm));
bytes = GetObject(hbmp, sizeof(bm), &bm);
ok(bytes == sizeof(bm), "GetObject returned %d\n", bytes);
ok(bm.bmType == 0, "wrong bmType %d\n", bm.bmType);
ok(bm.bmType == 0 ||
broken(bm.bmType == 21072), /* win9x */
"wrong bmType %d\n", bm.bmType);
ok(bm.bmWidth == 16, "wrong bmWidth %d\n", bm.bmWidth);
ok(bm.bmHeight == 16, "wrong bmHeight %d\n", bm.bmHeight);
ok(bm.bmWidthBytes == BITMAP_GetWidthBytes(bm.bmWidth, bm.bmBitsPixel), "wrong bmWidthBytes %d\n", bm.bmWidthBytes);
@ -1579,8 +1678,9 @@ todo_wine
ok(!bm.bmBits, "wrong bmBits %p\n", bm.bmBits);
bytes = GetBitmapBits(hbmp, 0, NULL);
ok(bytes == bm.bmWidthBytes * bm.bmHeight, "expected %d got %d bytes\n",
bm.bmWidthBytes * bm.bmHeight, bytes);
ok(bytes == bm.bmWidthBytes * bm.bmHeight ||
broken(bytes == 0), /* win9x */
"expected %d got %d bytes\n", bm.bmWidthBytes * bm.bmHeight, bytes);
bytes = GetBitmapBits(hbmp, sizeof(buf), buf);
ok(bytes == bm.bmWidthBytes * bm.bmHeight, "expected %d got %d bytes\n",
bm.bmWidthBytes * bm.bmHeight, bytes);
@ -1600,7 +1700,9 @@ todo_wine
lines = GetDIBits(hdc, hbmp, 0, bm.bmHeight, buf, bi, DIB_RGB_COLORS);
ok(lines == bm.bmHeight, "GetDIBits copied %d lines of %d, error %u\n",
lines, bm.bmHeight, GetLastError());
ok(bi->bmiHeader.biSizeImage == sizeof(dib_bits_1), "expected 16*4, got %u\n", bi->bmiHeader.biSizeImage);
ok(bi->bmiHeader.biSizeImage == sizeof(dib_bits_1) ||
broken(bi->bmiHeader.biSizeImage == 0), /* win9x */
"expected 16*4, got %u\n", bi->bmiHeader.biSizeImage);
/* the color table consists of black and white */
ok(bi->bmiColors[0].rgbRed == 0 && bi->bmiColors[0].rgbGreen == 0 &&
@ -1624,15 +1726,21 @@ todo_wine
/* returned bits are DWORD aligned and upside down */
todo_wine
ok(!memcmp(buf, dib_bits_1, sizeof(dib_bits_1)), "DIB bits don't match\n");
ok(!memcmp(buf, dib_bits_1, sizeof(dib_bits_1)) ||
broken(!memcmp(buf, dib_bits_1_9x, sizeof(dib_bits_1_9x))), /* Win9x, WinME */
"DIB bits don't match\n");
/* Test the palette indices */
memset(bi->bmiColors, 0xAA, sizeof(RGBQUAD) * 256);
SetLastError(0xdeadbeef);
lines = GetDIBits(hdc, hbmp, 0, 0, NULL, bi, DIB_PAL_COLORS);
if (lines == 0 && GetLastError() == ERROR_INVALID_PARAMETER)
win_skip("Win9x/WinMe doesn't handle 0 for the number of scan lines\n");
else
{
ok(((WORD*)bi->bmiColors)[0] == 0, "Color 0 is %d\n", ((WORD*)bi->bmiColors)[0]);
ok(((WORD*)bi->bmiColors)[1] == 1, "Color 1 is %d\n", ((WORD*)bi->bmiColors)[1]);
}
for (i = 2; i < 256; i++)
ok(((WORD*)bi->bmiColors)[i] == 0xAAAA, "Color %d is %d\n", i, ((WORD*)bi->bmiColors)[i]);
@ -1651,7 +1759,9 @@ todo_wine
lines = GetDIBits(hdc, hbmp, 0, bm.bmHeight, buf, bi, DIB_RGB_COLORS);
ok(lines == bm.bmHeight, "GetDIBits copied %d lines of %d, error %u\n",
lines, bm.bmHeight, GetLastError());
ok(bi->bmiHeader.biSizeImage == sizeof(dib_bits_24), "expected 16*16*3, got %u\n", bi->bmiHeader.biSizeImage);
ok(bi->bmiHeader.biSizeImage == sizeof(dib_bits_24) ||
broken(bi->bmiHeader.biSizeImage == 0), /* win9x */
"expected 16*16*3, got %u\n", bi->bmiHeader.biSizeImage);
/* the color table doesn't exist for 24-bit images */
for (i = 0; i < 256; i++)
@ -1731,7 +1841,9 @@ static void test_GetDIBits_BI_BITFIELDS(void)
ok( bitmasks[0] != 0, "red mask is not set\n" );
ok( bitmasks[1] != 0, "green mask is not set\n" );
ok( bitmasks[2] != 0, "blue mask is not set\n" );
ok( dibinfo->bmiHeader.biSizeImage != 0xdeadbeef, "size image not set\n" );
ok( dibinfo->bmiHeader.biSizeImage != 0xdeadbeef ||
broken(dibinfo->bmiHeader.biSizeImage == 0xdeadbeef), /* win9x */
"size image not set\n" );
/* now with bits and 0 lines */
memset(dibinfo, 0, sizeof(dibinfo_buf));
@ -1834,7 +1946,9 @@ static void test_select_object(void)
memset(&bm, 0xAA, sizeof(bm));
bytes = GetObject(hbm, sizeof(bm), &bm);
ok(bytes == sizeof(bm), "GetObject returned %d\n", bytes);
ok(bm.bmType == 0, "wrong bmType %d\n", bm.bmType);
ok(bm.bmType == 0 ||
broken(bm.bmType == 21072), /* win9x */
"wrong bmType %d\n", bm.bmType);
ok(bm.bmWidth == 10, "wrong bmWidth %d\n", bm.bmWidth);
ok(bm.bmHeight == 10, "wrong bmHeight %d\n", bm.bmHeight);
ok(bm.bmWidthBytes == BITMAP_GetWidthBytes(bm.bmWidth, bm.bmBitsPixel), "wrong bmWidthBytes %d\n", bm.bmWidthBytes);
@ -1910,7 +2024,9 @@ static void test_CreateBitmap(void)
"0: %p, 1: %p, 4: %p, 5: %p, curObj1 %p, old1 %p\n",
bm, bm1, bm4, bm5, curObj1, old1);
ok(bm != bm2 && bm != bm3, "0: %p, 2: %p, 3: %p\n", bm, bm2, bm3);
ok(bm != curObj2 /* XP */ || bm == curObj2 /* Win9x */,
todo_wine
ok(bm != curObj2 || /* WinXP */
broken(bm == curObj2) /* Win9x */,
"0: %p, curObj2 %p\n", bm, curObj2);
ok(old2 == 0, "old2 %p\n", old2);
@ -1922,7 +2038,6 @@ static void test_CreateBitmap(void)
test_mono_1x1_bmp(bm5);
test_mono_1x1_bmp(old1);
test_mono_1x1_bmp(curObj1);
test_mono_1x1_bmp(curObj2);
DeleteObject(bm);
DeleteObject(bm1);
@ -1956,11 +2071,17 @@ static void test_CreateBitmap(void)
bmp.bmPlanes = 1;
bmp.bmBitsPixel = i;
bmp.bmBits = NULL;
SetLastError(0xdeadbeef);
bm = CreateBitmapIndirect(&bmp);
if(i > 32) {
DWORD error = GetLastError();
ok(bm == 0, "CreateBitmapIndirect for %d bpp succeeded\n", i);
ok(error == ERROR_INVALID_PARAMETER, "Got error %d, expected ERROR_INVALID_PARAMETER\n", error);
ok(bm == 0 ||
broken(bm != 0), /* Win9x and WinMe */
"CreateBitmapIndirect for %d bpp succeeded\n", i);
ok(error == ERROR_INVALID_PARAMETER ||
broken(error == 0xdeadbeef), /* Win9x and WinME */
"Got error %d, expected ERROR_INVALID_PARAMETER\n", error);
DeleteObject(bm);
continue;
}
ok(bm != 0, "CreateBitmapIndirect error %u\n", GetLastError());
@ -1978,7 +2099,9 @@ static void test_CreateBitmap(void)
} else if(i <= 32) {
expect = 32;
}
ok(bmp.bmBitsPixel == expect, "CreateBitmapIndirect for a %d bpp bitmap created a %d bpp bitmap, expected %d\n",
ok(bmp.bmBitsPixel == expect ||
broken(bmp.bmBitsPixel == i), /* Win9x and WinMe */
"CreateBitmapIndirect for a %d bpp bitmap created a %d bpp bitmap, expected %d\n",
i, bmp.bmBitsPixel, expect);
DeleteObject(bm);
}
@ -2013,21 +2136,27 @@ static void test_bitmapinfoheadersize(void)
SetLastError(0xdeadbeef);
hdib = CreateDIBSection(hdc, &bmi, 0, NULL, NULL, 0);
ok(hdib != NULL, "CreateDIBSection error %d\n", GetLastError());
ok(hdib != NULL ||
broken(!hdib), /* Win98, WinMe */
"CreateDIBSection error %d\n", GetLastError());
DeleteObject(hdib);
bmi.bmiHeader.biSize = sizeof(BITMAPINFO);
SetLastError(0xdeadbeef);
hdib = CreateDIBSection(hdc, &bmi, 0, NULL, NULL, 0);
ok(hdib != NULL, "CreateDIBSection error %d\n", GetLastError());
ok(hdib != NULL ||
broken(!hdib), /* Win98, WinMe */
"CreateDIBSection error %d\n", GetLastError());
DeleteObject(hdib);
bmi.bmiHeader.biSize++;
SetLastError(0xdeadbeef);
hdib = CreateDIBSection(hdc, &bmi, 0, NULL, NULL, 0);
ok(hdib != NULL, "CreateDIBSection error %d\n", GetLastError());
ok(hdib != NULL ||
broken(!hdib), /* Win98, WinMe */
"CreateDIBSection error %d\n", GetLastError());
DeleteObject(hdib);
bmi.bmiHeader.biSize = sizeof(BITMAPV4HEADER);
@ -2041,7 +2170,9 @@ static void test_bitmapinfoheadersize(void)
SetLastError(0xdeadbeef);
hdib = CreateDIBSection(hdc, &bmi, 0, NULL, NULL, 0);
ok(hdib != NULL, "CreateDIBSection error %d\n", GetLastError());
ok(hdib != NULL ||
broken(!hdib), /* Win95 */
"CreateDIBSection error %d\n", GetLastError());
DeleteObject(hdib);
memset(&bci, 0, sizeof(BITMAPCOREINFO));
@ -2103,7 +2234,9 @@ static void test_get16dibits(void)
info->bmiHeader.biCompression = BI_RGB;
ret = GetDIBits(screen_dc, hbmp, 0, 0, NULL, info, 0);
ok(ret != 0, "GetDIBits failed\n");
ok(ret != 0 ||
broken(ret == 0), /* win9x */
"GetDIBits failed got %d\n", ret);
for (p = ((BYTE *) info) + sizeof(info->bmiHeader); (p - ((BYTE *) info)) < info_len; p++)
if (*p != '!')
@ -2115,7 +2248,7 @@ static void test_get16dibits(void)
ReleaseDC(NULL, screen_dc);
}
void test_GdiAlphaBlend()
static void test_GdiAlphaBlend(void)
{
/* test out-of-bound parameters for GdiAlphaBlend */
HDC hdcNull;
@ -2134,7 +2267,7 @@ void test_GdiAlphaBlend()
if (!pGdiAlphaBlend)
{
skip("GdiAlphaBlend() is not implemented\n");
win_skip("GdiAlphaBlend() is not implemented\n");
return;
}

View file

@ -162,12 +162,16 @@ static void verify_region(HRGN hrgn, const RECT *rc)
if (IsRectEmpty(rc))
{
ok(rgn.data.rdh.nCount == 0, "expected 0, got %u\n", rgn.data.rdh.nCount);
ok(rgn.data.rdh.nRgnSize == 0, "expected 0, got %u\n", rgn.data.rdh.nRgnSize);
ok(rgn.data.rdh.nRgnSize == 0 ||
broken(rgn.data.rdh.nRgnSize == 168), /* NT4 */
"expected 0, got %u\n", rgn.data.rdh.nRgnSize);
}
else
{
ok(rgn.data.rdh.nCount == 1, "expected 1, got %u\n", rgn.data.rdh.nCount);
ok(rgn.data.rdh.nRgnSize == sizeof(RECT), "expected sizeof(RECT), got %u\n", rgn.data.rdh.nRgnSize);
ok(rgn.data.rdh.nRgnSize == sizeof(RECT) ||
broken(rgn.data.rdh.nRgnSize == 168), /* NT4 */
"expected sizeof(RECT), got %u\n", rgn.data.rdh.nRgnSize);
}
ok(EqualRect(&rgn.data.rdh.rcBound, rc), "rects don't match\n");
}
@ -236,9 +240,14 @@ if (0) /* crashes under Win9x */
SetLastError(0xdeadbeef);
hrgn = ExtCreateRegion(NULL, 1, &rgn.data);
ok(hrgn != 0, "ExtCreateRegion error %u\n", GetLastError());
ok(hrgn != 0 ||
broken(GetLastError() == 0xdeadbeef), /* NT4 */
"ExtCreateRegion error %u\n", GetLastError());
if(hrgn)
{
verify_region(hrgn, &rc);
DeleteObject(hrgn);
}
xform.eM11 = 0.5; /* 50% width */
xform.eM12 = 0.0;

View file

@ -185,7 +185,7 @@ static void test_GdiConvertToDevmodeW(void)
pGdiConvertToDevmodeW = (void *)GetProcAddress(GetModuleHandleA("gdi32.dll"), "GdiConvertToDevmodeW");
if (!pGdiConvertToDevmodeW)
{
skip("GdiConvertToDevmodeW is not available on this platform\n");
win_skip("GdiConvertToDevmodeW is not available on this platform\n");
return;
}
@ -253,10 +253,86 @@ static void test_CreateCompatibleDC(void)
ok(hNewDC == NULL, "CreateCompatibleDC returned %p\n", hNewDC);
}
static void test_DC_bitmap(void)
{
HDC hdc, hdcmem;
DWORD bits[64];
HBITMAP hbmp, oldhbmp;
COLORREF col;
int i, bitspixel;
/* fill bitmap data with b&w pattern */
for( i = 0; i < 64; i++) bits[i] = i & 1 ? 0 : 0xffffff;
hdc = GetDC(0);
ok( hdc != NULL, "CreateDC rets %p\n", hdc);
bitspixel = GetDeviceCaps( hdc, BITSPIXEL);
/* create a memory dc */
hdcmem = CreateCompatibleDC( hdc);
ok( hdcmem != NULL, "CreateCompatibleDC rets %p\n", hdcmem);
/* tests */
/* test monochrome bitmap: should always work */
hbmp = CreateBitmap(32, 32, 1, 1, bits);
ok( hbmp != NULL, "CreateBitmap returns %p\n", hbmp);
oldhbmp = SelectObject( hdcmem, hbmp);
ok( oldhbmp != NULL, "SelectObject returned NULL\n" ); /* a memdc always has a bitmap selected */
col = GetPixel( hdcmem, 0, 0);
ok( col == 0xffffff, "GetPixel returned %08x, expected 00ffffff\n", col);
col = GetPixel( hdcmem, 1, 1);
ok( col == 0x000000, "GetPixel returned %08x, expected 00000000\n", col);
col = GetPixel( hdcmem, 100, 1);
ok( col == CLR_INVALID, "GetPixel returned %08x, expected ffffffff\n", col);
SelectObject( hdcmem, oldhbmp);
DeleteObject( hbmp);
/* test with 2 bits color depth, not likely to succeed */
hbmp = CreateBitmap(16, 16, 1, 2, bits);
ok( hbmp != NULL, "CreateBitmap returns %p\n", hbmp);
oldhbmp = SelectObject( hdcmem, hbmp);
if( bitspixel != 2)
ok( !oldhbmp, "SelectObject of a bitmap with 2 bits/pixel should return NULL\n");
if( oldhbmp) SelectObject( hdcmem, oldhbmp);
DeleteObject( hbmp);
/* test with 16 bits color depth, might succeed */
hbmp = CreateBitmap(6, 6, 1, 16, bits);
ok( hbmp != NULL, "CreateBitmap returns %p\n", hbmp);
oldhbmp = SelectObject( hdcmem, hbmp);
if( bitspixel == 16) {
ok( oldhbmp != NULL, "SelectObject returned NULL\n" );
col = GetPixel( hdcmem, 0, 0);
ok( col == 0xffffff,
"GetPixel of a bitmap with 16 bits/pixel returned %08x, expected 00ffffff\n", col);
col = GetPixel( hdcmem, 1, 1);
ok( col == 0x000000,
"GetPixel of a bitmap with 16 bits/pixel returned returned %08x, expected 00000000\n", col);
}
if( oldhbmp) SelectObject( hdcmem, oldhbmp);
DeleteObject( hbmp);
/* test with 32 bits color depth, probably succeed */
hbmp = CreateBitmap(4, 4, 1, 32, bits);
ok( hbmp != NULL, "CreateBitmap returns %p\n", hbmp);
oldhbmp = SelectObject( hdcmem, hbmp);
if( bitspixel == 32) {
ok( oldhbmp != NULL, "SelectObject returned NULL\n" );
col = GetPixel( hdcmem, 0, 0);
ok( col == 0xffffff,
"GetPixel of a bitmap with 32 bits/pixel returned %08x, expected 00ffffff\n", col);
col = GetPixel( hdcmem, 1, 1);
ok( col == 0x000000,
"GetPixel of a bitmap with 32 bits/pixel returned returned %08x, expected 00000000\n", col);
}
if( oldhbmp) SelectObject( hdcmem, oldhbmp);
DeleteObject( hbmp);
ReleaseDC( 0, hdc );
}
START_TEST(dc)
{
test_savedc();
test_savedc_2();
test_GdiConvertToDevmodeW();
test_CreateCompatibleDC();
test_DC_bitmap();
}

File diff suppressed because it is too large Load diff

View file

@ -110,7 +110,7 @@ struct hgdiobj_event
static DWORD WINAPI thread_proc(void *param)
{
LOGPEN lp;
struct hgdiobj_event *hgdiobj_event = (struct hgdiobj_event *)param;
struct hgdiobj_event *hgdiobj_event = param;
hgdiobj_event->hdc = CreateDC("display", NULL, NULL, NULL);
ok(hgdiobj_event->hdc != NULL, "CreateDC error %u\n", GetLastError());

File diff suppressed because it is too large Load diff

View file

@ -39,7 +39,7 @@ static void test_GetICMProfileA( HDC dc )
ret = GetICMProfileA( NULL, NULL, NULL );
if ( !ret && ( GetLastError() == ERROR_CALL_NOT_IMPLEMENTED ) )
{
skip( "GetICMProfileA is not implemented\n" );
win_skip( "GetICMProfileA is not implemented\n" );
return;
}
ok( !ret, "GetICMProfileA succeeded\n" );
@ -91,7 +91,7 @@ static void test_GetICMProfileW( HDC dc )
ret = GetICMProfileW( NULL, NULL, NULL );
if ( !ret && ( GetLastError() == ERROR_CALL_NOT_IMPLEMENTED ) )
{
skip( "GetICMProfileW is not implemented\n" );
win_skip( "GetICMProfileW is not implemented\n" );
return;
}
ok( !ret, "GetICMProfileW succeeded\n" );
@ -136,7 +136,7 @@ static void test_SetICMMode( HDC dc )
impl = GetICMProfileA( NULL, NULL, NULL );
if ( !impl && ( GetLastError() == ERROR_CALL_NOT_IMPLEMENTED ) )
{
skip( "On NT4 where SetICMMode is not implemented but this is not advertised\n" );
win_skip( "On NT4 where SetICMMode is not implemented but this is not advertised\n" );
return;
}
@ -165,7 +165,7 @@ static void test_SetICMMode( HDC dc )
dc = CreateDCW( displayW, NULL, NULL, NULL );
if ( !dc && ( GetLastError() == ERROR_CALL_NOT_IMPLEMENTED ) )
{
skip( "CreateDCW is not implemented\n" );
win_skip( "CreateDCW is not implemented\n" );
return;
}
ok( dc != NULL, "CreateDCW failed (%d)\n", GetLastError() );

View file

@ -75,8 +75,9 @@ static void test_world_transform(void)
{
BOOL is_win9x;
HDC hdc;
INT ret, size_cx, size_cy, res_x, res_y;
INT ret, size_cx, size_cy, res_x, res_y, dpi_x, dpi_y;
XFORM xform;
SIZE size;
SetLastError(0xdeadbeef);
GetWorldTransform(0, NULL);
@ -84,11 +85,23 @@ static void test_world_transform(void)
hdc = CreateCompatibleDC(0);
xform.eM11 = 1.0f;
xform.eM12 = 0.0f;
xform.eM21 = 0.0f;
xform.eM22 = 1.0f;
xform.eDx = 0.0f;
xform.eDy = 0.0f;
ret = SetWorldTransform(hdc, &xform);
ok(!ret, "SetWorldTransform should fail in GM_COMPATIBLE mode\n");
size_cx = GetDeviceCaps(hdc, HORZSIZE);
size_cy = GetDeviceCaps(hdc, VERTSIZE);
res_x = GetDeviceCaps(hdc, HORZRES);
res_y = GetDeviceCaps(hdc, VERTRES);
trace("dc size %d x %d, resolution %d x %d\n", size_cx, size_cy, res_x, res_y);
dpi_x = GetDeviceCaps(hdc, LOGPIXELSX);
dpi_y = GetDeviceCaps(hdc, LOGPIXELSY);
trace("dc size %d x %d, resolution %d x %d dpi %d x %d\n",
size_cx, size_cy, res_x, res_y, dpi_x, dpi_y );
expect_viewport_ext(hdc, 1, 1);
expect_window_ext(hdc, 1, 1);
@ -101,13 +114,19 @@ static void test_world_transform(void)
if (is_win9x)
{
expect_viewport_ext(hdc, GetDeviceCaps(hdc, LOGPIXELSX), GetDeviceCaps(hdc, LOGPIXELSY));
expect_viewport_ext(hdc, dpi_x, dpi_y);
expect_window_ext(hdc, 254, -254);
}
else
{
expect_viewport_ext(hdc, res_x, -res_y);
expect_window_ext(hdc, size_cx * 10, size_cy * 10);
ok( GetWindowExtEx( hdc, &size ), "GetWindowExtEx failed\n" );
ok( size.cx == size_cx * 10 ||
size.cx == MulDiv( res_x, 254, dpi_x ), /* Vista uses a more precise method */
"expected cx %d or %d, got %d\n", size_cx * 10, MulDiv( res_x, 254, dpi_x ), size.cx );
ok( size.cy == size_cy * 10 ||
size.cy == MulDiv( res_y, 254, dpi_y ), /* Vista uses a more precise method */
"expected cy %d or %d, got %d\n", size_cy * 10, MulDiv( res_y, 254, dpi_y ), size.cy );
}
expect_world_trasform(hdc, 1.0, 1.0);
expect_LPtoDP(hdc, MulDiv(1000 / 10, res_x, size_cx), -MulDiv(1000 / 10, res_y, size_cy));
@ -134,6 +153,18 @@ static void test_world_transform(void)
expect_world_trasform(hdc, 1.0, 1.0);
expect_LPtoDP(hdc, 1000, 1000);
/* The transform must conform to (eM11 * eM22 != eM12 * eM21) requirement */
xform.eM11 = 1.0f;
xform.eM12 = 2.0f;
xform.eM21 = 1.0f;
xform.eM22 = 2.0f;
xform.eDx = 0.0f;
xform.eDy = 0.0f;
ret = SetWorldTransform(hdc, &xform);
ok(!ret ||
broken(ret), /* NT4 */
"SetWorldTransform should fail with an invalid xform\n");
xform.eM11 = 20.0f;
xform.eM12 = 0.0f;
xform.eM21 = 0.0f;
@ -154,9 +185,15 @@ static void test_world_transform(void)
ok(ret == MM_TEXT, "expected MM_TEXT, got %d\n", ret);
expect_viewport_ext(hdc, res_x, -res_y);
expect_window_ext(hdc, size_cx * 10, size_cy * 10);
ok( GetWindowExtEx( hdc, &size ), "GetWindowExtEx failed\n" );
ok( size.cx == size_cx * 10 ||
size.cx == MulDiv( res_x, 254, dpi_x ), /* Vista uses a more precise method */
"expected cx %d or %d, got %d\n", size_cx * 10, MulDiv( res_x, 254, dpi_x ), size.cx );
ok( size.cy == size_cy * 10 ||
size.cy == MulDiv( res_y, 254, dpi_y ), /* Vista uses a more precise method */
"expected cy %d or %d, got %d\n", size_cy * 10, MulDiv( res_y, 254, dpi_y ), size.cy );
expect_world_trasform(hdc, 20.0, 20.0);
expect_LPtoDP(hdc, MulDiv(1000 * 2, res_x, size_cx), -MulDiv(1000 * 2, res_y, size_cy));
expect_LPtoDP(hdc, MulDiv(20000, res_x, size.cx), -MulDiv(20000, res_y, size.cy));
SetLastError(0xdeadbeef);
ret = SetMapMode(hdc, MM_TEXT);
@ -167,6 +204,16 @@ static void test_world_transform(void)
expect_world_trasform(hdc, 20.0, 20.0);
expect_LPtoDP(hdc, 20000, 20000);
ret = SetGraphicsMode(hdc, GM_COMPATIBLE);
ok(ret, "SetGraphicsMode(GM_COMPATIBLE) should not fail if DC has't an identity transform\n");
ret = GetGraphicsMode(hdc);
ok(ret == GM_COMPATIBLE, "expected GM_COMPATIBLE, got %d\n", ret);
expect_viewport_ext(hdc, 1, 1);
expect_window_ext(hdc, 1, 1);
expect_world_trasform(hdc, 20.0, 20.0);
expect_LPtoDP(hdc, 20000, 20000);
DeleteDC(hdc);
}

View file

@ -121,8 +121,11 @@ static int CALLBACK eto_emf_enum_proc(HDC hdc, HANDLETABLE *handle_table,
const EMREXTTEXTOUTW *emr_ExtTextOutW = (const EMREXTTEXTOUTW *)emr;
dx = (const INT *)((const char *)emr + emr_ExtTextOutW->emrtext.offDx);
SetLastError(0xdeadbeef);
ret = GetObjectA(GetCurrentObject(hdc, OBJ_FONT), sizeof(device_lf), &device_lf);
ok( ret == sizeof(device_lf), "GetObjectA error %d\n", GetLastError());
ok( ret == sizeof(device_lf) ||
broken(ret == (sizeof(device_lf) - LF_FACESIZE + strlen(device_lf.lfFaceName) + 1)), /* NT4 */
"GetObjectA error %d\n", GetLastError());
/* compare up to lfOutPrecision, other values are not interesting,
* and in fact sometimes arbitrary adapted by Win9x.
@ -327,6 +330,7 @@ static int CALLBACK savedc_emf_enum_proc(HDC hdc, HANDLETABLE *handle_table,
SIZE size;
static int save_state;
static int restore_no;
static int select_no;
trace("hdc %p, emr->iType %d, emr->nSize %d, param %p\n",
hdc, emr->iType, emr->nSize, (void *)param);
@ -372,6 +376,7 @@ static int CALLBACK savedc_emf_enum_proc(HDC hdc, HANDLETABLE *handle_table,
save_state = 0;
restore_no = 0;
select_no = 0;
check_dc_state(hdc, restore_no, 0, 0, 1, 1, 0, 0, 1, 1);
break;
}
@ -435,8 +440,16 @@ static int CALLBACK savedc_emf_enum_proc(HDC hdc, HANDLETABLE *handle_table,
save_state += restoredc->iRelative;
break;
}
case EMR_SELECTOBJECT:
{
const EMRSELECTOBJECT *selectobj = (const EMRSELECTOBJECT*)emr;
trace("EMR_SELECTOBJECT: %x\n",selectobj->ihObject);
select_no ++;
break;
}
case EMR_EOF:
ok(save_state == 0, "EOF save_state %d\n", save_state);
ok(select_no == 3, "Too many/few selects %i\n",select_no);
break;
}
@ -469,6 +482,9 @@ static void test_SaveDC(void)
HENHMETAFILE hMetafile;
HWND hwnd;
int ret;
POINT pt;
SIZE size;
HFONT hFont,hFont2,hFontOld,hFontCheck;
static const RECT rc = { 0, 0, 150, 150 };
/* Win9x doesn't play EMFs on invisible windows */
@ -495,6 +511,190 @@ static void test_SaveDC(void)
/* Force Win9x to update DC state */
SetPixelV(hdcMetafile, 50, 50, 0);
ret = GetViewportOrgEx(hdcMetafile, &pt);
ok(pt.x == 0,"Expecting ViewportOrg x of 0, got %i\n",pt.x);
ret = GetViewportExtEx(hdcMetafile, &size);
ok(size.cx == 120,"Expecting ViewportExt cx of 120, got %i\n",size.cx);
ret = SaveDC(hdcMetafile);
ok(ret == 1, "ret = %d\n", ret);
SetWindowOrgEx(hdcMetafile, -1, -1, NULL);
SetViewportOrgEx(hdcMetafile, 10, 10, NULL);
SetWindowExtEx(hdcMetafile, 150, 150, NULL );
SetViewportExtEx(hdcMetafile, 200, 200, NULL );
/* Force Win9x to update DC state */
SetPixelV(hdcMetafile, 50, 50, 0);
ret = GetViewportOrgEx(hdcMetafile, &pt);
ok(pt.x == 10,"Expecting ViewportOrg x of 10, got %i\n",pt.x);
ret = GetViewportExtEx(hdcMetafile, &size);
ok(size.cx == 200,"Expecting ViewportExt cx of 200, got %i\n",size.cx);
ret = SaveDC(hdcMetafile);
ok(ret == 2, "ret = %d\n", ret);
SetWindowOrgEx(hdcMetafile, -2, -2, NULL);
SetViewportOrgEx(hdcMetafile, 20, 20, NULL);
SetWindowExtEx(hdcMetafile, 120, 120, NULL );
SetViewportExtEx(hdcMetafile, 300, 300, NULL );
SetPolyFillMode( hdcMetafile, ALTERNATE );
SetBkColor( hdcMetafile, 0 );
/* Force Win9x to update DC state */
SetPixelV(hdcMetafile, 50, 50, 0);
ret = GetViewportOrgEx(hdcMetafile, &pt);
ok(pt.x == 20,"Expecting ViewportOrg x of 20, got %i\n",pt.x);
ret = GetViewportExtEx(hdcMetafile, &size);
ok(size.cx == 300,"Expecting ViewportExt cx of 300, got %i\n",size.cx);
ret = SaveDC(hdcMetafile);
ok(ret == 3, "ret = %d\n", ret);
SetWindowOrgEx(hdcMetafile, -3, -3, NULL);
SetViewportOrgEx(hdcMetafile, 30, 30, NULL);
SetWindowExtEx(hdcMetafile, 200, 200, NULL );
SetViewportExtEx(hdcMetafile, 400, 400, NULL );
SetPolyFillMode( hdcMetafile, WINDING );
SetBkColor( hdcMetafile, 0x123456 );
ok( GetPolyFillMode( hdcMetafile ) == WINDING, "PolyFillMode not restored\n" );
ok( GetBkColor( hdcMetafile ) == 0x123456, "Background color not restored\n" );
/* Force Win9x to update DC state */
SetPixelV(hdcMetafile, 50, 50, 0);
ret = GetViewportOrgEx(hdcMetafile, &pt);
ok(pt.x == 30,"Expecting ViewportOrg x of 30, got %i\n",pt.x);
ret = GetViewportExtEx(hdcMetafile, &size);
ok(size.cx == 400,"Expecting ViewportExt cx of 400, got %i\n",size.cx);
ret = RestoreDC(hdcMetafile, -1);
ok(ret, "ret = %d\n", ret);
ret = GetViewportOrgEx(hdcMetafile, &pt);
ok(pt.x == 20,"Expecting ViewportOrg x of 20, got %i\n",pt.x);
ret = GetViewportExtEx(hdcMetafile, &size);
ok(size.cx == 300,"Expecting ViewportExt cx of 300, got %i\n",size.cx);
ok( GetPolyFillMode( hdcMetafile ) == ALTERNATE, "PolyFillMode not restored\n" );
ok( GetBkColor( hdcMetafile ) == 0, "Background color not restored\n" );
ret = SaveDC(hdcMetafile);
ok(ret == 3, "ret = %d\n", ret);
ret = GetViewportOrgEx(hdcMetafile, &pt);
ok(pt.x == 20,"Expecting ViewportOrg x of 20, got %i\n",pt.x);
ret = GetViewportExtEx(hdcMetafile, &size);
ok(size.cx == 300,"Expecting ViewportExt cx of 300, got %i\n",size.cx);
ret = RestoreDC(hdcMetafile, 1);
ok(ret, "ret = %d\n", ret);
ret = GetViewportOrgEx(hdcMetafile, &pt);
ok(pt.x == 0,"Expecting ViewportOrg x of 0, got %i\n",pt.x);
ret = GetViewportExtEx(hdcMetafile, &size);
ok(size.cx == 120,"Expecting ViewportExt cx of 120, got %i\n",size.cx);
SetWindowOrgEx(hdcMetafile, -4, -4, NULL);
SetViewportOrgEx(hdcMetafile, 40, 40, NULL);
SetWindowExtEx(hdcMetafile, 500, 500, NULL );
SetViewportExtEx(hdcMetafile, 50, 50, NULL );
/* Force Win9x to update DC state */
SetPixelV(hdcMetafile, 50, 50, 0);
ret = GetViewportOrgEx(hdcMetafile, &pt);
ok(pt.x == 40,"Expecting ViewportOrg x of 40, got %i\n",pt.x);
ret = GetViewportExtEx(hdcMetafile, &size);
ok(size.cx == 50,"Expecting ViewportExt cx of 50, got %i\n",size.cx);
ret = SaveDC(hdcMetafile);
ok(ret == 1, "ret = %d\n", ret);
ret = GetViewportOrgEx(hdcMetafile, &pt);
ok(pt.x == 40,"Expecting ViewportOrg x of 40, got %i\n",pt.x);
ret = GetViewportExtEx(hdcMetafile, &size);
ok(size.cx == 50,"Expecting ViewportExt cx of 50, got %i\n",size.cx);
ret = SaveDC(hdcMetafile);
ok(ret == 2, "ret = %d\n", ret);
memset(&orig_lf, 0, sizeof(orig_lf));
orig_lf.lfCharSet = ANSI_CHARSET;
orig_lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
orig_lf.lfWeight = FW_DONTCARE;
orig_lf.lfHeight = 7;
orig_lf.lfQuality = DEFAULT_QUALITY;
lstrcpyA(orig_lf.lfFaceName, "Arial");
hFont = CreateFontIndirectA(&orig_lf);
ok(hFont != 0, "CreateFontIndirectA error %d\n", GetLastError());
hFontOld = SelectObject(hdcMetafile, hFont);
hFont2 = CreateFontIndirectA(&orig_lf);
ok(hFont2 != 0, "CreateFontIndirectA error %d\n", GetLastError());
hFontCheck = SelectObject(hdcMetafile, hFont2);
ok(hFontCheck == hFont, "Font not selected\n");
/* Force Win9x to update DC state */
SetPixelV(hdcMetafile, 50, 50, 0);
ret = RestoreDC(hdcMetafile, 1);
ok(ret, "ret = %d\n", ret);
ret = GetViewportOrgEx(hdcMetafile, &pt);
ok(pt.x == 40,"Expecting ViewportOrg x of 40, got %i\n",pt.x);
ret = GetViewportExtEx(hdcMetafile, &size);
ok(size.cx == 50,"Expecting ViewportExt cx of 50, got %i\n",size.cx);
hFontCheck = SelectObject(hdcMetafile, hFontOld);
ok(hFontOld == hFontCheck && hFontCheck != hFont && hFontCheck != hFont2,
"Font not reverted with DC Restore\n");
ret = RestoreDC(hdcMetafile, -20);
ok(!ret, "ret = %d\n", ret);
ret = RestoreDC(hdcMetafile, 20);
ok(!ret, "ret = %d\n", ret);
hMetafile = CloseEnhMetaFile(hdcMetafile);
ok(hMetafile != 0, "CloseEnhMetaFile error %d\n", GetLastError());
ret = EnumEnhMetaFile(hdcDisplay, hMetafile, savedc_emf_enum_proc, 0, &rc);
ok( ret == 1, "EnumEnhMetaFile rets %d\n", ret);
ret = DeleteObject(hFont);
ok( ret, "DeleteObject error %d\n", GetLastError());
ret = DeleteObject(hFont2);
ok( ret, "DeleteObject error %d\n", GetLastError());
ret = DeleteEnhMetaFile(hMetafile);
ok( ret, "DeleteEnhMetaFile error %d\n", GetLastError());
ret = ReleaseDC(hwnd, hdcDisplay);
ok( ret, "ReleaseDC error %d\n", GetLastError());
DestroyWindow(hwnd);
}
static void test_mf_SaveDC(void)
{
HDC hdcMetafile;
HMETAFILE hMetafile;
int ret;
POINT pt;
SIZE size;
HFONT hFont,hFont2,hFontOld,hFontCheck;
hdcMetafile = CreateMetaFileA(NULL);
ok(hdcMetafile != 0, "CreateMetaFileA error %d\n", GetLastError());
ret = SetMapMode(hdcMetafile, MM_ANISOTROPIC);
ok (ret, "SetMapMode should not fail\n");
/* Need to write something to the emf, otherwise Windows won't play it back */
LineTo(hdcMetafile, 150, 150);
SetWindowOrgEx(hdcMetafile, 0, 0, NULL);
SetViewportOrgEx(hdcMetafile, 0, 0, NULL);
SetWindowExtEx(hdcMetafile, 110, 110, NULL );
SetViewportExtEx(hdcMetafile, 120, 120, NULL );
/* Force Win9x to update DC state */
SetPixelV(hdcMetafile, 50, 50, 0);
ret = GetViewportOrgEx(hdcMetafile, &pt);
todo_wine ok (!ret, "GetViewportOrgEx should fail\n");
ret = GetViewportExtEx(hdcMetafile, &size);
todo_wine ok (!ret, "GetViewportExtEx should fail\n");
ret = SaveDC(hdcMetafile);
ok(ret == 1, "ret = %d\n", ret);
@ -507,7 +707,7 @@ static void test_SaveDC(void)
SetPixelV(hdcMetafile, 50, 50, 0);
ret = SaveDC(hdcMetafile);
ok(ret == 2, "ret = %d\n", ret);
ok(ret == 1, "ret = %d\n", ret);
SetWindowOrgEx(hdcMetafile, -2, -2, NULL);
SetViewportOrgEx(hdcMetafile, 20, 20, NULL);
@ -516,15 +716,22 @@ static void test_SaveDC(void)
/* Force Win9x to update DC state */
SetPixelV(hdcMetafile, 50, 50, 0);
SetPolyFillMode( hdcMetafile, ALTERNATE );
SetBkColor( hdcMetafile, 0 );
ret = SaveDC(hdcMetafile);
ok(ret == 3, "ret = %d\n", ret);
ok(ret == 1, "ret = %d\n", ret);
SetWindowOrgEx(hdcMetafile, -3, -3, NULL);
SetViewportOrgEx(hdcMetafile, 30, 30, NULL);
SetWindowExtEx(hdcMetafile, 200, 200, NULL );
SetViewportExtEx(hdcMetafile, 400, 400, NULL );
SetPolyFillMode( hdcMetafile, WINDING );
SetBkColor( hdcMetafile, 0x123456 );
todo_wine ok( !GetPolyFillMode( hdcMetafile ), "GetPolyFillMode succeeded\n" );
todo_wine ok( GetBkColor( hdcMetafile ) == CLR_INVALID, "GetBkColor succeeded\n" );
/* Force Win9x to update DC state */
SetPixelV(hdcMetafile, 50, 50, 0);
@ -532,7 +739,7 @@ static void test_SaveDC(void)
ok(ret, "ret = %d\n", ret);
ret = SaveDC(hdcMetafile);
ok(ret == 3, "ret = %d\n", ret);
ok(ret == 1, "ret = %d\n", ret);
ret = RestoreDC(hdcMetafile, 1);
ok(ret, "ret = %d\n", ret);
@ -549,21 +756,54 @@ static void test_SaveDC(void)
ok(ret == 1, "ret = %d\n", ret);
ret = SaveDC(hdcMetafile);
ok(ret == 2, "ret = %d\n", ret);
ok(ret == 1, "ret = %d\n", ret);
hMetafile = CloseEnhMetaFile(hdcMetafile);
memset(&orig_lf, 0, sizeof(orig_lf));
orig_lf.lfCharSet = ANSI_CHARSET;
orig_lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
orig_lf.lfWeight = FW_DONTCARE;
orig_lf.lfHeight = 7;
orig_lf.lfQuality = DEFAULT_QUALITY;
lstrcpyA(orig_lf.lfFaceName, "Arial");
hFont = CreateFontIndirectA(&orig_lf);
ok(hFont != 0, "CreateFontIndirectA error %d\n", GetLastError());
hFontOld = SelectObject(hdcMetafile, hFont);
hFont2 = CreateFontIndirectA(&orig_lf);
ok(hFont2 != 0, "CreateFontIndirectA error %d\n", GetLastError());
hFontCheck = SelectObject(hdcMetafile, hFont2);
ok(hFontCheck == hFont, "Font not selected\n");
/* Force Win9x to update DC state */
SetPixelV(hdcMetafile, 50, 50, 0);
ret = RestoreDC(hdcMetafile, 1);
ok(ret, "ret = %d\n", ret);
hFontCheck = SelectObject(hdcMetafile, hFontOld);
ok(hFontOld != hFontCheck && hFontCheck == hFont2, "Font incorrectly reverted with DC Restore\n");
/* restore level is ignored */
ret = RestoreDC(hdcMetafile, -20);
ok(ret, "ret = %d\n", ret);
ret = RestoreDC(hdcMetafile, 20);
ok(ret, "ret = %d\n", ret);
ret = RestoreDC(hdcMetafile, 0);
ok(ret, "ret = %d\n", ret);
hMetafile = CloseMetaFile(hdcMetafile);
ok(hMetafile != 0, "CloseEnhMetaFile error %d\n", GetLastError());
ret = EnumEnhMetaFile(hdcDisplay, hMetafile, savedc_emf_enum_proc, 0, &rc);
ok( ret == 1, "EnumEnhMetaFile rets %d\n", ret);
ret = DeleteEnhMetaFile(hMetafile);
ok( ret, "DeleteEnhMetaFile error %d\n", GetLastError());
ret = ReleaseDC(hwnd, hdcDisplay);
ok( ret, "ReleaseDC error %d\n", GetLastError());
DestroyWindow(hwnd);
ret = DeleteMetaFile(hMetafile);
ok( ret, "DeleteMetaFile error %d\n", GetLastError());
ret = DeleteObject(hFont);
ok( ret, "DeleteObject error %d\n", GetLastError());
ret = DeleteObject(hFont2);
ok( ret, "DeleteObject error %d\n", GetLastError());
}
/* Win-format metafile (mfdrv) tests */
/* These tests compare the generated metafiles byte-by-byte */
/* with the nominal results. */
@ -992,31 +1232,13 @@ static void dump_EMREXTTEXTOUT(const EMREXTTEXTOUTW *eto)
}
static BOOL match_emf_record(const ENHMETARECORD *emr1, const ENHMETARECORD *emr2,
const char *desc, BOOL ignore_scaling, BOOL todo)
const char *desc, BOOL ignore_scaling)
{
int diff;
if (emr1->iType != emr2->iType && todo)
{
todo_wine
{
ok(emr1->iType == emr2->iType, "%s: emr->iType %u != %u\n",
desc, emr1->iType, emr2->iType);
}
}
else
ok(emr1->iType == emr2->iType, "%s: emr->iType %u != %u\n",
desc, emr1->iType, emr2->iType);
if (emr1->nSize != emr2->nSize && todo)
{
todo_wine
{
ok(emr1->nSize == emr2->nSize, "%s: emr->nSize %u != %u\n",
desc, emr1->nSize, emr2->nSize);
}
}
else
ok(emr1->nSize == emr2->nSize, "%s: emr->nSize %u != %u\n",
desc, emr1->nSize, emr2->nSize);
@ -1057,12 +1279,7 @@ static BOOL match_emf_record(const ENHMETARECORD *emr1, const ENHMETARECORD *emr
}
else
diff = memcmp(emr1, emr2, emr1->nSize);
if (diff && todo)
{
todo_wine
ok(diff == 0, "%s: contents of record %u don't match\n", desc, emr1->iType);
}
else
ok(diff == 0, "%s: contents of record %u don't match\n", desc, emr1->iType);
if (diff)
@ -1071,7 +1288,7 @@ static BOOL match_emf_record(const ENHMETARECORD *emr1, const ENHMETARECORD *emr
dump_emf_record(emr2, "actual bits");
}
return diff == 0 || todo; /* report all non-fatal record mismatches */
return diff == 0; /* report all non-fatal record mismatches */
}
/* Compare the EMF produced by a test function with the
@ -1082,7 +1299,7 @@ static BOOL match_emf_record(const ENHMETARECORD *emr1, const ENHMETARECORD *emr
*/
static int compare_emf_bits(const HENHMETAFILE mf, const unsigned char *bits,
UINT bsize, const char *desc,
BOOL ignore_scaling, BOOL todo)
BOOL ignore_scaling)
{
unsigned char buf[MF_BUFSIZE];
UINT mfsize, offset;
@ -1093,12 +1310,6 @@ static int compare_emf_bits(const HENHMETAFILE mf, const unsigned char *bits,
if (mfsize < MF_BUFSIZE)
{
if (mfsize != bsize && todo)
{
todo_wine
ok(mfsize == bsize, "%s: mfsize=%d, bsize=%d\n", desc, mfsize, bsize);
}
else
ok(mfsize == bsize, "%s: mfsize=%d, bsize=%d\n", desc, mfsize, bsize);
}
else
@ -1116,19 +1327,7 @@ static int compare_emf_bits(const HENHMETAFILE mf, const unsigned char *bits,
ok(emh1->iType == emh2->iType, "expected EMR_HEADER, got %u\n", emh2->iType);
ok(emh1->nSize == emh2->nSize, "expected nSize %u, got %u\n", emh1->nSize, emh2->nSize);
ok(emh1->dSignature == emh2->dSignature, "expected dSignature %u, got %u\n", emh1->dSignature, emh2->dSignature);
if (todo && emh1->nBytes != emh2->nBytes)
{
todo_wine
ok(emh1->nBytes == emh2->nBytes, "expected nBytes %u, got %u\n", emh1->nBytes, emh2->nBytes);
}
else
ok(emh1->nBytes == emh2->nBytes, "expected nBytes %u, got %u\n", emh1->nBytes, emh2->nBytes);
if (todo && emh1->nRecords != emh2->nRecords)
{
todo_wine
ok(emh1->nRecords == emh2->nRecords, "expected nBytes %u, got %u\n", emh1->nRecords, emh2->nRecords);
}
else
ok(emh1->nRecords == emh2->nRecords, "expected nBytes %u, got %u\n", emh1->nRecords, emh2->nRecords);
offset = emh1->nSize;
@ -1140,7 +1339,7 @@ static int compare_emf_bits(const HENHMETAFILE mf, const unsigned char *bits,
trace("EMF record %u, size %u/record %u, size %u\n",
emr1->iType, emr1->nSize, emr2->iType, emr2->nSize);
if (!match_emf_record(emr1, emr2, desc, ignore_scaling, todo)) return -1;
if (!match_emf_record(emr1, emr2, desc, ignore_scaling)) return -1;
offset += emr1->nSize;
}
@ -1261,7 +1460,9 @@ static void test_SetMetaFileBits(void)
SetLastError(0xdeadbeef);
hmf = SetMetaFileBitsEx(0, MF_GRAPHICS_BITS);
ok(!hmf, "SetMetaFileBitsEx should fail\n");
ok(GetLastError() == ERROR_INVALID_DATA, "wrong error %d\n", GetLastError());
ok(GetLastError() == ERROR_INVALID_DATA ||
broken(GetLastError() == ERROR_INVALID_PARAMETER), /* Win9x */
"wrong error %d\n", GetLastError());
/* Now with not even size */
SetLastError(0xdeadbeef);
@ -1280,7 +1481,9 @@ static void test_SetMetaFileBits(void)
SetLastError(0xdeadbeef);
hmf = SetMetaFileBitsEx(sizeof(MF_GRAPHICS_BITS), buf);
ok(!hmf, "SetMetaFileBitsEx should fail\n");
ok(GetLastError() == ERROR_INVALID_DATA, "wrong error %d\n", GetLastError());
ok(GetLastError() == ERROR_INVALID_DATA ||
broken(GetLastError() == ERROR_INVALID_PARAMETER), /* Win9x */
"wrong error %d\n", GetLastError());
/* Now with corrupted mtSize field */
memcpy(buf, MF_GRAPHICS_BITS, sizeof(MF_GRAPHICS_BITS));
@ -1480,7 +1683,7 @@ static void test_emf_ExtTextOut_on_path(void)
* are there, but their contents don't match for different reasons.
*/
if (compare_emf_bits(hMetafile, EMF_TEXTOUT_ON_PATH_BITS, sizeof(EMF_TEXTOUT_ON_PATH_BITS),
"emf_TextOut_on_path", FALSE, FALSE) != 0)
"emf_TextOut_on_path", FALSE) != 0)
{
dump_emf_bits(hMetafile, "emf_TextOut_on_path");
dump_emf_records(hMetafile, "emf_TextOut_on_path");
@ -1676,7 +1879,7 @@ static void test_emf_clipping(void)
ok(hemf != 0, "CloseEnhMetaFile error %d\n", GetLastError());
if (compare_emf_bits(hemf, EMF_CLIPPING, sizeof(EMF_CLIPPING),
"emf_clipping", FALSE, FALSE) != 0)
"emf_clipping", FALSE) != 0)
{
dump_emf_bits(hemf, "emf_clipping");
dump_emf_records(hemf, "emf_clipping");
@ -1785,7 +1988,7 @@ static void test_mf_conversions(void)
hemf = create_converted_emf(&mfp);
if (compare_emf_bits(hemf, EMF_LINETO_MM_ANISOTROPIC_BITS, sizeof(EMF_LINETO_MM_ANISOTROPIC_BITS),
"emf_LineTo MM_ANISOTROPIC", TRUE, FALSE) != 0)
"emf_LineTo MM_ANISOTROPIC", TRUE) != 0)
{
dump_emf_bits(hemf, "emf_LineTo MM_ANISOTROPIC");
dump_emf_records(hemf, "emf_LineTo MM_ANISOTROPIC");
@ -1810,7 +2013,7 @@ static void test_mf_conversions(void)
hemf = create_converted_emf(&mfp);
if (compare_emf_bits(hemf, EMF_LINETO_MM_TEXT_BITS, sizeof(EMF_LINETO_MM_TEXT_BITS),
"emf_LineTo MM_TEXT", TRUE, FALSE) != 0)
"emf_LineTo MM_TEXT", TRUE) != 0)
{
dump_emf_bits(hemf, "emf_LineTo MM_TEXT");
dump_emf_records(hemf, "emf_LineTo MM_TEXT");
@ -1830,7 +2033,7 @@ static void test_mf_conversions(void)
hemf = create_converted_emf(NULL);
if (compare_emf_bits(hemf, EMF_LINETO_BITS, sizeof(EMF_LINETO_BITS),
"emf_LineTo NULL", TRUE, FALSE) != 0)
"emf_LineTo NULL", TRUE) != 0)
{
dump_emf_bits(hemf, "emf_LineTo NULL");
dump_emf_records(hemf, "emf_LineTo NULL");
@ -2146,7 +2349,6 @@ static void test_SetEnhMetaFileBits(void)
ok(!hemf ||
broken(hemf != NULL), /* Win9x, WinMe */
"SetEnhMetaFileBits should fail\n");
todo_wine
ok(GetLastError() == 0xdeadbeef, "Expected deadbeef, got %u\n", GetLastError());
DeleteEnhMetaFile(hemf);
@ -2157,7 +2359,6 @@ static void test_SetEnhMetaFileBits(void)
ok(!hemf ||
broken(hemf != NULL), /* Win9x, WinMe */
"SetEnhMetaFileBits should fail\n");
todo_wine
ok(GetLastError() == 0xdeadbeef, "Expected deadbeef, got %u\n", GetLastError());
DeleteEnhMetaFile(hemf);
}
@ -2171,6 +2372,7 @@ START_TEST(metafile)
test_SaveDC();
/* For win-format metafiles (mfdrv) */
test_mf_SaveDC();
test_mf_Blank();
test_mf_Graphics();
test_mf_PatternBrush();

View file

@ -238,7 +238,7 @@ static void test_arcto(void)
GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
{
/* ArcTo is only available on Win2k and later */
skip("ArcTo is not available\n");
win_skip("ArcTo is not available\n");
goto done;
}
SetArcDirection(hdc, AD_COUNTERCLOCKWISE);
@ -282,7 +282,7 @@ static void test_anglearc(void)
GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
{
/* AngleArc is only available on Win2k and later */
skip("AngleArc is not available\n");
win_skip("AngleArc is not available\n");
goto done;
}
AngleArc(hdc, 300, 300, 80, 150.0, -180.0);
@ -355,7 +355,7 @@ static void test_polydraw(void)
GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
{
/* PolyDraw is only available on Win2k and later */
skip("PolyDraw is not available\n");
win_skip("PolyDraw is not available\n");
goto done;
}
expect(TRUE, retb);

View file

@ -61,6 +61,7 @@ static void test_logpen(void)
LOGPEN lp;
EXTLOGPEN elp;
LOGBRUSH lb;
DWORD_PTR unset_hatch;
DWORD obj_type, user_style[2] = { 0xabc, 0xdef };
struct
{
@ -90,9 +91,19 @@ static void test_logpen(void)
size = GetObject(hpen, sizeof(lp), &lp);
ok(size == sizeof(lp), "GetObject returned %d, error %d\n", size, GetLastError());
if (pen[i].style == PS_USERSTYLE || pen[i].style == PS_ALTERNATE)
{
if (lp.lopnStyle == pen[i].style)
{
win_skip("Skipping PS_USERSTYLE and PS_ALTERNATE tests on Win9x\n");
continue;
}
}
ok(lp.lopnStyle == pen[i].ret_style, "expected %u, got %u\n", pen[i].ret_style, lp.lopnStyle);
ok(lp.lopnWidth.x == pen[i].ret_width, "expected %u, got %d\n", pen[i].ret_width, lp.lopnWidth.x);
ok(lp.lopnWidth.y == 0, "expected 0, got %d\n", lp.lopnWidth.y);
ok(lp.lopnWidth.y == 0 ||
broken(lp.lopnWidth.y == 0xb), /* Win9x */
"expected 0, got %d\n", lp.lopnWidth.y);
ok(lp.lopnColor == pen[i].ret_color, "expected %08x, got %08x\n", pen[i].ret_color, lp.lopnColor);
DeleteObject(hpen);
@ -113,12 +124,14 @@ static void test_logpen(void)
memset(&lp, 0xb0, sizeof(lp));
SetLastError(0xdeadbeef);
size = GetObject(hpen, sizeof(lp.lopnStyle), &lp);
ok(!size, "GetObject should fail: size %d, error %d\n", size, GetLastError());
ok(!size ||
broken(size == sizeof(lp.lopnStyle)), /* Win9x */
"GetObject should fail: size %d, error %d\n", size, GetLastError());
/* see how larger buffer sizes are handled */
memset(&lp, 0xb0, sizeof(lp));
SetLastError(0xdeadbeef);
size = GetObject(hpen, sizeof(lp) * 2, &lp);
size = GetObject(hpen, sizeof(lp) * 4, &lp);
ok(size == sizeof(lp), "GetObject returned %d, error %d\n", size, GetLastError());
/* see how larger buffer sizes are handled */
@ -225,12 +238,17 @@ static void test_logpen(void)
break;
case PS_USERSTYLE:
ok(size == sizeof(EXTLOGPEN) - sizeof(elp.elpStyleEntry) + sizeof(user_style),
ok(size == sizeof(EXTLOGPEN) - sizeof(elp.elpStyleEntry) + sizeof(user_style) ||
broken(size == 0 && GetLastError() == ERROR_INVALID_PARAMETER), /* Win9x */
"GetObject returned %d, error %d\n", size, GetLastError());
break;
default:
ok(size == sizeof(EXTLOGPEN) - sizeof(elp.elpStyleEntry),
ok(size == sizeof(EXTLOGPEN) - sizeof(elp.elpStyleEntry) ||
broken(size == sizeof(LOGPEN)) || /* Win9x */
broken(pen[i].style == PS_ALTERNATE &&
size == 0 &&
GetLastError() == ERROR_INVALID_PARAMETER), /* Win9x */
"GetObject returned %d, error %d\n", size, GetLastError());
break;
}
@ -239,7 +257,9 @@ static void test_logpen(void)
memset(&elp, 0xb0, sizeof(elp));
SetLastError(0xdeadbeef);
size = GetObject(hpen, sizeof(elp.elpPenStyle), &elp);
ok(!size, "GetObject should fail: size %d, error %d\n", size, GetLastError());
ok(!size ||
broken(size == sizeof(elp.elpPenStyle)), /* Win9x */
"GetObject should fail: size %d, error %d\n", size, GetLastError());
/* see how larger buffer sizes are handled */
memset(&ext_pen, 0xb0, sizeof(ext_pen));
@ -258,11 +278,12 @@ static void test_logpen(void)
/* for PS_NULL it also works this way */
memset(&elp, 0xb0, sizeof(elp));
memset(&unset_hatch, 0xb0, sizeof(unset_hatch));
SetLastError(0xdeadbeef);
size = GetObject(hpen, sizeof(elp), &elp);
ok(size == sizeof(EXTLOGPEN),
"GetObject returned %d, error %d\n", size, GetLastError());
ok(ext_pen.elp.elpHatch == 0xb0b0b0b0, "expected 0xb0b0b0b0, got %p\n", (void *)ext_pen.elp.elpHatch);
ok(ext_pen.elp.elpHatch == unset_hatch, "expected 0xb0b0b0b0, got %p\n", (void *)ext_pen.elp.elpHatch);
ok(ext_pen.elp.elpNumEntries == 0xb0b0b0b0, "expected 0xb0b0b0b0, got %x\n", ext_pen.elp.elpNumEntries);
break;
@ -276,7 +297,11 @@ static void test_logpen(void)
break;
default:
ok(size == sizeof(EXTLOGPEN) - sizeof(elp.elpStyleEntry),
ok(size == sizeof(EXTLOGPEN) - sizeof(elp.elpStyleEntry) ||
broken(size == sizeof(LOGPEN)) || /* Win9x */
broken(pen[i].style == PS_ALTERNATE &&
size == 0 &&
GetLastError() == ERROR_INVALID_PARAMETER), /* Win9x */
"GetObject returned %d, error %d\n", size, GetLastError());
ok(ext_pen.elp.elpHatch == HS_CROSS, "expected HS_CROSS, got %p\n", (void *)ext_pen.elp.elpHatch);
ok(ext_pen.elp.elpNumEntries == 0, "expected 0, got %x\n", ext_pen.elp.elpNumEntries);
@ -504,6 +529,11 @@ static void test_ps_userstyle(void)
pen = ExtCreatePen(PS_GEOMETRIC | PS_USERSTYLE, 50, &lb, 3, NULL);
ok(pen == 0, "ExtCreatePen should fail\n");
if (pen == 0 && GetLastError() == 0xdeadbeef)
{
win_skip("Looks like 9x, skipping PS_USERSTYLE tests\n");
return;
}
expect(ERROR_INVALID_PARAMETER, GetLastError());
DeleteObject(pen);
SetLastError(0xdeadbeef);
@ -542,7 +572,7 @@ static void test_ps_userstyle(void)
ok(pen != 0, "ExtCreatePen should not fail\n");
size = GetObject(pen, sizeof(ext_pen), &ext_pen);
expect(88, size);
expect(FIELD_OFFSET(EXTLOGPEN,elpStyleEntry[16]), size);
for(i = 0; i < 16; i++)
expect(style[i], ext_pen.elp.elpStyleEntry[i]);

View file

@ -328,6 +328,34 @@ static void test_gradientgetrect(void)
expectf(10.0, rectf.Width);
todo_wine expectf(10.0, rectf.Height);
status = GdipDeleteBrush((GpBrush*)brush);
/* slope = -1 */
pt1.X = pt1.Y = 0.0;
pt2.X = 20.0;
pt2.Y = -20.0;
status = GdipCreateLineBrush(&pt1, &pt2, 0, 0, WrapModeTile, &brush);
expect(Ok, status);
memset(&rectf, 0, sizeof(GpRectF));
status = GdipGetLineRect(brush, &rectf);
expect(Ok, status);
expectf(0.0, rectf.X);
expectf(-20.0, rectf.Y);
expectf(20.0, rectf.Width);
expectf(20.0, rectf.Height);
status = GdipDeleteBrush((GpBrush*)brush);
/* slope = 1/100 */
pt1.X = pt1.Y = 0.0;
pt2.X = 100.0;
pt2.Y = 1.0;
status = GdipCreateLineBrush(&pt1, &pt2, 0, 0, WrapModeTile, &brush);
expect(Ok, status);
memset(&rectf, 0, sizeof(GpRectF));
status = GdipGetLineRect(brush, &rectf);
expect(Ok, status);
expectf(0.0, rectf.X);
expectf(0.0, rectf.Y);
expectf(100.0, rectf.Width);
expectf(1.0, rectf.Height);
status = GdipDeleteBrush((GpBrush*)brush);
/* from rect with LinearGradientModeHorizontal */
rectf.X = rectf.Y = 10.0;
rectf.Width = rectf.Height = 100.0;
@ -342,6 +370,127 @@ static void test_gradientgetrect(void)
expectf(100.0, rectf.Width);
expectf(100.0, rectf.Height);
status = GdipDeleteBrush((GpBrush*)brush);
/* passing negative Width/Height to LinearGradientModeHorizontal */
rectf.X = rectf.Y = 10.0;
rectf.Width = rectf.Height = -100.0;
status = GdipCreateLineBrushFromRect(&rectf, 0, 0, LinearGradientModeHorizontal,
WrapModeTile, &brush);
expect(Ok, status);
memset(&rectf, 0, sizeof(GpRectF));
status = GdipGetLineRect(brush, &rectf);
expect(Ok, status);
expectf(10.0, rectf.X);
expectf(10.0, rectf.Y);
expectf(-100.0, rectf.Width);
expectf(-100.0, rectf.Height);
status = GdipDeleteBrush((GpBrush*)brush);
}
static void test_lineblend(void)
{
GpLineGradient *brush;
GpStatus status;
GpPointF pt1, pt2;
INT count=10;
int i;
const REAL factors[5] = {0.0f, 0.1f, 0.5f, 0.9f, 1.0f};
const REAL positions[5] = {0.0f, 0.2f, 0.5f, 0.8f, 1.0f};
REAL res_factors[6] = {0.3f, 0.0f, 0.0f, 0.0f, 0.0f};
REAL res_positions[6] = {0.3f, 0.0f, 0.0f, 0.0f, 0.0f};
pt1.X = pt1.Y = 1.0;
pt2.X = pt2.Y = 100.0;
status = GdipCreateLineBrush(&pt1, &pt2, 0, 0, WrapModeTile, &brush);
expect(Ok, status);
status = GdipGetLineBlendCount(NULL, &count);
expect(InvalidParameter, status);
status = GdipGetLineBlendCount(brush, NULL);
expect(InvalidParameter, status);
status = GdipGetLineBlendCount(brush, &count);
expect(Ok, status);
expect(1, count);
status = GdipGetLineBlend(NULL, res_factors, res_positions, 1);
expect(InvalidParameter, status);
status = GdipGetLineBlend(brush, NULL, res_positions, 1);
expect(InvalidParameter, status);
status = GdipGetLineBlend(brush, res_factors, NULL, 1);
expect(InvalidParameter, status);
status = GdipGetLineBlend(brush, res_factors, res_positions, 0);
expect(InvalidParameter, status);
status = GdipGetLineBlend(brush, res_factors, res_positions, -1);
expect(InvalidParameter, status);
status = GdipGetLineBlend(brush, res_factors, res_positions, 1);
expect(Ok, status);
status = GdipGetLineBlend(brush, res_factors, res_positions, 2);
expect(Ok, status);
status = GdipSetLineBlend(NULL, factors, positions, 5);
expect(InvalidParameter, status);
status = GdipSetLineBlend(brush, NULL, positions, 5);
expect(InvalidParameter, status);
status = GdipSetLineBlend(brush, factors, NULL, 5);
expect(InvalidParameter, status);
status = GdipSetLineBlend(brush, factors, positions, 0);
expect(InvalidParameter, status);
status = GdipSetLineBlend(brush, factors, positions, -1);
expect(InvalidParameter, status);
/* leave off the 0.0 position */
status = GdipSetLineBlend(brush, &factors[1], &positions[1], 4);
expect(InvalidParameter, status);
/* leave off the 1.0 position */
status = GdipSetLineBlend(brush, factors, positions, 4);
expect(InvalidParameter, status);
status = GdipSetLineBlend(brush, factors, positions, 5);
expect(Ok, status);
status = GdipGetLineBlendCount(brush, &count);
expect(Ok, status);
expect(5, count);
status = GdipGetLineBlend(brush, res_factors, res_positions, 4);
expect(InsufficientBuffer, status);
status = GdipGetLineBlend(brush, res_factors, res_positions, 5);
expect(Ok, status);
for (i=0; i<5; i++)
{
expectf(factors[i], res_factors[i]);
expectf(positions[i], res_positions[i]);
}
status = GdipGetLineBlend(brush, res_factors, res_positions, 6);
expect(Ok, status);
status = GdipSetLineBlend(brush, factors, positions, 1);
expect(Ok, status);
status = GdipGetLineBlendCount(brush, &count);
expect(Ok, status);
expect(1, count);
status = GdipGetLineBlend(brush, res_factors, res_positions, 1);
expect(Ok, status);
status = GdipDeleteBrush((GpBrush*)brush);
expect(Ok, status);
}
START_TEST(brush)
@ -365,6 +514,7 @@ START_TEST(brush)
test_transform();
test_texturewrap();
test_gradientgetrect();
test_lineblend();
GdiplusShutdown(gdiplusToken);
}

View file

@ -97,7 +97,7 @@ static void test_createfont(void)
static void test_logfont(void)
{
LOGFONTW lfw, lfw2;
LOGFONTA lfa, lfa2;
GpFont *font;
GpStatus stat;
GpGraphics *graphics;
@ -105,70 +105,69 @@ static void test_logfont(void)
INT style;
GdipCreateFromHDC(hdc, &graphics);
memset(&lfw, 0, sizeof(LOGFONTW));
memset(&lfw2, 0xff, sizeof(LOGFONTW));
memset(&lfa, 0, sizeof(LOGFONTA));
memset(&lfa2, 0xff, sizeof(LOGFONTA));
/* empty FaceName */
lfw.lfFaceName[0] = 0;
stat = GdipCreateFontFromLogfontW(hdc, &lfw, &font);
lfa.lfFaceName[0] = 0;
stat = GdipCreateFontFromLogfontA(hdc, &lfa, &font);
expect(NotTrueTypeFont, stat);
memcpy(&lfw.lfFaceName, arial, 6 * sizeof(WCHAR));
lstrcpyA(lfa.lfFaceName, "Arial");
stat = GdipCreateFontFromLogfontW(hdc, &lfw, &font);
stat = GdipCreateFontFromLogfontA(hdc, &lfa, &font);
if (stat == FileNotFound)
{
skip("Arial not installed.\n");
return;
}
expect(Ok, stat);
stat = GdipGetLogFontW(font, graphics, &lfw2);
stat = GdipGetLogFontA(font, graphics, &lfa2);
expect(Ok, stat);
ok(lfw2.lfHeight < 0, "Expected negative height\n");
expect(0, lfw2.lfWidth);
expect(0, lfw2.lfEscapement);
expect(0, lfw2.lfOrientation);
ok((lfw2.lfWeight >= 100) && (lfw2.lfWeight <= 900), "Expected weight to be set\n");
expect(0, lfw2.lfItalic);
expect(0, lfw2.lfUnderline);
expect(0, lfw2.lfStrikeOut);
expect(GetTextCharset(hdc), lfw2.lfCharSet);
expect(0, lfw2.lfOutPrecision);
expect(0, lfw2.lfClipPrecision);
expect(0, lfw2.lfQuality);
expect(0, lfw2.lfPitchAndFamily);
ok(lfa2.lfHeight < 0, "Expected negative height\n");
expect(0, lfa2.lfWidth);
expect(0, lfa2.lfEscapement);
expect(0, lfa2.lfOrientation);
ok((lfa2.lfWeight >= 100) && (lfa2.lfWeight <= 900), "Expected weight to be set\n");
expect(0, lfa2.lfItalic);
expect(0, lfa2.lfUnderline);
expect(0, lfa2.lfStrikeOut);
expect(GetTextCharset(hdc), lfa2.lfCharSet);
expect(0, lfa2.lfOutPrecision);
expect(0, lfa2.lfClipPrecision);
expect(0, lfa2.lfQuality);
expect(0, lfa2.lfPitchAndFamily);
GdipDeleteFont(font);
memset(&lfw, 0, sizeof(LOGFONTW));
lfw.lfHeight = 25;
lfw.lfWidth = 25;
lfw.lfEscapement = lfw.lfOrientation = 50;
lfw.lfItalic = lfw.lfUnderline = lfw.lfStrikeOut = TRUE;
memset(&lfa, 0, sizeof(LOGFONTA));
lfa.lfHeight = 25;
lfa.lfWidth = 25;
lfa.lfEscapement = lfa.lfOrientation = 50;
lfa.lfItalic = lfa.lfUnderline = lfa.lfStrikeOut = TRUE;
memset(&lfw2, 0xff, sizeof(LOGFONTW));
memcpy(&lfw.lfFaceName, arial, 6 * sizeof(WCHAR));
memset(&lfa2, 0xff, sizeof(LOGFONTA));
lstrcpyA(lfa.lfFaceName, "Arial");
stat = GdipCreateFontFromLogfontW(hdc, &lfw, &font);
stat = GdipCreateFontFromLogfontA(hdc, &lfa, &font);
expect(Ok, stat);
stat = GdipGetLogFontW(font, graphics, &lfw2);
stat = GdipGetLogFontA(font, graphics, &lfa2);
expect(Ok, stat);
ok(lfw2.lfHeight < 0, "Expected negative height\n");
expect(0, lfw2.lfWidth);
expect(0, lfw2.lfEscapement);
expect(0, lfw2.lfOrientation);
ok((lfw2.lfWeight >= 100) && (lfw2.lfWeight <= 900), "Expected weight to be set\n");
expect(TRUE, lfw2.lfItalic);
expect(TRUE, lfw2.lfUnderline);
expect(TRUE, lfw2.lfStrikeOut);
expect(GetTextCharset(hdc), lfw2.lfCharSet);
expect(0, lfw2.lfOutPrecision);
expect(0, lfw2.lfClipPrecision);
expect(0, lfw2.lfQuality);
expect(0, lfw2.lfPitchAndFamily);
ok(lfa2.lfHeight < 0, "Expected negative height\n");
expect(0, lfa2.lfWidth);
expect(0, lfa2.lfEscapement);
expect(0, lfa2.lfOrientation);
ok((lfa2.lfWeight >= 100) && (lfa2.lfWeight <= 900), "Expected weight to be set\n");
expect(TRUE, lfa2.lfItalic);
expect(TRUE, lfa2.lfUnderline);
expect(TRUE, lfa2.lfStrikeOut);
expect(GetTextCharset(hdc), lfa2.lfCharSet);
expect(0, lfa2.lfOutPrecision);
expect(0, lfa2.lfClipPrecision);
expect(0, lfa2.lfQuality);
expect(0, lfa2.lfPitchAndFamily);
stat = GdipGetFontStyle(font, &style);
expect(Ok, stat);
@ -341,6 +340,19 @@ monospace:
expect (Ok, stat);
}
static void test_installedfonts (void)
{
GpStatus stat;
GpFontCollection* collection=NULL;
stat = GdipNewInstalledFontCollection(NULL);
expect (InvalidParameter, stat);
stat = GdipNewInstalledFontCollection(&collection);
expect (Ok, stat);
ok (collection != NULL, "got NULL font collection\n");
}
START_TEST(font)
{
struct GdiplusStartupInput gdiplusStartupInput;
@ -358,6 +370,7 @@ START_TEST(font)
test_fontfamily();
test_fontfamily_properties();
test_getgenerics();
test_installedfonts();
GdiplusShutdown(gdiplusToken);
}

View file

@ -935,6 +935,57 @@ static void test_textcontrast(void)
ReleaseDC(0, hdc);
}
static void test_GdipDrawString(void)
{
GpStatus status;
GpGraphics *graphics = NULL;
GpFont *fnt = NULL;
RectF rect;
GpStringFormat *format;
GpBrush *brush;
LOGFONTA logfont;
HDC hdc = GetDC(0);
static const WCHAR string[] = {'T','e','s','t',0};
memset(&logfont,0,sizeof(logfont));
strcpy(logfont.lfFaceName,"Arial");
logfont.lfHeight = 12;
logfont.lfCharSet = DEFAULT_CHARSET;
status = GdipCreateFromHDC(hdc, &graphics);
expect(Ok, status);
status = GdipCreateFontFromLogfontA(hdc, &logfont, &fnt);
if (status == FileNotFound)
{
skip("Arial not installed.\n");
return;
}
expect(Ok, status);
status = GdipCreateSolidFill((ARGB)0xdeadbeef, (GpSolidFill**)&brush);
expect(Ok, status);
status = GdipCreateStringFormat(0,0,&format);
expect(Ok, status);
rect.X = 0;
rect.Y = 0;
rect.Width = 0;
rect.Height = 12;
status = GdipDrawString(graphics, string, 4, fnt, &rect, format, brush);
expect(Ok, status);
GdipDeleteGraphics(graphics);
GdipDeleteBrush(brush);
GdipDeleteFont(fnt);
GdipDeleteStringFormat(format);
ReleaseDC(0, hdc);
}
START_TEST(graphics)
{
struct GdiplusStartupInput gdiplusStartupInput;
@ -954,6 +1005,7 @@ START_TEST(graphics)
test_GdipDrawArcI();
test_GdipDrawLineI();
test_GdipDrawLinesI();
test_GdipDrawString();
test_Get_Release_DC();
test_transformpoints();
test_get_set_clip();

View file

@ -229,6 +229,7 @@ static void test_SavingImages(void)
const REAL WIDTH = 10.0, HEIGHT = 20.0;
REAL w, h;
ImageCodecInfo *codecs;
static const CHAR filenameA[] = "a.bmp";
static const WCHAR filename[] = { 'a','.','b','m','p',0 };
codecs = NULL;
@ -280,7 +281,7 @@ static void test_SavingImages(void)
GdipFree(codecs);
if (bm)
GdipDisposeImage((GpImage*)bm);
ok(DeleteFileW(filename), "Delete failed.\n");
ok(DeleteFileA(filenameA), "Delete failed.\n");
}
static void test_encoders(void)
@ -292,7 +293,7 @@ static void test_encoders(void)
int i;
int bmp_found;
static const WCHAR bmp_format[] = {'B', 'M', 'P', 0};
static const CHAR bmp_format[] = "BMP";
stat = GdipGetImageEncodersSize(&n, &s);
expect(stat, Ok);
@ -319,8 +320,13 @@ static void test_encoders(void)
bmp_found = FALSE;
for (i = 0; i < n; i++)
{
if (CompareStringW(LOCALE_SYSTEM_DEFAULT, 0,
codecs[i].FormatDescription, -1,
CHAR desc[32];
WideCharToMultiByte(CP_ACP, 0, codecs[i].FormatDescription, -1,
desc, 32, 0, 0);
if (CompareStringA(LOCALE_SYSTEM_DEFAULT, 0,
desc, -1,
bmp_format, -1) == CSTR_EQUAL) {
bmp_found = TRUE;
break;
@ -474,7 +480,7 @@ static void test_GdipCreateBitmapFromHBITMAP(void)
expectf(HEIGHT1, height);
if (stat == Ok)
GdipDisposeImage((GpImage*)gpbm);
GlobalFree(hbm);
DeleteObject(hbm);
hbm = CreateBitmap(WIDTH2, HEIGHT2, 1, 1, &buff);
stat = GdipCreateBitmapFromHBITMAP(hbm, NULL, &gpbm);
@ -487,7 +493,7 @@ static void test_GdipCreateBitmapFromHBITMAP(void)
expectf(HEIGHT2, height);
if (stat == Ok)
GdipDisposeImage((GpImage*)gpbm);
GlobalFree(hbm);
DeleteObject(hbm);
hdc = CreateCompatibleDC(0);
ok(hdc != NULL, "CreateCompatibleDC failed\n");
@ -524,8 +530,8 @@ static void test_GdipCreateBitmapFromHBITMAP(void)
if (stat == Ok)
GdipDisposeImage((GpImage*)gpbm);
GlobalFree(hpal);
GlobalFree(hbm);
DeleteObject(hpal);
DeleteObject(hbm);
}
static void test_GdipGetImageFlags(void)
@ -623,7 +629,9 @@ static void test_fromhicon(void)
DeleteObject(hbmColor);
stat = GdipCreateBitmapFromHICON(hIcon, &bitmap);
expect(Ok, stat);
ok(stat == Ok ||
broken(stat == InvalidParameter), /* Win98 */
"Expected Ok, got %.8x\n", stat);
if(stat == Ok){
/* check attributes */
stat = GdipGetImageHeight((GpImage*)bitmap, &dim);

View file

@ -793,12 +793,14 @@ static void test_fromhrgn(void)
status = GdipGetRegionDataSize(region, &needed);
todo_wine{
expect(Ok, status);
expect(216, needed);
ok(needed == 216 ||
needed == 196, /* win98 */
"Got %.8x\n", needed);
}
status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
todo_wine expect(Ok, status);
if(status == Ok)
if(status == Ok && needed == 216) /* Don't try to test win98 layout */
{
todo_wine{
expect(Ok, status);

View file

@ -135,6 +135,7 @@ static HWND hwnd;
static int init(void) {
WNDCLASSEX wc;
HIMC imc;
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = 0;
@ -158,6 +159,14 @@ static int init(void) {
if (!hwnd)
return 0;
imc = ImmGetContext(hwnd);
if (!imc)
{
win_skip("IME support not implemented\n");
return 0;
}
ImmReleaseContext(hwnd, imc);
ShowWindow(hwnd, SW_SHOWNORMAL);
UpdateWindow(hwnd);
@ -173,7 +182,7 @@ static void cleanup(void) {
UnregisterClass(wndcls, GetModuleHandle(0));
}
static int test_ImmNotifyIME(void) {
static void test_ImmNotifyIME(void) {
static const char string[] = "wine";
char resstr[16] = "";
HIMC imc;
@ -216,12 +225,88 @@ static int test_ImmNotifyIME(void) {
msg_spy_flush_msgs();
ImmReleaseContext(hwnd, imc);
}
return 0;
static void test_ImmGetCompositionString(void)
{
HIMC imc;
static const WCHAR string[] = {'w','i','n','e',0x65e5,0x672c,0x8a9e};
char cstring[20];
WCHAR wstring[20];
DWORD len;
DWORD alen,wlen;
imc = ImmGetContext(hwnd);
ImmSetCompositionStringW(imc, SCS_SETSTR, string, sizeof(string), NULL,0);
alen = ImmGetCompositionStringA(imc, GCS_COMPSTR, cstring, 20);
wlen = ImmGetCompositionStringW(imc, GCS_COMPSTR, wstring, 20);
/* windows machines without any IME installed just return 0 above */
if( alen && wlen)
{
len = ImmGetCompositionStringW(imc, GCS_COMPATTR, NULL, 0);
ok(len*sizeof(WCHAR)==wlen,"GCS_COMPATTR(W) not returning correct count\n");
len = ImmGetCompositionStringA(imc, GCS_COMPATTR, NULL, 0);
ok(len==alen,"GCS_COMPATTR(A) not returning correct count\n");
}
ImmReleaseContext(hwnd, imc);
}
static void test_ImmSetCompositionString(void)
{
HIMC imc;
BOOL ret;
SetLastError(0xdeadbeef);
imc = ImmGetContext(hwnd);
ok(imc != 0, "ImmGetContext() failed. Last error: %u\n", GetLastError());
if (!imc)
return;
ret = ImmSetCompositionStringW(imc, SCS_SETSTR, NULL, 0, NULL, 0);
todo_wine
ok(!ret, "ImmSetCompositionStringW() succeeded.\n");
ret = ImmSetCompositionStringW(imc, SCS_SETSTR | SCS_CHANGEATTR,
NULL, 0, NULL, 0);
todo_wine
ok(!ret, "ImmSetCompositionStringW() succeeded.\n");
ret = ImmSetCompositionStringW(imc, SCS_SETSTR | SCS_CHANGECLAUSE,
NULL, 0, NULL, 0);
todo_wine
ok(!ret, "ImmSetCompositionStringW() succeeded.\n");
ret = ImmSetCompositionStringW(imc, SCS_CHANGEATTR | SCS_CHANGECLAUSE,
NULL, 0, NULL, 0);
todo_wine
ok(!ret, "ImmSetCompositionStringW() succeeded.\n");
ImmReleaseContext(hwnd, imc);
}
static void test_ImmIME(void)
{
HIMC imc;
imc = ImmGetContext(hwnd);
if (imc)
{
BOOL rc;
rc = ImmConfigureIMEA(imc, NULL, IME_CONFIG_REGISTERWORD, NULL);
ok (rc == 0, "ImmConfigureIMEA did not fail\n");
rc = ImmConfigureIMEW(imc, NULL, IME_CONFIG_REGISTERWORD, NULL);
ok (rc == 0, "ImmConfigureIMEW did not fail\n");
}
ImmReleaseContext(hwnd,imc);
}
START_TEST(imm32) {
if (init())
{
test_ImmNotifyIME();
test_ImmGetCompositionString();
test_ImmSetCompositionString();
test_ImmIME();
}
cleanup();
}

View file

@ -35,7 +35,7 @@ static void testInit(void)
pInit = (void *)GetProcAddress(inetmib1, "SnmpExtensionInit");
if (!pInit)
{
skip("no SnmpExtensionInit\n");
win_skip("no SnmpExtensionInit\n");
return;
}
/* Crash
@ -72,7 +72,7 @@ static void testQuery(void)
pQuery = (void *)GetProcAddress(inetmib1, "SnmpExtensionQuery");
if (!pQuery)
{
skip("couldn't find SnmpExtensionQuery\n");
win_skip("couldn't find SnmpExtensionQuery\n");
return;
}
/* Crash
@ -473,4 +473,5 @@ START_TEST(main)
inetmib1 = LoadLibraryA("inetmib1");
testInit();
testQuery();
FreeLibrary(inetmib1);
}

View file

@ -35,6 +35,7 @@
*/
#include <stdarg.h>
#include "winsock2.h"
#include "windef.h"
#include "winbase.h"
#include "iphlpapi.h"
@ -43,6 +44,16 @@
#include <stdio.h>
#include <stdlib.h>
#undef htonl
#undef htons
#undef ntohl
#undef ntohs
#define htonl(l) ((u_long)(l))
#define htons(s) ((u_short)(s))
#define ntohl(l) ((u_long)(l))
#define ntohs(s) ((u_short)(s))
static HMODULE hLibrary = NULL;
typedef DWORD (WINAPI *GetNumberOfInterfacesFunc)(PDWORD);
@ -62,6 +73,7 @@ typedef DWORD (WINAPI *GetUdpStatisticsFunc)(PMIB_UDPSTATS);
typedef DWORD (WINAPI *GetTcpTableFunc)(PMIB_TCPTABLE,PDWORD,BOOL);
typedef DWORD (WINAPI *GetUdpTableFunc)(PMIB_UDPTABLE,PDWORD,BOOL);
typedef DWORD (WINAPI *GetPerAdapterInfoFunc)(ULONG,PIP_PER_ADAPTER_INFO,PULONG);
typedef DWORD (WINAPI *GetAdaptersAddressesFunc)(ULONG,ULONG,PVOID,PIP_ADAPTER_ADDRESSES,PULONG);
static GetNumberOfInterfacesFunc gGetNumberOfInterfaces = NULL;
static GetIpAddrTableFunc gGetIpAddrTable = NULL;
@ -80,6 +92,7 @@ static GetUdpStatisticsFunc gGetUdpStatistics = NULL;
static GetTcpTableFunc gGetTcpTable = NULL;
static GetUdpTableFunc gGetUdpTable = NULL;
static GetPerAdapterInfoFunc gGetPerAdapterInfo = NULL;
static GetAdaptersAddressesFunc gGetAdaptersAddresses = NULL;
static void loadIPHlpApi(void)
{
@ -118,6 +131,7 @@ static void loadIPHlpApi(void)
gGetUdpTable = (GetUdpTableFunc)GetProcAddress(
hLibrary, "GetUdpTable");
gGetPerAdapterInfo = (GetPerAdapterInfoFunc)GetProcAddress(hLibrary, "GetPerAdapterInfo");
gGetAdaptersAddresses = (GetAdaptersAddressesFunc)GetProcAddress(hLibrary, "GetAdaptersAddresses");
}
}
@ -145,6 +159,16 @@ static void freeIPHlpApi(void)
}
}
/* replacement for inet_ntoa */
static const char *ntoa( DWORD ip )
{
static char buffer[40];
ip = htonl(ip);
sprintf( buffer, "%u.%u.%u.%u", (ip >> 24) & 0xff, (ip >> 16) & 0xff, (ip >> 8) & 0xff, ip & 0xff );
return buffer;
}
/*
still-to-be-tested 98-only functions:
GetUniDirectionalAdapterInfo
@ -263,6 +287,30 @@ static void testGetIfTable(void)
ok(apiReturn == NO_ERROR,
"GetIfTable(buf, &dwSize, FALSE) returned %d, expected NO_ERROR\n\n",
apiReturn);
if (apiReturn == NO_ERROR && winetest_debug > 1)
{
DWORD i, j;
char name[MAX_INTERFACE_NAME_LEN];
trace( "interface table: %u entries\n", buf->dwNumEntries );
for (i = 0; i < buf->dwNumEntries; i++)
{
MIB_IFROW *row = &buf->table[i];
WideCharToMultiByte( CP_ACP, 0, row->wszName, -1, name, MAX_INTERFACE_NAME_LEN, NULL, NULL );
trace( "%u: '%s' type %u mtu %u speed %u phys",
row->dwIndex, name, row->dwType, row->dwMtu, row->dwSpeed );
for (j = 0; j < row->dwPhysAddrLen; j++)
printf( " %02x", row->bPhysAddr[j] );
printf( "\n" );
trace( " in: bytes %u upkts %u nupkts %u disc %u err %u unk %u\n",
row->dwInOctets, row->dwInUcastPkts, row->dwInNUcastPkts,
row->dwInDiscards, row->dwInErrors, row->dwInUnknownProtos );
trace( " out: bytes %u upkts %u nupkts %u disc %u err %u\n",
row->dwOutOctets, row->dwOutUcastPkts, row->dwOutNUcastPkts,
row->dwOutDiscards, row->dwOutErrors );
}
}
HeapFree(GetProcessHeap(), 0, buf);
}
}
@ -293,6 +341,22 @@ static void testGetIpForwardTable(void)
ok(apiReturn == NO_ERROR,
"GetIpForwardTable(buf, &dwSize, FALSE) returned %d, expected NO_ERROR\n",
apiReturn);
if (apiReturn == NO_ERROR && winetest_debug > 1)
{
DWORD i;
trace( "IP forward table: %u entries\n", buf->dwNumEntries );
for (i = 0; i < buf->dwNumEntries; i++)
{
char buffer[40];
sprintf( buffer, "dest %s", ntoa( buf->table[i].dwForwardDest ));
sprintf( buffer + strlen(buffer), " mask %s", ntoa( buf->table[i].dwForwardMask ));
trace( "%u: %s gw %s if %u type %u\n", i, buffer,
ntoa( buf->table[i].dwForwardNextHop ),
buf->table[i].dwForwardIfIndex, buf->table[i].dwForwardType );
}
}
HeapFree(GetProcessHeap(), 0, buf);
}
}
@ -326,6 +390,21 @@ static void testGetIpNetTable(void)
apiReturn == ERROR_NO_DATA, /* empty ARP table's okay */
"GetIpNetTable(buf, &dwSize, FALSE) returned %d, expected NO_ERROR\n",
apiReturn);
if (apiReturn == NO_ERROR && winetest_debug > 1)
{
DWORD i, j;
trace( "IP net table: %u entries\n", buf->dwNumEntries );
for (i = 0; i < buf->dwNumEntries; i++)
{
trace( "%u: idx %u type %u addr %s phys",
i, buf->table[i].dwIndex, buf->table[i].dwType, ntoa( buf->table[i].dwAddr ));
for (j = 0; j < buf->table[i].dwPhysAddrLen; j++)
printf( " %02x", buf->table[i].bPhysAddr[j] );
printf( "\n" );
}
}
HeapFree(GetProcessHeap(), 0, buf);
}
}
@ -355,6 +434,23 @@ static void testGetIcmpStatistics(void)
}
ok(apiReturn == NO_ERROR,
"GetIcmpStatistics returned %d, expected NO_ERROR\n", apiReturn);
if (apiReturn == NO_ERROR && winetest_debug > 1)
{
trace( "ICMP stats: %8s %8s\n", "in", "out" );
trace( " dwMsgs: %8u %8u\n", stats.stats.icmpInStats.dwMsgs, stats.stats.icmpOutStats.dwMsgs );
trace( " dwErrors: %8u %8u\n", stats.stats.icmpInStats.dwErrors, stats.stats.icmpOutStats.dwErrors );
trace( " dwDestUnreachs: %8u %8u\n", stats.stats.icmpInStats.dwDestUnreachs, stats.stats.icmpOutStats.dwDestUnreachs );
trace( " dwTimeExcds: %8u %8u\n", stats.stats.icmpInStats.dwTimeExcds, stats.stats.icmpOutStats.dwTimeExcds );
trace( " dwParmProbs: %8u %8u\n", stats.stats.icmpInStats.dwParmProbs, stats.stats.icmpOutStats.dwParmProbs );
trace( " dwSrcQuenchs: %8u %8u\n", stats.stats.icmpInStats.dwSrcQuenchs, stats.stats.icmpOutStats.dwSrcQuenchs );
trace( " dwRedirects: %8u %8u\n", stats.stats.icmpInStats.dwRedirects, stats.stats.icmpOutStats.dwRedirects );
trace( " dwEchos: %8u %8u\n", stats.stats.icmpInStats.dwEchos, stats.stats.icmpOutStats.dwEchos );
trace( " dwEchoReps: %8u %8u\n", stats.stats.icmpInStats.dwEchoReps, stats.stats.icmpOutStats.dwEchoReps );
trace( " dwTimestamps: %8u %8u\n", stats.stats.icmpInStats.dwTimestamps, stats.stats.icmpOutStats.dwTimestamps );
trace( " dwTimestampReps: %8u %8u\n", stats.stats.icmpInStats.dwTimestampReps, stats.stats.icmpOutStats.dwTimestampReps );
trace( " dwAddrMasks: %8u %8u\n", stats.stats.icmpInStats.dwAddrMasks, stats.stats.icmpOutStats.dwAddrMasks );
trace( " dwAddrMaskReps: %8u %8u\n", stats.stats.icmpInStats.dwAddrMaskReps, stats.stats.icmpOutStats.dwAddrMaskReps );
}
}
}
@ -375,6 +471,33 @@ static void testGetIpStatistics(void)
apiReturn = gGetIpStatistics(&stats);
ok(apiReturn == NO_ERROR,
"GetIpStatistics returned %d, expected NO_ERROR\n", apiReturn);
if (apiReturn == NO_ERROR && winetest_debug > 1)
{
trace( "IP stats:\n" );
trace( " dwForwarding: %u\n", stats.dwForwarding );
trace( " dwDefaultTTL: %u\n", stats.dwDefaultTTL );
trace( " dwInReceives: %u\n", stats.dwInReceives );
trace( " dwInHdrErrors: %u\n", stats.dwInHdrErrors );
trace( " dwInAddrErrors: %u\n", stats.dwInAddrErrors );
trace( " dwForwDatagrams: %u\n", stats.dwForwDatagrams );
trace( " dwInUnknownProtos: %u\n", stats.dwInUnknownProtos );
trace( " dwInDiscards: %u\n", stats.dwInDiscards );
trace( " dwInDelivers: %u\n", stats.dwInDelivers );
trace( " dwOutRequests: %u\n", stats.dwOutRequests );
trace( " dwRoutingDiscards: %u\n", stats.dwRoutingDiscards );
trace( " dwOutDiscards: %u\n", stats.dwOutDiscards );
trace( " dwOutNoRoutes: %u\n", stats.dwOutNoRoutes );
trace( " dwReasmTimeout: %u\n", stats.dwReasmTimeout );
trace( " dwReasmReqds: %u\n", stats.dwReasmReqds );
trace( " dwReasmOks: %u\n", stats.dwReasmOks );
trace( " dwReasmFails: %u\n", stats.dwReasmFails );
trace( " dwFragOks: %u\n", stats.dwFragOks );
trace( " dwFragFails: %u\n", stats.dwFragFails );
trace( " dwFragCreates: %u\n", stats.dwFragCreates );
trace( " dwNumIf: %u\n", stats.dwNumIf );
trace( " dwNumAddr: %u\n", stats.dwNumAddr );
trace( " dwNumRoutes: %u\n", stats.dwNumRoutes );
}
}
}
@ -395,6 +518,25 @@ static void testGetTcpStatistics(void)
apiReturn = gGetTcpStatistics(&stats);
ok(apiReturn == NO_ERROR,
"GetTcpStatistics returned %d, expected NO_ERROR\n", apiReturn);
if (apiReturn == NO_ERROR && winetest_debug > 1)
{
trace( "TCP stats:\n" );
trace( " dwRtoAlgorithm: %u\n", stats.dwRtoAlgorithm );
trace( " dwRtoMin: %u\n", stats.dwRtoMin );
trace( " dwRtoMax: %u\n", stats.dwRtoMax );
trace( " dwMaxConn: %u\n", stats.dwMaxConn );
trace( " dwActiveOpens: %u\n", stats.dwActiveOpens );
trace( " dwPassiveOpens: %u\n", stats.dwPassiveOpens );
trace( " dwAttemptFails: %u\n", stats.dwAttemptFails );
trace( " dwEstabResets: %u\n", stats.dwEstabResets );
trace( " dwCurrEstab: %u\n", stats.dwCurrEstab );
trace( " dwInSegs: %u\n", stats.dwInSegs );
trace( " dwOutSegs: %u\n", stats.dwOutSegs );
trace( " dwRetransSegs: %u\n", stats.dwRetransSegs );
trace( " dwInErrs: %u\n", stats.dwInErrs );
trace( " dwOutRsts: %u\n", stats.dwOutRsts );
trace( " dwNumConns: %u\n", stats.dwNumConns );
}
}
}
@ -415,6 +557,15 @@ static void testGetUdpStatistics(void)
apiReturn = gGetUdpStatistics(&stats);
ok(apiReturn == NO_ERROR,
"GetUdpStatistics returned %d, expected NO_ERROR\n", apiReturn);
if (apiReturn == NO_ERROR && winetest_debug > 1)
{
trace( "UDP stats:\n" );
trace( " dwInDatagrams: %u\n", stats.dwInDatagrams );
trace( " dwNoPorts: %u\n", stats.dwNoPorts );
trace( " dwInErrors: %u\n", stats.dwInErrors );
trace( " dwOutDatagrams: %u\n", stats.dwOutDatagrams );
trace( " dwNumAddrs: %u\n", stats.dwNumAddrs );
}
}
}
@ -424,15 +575,11 @@ static void testGetTcpTable(void)
DWORD apiReturn;
ULONG dwSize = 0;
apiReturn = gGetTcpTable(NULL, NULL, FALSE);
apiReturn = gGetTcpTable(NULL, &dwSize, FALSE);
if (apiReturn == ERROR_NOT_SUPPORTED) {
skip("GetTcpTable is not supported\n");
return;
}
ok(apiReturn == ERROR_INVALID_PARAMETER,
"GetTcpTable(NULL, NULL, FALSE) returned %d, expected ERROR_INVALID_PARAMETER\n",
apiReturn);
apiReturn = gGetTcpTable(NULL, &dwSize, FALSE);
ok(apiReturn == ERROR_INSUFFICIENT_BUFFER ||
broken(apiReturn == ERROR_NO_DATA), /* win95 */
"GetTcpTable(NULL, &dwSize, FALSE) returned %d, expected ERROR_INSUFFICIENT_BUFFER\n",
@ -444,6 +591,21 @@ static void testGetTcpTable(void)
ok(apiReturn == NO_ERROR,
"GetTcpTable(buf, &dwSize, FALSE) returned %d, expected NO_ERROR\n",
apiReturn);
if (apiReturn == NO_ERROR && winetest_debug > 1)
{
DWORD i;
trace( "TCP table: %u entries\n", buf->dwNumEntries );
for (i = 0; i < buf->dwNumEntries; i++)
{
char buffer[40];
sprintf( buffer, "local %s:%u",
ntoa(buf->table[i].dwLocalAddr), ntohs(buf->table[i].dwLocalPort) );
trace( "%u: %s remote %s:%u state %u\n",
i, buffer, ntoa( buf->table[i].dwRemoteAddr ),
ntohs(buf->table[i].dwRemotePort), buf->table[i].dwState );
}
}
HeapFree(GetProcessHeap(), 0, buf);
}
}
@ -455,25 +617,30 @@ static void testGetUdpTable(void)
DWORD apiReturn;
ULONG dwSize = 0;
apiReturn = gGetUdpTable(NULL, NULL, FALSE);
apiReturn = gGetUdpTable(NULL, &dwSize, FALSE);
if (apiReturn == ERROR_NOT_SUPPORTED) {
skip("GetUdpTable is not supported\n");
return;
}
ok(apiReturn == ERROR_INVALID_PARAMETER,
"GetUdpTable(NULL, NULL, FALSE) returned %d, expected ERROR_INVALID_PARAMETER\n",
apiReturn);
apiReturn = gGetUdpTable(NULL, &dwSize, FALSE);
ok(apiReturn == ERROR_INSUFFICIENT_BUFFER,
"GetUdpTable(NULL, &dwSize, FALSE) returned %d, expected ERROR_INSUFFICIENT_BUFFER\n",
apiReturn);
if (apiReturn != ERROR_INSUFFICIENT_BUFFER) {
if (apiReturn == ERROR_INSUFFICIENT_BUFFER) {
PMIB_UDPTABLE buf = HeapAlloc(GetProcessHeap(), 0, dwSize);
apiReturn = gGetUdpTable(buf, &dwSize, FALSE);
ok(apiReturn == NO_ERROR,
"GetUdpTable(buf, &dwSize, FALSE) returned %d, expected NO_ERROR\n",
apiReturn);
if (apiReturn == NO_ERROR && winetest_debug > 1)
{
DWORD i;
trace( "UDP table: %u entries\n", buf->dwNumEntries );
for (i = 0; i < buf->dwNumEntries; i++)
trace( "%u: %s:%u\n",
i, ntoa( buf->table[i].dwLocalAddr ), ntohs(buf->table[i].dwLocalPort) );
}
HeapFree(GetProcessHeap(), 0, buf);
}
}
@ -657,6 +824,71 @@ static void testWin2KFunctions(void)
testGetPerAdapterInfo();
}
static void test_GetAdaptersAddresses(void)
{
ULONG ret, size;
IP_ADAPTER_ADDRESSES *aa;
IP_ADAPTER_UNICAST_ADDRESS *ua;
if (!gGetAdaptersAddresses)
{
win_skip("GetAdaptersAddresses not present\n");
return;
}
ret = gGetAdaptersAddresses(AF_UNSPEC, 0, NULL, NULL, NULL);
ok(ret == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER got %u\n", ret);
ret = gGetAdaptersAddresses(AF_UNSPEC, 0, NULL, NULL, &size);
ok(ret == ERROR_BUFFER_OVERFLOW, "expected ERROR_BUFFER_OVERFLOW, got %u\n", ret);
if (ret != ERROR_BUFFER_OVERFLOW) return;
aa = HeapAlloc(GetProcessHeap(), 0, size);
ret = gGetAdaptersAddresses(AF_UNSPEC, 0, NULL, aa, &size);
ok(!ret, "expected ERROR_SUCCESS got %u\n", ret);
while (!ret && winetest_debug > 1 && aa)
{
trace("Length: %u\n", aa->Length);
trace("IfIndex: %u\n", aa->IfIndex);
trace("Next: %p\n", aa->Next);
trace("AdapterName: %s\n", aa->AdapterName);
trace("FirstUnicastAddress: %p\n", aa->FirstUnicastAddress);
ua = aa->FirstUnicastAddress;
while (ua)
{
trace("\tLength: %u\n", ua->Length);
trace("\tFlags: 0x%08x\n", ua->Flags);
trace("\tNext: %p\n", ua->Next);
trace("\tAddress.lpSockaddr: %p\n", ua->Address.lpSockaddr);
trace("\tAddress.iSockaddrLength: %d\n", ua->Address.iSockaddrLength);
trace("\tPrefixOrigin: %u\n", ua->PrefixOrigin);
trace("\tSuffixOrigin: %u\n", ua->SuffixOrigin);
trace("\tDadState: %u\n", ua->DadState);
trace("\tValidLifetime: 0x%08x\n", ua->ValidLifetime);
trace("\tPreferredLifetime: 0x%08x\n", ua->PreferredLifetime);
trace("\tLeaseLifetime: 0x%08x\n", ua->LeaseLifetime);
trace("\n");
ua = ua->Next;
}
trace("FirstAnycastAddress: %p\n", aa->FirstAnycastAddress);
trace("FirstMulticastAddress: %p\n", aa->FirstMulticastAddress);
trace("FirstDnsServerAddress: %p\n", aa->FirstDnsServerAddress);
trace("DnsSuffix: %p\n", aa->DnsSuffix);
trace("Description: %p\n", aa->Description);
trace("FriendlyName: %p\n", aa->FriendlyName);
trace("PhysicalAddress: %02x\n", aa->PhysicalAddress[0]);
trace("PhysicalAddressLength: %u\n", aa->PhysicalAddressLength);
trace("Flags: 0x%08x\n", aa->Flags);
trace("Mtu: %u\n", aa->Mtu);
trace("IfType: %u\n", aa->IfType);
trace("OperStatus: %u\n", aa->OperStatus);
trace("\n");
aa = aa->Next;
}
HeapFree(GetProcessHeap(), 0, aa);
}
START_TEST(iphlpapi)
{
@ -666,6 +898,7 @@ START_TEST(iphlpapi)
testWinNT4Functions();
testWin98Functions();
testWin2KFunctions();
test_GetAdaptersAddresses();
freeIPHlpApi();
}
}

View file

@ -579,6 +579,36 @@ ok(tmp === Infinity, "Math.abs(-Infinite) = " + tmp);
tmp = Math.abs(-3, 2);
ok(tmp === 3, "Math.abs(-3, 2) = " + tmp);
tmp = Math.cos(0);
ok(tmp === 1, "Math.cos(0) = " + tmp);
tmp = Math.cos(Math.PI/2);
ok(Math.floor(tmp*100) === 0, "Math.cos(Math.PI/2) = " + tmp);
tmp = Math.cos(-Math.PI/2);
ok(Math.floor(tmp*100) === 0, "Math.cos(-Math.PI/2) = " + tmp);
tmp = Math.cos(Math.PI/3, 2);
ok(Math.floor(tmp*100) === 50, "Math.cos(Math.PI/3, 2) = " + tmp);
tmp = Math.cos(true);
ok(Math.floor(tmp*100) === 54, "Math.cos(true) = " + tmp);
tmp = Math.cos(false);
ok(tmp === 1, "Math.cos(false) = " + tmp);
tmp = Math.cos();
ok(isNaN(tmp), "Math.cos() is not NaN");
tmp = Math.cos(NaN);
ok(isNaN(tmp), "Math.cos(NaN) is not NaN");
tmp = Math.cos(Infinity);
ok(isNaN(tmp), "Math.cos(Infinity) is not NaN");
tmp = Math.cos(-Infinity);
ok(isNaN(tmp), "Math.cos(-Infinity) is not NaN");
tmp = Math.pow(2, 2);
ok(tmp === 4, "Math.pow(2, 2) = " + tmp);
@ -640,4 +670,9 @@ ok(Math.floor(Math.LOG10E*100) === 43, "Math.LOG10E = " + Math.LOG10E);
Math.LOG10E = "test";
ok(Math.floor(Math.LOG10E*100) === 43, "modified Math.LOG10E = " + Math.LOG10E);
ok(typeof(Math.LN2) === "number", "typeof(Math.LN2) = " + typeof(Math.LN2));
ok(Math.floor(Math.LN2*100) === 69, "Math.LN2 = " + Math.LN2);
Math.LN2 = "test";
ok(Math.floor(Math.LN2*100) === 69, "modified Math.LN2 = " + Math.LN2);
reportSuccess();

View file

@ -600,6 +600,47 @@ static void parse_script(BSTR script_str)
IUnknown_Release(parser);
}
static HRESULT parse_htmlscript(BSTR script_str)
{
IActiveScriptParse *parser;
IActiveScript *engine;
HRESULT hres;
BSTR tmp = a2bstr("</SCRIPT>");
engine = create_script();
if(!engine)
return E_FAIL;
hres = IActiveScript_QueryInterface(engine, &IID_IActiveScriptParse, (void**)&parser);
ok(hres == S_OK, "Could not get IActiveScriptParse: %08x\n", hres);
if (FAILED(hres))
{
IActiveScript_Release(engine);
return E_FAIL;
}
hres = IActiveScriptParse64_InitNew(parser);
ok(hres == S_OK, "InitNew failed: %08x\n", hres);
hres = IActiveScript_SetScriptSite(engine, &ActiveScriptSite);
ok(hres == S_OK, "SetScriptSite failed: %08x\n", hres);
hres = IActiveScript_AddNamedItem(engine, testW,
SCRIPTITEM_ISVISIBLE|SCRIPTITEM_ISSOURCE|SCRIPTITEM_GLOBALMEMBERS);
ok(hres == S_OK, "AddNamedItem failed: %08x\n", hres);
hres = IActiveScript_SetScriptState(engine, SCRIPTSTATE_STARTED);
ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_STARTED) failed: %08x\n", hres);
hres = IActiveScriptParse64_ParseScriptText(parser, script_str, NULL, NULL, tmp, 0, 0, 0, NULL, NULL);
IActiveScript_Release(engine);
IUnknown_Release(parser);
SysFreeString(tmp);
return hres;
}
static void parse_script_a(const char *src)
{
BSTR tmp = a2bstr(src);
@ -607,6 +648,16 @@ static void parse_script_a(const char *src)
SysFreeString(tmp);
}
static HRESULT parse_htmlscript_a(const char *src)
{
HRESULT hres;
BSTR tmp = a2bstr(src);
hres = parse_htmlscript(tmp);
SysFreeString(tmp);
return hres;
}
static BSTR get_script_from_file(const char *filename)
{
DWORD size, len;
@ -741,6 +792,8 @@ static void test_isvisible(BOOL global_members)
static void run_tests(void)
{
HRESULT hres;
strict_dispid_check = TRUE;
parse_script_a("");
@ -776,6 +829,19 @@ static void run_tests(void)
test_isvisible(FALSE);
test_isvisible(TRUE);
hres = parse_htmlscript_a("<!--");
ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres);
hres = parse_htmlscript_a("-->");
ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres);
hres = parse_htmlscript_a("<!--\nvar a=1;\n-->\n");
ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres);
hres = parse_htmlscript_a("<!--\n<!-- ignore this\n-->\n");
ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres);
hres = parse_htmlscript_a("var a=1;\nif(a-->0) a=5;\n");
ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres);
hres = parse_htmlscript_a("var a=1;\nif(a\n-->0) a=5;\n");
ok(hres != S_OK, "ParseScriptText have not failed\n");
}
START_TEST(run)

View file

@ -43,6 +43,14 @@ static const char* strw(LPCWSTR x)
return buffer;
}
#ifdef __i386__
#define ARCH "x86"
#elif defined __x86_64__
#define ARCH "amd64"
#else
#define ARCH "none"
#endif
static const char manifest1[] =
"<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
"<assemblyIdentity version=\"1.0.0.0\" name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
@ -54,7 +62,7 @@ static const char manifest2[] =
"</assemblyIdentity>"
"<dependency>"
"<dependentAssembly>"
"<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.3\" processorArchitecture=\"x86\">"
"<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.3\" processorArchitecture=\"" ARCH "\">"
"</assemblyIdentity>"
"</dependentAssembly>"
"</dependency>"
@ -76,7 +84,7 @@ static const char manifest4[] =
"<dependency>"
"<dependentAssembly>"
"<assemblyIdentity type=\"win32\" name=\"Microsoft.Windows.Common-Controls\" "
"version=\"6.0.1.0\" processorArchitecture=\"x86\" publicKeyToken=\"6595b64144ccf1df\">"
"version=\"6.0.1.0\" processorArchitecture=\"" ARCH "\" publicKeyToken=\"6595b64144ccf1df\">"
"</assemblyIdentity>"
"</dependentAssembly>"
"</dependency>"
@ -84,19 +92,19 @@ static const char manifest4[] =
static const char testdep_manifest1[] =
"<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
"<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.3\" processorArchitecture=\"x86\"/>"
"<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.3\" processorArchitecture=\"" ARCH "\"/>"
"</assembly>";
static const char testdep_manifest2[] =
"<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
"<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.3\" processorArchitecture=\"x86\" />"
"<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.3\" processorArchitecture=\"" ARCH "\" />"
"<file name=\"testlib.dll\"></file>"
"<file name=\"testlib2.dll\" hash=\"63c978c2b53d6cf72b42fb7308f9af12ab19ec53\" hashalg=\"SHA1\" />"
"</assembly>";
static const char testdep_manifest3[] =
"<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\"> "
"<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.3\" processorArchitecture=\"x86\"/>"
"<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.3\" processorArchitecture=\"" ARCH "\"/>"
"<file name=\"testlib.dll\"/>"
"<file name=\"testlib2.dll\" hash=\"63c978c2b53d6cf72b42fb7308f9af12ab19ec53\" hashalg=\"SHA1\">"
"<windowClass>wndClass</windowClass>"
@ -138,7 +146,7 @@ static const char wrong_manifest6[] =
static const char wrong_manifest7[] =
"<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
"<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.3\" processorArchitecture=\"x86\" />"
"<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.3\" processorArchitecture=\"" ARCH "\" />"
"<file name=\"testlib.dll\" hash=\"63c978c2b53d6cf72b42fb7308f9af12ab19ec5\" hashalg=\"SHA1\" />"
"</assembly>";
@ -150,7 +158,7 @@ static const char wrong_manifest8[] =
static const char wrong_depmanifest1[] =
"<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
"<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.4\" processorArchitecture=\"x86\" />"
"<assemblyIdentity type=\"win32\" name=\"testdep\" version=\"6.5.4.4\" processorArchitecture=\"" ARCH "\" />"
"</assembly>";
static const WCHAR testlib_dll[] =
@ -386,21 +394,21 @@ static const info_in_assembly manifest4_info = {
static const info_in_assembly depmanifest1_info = {
0x10, depmanifest_path,
"testdep,processorArchitecture=\"x86\","
"testdep,processorArchitecture=\"" ARCH "\","
"type=\"win32\",version=\"6.5.4.3\"",
TRUE
};
static const info_in_assembly depmanifest2_info = {
0x10, depmanifest_path,
"testdep,processorArchitecture=\"x86\","
"testdep,processorArchitecture=\"" ARCH "\","
"type=\"win32\",version=\"6.5.4.3\"",
TRUE
};
static const info_in_assembly depmanifest3_info = {
0x10, depmanifest_path,
"testdep,processorArchitecture=\"x86\",type=\"win32\",version=\"6.5.4.3\"",
"testdep,processorArchitecture=\"" ARCH "\",type=\"win32\",version=\"6.5.4.3\"",
TRUE
};
@ -1202,7 +1210,7 @@ START_TEST(actctx)
if (!init_funcs())
{
skip("Needed functions are not available\n");
win_skip("Needed functions are not available\n");
return;
}
init_paths();

View file

@ -77,7 +77,7 @@ static BOOL unicode_OS;
static void test_add_atom(void)
{
ATOM atom, w_atom;
int i;
INT_PTR i;
SetLastError( 0xdeadbeef );
atom = GlobalAddAtomA( "foobar" );
@ -129,20 +129,20 @@ static void test_add_atom(void)
{
SetLastError( 0xdeadbeef );
ok( GlobalAddAtomA((LPCSTR)i) == i && GetLastError() == 0xdeadbeef,
"failed to add atom %x\n", i );
"failed to add atom %lx\n", i );
if (unicode_OS)
{
SetLastError( 0xdeadbeef );
ok( GlobalAddAtomW((LPCWSTR)i) == i && GetLastError() == 0xdeadbeef,
"failed to add atom %x\n", i );
"failed to add atom %lx\n", i );
}
}
for (i = 0xc000; i <= 0xffff; i++)
{
ok( !GlobalAddAtomA((LPCSTR)i), "succeeded adding %x\n", i );
ok( !GlobalAddAtomA((LPCSTR)i), "succeeded adding %lx\n", i );
if (unicode_OS)
ok( !GlobalAddAtomW((LPCWSTR)i), "succeeded adding %x\n", i );
ok( !GlobalAddAtomW((LPCWSTR)i), "succeeded adding %lx\n", i );
}
}
@ -201,6 +201,7 @@ static void test_get_atom_name(void)
sprintf( res, "#%d", i );
memset( res + strlen(res) + 1, 'a', 10 );
ok( !memcmp( res, buf, 10 ), "bad buffer contents %s\n", buf );
if (len <= 1 || len >= 7) break; /* don't bother testing all of them */
}
else
ok( !len, "bad length %d\n", len );
@ -283,6 +284,7 @@ static void test_get_atom_name(void)
print_integral( res, i );
memset( res + lstrlenW(res) + 1, 'a', 10 * sizeof(WCHAR));
ok( !memcmp( res, outW, 10 * sizeof(WCHAR) ), "bad buffer contents for %d\n", i );
if (len <= 1 || len >= 7) break; /* don't bother testing all of them */
}
else
ok( !len, "bad length %d\n", len );
@ -349,7 +351,7 @@ static void test_error_handling(void)
static void test_local_add_atom(void)
{
ATOM atom, w_atom;
int i;
INT_PTR i;
SetLastError( 0xdeadbeef );
atom = AddAtomA( "foobar" );
@ -401,20 +403,20 @@ static void test_local_add_atom(void)
{
SetLastError( 0xdeadbeef );
ok( AddAtomA((LPCSTR)i) == i && GetLastError() == 0xdeadbeef,
"failed to add atom %x\n", i );
"failed to add atom %lx\n", i );
if (unicode_OS)
{
SetLastError( 0xdeadbeef );
ok( AddAtomW((LPCWSTR)i) == i && GetLastError() == 0xdeadbeef,
"failed to add atom %x\n", i );
"failed to add atom %lx\n", i );
}
}
for (i = 0xc000; i <= 0xffff; i++)
{
ok( !AddAtomA((LPCSTR)i), "succeeded adding %x\n", i );
ok( !AddAtomA((LPCSTR)i), "succeeded adding %lx\n", i );
if (unicode_OS)
ok( !AddAtomW((LPCWSTR)i), "succeeded adding %x\n", i );
ok( !AddAtomW((LPCWSTR)i), "succeeded adding %lx\n", i );
}
}

View file

@ -38,7 +38,7 @@
static DWORD CALLBACK NotificationThread(LPVOID arg)
{
HANDLE change = (HANDLE) arg;
HANDLE change = arg;
BOOL notified = FALSE;
BOOL ret = FALSE;
DWORD status;
@ -65,8 +65,7 @@ static HANDLE StartNotificationThread(LPCSTR path, BOOL subtree, DWORD flags)
change = FindFirstChangeNotificationA(path, subtree, flags);
ok(change != INVALID_HANDLE_VALUE, "FindFirstChangeNotification error: %d\n", GetLastError());
thread = CreateThread(NULL, 0, NotificationThread, (LPVOID)change,
0, &threadId);
thread = CreateThread(NULL, 0, NotificationThread, change, 0, &threadId);
ok(thread != NULL, "CreateThread error: %d\n", GetLastError());
return thread;
@ -264,7 +263,7 @@ static void test_ffcn(void)
r = GetTempPathW( MAX_PATH, path );
if (!r && (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED))
{
skip("GetTempPathW is not implemented\n");
win_skip("GetTempPathW is not implemented\n");
return;
}
ok( r != 0, "temp path failed\n");
@ -356,8 +355,8 @@ static void test_ffcnMultipleThreads(void)
* directory object with an empty wine user APC queue for this thread (bug #7286) */
/* Create our notification thread */
handles[1] = CreateThread(NULL, 0, NotificationThread, (LPVOID)handles[0],
0, &threadId);
handles[1] = CreateThread(NULL, 0, NotificationThread, handles[0], 0,
&threadId);
ok(handles[1] != NULL, "CreateThread error: %d\n", GetLastError());
status = WaitForMultipleObjects(2, handles, FALSE, 5000);
@ -387,7 +386,7 @@ static void test_readdirectorychanges(void)
if (!pReadDirectoryChangesW)
{
skip("ReadDirectoryChangesW is not available\n");
win_skip("ReadDirectoryChangesW is not available\n");
return;
}
@ -395,7 +394,7 @@ static void test_readdirectorychanges(void)
r = GetTempPathW( MAX_PATH, path );
if (!r && (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED))
{
skip("GetTempPathW is not implemented\n");
win_skip("GetTempPathW is not implemented\n");
return;
}
ok( r != 0, "temp path failed\n");
@ -615,14 +614,14 @@ static void test_readdirectorychanges_null(void)
if (!pReadDirectoryChangesW)
{
skip("ReadDirectoryChangesW is not available\n");
win_skip("ReadDirectoryChangesW is not available\n");
return;
}
SetLastError(0xdeadbeef);
r = GetTempPathW( MAX_PATH, path );
if (!r && (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED))
{
skip("GetTempPathW is not implemented\n");
win_skip("GetTempPathW is not implemented\n");
return;
}
ok( r != 0, "temp path failed\n");
@ -717,7 +716,7 @@ static void test_readdirectorychanges_filedir(void)
r = GetTempPathW( MAX_PATH, path );
if (!r && (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED))
{
skip("GetTempPathW is not implemented\n");
win_skip("GetTempPathW is not implemented\n");
return;
}
ok( r != 0, "temp path failed\n");
@ -848,8 +847,8 @@ static void test_ffcn_directory_overlap(void)
ret = FindCloseChangeNotification(parent_watch);
ok(ret, "FindCloseChangeNotification error: %d\n", GetLastError());
child_thread = CreateThread(NULL, 0, NotificationThread,
(LPVOID)child_watch, 0, &threadId);
child_thread = CreateThread(NULL, 0, NotificationThread, child_watch, 0,
&threadId);
ok(child_thread != NULL, "CreateThread error: %d\n", GetLastError());
/* Create a file in child */

View file

@ -205,7 +205,7 @@ static void test_overlapped_buffers(void)
int ret;
SetLastError(0xdeadbeef);
memcpy((WCHAR *)(buf + 1), strW, sizeof(strW));
memcpy(buf + 1, strW, sizeof(strW));
ret = WideCharToMultiByte(CP_ACP, 0, (WCHAR *)(buf + 1), -1, buf, sizeof(buf), NULL, NULL);
ok(ret == sizeof(strA), "unexpected ret %d\n", ret);
ok(!memcmp(buf, strA, sizeof(strA)), "conversion failed: %s\n", buf);

View file

@ -1161,15 +1161,14 @@ static void test_WaitRx(HANDLE hcom)
*/
static DWORD CALLBACK toggle_ctlLine(LPVOID arg)
{
DWORD *args = (DWORD *) arg;
DWORD_PTR *args = arg;
DWORD timeout = args[0];
DWORD ctl = args[1];
HANDLE hcom = (HANDLE) args[2];
HANDLE hComPortEvent = (HANDLE) args[3];
DWORD success, err;
trace("toggle_ctlLine timeout %d clt 0x%08x handle 0x%08x\n",
args[0], args[1], args[2]);
trace("toggle_ctlLine timeout %d ctl 0x%08x handle %p\n", timeout, ctl, hcom );
Sleep(timeout);
ok(EscapeCommFunction(hcom, ctl),"EscapeCommFunction 0x%08x failed\n", ctl);
trace("toggle_ctline done\n");
@ -1190,8 +1189,8 @@ static void test_WaitCts(HANDLE hcom)
OVERLAPPED overlapped;
HANDLE hComPortEvent;
HANDLE alarmThread;
DWORD args[4], defaultStat = 0;
DWORD alarmThreadId, before, after, after1, diff, success, err, written, evtmask=0;
DWORD_PTR args[4];
DWORD alarmThreadId, before, after, after1, diff, success, err, written, evtmask=0, defaultStat = 0;
ok(GetCommState(hcom, &dcb), "GetCommState failed\n");
dcb.fRtsControl=RTS_CONTROL_ENABLE;
@ -1208,15 +1207,15 @@ static void test_WaitCts(HANDLE hcom)
args[1] = CLRRTS;
else
args[1] = SETRTS;
args[2]=(DWORD) hcom;
args[2]=(DWORD_PTR)hcom;
trace("test_WaitCts timeout %d clt 0x%08x handle 0x%08x\n",args[0], args[1], args[2]);
trace("test_WaitCts timeout %ld clt 0x%08lx handle %p\n",args[0], args[1], hcom);
ok(SetCommMask(hcom, EV_CTS), "SetCommMask failed\n");
hComPortEvent = CreateEvent( NULL, TRUE, FALSE, NULL );
ok(hComPortEvent != 0, "CreateEvent failed\n");
args[3] = (DWORD) hComPortEvent;
alarmThread = CreateThread(NULL, 0, toggle_ctlLine, (void *) &args, 0, &alarmThreadId);
args[3] = (DWORD_PTR)hComPortEvent;
alarmThread = CreateThread(NULL, 0, toggle_ctlLine, args, 0, &alarmThreadId);
/* Wait a minimum to let the thread start up */
Sleep(10);
trace("Thread created\n");
@ -1265,7 +1264,7 @@ static void test_WaitCts(HANDLE hcom)
*/
static DWORD CALLBACK reset_CommMask(LPVOID arg)
{
DWORD *args = (DWORD *) arg;
DWORD_PTR *args = arg;
DWORD timeout = args[0];
HANDLE hcom = (HANDLE) args[1];
@ -1287,7 +1286,7 @@ static void test_AbortWaitCts(HANDLE hcom)
OVERLAPPED overlapped;
HANDLE hComPortEvent;
HANDLE alarmThread;
DWORD args[2];
DWORD_PTR args[2];
DWORD alarmThreadId, before, after, after1, diff, success, err, written, evtmask=0;
ok(GetCommState(hcom, &dcb), "GetCommState failed\n");
@ -1297,14 +1296,14 @@ static void test_AbortWaitCts(HANDLE hcom)
return;
}
args[0]= TIMEOUT >>1;
args[1]=(DWORD) hcom;
args[1]= (DWORD_PTR)hcom;
trace("test_AbortWaitCts timeout %d handle 0x%08x\n",args[0], args[1]);
trace("test_AbortWaitCts timeout %ld handle %p\n",args[0], hcom);
ok(SetCommMask(hcom, EV_CTS), "SetCommMask failed\n");
hComPortEvent = CreateEvent( NULL, TRUE, FALSE, NULL );
ok(hComPortEvent != 0, "CreateEvent failed\n");
alarmThread = CreateThread(NULL, 0, reset_CommMask, (void *) &args, 0, &alarmThreadId);
alarmThread = CreateThread(NULL, 0, reset_CommMask, args, 0, &alarmThreadId);
/* Wait a minimum to let the thread start up */
Sleep(10);
trace("Thread created\n");
@ -1348,8 +1347,8 @@ static void test_WaitDsr(HANDLE hcom)
OVERLAPPED overlapped;
HANDLE hComPortEvent;
HANDLE alarmThread;
DWORD args[3], defaultStat = 0;
DWORD alarmThreadId, before, after, after1, diff, success, err, written, evtmask=0;
DWORD_PTR args[3];
DWORD alarmThreadId, before, after, after1, diff, success, err, written, evtmask=0, defaultStat = 0;
ok(GetCommState(hcom, &dcb), "GetCommState failed\n");
if (dcb.fDtrControl == DTR_CONTROL_DISABLE)
@ -1363,14 +1362,14 @@ static void test_WaitDsr(HANDLE hcom)
args[1] = CLRDTR;
else
args[1] = SETDTR;
args[2]=(DWORD) hcom;
args[2]= (DWORD_PTR)hcom;
trace("test_WaitDsr timeout %d clt 0x%08x handle 0x%08x\n",args[0], args[1], args[2]);
trace("test_WaitDsr timeout %ld clt 0x%08lx handle %p\n",args[0], args[1], hcom);
ok(SetCommMask(hcom, EV_DSR), "SetCommMask failed\n");
hComPortEvent = CreateEvent( NULL, TRUE, FALSE, NULL );
ok(hComPortEvent != 0, "CreateEvent failed\n");
alarmThread = CreateThread(NULL, 0, toggle_ctlLine, (void *) &args, 0, &alarmThreadId);
alarmThread = CreateThread(NULL, 0, toggle_ctlLine, args, 0, &alarmThreadId);
ok(alarmThread !=0 , "CreateThread Failed\n");
ZeroMemory( &overlapped, sizeof(overlapped));
@ -1421,8 +1420,8 @@ static void test_WaitRing(HANDLE hcom)
OVERLAPPED overlapped;
HANDLE hComPortEvent;
HANDLE alarmThread;
DWORD args[3], defaultStat;
DWORD alarmThreadId, before, after, after1, diff, success, err, written, evtmask=0;
DWORD_PTR args[3];
DWORD alarmThreadId, before, after, after1, diff, success, err, written, evtmask=0, defaultStat;
BOOL ret;
ok(GetCommState(hcom, &dcb), "GetCommState failed\n");
@ -1441,14 +1440,14 @@ static void test_WaitRing(HANDLE hcom)
args[1] = CLRDTR;
else
args[1] = SETDTR;
args[2]=(DWORD) hcom;
args[2]=(DWORD_PTR) hcom;
trace("test_WaitRing timeout %d clt 0x%08x handle 0x%08x\n",args[0], args[1], args[2]);
trace("test_WaitRing timeout %ld clt 0x%08lx handle %p\n",args[0], args[1], hcom);
ok(SetCommMask(hcom, EV_RING), "SetCommMask failed\n");
hComPortEvent = CreateEvent( NULL, TRUE, FALSE, NULL );
ok(hComPortEvent != 0, "CreateEvent failed\n");
alarmThread = CreateThread(NULL, 0, toggle_ctlLine, (void *) &args, 0, &alarmThreadId);
alarmThread = CreateThread(NULL, 0, toggle_ctlLine, args, 0, &alarmThreadId);
ok(alarmThread !=0 , "CreateThread Failed\n");
ZeroMemory( &overlapped, sizeof(overlapped));
@ -1498,8 +1497,8 @@ static void test_WaitDcd(HANDLE hcom)
OVERLAPPED overlapped;
HANDLE hComPortEvent;
HANDLE alarmThread;
DWORD args[3], defaultStat = 0;
DWORD alarmThreadId, before, after, after1, diff, success, err, written, evtmask=0;
DWORD_PTR args[3];
DWORD alarmThreadId, before, after, after1, diff, success, err, written, evtmask=0, defaultStat = 0;
ok(GetCommState(hcom, &dcb), "GetCommState failed\n");
if (dcb.fDtrControl == DTR_CONTROL_DISABLE)
@ -1513,14 +1512,14 @@ static void test_WaitDcd(HANDLE hcom)
args[1] = CLRDTR;
else
args[1] = SETDTR;
args[2]=(DWORD) hcom;
args[2]= (DWORD_PTR)hcom;
trace("test_WaitDcd timeout %d clt 0x%08x handle 0x%08x\n",args[0], args[1], args[2]);
trace("test_WaitDcd timeout %ld clt 0x%08lx handle %p\n",args[0], args[1], hcom);
ok(SetCommMask(hcom, EV_RLSD), "SetCommMask failed\n");
hComPortEvent = CreateEvent( NULL, TRUE, FALSE, NULL );
ok(hComPortEvent != 0, "CreateEvent failed\n");
alarmThread = CreateThread(NULL, 0, toggle_ctlLine, (void *) &args, 0, &alarmThreadId);
alarmThread = CreateThread(NULL, 0, toggle_ctlLine, args, 0, &alarmThreadId);
ok(alarmThread !=0 , "CreateThread Failed\n");
ZeroMemory( &overlapped, sizeof(overlapped));
@ -1566,7 +1565,7 @@ static void test_WaitDcd(HANDLE hcom)
*/
static DWORD CALLBACK set_CommBreak(LPVOID arg)
{
DWORD *args = (DWORD *) arg;
DWORD_PTR *args = arg;
DWORD timeout = args[0];
HANDLE hcom = (HANDLE) args[1];
@ -1587,7 +1586,7 @@ static void test_WaitBreak(HANDLE hcom)
OVERLAPPED overlapped;
HANDLE hComPortEvent;
HANDLE alarmThread;
DWORD args[2];
DWORD_PTR args[2];
DWORD alarmThreadId, before, after, after1, diff, success, err, written, evtmask=0;
ok(SetCommMask(hcom, EV_BREAK), "SetCommMask failed\n");
@ -1596,8 +1595,8 @@ static void test_WaitBreak(HANDLE hcom)
trace("test_WaitBreak\n");
args[0]= TIMEOUT >>1;
args[1]=(DWORD) hcom;
alarmThread = CreateThread(NULL, 0, set_CommBreak, (void *) &args, 0, &alarmThreadId);
args[1]= (DWORD_PTR)hcom;
alarmThread = CreateThread(NULL, 0, set_CommBreak, args, 0, &alarmThreadId);
/* Wait a minimum to let the thread start up */
Sleep(10);
trace("Thread created\n");

View file

@ -162,7 +162,7 @@ static void testCursorInfo(HANDLE hCon)
if (info.dwSize == 12)
{
skip("NULL CONSOLE_CURSOR_INFO will crash on win9x\n");
win_skip("NULL CONSOLE_CURSOR_INFO will crash on win9x\n");
return;
}
@ -173,7 +173,46 @@ static void testCursorInfo(HANDLE hCon)
ERROR_INVALID_ACCESS, GetLastError());
}
static void testWriteSimple(HANDLE hCon, COORD sbSize)
static void testEmptyWrite(HANDLE hCon)
{
COORD c;
DWORD len;
const char* mytest = "";
c.X = c.Y = 0;
ok(SetConsoleCursorPosition(hCon, c) != 0, "Cursor in upper-left\n");
len = -1;
ok(WriteConsole(hCon, NULL, 0, &len, NULL) != 0 && len == 0, "WriteConsole\n");
okCURSOR(hCon, c);
/* Passing a NULL lpBuffer with sufficiently large non-zero length succeeds
* on native Windows and result in memory-like contents being written to
* the console. Calling WriteConsoleW like this will crash on Wine. */
if (0)
{
len = -1;
ok(!WriteConsole(hCon, NULL, 16, &len, NULL) && len == -1, "WriteConsole\n");
okCURSOR(hCon, c);
/* Cursor advances for this call. */
len = -1;
ok(WriteConsole(hCon, NULL, 128, &len, NULL) != 0 && len == 128, "WriteConsole\n");
}
len = -1;
ok(WriteConsole(hCon, mytest, 0, &len, NULL) != 0 && len == 0, "WriteConsole\n");
okCURSOR(hCon, c);
/* WriteConsole does not halt on a null terminator and is happy to write
* memory contents beyond the actual size of the buffer. */
len = -1;
ok(WriteConsole(hCon, mytest, 16, &len, NULL) != 0 && len == 16, "WriteConsole\n");
c.X += 16;
okCURSOR(hCon, c);
}
static void testWriteSimple(HANDLE hCon)
{
COORD c;
DWORD len;
@ -407,7 +446,9 @@ static void testWrite(HANDLE hCon, COORD sbSize)
/* FIXME: should in fact insure that the sb is at least 10 character wide */
ok(SetConsoleTextAttribute(hCon, TEST_ATTRIB), "Setting default text color\n");
resetContent(hCon, sbSize, FALSE);
testWriteSimple(hCon, sbSize);
testEmptyWrite(hCon);
resetContent(hCon, sbSize, FALSE);
testWriteSimple(hCon);
resetContent(hCon, sbSize, FALSE);
testWriteNotWrappedNotProcessed(hCon, sbSize);
resetContent(hCon, sbSize, FALSE);
@ -665,7 +706,7 @@ static void testScreenBuffer(HANDLE hConOut)
ret = SetConsoleOutputCP(866);
if (!ret && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
{
skip("SetConsoleOutputCP is not implemented\n");
win_skip("SetConsoleOutputCP is not implemented\n");
return;
}
ok(ret, "Cannot set output codepage to 866\n");
@ -901,7 +942,8 @@ START_TEST(console)
ok(hConIn != INVALID_HANDLE_VALUE, "Opening ConIn\n");
ok(hConOut != INVALID_HANDLE_VALUE, "Opening ConOut\n");
ok(ret = GetConsoleScreenBufferInfo(hConOut, &sbi), "Getting sb info\n");
ret = GetConsoleScreenBufferInfo(hConOut, &sbi);
ok(ret, "Getting sb info\n");
if (!ret) return;
/* Non interactive tests */
@ -921,7 +963,7 @@ START_TEST(console)
if (!pGetConsoleInputExeNameA || !pSetConsoleInputExeNameA)
{
skip("GetConsoleInputExeNameA and/or SetConsoleInputExeNameA is not available\n");
win_skip("GetConsoleInputExeNameA and/or SetConsoleInputExeNameA is not available\n");
return;
}
else

View file

@ -47,6 +47,40 @@ static void get_file_name(char* buf)
GetTempFileNameA(path, "wt", 0, buf);
}
typedef struct tag_reg_save_value
{
const char *name;
DWORD type;
BYTE *data;
DWORD size;
} reg_save_value;
static DWORD save_value(HKEY hkey, const char *value, reg_save_value *saved)
{
DWORD ret;
saved->name=value;
saved->data=0;
saved->size=0;
ret=RegQueryValueExA(hkey, value, NULL, &saved->type, NULL, &saved->size);
if (ret == ERROR_SUCCESS)
{
saved->data=HeapAlloc(GetProcessHeap(), 0, saved->size);
RegQueryValueExA(hkey, value, NULL, &saved->type, saved->data, &saved->size);
}
return ret;
}
static void restore_value(HKEY hkey, reg_save_value *saved)
{
if (saved->data)
{
RegSetValueExA(hkey, saved->name, 0, saved->type, saved->data, saved->size);
HeapFree(GetProcessHeap(), 0, saved->data);
}
else
RegDeleteValueA(hkey, saved->name);
}
static void get_events(const char* name, HANDLE *start_event, HANDLE *done_event)
{
const char* basename;
@ -133,7 +167,7 @@ static void doDebugger(int argc, char** argv)
{
const char* logfile;
debugger_blackbox_t blackbox;
HANDLE start_event, done_event, debug_event;
HANDLE start_event = 0, done_event = 0, debug_event;
blackbox.argc=argc;
logfile=(argc >= 4 ? argv[3] : NULL);
@ -149,7 +183,7 @@ static void doDebugger(int argc, char** argv)
else
blackbox.attach_rc=TRUE;
debug_event=(argc >= 6 ? (HANDLE)atol(argv[5]) : NULL);
debug_event=(argc >= 6 ? (HANDLE)(INT_PTR)atol(argv[5]) : NULL);
blackbox.debug_err=0;
if (debug_event && strstr(myARGV[2], "event"))
{
@ -313,14 +347,13 @@ static void crash_and_winedbg(HKEY hkey, const char* argv0)
static void test_ExitCode(void)
{
static const char* AeDebug="Software\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug";
static const char* WineDbg="Software\\Wine\\WineDbg";
char test_exe[MAX_PATH];
DWORD ret;
HKEY hkey;
DWORD disposition;
LPBYTE auto_val=NULL;
DWORD auto_size, auto_type;
LPBYTE debugger_val=NULL;
DWORD debugger_size, debugger_type;
reg_save_value auto_value;
reg_save_value debugger_value;
GetModuleFileNameA(GetModuleHandle(NULL), test_exe, sizeof(test_exe));
if (GetFileAttributes(test_exe) == INVALID_FILE_ATTRIBUTES)
@ -334,22 +367,9 @@ static void test_ExitCode(void)
ret=RegCreateKeyExA(HKEY_LOCAL_MACHINE, AeDebug, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, &disposition);
if (ret == ERROR_SUCCESS)
{
auto_size=0;
ret=RegQueryValueExA(hkey, "auto", NULL, &auto_type, NULL, &auto_size);
if (ret == ERROR_SUCCESS)
{
auto_val=HeapAlloc(GetProcessHeap(), 0, auto_size);
RegQueryValueExA(hkey, "auto", NULL, &auto_type, auto_val, &auto_size);
}
debugger_size=0;
ret=RegQueryValueExA(hkey, "debugger", NULL, &debugger_type, NULL, &debugger_size);
if (ret == ERROR_SUCCESS)
{
debugger_val=HeapAlloc(GetProcessHeap(), 0, debugger_size);
RegQueryValueExA(hkey, "debugger", NULL, &debugger_type, debugger_val, &debugger_size);
trace("HKLM\\%s\\debugger is set to '%s'\n", AeDebug, debugger_val);
}
save_value(hkey, "auto", &auto_value);
save_value(hkey, "debugger", &debugger_value);
trace("HKLM\\%s\\debugger is set to '%s'\n", AeDebug, debugger_value.data);
}
else if (ret == ERROR_ACCESS_DENIED)
{
@ -362,11 +382,32 @@ static void test_ExitCode(void)
return;
}
if (debugger_val && debugger_type == REG_SZ &&
strstr((char*)debugger_val, "winedbg --auto"))
if (debugger_value.data && debugger_value.type == REG_SZ &&
strstr((char*)debugger_value.data, "winedbg --auto"))
{
HKEY hkeyWinedbg;
ret=RegCreateKeyA(HKEY_CURRENT_USER, WineDbg, &hkeyWinedbg);
if (ret == ERROR_SUCCESS)
{
static DWORD zero;
reg_save_value crash_dlg_value;
save_value(hkeyWinedbg, "ShowCrashDialog", &crash_dlg_value);
RegSetValueExA(hkeyWinedbg, "ShowCrashDialog", 0, REG_DWORD, (BYTE *)&zero, sizeof(DWORD));
crash_and_winedbg(hkey, test_exe);
restore_value(hkeyWinedbg, &crash_dlg_value);
RegCloseKey(hkeyWinedbg);
}
else
ok(0, "Couldn't access WineDbg Key - error %u\n", ret);
}
if (winetest_interactive)
/* Since the debugging process never sets the debug event, it isn't recognized
as a valid debugger and, after the debugger exits, Windows will show a dialog box
asking the user what to do */
crash_and_debug(hkey, test_exe, "dbg,none");
else
skip("\"none\" debugger test needs user interaction\n");
crash_and_debug(hkey, test_exe, "dbg,event,order");
crash_and_debug(hkey, test_exe, "dbg,attach,event,code2");
if (pDebugSetProcessKillOnExit)
@ -381,20 +422,8 @@ static void test_ExitCode(void)
}
else
{
if (auto_val)
{
RegSetValueExA(hkey, "auto", 0, auto_type, auto_val, auto_size);
HeapFree(GetProcessHeap(), 0, auto_val);
}
else
RegDeleteValueA(hkey, "auto");
if (debugger_val)
{
RegSetValueExA(hkey, "debugger", 0, debugger_type, debugger_val, debugger_size);
HeapFree(GetProcessHeap(), 0, debugger_val);
}
else
RegDeleteValueA(hkey, "debugger");
restore_value(hkey, &auto_value);
restore_value(hkey, &debugger_value);
RegCloseKey(hkey);
}
}

View file

@ -339,27 +339,32 @@ static void test_CreateDirectoryW(void)
ret = CreateDirectoryW(NULL, NULL);
if (!ret && GetLastError()==ERROR_CALL_NOT_IMPLEMENTED)
return;
ok(ret == FALSE && GetLastError() == ERROR_PATH_NOT_FOUND, "should not create NULL path\n");
ok(ret == FALSE && GetLastError() == ERROR_PATH_NOT_FOUND,
"should not create NULL path ret %u err %u\n", ret, GetLastError());
ret = CreateDirectoryW(empty_strW, NULL);
ok(ret == FALSE && GetLastError() == ERROR_PATH_NOT_FOUND, "should not create empty path\n");
ok(ret == FALSE && GetLastError() == ERROR_PATH_NOT_FOUND,
"should not create empty path ret %u err %u\n", ret, GetLastError());
ret = GetSystemDirectoryW(tmpdir, MAX_PATH);
ok(ret < MAX_PATH, "System directory should fit into MAX_PATH\n");
ret = SetCurrentDirectoryW(tmpdir);
ok(ret == TRUE, "could not chdir to the System directory\n");
ok(ret == TRUE, "could not chdir to the System directory ret %u err %u\n", ret, GetLastError());
ret = CreateDirectoryW(dotW, NULL);
ok(ret == FALSE && GetLastError() == ERROR_ALREADY_EXISTS, "should not create existing path\n");
ok(ret == FALSE && GetLastError() == ERROR_ALREADY_EXISTS,
"should not create existing path ret %u err %u\n", ret, GetLastError());
ret = CreateDirectoryW(dotdotW, NULL);
ok(ret == FALSE && GetLastError() == ERROR_ALREADY_EXISTS, "should not create existing path\n");
ok(ret == FALSE && GetLastError() == ERROR_ALREADY_EXISTS,
"should not create existing path ret %u err %u\n", ret, GetLastError());
GetTempPathW(MAX_PATH, tmpdir);
tmpdir[3] = 0; /* truncate the path */
ret = CreateDirectoryW(tmpdir, NULL);
ok(ret == FALSE && GetLastError() == ERROR_ACCESS_DENIED, "should deny access to the drive root\n");
ok(ret == FALSE && (GetLastError() == ERROR_ACCESS_DENIED || GetLastError() == ERROR_ALREADY_EXISTS),
"should deny access to the drive root ret %u err %u\n", ret, GetLastError());
GetTempPathW(MAX_PATH, tmpdir);
lstrcatW(tmpdir, tmp_dir_name);
@ -367,7 +372,8 @@ static void test_CreateDirectoryW(void)
ok(ret == TRUE, "CreateDirectoryW should always succeed\n");
ret = CreateDirectoryW(tmpdir, NULL);
ok(ret == FALSE && GetLastError() == ERROR_ALREADY_EXISTS, "should not create existing path\n");
ok(ret == FALSE && GetLastError() == ERROR_ALREADY_EXISTS,
"should not create existing path ret %u err %u\n", ret, GetLastError());
ret = RemoveDirectoryW(tmpdir);
ok(ret == TRUE, "RemoveDirectoryW should always succeed\n");
@ -392,7 +398,8 @@ static void test_CreateDirectoryW(void)
lstrcatW(tmpdir, tmp_dir_name);
ret = CreateDirectoryW(tmpdir, NULL);
ok(ret == FALSE && GetLastError() == ERROR_PATH_NOT_FOUND,
"CreateDirectoryW with multiple nonexistent directories in path should fail\n");
"CreateDirectoryW with multiple nonexistent directories in path should fail ret %u err %u\n",
ret, GetLastError());
ret = RemoveDirectoryW(tmpdir);
}

View file

@ -118,7 +118,12 @@ static void test_GetDiskFreeSpaceA(void)
else
{
ok(ret ||
(!ret && (GetLastError() == ERROR_NOT_READY || GetLastError() == ERROR_INVALID_DRIVE)),
GetLastError() == ERROR_NOT_READY ||
GetLastError() == ERROR_INVALID_FUNCTION ||
GetLastError() == ERROR_INVALID_DRIVE ||
GetLastError() == ERROR_PATH_NOT_FOUND ||
GetLastError() == ERROR_REQUEST_ABORTED ||
GetLastError() == ERROR_UNRECOGNIZED_VOLUME,
"GetDiskFreeSpaceA(%s): ret=%d GetLastError=%d\n",
drive, ret, GetLastError());
if( GetVersion() & 0x80000000)
@ -132,7 +137,12 @@ static void test_GetDiskFreeSpaceA(void)
tot.QuadPart = sectors_per_cluster;
tot.QuadPart = (tot.QuadPart * bytes_per_sector) * total_clusters;
ret = pGetDiskFreeSpaceExA( drive, &d, &totEx, NULL);
ok( ret || (!ret && ERROR_NOT_READY == GetLastError()),
ok( ret ||
GetLastError() == ERROR_NOT_READY ||
GetLastError() == ERROR_INVALID_FUNCTION ||
GetLastError() == ERROR_PATH_NOT_FOUND ||
GetLastError() == ERROR_REQUEST_ABORTED ||
GetLastError() == ERROR_UNRECOGNIZED_VOLUME,
"GetDiskFreeSpaceExA( %s ) failed. GetLastError=%d\n", drive, GetLastError());
ok( bytes_per_sector == 0 || /* empty cd rom drive */
totEx.QuadPart <= tot.QuadPart,
@ -188,7 +198,12 @@ static void test_GetDiskFreeSpaceW(void)
"GetDiskFreeSpaceW(%c): ret=%d GetLastError=%d\n",
drive[0], ret, GetLastError());
else
ok(ret || GetLastError() == ERROR_NOT_READY,
ok( ret ||
GetLastError() == ERROR_NOT_READY ||
GetLastError() == ERROR_INVALID_FUNCTION ||
GetLastError() == ERROR_PATH_NOT_FOUND ||
GetLastError() == ERROR_REQUEST_ABORTED ||
GetLastError() == ERROR_UNRECOGNIZED_VOLUME,
"GetDiskFreeSpaceW(%c): ret=%d GetLastError=%d\n",
drive[0], ret, GetLastError());
}

View file

@ -148,7 +148,7 @@ static void test_GetSetEnvironmentVariableW(void)
if (ret == FALSE && GetLastError()==ERROR_CALL_NOT_IMPLEMENTED)
{
/* Must be Win9x which doesn't support the Unicode functions */
skip("SetEnvironmentVariableW is not implemented\n");
win_skip("SetEnvironmentVariableW is not implemented\n");
return;
}
ok(ret == TRUE,
@ -245,13 +245,14 @@ static void test_ExpandEnvironmentStringsA(void)
SetEnvironmentVariableA("EnvVar", value);
ret_size = ExpandEnvironmentStringsA(NULL, buf1, sizeof(buf1));
ok(ret_size == 1 || ret_size == 0 /* Win9x */,
ok(ret_size == 1 || ret_size == 0 /* Win9x */ || ret_size == 2 /* NT4 */,
"ExpandEnvironmentStrings returned %d\n", ret_size);
/* Try to get the required buffer size 'the natural way' */
strcpy(buf, "%EnvVar%");
ret_size = ExpandEnvironmentStringsA(buf, NULL, 0);
ok(ret_size == strlen(value)+1 || /* win98 */
ret_size == (strlen(value)+1)*2 || /* NT4 */
ret_size == strlen(value)+2 || /* win2k, XP, win2k3 */
ret_size == 0 /* Win95 */,
"ExpandEnvironmentStrings returned %d instead of %d, %d or %d\n",
@ -260,21 +261,24 @@ static void test_ExpandEnvironmentStringsA(void)
/* Again, side-stepping the Win95 bug */
ret_size = ExpandEnvironmentStringsA(buf, buf1, 0);
/* v5.1.2600.2945 (XP SP2) returns len + 2 here! */
ok(ret_size == strlen(value)+1 || ret_size == strlen(value)+2,
ok(ret_size == strlen(value)+1 || ret_size == strlen(value)+2 ||
ret_size == (strlen(value)+1)*2 /* NT4 */,
"ExpandEnvironmentStrings returned %d instead of %d\n",
ret_size, lstrlenA(value)+1);
/* Try with a buffer that's too small */
ret_size = ExpandEnvironmentStringsA(buf, buf1, 12);
/* v5.1.2600.2945 (XP SP2) returns len + 2 here! */
ok(ret_size == strlen(value)+1 || ret_size == strlen(value)+2,
ok(ret_size == strlen(value)+1 || ret_size == strlen(value)+2 ||
ret_size == (strlen(value)+1)*2 /* NT4 */,
"ExpandEnvironmentStrings returned %d instead of %d\n",
ret_size, lstrlenA(value)+1);
/* Try with a buffer of just the right size */
/* v5.1.2600.2945 (XP SP2) needs and returns len + 2 here! */
ret_size = ExpandEnvironmentStringsA(buf, buf1, ret_size);
ok(ret_size == strlen(value)+1 || ret_size == strlen(value)+2,
ok(ret_size == strlen(value)+1 || ret_size == strlen(value)+2 ||
ret_size == (strlen(value)+1)*2 /* NT4 */,
"ExpandEnvironmentStrings returned %d instead of %d\n",
ret_size, lstrlenA(value)+1);
ok(!strcmp(buf1, value), "ExpandEnvironmentStrings returned [%s]\n", buf1);
@ -282,7 +286,9 @@ static void test_ExpandEnvironmentStringsA(void)
/* Try with an unset environment variable */
strcpy(buf, not_an_env_var);
ret_size = ExpandEnvironmentStringsA(buf, buf1, sizeof(buf1));
ok(ret_size == strlen(not_an_env_var)+1, "ExpandEnvironmentStrings returned %d instead of %d\n", ret_size, lstrlenA(value)+1);
ok(ret_size == strlen(not_an_env_var)+1 ||
ret_size == (strlen(not_an_env_var)+1)*2 /* NT4 */,
"ExpandEnvironmentStrings returned %d instead of %d\n", ret_size, lstrlenA(not_an_env_var)+1);
ok(!strcmp(buf1, not_an_env_var), "ExpandEnvironmentStrings returned [%s]\n", buf1);
/* test a large destination size */
@ -303,7 +309,9 @@ static void test_ExpandEnvironmentStringsA(void)
strcpy(buf, "Indirect-%IndirectVar%-Indirect");
strcpy(buf2, "Indirect-Foo%EnvVar%Bar-Indirect");
ret_size = ExpandEnvironmentStringsA(buf, buf1, sizeof(buf1));
ok(ret_size == strlen(buf2)+1, "ExpandEnvironmentStrings returned %d instead of %d\n", ret_size, lstrlen(buf2)+1);
ok(ret_size == strlen(buf2)+1 ||
ret_size == (strlen(buf2)+1)*2 /* NT4 */,
"ExpandEnvironmentStrings returned %d instead of %d\n", ret_size, lstrlen(buf2)+1);
ok(!strcmp(buf1, buf2), "ExpandEnvironmentStrings returned [%s]\n", buf1);
SetEnvironmentVariableA("IndirectVar", NULL);
@ -351,7 +359,7 @@ static void test_GetComputerName(void)
ret = GetComputerNameW((LPWSTR)0xdeadbeef, &size);
error = GetLastError();
if (error == ERROR_CALL_NOT_IMPLEMENTED)
skip("GetComputerNameW is not implemented\n");
win_skip("GetComputerNameW is not implemented\n");
else
{
todo_wine
@ -376,7 +384,7 @@ static void test_GetComputerNameExA(void)
if (!pGetComputerNameExA)
{
skip("GetComputerNameExA function not implemented\n");
win_skip("GetComputerNameExA function not implemented\n");
return;
}
@ -450,7 +458,7 @@ static void test_GetComputerNameExW(void)
if (!pGetComputerNameExW)
{
skip("GetComputerNameExW function not implemented\n");
win_skip("GetComputerNameExW function not implemented\n");
return;
}

View file

@ -20,6 +20,9 @@
*
*/
/* ReplaceFile requires Windows 2000 or newer */
#define _WIN32_WINNT 0x0500
#include <stdarg.h>
#include <stdlib.h>
#include <time.h>
@ -32,6 +35,7 @@
static HANDLE (WINAPI *pFindFirstFileExA)(LPCSTR,FINDEX_INFO_LEVELS,LPVOID,FINDEX_SEARCH_OPS,LPVOID,DWORD);
static BOOL (WINAPI *pReplaceFileA)(LPCSTR, LPCSTR, LPCSTR, DWORD, LPVOID, LPVOID);
static BOOL (WINAPI *pReplaceFileW)(LPCWSTR, LPCWSTR, LPCWSTR, DWORD, LPVOID, LPVOID);
static UINT (WINAPI *pGetSystemWindowsDirectoryA)(LPSTR, UINT);
/* keep filename and filenameW the same */
static const char filename[] = "testfile.xxx";
@ -55,6 +59,7 @@ static void InitFunctionPointers(void)
pFindFirstFileExA=(void*)GetProcAddress(hkernel32, "FindFirstFileExA");
pReplaceFileA=(void*)GetProcAddress(hkernel32, "ReplaceFileA");
pReplaceFileW=(void*)GetProcAddress(hkernel32, "ReplaceFileW");
pGetSystemWindowsDirectoryA=(void*)GetProcAddress(hkernel32, "GetSystemWindowsDirectoryA");
}
static void test__hread( void )
@ -351,20 +356,20 @@ static void test__llseek( void )
for (i = 0; i < 400; i++)
{
ok( HFILE_ERROR != _hwrite( filehandle, sillytext, strlen( sillytext ) ), "_hwrite complains\n" );
ok( _hwrite( filehandle, sillytext, strlen( sillytext ) ) != -1, "_hwrite complains\n" );
}
ok( HFILE_ERROR != _llseek( filehandle, 400 * strlen( sillytext ), FILE_CURRENT ), "should be able to seek\n" );
ok( HFILE_ERROR != _llseek( filehandle, 27 + 35 * strlen( sillytext ), FILE_BEGIN ), "should be able to seek\n" );
ok( _llseek( filehandle, 400 * strlen( sillytext ), FILE_CURRENT ) != -1, "should be able to seek\n" );
ok( _llseek( filehandle, 27 + 35 * strlen( sillytext ), FILE_BEGIN ) != -1, "should be able to seek\n" );
bytes_read = _hread( filehandle, buffer, 1);
ok( 1 == bytes_read, "file read size error\n" );
ok( buffer[0] == sillytext[27], "_llseek error, it got lost seeking\n" );
ok( HFILE_ERROR != _llseek( filehandle, -400 * strlen( sillytext ), FILE_END ), "should be able to seek\n" );
ok( _llseek( filehandle, -400 * (LONG)strlen( sillytext ), FILE_END ) != -1, "should be able to seek\n" );
bytes_read = _hread( filehandle, buffer, 1);
ok( 1 == bytes_read, "file read size error\n" );
ok( buffer[0] == sillytext[0], "_llseek error, it got lost seeking\n" );
ok( HFILE_ERROR != _llseek( filehandle, 1000000, FILE_END ), "should be able to seek past file; poor, poor Windows programmers\n" );
ok( _llseek( filehandle, 1000000, FILE_END ) != -1, "should be able to seek past file; poor, poor Windows programmers\n" );
ok( HFILE_ERROR != _lclose(filehandle), "_lclose complains\n" );
ret = DeleteFileA( filename );
@ -559,6 +564,9 @@ static void test_CopyFileA(void)
ret = GetTempFileNameA(temp_path, prefix, 0, source);
ok(ret != 0, "GetTempFileNameA error %d\n", GetLastError());
ret = MoveFileA(source, source);
todo_wine ok(ret, "MoveFileA: failed, error %d\n", GetLastError());
/* make the source have not zero size */
hfile = CreateFileA(source, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0 );
ok(hfile != INVALID_HANDLE_VALUE, "failed to open source file\n");
@ -1318,6 +1326,7 @@ static void test_FindFirstFileA(void)
int err;
char buffer[5] = "C:\\";
char buffer2[100];
char nonexistent[MAX_PATH];
/* try FindFirstFileA on "C:\" */
buffer[0] = get_windows_drive();
@ -1355,8 +1364,10 @@ static void test_FindFirstFileA(void)
/* try FindFirstFileA on "C:\foo\" */
SetLastError( 0xdeadbeaf );
strcpy(buffer2, buffer);
strcat(buffer2, "foo\\");
GetTempFileNameA( buffer, "foo", 0, nonexistent );
DeleteFileA( nonexistent );
strcpy(buffer2, nonexistent);
strcat(buffer2, "\\");
handle = FindFirstFileA(buffer2, &data);
err = GetLastError();
ok ( handle == INVALID_HANDLE_VALUE, "FindFirstFile on %s should Fail\n", buffer2 );
@ -1366,8 +1377,8 @@ static void test_FindFirstFileA(void)
/* try FindFirstFileA on "C:\foo\bar.txt" */
SetLastError( 0xdeadbeaf );
strcpy(buffer2, buffer);
strcat(buffer2, "foo\\bar.txt");
strcpy(buffer2, nonexistent);
strcat(buffer2, "\\bar.txt");
handle = FindFirstFileA(buffer2, &data);
err = GetLastError();
ok ( handle == INVALID_HANDLE_VALUE, "FindFirstFile on %s should Fail\n", buffer2 );
@ -1375,8 +1386,8 @@ static void test_FindFirstFileA(void)
/* try FindFirstFileA on "C:\foo\*.*" */
SetLastError( 0xdeadbeaf );
strcpy(buffer2, buffer);
strcat(buffer2, "foo\\*.*");
strcpy(buffer2, nonexistent);
strcat(buffer2, "\\*.*");
handle = FindFirstFileA(buffer2, &data);
err = GetLastError();
ok ( handle == INVALID_HANDLE_VALUE, "FindFirstFile on %s should Fail\n", buffer2 );
@ -1384,7 +1395,8 @@ static void test_FindFirstFileA(void)
/* try FindFirstFileA on "foo\bar.txt" */
SetLastError( 0xdeadbeaf );
strcpy(buffer2, "foo\\bar.txt");
strcpy(buffer2, nonexistent + 3);
strcat(buffer2, "\\bar.txt");
handle = FindFirstFileA(buffer2, &data);
err = GetLastError();
ok ( handle == INVALID_HANDLE_VALUE, "FindFirstFile on %s should Fail\n", buffer2 );
@ -1494,7 +1506,7 @@ static void test_FindFirstFileExA(void)
if (!pFindFirstFileExA)
{
skip("FindFirstFileExA() is missing\n");
win_skip("FindFirstFileExA() is missing\n");
return;
}
@ -1507,7 +1519,7 @@ static void test_FindFirstFileExA(void)
handle = pFindFirstFileExA("test-dir\\*", FindExInfoStandard, &search_results, FindExSearchLimitToDirectories, NULL, 0);
if (handle == INVALID_HANDLE_VALUE && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
{
skip("FindFirstFileExA is not implemented\n");
win_skip("FindFirstFileExA is not implemented\n");
goto cleanup;
}
ok(handle != INVALID_HANDLE_VALUE, "FindFirstFile failed (err=%u)\n", GetLastError());
@ -1668,10 +1680,11 @@ static void test_async_file_errors(void)
static void test_read_write(void)
{
DWORD bytes, ret;
DWORD bytes, ret, old_prot;
HANDLE hFile;
char temp_path[MAX_PATH];
char filename[MAX_PATH];
char *mem;
static const char prefix[] = "pfx";
ret = GetTempPathA(MAX_PATH, temp_path);
@ -1721,6 +1734,95 @@ static void test_read_write(void)
"ret = %d, error %d\n", ret, GetLastError());
ok(!bytes, "bytes = %d\n", bytes);
/* test passing protected memory as buffer */
mem = VirtualAlloc( NULL, 0x4000, MEM_COMMIT, PAGE_READWRITE );
ok( mem != NULL, "failed to allocate virtual mem error %u\n", GetLastError() );
ret = WriteFile( hFile, mem, 0x4000, &bytes, NULL );
ok( ret, "WriteFile failed error %u\n", GetLastError() );
ok( bytes == 0x4000, "only wrote %x bytes\n", bytes );
ret = VirtualProtect( mem + 0x2000, 0x2000, PAGE_NOACCESS, &old_prot );
ok( ret, "VirtualProtect failed error %u\n", GetLastError() );
ret = WriteFile( hFile, mem, 0x4000, &bytes, NULL );
ok( !ret, "WriteFile succeeded\n" );
ok( GetLastError() == ERROR_INVALID_USER_BUFFER ||
GetLastError() == ERROR_INVALID_PARAMETER, /* win9x */
"wrong error %u\n", GetLastError() );
ok( bytes == 0, "wrote %x bytes\n", bytes );
ret = WriteFile( (HANDLE)0xdead, mem, 0x4000, &bytes, NULL );
ok( !ret, "WriteFile succeeded\n" );
ok( GetLastError() == ERROR_INVALID_HANDLE || /* handle is checked before buffer on NT */
GetLastError() == ERROR_INVALID_PARAMETER, /* win9x */
"wrong error %u\n", GetLastError() );
ok( bytes == 0, "wrote %x bytes\n", bytes );
ret = VirtualProtect( mem, 0x2000, PAGE_NOACCESS, &old_prot );
ok( ret, "VirtualProtect failed error %u\n", GetLastError() );
ret = WriteFile( hFile, mem, 0x4000, &bytes, NULL );
ok( !ret, "WriteFile succeeded\n" );
ok( GetLastError() == ERROR_INVALID_USER_BUFFER ||
GetLastError() == ERROR_INVALID_PARAMETER, /* win9x */
"wrong error %u\n", GetLastError() );
ok( bytes == 0, "wrote %x bytes\n", bytes );
SetFilePointer( hFile, 0, NULL, FILE_BEGIN );
ret = ReadFile( hFile, mem, 0x4000, &bytes, NULL );
ok( !ret, "ReadFile succeeded\n" );
ok( GetLastError() == ERROR_NOACCESS ||
GetLastError() == ERROR_INVALID_PARAMETER, /* win9x */
"wrong error %u\n", GetLastError() );
ok( bytes == 0, "read %x bytes\n", bytes );
ret = VirtualProtect( mem, 0x2000, PAGE_READONLY, &old_prot );
ok( ret, "VirtualProtect failed error %u\n", GetLastError() );
ret = ReadFile( hFile, mem, 0x4000, &bytes, NULL );
ok( !ret, "ReadFile succeeded\n" );
ok( GetLastError() == ERROR_NOACCESS ||
GetLastError() == ERROR_INVALID_PARAMETER, /* win9x */
"wrong error %u\n", GetLastError() );
ok( bytes == 0, "read %x bytes\n", bytes );
ret = VirtualProtect( mem, 0x2000, PAGE_READWRITE, &old_prot );
ok( ret, "VirtualProtect failed error %u\n", GetLastError() );
ret = ReadFile( hFile, mem, 0x4000, &bytes, NULL );
ok( !ret, "ReadFile succeeded\n" );
ok( GetLastError() == ERROR_NOACCESS ||
GetLastError() == ERROR_INVALID_PARAMETER, /* win9x */
"wrong error %u\n", GetLastError() );
ok( bytes == 0, "read %x bytes\n", bytes );
SetFilePointer( hFile, 0x1234, NULL, FILE_BEGIN );
SetEndOfFile( hFile );
SetFilePointer( hFile, 0, NULL, FILE_BEGIN );
ret = ReadFile( hFile, mem, 0x4000, &bytes, NULL );
ok( !ret, "ReadFile succeeded\n" );
ok( GetLastError() == ERROR_NOACCESS ||
GetLastError() == ERROR_INVALID_PARAMETER, /* win9x */
"wrong error %u\n", GetLastError() );
ok( bytes == 0, "read %x bytes\n", bytes );
ret = ReadFile( hFile, mem, 0x2000, &bytes, NULL );
ok( ret, "ReadFile failed error %u\n", GetLastError() );
ok( bytes == 0x1234, "read %x bytes\n", bytes );
ret = ReadFile( hFile, NULL, 1, &bytes, NULL );
ok( !ret, "ReadFile succeeded\n" );
ok( GetLastError() == ERROR_NOACCESS ||
GetLastError() == ERROR_INVALID_PARAMETER, /* win9x */
"wrong error %u\n", GetLastError() );
ok( bytes == 0, "read %x bytes\n", bytes );
VirtualFree( mem, 0, MEM_FREE );
ret = CloseHandle(hFile);
ok( ret, "CloseHandle: error %d\n", GetLastError());
ret = DeleteFileA(filename);
@ -1749,7 +1851,10 @@ static void test_OpenFile(void)
UINT length;
/* Check for existing file */
if (!pGetSystemWindowsDirectoryA)
length = GetWindowsDirectoryA(buff, MAX_PATH);
else
length = pGetSystemWindowsDirectoryA(buff, MAX_PATH);
if (length + sizeof(file) < MAX_PATH)
{
@ -1837,8 +1942,8 @@ static void test_OpenFile(void)
ok( ofs.cBytes == sizeof(OFSTRUCT), "OpenFile set ofs.cBytes to %d\n", ofs.cBytes );
ok( ofs.nErrCode == ERROR_SUCCESS || broken(ofs.nErrCode != ERROR_SUCCESS) /* win9x */,
"OpenFile set ofs.nErrCode to %d\n", ofs.nErrCode );
ret = CloseHandle((HANDLE)hFile);
ok( ret == TRUE, "CloseHandle() returns %d\n", ret );
ret = _lclose(hFile);
ok( !ret, "_lclose() returns %d\n", ret );
retval = GetFileAttributesA(filename);
ok( retval != INVALID_FILE_ATTRIBUTES, "GetFileAttributesA: error %d\n", GetLastError() );
@ -1855,8 +1960,8 @@ static void test_OpenFile(void)
"OpenFile set ofs.nErrCode to %d\n", ofs.nErrCode );
ok( lstrcmpiA(ofs.szPathName, buff) == 0,
"OpenFile returned '%s', but was expected to return '%s'\n", ofs.szPathName, buff );
ret = CloseHandle((HANDLE)hFile);
ok( ret == TRUE, "CloseHandle() returns %d\n", ret );
ret = _lclose(hFile);
ok( !ret, "_lclose() returns %d\n", ret );
memset(&ofs, 0xA5, sizeof(ofs));
SetLastError(0xfaceabee);
@ -1870,8 +1975,8 @@ static void test_OpenFile(void)
"OpenFile set ofs.nErrCode to %d\n", ofs.nErrCode );
ok( lstrcmpiA(ofs.szPathName, buff) == 0,
"OpenFile returned '%s', but was expected to return '%s'\n", ofs.szPathName, buff );
ret = CloseHandle((HANDLE)hFile);
ok( ret == TRUE, "CloseHandle() returns %d\n", ret );
ret = _lclose(hFile);
ok( !ret, "_lclose() returns %d\n", ret );
memset(&ofs, 0xA5, sizeof(ofs));
SetLastError(0xfaceabee);
@ -1885,8 +1990,8 @@ static void test_OpenFile(void)
"OpenFile set ofs.nErrCode to %d\n", ofs.nErrCode );
ok( lstrcmpiA(ofs.szPathName, buff) == 0,
"OpenFile returned '%s', but was expected to return '%s'\n", ofs.szPathName, buff );
ret = CloseHandle((HANDLE)hFile);
ok( ret == TRUE, "CloseHandle() returns %d\n", ret );
ret = _lclose(hFile);
ok( !ret, "_lclose() returns %d\n", ret );
memset(&ofs, 0xA5, sizeof(ofs));
SetLastError(0xfaceabee);
@ -1924,6 +2029,12 @@ static void test_overlapped(void)
DWORD r, result;
/* GetOverlappedResult crashes if the 2nd or 3rd param are NULL */
if (0) /* tested: WinXP */
{
GetOverlappedResult(0, NULL, &result, FALSE);
GetOverlappedResult(0, &ov, NULL, FALSE);
GetOverlappedResult(0, NULL, NULL, FALSE);
}
memset( &ov, 0, sizeof ov );
result = 1;
@ -2024,11 +2135,11 @@ static void test_ReplaceFileA(void)
static const char prefix[] = "pfx";
char temp_path[MAX_PATH];
DWORD ret;
BOOL retok;
BOOL retok, removeBackup = FALSE;
if (!pReplaceFileA)
{
skip("ReplaceFileA() is missing\n");
win_skip("ReplaceFileA() is missing\n");
return;
}
@ -2109,7 +2220,9 @@ static void test_ReplaceFileA(void)
/* make sure that the "replaced" file has the size of the replacement file */
hReplacedFile = CreateFileA(replaced, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0);
ok(hReplacedFile != INVALID_HANDLE_VALUE,
"failed to open replaced file\n");
"failed to open replaced file: %d\n", GetLastError());
if (hReplacedFile != INVALID_HANDLE_VALUE)
{
ret = GetFileSize(hReplacedFile, NULL);
ok(ret == sizeof(replacementData),
"replaced file has wrong size %d\n", ret);
@ -2130,6 +2243,9 @@ static void test_ReplaceFileA(void)
ftReplaced.dwHighDateTime, ftReplaced.dwLowDateTime,
ftReplacement.dwHighDateTime, ftReplacement.dwLowDateTime );
CloseHandle(hReplacedFile);
}
else
skip("couldn't open replacement file, skipping tests\n");
/* re-create replacement file for pass w/o backup (blank) */
ret = GetTempFileNameA(temp_path, prefix, 0, replacement);
@ -2139,7 +2255,8 @@ static void test_ReplaceFileA(void)
*/
SetLastError(0xdeadbeef);
ret = pReplaceFileA(replaced, replacement, NULL, 0, 0, 0);
ok(ret, "ReplaceFileA: unexpected error %d\n", GetLastError());
ok(ret || GetLastError() == ERROR_ACCESS_DENIED,
"ReplaceFileA: unexpected error %d\n", GetLastError());
/* re-create replacement file for pass w/ backup (backup-file not existing) */
ret = GetTempFileNameA(temp_path, prefix, 0, replacement);
@ -2151,13 +2268,17 @@ static void test_ReplaceFileA(void)
*/
SetLastError(0xdeadbeef);
ret = pReplaceFileA(replaced, replacement, backup, 0, 0, 0);
ok(ret, "ReplaceFileA: unexpected error %d\n", GetLastError());
ok(ret || GetLastError() == ERROR_ACCESS_DENIED,
"ReplaceFileA: unexpected error %d\n", GetLastError());
if (ret)
removeBackup = TRUE;
/* re-create replacement file for pass w/ no permissions to "replaced" */
ret = GetTempFileNameA(temp_path, prefix, 0, replacement);
ok(ret != 0, "GetTempFileNameA error (replacement) %d\n", GetLastError());
ret = SetFileAttributesA(replaced, FILE_ATTRIBUTE_READONLY);
ok(ret, "SetFileAttributesA: error setting to read only %d\n", GetLastError());
ok(ret || GetLastError() == ERROR_ACCESS_DENIED,
"SetFileAttributesA: error setting to read only %d\n", GetLastError());
/* perform replacement w/ backup (no permission to "replaced")
* TODO: flags are not implemented
*/
@ -2171,17 +2292,20 @@ static void test_ReplaceFileA(void)
"unexpected error, replacement file should still exist %d\n", GetLastError());
CloseHandle(hReplacementFile);
ret = SetFileAttributesA(replaced, FILE_ATTRIBUTE_NORMAL);
ok(ret, "SetFileAttributesA: error setting to normal %d\n", GetLastError());
ok(ret || GetLastError() == ERROR_ACCESS_DENIED,
"SetFileAttributesA: error setting to normal %d\n", GetLastError());
/* replacement file still exists, make pass w/o "replaced" */
ret = DeleteFileA(replaced);
ok(ret, "DeleteFileA: error (replaced) %d\n", GetLastError());
ok(ret || GetLastError() == ERROR_ACCESS_DENIED,
"DeleteFileA: error (replaced) %d\n", GetLastError());
/* perform replacement w/ backup (no pre-existing backup or "replaced")
* TODO: flags are not implemented
*/
SetLastError(0xdeadbeef);
ret = pReplaceFileA(replaced, replacement, backup, 0, 0, 0);
ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND,
ok(!ret && (GetLastError() == ERROR_FILE_NOT_FOUND ||
GetLastError() == ERROR_ACCESS_DENIED),
"ReplaceFileA: unexpected error %d\n", GetLastError());
/* perform replacement w/o existing "replacement" file
@ -2189,7 +2313,8 @@ static void test_ReplaceFileA(void)
*/
SetLastError(0xdeadbeef);
ret = pReplaceFileA(replaced, replacement, NULL, 0, 0, 0);
ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND,
ok(!ret && (GetLastError() == ERROR_FILE_NOT_FOUND ||
GetLastError() == ERROR_ACCESS_DENIED),
"ReplaceFileA: unexpected error %d\n", GetLastError());
/*
@ -2199,11 +2324,14 @@ static void test_ReplaceFileA(void)
*/
/* delete temporary files, replacement and replaced are already deleted */
if (removeBackup)
{
ret = DeleteFileA(backup);
ok(ret ||
broken(GetLastError() == ERROR_ACCESS_DENIED), /* win2k */
"DeleteFileA: error (backup) %d\n", GetLastError());
}
}
/*
* ReplaceFileW is a simpler case of ReplaceFileA, there is no
@ -2215,10 +2343,11 @@ static void test_ReplaceFileW(void)
static const WCHAR prefix[] = {'p','f','x',0};
WCHAR temp_path[MAX_PATH];
DWORD ret;
BOOL removeBackup = FALSE;
if (!pReplaceFileW)
{
skip("ReplaceFileW() is missing\n");
win_skip("ReplaceFileW() is missing\n");
return;
}
@ -2243,25 +2372,31 @@ static void test_ReplaceFileW(void)
ret = GetTempFileNameW(temp_path, prefix, 0, replacement);
ok(ret != 0, "GetTempFileNameW error (replacement) %d\n", GetLastError());
ret = pReplaceFileW(replaced, replacement, NULL, 0, 0, 0);
ok(ret, "ReplaceFileW: error %d\n", GetLastError());
ok(ret || GetLastError() == ERROR_ACCESS_DENIED,
"ReplaceFileW: error %d\n", GetLastError());
ret = GetTempFileNameW(temp_path, prefix, 0, replacement);
ok(ret != 0, "GetTempFileNameW error (replacement) %d\n", GetLastError());
ret = DeleteFileW(backup);
ok(ret, "DeleteFileW: error (backup) %d\n", GetLastError());
ret = pReplaceFileW(replaced, replacement, backup, 0, 0, 0);
ok(ret, "ReplaceFileW: error %d\n", GetLastError());
ok(ret || GetLastError() == ERROR_ACCESS_DENIED,
"ReplaceFileW: error %d\n", GetLastError());
ret = GetTempFileNameW(temp_path, prefix, 0, replacement);
ok(ret != 0, "GetTempFileNameW error (replacement) %d\n", GetLastError());
ret = SetFileAttributesW(replaced, FILE_ATTRIBUTE_READONLY);
ok(ret, "SetFileAttributesW: error setting to read only %d\n", GetLastError());
ok(ret || GetLastError() == ERROR_ACCESS_DENIED,
"SetFileAttributesW: error setting to read only %d\n", GetLastError());
ret = pReplaceFileW(replaced, replacement, backup, 0, 0, 0);
ok(ret != ERROR_UNABLE_TO_REMOVE_REPLACED,
"ReplaceFileW: unexpected error %d\n", GetLastError());
ret = SetFileAttributesW(replaced, FILE_ATTRIBUTE_NORMAL);
ok(ret, "SetFileAttributesW: error setting to normal %d\n", GetLastError());
ok(ret || GetLastError() == ERROR_ACCESS_DENIED,
"SetFileAttributesW: error setting to normal %d\n", GetLastError());
if (ret)
removeBackup = TRUE;
ret = DeleteFileW(replaced);
ok(ret, "DeleteFileW: error (replaced) %d\n", GetLastError());
@ -2269,14 +2404,18 @@ static void test_ReplaceFileW(void)
ok(!ret, "ReplaceFileW: error %d\n", GetLastError());
ret = pReplaceFileW(replaced, replacement, NULL, 0, 0, 0);
ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND,
ok(!ret && (GetLastError() == ERROR_FILE_NOT_FOUND ||
GetLastError() == ERROR_ACCESS_DENIED),
"ReplaceFileW: unexpected error %d\n", GetLastError());
if (removeBackup)
{
ret = DeleteFileW(backup);
ok(ret ||
broken(GetLastError() == ERROR_ACCESS_DENIED), /* win2k */
"DeleteFileW: error (backup) %d\n", GetLastError());
}
}
START_TEST(file)
{

View file

@ -237,7 +237,7 @@ static void test_message_null_buffer(void)
error = GetLastError();
if (!ret && error == ERROR_CALL_NOT_IMPLEMENTED)
{
skip("FormatMessageW is not implemented\n");
win_skip("FormatMessageW is not implemented\n");
return;
}

View file

@ -34,7 +34,30 @@ static SIZE_T resize_9x(SIZE_T size)
return max(dwSizeAligned, 12); /* at least 12 bytes */
}
START_TEST(heap)
static void test_sized_HeapAlloc(int nbytes)
{
int success;
char *buf = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, nbytes);
ok(buf != NULL, "allocate failed\n");
ok(buf[0] == 0, "buffer not zeroed\n");
success = HeapFree(GetProcessHeap(), 0, buf);
ok(success, "free failed\n");
}
static void test_sized_HeapReAlloc(int nbytes1, int nbytes2)
{
int success;
char *buf = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, nbytes1);
ok(buf != NULL, "allocate failed\n");
ok(buf[0] == 0, "buffer not zeroed\n");
buf = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, buf, nbytes2);
ok(buf != NULL, "reallocate failed\n");
ok(buf[nbytes2-1] == 0, "buffer not zeroed\n");
success = HeapFree(GetProcessHeap(), 0, buf);
ok(success, "free failed\n");
}
static void test_heap(void)
{
LPVOID mem;
LPVOID msecond;
@ -64,13 +87,13 @@ START_TEST(heap)
/* test some border cases of HeapAlloc and HeapReAlloc */
mem = HeapAlloc(GetProcessHeap(), 0, 0);
ok(mem != NULL, "memory not allocated for size 0\n");
msecond = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, mem, ~0UL - 7);
ok(msecond == NULL, "HeapReAlloc(0xfffffff8) should have failed\n");
msecond = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, mem, ~0UL);
ok(msecond == NULL, "HeapReAlloc(0xffffffff) should have failed\n");
msecond = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, mem, ~(SIZE_T)0 - 7);
ok(msecond == NULL, "HeapReAlloc(~0 - 7) should have failed\n");
msecond = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, mem, ~(SIZE_T)0);
ok(msecond == NULL, "HeapReAlloc(~0) should have failed\n");
HeapFree(GetProcessHeap(), 0, mem);
mem = HeapAlloc(GetProcessHeap(), 0, ~0UL);
ok(mem == NULL, "memory allocated for size ~0UL\n");
mem = HeapAlloc(GetProcessHeap(), 0, ~(SIZE_T)0);
ok(mem == NULL, "memory allocated for size ~0\n");
/* large blocks must be 16-byte aligned */
mem = HeapAlloc(GetProcessHeap(), 0, 512 * 1024);
@ -190,6 +213,8 @@ START_TEST(heap)
ok(mem == NULL, "Expected NULL, got %p\n", mem);
/* invalid free */
if (sizeof(void *) != 8) /* crashes on 64-bit Vista */
{
SetLastError(MAGIC_DEAD);
mem = GlobalFree(gbl);
ok(mem == gbl || broken(mem == NULL) /* nt4 */, "Expected gbl, got %p\n", mem);
@ -197,6 +222,7 @@ START_TEST(heap)
ok(GetLastError() == ERROR_INVALID_HANDLE ||
GetLastError() == ERROR_INVALID_PARAMETER, /* win9x */
"Expected ERROR_INVALID_HANDLE or ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
}
gbl = GlobalAlloc(GMEM_DDESHARE, 100);
@ -211,12 +237,15 @@ START_TEST(heap)
"Expected 1 or 0, got %d\n", res);
/* GlobalSize on an invalid handle */
if (sizeof(void *) != 8) /* crashes on 64-bit Vista */
{
SetLastError(MAGIC_DEAD);
size = GlobalSize((HGLOBAL)0xc042);
ok(size == 0, "Expected 0, got %ld\n", size);
ok(GetLastError() == ERROR_INVALID_HANDLE ||
GetLastError() == ERROR_INVALID_PARAMETER, /* win9x */
"Expected ERROR_INVALID_HANDLE or ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
}
/* ####################################### */
/* Local*() functions */
@ -332,3 +361,16 @@ START_TEST(heap)
GlobalFree(gbl);
}
START_TEST(heap)
{
test_heap();
/* Test both short and very long blocks */
test_sized_HeapAlloc(1);
test_sized_HeapAlloc(1 << 20);
test_sized_HeapReAlloc(1, 100);
test_sized_HeapReAlloc(1, (1 << 20));
test_sized_HeapReAlloc((1 << 20), (2 << 20));
test_sized_HeapReAlloc((1 << 20), 1);
}

View file

@ -52,6 +52,8 @@ static IMAGE_NT_HEADERS nt_header =
IMAGE_FILE_MACHINE_I386, /* Machine */
#elif defined __x86_64__
IMAGE_FILE_MACHINE_AMD64, /* Machine */
#elif defined __powerpc__
IMAGE_FILE_MACHINE_POWERPC, /* Machine */
#else
# error You must specify the machine type
#endif
@ -70,7 +72,9 @@ static IMAGE_NT_HEADERS nt_header =
0, /* SizeOfUninitializedData */
0, /* AddressOfEntryPoint */
0x10, /* BaseOfCode, also serves as e_lfanew in the truncated MZ header */
#ifndef _WIN64
0, /* BaseOfData */
#endif
0x10000000, /* ImageBase */
0, /* SectionAlignment */
0, /* FileAlignment */
@ -398,7 +402,7 @@ static void test_Loader(void)
"%d: VirtualQuery error %d\n", i, GetLastError());
if (nt_header.OptionalHeader.SectionAlignment < si.dwPageSize)
{
ok(info.BaseAddress == (char *)hlib, "%d: got %p != expected %p\n", i, info.BaseAddress, (char *)hlib);
ok(info.BaseAddress == hlib, "%d: got %p != expected %p\n", i, info.BaseAddress, hlib);
ok(info.RegionSize == ALIGN_SIZE(nt_header.OptionalHeader.SizeOfImage, si.dwPageSize), "%d: got %lx != expected %x\n",
i, info.RegionSize, ALIGN_SIZE(nt_header.OptionalHeader.SizeOfImage, si.dwPageSize));
ok(info.Protect == PAGE_EXECUTE_WRITECOPY, "%d: %x != PAGE_EXECUTE_WRITECOPY\n", i, info.Protect);

View file

@ -1110,6 +1110,12 @@ static void test_CompareStringA(void)
ret = CompareStringA(lcid, 0, "\2", 2, "\1", 2);
todo_wine ok(ret != 2, "\\2 vs \\1 expected unequal\n");
ret = CompareStringA(lcid, NORM_IGNORECASE | LOCALE_USE_CP_ACP, "#", -1, ".", -1);
todo_wine ok(ret == CSTR_LESS_THAN, "\"#\" vs \".\" expected CSTR_LESS_THAN, got %d\n", ret);
ret = lstrcmpi("#", ".");
todo_wine ok(ret == -1, "\"#\" vs \".\" expected -1, got %d\n", ret);
}
static void test_LCMapStringA(void)
@ -1221,9 +1227,11 @@ static void test_LCMapStringA(void)
ret = LCMapStringA(LOCALE_USER_DEFAULT, LCMAP_SORTKEY,
upper_case, -1, buf, sizeof(buf));
ok(ret, "LCMapStringA must succeed\n");
ok(buf[ret-1] == 0, "LCMapStringA not null-terminated\n");
ret2 = LCMapStringA(LOCALE_USER_DEFAULT, LCMAP_SORTKEY,
upper_case, lstrlenA(upper_case), buf2, sizeof(buf2));
ok(ret, "LCMapStringA must succeed\n");
ok(ret2, "LCMapStringA must succeed\n");
ok(buf2[ret2-1] == 0, "LCMapStringA not null-terminated\n" );
ok(ret == ret2, "lengths of sort keys must be equal\n");
ok(!lstrcmpA(buf, buf2), "sort keys must be equal\n");
@ -1901,7 +1909,7 @@ static void test_FoldStringW(void)
if (!pFoldStringW)
{
skip("FoldStringW is not available\n");
win_skip("FoldStringW is not available\n");
return; /* FoldString is present in NT v3.1+, but not 95/98/Me */
}
@ -1913,7 +1921,7 @@ static void test_FoldStringW(void)
ret = pFoldStringW(badFlags[i], src, 256, dst, 256);
if (GetLastError()==ERROR_CALL_NOT_IMPLEMENTED)
{
skip("FoldStringW is not implemented\n");
win_skip("FoldStringW is not implemented\n");
return;
}
ok(!ret && GetLastError() == ERROR_INVALID_FLAGS,
@ -2291,7 +2299,7 @@ static void test_EnumUILanguageA(void)
{
BOOL ret;
if (!pEnumUILanguagesA) {
skip("EnumUILanguagesA is not available on Win9x or NT4\n");
win_skip("EnumUILanguagesA is not available on Win9x or NT4\n");
return;
}

View file

@ -328,7 +328,7 @@ static void test_InitPathA(CHAR *newdir, CHAR *curDrive, CHAR *otherDrive)
"GetTempPathA returned a path that did not end in '\\'\n");
lstrcpyA(tmpstr,"aaaaaaaa");
len1=GetTempPathA(len,tmpstr);
ok(len1==len+1,
ok(len1==len+1 || broken(len1 == len), /* WinME */
"GetTempPathA should return string length %d instead of %d\n",len+1,len1);
/* Test GetTmpFileNameA
@ -384,14 +384,16 @@ static void test_InitPathA(CHAR *newdir, CHAR *curDrive, CHAR *otherDrive)
ok(CreateDirectoryA(tmpstr,NULL),"CreateDirectoryA failed\n");
sprintf(tmpstr,"%s\\%s",newdir,LONGDIR);
ok(CreateDirectoryA(tmpstr,NULL),"CreateDirectoryA failed\n");
bRes = CreateDirectoryA("c:",NULL);
sprintf(tmpstr,"%c:", *curDrive);
bRes = CreateDirectoryA(tmpstr,NULL);
ok(!bRes && (GetLastError() == ERROR_ACCESS_DENIED ||
GetLastError() == ERROR_ALREADY_EXISTS),
"CreateDirectoryA(\"c:\" should have failed (%d)\n", GetLastError());
bRes = CreateDirectoryA("c:\\",NULL);
"CreateDirectoryA(\"%s\" should have failed (%d)\n", tmpstr, GetLastError());
sprintf(tmpstr,"%c:\\", *curDrive);
bRes = CreateDirectoryA(tmpstr,NULL);
ok(!bRes && (GetLastError() == ERROR_ACCESS_DENIED ||
GetLastError() == ERROR_ALREADY_EXISTS),
"CreateDirectoryA(\"c:\\\" should have failed (%d)\n", GetLastError());
"CreateDirectoryA(\"%s\" should have failed (%d)\n", tmpstr, GetLastError());
sprintf(tmpstr,"%s\\%s\\%s",newdir,SHORTDIR,SHORTFILE);
hndl=CreateFileA(tmpstr,GENERIC_WRITE,0,NULL,
CREATE_NEW,FILE_ATTRIBUTE_NORMAL,NULL);
@ -468,10 +470,10 @@ static void test_CurrentDirectoryA(CHAR *origdir, CHAR *newdir)
/* change to root without a trailing backslash. The function call succeeds
but the directory is not changed.
*/
strcpy(tmpstr,"C:");
sprintf(tmpstr, "%c:", newdir[0]);
test_setdir(newdir,tmpstr,newdir,1,"check 10");
/* works however with a trailing backslash */
strcpy(tmpstr,"C:\\");
sprintf(tmpstr, "%c:\\", newdir[0]);
test_setdir(newdir,tmpstr,NULL,1,"check 11");
}
@ -901,15 +903,18 @@ static void test_GetTempPath(void)
char windir[MAX_PATH];
char buf[MAX_PATH];
GetEnvironmentVariableA("TMP", save_TMP, sizeof(save_TMP));
if (!GetEnvironmentVariableA("TMP", save_TMP, sizeof(save_TMP))) save_TMP[0] = 0;
/* test default configuration */
trace("TMP=%s\n", save_TMP);
if (save_TMP[0])
{
strcpy(buf,save_TMP);
if (buf[strlen(buf)-1]!='\\')
strcat(buf,"\\");
test_GetTempPathA(buf);
test_GetTempPathW(buf);
}
/* TMP=C:\WINDOWS */
GetWindowsDirectoryA(windir, sizeof(windir));
@ -956,7 +961,7 @@ static void test_GetLongPathNameW(void)
length = pGetLongPathNameW(NULL,NULL,0);
if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
{
skip("GetLongPathNameW is not implemented\n");
win_skip("GetLongPathNameW is not implemented\n");
return;
}
ok(0==length,"GetLongPathNameW returned %d but expected 0\n",length);
@ -985,7 +990,7 @@ static void test_GetShortPathNameW(void)
GetTempPathW( MAX_PATH, path );
if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
{
skip("GetTempPathW is not implemented\n");
win_skip("GetTempPathW is not implemented\n");
return;
}
@ -1216,8 +1221,11 @@ static void test_drive_letter_case(void)
ret = GetTempPath(sizeof(buf), buf);
ok(ret, "GetTempPath error %u\n", GetLastError());
ok(ret < sizeof(buf), "buffer should be %u bytes\n", ret);
if (buf[0])
{
ok(buf[1] == ':', "expected buf[1] == ':' got %c\n", buf[1]);
ok(buf[strlen(buf)-1] == '\\', "Temporary path (%s) doesn't end in a slash\n", buf);
}
memset(buf, 0, sizeof(buf));
SetLastError(0xdeadbeef);

View file

@ -62,13 +62,6 @@ static void test_CreateNamedPipe(int pipemode)
/* nInBufSize */ 1024,
/* nDefaultWait */ NMPWAIT_USE_DEFAULT_WAIT,
/* lpSecurityAttrib */ NULL);
if (hnp == INVALID_HANDLE_VALUE && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED) {
/* Is this the right way to notify user of skipped tests? */
ok(hnp == INVALID_HANDLE_VALUE && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED,
"CreateNamedPipe not supported on this platform, skipping tests.\n");
return;
}
ok(hnp == INVALID_HANDLE_VALUE && GetLastError() == ERROR_INVALID_NAME,
"CreateNamedPipe should fail if name doesn't start with \\\\.\\pipe\n");
@ -389,7 +382,7 @@ static void test_CreateNamedPipe_instances_must_match(void)
/** implementation of alarm() */
static DWORD CALLBACK alarmThreadMain(LPVOID arg)
{
DWORD timeout = (DWORD) arg;
DWORD_PTR timeout = (DWORD_PTR) arg;
trace("alarmThreadMain\n");
if (WaitForSingleObject( alarm_event, timeout ) == WAIT_TIMEOUT)
{
@ -557,51 +550,74 @@ static DWORD CALLBACK serverThreadMain3(LPVOID arg)
trace("Server calling overlapped ConnectNamedPipe...\n");
success = ConnectNamedPipe(hnp, &oOverlap);
err = GetLastError();
ok(success || err == ERROR_IO_PENDING
|| err == ERROR_PIPE_CONNECTED, "overlapped ConnectNamedPipe\n");
ok(!success && (err == ERROR_IO_PENDING || err == ERROR_PIPE_CONNECTED), "overlapped ConnectNamedPipe\n");
trace("overlapped ConnectNamedPipe returned.\n");
if (!success && (err == ERROR_IO_PENDING) && letWFSOEwait)
ok(WaitForSingleObjectEx(hEvent, INFINITE, TRUE) == 0, "wait ConnectNamedPipe\n");
if (!success && (err == ERROR_IO_PENDING)) {
if (letWFSOEwait)
{
DWORD ret;
do {
ret = WaitForSingleObjectEx(hEvent, INFINITE, TRUE);
} while (ret == WAIT_IO_COMPLETION);
ok(ret == 0, "wait ConnectNamedPipe returned %x\n", ret);
}
success = GetOverlappedResult(hnp, &oOverlap, &dummy, letGORwait);
if (!letGORwait && !letWFSOEwait && !success) {
ok(GetLastError() == ERROR_IO_INCOMPLETE, "GetOverlappedResult\n");
success = GetOverlappedResult(hnp, &oOverlap, &dummy, TRUE);
}
ok(success, "GetOverlappedResult ConnectNamedPipe\n");
}
ok(success || (err == ERROR_PIPE_CONNECTED), "GetOverlappedResult ConnectNamedPipe\n");
trace("overlapped ConnectNamedPipe operation complete.\n");
/* Echo bytes once */
memset(buf, 0, sizeof(buf));
trace("Server reading...\n");
success = ReadFile(hnp, buf, sizeof(buf), NULL, &oOverlap);
success = ReadFile(hnp, buf, sizeof(buf), &readden, &oOverlap);
trace("Server ReadFile returned...\n");
err = GetLastError();
ok(success || err == ERROR_IO_PENDING, "overlapped ReadFile\n");
trace("overlapped ReadFile returned.\n");
if (!success && (err == ERROR_IO_PENDING) && letWFSOEwait)
ok(WaitForSingleObjectEx(hEvent, INFINITE, TRUE) == 0, "wait ReadFile\n");
if (!success && (err == ERROR_IO_PENDING)) {
if (letWFSOEwait)
{
DWORD ret;
do {
ret = WaitForSingleObjectEx(hEvent, INFINITE, TRUE);
} while (ret == WAIT_IO_COMPLETION);
ok(ret == 0, "wait ReadFile returned %x\n", ret);
}
success = GetOverlappedResult(hnp, &oOverlap, &readden, letGORwait);
if (!letGORwait && !letWFSOEwait && !success) {
ok(GetLastError() == ERROR_IO_INCOMPLETE, "GetOverlappedResult\n");
success = GetOverlappedResult(hnp, &oOverlap, &readden, TRUE);
}
}
trace("Server done reading.\n");
ok(success, "overlapped ReadFile\n");
trace("Server writing...\n");
success = WriteFile(hnp, buf, readden, NULL, &oOverlap);
success = WriteFile(hnp, buf, readden, &written, &oOverlap);
trace("Server WriteFile returned...\n");
err = GetLastError();
ok(success || err == ERROR_IO_PENDING, "overlapped WriteFile\n");
trace("overlapped WriteFile returned.\n");
if (!success && (err == ERROR_IO_PENDING) && letWFSOEwait)
ok(WaitForSingleObjectEx(hEvent, INFINITE, TRUE) == 0, "wait WriteFile\n");
if (!success && (err == ERROR_IO_PENDING)) {
if (letWFSOEwait)
{
DWORD ret;
do {
ret = WaitForSingleObjectEx(hEvent, INFINITE, TRUE);
} while (ret == WAIT_IO_COMPLETION);
ok(ret == 0, "wait WriteFile returned %x\n", ret);
}
success = GetOverlappedResult(hnp, &oOverlap, &written, letGORwait);
if (!letGORwait && !letWFSOEwait && !success) {
ok(GetLastError() == ERROR_IO_INCOMPLETE, "GetOverlappedResult\n");
success = GetOverlappedResult(hnp, &oOverlap, &written, TRUE);
}
}
trace("Server done writing.\n");
ok(success, "overlapped WriteFile\n");
ok(written == readden, "write file len\n");
@ -613,6 +629,113 @@ static DWORD CALLBACK serverThreadMain3(LPVOID arg)
return 0;
}
/** Trivial byte echo server - uses i/o completion ports */
static DWORD CALLBACK serverThreadMain4(LPVOID arg)
{
int i;
HANDLE hcompletion;
trace("serverThreadMain4\n");
/* Set up a simple echo server */
hnp = CreateNamedPipe(PIPENAME "serverThreadMain4", PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED,
PIPE_TYPE_BYTE | PIPE_WAIT,
/* nMaxInstances */ 1,
/* nOutBufSize */ 1024,
/* nInBufSize */ 1024,
/* nDefaultWait */ NMPWAIT_USE_DEFAULT_WAIT,
/* lpSecurityAttrib */ NULL);
ok(hnp != INVALID_HANDLE_VALUE, "CreateNamedPipe failed\n");
hcompletion = CreateIoCompletionPort(hnp, NULL, 12345, 1);
ok(hcompletion != NULL, "CreateIoCompletionPort failed, error=%i\n", GetLastError());
for (i = 0; i < NB_SERVER_LOOPS; i++) {
char buf[512];
DWORD written;
DWORD readden;
DWORD dummy;
DWORD success;
OVERLAPPED oConnect;
OVERLAPPED oRead;
OVERLAPPED oWrite;
OVERLAPPED *oResult;
DWORD err;
ULONG_PTR compkey;
memset(&oConnect, 0, sizeof(oConnect));
memset(&oRead, 0, sizeof(oRead));
memset(&oWrite, 0, sizeof(oWrite));
/* Wait for client to connect */
trace("Server calling overlapped ConnectNamedPipe...\n");
success = ConnectNamedPipe(hnp, &oConnect);
err = GetLastError();
ok(!success && (err == ERROR_IO_PENDING || err == ERROR_PIPE_CONNECTED),
"overlapped ConnectNamedPipe got %u err %u\n", success, err );
if (!success && err == ERROR_IO_PENDING) {
trace("ConnectNamedPipe GetQueuedCompletionStatus\n");
success = GetQueuedCompletionStatus(hcompletion, &dummy, &compkey, &oResult, 0);
if (!success)
{
ok( GetLastError() == WAIT_TIMEOUT,
"ConnectNamedPipe GetQueuedCompletionStatus wrong error %u\n", GetLastError());
success = GetQueuedCompletionStatus(hcompletion, &dummy, &compkey, &oResult, 10000);
}
ok(success, "ConnectNamedPipe GetQueuedCompletionStatus failed, errno=%i\n", GetLastError());
if (success)
{
ok(compkey == 12345, "got completion key %i instead of 12345\n", (int)compkey);
ok(oResult == &oConnect, "got overlapped pointer %p instead of %p\n", oResult, &oConnect);
}
}
trace("overlapped ConnectNamedPipe operation complete.\n");
/* Echo bytes once */
memset(buf, 0, sizeof(buf));
trace("Server reading...\n");
success = ReadFile(hnp, buf, sizeof(buf), &readden, &oRead);
trace("Server ReadFile returned...\n");
err = GetLastError();
ok(success || err == ERROR_IO_PENDING, "overlapped ReadFile, err=%i\n", err);
success = GetQueuedCompletionStatus(hcompletion, &readden, &compkey,
&oResult, 10000);
ok(success, "ReadFile GetQueuedCompletionStatus failed, errno=%i\n", GetLastError());
if (success)
{
ok(compkey == 12345, "got completion key %i instead of 12345\n", (int)compkey);
ok(oResult == &oRead, "got overlapped pointer %p instead of %p\n", oResult, &oRead);
}
trace("Server done reading.\n");
trace("Server writing...\n");
success = WriteFile(hnp, buf, readden, &written, &oWrite);
trace("Server WriteFile returned...\n");
err = GetLastError();
ok(success || err == ERROR_IO_PENDING, "overlapped WriteFile failed, err=%u\n", err);
success = GetQueuedCompletionStatus(hcompletion, &written, &compkey,
&oResult, 10000);
ok(success, "WriteFile GetQueuedCompletionStatus failed, errno=%i\n", GetLastError());
if (success)
{
ok(compkey == 12345, "got completion key %i instead of 12345\n", (int)compkey);
ok(oResult == &oWrite, "got overlapped pointer %p instead of %p\n", oResult, &oWrite);
ok(written == readden, "write file len\n");
}
trace("Server done writing.\n");
/* finish this connection, wait for next one */
ok(FlushFileBuffers(hnp), "FlushFileBuffers\n");
success = DisconnectNamedPipe(hnp);
ok(success, "DisconnectNamedPipe failed, err %u\n", GetLastError());
}
ok(CloseHandle(hnp), "CloseHandle named pipe failed, err=%i\n", GetLastError());
ok(CloseHandle(hcompletion), "CloseHandle completion failed, err=%i\n", GetLastError());
return 0;
}
static void exercizeServer(const char *pipename, HANDLE serverThread)
{
int i;
@ -690,13 +813,15 @@ static void test_NamedPipe_2(void)
ok(serverThread != INVALID_HANDLE_VALUE, "CreateThread\n");
exercizeServer(PIPENAME "serverThreadMain2", serverThread);
if( 0 ) /* overlapped pipe server doesn't work yet - it randomly fails */
{
/* Try server #3 */
serverThread = CreateThread(NULL, 0, serverThreadMain3, 0, 0, &serverThreadId);
ok(serverThread != INVALID_HANDLE_VALUE, "CreateThread\n");
exercizeServer(PIPENAME "serverThreadMain3", serverThread);
}
/* Try server #4 */
serverThread = CreateThread(NULL, 0, serverThreadMain4, 0, 0, &serverThreadId);
ok(serverThread != INVALID_HANDLE_VALUE, "CreateThread\n");
exercizeServer(PIPENAME "serverThreadMain4", serverThread);
ok(SetEvent( alarm_event ), "SetEvent\n");
CloseHandle( alarm_event );
@ -821,7 +946,7 @@ struct named_pipe_client_params
static DWORD CALLBACK named_pipe_client_func(LPVOID p)
{
struct named_pipe_client_params *params = (struct named_pipe_client_params *)p;
struct named_pipe_client_params *params = p;
HANDLE pipe;
BOOL ret;
const char message[] = "Test";
@ -1266,7 +1391,7 @@ static DWORD CALLBACK overlapped_server(LPVOID arg)
OVERLAPPED ol;
HANDLE pipe;
int ret, err;
struct overlapped_server_args *a = (struct overlapped_server_args*)arg;
struct overlapped_server_args *a = arg;
DWORD num;
char buf[100];
@ -1323,6 +1448,117 @@ static void test_overlapped(void)
CloseHandle(thread);
}
static void test_NamedPipeHandleState(void)
{
HANDLE server, client;
BOOL ret;
DWORD state, instances, maxCollectionCount, collectDataTimeout;
char userName[MAX_PATH];
server = CreateNamedPipe(PIPENAME, PIPE_ACCESS_DUPLEX,
/* dwOpenMode */ PIPE_TYPE_BYTE | PIPE_WAIT,
/* nMaxInstances */ 1,
/* nOutBufSize */ 1024,
/* nInBufSize */ 1024,
/* nDefaultWait */ NMPWAIT_USE_DEFAULT_WAIT,
/* lpSecurityAttrib */ NULL);
ok(server != INVALID_HANDLE_VALUE, "cf failed\n");
ret = GetNamedPipeHandleState(server, NULL, NULL, NULL, NULL, NULL, 0);
todo_wine
ok(ret, "GetNamedPipeHandleState failed: %d\n", GetLastError());
ret = GetNamedPipeHandleState(server, &state, &instances, NULL, NULL, NULL,
0);
todo_wine
ok(ret, "GetNamedPipeHandleState failed: %d\n", GetLastError());
if (ret)
{
ok(state == 0, "unexpected state %08x\n", state);
ok(instances == 1, "expected 1 instances, got %d\n", instances);
}
/* Some parameters have no meaning, and therefore can't be retrieved,
* on a local pipe.
*/
SetLastError(0xdeadbeef);
ret = GetNamedPipeHandleState(server, &state, &instances,
&maxCollectionCount, &collectDataTimeout, userName,
sizeof(userName) / sizeof(userName[0]));
todo_wine
ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
"expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
/* A byte-mode pipe server can't be changed to message mode. */
state = PIPE_READMODE_MESSAGE;
SetLastError(0xdeadbeef);
ret = SetNamedPipeHandleState(server, &state, NULL, NULL);
todo_wine
ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
"expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
client = CreateFileA(PIPENAME, GENERIC_READ|GENERIC_WRITE, 0, NULL,
OPEN_EXISTING, 0, NULL);
ok(client != INVALID_HANDLE_VALUE, "cf failed\n");
state = PIPE_READMODE_BYTE;
ret = SetNamedPipeHandleState(client, &state, NULL, NULL);
todo_wine
ok(ret, "SetNamedPipeHandleState failed: %d\n", GetLastError());
/* A byte-mode pipe client can't be changed to message mode, either. */
state = PIPE_READMODE_MESSAGE;
SetLastError(0xdeadbeef);
ret = SetNamedPipeHandleState(server, &state, NULL, NULL);
todo_wine
ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
"expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
CloseHandle(client);
CloseHandle(server);
server = CreateNamedPipe(PIPENAME, PIPE_ACCESS_DUPLEX,
/* dwOpenMode */ PIPE_TYPE_MESSAGE | PIPE_WAIT,
/* nMaxInstances */ 1,
/* nOutBufSize */ 1024,
/* nInBufSize */ 1024,
/* nDefaultWait */ NMPWAIT_USE_DEFAULT_WAIT,
/* lpSecurityAttrib */ NULL);
ok(server != INVALID_HANDLE_VALUE, "cf failed\n");
ret = GetNamedPipeHandleState(server, NULL, NULL, NULL, NULL, NULL, 0);
todo_wine
ok(ret, "GetNamedPipeHandleState failed: %d\n", GetLastError());
ret = GetNamedPipeHandleState(server, &state, &instances, NULL, NULL, NULL,
0);
todo_wine
ok(ret, "GetNamedPipeHandleState failed: %d\n", GetLastError());
if (ret)
{
ok(state == 0, "unexpected state %08x\n", state);
ok(instances == 1, "expected 1 instances, got %d\n", instances);
}
/* In contrast to byte-mode pipes, a message-mode pipe server can be
* changed to byte mode.
*/
state = PIPE_READMODE_BYTE;
ret = SetNamedPipeHandleState(server, &state, NULL, NULL);
todo_wine
ok(ret, "SetNamedPipeHandleState failed: %d\n", GetLastError());
client = CreateFileA(PIPENAME, GENERIC_READ|GENERIC_WRITE, 0, NULL,
OPEN_EXISTING, 0, NULL);
ok(client != INVALID_HANDLE_VALUE, "cf failed\n");
state = PIPE_READMODE_MESSAGE;
ret = SetNamedPipeHandleState(client, &state, NULL, NULL);
todo_wine
ok(ret, "SetNamedPipeHandleState failed: %d\n", GetLastError());
/* A message-mode pipe client can also be changed to byte mode.
*/
state = PIPE_READMODE_BYTE;
ret = SetNamedPipeHandleState(client, &state, NULL, NULL);
todo_wine
ok(ret, "SetNamedPipeHandleState failed: %d\n", GetLastError());
CloseHandle(client);
CloseHandle(server);
}
START_TEST(pipe)
{
HMODULE hmod;
@ -1339,4 +1575,5 @@ START_TEST(pipe)
test_CreatePipe();
test_impersonation();
test_overlapped();
test_NamedPipeHandleState();
}

View file

@ -35,9 +35,42 @@
#include "wine/test.h"
#define PROCESS_NAME_NATIVE 1
#define expect_eq_d(expected, actual) \
do { \
int value = (actual); \
ok((expected) == value, "Expected " #actual " to be %d (" #expected ") is %d\n", \
(expected), value); \
} while (0)
#define expect_eq_ws_i(expected, actual) \
do { \
LPCWSTR value = (actual); \
ok(lstrcmpiW((expected), value) == 0, "Expected " #actual " to be L\"%s\" (" #expected ") is L\"%s\"\n", \
wine_dbgstr_w(expected), wine_dbgstr_w(value)); \
} while (0)
/* A simpler version of wine_dbgstr_w. Note that the returned buffer will be
* invalid after 16 calls to this funciton. */
static const char *wine_dbgstr_w(LPCWSTR wstr)
{
static char *buffers[16];
static int curr_buffer = 0;
int size;
curr_buffer = (curr_buffer + 1) % 16;
HeapFree(GetProcessHeap(), 0, buffers[curr_buffer]);
size = WideCharToMultiByte(CP_ACP, 0, wstr, -1, NULL, 0, NULL, NULL);
buffers[curr_buffer] = HeapAlloc(GetProcessHeap(), 0, size);
size = WideCharToMultiByte(CP_ACP, 0, wstr, -1, buffers[curr_buffer], size, NULL, NULL);
return buffers[curr_buffer];
}
static HINSTANCE hkernel32;
static LPVOID (WINAPI *pVirtualAllocEx)(HANDLE, LPVOID, SIZE_T, DWORD, DWORD);
static BOOL (WINAPI *pVirtualFreeEx)(HANDLE, LPVOID, SIZE_T, DWORD);
static BOOL (WINAPI *pQueryFullProcessImageNameW)(HANDLE hProcess, DWORD dwFlags, LPWSTR lpExeName, PDWORD lpdwSize);
/* ############################### */
static char base[MAX_PATH];
@ -175,6 +208,7 @@ static int init(void)
hkernel32 = GetModuleHandleA("kernel32");
pVirtualAllocEx = (void *) GetProcAddress(hkernel32, "VirtualAllocEx");
pVirtualFreeEx = (void *) GetProcAddress(hkernel32, "VirtualFreeEx");
pQueryFullProcessImageNameW = (void *) GetProcAddress(hkernel32, "QueryFullProcessImageNameW");
return 1;
}
@ -241,7 +275,7 @@ static void doChild(const char* file, const char* option)
siA.dwX, siA.dwY, siA.dwXSize, siA.dwYSize,
siA.dwXCountChars, siA.dwYCountChars, siA.dwFillAttribute,
siA.dwFlags, siA.wShowWindow,
(DWORD)siA.hStdInput, (DWORD)siA.hStdOutput, (DWORD)siA.hStdError);
(DWORD_PTR)siA.hStdInput, (DWORD_PTR)siA.hStdOutput, (DWORD_PTR)siA.hStdError);
/* since GetStartupInfoW is only implemented in win2k,
* zero out before calling so we can notice the difference
@ -258,7 +292,7 @@ static void doChild(const char* file, const char* option)
siW.dwX, siW.dwY, siW.dwXSize, siW.dwYSize,
siW.dwXCountChars, siW.dwYCountChars, siW.dwFillAttribute,
siW.dwFlags, siW.wShowWindow,
(DWORD)siW.hStdInput, (DWORD)siW.hStdOutput, (DWORD)siW.hStdError);
(DWORD_PTR)siW.hStdInput, (DWORD_PTR)siW.hStdOutput, (DWORD_PTR)siW.hStdError);
/* Arguments */
childPrintf(hFile, "[Arguments]\nargcA=%d\n", myARGC);
@ -492,7 +526,7 @@ static void ok_child_stringWA( int line, const char *sect, const char *key,
#define okChildInt(sect, key, expect) \
do { \
UINT result = GetPrivateProfileIntA((sect), (key), !(expect), resfile); \
ok(result == expect, "%s:%s expected %d, but got %d\n", (sect), (key), (int)(expect), result); \
ok(result == expect, "%s:%s expected %u, but got %u\n", (sect), (key), (UINT)(expect), result); \
} while (0)
static void test_Startup(void)
@ -1292,9 +1326,9 @@ static void test_Console(void)
okChildInt("StartupInfoA", "wShowWindow", startup.wShowWindow);
/* check child correctly inherited the console */
okChildInt("StartupInfoA", "hStdInput", (DWORD)startup.hStdInput);
okChildInt("StartupInfoA", "hStdOutput", (DWORD)startup.hStdOutput);
okChildInt("StartupInfoA", "hStdError", (DWORD)startup.hStdError);
okChildInt("StartupInfoA", "hStdInput", (DWORD_PTR)startup.hStdInput);
okChildInt("StartupInfoA", "hStdOutput", (DWORD_PTR)startup.hStdOutput);
okChildInt("StartupInfoA", "hStdError", (DWORD_PTR)startup.hStdError);
okChildInt("Console", "SizeX", (DWORD)sbi.dwSize.X);
okChildInt("Console", "SizeY", (DWORD)sbi.dwSize.Y);
okChildInt("Console", "CursorX", (DWORD)sbi.dwCursorPosition.X);
@ -1409,7 +1443,7 @@ static void test_OpenProcess(void)
/* not exported in all windows versions */
if ((!pVirtualAllocEx) || (!pVirtualFreeEx)) {
skip("VirtualAllocEx not found\n");
win_skip("VirtualAllocEx not found\n");
return;
}
@ -1423,7 +1457,7 @@ static void test_OpenProcess(void)
if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
{ /* Win9x */
CloseHandle(hproc);
skip("VirtualAllocEx not implemented\n");
win_skip("VirtualAllocEx not implemented\n");
return;
}
ok(GetLastError() == ERROR_ACCESS_DENIED, "wrong error %d\n", GetLastError());
@ -1520,6 +1554,76 @@ static void test_GetProcessVersion(void)
CloseHandle(pi.hThread);
}
static void test_ProcessName(void)
{
HANDLE hSelf;
WCHAR module_name[1024];
WCHAR deviceW[] = {'\\','D', 'e','v','i','c','e',0};
WCHAR buf[1024];
DWORD size;
if (!pQueryFullProcessImageNameW)
{
win_skip("QueryFullProcessImageNameW unavailable (added in Windows Vista)\n");
return;
}
ok(GetModuleFileNameW(NULL, module_name, 1024), "GetModuleFileNameW(NULL, ...) failed\n");
/* GetCurrentProcess pseudo-handle */
size = sizeof(buf) / sizeof(buf[0]);
expect_eq_d(TRUE, pQueryFullProcessImageNameW(GetCurrentProcess(), 0, buf, &size));
expect_eq_d(lstrlenW(buf), size);
expect_eq_ws_i(buf, module_name);
hSelf = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, GetCurrentProcessId());
/* Real handle */
size = sizeof(buf) / sizeof(buf[0]);
expect_eq_d(TRUE, pQueryFullProcessImageNameW(hSelf, 0, buf, &size));
expect_eq_d(lstrlenW(buf), size);
expect_eq_ws_i(buf, module_name);
/* Buffer too small */
size = lstrlenW(module_name)/2;
lstrcpyW(buf, deviceW);
SetLastError(0xdeadbeef);
expect_eq_d(FALSE, pQueryFullProcessImageNameW(hSelf, 0, buf, &size));
expect_eq_d(lstrlenW(module_name)/2, size); /* size not changed(!) */
expect_eq_d(ERROR_INSUFFICIENT_BUFFER, GetLastError());
expect_eq_ws_i(deviceW, buf); /* buffer not changed */
/* Too small - not space for NUL terminator */
size = lstrlenW(module_name);
SetLastError(0xdeadbeef);
expect_eq_d(FALSE, pQueryFullProcessImageNameW(hSelf, 0, buf, &size));
expect_eq_d(lstrlenW(module_name), size); /* size not changed(!) */
expect_eq_d(ERROR_INSUFFICIENT_BUFFER, GetLastError());
/* NULL buffer */
size = 0;
expect_eq_d(FALSE, pQueryFullProcessImageNameW(hSelf, 0, NULL, &size));
expect_eq_d(0, size);
expect_eq_d(ERROR_INSUFFICIENT_BUFFER, GetLastError());
/* native path */
size = sizeof(buf) / sizeof(buf[0]);
expect_eq_d(TRUE, pQueryFullProcessImageNameW(hSelf, PROCESS_NAME_NATIVE, buf, &size));
expect_eq_d(lstrlenW(buf), size);
ok(buf[0] == '\\', "NT path should begin with '\\'\n");
todo_wine ok(memcmp(buf, deviceW, sizeof(WCHAR)*lstrlenW(deviceW)) == 0, "NT path should begin with \\Device\n");
/* Buffer too small */
size = lstrlenW(module_name)/2;
SetLastError(0xdeadbeef);
lstrcpyW(buf, module_name);
expect_eq_d(FALSE, pQueryFullProcessImageNameW(hSelf, 0, buf, &size));
expect_eq_d(lstrlenW(module_name)/2, size); /* size not changed(!) */
expect_eq_d(ERROR_INSUFFICIENT_BUFFER, GetLastError());
expect_eq_ws_i(module_name, buf); /* buffer not changed */
CloseHandle(hSelf);
}
static void test_Handles(void)
{
HANDLE handle = GetCurrentProcess();
@ -1573,6 +1677,7 @@ START_TEST(process)
test_ExitCode();
test_OpenProcess();
test_GetProcessVersion();
test_ProcessName();
test_Handles();
/* things that can be tested:
* lookup: check the way program to be executed is searched

View file

@ -186,7 +186,15 @@ static void test_profile_sections(void)
broken(GetLastError() == 0xdeadbeef), /* Win9x, WinME */
"expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
/* And a real one */
/* Existing empty section with no keys */
SetLastError(0xdeadbeef);
ret=GetPrivateProfileSectionA("section2", buf, sizeof(buf), testfile4);
ok( ret == 0, "expected return size 0, got %d\n", ret );
ok( GetLastError() == ERROR_SUCCESS ||
broken(GetLastError() == 0xdeadbeef), /* Win9x, WinME */
"expected ERROR_SUCCESS, got %d\n", GetLastError());
/* Existing section with keys and values*/
SetLastError(0xdeadbeef);
ret=GetPrivateProfileSectionA("section1", buf, sizeof(buf), testfile4);
for( p = buf + strlen(buf) + 1; *p;p += strlen(p)+1)
@ -798,17 +806,28 @@ static void test_GetPrivateProfileString(const char *content, const char *descri
ok(ret == 4, "Expected 4, got %d\n", ret);
ok(!lstrcmpA(buf, "val1"), "Expected \"val1\", got \"%s\"\n", buf);
/* Existing section with no keys in an existing file */
memset(buf, 0xc,sizeof(buf));
SetLastError(0xdeadbeef);
ret=GetPrivateProfileStringA("section2", "DoesntExist", "",
buf, MAX_PATH, filename);
ok( ret == 0, "expected return size 0, got %d\n", ret );
ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
todo_wine
ok( GetLastError() == 0xdeadbeef , "expected 0xdeadbeef, got %d\n",
GetLastError());
DeleteFileA(path);
DeleteFileA(filename);
}
static DWORD timeout = 0;
static BOOL check_file_data(LPCSTR path, LPCSTR data)
static BOOL check_binary_file_data(LPCSTR path, const VOID *data, DWORD size)
{
HANDLE file;
CHAR buf[MAX_PATH];
DWORD size;
BOOL ret;
/* Sleep() is needed on Win9x and WinME */
@ -819,17 +838,23 @@ static BOOL check_file_data(LPCSTR path, LPCSTR data)
if (file == INVALID_HANDLE_VALUE)
return FALSE;
size = GetFileSize(file, NULL);
buf[size] = '\0';
if(size != GetFileSize(file, NULL) )
{
CloseHandle(file);
return FALSE;
}
ret = ReadFile(file, buf, size, &size, NULL);
CloseHandle(file);
if (!ret)
return FALSE;
if (!*data && size != 0)
return FALSE;
return !memcmp(buf, data, size);
}
return !lstrcmpA(buf, data);
static BOOL check_file_data(LPCSTR path, LPCSTR data)
{
return check_binary_file_data(path, data, lstrlenA(data));
}
static void test_WritePrivateProfileString(void)
@ -1019,7 +1044,23 @@ static void test_WritePrivateProfileString(void)
ret = WritePrivateProfileStringA("App3", "key5", NULL, path);
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
ok(check_file_data(path, data), "File doesn't match\n");
DeleteFileA(path);
/* NULLs in file before first section. Should be preserved in output */
data = "Data \0 before \0 first \0 section" /* 31 bytes */
"\r\n[section1]\r\n" /* 14 bytes */
"key1=string1\r\n"; /* 14 bytes */
GetTempFileNameA(temp, "wine", 0, path);
create_test_file(path, data, 31);
ret = WritePrivateProfileStringA("section1", "key1", "string1", path);
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
todo_wine
ok( check_binary_file_data(path, data, 59) ||
broken( check_binary_file_data(path, /* Windows 9x */
"Data \0 before \0 first \0 section" /* 31 bytes */
"\r\n\r\n[section1]\r\n" /* 14 bytes */
"key1=string1" /* 14 bytes */
, 59)), "File doesn't match\n");
DeleteFileA(path);
}

View file

@ -310,7 +310,7 @@ START_TEST(resource)
if (GLE == ERROR_CALL_NOT_IMPLEMENTED)
{
skip("Resource calls are not implemented\n");
win_skip("Resource calls are not implemented\n");
return;
}

View file

@ -18,6 +18,7 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#define _WIN32_WINNT 0x500
#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>
@ -53,7 +54,7 @@ static void test_signalandwait(void)
r = pSignalObjectAndWait(NULL, NULL, 0, 0);
if (r == ERROR_INVALID_FUNCTION)
{
skip("SignalObjectAndWait is not implemented\n");
win_skip("SignalObjectAndWait is not implemented\n");
return; /* Win98/ME */
}
ok( r == WAIT_FAILED, "should fail\n");
@ -196,7 +197,7 @@ static void test_slist(void)
int value;
} item1, item2, item3, *pitem;
SLIST_HEADER slist_header, test_header;
SLIST_HEADER slist_header;
PSLIST_ENTRY entry;
USHORT size;
@ -219,15 +220,12 @@ static void test_slist(void)
pInterlockedPopEntrySList == NULL ||
pInterlockedPushEntrySList == NULL)
{
skip("some required slist entrypoints were not found, skipping tests\n");
win_skip("some required slist entrypoints were not found, skipping tests\n");
return;
}
memset(&test_header, 0, sizeof(test_header));
memset(&slist_header, 0xFF, sizeof(slist_header));
pInitializeSListHead(&slist_header);
ok(memcmp(&test_header, &slist_header, sizeof(SLIST_HEADER)) == 0,
"InitializeSListHead didn't zero-fill list header\n");
size = pQueryDepthSList(&slist_header);
ok(size == 0, "initially created slist has size %d, expected 0\n", size);
@ -395,7 +393,7 @@ static void test_waitable_timer(void)
if (!pCreateWaitableTimerA || !pOpenWaitableTimerA)
{
skip("{Create,Open}WaitableTimerA() is not available\n");
win_skip("{Create,Open}WaitableTimerA() is not available\n");
return;
}
@ -457,7 +455,7 @@ static void test_iocp_callback(void)
p_BindIoCompletionCallback = (void*)GetProcAddress(hmod, "BindIoCompletionCallback");
if(!p_BindIoCompletionCallback) {
skip("BindIoCompletionCallback not found in this DLL\n");
win_skip("BindIoCompletionCallback not found in this DLL\n");
return;
}
@ -492,7 +490,7 @@ static void test_iocp_callback(void)
ok(retb == TRUE, "BindIoCompletionCallback failed\n");
memset(&overlapped, 0, sizeof(overlapped));
retb = WriteFile(hFile, (const void *) buffer, 4, &bytesWritten, &overlapped);
retb = WriteFile(hFile, buffer, 4, &bytesWritten, &overlapped);
ok(retb == TRUE || GetLastError() == ERROR_IO_PENDING, "WriteFile failed, lastError = %d\n", GetLastError());
ret = WaitForSingleObject(sem, 5000);
@ -536,7 +534,7 @@ static void test_iocp_callback(void)
static void CALLBACK timer_queue_cb1(PVOID p, BOOLEAN timedOut)
{
int *pn = (int *) p;
int *pn = p;
ok(timedOut, "Timer callbacks should always time out\n");
++*pn;
}
@ -596,7 +594,7 @@ static void CALLBACK timer_queue_cb4(PVOID p, BOOLEAN timedOut)
static void CALLBACK timer_queue_cb5(PVOID p, BOOLEAN timedOut)
{
DWORD delay = (DWORD) p;
DWORD_PTR delay = (DWORD_PTR) p;
ok(timedOut, "Timer callbacks should always time out\n");
if (delay)
Sleep(delay);
@ -647,7 +645,7 @@ static void test_timer_queue(void)
if (!pChangeTimerQueueTimer || !pCreateTimerQueue || !pCreateTimerQueueTimer
|| !pDeleteTimerQueueEx || !pDeleteTimerQueueTimer)
{
skip("TimerQueue API not present\n");
win_skip("TimerQueue API not present\n");
return;
}

View file

@ -18,6 +18,9 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
/* Define _WIN32_WINNT to get SetThreadIdealProcessor on Windows */
#define _WIN32_WINNT 0x0500
#include <assert.h>
#include <stdarg.h>
#include <stdio.h>
@ -180,11 +183,11 @@ INT obeying_ars = 0; /* -1 == no, 0 == dunno yet, 1 == yes */
*/
static DWORD WINAPI threadFunc1(LPVOID p)
{
t1Struct *tstruct = (t1Struct *)p;
t1Struct *tstruct = p;
int i;
/* write our thread # into shared memory */
tstruct->threadmem[tstruct->threadnum]=GetCurrentThreadId();
ok(TlsSetValue(tlsIndex,(LPVOID)(tstruct->threadnum+1))!=0,
ok(TlsSetValue(tlsIndex,(LPVOID)(INT_PTR)(tstruct->threadnum+1))!=0,
"TlsSetValue failed\n");
/* The threads synchronize before terminating. This is done by
Signaling an event, and waiting for all events to occur
@ -202,7 +205,7 @@ static DWORD WINAPI threadFunc1(LPVOID p)
ok( lstrlenA( (char *)0xdeadbeef ) == 0, "lstrlenA: unexpected success\n" );
/* Check that no one changed our tls memory */
ok((int)TlsGetValue(tlsIndex)-1==tstruct->threadnum,
ok((INT_PTR)TlsGetValue(tlsIndex)-1==tstruct->threadnum,
"TlsGetValue failed\n");
return NUM_THREADS+tstruct->threadnum;
}
@ -222,7 +225,7 @@ static DWORD WINAPI threadFunc3(LPVOID p)
static DWORD WINAPI threadFunc4(LPVOID p)
{
HANDLE event = (HANDLE)p;
HANDLE event = p;
if(event != NULL) {
SetEvent(event);
}
@ -233,7 +236,7 @@ static DWORD WINAPI threadFunc4(LPVOID p)
#if CHECK_STACK
static DWORD WINAPI threadFunc5(LPVOID p)
{
DWORD *exitCode = (DWORD *)p;
DWORD *exitCode = p;
SYSTEM_INFO sysInfo;
sysInfo.dwPageSize=0;
GetSystemInfo(&sysInfo);
@ -252,13 +255,13 @@ static DWORD WINAPI threadFunc5(LPVOID p)
static DWORD WINAPI threadFunc_SetEvent(LPVOID p)
{
SetEvent((HANDLE) p);
SetEvent(p);
return 0;
}
static DWORD WINAPI threadFunc_CloseHandle(LPVOID p)
{
CloseHandle((HANDLE) p);
CloseHandle(p);
return 0;
}
@ -305,7 +308,7 @@ static VOID test_CreateRemoteThread(void)
hRemoteEvent, CREATE_SUSPENDED, &tid);
if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
{
skip("CreateRemoteThread is not implemented\n");
win_skip("CreateRemoteThread is not implemented\n");
goto cleanup;
}
ok(hThread != NULL, "CreateRemoteThread failed, err=%u\n", GetLastError());
@ -547,8 +550,7 @@ static VOID test_TerminateThread(void)
HANDLE thread,access_thread,event;
DWORD threadId,exitCode;
event=CreateEventA(NULL,TRUE,FALSE,NULL);
thread = CreateThread(NULL,0,threadFunc4,
(LPVOID)event, 0,&threadId);
thread = CreateThread(NULL,0,threadFunc4,event,0,&threadId);
ok(thread!=NULL,"Create Thread failed\n");
/* TerminateThread has a race condition in Wine. If the thread is terminated
before it starts, it leaves a process behind. Therefore, we wait for the
@ -926,7 +928,7 @@ static DWORD CALLBACK work_function(void *p)
static void test_QueueUserWorkItem(void)
{
int i;
INT_PTR i;
DWORD wait_result;
DWORD before, after;
@ -975,7 +977,7 @@ static void test_RegisterWaitForSingleObject(void)
if (!pRegisterWaitForSingleObject || !pUnregisterWait)
{
skip("RegisterWaitForSingleObject or UnregisterWait not implemented\n");
win_skip("RegisterWaitForSingleObject or UnregisterWait not implemented\n");
return;
}
@ -1043,7 +1045,7 @@ static DWORD WINAPI TLS_InheritanceProc(LPVOID p)
inheritance with TLS_InheritanceProc. */
static DWORD WINAPI TLS_ThreadProc(LPVOID p)
{
LONG id = (LONG) p;
LONG_PTR id = (LONG_PTR) p;
LPVOID val;
BOOL ret;
@ -1163,7 +1165,7 @@ static DWORD WINAPI TLS_ThreadProc(LPVOID p)
static void test_TLS(void)
{
HANDLE threads[2];
LONG i;
LONG_PTR i;
DWORD ret;
BOOL suc;

View file

@ -294,7 +294,7 @@ static void test_GetTimeZoneInformation(void)
if (!pSystemTimeToTzSpecificLocalTime)
{
skip("SystemTimeToTzSpecificLocalTime not present\n");
win_skip("SystemTimeToTzSpecificLocalTime not available\n");
return;
}
@ -305,7 +305,7 @@ static void test_GetTimeZoneInformation(void)
res = pSystemTimeToTzSpecificLocalTime(&tzinfo, &utc, &current);
if (!res && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
{
skip("SystemTimeToTzSpecificLocalTime is not implemented\n");
win_skip("SystemTimeToTzSpecificLocalTime is not implemented\n");
return;
}
@ -425,7 +425,7 @@ static void test_TzSpecificLocalTimeToSystemTime(void)
if (!pTzSpecificLocalTimeToSystemTime || !pSystemTimeToTzSpecificLocalTime)
{
skip("TzSpecificLocalTimeToSystemTime or SystemTimeToTzSpecificLocalTime not present\n");
win_skip("TzSpecificLocalTimeToSystemTime or SystemTimeToTzSpecificLocalTime not available\n");
return;
}

View file

@ -18,6 +18,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#define _WIN32_WINNT 0x0501
#include "wine/test.h"
#include "winbase.h"
@ -37,14 +39,14 @@ static void test_timer(void)
pCreateWaitableTimerA = (fnCreateWaitableTimerA) GetProcAddress( hker, "CreateWaitableTimerA");
if( !pCreateWaitableTimerA )
{
skip("CreateWaitableTimerA is not available\n");
win_skip("CreateWaitableTimerA is not available\n");
return;
}
pSetWaitableTimer = (fnSetWaitableTimer) GetProcAddress( hker, "SetWaitableTimer");
if( !pSetWaitableTimer )
{
skip("SetWaitableTimer is not available\n");
win_skip("SetWaitableTimer is not available\n");
return;
}

View file

@ -44,7 +44,7 @@ static BOOL (WINAPI *pThread32Next)(HANDLE, LPTHREADENTRY32);
static DWORD WINAPI sub_thread(void* pmt)
{
DWORD w = WaitForSingleObject((HANDLE)pmt, WAIT_TIME);
DWORD w = WaitForSingleObject(pmt, WAIT_TIME);
return w;
}
@ -73,8 +73,8 @@ static int init(void)
case 2: /* the test program */
return 0;
case 4: /* the sub-process */
ev1 = (HANDLE)atoi(argv[2]);
ev2 = (HANDLE)atoi(argv[3]);
ev1 = (HANDLE)(INT_PTR)atoi(argv[2]);
ev2 = (HANDLE)(INT_PTR)atoi(argv[3]);
ev3 = CreateEvent(NULL, FALSE, FALSE, NULL);
if (ev3 == NULL) ExitProcess(WAIT_ABANDONED);
@ -204,14 +204,14 @@ static void test_thread(DWORD curr_pid, DWORD sub_pcs_pid)
static const char* curr_expected_modules[] =
{
"kernel32.dll",
"kernel32_test.exe"
"kernel32.dll",
/* FIXME: could test for ntdll on NT and Wine */
};
static const char* sub_expected_modules[] =
{
"kernel32.dll",
"kernel32_test.exe",
"kernel32.dll",
"shell32.dll"
/* FIXME: could test for ntdll on NT and Wine */
};
@ -283,6 +283,7 @@ START_TEST(toolhelp)
{
DWORD pid = GetCurrentProcessId();
int r;
char *p, module[MAX_PATH];
char buffer[MAX_PATH];
SECURITY_ATTRIBUTES sa;
PROCESS_INFORMATION info;
@ -304,7 +305,7 @@ START_TEST(toolhelp)
!pProcess32First || !pProcess32Next ||
!pThread32First || !pThread32Next)
{
skip("Needed functions are not available, most likely running on Windows NT\n");
win_skip("Needed functions are not available, most likely running on Windows NT\n");
return;
}
@ -324,12 +325,18 @@ START_TEST(toolhelp)
startup.dwFlags = STARTF_USESHOWWINDOW;
startup.wShowWindow = SW_SHOWNORMAL;
sprintf(buffer, "%s tests/toolhelp.c %u %u", selfname, (DWORD)ev1, (DWORD)ev2);
sprintf(buffer, "%s tests/toolhelp.c %lu %lu", selfname, (DWORD_PTR)ev1, (DWORD_PTR)ev2);
ok(CreateProcessA(NULL, buffer, NULL, NULL, TRUE, 0, NULL, NULL, &startup, &info), "CreateProcess\n");
/* wait for child to be initialized */
w = WaitForSingleObject(ev1, WAIT_TIME);
ok(w == WAIT_OBJECT_0, "Failed to wait on sub-process startup\n");
GetModuleFileNameA( 0, module, sizeof(module) );
if (!(p = strrchr( module, '\\' ))) p = module;
else p++;
curr_expected_modules[0] = p;
sub_expected_modules[0] = p;
test_process(pid, info.dwProcessId);
test_thread(pid, info.dwProcessId);
test_module(pid, curr_expected_modules, NUM_OF(curr_expected_modules));

View file

@ -107,7 +107,7 @@ static void test_VerifyVersionInfo(void)
if(!pVerifyVersionInfoA || !pVerSetConditionMask)
{
skip("Needed functions not available\n");
win_skip("Needed functions not available\n");
return;
}

View file

@ -22,7 +22,7 @@
#include <stdio.h>
#include "windef.h"
#include "psdk/winbase.h"
#include "winbase.h"
#include "winerror.h"
#include "wine/test.h"
@ -57,7 +57,7 @@ static void test_VirtualAllocEx(void)
{
const unsigned int alloc_size = 1<<15;
char *src, *dst;
unsigned long bytes_written = 0, bytes_read = 0, i;
SIZE_T bytes_written = 0, bytes_read = 0, i;
void *addr1, *addr2;
BOOL b;
DWORD old_prot;
@ -66,7 +66,7 @@ static void test_VirtualAllocEx(void)
/* not exported in all windows-versions */
if ((!pVirtualAllocEx) || (!pVirtualFreeEx)) {
skip("VirtualAllocEx not found\n");
win_skip("Virtual{Alloc,Free}Ex not available\n");
return;
}
@ -78,14 +78,14 @@ static void test_VirtualAllocEx(void)
PAGE_EXECUTE_READWRITE);
if (!addr1 && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
{ /* Win9x */
skip("VirtualAllocEx not implemented\n");
win_skip("VirtualAllocEx not implemented\n");
TerminateProcess(hProcess, 0);
CloseHandle(hProcess);
return;
}
src = HeapAlloc( GetProcessHeap(), 0, alloc_size );
dst = HeapAlloc( GetProcessHeap(), 0, alloc_size );
src = VirtualAlloc( NULL, alloc_size, MEM_COMMIT, PAGE_READWRITE );
dst = VirtualAlloc( NULL, alloc_size, MEM_COMMIT, PAGE_READWRITE );
for (i = 0; i < alloc_size; i++)
src[i] = i & 0xff;
@ -96,11 +96,40 @@ static void test_VirtualAllocEx(void)
b = ReadProcessMemory(hProcess, addr1, dst, alloc_size, &bytes_read);
ok(b && (bytes_read == alloc_size), "%lu bytes read\n", bytes_read);
ok(!memcmp(src, dst, alloc_size), "Data from remote process differs\n");
/* test invalid source buffers */
b = VirtualProtect( src + 0x2000, 0x2000, PAGE_NOACCESS, &old_prot );
ok( b, "VirtualProtect failed error %u\n", GetLastError() );
b = WriteProcessMemory(hProcess, addr1, src, alloc_size, &bytes_written);
ok( !b, "WriteProcessMemory succeeded\n" );
ok( GetLastError() == ERROR_NOACCESS ||
GetLastError() == ERROR_PARTIAL_COPY, /* vista */
"wrong error %u\n", GetLastError() );
ok( bytes_written == 0, "%lu bytes written\n", bytes_written );
b = ReadProcessMemory(hProcess, addr1, src, alloc_size, &bytes_read);
ok( !b, "ReadProcessMemory succeeded\n" );
ok( GetLastError() == ERROR_NOACCESS, "wrong error %u\n", GetLastError() );
ok( bytes_read == 0, "%lu bytes written\n", bytes_read );
b = VirtualProtect( src, 0x2000, PAGE_NOACCESS, &old_prot );
ok( b, "VirtualProtect failed error %u\n", GetLastError() );
b = WriteProcessMemory(hProcess, addr1, src, alloc_size, &bytes_written);
ok( !b, "WriteProcessMemory succeeded\n" );
ok( GetLastError() == ERROR_NOACCESS ||
GetLastError() == ERROR_PARTIAL_COPY, /* vista */
"wrong error %u\n", GetLastError() );
ok( bytes_written == 0, "%lu bytes written\n", bytes_written );
b = ReadProcessMemory(hProcess, addr1, src, alloc_size, &bytes_read);
ok( !b, "ReadProcessMemory succeeded\n" );
ok( GetLastError() == ERROR_NOACCESS, "wrong error %u\n", GetLastError() );
ok( bytes_read == 0, "%lu bytes written\n", bytes_read );
b = pVirtualFreeEx(hProcess, addr1, 0, MEM_RELEASE);
ok(b != 0, "VirtualFreeEx, error %u\n", GetLastError());
HeapFree( GetProcessHeap(), 0, src );
HeapFree( GetProcessHeap(), 0, dst );
VirtualFree( src, 0, MEM_FREE );
VirtualFree( dst, 0, MEM_FREE );
/*
* The following tests parallel those in test_VirtualAlloc()
@ -674,7 +703,7 @@ static void test_NtMapViewOfSection(void)
pNtUnmapViewOfSection = (void *)GetProcAddress( GetModuleHandle("ntdll.dll"), "NtUnmapViewOfSection" );
if (!pNtMapViewOfSection || !pNtUnmapViewOfSection)
{
skip( "NtMapViewOfSection not found\n" );
win_skip( "NtMapViewOfSection not available\n" );
return;
}

View file

@ -20,6 +20,7 @@
#include "wine/test.h"
#include "winbase.h"
#include <stdio.h>
static HINSTANCE hdll;
static BOOL (WINAPI * pGetVolumeNameForVolumeMountPointA)(LPCSTR, LPSTR, DWORD);
@ -29,29 +30,51 @@ static BOOL (WINAPI *pFindNextVolumeA)(HANDLE,LPSTR,DWORD);
static BOOL (WINAPI *pFindVolumeClose)(HANDLE);
static UINT (WINAPI *pGetLogicalDriveStringsA)(UINT,LPSTR);
static UINT (WINAPI *pGetLogicalDriveStringsW)(UINT,LPWSTR);
static BOOL (WINAPI *pGetVolumeInformationA)(LPCSTR, LPSTR, DWORD, LPDWORD, LPDWORD, LPDWORD, LPSTR, DWORD);
/* ############################### */
static void test_query_dos_deviceA(void)
{
char drivestr[] = "a:";
char *p, buffer[2000];
DWORD ret;
char *p, *buffer, buffer2[2000];
DWORD ret, ret2, buflen=32768;
BOOL found = FALSE;
if (!pFindFirstVolumeA) {
skip("On win9x, HARDDISK and RAMDISK not present\n");
win_skip("On win9x, HARDDISK and RAMDISK not present\n");
return;
}
buffer = HeapAlloc( GetProcessHeap(), 0, buflen );
ret = QueryDosDeviceA( NULL, buffer, buflen );
ok(ret && GetLastError() != ERROR_INSUFFICIENT_BUFFER,
"QueryDosDevice buffer too small\n");
if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
HeapFree( GetProcessHeap(), 0, buffer );
return;
}
ok(ret, "QueryDosDeviceA failed to return list, last error %u\n", GetLastError());
if (ret) {
p = buffer;
for (;;) {
if (!strlen(p)) break;
ret2 = QueryDosDeviceA( p, buffer2, sizeof(buffer2) );
ok(ret2, "QueryDosDeviceA failed to return current mapping for %s, last error %u\n", p, GetLastError());
p += strlen(p) + 1;
if (ret <= (p-buffer)) break;
}
}
for (;drivestr[0] <= 'z'; drivestr[0]++) {
ret = QueryDosDeviceA( drivestr, buffer, sizeof(buffer));
ret = QueryDosDeviceA( drivestr, buffer, buflen);
if(ret) {
for (p = buffer; *p; p++) *p = toupper(*p);
if (strstr(buffer, "HARDDISK") || strstr(buffer, "RAMDISK")) found = TRUE;
}
}
ok(found, "expected at least one devicename to contain HARDDISK or RAMDISK\n");
HeapFree( GetProcessHeap(), 0, buffer );
}
static void test_FindFirstVolume(void)
@ -216,6 +239,130 @@ static void test_GetLogicalDriveStringsW(void)
HeapFree(GetProcessHeap(), 0, buf);
}
static void test_GetVolumeInformationA(void)
{
BOOL ret;
UINT result;
char Root_Dir0[]="C:";
char Root_Dir1[]="C:\\";
char Root_Dir2[]="\\\\?\\C:\\";
char volume[MAX_PATH+1];
DWORD vol_name_size=MAX_PATH+1, vol_serial_num=-1, max_comp_len=0, fs_flags=0, fs_name_len=MAX_PATH+1;
char vol_name_buf[MAX_PATH+1], fs_name_buf[MAX_PATH+1];
char windowsdir[MAX_PATH+10];
if (!pGetVolumeInformationA) {
win_skip("GetVolumeInformationA not found\n");
return;
}
if (!pGetVolumeNameForVolumeMountPointA) {
win_skip("GetVolumeNameForVolumeMountPointA not found\n");
return;
}
/* get windows drive letter and update strings for testing */
result = GetWindowsDirectory(windowsdir, sizeof(windowsdir));
ok(result < sizeof(windowsdir), "windowsdir is abnormally long!\n");
ok(result != 0, "GetWindowsDirectory: error %d\n", GetLastError());
Root_Dir0[0] = windowsdir[0];
Root_Dir1[0] = windowsdir[0];
Root_Dir2[4] = windowsdir[0];
/* get the unique volume name for the windows drive */
ret = pGetVolumeNameForVolumeMountPointA(Root_Dir1, volume, MAX_PATH);
ok(ret == TRUE, "GetVolumeNameForVolumeMountPointA failed\n");
/* **** now start the tests **** */
/* check for error on no trailing \ */
ret = pGetVolumeInformationA(Root_Dir0, vol_name_buf, vol_name_size, NULL,
NULL, NULL, fs_name_buf, fs_name_len);
ok(!ret && GetLastError() == ERROR_INVALID_NAME,
"GetVolumeInformationA w/o '\\' did not fail, last error %u\n", GetLastError());
/* try null root directory to return "root of the current directory" */
ret = pGetVolumeInformationA(NULL, vol_name_buf, vol_name_size, NULL,
NULL, NULL, fs_name_buf, fs_name_len);
ok(ret, "GetVolumeInformationA failed on null root dir, last error %u\n", GetLastError());
/* Try normal drive letter with trailing \ */
ret = pGetVolumeInformationA(Root_Dir1, vol_name_buf, vol_name_size,
&vol_serial_num, &max_comp_len, &fs_flags, fs_name_buf, fs_name_len);
ok(ret, "GetVolumeInformationA failed, root=%s, last error=%u\n", Root_Dir1, GetLastError());
/* try again with dirve letter and the "disable parsing" prefix */
ret = pGetVolumeInformationA(Root_Dir2, vol_name_buf, vol_name_size,
&vol_serial_num, &max_comp_len, &fs_flags, fs_name_buf, fs_name_len);
todo_wine ok(ret, "GetVolumeInformationA failed, root=%s, last error=%u\n", Root_Dir2, GetLastError());
/* try again with unique voluem name */
ret = pGetVolumeInformationA(volume, vol_name_buf, vol_name_size,
&vol_serial_num, &max_comp_len, &fs_flags, fs_name_buf, fs_name_len);
todo_wine ok(ret, "GetVolumeInformationA failed, root=%s, last error=%u\n", volume, GetLastError());
/* try again with device name space */
Root_Dir2[2] = '.';
ret = pGetVolumeInformationA(Root_Dir2, vol_name_buf, vol_name_size,
&vol_serial_num, &max_comp_len, &fs_flags, fs_name_buf, fs_name_len);
todo_wine ok(ret, "GetVolumeInformationA failed, root=%s, last error=%u\n", Root_Dir2, GetLastError());
/* try again with a directory off the root - should generate error */
if (windowsdir[strlen(windowsdir)-1] != '\\') strcat(windowsdir, "\\");
ret = pGetVolumeInformationA(windowsdir, vol_name_buf, vol_name_size,
&vol_serial_num, &max_comp_len, &fs_flags, fs_name_buf, fs_name_len);
todo_wine ok(!ret && GetLastError()==ERROR_DIR_NOT_ROOT,
"GetVolumeInformationA failed, root=%s, last error=%u\n", windowsdir, GetLastError());
}
/* Test to check that unique volume name from windows dir mount point */
/* matches at least one of the unique volume names returned from the */
/* FindFirstVolumeA/FindNextVolumeA list. */
static void test_enum_vols(void)
{
DWORD ret;
HANDLE hFind = INVALID_HANDLE_VALUE;
char Volume_1[MAX_PATH] = {0};
char Volume_2[MAX_PATH] = {0};
char path[] = "c:\\";
BOOL found = FALSE;
char windowsdir[MAX_PATH];
if (!pGetVolumeNameForVolumeMountPointA) {
win_skip("GetVolumeNameForVolumeMountPointA not found\n");
return;
}
/*get windows drive letter and update strings for testing */
ret = GetWindowsDirectory( windowsdir, sizeof(windowsdir) );
ok(ret < sizeof(windowsdir), "windowsdir is abnormally long!\n");
ok(ret != 0, "GetWindowsDirecory: error %d\n", GetLastError());
path[0] = windowsdir[0];
/* get the unique volume name for the windows drive */
ret = pGetVolumeNameForVolumeMountPointA( path, Volume_1, MAX_PATH );
ok(ret == TRUE, "GetVolumeNameForVolumeMountPointA failed\n");
todo_wine
ok(strlen(Volume_1) == 49, "GetVolumeNameForVolumeMountPointA returned wrong length name %s\n", Volume_1);
/* get first unique volume name of list */
hFind = pFindFirstVolumeA( Volume_2, MAX_PATH );
ok(hFind != INVALID_HANDLE_VALUE, "FindFirstVolume failed, err=%u\n",
GetLastError());
do
{
/* validate correct length of unique volume name */
ok(strlen(Volume_2) == 49, "Find[First/Next]Volume returned wrong length name %s\n", Volume_1);
if (memcmp(Volume_1, Volume_2, 49) == 0)
{
found = TRUE;
break;
}
} while (pFindNextVolumeA( hFind, Volume_2, MAX_PATH ));
todo_wine
ok(found, "volume name %s not found by Find[First/Next]Volume\n", Volume_1);
pFindVolumeClose( hFind );
}
START_TEST(volume)
{
hdll = GetModuleHandleA("kernel32.dll");
@ -226,6 +373,7 @@ START_TEST(volume)
pFindVolumeClose = (void *) GetProcAddress(hdll, "FindVolumeClose");
pGetLogicalDriveStringsA = (void *) GetProcAddress(hdll, "GetLogicalDriveStringsA");
pGetLogicalDriveStringsW = (void *) GetProcAddress(hdll, "GetLogicalDriveStringsW");
pGetVolumeInformationA = (void *) GetProcAddress(hdll, "GetVolumeInformationA");
test_query_dos_deviceA();
test_FindFirstVolume();
@ -233,4 +381,6 @@ START_TEST(volume)
test_GetVolumeNameForVolumeMountPointW();
test_GetLogicalDriveStringsA();
test_GetLogicalDriveStringsW();
test_GetVolumeInformationA();
test_enum_vols();
}

View file

@ -211,7 +211,7 @@ static void test_multibyte_to_unicode_translations(IMultiLanguage2 *iML2)
ok(lenA == expected_len, "expected lenA %u, got %u\n", expected_len, lenA);
}
static inline void cpinfo_cmp(MIMECPINFO *cpinfo1, MIMECPINFO *cpinfo2)
static void cpinfo_cmp(MIMECPINFO *cpinfo1, MIMECPINFO *cpinfo2)
{
ok(cpinfo1->dwFlags == cpinfo2->dwFlags, "dwFlags mismatch: %08x != %08x\n", cpinfo1->dwFlags, cpinfo2->dwFlags);
ok(cpinfo1->uiCodePage == cpinfo2->uiCodePage, "uiCodePage mismatch: %u != %u\n", cpinfo1->uiCodePage, cpinfo2->uiCodePage);
@ -538,7 +538,7 @@ static void test_EnumCodePages(IMultiLanguage2 *iML2, DWORD flags)
IEnumCodePage_Release(iEnumCP);
}
static inline void scriptinfo_cmp(SCRIPTINFO *sinfo1, SCRIPTINFO *sinfo2)
static void scriptinfo_cmp(SCRIPTINFO *sinfo1, SCRIPTINFO *sinfo2)
{
ok(sinfo1->ScriptId == sinfo2->ScriptId, "ScriptId mismatch: %d != %d\n", sinfo1->ScriptId, sinfo2->ScriptId);
ok(sinfo1->uiCodePage == sinfo2->uiCodePage, "uiCodePage mismatch: %u != %u\n", sinfo1->uiCodePage, sinfo2->uiCodePage);
@ -649,6 +649,8 @@ static void IMLangFontLink_Test(IMLangFontLink* iMLFL)
DWORD dwCodePages, dwManyCodePages;
DWORD dwCmpCodePages;
UINT CodePage;
static const WCHAR str[3] = { 'd', 0x0436, 0xff90 };
LONG processed;
HRESULT ret;
dwCodePages = ~0u;
@ -693,21 +695,89 @@ static void IMLangFontLink_Test(IMLangFontLink* iMLFL)
dwCmpCodePages = FS_LATIN1 | FS_LATIN2 | FS_CYRILLIC | FS_GREEK | FS_TURKISH
| FS_HEBREW | FS_ARABIC | FS_BALTIC | FS_VIETNAMESE | FS_THAI
| FS_JISJAPAN | FS_CHINESESIMP | FS_WANSUNG | FS_CHINESETRAD;
ok(IMLangFontLink_GetCharCodePages(iMLFL, 'd', &dwCodePages) == S_OK,
"IMLangFontLink_GetCharCodePages failed\n");
ok(dwCodePages == dwCmpCodePages, "Incorrect CodePages returned (%i)\n", dwCodePages);
ret = IMLangFontLink_GetCharCodePages(iMLFL, 'd', &dwCodePages);
ok(ret == S_OK, "IMLangFontLink_GetCharCodePages error %x\n", ret);
ok(dwCodePages == dwCmpCodePages, "expected %x, got %x\n", dwCmpCodePages, dwCodePages);
dwCodePages = 0;
processed = 0;
ret = IMLangFontLink_GetStrCodePages(iMLFL, &str[0], 1, 0, &dwCodePages, &processed);
ok(ret == S_OK, "IMLangFontLink_GetStrCodePages error %x\n", ret);
ok(dwCodePages == dwCmpCodePages, "expected %x, got %x\n", dwCmpCodePages, dwCodePages);
ok(processed == 1, "expected 1, got %d\n", processed);
/* Cyrillic */
dwCmpCodePages = FS_CYRILLIC | FS_JISJAPAN | FS_CHINESESIMP | FS_WANSUNG;
ok(IMLangFontLink_GetCharCodePages(iMLFL, 0x0436, &dwCodePages) == S_OK,
"IMLangFontLink_GetCharCodePages failed\n");
ok(dwCodePages == dwCmpCodePages, "Incorrect CodePages returned (%i)\n", dwCodePages);
ret = IMLangFontLink_GetCharCodePages(iMLFL, 0x0436, &dwCodePages);
ok(ret == S_OK, "IMLangFontLink_GetCharCodePages error %x\n", ret);
ok(dwCodePages == dwCmpCodePages, "expected %x, got %x\n", dwCmpCodePages, dwCodePages);
dwCodePages = 0;
processed = 0;
ret = IMLangFontLink_GetStrCodePages(iMLFL, &str[1], 1, 0, &dwCodePages, &processed);
ok(ret == S_OK, "IMLangFontLink_GetStrCodePages error %x\n", ret);
ok(dwCodePages == dwCmpCodePages, "expected %x, got %x\n", dwCmpCodePages, dwCodePages);
ok(processed == 1, "expected 1, got %d\n", processed);
/* Japanese */
dwCmpCodePages = FS_JISJAPAN;
ok(IMLangFontLink_GetCharCodePages(iMLFL, 0xff90, &dwCodePages) == S_OK,
"IMLangFontLink_GetCharCodePages failed\n");
ok(dwCodePages == dwCmpCodePages, "Incorrect CodePages returned (%i)\n", dwCodePages);
ret = IMLangFontLink_GetCharCodePages(iMLFL, 0xff90, &dwCodePages);
ok(ret == S_OK, "IMLangFontLink_GetCharCodePages error %x\n", ret);
ok(dwCodePages == dwCmpCodePages, "expected %x, got %x\n", dwCmpCodePages, dwCodePages);
dwCodePages = 0;
processed = 0;
ret = IMLangFontLink_GetStrCodePages(iMLFL, &str[2], 1, 0, &dwCodePages, &processed);
ok(ret == S_OK, "IMLangFontLink_GetStrCodePages error %x\n", ret);
ok(dwCodePages == dwCmpCodePages, "expected %x, got %x\n", dwCmpCodePages, dwCodePages);
ok(processed == 1, "expected 1, got %d\n", processed);
dwCmpCodePages = FS_CYRILLIC | FS_JISJAPAN | FS_CHINESESIMP | FS_WANSUNG;
dwCodePages = 0;
processed = 0;
ret = IMLangFontLink_GetStrCodePages(iMLFL, str, 2, 0, &dwCodePages, &processed);
ok(ret == S_OK, "IMLangFontLink_GetStrCodePages error %x\n", ret);
ok(dwCodePages == dwCmpCodePages, "expected %x, got %x\n", dwCmpCodePages, dwCodePages);
ok(processed == 2, "expected 2, got %d\n", processed);
dwCmpCodePages = FS_JISJAPAN;
dwCodePages = 0;
processed = 0;
ret = IMLangFontLink_GetStrCodePages(iMLFL, str, 3, 0, &dwCodePages, &processed);
ok(ret == S_OK, "IMLangFontLink_GetStrCodePages error %x\n", ret);
ok(dwCodePages == dwCmpCodePages, "expected %x, got %x\n", dwCmpCodePages, dwCodePages);
ok(processed == 3, "expected 3, got %d\n", processed);
dwCodePages = 0xffff;
processed = -1;
ret = IMLangFontLink_GetStrCodePages(iMLFL, &str[2], 1, 0, &dwCodePages, &processed);
ok(ret == S_OK, "IMLangFontLink_GetStrCodePages error %x\n", ret);
ok(dwCodePages == dwCmpCodePages, "expected %x, got %x\n", dwCmpCodePages, dwCodePages);
ok(processed == 1, "expected 0, got %d\n", processed);
ret = IMLangFontLink_GetStrCodePages(iMLFL, &str[2], 1, 0, NULL, NULL);
ok(ret == S_OK, "IMLangFontLink_GetStrCodePages error %x\n", ret);
dwCodePages = 0xffff;
processed = -1;
ret = IMLangFontLink_GetStrCodePages(iMLFL, str, -1, 0, &dwCodePages, &processed);
ok(ret == E_INVALIDARG, "IMLangFontLink_GetStrCodePages should fail: %x\n", ret);
ok(dwCodePages == 0, "expected %x, got %x\n", dwCmpCodePages, dwCodePages);
ok(processed == 0, "expected 0, got %d\n", processed);
dwCodePages = 0xffff;
processed = -1;
ret = IMLangFontLink_GetStrCodePages(iMLFL, NULL, 1, 0, &dwCodePages, &processed);
ok(ret == E_INVALIDARG, "IMLangFontLink_GetStrCodePages should fail: %x\n", ret);
ok(dwCodePages == 0, "expected %x, got %x\n", dwCmpCodePages, dwCodePages);
ok(processed == 0, "expected 0, got %d\n", processed);
dwCodePages = 0xffff;
processed = -1;
ret = IMLangFontLink_GetStrCodePages(iMLFL, str, 0, 0, &dwCodePages, &processed);
ok(ret == E_INVALIDARG, "IMLangFontLink_GetStrCodePages should fail: %x\n", ret);
ok(dwCodePages == 0, "expected %x, got %x\n", dwCmpCodePages, dwCodePages);
ok(processed == 0, "expected 0, got %d\n", processed);
}
/* copied from libs/wine/string.c */
@ -1395,7 +1465,7 @@ static void test_GetScriptFontInfo(IMLangFontLink2 *font_link)
hr = IMLangFontLink2_GetScriptFontInfo(font_link, sidLatin, SCRIPTCONTF_FIXED_FONT, &nfonts, sfi);
ok(hr == S_OK, "GetScriptFontInfo failed %u\n", GetLastError());
ok(nfonts == 1, "got %u, expected 1\n", nfonts);
ok(sfi[0].scripts, "unexpected result\n");
ok(sfi[0].scripts != 0, "unexpected result\n");
ok(sfi[0].wszFont[0], "unexpected result\n");
nfonts = 1;
@ -1403,7 +1473,7 @@ static void test_GetScriptFontInfo(IMLangFontLink2 *font_link)
hr = IMLangFontLink2_GetScriptFontInfo(font_link, sidLatin, SCRIPTCONTF_PROPORTIONAL_FONT, &nfonts, sfi);
ok(hr == S_OK, "GetScriptFontInfo failed %u\n", GetLastError());
ok(nfonts == 1, "got %u, expected 1\n", nfonts);
ok(sfi[0].scripts, "unexpected result\n");
ok(sfi[0].scripts != 0, "unexpected result\n");
ok(sfi[0].wszFont[0], "unexpected result\n");
}

View file

@ -581,9 +581,14 @@ static void check_registry(BOOL *has_space_rgb)
trace("RegEnumValueA() failed (%d), cannot enumerate profiles\n", res);
break;
}
ok( dwType == REG_SZ, "RegEnumValueA() returned unexpected value type (%d)\n", dwType );
if (dwType != REG_SZ) break;
trace(" found '%s' value containing '%s' (%d chars)\n", szName, szData, lstrlenA(szData));
ok( dwType == REG_SZ || dwType == REG_DWORD, "RegEnumValueA() returned unexpected value type (%d)\n", dwType );
if (dwType == REG_SZ)
trace(" found string value '%s' containing '%s' (%d chars)\n", szName, szData, lstrlenA(szData));
else if (dwType == REG_DWORD)
trace(" found DWORD value '%s' containing '%x'\n", szName, *(DWORD *)szData);
else
break;
}
RegCloseKey( hkIcmKey );

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -36,6 +36,7 @@
#include "dispex.h"
#include "idispids.h"
#include "shlguid.h"
#include "perhist.h"
DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
DEFINE_GUID(IID_IProxyManager,0x00000008,0x0000,0x0000,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
@ -102,6 +103,7 @@ DEFINE_EXPECT(Exec_SETDOWNLOADSTATE_1);
DEFINE_EXPECT(Exec_ShellDocView_37);
DEFINE_EXPECT(Exec_ShellDocView_84);
DEFINE_EXPECT(Exec_ShellDocView_103);
DEFINE_EXPECT(Exec_ShellDocView_105);
DEFINE_EXPECT(Exec_UPDATECOMMANDS);
DEFINE_EXPECT(Exec_SETTITLE);
DEFINE_EXPECT(Exec_HTTPEQUIV);
@ -148,7 +150,7 @@ static BOOL expect_LockContainer_fLock;
static BOOL expect_InPlaceUIWindow_SetActiveObject_active = TRUE;
static BOOL ipsex;
static BOOL set_clientsite = FALSE, container_locked = FALSE;
static BOOL readystate_set_loading = FALSE, load_from_stream;
static BOOL readystate_set_loading = FALSE, readystate_set_interactive = FALSE, load_from_stream;
static BOOL editmode = FALSE, show_failed;
static int stream_read, protocol_read;
static enum load_state_t {
@ -334,7 +336,7 @@ static ULONG WINAPI Protocol_Release(IInternetProtocol *iface)
static HRESULT WINAPI Protocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo,
DWORD grfPI, DWORD dwReserved)
DWORD grfPI, HANDLE_PTR dwReserved)
{
BINDINFO bindinfo;
DWORD bindf = 0;
@ -348,7 +350,7 @@ static HRESULT WINAPI Protocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
ok(pOIProtSink != NULL, "pOIProtSink == NULL\n");
ok(pOIBindInfo != NULL, "pOIBindInfo == NULL\n");
ok(!grfPI, "grfPI = %x\n", grfPI);
ok(!dwReserved, "dwReserved = %d\n", dwReserved);
ok(!dwReserved, "dwReserved = %lx\n", dwReserved);
memset(&bindinfo, 0, sizeof(bindinfo));
bindinfo.cbSize = sizeof(bindinfo);
@ -647,6 +649,12 @@ static HRESULT WINAPI PropertyNotifySink_OnChanged(IPropertyNotifySink *iface, D
switch(dispID) {
case DISPID_READYSTATE:
CHECK_EXPECT2(OnChanged_READYSTATE);
if(readystate_set_interactive) {
readystate_set_interactive = FALSE;
load_state = LD_INTERACTIVE;
}
else
test_MSHTML_QueryStatus(NULL, OLECMDF_SUPPORTED
| (editmode && (load_state == LD_INTERACTIVE || load_state == LD_COMPLETE)
? OLECMDF_ENABLED : 0));
@ -662,7 +670,7 @@ static HRESULT WINAPI PropertyNotifySink_OnChanged(IPropertyNotifySink *iface, D
CHECK_EXPECT(OnChanged_1005);
if(!editmode)
test_readyState(NULL);
load_state = LD_INTERACTIVE;
readystate_set_interactive = (load_state != LD_INTERACTIVE);
return S_OK;
}
@ -2137,6 +2145,7 @@ static HRESULT WINAPI OleCommandTarget_Exec(IOleCommandTarget *iface, const GUID
break;
case 1:
CHECK_EXPECT(Exec_SETDOWNLOADSTATE_1);
readystate_set_interactive = (load_state != LD_INTERACTIVE);
break;
default:
ok(0, "unexpevted V_I4(pvaIn)=%d\n", V_I4(pvaIn));
@ -2205,6 +2214,14 @@ static HRESULT WINAPI OleCommandTarget_Exec(IOleCommandTarget *iface, const GUID
return E_NOTIMPL;
case 105:
CHECK_EXPECT2(Exec_ShellDocView_105);
ok(pvaIn != NULL, "pvaIn == NULL\n");
ok(pvaOut == NULL, "pvaOut != NULL\n");
return E_NOTIMPL;
default:
ok(0, "unexpected command %d\n", nCmdID);
return E_FAIL;
@ -2749,6 +2766,7 @@ static void test_download(BOOL verb_done, BOOL css_dwl, BOOL css_try_dwl)
SET_EXPECT(Exec_SETPROGRESSPOS);
SET_EXPECT(Exec_SETDOWNLOADSTATE_0);
SET_EXPECT(Exec_ShellDocView_103);
SET_EXPECT(Exec_ShellDocView_105);
SET_EXPECT(Exec_MSHTML_PARSECOMPLETE);
SET_EXPECT(Exec_HTTPEQUIV_DONE);
SET_EXPECT(SetStatusText);
@ -2801,6 +2819,7 @@ static void test_download(BOOL verb_done, BOOL css_dwl, BOOL css_try_dwl)
CHECK_CALLED(Exec_SETPROGRESSPOS);
CHECK_CALLED(Exec_SETDOWNLOADSTATE_0);
SET_CALLED(Exec_ShellDocView_103);
SET_CALLED(Exec_ShellDocView_105);
CHECK_CALLED(Exec_MSHTML_PARSECOMPLETE);
CHECK_CALLED(Exec_HTTPEQUIV_DONE);
SET_CALLED(SetStatusText);
@ -4160,6 +4179,26 @@ static void test_HTMLDoc_ISupportErrorInfo(void)
ok(ref == 0, "ref=%d, expected 0\n", ref);
}
static void test_IPersistHistory(void)
{
HRESULT hres;
IUnknown *unk;
LONG ref;
IPersistHistory *phist;
hres = create_document(&unk);
if(FAILED(hres))
return;
hres = IUnknown_QueryInterface(unk, &IID_IPersistHistory, (void**)&phist);
ok(hres == S_OK, "QueryInterface returned %08x, expected S_OK\n", hres);
if(hres == S_OK)
IPersistHistory_Release(phist);
ref = IUnknown_Release(unk);
ok(ref == 0, "ref=%d, expected 0\n", ref);
}
START_TEST(htmldoc)
{
gecko_installer_workaround(TRUE);
@ -4177,6 +4216,7 @@ START_TEST(htmldoc)
test_editing_mode(TRUE);
}
test_HTMLDoc_ISupportErrorInfo();
test_IPersistHistory();
DestroyWindow(container_hwnd);
CoUninitialize();

View file

@ -1046,7 +1046,7 @@ static HRESULT Session_EvaluateCondition(IDispatch *pSession, LPCWSTR szConditio
return hr;
}
static HRESULT Session_Message(IDispatch *pSession, long kind, IDispatch *record, int *ret)
static HRESULT Session_Message(IDispatch *pSession, LONG kind, IDispatch *record, int *ret)
{
VARIANT varresult;
VARIANTARG vararg[2];
@ -1067,7 +1067,7 @@ static HRESULT Session_Message(IDispatch *pSession, long kind, IDispatch *record
return hr;
}
static HRESULT Session_SetInstallLevel(IDispatch *pSession, long iInstallLevel)
static HRESULT Session_SetInstallLevel(IDispatch *pSession, LONG iInstallLevel)
{
VARIANT varresult;
VARIANTARG vararg[1];
@ -2022,7 +2022,7 @@ static void test_Installer_Products(BOOL bProductInstalled)
}
}
if (bProductInstalled) todo_wine
if (bProductInstalled)
{
ok(bProductInstalled == bProductFound, "Product expected to %s installed but product code was %s\n",
bProductInstalled ? "be" : "not be",
@ -2295,12 +2295,22 @@ static void test_Installer_InstallProduct(void)
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
res = find_registry_key(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData", "05FA3C1F65B896A40AC00077F34EF203", &hkey);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
ok(res == ERROR_SUCCESS ||
broken(res == ERROR_FILE_NOT_FOUND), /* win9x */
"Expected ERROR_SUCCESS, got %d\n", res);
if (res == ERROR_SUCCESS)
{
res = delete_registry_key(hkey, "05FA3C1F65B896A40AC00077F34EF203");
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
RegCloseKey(hkey);
res = RegDeleteKeyA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Installer\\Products\\05FA3C1F65B896A40AC00077F34EF203");
ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
}
else
{
/* win9x defaults to a per-machine install. */
RegDeleteKeyA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Installer\\Products\\05FA3C1F65B896A40AC00077F34EF203");
}
/* Remove registry keys written by PublishProduct standard action */
@ -2315,16 +2325,12 @@ static void test_Installer_InstallProduct(void)
RegCloseKey(hkey);
res = RegDeleteKeyA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Installer\\Products\\05FA3C1F65B896A40AC00077F34EF203");
ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
/* Delete installation files we installed */
delete_test_files();
}
static void test_Installer(void)
{
static WCHAR szBackslash[] = { '\\',0 };
static WCHAR szCreateRecordException[] = { 'C','r','e','a','t','e','R','e','c','o','r','d',',','C','o','u','n','t',0 };
static WCHAR szIntegerDataException[] = { 'I','n','t','e','g','e','r','D','a','t','a',',','F','i','e','l','d',0 };
WCHAR szPath[MAX_PATH];
@ -2388,8 +2394,9 @@ static void test_Installer(void)
ok(len, "MultiByteToWideChar returned error %d\n", GetLastError());
if (!len) return;
lstrcatW(szPath, szBackslash);
lstrcatW(szPath, szMsifile);
/* lstrcatW does not work on win95 */
szPath[len - 1] = '\\';
memcpy(&szPath[len], szMsifile, sizeof(szMsifile));
/* Installer::OpenPackage */
hr = Installer_OpenPackage(szPath, 0, &pSession);

View file

@ -321,10 +321,8 @@ static void test_msiinsert(void)
r = MsiRecordGetFieldCount(hrec);
ok(r == 3, "record count wrong\n");
todo_wine {
r = MsiRecordIsNull(hrec, 0);
ok(r == FALSE, "field 0 not null\n");
}
r = MsiRecordGetInteger(hrec, 1);
ok(r == 1, "field 1 contents wrong\n");
@ -651,7 +649,10 @@ static void test_msibadqueries(void)
ok(r == ERROR_SUCCESS , "query failed\n");
r = try_query( hdb, "select * from c where b = 'x");
todo_wine ok(r == ERROR_BAD_QUERY_SYNTAX, "query failed\n");
ok(r == ERROR_BAD_QUERY_SYNTAX, "query failed\n");
r = try_query( hdb, "select * from c where b = 'x'");
ok(r == ERROR_SUCCESS, "query failed\n");
r = try_query( hdb, "select * from 'c'");
ok(r == ERROR_BAD_QUERY_SYNTAX, "query failed\n");
@ -900,10 +901,7 @@ static void test_viewmodify(void)
ok(r == ERROR_SUCCESS, "failed to set string\n");
r = MsiViewModify(hview, MSIMODIFY_UPDATE, hrec);
todo_wine
{
ok(r == ERROR_FUNCTION_FAILED, "MsiViewModify failed\n");
}
r = MsiCloseHandle(hrec);
ok(r == ERROR_SUCCESS, "failed to close record\n");
@ -1072,8 +1070,8 @@ static MSIHANDLE get_column_info(MSIHANDLE hdb, const char *query, MSICOLINFO ty
if( r == ERROR_SUCCESS )
{
MsiViewGetColumnInfo( hview, type, &rec );
MsiViewClose(hview);
}
MsiViewClose(hview);
MsiCloseHandle(hview);
return rec;
}
@ -1103,9 +1101,8 @@ static UINT get_columns_table_type(MSIHANDLE hdb, const char *table, UINT field)
type = MsiRecordGetInteger( rec, 4 );
MsiCloseHandle( rec );
}
MsiViewClose(hview);
}
MsiViewClose(hview);
MsiCloseHandle(hview);
return type;
}
@ -1131,7 +1128,14 @@ static void test_viewgetcolumninfo(void)
r = run_query( hdb, 0,
"CREATE TABLE `Properties` "
"( `Property` CHAR(255), `Value` CHAR(1) PRIMARY KEY `Property`)" );
"( `Property` CHAR(255), "
" `Value` CHAR(1), "
" `Intvalue` INT, "
" `Integervalue` INTEGER, "
" `Shortvalue` SHORT, "
" `Longvalue` LONG, "
" `Longcharvalue` LONGCHAR "
" PRIMARY KEY `Property`)" );
ok( r == ERROR_SUCCESS , "Failed to create table\n" );
/* check the column types */
@ -1140,12 +1144,22 @@ static void test_viewgetcolumninfo(void)
ok( check_record( rec, 1, "S255"), "wrong record type\n");
ok( check_record( rec, 2, "S1"), "wrong record type\n");
ok( check_record( rec, 3, "I2"), "wrong record type\n");
ok( check_record( rec, 4, "I2"), "wrong record type\n");
ok( check_record( rec, 5, "I2"), "wrong record type\n");
ok( check_record( rec, 6, "I4"), "wrong record type\n");
ok( check_record( rec, 7, "S0"), "wrong record type\n");
MsiCloseHandle( rec );
/* check the type in _Columns */
ok( 0x3dff == get_columns_table_type(hdb, "Properties", 1 ), "_columns table wrong\n");
ok( 0x1d01 == get_columns_table_type(hdb, "Properties", 2 ), "_columns table wrong\n");
ok( 0x1502 == get_columns_table_type(hdb, "Properties", 3 ), "_columns table wrong\n");
ok( 0x1502 == get_columns_table_type(hdb, "Properties", 4 ), "_columns table wrong\n");
ok( 0x1502 == get_columns_table_type(hdb, "Properties", 5 ), "_columns table wrong\n");
ok( 0x1104 == get_columns_table_type(hdb, "Properties", 6 ), "_columns table wrong\n");
ok( 0x1d00 == get_columns_table_type(hdb, "Properties", 7 ), "_columns table wrong\n");
/* now try the names */
rec = get_column_info( hdb, "select * from `Properties`", MSICOLINFO_NAMES );
@ -1153,6 +1167,11 @@ static void test_viewgetcolumninfo(void)
ok( check_record( rec, 1, "Property"), "wrong record type\n");
ok( check_record( rec, 2, "Value"), "wrong record type\n");
ok( check_record( rec, 3, "Intvalue"), "wrong record type\n");
ok( check_record( rec, 4, "Integervalue"), "wrong record type\n");
ok( check_record( rec, 5, "Shortvalue"), "wrong record type\n");
ok( check_record( rec, 6, "Longvalue"), "wrong record type\n");
ok( check_record( rec, 7, "Longcharvalue"), "wrong record type\n");
MsiCloseHandle( rec );
@ -1327,6 +1346,7 @@ static void test_longstrings(void)
r = MsiViewFetch(hview, &hrec);
ok(r == ERROR_SUCCESS, "MsiViewFetch failed\n");
MsiViewClose(hview);
MsiCloseHandle(hview);
r = MsiRecordGetString(hrec, 2, NULL, &len);
@ -1427,6 +1447,7 @@ static void test_streamtable(void)
ok( r == ERROR_SUCCESS, "Failed to execute view: %d\n", r);
MsiCloseHandle( rec );
MsiViewClose( view );
MsiCloseHandle( view );
r = MsiDatabaseOpenView( hdb,
@ -1455,6 +1476,7 @@ static void test_streamtable(void)
r = MsiViewFetch( view, &rec );
ok( r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
MsiViewClose( view );
MsiCloseHandle( view );
MsiCloseHandle( hdb );
DeleteFile(msifile);
@ -1716,6 +1738,7 @@ static void test_msiimport(void)
ok(i == -2147483640, "Expected -2147483640, got %d\n", i);
MsiCloseHandle(rec);
MsiViewClose(view);
MsiCloseHandle(view);
query = "SELECT * FROM `TwoPrimary`";
@ -2044,6 +2067,7 @@ static void test_handle_limit(void)
for (i=0; i<MY_NVIEWS; i++) {
if (hviews[i] != 0 && hviews[i] != 0xdeadbeeb) {
MsiViewClose(hviews[i]);
r = MsiCloseHandle(hviews[i]);
if (r != ERROR_SUCCESS)
break;
@ -2531,6 +2555,7 @@ static void test_try_transform(void)
ok(r == ERROR_NO_MORE_ITEMS, "view fetch succeeded\n");
MsiCloseHandle(hrec);
MsiViewClose(hview);
MsiCloseHandle(hview);
/* check that the property was added */
@ -3239,13 +3264,11 @@ static void test_temporary_table(void)
cond = MsiDatabaseIsTablePersistent(hdb, NULL);
ok( cond == MSICONDITION_ERROR, "wrong return condition\n");
todo_wine {
cond = MsiDatabaseIsTablePersistent(hdb, "_Tables");
ok( cond == MSICONDITION_NONE, "wrong return condition\n");
cond = MsiDatabaseIsTablePersistent(hdb, "_Columns");
ok( cond == MSICONDITION_NONE, "wrong return condition\n");
}
cond = MsiDatabaseIsTablePersistent(hdb, "_Storages");
ok( cond == MSICONDITION_NONE, "wrong return condition\n");
@ -3278,10 +3301,13 @@ static void test_temporary_table(void)
r = run_query(hdb, 0, query);
ok(r == ERROR_SUCCESS, "failed to add table\n");
todo_wine {
query = "SELECT * FROM `T2`";
r = MsiDatabaseOpenView(hdb, query, &view);
ok(r == ERROR_BAD_QUERY_SYNTAX,
"Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
cond = MsiDatabaseIsTablePersistent(hdb, "T2");
ok( cond == MSICONDITION_NONE, "wrong return condition\n");
}
query = "CREATE TABLE `T3` ( `B` SHORT NOT NULL TEMPORARY, `C` CHAR(255) PRIMARY KEY `C`)";
r = run_query(hdb, 0, query);
@ -3290,14 +3316,12 @@ static void test_temporary_table(void)
cond = MsiDatabaseIsTablePersistent(hdb, "T3");
ok( cond == MSICONDITION_TRUE, "wrong return condition\n");
todo_wine {
query = "CREATE TABLE `T4` ( `B` SHORT NOT NULL, `C` CHAR(255) TEMPORARY PRIMARY KEY `C`)";
r = run_query(hdb, 0, query);
ok(r == ERROR_FUNCTION_FAILED, "failed to add table\n");
cond = MsiDatabaseIsTablePersistent(hdb, "T4");
ok( cond == MSICONDITION_NONE, "wrong return condition\n");
}
query = "CREATE TABLE `T5` ( `B` SHORT NOT NULL TEMP, `C` CHAR(255) TEMP PRIMARY KEY `C`) HOLD";
r = run_query(hdb, 0, query);
@ -3312,14 +3336,15 @@ static void test_temporary_table(void)
sz = sizeof buf;
r = MsiRecordGetString(rec, 1, buf, &sz);
ok(r == ERROR_SUCCESS, "failed to get string\n");
todo_wine ok( 0 == strcmp("G255", buf), "wrong column type\n");
ok( 0 == strcmp("G255", buf), "wrong column type\n");
sz = sizeof buf;
r = MsiRecordGetString(rec, 2, buf, &sz);
ok(r == ERROR_SUCCESS, "failed to get string\n");
todo_wine ok( 0 == strcmp("j2", buf), "wrong column type\n");
ok( 0 == strcmp("j2", buf), "wrong column type\n");
MsiCloseHandle( rec );
MsiViewClose( view );
MsiCloseHandle( view );
/* query the table data */
@ -3968,12 +3993,12 @@ static void test_special_tables(void)
query = "CREATE TABLE `_Storages` ( "
"`foo` INT NOT NULL, `bar` INT LOCALIZABLE PRIMARY KEY `foo`)";
r = run_query(hdb, 0, query);
todo_wine ok(r == ERROR_BAD_QUERY_SYNTAX, "created _Streams table\n");
ok(r == ERROR_BAD_QUERY_SYNTAX, "created _Streams table\n");
query = "CREATE TABLE `_Streams` ( "
"`foo` INT NOT NULL, `bar` INT LOCALIZABLE PRIMARY KEY `foo`)";
r = run_query(hdb, 0, query);
todo_wine ok(r == ERROR_BAD_QUERY_SYNTAX, "created _Streams table\n");
ok(r == ERROR_BAD_QUERY_SYNTAX, "created _Streams table\n");
query = "CREATE TABLE `_Tables` ( "
"`foo` INT NOT NULL, `bar` INT LOCALIZABLE PRIMARY KEY `foo`)";
@ -5254,10 +5279,7 @@ static void test_quotes(void)
query = "INSERT INTO `Table` ( `A` ) VALUES ( 'This is a ''string'' ok' )";
r = run_query(hdb, 0, query);
todo_wine
{
ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
}
query = "INSERT INTO `Table` ( `A` ) VALUES ( 'This is a '''string''' ok' )";
r = run_query(hdb, 0, query);
@ -5284,20 +5306,15 @@ static void test_quotes(void)
size = MAX_PATH;
r = MsiRecordGetString(hrec, 1, buf, &size);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
todo_wine
{
ok(!lstrcmp(buf, "This is a \"string\" ok"),
"Expected \"This is a \"string\" ok\", got %s\n", buf);
}
MsiCloseHandle(hrec);
r = MsiViewFetch(hview, &hrec);
todo_wine
{
ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
}
MsiViewClose(hview);
MsiCloseHandle(hview);
write_file("import.idt", import_dat, (sizeof(import_dat) - 1) * sizeof(char));
@ -5328,8 +5345,8 @@ static void test_quotes(void)
r = MsiViewFetch(hview, &hrec);
ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
MsiViewClose(hview);
MsiCloseHandle(hview);
MsiCloseHandle(hdb);
DeleteFileA(msifile);
}
@ -5349,11 +5366,8 @@ static void test_carriagereturn(void)
query = "CREATE TABLE `Table`\r ( `A` CHAR(72) NOT NULL PRIMARY KEY `A` )";
r = run_query(hdb, 0, query);
todo_wine
{
ok(r == ERROR_BAD_QUERY_SYNTAX,
"Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
}
query = "CREATE TABLE `Table` \r( `A` CHAR(72) NOT NULL PRIMARY KEY `A` )";
r = run_query(hdb, 0, query);
@ -5454,11 +5468,8 @@ static void test_carriagereturn(void)
query = "CREATE TABLE `Four` ( `A` CHAR(72\r) NOT NULL PRIMARY KEY `A` )";
r = run_query(hdb, 0, query);
todo_wine
{
ok(r == ERROR_BAD_QUERY_SYNTAX,
"Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
}
query = "CREATE TABLE `Four` ( `A` CHAR(\r72) NOT NULL PRIMARY KEY `A` )";
r = run_query(hdb, 0, query);
@ -5492,10 +5503,7 @@ static void test_carriagereturn(void)
size = MAX_PATH;
r = MsiRecordGetStringA(hrec, 1, buf, &size);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
todo_wine
{
ok(!lstrcmpA(buf, "\rOne"), "Expected \"\\rOne\", got \"%s\"\n", buf);
}
MsiCloseHandle(hrec);
@ -5505,10 +5513,7 @@ static void test_carriagereturn(void)
size = MAX_PATH;
r = MsiRecordGetStringA(hrec, 1, buf, &size);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
todo_wine
{
ok(!lstrcmpA(buf, "Tw\ro"), "Expected \"Tw\\ro\", got \"%s\"\n", buf);
}
MsiCloseHandle(hrec);
@ -5518,20 +5523,12 @@ static void test_carriagereturn(void)
size = MAX_PATH;
r = MsiRecordGetStringA(hrec, 1, buf, &size);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
todo_wine
{
ok(!lstrcmpA(buf, "Three\r"),
"Expected \"Three\r\", got \"%s\"\n", buf);
}
ok(!lstrcmpA(buf, "Three\r"), "Expected \"Three\r\", got \"%s\"\n", buf);
MsiCloseHandle(hrec);
r = MsiViewFetch(hview, &hrec);
todo_wine
{
ok(r == ERROR_NO_MORE_ITEMS,
"Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
}
ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
MsiViewClose(hview);
MsiCloseHandle(hview);
@ -5734,8 +5731,6 @@ static void test_noquotes(void)
MsiViewClose(hview);
MsiCloseHandle(hview);
MsiCloseHandle(hdb);
DeleteFileA(msifile);
}
@ -6104,12 +6099,9 @@ static void test_storages_table(void)
size = MAX_PATH;
lstrcpyA(buf, "apple");
r = MsiRecordReadStream(hrec, 2, buf, &size);
ok(!lstrcmp(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
todo_wine
{
ok(r == ERROR_INVALID_DATA, "Expected ERROR_INVALID_DATA, got %d\n", r);
ok(!lstrcmp(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
ok(size == 0, "Expected 0, got %d\n", size);
}
MsiCloseHandle(hrec);
@ -6930,6 +6922,600 @@ static void test_dbmerge(void)
DeleteFileA("binary.dat");
}
UINT ordervals[6][3] =
{
{ MSI_NULL_INTEGER, 12, 13 },
{ 1, 2, 3 },
{ 6, 4, 5 },
{ 8, 9, 7 },
{ 10, 11, MSI_NULL_INTEGER },
{ 14, MSI_NULL_INTEGER, 15 }
};
static void test_insertorder(void)
{
MSIHANDLE hdb, view, rec;
LPCSTR query;
UINT r;
int i;
hdb = create_db();
ok(hdb, "failed to create db\n");
query = "CREATE TABLE `T` ( `A` SHORT, `B` SHORT, `C` SHORT PRIMARY KEY `A`)";
r = run_query(hdb, 0, query);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
query = "INSERT INTO `T` ( `A`, `B`, `C` ) VALUES ( 1, 2, 3 )";
r = run_query(hdb, 0, query);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
query = "INSERT INTO `T` ( `B`, `C`, `A` ) VALUES ( 4, 5, 6 )";
r = run_query(hdb, 0, query);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
query = "INSERT INTO `T` ( `C`, `A`, `B` ) VALUES ( 7, 8, 9 )";
r = run_query(hdb, 0, query);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
query = "INSERT INTO `T` ( `A`, `B` ) VALUES ( 10, 11 )";
r = run_query(hdb, 0, query);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
query = "INSERT INTO `T` ( `B`, `C` ) VALUES ( 12, 13 )";
r = run_query(hdb, 0, query);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
/* fails because the primary key already
* has an MSI_NULL_INTEGER value set above
*/
query = "INSERT INTO `T` ( `C` ) VALUES ( 14 )";
r = run_query(hdb, 0, query);
ok(r == ERROR_FUNCTION_FAILED,
"Expected ERROR_FUNCTION_FAILED, got %d\n", r);
/* replicate the error where primary key is set twice */
query = "INSERT INTO `T` ( `A`, `C` ) VALUES ( 1, 14 )";
r = run_query(hdb, 0, query);
ok(r == ERROR_FUNCTION_FAILED,
"Expected ERROR_FUNCTION_FAILED, got %d\n", r);
query = "INSERT INTO `T` ( `A`, `C` ) VALUES ( 14, 15 )";
r = run_query(hdb, 0, query);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
query = "INSERT INTO `T` VALUES ( 16 )";
r = run_query(hdb, 0, query);
ok(r == ERROR_BAD_QUERY_SYNTAX,
"Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
query = "INSERT INTO `T` VALUES ( 17, 18 )";
r = run_query(hdb, 0, query);
ok(r == ERROR_BAD_QUERY_SYNTAX,
"Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
query = "INSERT INTO `T` VALUES ( 19, 20, 21 )";
r = run_query(hdb, 0, query);
ok(r == ERROR_BAD_QUERY_SYNTAX,
"Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
query = "SELECT * FROM `T`";
r = MsiDatabaseOpenView(hdb, query, &view);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
r = MsiViewExecute(view, 0);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
for (i = 0; i < 6; i++)
{
r = MsiViewFetch(view, &rec);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
r = MsiRecordGetInteger(rec, 1);
ok(r == ordervals[i][0], "Expected %d, got %d\n", ordervals[i][0], r);
r = MsiRecordGetInteger(rec, 2);
ok(r == ordervals[i][1], "Expected %d, got %d\n", ordervals[i][1], r);
r = MsiRecordGetInteger(rec, 3);
ok(r == ordervals[i][2], "Expected %d, got %d\n", ordervals[i][2], r);
MsiCloseHandle(rec);
}
r = MsiViewFetch(view, &rec);
ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
MsiViewClose(view);
MsiCloseHandle(view);
MsiCloseHandle(hdb);
DeleteFileA(msifile);
}
static void test_columnorder(void)
{
MSIHANDLE hdb, view, rec;
char buf[MAX_PATH];
LPCSTR query;
DWORD sz;
UINT r;
hdb = create_db();
ok(hdb, "failed to create db\n");
/* Each column is a slot:
* ---------------------
* | B | C | A | E | D |
* ---------------------
*
* When a column is selected as a primary key,
* the column occupying the nth primary key slot is swapped
* with the current position of the primary key in question:
*
* set primary key `D`
* --------------------- ---------------------
* | B | C | A | E | D | -> | D | C | A | E | B |
* --------------------- ---------------------
*
* set primary key `E`
* --------------------- ---------------------
* | D | C | A | E | B | -> | D | E | A | C | B |
* --------------------- ---------------------
*/
query = "CREATE TABLE `T` ( `B` SHORT NOT NULL, `C` SHORT NOT NULL, "
"`A` CHAR(255), `E` INT, `D` CHAR(255) NOT NULL "
"PRIMARY KEY `D`, `E`)";
r = run_query(hdb, 0, query);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
query = "SELECT * FROM `T`";
r = MsiDatabaseOpenView(hdb, query, &view);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
r = MsiViewGetColumnInfo(view, MSICOLINFO_TYPES, &rec);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
sz = MAX_PATH;
lstrcpyA(buf, "kiwi");
r = MsiRecordGetString(rec, 1, buf, &sz);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!lstrcmpA("s255", buf), "Expected \"s255\", got \"%s\"\n", buf);
sz = MAX_PATH;
lstrcpyA(buf, "kiwi");
r = MsiRecordGetString(rec, 2, buf, &sz);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!lstrcmpA("I2", buf), "Expected \"I2\", got \"%s\"\n", buf);
sz = MAX_PATH;
lstrcpyA(buf, "kiwi");
r = MsiRecordGetString(rec, 3, buf, &sz);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!lstrcmpA("S255", buf), "Expected \"S255\", got \"%s\"\n", buf);
sz = MAX_PATH;
lstrcpyA(buf, "kiwi");
r = MsiRecordGetString(rec, 4, buf, &sz);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!lstrcmpA("i2", buf), "Expected \"i2\", got \"%s\"\n", buf);
sz = MAX_PATH;
lstrcpyA(buf, "kiwi");
r = MsiRecordGetString(rec, 5, buf, &sz);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!lstrcmpA("i2", buf), "Expected \"i2\", got \"%s\"\n", buf);
MsiCloseHandle(rec);
r = MsiViewGetColumnInfo(view, MSICOLINFO_NAMES, &rec);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
sz = MAX_PATH;
lstrcpyA(buf, "kiwi");
r = MsiRecordGetString(rec, 1, buf, &sz);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!lstrcmpA("D", buf), "Expected \"D\", got \"%s\"\n", buf);
sz = MAX_PATH;
lstrcpyA(buf, "kiwi");
r = MsiRecordGetString(rec, 2, buf, &sz);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!lstrcmpA("E", buf), "Expected \"E\", got \"%s\"\n", buf);
sz = MAX_PATH;
lstrcpyA(buf, "kiwi");
r = MsiRecordGetString(rec, 3, buf, &sz);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!lstrcmpA("A", buf), "Expected \"A\", got \"%s\"\n", buf);
sz = MAX_PATH;
lstrcpyA(buf, "kiwi");
r = MsiRecordGetString(rec, 4, buf, &sz);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!lstrcmpA("C", buf), "Expected \"C\", got \"%s\"\n", buf);
sz = MAX_PATH;
lstrcpyA(buf, "kiwi");
r = MsiRecordGetString(rec, 5, buf, &sz);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!lstrcmpA("B", buf), "Expected \"B\", got \"%s\"\n", buf);
MsiCloseHandle(rec);
MsiViewClose(view);
MsiCloseHandle(view);
query = "INSERT INTO `T` ( `B`, `C`, `A`, `E`, `D` ) "
"VALUES ( 1, 2, 'a', 3, 'bc' )";
r = run_query(hdb, 0, query);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
query = "SELECT * FROM `T`";
r = do_query(hdb, query, &rec);
sz = MAX_PATH;
lstrcpyA(buf, "kiwi");
r = MsiRecordGetString(rec, 1, buf, &sz);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!lstrcmpA("bc", buf), "Expected \"bc\", got \"%s\"\n", buf);
r = MsiRecordGetInteger(rec, 2);
ok(r == 3, "Expected 3, got %d\n", r);
sz = MAX_PATH;
lstrcpyA(buf, "kiwi");
r = MsiRecordGetString(rec, 3, buf, &sz);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!lstrcmpA("a", buf), "Expected \"a\", got \"%s\"\n", buf);
r = MsiRecordGetInteger(rec, 4);
ok(r == 2, "Expected 2, got %d\n", r);
r = MsiRecordGetInteger(rec, 5);
ok(r == 1, "Expected 1, got %d\n", r);
MsiCloseHandle(rec);
query = "SELECT * FROM `_Columns` WHERE `Table` = 'T'";
r = MsiDatabaseOpenView(hdb, query, &view);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
r = MsiViewExecute(view, 0);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
r = MsiViewFetch(view, &rec);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
sz = MAX_PATH;
lstrcpyA(buf, "kiwi");
r = MsiRecordGetString(rec, 1, buf, &sz);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!lstrcmpA("T", buf), "Expected \"T\", got \"%s\"\n", buf);
r = MsiRecordGetInteger(rec, 2);
ok(r == 1, "Expected 1, got %d\n", r);
sz = MAX_PATH;
lstrcpyA(buf, "kiwi");
r = MsiRecordGetString(rec, 3, buf, &sz);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!lstrcmpA("D", buf), "Expected \"D\", got \"%s\"\n", buf);
MsiCloseHandle(rec);
r = MsiViewFetch(view, &rec);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
sz = MAX_PATH;
lstrcpyA(buf, "kiwi");
r = MsiRecordGetString(rec, 1, buf, &sz);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!lstrcmpA("T", buf), "Expected \"T\", got \"%s\"\n", buf);
r = MsiRecordGetInteger(rec, 2);
ok(r == 2, "Expected 2, got %d\n", r);
sz = MAX_PATH;
lstrcpyA(buf, "kiwi");
r = MsiRecordGetString(rec, 3, buf, &sz);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!lstrcmpA("E", buf), "Expected \"E\", got \"%s\"\n", buf);
MsiCloseHandle(rec);
r = MsiViewFetch(view, &rec);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
sz = MAX_PATH;
lstrcpyA(buf, "kiwi");
r = MsiRecordGetString(rec, 1, buf, &sz);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!lstrcmpA("T", buf), "Expected \"T\", got \"%s\"\n", buf);
r = MsiRecordGetInteger(rec, 2);
ok(r == 3, "Expected 3, got %d\n", r);
sz = MAX_PATH;
lstrcpyA(buf, "kiwi");
r = MsiRecordGetString(rec, 3, buf, &sz);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!lstrcmpA("A", buf), "Expected \"A\", got \"%s\"\n", buf);
MsiCloseHandle(rec);
r = MsiViewFetch(view, &rec);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
sz = MAX_PATH;
lstrcpyA(buf, "kiwi");
r = MsiRecordGetString(rec, 1, buf, &sz);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!lstrcmpA("T", buf), "Expected \"T\", got \"%s\"\n", buf);
r = MsiRecordGetInteger(rec, 2);
ok(r == 4, "Expected 4, got %d\n", r);
sz = MAX_PATH;
lstrcpyA(buf, "kiwi");
r = MsiRecordGetString(rec, 3, buf, &sz);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!lstrcmpA("C", buf), "Expected \"C\", got \"%s\"\n", buf);
MsiCloseHandle(rec);
r = MsiViewFetch(view, &rec);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
sz = MAX_PATH;
lstrcpyA(buf, "kiwi");
r = MsiRecordGetString(rec, 1, buf, &sz);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!lstrcmpA("T", buf), "Expected \"T\", got \"%s\"\n", buf);
r = MsiRecordGetInteger(rec, 2);
ok(r == 5, "Expected 5, got %d\n", r);
sz = MAX_PATH;
lstrcpyA(buf, "kiwi");
r = MsiRecordGetString(rec, 3, buf, &sz);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!lstrcmpA("B", buf), "Expected \"B\", got \"%s\"\n", buf);
MsiCloseHandle(rec);
r = MsiViewFetch(view, &rec);
ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
MsiViewClose(view);
MsiCloseHandle(view);
query = "CREATE TABLE `Z` ( `B` SHORT NOT NULL, `C` SHORT NOT NULL, "
"`A` CHAR(255), `E` INT, `D` CHAR(255) NOT NULL "
"PRIMARY KEY `C`, `A`, `D`)";
r = run_query(hdb, 0, query);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
query = "SELECT * FROM `Z`";
r = MsiDatabaseOpenView(hdb, query, &view);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
r = MsiViewGetColumnInfo(view, MSICOLINFO_TYPES, &rec);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
sz = MAX_PATH;
lstrcpyA(buf, "kiwi");
r = MsiRecordGetString(rec, 1, buf, &sz);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!lstrcmpA("i2", buf), "Expected \"i2\", got \"%s\"\n", buf);
sz = MAX_PATH;
lstrcpyA(buf, "kiwi");
r = MsiRecordGetString(rec, 2, buf, &sz);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!lstrcmpA("S255", buf), "Expected \"S255\", got \"%s\"\n", buf);
sz = MAX_PATH;
lstrcpyA(buf, "kiwi");
r = MsiRecordGetString(rec, 3, buf, &sz);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!lstrcmpA("s255", buf), "Expected \"s255\", got \"%s\"\n", buf);
sz = MAX_PATH;
lstrcpyA(buf, "kiwi");
r = MsiRecordGetString(rec, 4, buf, &sz);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!lstrcmpA("I2", buf), "Expected \"I2\", got \"%s\"\n", buf);
sz = MAX_PATH;
lstrcpyA(buf, "kiwi");
r = MsiRecordGetString(rec, 5, buf, &sz);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!lstrcmpA("i2", buf), "Expected \"i2\", got \"%s\"\n", buf);
MsiCloseHandle(rec);
r = MsiViewGetColumnInfo(view, MSICOLINFO_NAMES, &rec);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
sz = MAX_PATH;
lstrcpyA(buf, "kiwi");
r = MsiRecordGetString(rec, 1, buf, &sz);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!lstrcmpA("C", buf), "Expected \"C\", got \"%s\"\n", buf);
sz = MAX_PATH;
lstrcpyA(buf, "kiwi");
r = MsiRecordGetString(rec, 2, buf, &sz);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!lstrcmpA("A", buf), "Expected \"A\", got \"%s\"\n", buf);
sz = MAX_PATH;
lstrcpyA(buf, "kiwi");
r = MsiRecordGetString(rec, 3, buf, &sz);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!lstrcmpA("D", buf), "Expected \"D\", got \"%s\"\n", buf);
sz = MAX_PATH;
lstrcpyA(buf, "kiwi");
r = MsiRecordGetString(rec, 4, buf, &sz);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!lstrcmpA("E", buf), "Expected \"E\", got \"%s\"\n", buf);
sz = MAX_PATH;
lstrcpyA(buf, "kiwi");
r = MsiRecordGetString(rec, 5, buf, &sz);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!lstrcmpA("B", buf), "Expected \"B\", got \"%s\"\n", buf);
MsiCloseHandle(rec);
MsiViewClose(view);
MsiCloseHandle(view);
query = "INSERT INTO `Z` ( `B`, `C`, `A`, `E`, `D` ) "
"VALUES ( 1, 2, 'a', 3, 'bc' )";
r = run_query(hdb, 0, query);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
query = "SELECT * FROM `Z`";
r = do_query(hdb, query, &rec);
r = MsiRecordGetInteger(rec, 1);
ok(r == 2, "Expected 2, got %d\n", r);
sz = MAX_PATH;
lstrcpyA(buf, "kiwi");
r = MsiRecordGetString(rec, 2, buf, &sz);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!lstrcmpA("a", buf), "Expected \"a\", got \"%s\"\n", buf);
sz = MAX_PATH;
lstrcpyA(buf, "kiwi");
r = MsiRecordGetString(rec, 3, buf, &sz);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!lstrcmpA("bc", buf), "Expected \"bc\", got \"%s\"\n", buf);
r = MsiRecordGetInteger(rec, 4);
ok(r == 3, "Expected 3, got %d\n", r);
r = MsiRecordGetInteger(rec, 5);
ok(r == 1, "Expected 1, got %d\n", r);
MsiCloseHandle(rec);
query = "SELECT * FROM `_Columns` WHERE `Table` = 'T'";
r = MsiDatabaseOpenView(hdb, query, &view);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
r = MsiViewExecute(view, 0);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
r = MsiViewFetch(view, &rec);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
sz = MAX_PATH;
lstrcpyA(buf, "kiwi");
r = MsiRecordGetString(rec, 1, buf, &sz);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!lstrcmpA("T", buf), "Expected \"T\", got \"%s\"\n", buf);
r = MsiRecordGetInteger(rec, 2);
ok(r == 1, "Expected 1, got %d\n", r);
sz = MAX_PATH;
lstrcpyA(buf, "kiwi");
r = MsiRecordGetString(rec, 3, buf, &sz);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!lstrcmpA("D", buf), "Expected \"D\", got \"%s\"\n", buf);
MsiCloseHandle(rec);
r = MsiViewFetch(view, &rec);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
sz = MAX_PATH;
lstrcpyA(buf, "kiwi");
r = MsiRecordGetString(rec, 1, buf, &sz);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!lstrcmpA("T", buf), "Expected \"T\", got \"%s\"\n", buf);
r = MsiRecordGetInteger(rec, 2);
ok(r == 2, "Expected 2, got %d\n", r);
sz = MAX_PATH;
lstrcpyA(buf, "kiwi");
r = MsiRecordGetString(rec, 3, buf, &sz);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!lstrcmpA("E", buf), "Expected \"E\", got \"%s\"\n", buf);
MsiCloseHandle(rec);
r = MsiViewFetch(view, &rec);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
sz = MAX_PATH;
lstrcpyA(buf, "kiwi");
r = MsiRecordGetString(rec, 1, buf, &sz);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!lstrcmpA("T", buf), "Expected \"T\", got \"%s\"\n", buf);
r = MsiRecordGetInteger(rec, 2);
ok(r == 3, "Expected 3, got %d\n", r);
sz = MAX_PATH;
lstrcpyA(buf, "kiwi");
r = MsiRecordGetString(rec, 3, buf, &sz);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!lstrcmpA("A", buf), "Expected \"A\", got \"%s\"\n", buf);
MsiCloseHandle(rec);
r = MsiViewFetch(view, &rec);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
sz = MAX_PATH;
lstrcpyA(buf, "kiwi");
r = MsiRecordGetString(rec, 1, buf, &sz);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!lstrcmpA("T", buf), "Expected \"T\", got \"%s\"\n", buf);
r = MsiRecordGetInteger(rec, 2);
ok(r == 4, "Expected 4, got %d\n", r);
sz = MAX_PATH;
lstrcpyA(buf, "kiwi");
r = MsiRecordGetString(rec, 3, buf, &sz);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!lstrcmpA("C", buf), "Expected \"C\", got \"%s\"\n", buf);
MsiCloseHandle(rec);
r = MsiViewFetch(view, &rec);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
sz = MAX_PATH;
lstrcpyA(buf, "kiwi");
r = MsiRecordGetString(rec, 1, buf, &sz);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!lstrcmpA("T", buf), "Expected \"T\", got \"%s\"\n", buf);
r = MsiRecordGetInteger(rec, 2);
ok(r == 5, "Expected 5, got %d\n", r);
sz = MAX_PATH;
lstrcpyA(buf, "kiwi");
r = MsiRecordGetString(rec, 3, buf, &sz);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!lstrcmpA("B", buf), "Expected \"B\", got \"%s\"\n", buf);
MsiCloseHandle(rec);
r = MsiViewFetch(view, &rec);
ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
MsiViewClose(view);
MsiCloseHandle(view);
MsiCloseHandle(hdb);
DeleteFileA(msifile);
}
START_TEST(db)
{
test_msidatabase();
@ -6971,4 +7557,6 @@ START_TEST(db)
test_dbtopackage();
test_droptable();
test_dbmerge();
test_insertorder();
test_columnorder();
}

View file

@ -2361,12 +2361,14 @@ static void test_formatrecord_tables(void)
/* component with INSTALLSTATE_SOURCE */
lstrcpy( expected, "1: " );
lstrcat( expected, curr_dir );
if (strlen(curr_dir) > 3)
lstrcat( expected, "\\" );
lstrcat( expected, " " );
size = MAX_PATH;
MsiRecordSetString( hrec, 1, "[$parietal]" );
r = MsiFormatRecord( hpkg, hrec, buf, &size );
ok( r == ERROR_SUCCESS, "format record failed: %d\n", r);
ok( !lstrcmp( buf, expected ), "Expected '%s', got %s\n", expected, buf);
ok( !lstrcmp( buf, expected ), "Expected '%s', got '%s'\n", expected, buf);
sprintf( buf, "%sI am a really long directory\\temporal.txt", root );
DeleteFile( buf );

View file

@ -1721,6 +1721,21 @@ static void test_MsiInstallProduct(void)
return;
}
/* szPackagePath is NULL */
r = MsiInstallProductA(NULL, "INSTALL=ALL");
ok(r == ERROR_INVALID_PARAMETER,
"Expected ERROR_INVALID_PARAMETER, got %d\n", r);
/* both szPackagePath and szCommandLine are NULL */
r = MsiInstallProductA(NULL, NULL);
ok(r == ERROR_INVALID_PARAMETER,
"Expected ERROR_INVALID_PARAMETER, got %d\n", r);
/* szPackagePath is empty */
r = MsiInstallProductA("", "INSTALL=ALL");
ok(r == ERROR_PATH_NOT_FOUND,
"Expected ERROR_PATH_NOT_FOUND, got %d\n", r);
create_test_files();
create_database(msifile, tables, sizeof(tables) / sizeof(msi_table));
@ -1764,7 +1779,7 @@ static void test_MsiInstallProduct(void)
type = REG_SZ;
res = RegQueryValueExA(hkey, "OrderTestName", NULL, &type, (LPBYTE)path, &size);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
ok(!lstrcmpA(path, "OrderTestValue"), "Expected imaname, got %s\n", path);
ok(!lstrcmpA(path, "OrderTestValue"), "Expected OrderTestValue, got %s\n", path);
check_service_is_installed();
@ -2280,6 +2295,7 @@ static void test_setpropertyfolder(void)
{
UINT r;
CHAR path[MAX_PATH];
DWORD attr;
lstrcpyA(path, PROG_FILES_DIR);
lstrcatA(path, "\\msitest\\added");
@ -2293,7 +2309,8 @@ static void test_setpropertyfolder(void)
r = MsiInstallProductA(msifile, NULL);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
if (GetFileAttributesA(path) == FILE_ATTRIBUTE_DIRECTORY)
attr = GetFileAttributesA(path);
if (attr != INVALID_FILE_ATTRIBUTES && (attr & FILE_ATTRIBUTE_DIRECTORY))
{
ok(delete_pf("msitest\\added\\maximus", TRUE), "File not installed\n");
ok(delete_pf("msitest\\added", FALSE), "File not installed\n");
@ -3213,7 +3230,7 @@ static void test_publish_processcomponents(void)
lstrcpyA(program_files_maximus,PROG_FILES_DIR);
lstrcatA(program_files_maximus,"\\msitest\\maximus");
ok(!lstrcmpA(val, program_files_maximus),
ok(!lstrcmpiA(val, program_files_maximus),
"Expected \"%s\", got \"%s\"\n", program_files_maximus, val);
res = RegOpenKeyA(HKEY_LOCAL_MACHINE, compkey, &hkey);
@ -3257,7 +3274,7 @@ static void test_publish_processcomponents(void)
res = RegQueryValueExA(comp, "84A88FD7F6998CE40A22FB59F6B9C2BB",
NULL, NULL, (LPBYTE)val, &size);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
ok(!lstrcmpA(val, program_files_maximus),
ok(!lstrcmpiA(val, program_files_maximus),
"Expected \"%s\", got \"%s\"\n", program_files_maximus, val);
res = RegOpenKeyA(HKEY_LOCAL_MACHINE, compkey, &hkey);
@ -4193,8 +4210,8 @@ static void test_transformprop(void)
static void test_currentworkingdir(void)
{
UINT r;
CHAR path[MAX_PATH];
LPSTR ptr, ptr2;
CHAR drive[MAX_PATH], path[MAX_PATH];
LPSTR ptr;
CreateDirectoryA("msitest", NULL);
create_file("msitest\\augustus", 500);
@ -4221,18 +4238,17 @@ static void test_currentworkingdir(void)
ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
ok(delete_pf("msitest", FALSE), "File not installed\n");
lstrcpyA(path, CURR_DIR);
lstrcpyA(drive, CURR_DIR);
drive[2] = '\\';
drive[3] = '\0';
SetCurrentDirectoryA(drive);
lstrcpy(path, CURR_DIR);
if (path[lstrlenA(path) - 1] != '\\')
lstrcatA(path, "\\");
lstrcatA(path, "msitest.msi");
ptr2 = strrchr(path, '\\');
*ptr2 = '\0';
ptr = strrchr(path, '\\');
*ptr2 = '\\';
*(ptr++) = '\0';
SetCurrentDirectoryA(path);
lstrcatA(path, msifile);
ptr = strchr(path, ':');
ptr +=2;
r = MsiInstallProductA(ptr, NULL);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
@ -4628,10 +4644,15 @@ static void test_missingcab(void)
create_pf_data("msitest\\caesar", "abcdefgh", TRUE);
r = MsiInstallProductA(msifile, NULL);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
ok(r == ERROR_SUCCESS ||
broken(r == ERROR_INSTALL_FAILURE), /* win9x */
"Expected ERROR_SUCCESS, got %u\n", r);
if (r == ERROR_SUCCESS)
{
ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
ok(delete_pf("msitest\\caesar", TRUE), "File not installed\n");
ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
}
ok(delete_pf("msitest\\caesar", TRUE), "File not installed\n");
ok(!delete_pf("msitest\\gaius", TRUE), "File installed\n");
ok(delete_pf("msitest", FALSE), "File not installed\n");

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -24,6 +24,8 @@
#include "wine/test.h"
static const char *msifile = "winetest.msi";
static BOOL create_temp_file(char *name)
{
UINT r;
@ -120,15 +122,45 @@ static void test_msirecord(void)
r = MsiRecordGetInteger(h, 0);
ok(r == 1, "failed to get integer\n");
/* same record, but add a string to it */
/* same record, but add a null or empty string to it */
r = MsiRecordSetString(h, 0, NULL);
ok(r == ERROR_SUCCESS, "Failed to set null string at 0\n");
r = MsiRecordIsNull(h, 0);
ok(r == TRUE, "null string not null field\n");
r = MsiRecordDataSize(h, 0);
ok(r == 0, "size of string record is strlen\n");
buf[0] = 0;
sz = sizeof buf;
r = MsiRecordGetStringA(h, 0, buf, &sz);
ok(r == ERROR_SUCCESS, "Failed to get string at 0\n");
ok(buf[0] == 0, "MsiRecordGetStringA returned the wrong string\n");
ok(sz == 0, "MsiRecordGetStringA returned the wrong length\n");
bufW[0] = 0;
sz = sizeof bufW / sizeof bufW[0];
r = MsiRecordGetStringW(h, 0, bufW, &sz);
ok(r == ERROR_SUCCESS, "Failed to get string at 0\n");
ok(bufW[0] == 0, "MsiRecordGetStringW returned the wrong string\n");
ok(sz == 0, "MsiRecordGetStringW returned the wrong length\n");
r = MsiRecordSetString(h, 0, "");
ok(r == ERROR_SUCCESS, "Failed to set empty string at 0\n");
r = MsiRecordIsNull(h, 0);
ok(r == TRUE, "null string not null field\n");
r = MsiRecordDataSize(h, 0);
ok(r == 0, "size of string record is strlen\n");
buf[0] = 0;
sz = sizeof buf;
r = MsiRecordGetStringA(h, 0, buf, &sz);
ok(r == ERROR_SUCCESS, "Failed to get string at 0\n");
ok(buf[0] == 0, "MsiRecordGetStringA returned the wrong string\n");
ok(sz == 0, "MsiRecordGetStringA returned the wrong length\n");
bufW[0] = 0;
sz = sizeof bufW / sizeof bufW[0];
r = MsiRecordGetStringW(h, 0, bufW, &sz);
ok(r == ERROR_SUCCESS, "Failed to get string at 0\n");
ok(bufW[0] == 0, "MsiRecordGetStringW returned the wrong string\n");
ok(sz == 0, "MsiRecordGetStringW returned the wrong length\n");
/* same record, but add a string to it */
r = MsiRecordSetString(h,0,str);
ok(r == ERROR_SUCCESS, "Failed to set string at 0\n");
r = MsiRecordGetInteger(h, 0);
@ -443,9 +475,143 @@ static void test_MsiRecordGetInteger(void)
MsiCloseHandle(rec);
}
static void test_fieldzero(void)
{
MSIHANDLE hdb, hview, rec;
CHAR buf[MAX_PATH];
LPCSTR query;
DWORD sz;
UINT r;
rec = MsiCreateRecord(1);
ok(rec != 0, "Expected a valid handle\n");
r = MsiRecordGetInteger(rec, 0);
ok(r == MSI_NULL_INTEGER, "Expected MSI_NULL_INTEGER, got %d\n", r);
sz = MAX_PATH;
lstrcpyA(buf, "apple");
r = MsiRecordGetString(rec, 0, buf, &sz);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
ok(sz == 0, "Expectd 0, got %d\n", sz);
r = MsiRecordIsNull(rec, 0);
ok(r == TRUE, "Expected TRUE, got %d\n", r);
r = MsiRecordGetInteger(rec, 1);
ok(r == MSI_NULL_INTEGER, "Expected MSI_NULL_INTEGER, got %d\n", r);
r = MsiRecordSetInteger(rec, 1, 42);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
r = MsiRecordGetInteger(rec, 0);
ok(r == MSI_NULL_INTEGER, "Expected MSI_NULL_INTEGER, got %d\n", r);
sz = MAX_PATH;
lstrcpyA(buf, "apple");
r = MsiRecordGetString(rec, 0, buf, &sz);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
ok(sz == 0, "Expectd 0, got %d\n", sz);
r = MsiRecordIsNull(rec, 0);
ok(r == TRUE, "Expected TRUE, got %d\n", r);
r = MsiRecordGetInteger(rec, 1);
ok(r == 42, "Expected 42, got %d\n", r);
r = MsiRecordSetString(rec, 1, "bologna");
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
r = MsiRecordGetInteger(rec, 0);
ok(r == MSI_NULL_INTEGER, "Expected MSI_NULL_INTEGER, got %d\n", r);
sz = MAX_PATH;
lstrcpyA(buf, "apple");
r = MsiRecordGetString(rec, 0, buf, &sz);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
ok(sz == 0, "Expectd 0, got %d\n", sz);
r = MsiRecordIsNull(rec, 0);
ok(r == TRUE, "Expected TRUE, got %d\n", r);
sz = MAX_PATH;
lstrcpyA(buf, "apple");
r = MsiRecordGetString(rec, 1, buf, &sz);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!lstrcmpA(buf, "bologna"), "Expected \"bologna\", got \"%s\"\n", buf);
ok(sz == 7, "Expectd 7, got %d\n", sz);
MsiCloseHandle(rec);
r = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb);
ok(r == ERROR_SUCCESS, "MsiOpenDatabase failed\n");
query = "CREATE TABLE `drone` ( "
"`id` INT, `name` CHAR(32), `number` CHAR(32) "
"PRIMARY KEY `id`)";
r = MsiDatabaseOpenView(hdb, query, &hview);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
r = MsiViewExecute(hview, 0);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
r = MsiViewClose(hview);
ok(r == ERROR_SUCCESS, "MsiViewClose failed\n");
r = MsiCloseHandle(hview);
ok(r == ERROR_SUCCESS, "MsiCloseHandle failed\n");
query = "INSERT INTO `drone` ( `id`, `name`, `number` )"
"VALUES('1', 'Abe', '8675309')";
r = MsiDatabaseOpenView(hdb, query, &hview);
ok(r == ERROR_SUCCESS, "MsiDatabaseOpenView failed\n");
r = MsiViewExecute(hview, 0);
ok(r == ERROR_SUCCESS, "MsiViewExecute failed\n");
r = MsiViewClose(hview);
ok(r == ERROR_SUCCESS, "MsiViewClose failed\n");
r = MsiCloseHandle(hview);
ok(r == ERROR_SUCCESS, "MsiCloseHandle failed\n");
r = MsiDatabaseGetPrimaryKeysA(hdb, "drone", &rec);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
r = MsiRecordGetInteger(rec, 0);
ok(r == MSI_NULL_INTEGER, "Expected MSI_NULL_INTEGER, got %d\n", r);
sz = MAX_PATH;
lstrcpyA(buf, "apple");
r = MsiRecordGetString(rec, 0, buf, &sz);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!lstrcmpA(buf, "drone"), "Expected \"drone\", got \"%s\"\n", buf);
ok(sz == 5, "Expectd 5, got %d\n", sz);
r = MsiRecordIsNull(rec, 0);
ok(r == FALSE, "Expected FALSE, got %d\n", r);
MsiCloseHandle(rec);
query = "SELECT * FROM `drone` WHERE `id` = 1";
r = MsiDatabaseOpenView(hdb, query, &hview);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
r = MsiViewExecute(hview, 0);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
r = MsiViewFetch(hview, &rec);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
r = MsiRecordGetInteger(rec, 0);
ok(r != MSI_NULL_INTEGER && r != 0, "Expected non-NULL value, got %d\n", r);
r = MsiRecordIsNull(rec, 0);
ok(r == FALSE, "Expected FALSE, got %d\n", r);
MsiCloseHandle(hdb);
DeleteFileA(msifile);
}
START_TEST(record)
{
test_msirecord();
test_MsiRecordGetString();
test_MsiRecordGetInteger();
test_fieldzero();
}

View file

@ -27,10 +27,12 @@
#include <msidefs.h>
#include <msi.h>
#include <sddl.h>
#include <secext.h>
#include "wine/test.h"
static BOOL (WINAPI *pConvertSidToStringSidA)(PSID, LPSTR*);
static BOOLEAN (WINAPI *pGetUserNameExA)(EXTENDED_NAME_FORMAT, LPSTR, PULONG);
static UINT (WINAPI *pMsiSourceListAddMediaDiskA)
(LPCSTR, LPCSTR, MSIINSTALLCONTEXT, DWORD, DWORD, LPCSTR, LPCSTR);
static UINT (WINAPI *pMsiSourceListAddSourceExA)
@ -51,6 +53,7 @@ static void init_functionpointers(void)
{
HMODULE hmsi = GetModuleHandleA("msi.dll");
HMODULE hadvapi32 = GetModuleHandleA("advapi32.dll");
HMODULE hsecur32 = LoadLibraryA("secur32.dll");
#define GET_PROC(dll, func) \
p ## func = (void *)GetProcAddress(dll, #func); \
@ -67,6 +70,8 @@ static void init_functionpointers(void)
GET_PROC(hadvapi32, ConvertSidToStringSidA)
GET_PROC(hsecur32, GetUserNameExA)
#undef GET_PROC
}
@ -3139,11 +3144,17 @@ static void test_MsiSourceListAddSource(void)
/* MACHINENAME\username */
size = MAX_PATH;
if (pGetUserNameExA != NULL)
pGetUserNameExA(NameSamCompatible, username, &size);
else
{
GetComputerNameA(username, &size);
lstrcatA(username, "\\");
ptr = username + lstrlenA(username);
size = MAX_PATH;
size = MAX_PATH - (ptr - username);
GetUserNameA(ptr, &size);
}
trace("username: %s\n", username);
/* GetLastError is not set by the function */

View file

@ -67,13 +67,51 @@ static void test_initterm(void)
initterm_test(&callbacks[0], &callbacks[3], 2);
}
static void test_initvar( HMODULE hmsvcrt )
{
OSVERSIONINFO osvi = { sizeof(OSVERSIONINFO) };
int* (*pp_winver)() = (int*(*)())GetProcAddress(hmsvcrt, "__p__winver");
int* (*pp_winmajor)() = (int*(*)())GetProcAddress(hmsvcrt, "__p__winmajor");
int* (*pp_winminor)() = (int*(*)())GetProcAddress(hmsvcrt, "__p__winminor");
int* (*pp_osver)() = (int*(*)())GetProcAddress(hmsvcrt, "__p__osver");
int winver, winmajor, winminor, osver;
if( !( pp_winmajor && pp_winminor && pp_winver)) {
win_skip("_winver variables are not available\n");
return;
}
winver = *pp_winver();
winminor = *pp_winminor();
winmajor = *pp_winmajor();
GetVersionEx( &osvi);
ok( winminor == osvi.dwMinorVersion, "Wrong value for _winminor %02x expected %02x\n",
winminor, osvi.dwMinorVersion);
ok( winmajor == osvi.dwMajorVersion, "Wrong value for _winmajor %02x expected %02x\n",
winmajor, osvi.dwMajorVersion);
ok( winver == ((osvi.dwMajorVersion << 8) | osvi.dwMinorVersion),
"Wrong value for _winver %02x expected %02x\n",
winver, ((osvi.dwMajorVersion << 8) | osvi.dwMinorVersion));
if( !pp_osver) {
win_skip("_osver variables are not available\n");
return;
}
osver = *pp_osver();
ok( osver == (osvi.dwBuildNumber & 0xffff) ||
((osvi.dwBuildNumber >> 24) == osvi.dwMajorVersion &&
((osvi.dwBuildNumber >> 16) & 0xff) == osvi.dwMinorVersion), /* 95/98/ME */
"Wrong value for _osver %04x expected %04x\n",
osver, osvi.dwBuildNumber);
}
START_TEST(data)
{
HMODULE hmsvcrt;
hmsvcrt = GetModuleHandleA("msvcrt.dll");
if (!hmsvcrt)
hmsvcrt = GetModuleHandleA("msvcrtd.dll");
if (hmsvcrt)
p_initterm=(void*)GetProcAddress(hmsvcrt, "_initterm");
test_initterm();
test_initvar(hmsvcrt);
}

View file

@ -698,6 +698,90 @@ static void test_fcvt(void)
ok( 0 == sign, "sign wrong\n");
}
static struct {
double value;
int nrdigits;
const char *expstr_e;
const char *expstr_f;
int expdecpt_e;
int expdecpt_f;
int expsign;
} test_cvt_testcases[] = {
{ 45.0, 2, "45", "4500", 2, 2, 0 },
/* Numbers less than 1.0 with different precisions */
{ 0.0001, 1, "1", "", -3, -3, 0 },
{ 0.0001, -10, "", "", -3, -3, 0 },
{ 0.0001, 10,"1000000000", "1000000", -3, -3, 0 },
/* Basic sign test */
{ -111.0001, 5, "11100", "11100010", 3, 3, 1 },
{ 111.0001, 5, "11100", "11100010", 3, 3, 0 },
/* big numbers with low precision */
{ 3333.3, 2, "33", "333330", 4, 4, 0 },
{999999999999.9, 3, "100","999999999999900", 13, 12, 0 },
/* 0.0 with different precisions */
{ 0.0, 5, "00000", "00000", 0, 0, 0 },
{ 0.0, 0, "", "", 0, 0, 0 },
{ 0.0, -1, "", "", 0, 0, 0 },
/* Numbers > 1.0 with 0 or -ve precision */
{ -123.0001, 0, "", "123", 3, 3, 1 },
{ -123.0001, -1, "", "12", 3, 3, 1 },
{ -123.0001, -2, "", "1", 3, 3, 1 },
{ -123.0001, -3, "", "", 3, 3, 1 },
/* Numbers > 1.0, but with rounding at the point of precision */
{ 99.99, 1, "1", "1000", 3, 3, 0 },
/* Numbers < 1.0 where rounding occurs at the point of precision */
{ 0.0063, 2, "63", "1", -2, -1, 0 },
{ 0.0063, 3, "630", "6", -2, -2, 0 },
{ 0.09999999996, 2, "10", "10", 0, 0, 0 },
{ 0.6, 1, "6", "6", 0, 0, 0 },
{ 0.6, 0, "", "1", 1, 1, 0 },
{ 0.4, 0, "", "", 0, 0, 0 },
{ 0.49, 0, "", "", 0, 0, 0 },
{ 0.51, 0, "", "1", 1, 1, 0 },
/* ask ridiculous amunt of precision, ruin formatting this table */
{ 1.0, 30, "100000000000000000000000000000",
"1000000000000000000000000000000", 1, 1, 0},
{ 123456789012345678901.0, 30, "123456789012345680000000000000",
"123456789012345680000000000000000000000000000000000", 21, 21, 0},
/* end marker */
{ 0, 0, "END"}
};
static void test_xcvt(void)
{
char *str;
int i, decpt, sign;
for( i = 0; strcmp( test_cvt_testcases[i].expstr_e, "END"); i++){
decpt = sign = 100;
str = _ecvt( test_cvt_testcases[i].value,
test_cvt_testcases[i].nrdigits,
&decpt,
&sign);
ok( 0 == strncmp( str, test_cvt_testcases[i].expstr_e, 15),
"_ecvt() bad return, got \n'%s' expected \n'%s'\n", str,
test_cvt_testcases[i].expstr_e);
ok( decpt == test_cvt_testcases[i].expdecpt_e,
"_ecvt() decimal point wrong, got %d expected %d\n", decpt,
test_cvt_testcases[i].expdecpt_e);
}
for( i = 0; strcmp( test_cvt_testcases[i].expstr_e, "END"); i++){
decpt = sign = 100;
str = _fcvt( test_cvt_testcases[i].value,
test_cvt_testcases[i].nrdigits,
&decpt,
&sign);
ok( 0 == strncmp( str, test_cvt_testcases[i].expstr_f, 15),
"_fcvt() bad return, got \n'%s' expected \n'%s'\n", str,
test_cvt_testcases[i].expstr_f);
ok( decpt == test_cvt_testcases[i].expdecpt_f,
"_fcvt() decimal point wrong, got %d expected %d\n", decpt,
test_cvt_testcases[i].expdecpt_f);
ok( sign == test_cvt_testcases[i].expsign,
"_ecvt() sign wrong, got %d expected %d\n", sign,
test_cvt_testcases[i].expsign);
}
}
static int _vsnwprintf_wrapper(wchar_t *str, size_t len, const wchar_t *format, ...)
{
int ret;
@ -726,11 +810,60 @@ static void test_vsnwprintf(void)
ok( !strcmp(buf, "onetwothree"), "got %s expected 'onetwothree'\n", buf );
}
static int (*p__vscprintf)(const char *format, __ms_va_list valist);
static int (*p__vscwprintf)(const wchar_t *format, __ms_va_list valist);
static int __cdecl _vscprintf_wrapper(const char *format, ...)
{
int ret;
__ms_va_list valist;
__ms_va_start(valist, format);
ret = p__vscprintf(format, valist);
__ms_va_end(valist);
return ret;
}
static void test_vscprintf(void)
{
int ret;
ret = _vscprintf_wrapper( "%s %d", "number", 1 );
ok( ret == 8, "got %d expected 8\n", ret );
}
static int __cdecl _vscwprintf_wrapper(const wchar_t *format, ...)
{
int ret;
__ms_va_list valist;
__ms_va_start(valist, format);
ret = p__vscwprintf(format, valist);
__ms_va_end(valist);
return ret;
}
static void test_vscwprintf(void)
{
const wchar_t format[] = {'%','s',' ','%','d',0};
const wchar_t number[] = {'n','u','m','b','e','r',0};
int ret;
ret = _vscwprintf_wrapper( format, number, 1 );
ok( ret == 8, "got %d expected 8\n", ret );
}
START_TEST(printf)
{
test_sprintf();
test_swprintf();
test_snprintf();
test_fcvt();
test_xcvt();
test_vsnwprintf();
p__vscprintf = (void *)GetProcAddress(GetModuleHandle("msvcrt.dll"), "_vscprintf");
p__vscwprintf = (void *)GetProcAddress(GetModuleHandle("msvcrt.dll"), "_vscwprintf");
if (p__vscprintf) test_vscprintf();
if (p__vscwprintf) test_vscwprintf();
}

Some files were not shown because too many files have changed in this diff Show more