localspl/tests: Open the default Xcv-channel only once.
This commit is contained in:
parent
c5da6019d3
commit
fd37d30a26
|
@ -65,6 +65,7 @@ static BOOL (WINAPI *pAddPortUI)(PCWSTR, HWND, PCWSTR, PWSTR *);
|
|||
static BOOL (WINAPI *pConfigurePortUI)(PCWSTR, HWND, PCWSTR);
|
||||
static BOOL (WINAPI *pDeletePortUI)(PCWSTR, HWND, PCWSTR);
|
||||
|
||||
static HANDLE hXcv;
|
||||
static HANDLE hXcv_noaccess;
|
||||
|
||||
/* ########################### */
|
||||
|
@ -382,15 +383,8 @@ static void test_XcvClosePort(void)
|
|||
static void test_XcvDataPort_AddPort(void)
|
||||
{
|
||||
DWORD res;
|
||||
HANDLE hXcv;
|
||||
|
||||
|
||||
hXcv = (HANDLE) 0xdeadbeef;
|
||||
SetLastError(0xdeadbeef);
|
||||
res = pXcvOpenPort(emptyW, SERVER_ALL_ACCESS, &hXcv);
|
||||
ok(res, "hXcv: %d with %u and %p (expected '!= 0')\n", res, GetLastError(), hXcv);
|
||||
if (!res) return;
|
||||
|
||||
/*
|
||||
* The following tests crash with native localspl.dll on w2k and xp,
|
||||
* but it works, when the native dll (w2k and xp) is used in wine.
|
||||
|
@ -427,7 +421,6 @@ static void test_XcvDataPort_AddPort(void)
|
|||
res = pXcvDataPort(hXcv, cmd_DeletePortW, (PBYTE) tempfileW, (lstrlenW(tempfileW) + 1) * sizeof(WCHAR), NULL, 0, NULL);
|
||||
}
|
||||
|
||||
pXcvClosePort(hXcv);
|
||||
}
|
||||
|
||||
/* ########################### */
|
||||
|
@ -437,28 +430,19 @@ static void test_XcvDataPort_ConfigureLPTPortCommandOK(void)
|
|||
CHAR org_value[16];
|
||||
CHAR buffer[16];
|
||||
HKEY hroot = NULL;
|
||||
HANDLE hXcv;
|
||||
DWORD res;
|
||||
DWORD needed;
|
||||
|
||||
|
||||
hXcv = (HANDLE) 0xdeadbeef;
|
||||
SetLastError(0xdeadbeef);
|
||||
res = pXcvOpenPort(emptyW, SERVER_ACCESS_ADMINISTER, &hXcv);
|
||||
ok(res, "hXcv: %d with %u and %p (expected '!= 0')\n", res, GetLastError(), hXcv);
|
||||
if (!res) return;
|
||||
|
||||
/* Read the original value from the registry */
|
||||
res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, WinNT_CV_WindowsA, 0, KEY_ALL_ACCESS, &hroot);
|
||||
if (res == ERROR_ACCESS_DENIED) {
|
||||
pXcvClosePort(hXcv);
|
||||
skip("ACCESS_DENIED\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (res != ERROR_SUCCESS) {
|
||||
/* unable to open the registry: skip the test */
|
||||
pXcvClosePort(hXcv);
|
||||
skip("got %d\n", res);
|
||||
return;
|
||||
}
|
||||
|
@ -476,7 +460,6 @@ static void test_XcvDataPort_ConfigureLPTPortCommandOK(void)
|
|||
SetLastError(0xdeadbeef);
|
||||
res = pXcvDataPort(hXcv, cmd_ConfigureLPTPortCommandOKW, (PBYTE) num_0W, sizeof(num_0W), NULL, 0, &needed);
|
||||
if (res == ERROR_INVALID_PARAMETER) {
|
||||
pXcvClosePort(hXcv);
|
||||
skip("'ConfigureLPTPortCommandOK' not supported\n");
|
||||
return;
|
||||
}
|
||||
|
@ -533,7 +516,6 @@ static void test_XcvDataPort_ConfigureLPTPortCommandOK(void)
|
|||
}
|
||||
|
||||
RegCloseKey(hroot);
|
||||
pXcvClosePort(hXcv);
|
||||
|
||||
}
|
||||
|
||||
|
@ -542,16 +524,9 @@ static void test_XcvDataPort_ConfigureLPTPortCommandOK(void)
|
|||
static void test_XcvDataPort_DeletePort(void)
|
||||
{
|
||||
DWORD res;
|
||||
HANDLE hXcv;
|
||||
DWORD needed;
|
||||
|
||||
|
||||
hXcv = (HANDLE) 0xdeadbeef;
|
||||
SetLastError(0xdeadbeef);
|
||||
res = pXcvOpenPort(emptyW, SERVER_ALL_ACCESS, &hXcv);
|
||||
ok(res, "hXcv: %d with %u and %p (expected '!= 0')\n", res, GetLastError(), hXcv);
|
||||
if (!res) return;
|
||||
|
||||
/* cleanup: just to make sure */
|
||||
needed = (DWORD) 0xdeadbeef;
|
||||
SetLastError(0xdeadbeef);
|
||||
|
@ -574,7 +549,6 @@ static void test_XcvDataPort_DeletePort(void)
|
|||
/* emptyW as Portname: ERROR_FILE_NOT_FOUND is returned */
|
||||
/* NULL as Portname: Native localspl.dll crashed */
|
||||
|
||||
pXcvClosePort(hXcv);
|
||||
}
|
||||
|
||||
/* ########################### */
|
||||
|
@ -583,25 +557,17 @@ static void test_XcvDataPort_GetTransmissionRetryTimeout(void)
|
|||
{
|
||||
CHAR org_value[16];
|
||||
HKEY hroot = NULL;
|
||||
HANDLE hXcv;
|
||||
DWORD buffer[2];
|
||||
DWORD res;
|
||||
DWORD needed;
|
||||
DWORD len;
|
||||
|
||||
|
||||
hXcv = (HANDLE) 0xdeadbeef;
|
||||
SetLastError(0xdeadbeef);
|
||||
res = pXcvOpenPort(emptyW, SERVER_ACCESS_ADMINISTER, &hXcv);
|
||||
ok(res, "hXcv: %d with %u and %p (expected '!= 0')\n", res, GetLastError(), hXcv);
|
||||
if (!res) return;
|
||||
|
||||
/* ask for needed size */
|
||||
needed = (DWORD) 0xdeadbeef;
|
||||
SetLastError(0xdeadbeef);
|
||||
res = pXcvDataPort(hXcv, cmd_GetTransmissionRetryTimeoutW, NULL, 0, NULL, 0, &needed);
|
||||
if (res == ERROR_INVALID_PARAMETER) {
|
||||
pXcvClosePort(hXcv);
|
||||
skip("'GetTransmissionRetryTimeout' not supported\n");
|
||||
return;
|
||||
}
|
||||
|
@ -614,14 +580,12 @@ static void test_XcvDataPort_GetTransmissionRetryTimeout(void)
|
|||
/* Read the original value from the registry */
|
||||
res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, WinNT_CV_WindowsA, 0, KEY_ALL_ACCESS, &hroot);
|
||||
if (res == ERROR_ACCESS_DENIED) {
|
||||
pXcvClosePort(hXcv);
|
||||
skip("ACCESS_DENIED\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (res != ERROR_SUCCESS) {
|
||||
/* unable to open the registry: skip the test */
|
||||
pXcvClosePort(hXcv);
|
||||
skip("got %d\n", res);
|
||||
return;
|
||||
}
|
||||
|
@ -700,7 +664,6 @@ static void test_XcvDataPort_GetTransmissionRetryTimeout(void)
|
|||
}
|
||||
|
||||
RegCloseKey(hroot);
|
||||
pXcvClosePort(hXcv);
|
||||
}
|
||||
|
||||
/* ########################### */
|
||||
|
@ -708,24 +671,16 @@ static void test_XcvDataPort_GetTransmissionRetryTimeout(void)
|
|||
static void test_XcvDataPort_MonitorUI(void)
|
||||
{
|
||||
DWORD res;
|
||||
HANDLE hXcv;
|
||||
BYTE buffer[MAX_PATH + 2];
|
||||
DWORD needed;
|
||||
DWORD len;
|
||||
|
||||
|
||||
hXcv = (HANDLE) 0xdeadbeef;
|
||||
SetLastError(0xdeadbeef);
|
||||
res = pXcvOpenPort(emptyW, SERVER_ACCESS_ADMINISTER, &hXcv);
|
||||
ok(res, "returned %d with %u and %p (expected '!= 0')\n", res, GetLastError(), hXcv);
|
||||
if (!res) return;
|
||||
|
||||
/* ask for needed size */
|
||||
needed = (DWORD) 0xdeadbeef;
|
||||
SetLastError(0xdeadbeef);
|
||||
res = pXcvDataPort(hXcv, cmd_MonitorUIW, NULL, 0, NULL, 0, &needed);
|
||||
if (res == ERROR_INVALID_PARAMETER) {
|
||||
pXcvClosePort(hXcv);
|
||||
skip("'MonitorUI' nor supported\n");
|
||||
return;
|
||||
}
|
||||
|
@ -734,7 +689,6 @@ static void test_XcvDataPort_MonitorUI(void)
|
|||
" and '<= MAX_PATH')\n", res, GetLastError(), needed);
|
||||
|
||||
if (needed > MAX_PATH) {
|
||||
pXcvClosePort(hXcv);
|
||||
skip("buffer overflow (%u)\n", needed);
|
||||
return;
|
||||
}
|
||||
|
@ -796,9 +750,6 @@ static void test_XcvDataPort_MonitorUI(void)
|
|||
"(expected 'ERROR_SUCCESS')\n", res, GetLastError(), needed);
|
||||
|
||||
|
||||
pXcvClosePort(hXcv);
|
||||
|
||||
|
||||
/* small check without access-rights: */
|
||||
if (!hXcv_noaccess) return;
|
||||
|
||||
|
@ -816,22 +767,13 @@ static void test_XcvDataPort_MonitorUI(void)
|
|||
static void test_XcvDataPort_PortIsValid(void)
|
||||
{
|
||||
DWORD res;
|
||||
HANDLE hXcv;
|
||||
DWORD needed;
|
||||
|
||||
|
||||
hXcv = (HANDLE) 0xdeadbeef;
|
||||
SetLastError(0xdeadbeef);
|
||||
res = pXcvOpenPort(emptyW, SERVER_ACCESS_ADMINISTER, &hXcv);
|
||||
ok(res, "hXcv: %d with %u and %p (expected '!= 0')\n", res, GetLastError(), hXcv);
|
||||
if (!res) return;
|
||||
|
||||
/* normal use: "LPT1:" */
|
||||
needed = (DWORD) 0xdeadbeef;
|
||||
SetLastError(0xdeadbeef);
|
||||
res = pXcvDataPort(hXcv, cmd_PortIsValidW, (PBYTE) portname_lpt1W, sizeof(portname_lpt1W), NULL, 0, &needed);
|
||||
if (res == ERROR_INVALID_PARAMETER) {
|
||||
pXcvClosePort(hXcv);
|
||||
skip("'PostIsValid' not supported\n");
|
||||
return;
|
||||
}
|
||||
|
@ -948,8 +890,6 @@ static void test_XcvDataPort_PortIsValid(void)
|
|||
"returned %d with %u and 0x%x (expected ERROR_SUCCESS)\n",
|
||||
res, GetLastError(), needed);
|
||||
|
||||
pXcvClosePort(hXcv);
|
||||
|
||||
|
||||
/* small check without access-rights: */
|
||||
if (!hXcv_noaccess) return;
|
||||
|
@ -1076,26 +1016,24 @@ START_TEST(localmon)
|
|||
GET_MONITOR_FUNC(XcvClosePort);
|
||||
|
||||
if ((pXcvOpenPort) && (pXcvDataPort) && (pXcvClosePort)) {
|
||||
SetLastError(0xdeadbeef);
|
||||
res = pXcvOpenPort(emptyW, 0, &hXcv);
|
||||
ok(res, "hXcv: %d with %u and %p (expected '!= 0')\n", res, GetLastError(), hXcv);
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
res = pXcvOpenPort(emptyW, 0, &hXcv_noaccess);
|
||||
ok(res, "hXcv_noaccess: %d with %u and %p (expected '!= 0')\n", res, GetLastError(), hXcv_noaccess);
|
||||
}
|
||||
}
|
||||
|
||||
if ((!pInitializePrintMonitorUI) && (pXcvOpenPort) && (pXcvDataPort) && (pXcvClosePort)) {
|
||||
if ((!pInitializePrintMonitorUI) && (hXcv)) {
|
||||
/* The user interface for "Local Ports" is in a separate dll since w2k */
|
||||
BYTE buffer[MAX_PATH];
|
||||
DWORD res;
|
||||
DWORD len;
|
||||
HANDLE hXcv;
|
||||
|
||||
res = pXcvOpenPort(emptyW, SERVER_ACCESS_ADMINISTER, &hXcv);
|
||||
if (res) {
|
||||
res = pXcvDataPort(hXcv, cmd_MonitorUIW, NULL, 0, buffer, MAX_PATH, &len);
|
||||
if (res == ERROR_SUCCESS) hlocalui = LoadLibraryW( (LPWSTR) buffer);
|
||||
if (hlocalui) pInitializePrintMonitorUI = (void *) GetProcAddress(hlocalui, "InitializePrintMonitorUI");
|
||||
pXcvClosePort(hXcv);
|
||||
}
|
||||
res = pXcvDataPort(hXcv, cmd_MonitorUIW, NULL, 0, buffer, MAX_PATH, &len);
|
||||
if (res == ERROR_SUCCESS) hlocalui = LoadLibraryW( (LPWSTR) buffer);
|
||||
if (hlocalui) pInitializePrintMonitorUI = (void *) GetProcAddress(hlocalui, "InitializePrintMonitorUI");
|
||||
}
|
||||
|
||||
if (pInitializePrintMonitorUI) {
|
||||
|
@ -1119,7 +1057,7 @@ START_TEST(localmon)
|
|||
test_ConfigurePort();
|
||||
test_DeletePort();
|
||||
test_EnumPorts();
|
||||
if ((pXcvOpenPort == NULL) || (pXcvDataPort == NULL) || (pXcvClosePort == NULL)) {
|
||||
if ( !hXcv ) {
|
||||
skip("Xcv not supported\n");
|
||||
}
|
||||
else
|
||||
|
@ -1132,6 +1070,8 @@ START_TEST(localmon)
|
|||
test_XcvDataPort_MonitorUI();
|
||||
test_XcvDataPort_PortIsValid();
|
||||
test_XcvOpenPort();
|
||||
|
||||
pXcvClosePort(hXcv);
|
||||
}
|
||||
if (hXcv_noaccess) pXcvClosePort(hXcv_noaccess);
|
||||
|
||||
|
|
Loading…
Reference in New Issue