2003-01-15 01:50:48 +01:00
|
|
|
|
/*
|
2004-03-07 04:46:54 +01:00
|
|
|
|
* Copyright (C) 2003, 2004 Stefan Leichter
|
2006-04-10 00:29:22 +02:00
|
|
|
|
* Copyright (C) 2005, 2006 Detlef Riekenberg
|
2006-04-14 15:34:57 +02:00
|
|
|
|
* Copyright (C) 2006 Dmitry Timoshkov
|
2003-01-15 01:50:48 +01:00
|
|
|
|
*
|
|
|
|
|
* 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
|
2006-05-18 14:49:52 +02:00
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2003-01-15 01:50:48 +01:00
|
|
|
|
*/
|
|
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
2003-01-15 01:50:48 +01:00
|
|
|
|
#include "wine/test.h"
|
2003-09-06 01:08:26 +02:00
|
|
|
|
#include "windef.h"
|
2003-01-15 01:50:48 +01:00
|
|
|
|
#include "winbase.h"
|
|
|
|
|
#include "winerror.h"
|
|
|
|
|
#include "wingdi.h"
|
2006-04-18 12:36:58 +02:00
|
|
|
|
#include "winuser.h"
|
2005-12-12 13:02:15 +01:00
|
|
|
|
#include "winreg.h"
|
2003-01-15 01:50:48 +01:00
|
|
|
|
#include "winspool.h"
|
|
|
|
|
|
2006-05-27 12:09:52 +02:00
|
|
|
|
#define MAGIC_DEAD 0xdeadbeef
|
2005-12-12 13:02:15 +01:00
|
|
|
|
#define DEFAULT_PRINTER_SIZE 1000
|
2005-11-15 17:51:45 +01:00
|
|
|
|
|
2006-09-10 19:01:30 +02:00
|
|
|
|
static CHAR does_not_exist_dll[]= "does_not_exists.dll";
|
|
|
|
|
static CHAR empty[] = "";
|
|
|
|
|
static CHAR env_x86[] = "Windows NT x86";
|
|
|
|
|
static CHAR env_win9x_case[] = "windowS 4.0";
|
|
|
|
|
static CHAR illegal_name[] = "illegal,name";
|
|
|
|
|
static CHAR invalid_env[] = "invalid_env";
|
|
|
|
|
static CHAR invalid_server[] = "\\invalid_server";
|
|
|
|
|
static CHAR version_dll[] = "version.dll";
|
|
|
|
|
static CHAR winetest_monitor[] = "winetest";
|
2005-11-15 17:51:45 +01:00
|
|
|
|
|
2005-12-12 13:02:15 +01:00
|
|
|
|
static HANDLE hwinspool;
|
|
|
|
|
static FARPROC pGetDefaultPrinterA;
|
2006-02-20 11:51:10 +01:00
|
|
|
|
static FARPROC pSetDefaultPrinterA;
|
2005-12-12 13:02:15 +01:00
|
|
|
|
|
2006-04-10 00:29:22 +02:00
|
|
|
|
struct monitor_entry {
|
|
|
|
|
LPSTR env;
|
2006-07-25 22:53:32 +02:00
|
|
|
|
CHAR dllname[32];
|
2006-04-10 00:29:22 +02:00
|
|
|
|
};
|
|
|
|
|
|
2006-02-02 13:50:36 +01:00
|
|
|
|
/* report common behavior only once */
|
|
|
|
|
static DWORD report_deactivated_spooler = 1;
|
|
|
|
|
#define RETURN_ON_DEACTIVATED_SPOOLER(res) \
|
|
|
|
|
if((res == 0) && (GetLastError() == RPC_S_SERVER_UNAVAILABLE)) \
|
|
|
|
|
{ \
|
|
|
|
|
if(report_deactivated_spooler > 0) { \
|
|
|
|
|
report_deactivated_spooler--; \
|
|
|
|
|
trace("The Service 'Spooler' is required for many test\n"); \
|
|
|
|
|
} \
|
|
|
|
|
return; \
|
|
|
|
|
}
|
|
|
|
|
|
2005-12-12 13:02:15 +01:00
|
|
|
|
|
|
|
|
|
static LPSTR find_default_printer(VOID)
|
|
|
|
|
{
|
|
|
|
|
static LPSTR default_printer = NULL;
|
|
|
|
|
static char buffer[DEFAULT_PRINTER_SIZE];
|
|
|
|
|
DWORD needed;
|
|
|
|
|
DWORD res;
|
|
|
|
|
LPSTR ptr;
|
|
|
|
|
|
|
|
|
|
if ((default_printer == NULL) && (pGetDefaultPrinterA))
|
|
|
|
|
{
|
|
|
|
|
/* w2k and above */
|
|
|
|
|
needed = sizeof(buffer);
|
|
|
|
|
res = pGetDefaultPrinterA(buffer, &needed);
|
|
|
|
|
if(res) default_printer = buffer;
|
|
|
|
|
trace("default_printer: '%s'\n", default_printer);
|
|
|
|
|
}
|
|
|
|
|
if (default_printer == NULL)
|
|
|
|
|
{
|
|
|
|
|
HKEY hwindows;
|
|
|
|
|
DWORD type;
|
|
|
|
|
/* NT 3.x and above */
|
|
|
|
|
if (RegOpenKeyEx(HKEY_CURRENT_USER,
|
|
|
|
|
"Software\\Microsoft\\Windows NT\\CurrentVersion\\Windows",
|
|
|
|
|
0, KEY_QUERY_VALUE, &hwindows) == NO_ERROR) {
|
|
|
|
|
|
|
|
|
|
needed = sizeof(buffer);
|
|
|
|
|
if (RegQueryValueEx(hwindows, "device", NULL,
|
|
|
|
|
&type, (LPBYTE)buffer, &needed) == NO_ERROR) {
|
|
|
|
|
|
|
|
|
|
ptr = strchr(buffer, ',');
|
|
|
|
|
if (ptr) {
|
|
|
|
|
ptr[0] = '\0';
|
|
|
|
|
default_printer = buffer;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
RegCloseKey(hwindows);
|
|
|
|
|
}
|
|
|
|
|
trace("default_printer: '%s'\n", default_printer);
|
|
|
|
|
}
|
|
|
|
|
if (default_printer == NULL)
|
|
|
|
|
{
|
|
|
|
|
/* win9x */
|
|
|
|
|
needed = sizeof(buffer);
|
|
|
|
|
res = GetProfileStringA("windows", "device", "*", buffer, needed);
|
|
|
|
|
if(res) {
|
|
|
|
|
ptr = strchr(buffer, ',');
|
|
|
|
|
if (ptr) {
|
|
|
|
|
ptr[0] = '\0';
|
|
|
|
|
default_printer = buffer;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
trace("default_printer: '%s'\n", default_printer);
|
|
|
|
|
}
|
|
|
|
|
return default_printer;
|
|
|
|
|
}
|
|
|
|
|
|
2006-04-10 00:29:22 +02:00
|
|
|
|
|
|
|
|
|
static struct monitor_entry * find_installed_monitor(void)
|
|
|
|
|
{
|
|
|
|
|
MONITOR_INFO_2A mi2a;
|
|
|
|
|
static struct monitor_entry * entry = NULL;
|
|
|
|
|
DWORD num_tests;
|
|
|
|
|
DWORD i = 0;
|
|
|
|
|
|
|
|
|
|
static struct monitor_entry monitor_table[] = {
|
|
|
|
|
{env_win9x_case, "localspl.dll"},
|
|
|
|
|
{env_x86, "localspl.dll"},
|
|
|
|
|
{env_win9x_case, "localmon.dll"},
|
|
|
|
|
{env_x86, "localmon.dll"},
|
|
|
|
|
{env_win9x_case, "tcpmon.dll"},
|
|
|
|
|
{env_x86, "tcpmon.dll"},
|
|
|
|
|
{env_win9x_case, "usbmon.dll"},
|
|
|
|
|
{env_x86, "usbmon.dll"},
|
|
|
|
|
{env_win9x_case, "mspp32.dll"},
|
|
|
|
|
{env_x86, "win32spl.dll"},
|
|
|
|
|
{env_x86, "redmonnt.dll"},
|
|
|
|
|
{env_x86, "redmon35.dll"},
|
|
|
|
|
{env_win9x_case, "redmon95.dll"},
|
|
|
|
|
{env_x86, "pdfcmnnt.dll"},
|
|
|
|
|
{env_win9x_case, "pdfcmn95.dll"},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (entry) return entry;
|
|
|
|
|
|
|
|
|
|
num_tests = (sizeof(monitor_table)/sizeof(struct monitor_entry));
|
|
|
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
|
DeleteMonitorA(NULL, env_x86, winetest_monitor);
|
|
|
|
|
DeleteMonitorA(NULL, env_win9x_case, winetest_monitor);
|
|
|
|
|
|
|
|
|
|
/* find a usable monitor from the table */
|
|
|
|
|
mi2a.pName = winetest_monitor;
|
|
|
|
|
while ((entry == NULL) && (i < num_tests)) {
|
|
|
|
|
entry = &monitor_table[i];
|
|
|
|
|
i++;
|
|
|
|
|
mi2a.pEnvironment = entry->env;
|
|
|
|
|
mi2a.pDLLName = entry->dllname;
|
|
|
|
|
|
|
|
|
|
if (AddMonitorA(NULL, 2, (LPBYTE) &mi2a)) {
|
|
|
|
|
/* we got one */
|
|
|
|
|
trace("using '%s', '%s'\n", entry->env, entry->dllname);
|
|
|
|
|
DeleteMonitorA(NULL, entry->env, winetest_monitor);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
entry = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return entry;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ########################### */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void test_AddMonitor(void)
|
|
|
|
|
{
|
|
|
|
|
MONITOR_INFO_2A mi2a;
|
|
|
|
|
struct monitor_entry * entry = NULL;
|
|
|
|
|
DWORD res;
|
|
|
|
|
|
|
|
|
|
entry = find_installed_monitor();
|
|
|
|
|
|
|
|
|
|
SetLastError(MAGIC_DEAD);
|
|
|
|
|
res = AddMonitorA(NULL, 1, NULL);
|
|
|
|
|
ok(!res && (GetLastError() == ERROR_INVALID_LEVEL),
|
|
|
|
|
"returned %ld with %ld (expected '0' with ERROR_INVALID_LEVEL)\n",
|
|
|
|
|
res, GetLastError());
|
|
|
|
|
|
|
|
|
|
SetLastError(MAGIC_DEAD);
|
|
|
|
|
res = AddMonitorA(NULL, 3, NULL);
|
|
|
|
|
ok(!res && (GetLastError() == ERROR_INVALID_LEVEL),
|
|
|
|
|
"returned %ld with %ld (expected '0' with ERROR_INVALID_LEVEL)\n",
|
|
|
|
|
res, GetLastError());
|
|
|
|
|
|
2006-05-22 00:39:33 +02:00
|
|
|
|
#if 0
|
|
|
|
|
/* This test crash with win9x on vmware (works with win9x on qemu 0.8.1) */
|
2006-04-10 00:29:22 +02:00
|
|
|
|
SetLastError(MAGIC_DEAD);
|
|
|
|
|
res = AddMonitorA(NULL, 2, NULL);
|
|
|
|
|
/* NT: unchanged, 9x: ERROR_PRIVILEGE_NOT_HELD */
|
|
|
|
|
ok(!res &&
|
|
|
|
|
((GetLastError() == MAGIC_DEAD) ||
|
|
|
|
|
(GetLastError() == ERROR_PRIVILEGE_NOT_HELD)),
|
|
|
|
|
"returned %ld with %ld (expected '0' with: MAGIC_DEAD or " \
|
|
|
|
|
"ERROR_PRIVILEGE_NOT_HELD)\n", res, GetLastError());
|
2006-05-22 00:39:33 +02:00
|
|
|
|
#endif
|
2006-04-10 00:29:22 +02:00
|
|
|
|
|
|
|
|
|
ZeroMemory(&mi2a, sizeof(MONITOR_INFO_2A));
|
|
|
|
|
SetLastError(MAGIC_DEAD);
|
|
|
|
|
res = AddMonitorA(NULL, 2, (LPBYTE) &mi2a);
|
|
|
|
|
RETURN_ON_DEACTIVATED_SPOOLER(res)
|
|
|
|
|
|
|
|
|
|
if (!res && (GetLastError() == ERROR_ACCESS_DENIED)) {
|
|
|
|
|
trace("skip tests (ACCESS_DENIED)\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* NT: ERROR_INVALID_PARAMETER, 9x: ERROR_INVALID_ENVIRONMENT */
|
|
|
|
|
ok(!res && ((GetLastError() == ERROR_INVALID_PARAMETER) ||
|
|
|
|
|
(GetLastError() == ERROR_INVALID_ENVIRONMENT)),
|
|
|
|
|
"returned %ld with %ld (expected '0' with: ERROR_INVALID_PARAMETER or " \
|
|
|
|
|
"ERROR_INVALID_ENVIRONMENT)\n", res, GetLastError());
|
|
|
|
|
|
|
|
|
|
if (!entry) {
|
|
|
|
|
trace("No usable Monitor found: Skip tests\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
|
/* The Test is deactivated, because when mi2a.pName is NULL, the subkey
|
|
|
|
|
HKLM\System\CurrentControlSet\Control\Print\Monitors\C:\WINDOWS\SYSTEM
|
|
|
|
|
or HKLM\System\CurrentControlSet\Control\Print\Monitors\<EFBFBD>
|
|
|
|
|
is created on win9x and we do not want to hit this bug here. */
|
|
|
|
|
|
|
|
|
|
mi2a.pEnvironment = entry->env;
|
|
|
|
|
SetLastError(MAGIC_DEAD);
|
|
|
|
|
res = AddMonitorA(NULL, 2, (LPBYTE) &mi2a);
|
|
|
|
|
/* NT: ERROR_INVALID_PARAMETER, 9x: ERROR_PRIVILEGE_NOT_HELD */
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
mi2a.pEnvironment = entry->env;
|
2006-07-12 23:31:46 +02:00
|
|
|
|
mi2a.pName = empty;
|
2006-04-10 00:29:22 +02:00
|
|
|
|
SetLastError(MAGIC_DEAD);
|
|
|
|
|
res = AddMonitorA(NULL, 2, (LPBYTE) &mi2a);
|
|
|
|
|
/* NT: ERROR_INVALID_PARAMETER, 9x: ERROR_PRIVILEGE_NOT_HELD */
|
|
|
|
|
ok( !res &&
|
|
|
|
|
((GetLastError() == ERROR_INVALID_PARAMETER) ||
|
|
|
|
|
(GetLastError() == ERROR_PRIVILEGE_NOT_HELD)),
|
|
|
|
|
"returned %ld with %ld (expected '0' with: ERROR_INVALID_PARAMETER or " \
|
|
|
|
|
"ERROR_PRIVILEGE_NOT_HELD)\n",
|
|
|
|
|
res, GetLastError());
|
|
|
|
|
|
|
|
|
|
mi2a.pName = winetest_monitor;
|
|
|
|
|
SetLastError(MAGIC_DEAD);
|
|
|
|
|
res = AddMonitorA(NULL, 2, (LPBYTE) &mi2a);
|
|
|
|
|
/* NT: ERROR_INVALID_PARAMETER, 9x: ERROR_PRIVILEGE_NOT_HELD */
|
|
|
|
|
ok( !res &&
|
|
|
|
|
((GetLastError() == ERROR_INVALID_PARAMETER) ||
|
|
|
|
|
(GetLastError() == ERROR_PRIVILEGE_NOT_HELD)),
|
|
|
|
|
"returned %ld with %ld (expected '0' with: ERROR_INVALID_PARAMETER or " \
|
|
|
|
|
"ERROR_PRIVILEGE_NOT_HELD)\n",
|
|
|
|
|
res, GetLastError());
|
|
|
|
|
|
2006-07-12 23:31:46 +02:00
|
|
|
|
mi2a.pDLLName = empty;
|
2006-04-10 00:29:22 +02:00
|
|
|
|
SetLastError(MAGIC_DEAD);
|
|
|
|
|
res = AddMonitorA(NULL, 2, (LPBYTE) &mi2a);
|
|
|
|
|
ok( !res && (GetLastError() == ERROR_INVALID_PARAMETER),
|
|
|
|
|
"returned %ld with %ld (expected '0' with ERROR_INVALID_PARAMETER)\n",
|
|
|
|
|
res, GetLastError());
|
|
|
|
|
|
2006-07-12 23:31:46 +02:00
|
|
|
|
mi2a.pDLLName = does_not_exist_dll;
|
2006-04-10 00:29:22 +02:00
|
|
|
|
SetLastError(MAGIC_DEAD);
|
|
|
|
|
res = AddMonitorA(NULL, 2, (LPBYTE) &mi2a);
|
|
|
|
|
/* NT: ERROR_MOD_NOT_FOUND, 9x: ERROR_INVALID_PARAMETER */
|
|
|
|
|
ok( !res &&
|
|
|
|
|
((GetLastError() == ERROR_MOD_NOT_FOUND) ||
|
|
|
|
|
(GetLastError() == ERROR_INVALID_PARAMETER)),
|
|
|
|
|
"returned %ld with %ld (expected '0' with: ERROR_MOD_NOT_FOUND or " \
|
|
|
|
|
"ERROR_INVALID_PARAMETER)\n", res, GetLastError());
|
|
|
|
|
|
2006-07-12 23:31:46 +02:00
|
|
|
|
mi2a.pDLLName = version_dll;
|
2006-04-10 00:29:22 +02:00
|
|
|
|
SetLastError(MAGIC_DEAD);
|
|
|
|
|
res = AddMonitorA(NULL, 2, (LPBYTE) &mi2a);
|
|
|
|
|
/* NT: ERROR_PROC_NOT_FOUND, 9x: ERROR_INVALID_PARAMETER */
|
|
|
|
|
ok( !res &&
|
|
|
|
|
((GetLastError() == ERROR_PROC_NOT_FOUND) ||
|
|
|
|
|
(GetLastError() == ERROR_INVALID_PARAMETER)),
|
|
|
|
|
"returned %ld with %ld (expected '0' with: ERROR_PROC_NOT_FOUND or " \
|
|
|
|
|
"ERROR_INVALID_PARAMETER)\n", res, GetLastError());
|
|
|
|
|
if (res) DeleteMonitorA(NULL, entry->env, winetest_monitor);
|
|
|
|
|
|
|
|
|
|
/* Test AddMonitor with real options */
|
|
|
|
|
mi2a.pDLLName = entry->dllname;
|
|
|
|
|
SetLastError(MAGIC_DEAD);
|
|
|
|
|
res = AddMonitorA(NULL, 2, (LPBYTE) &mi2a);
|
|
|
|
|
ok(res, "returned %ld with %ld (expected '!= 0')\n", res, GetLastError());
|
2006-07-12 23:31:46 +02:00
|
|
|
|
|
2006-04-10 00:29:22 +02:00
|
|
|
|
/* add a monitor twice */
|
|
|
|
|
SetLastError(MAGIC_DEAD);
|
|
|
|
|
res = AddMonitorA(NULL, 2, (LPBYTE) &mi2a);
|
|
|
|
|
/* NT: ERROR_PRINT_MONITOR_ALREADY_INSTALLED (3006), 9x: ERROR_ALREADY_EXISTS (183) */
|
|
|
|
|
ok( !res &&
|
|
|
|
|
((GetLastError() == ERROR_PRINT_MONITOR_ALREADY_INSTALLED) ||
|
|
|
|
|
(GetLastError() == ERROR_ALREADY_EXISTS)),
|
|
|
|
|
"returned %ld with %ld (expected '0' with: " \
|
|
|
|
|
"ERROR_PRINT_MONITOR_ALREADY_INSTALLED or ERROR_ALREADY_EXISTS)\n",
|
|
|
|
|
res, GetLastError());
|
|
|
|
|
|
|
|
|
|
DeleteMonitorA(NULL, entry->env, winetest_monitor);
|
|
|
|
|
SetLastError(MAGIC_DEAD);
|
2006-08-19 17:15:59 +02:00
|
|
|
|
res = AddMonitorA(empty, 2, (LPBYTE) &mi2a);
|
2006-04-10 00:29:22 +02:00
|
|
|
|
ok(res, "returned %ld with %ld (expected '!= 0')\n", res, GetLastError());
|
|
|
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
|
DeleteMonitorA(NULL, entry->env, winetest_monitor);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2006-04-16 02:42:34 +02:00
|
|
|
|
/* ########################### */
|
|
|
|
|
|
|
|
|
|
static void test_DeleteMonitor(void)
|
|
|
|
|
{
|
2006-08-19 17:15:59 +02:00
|
|
|
|
MONITOR_INFO_2A mi2a;
|
|
|
|
|
struct monitor_entry * entry = NULL;
|
|
|
|
|
DWORD res;
|
2006-09-10 19:01:30 +02:00
|
|
|
|
|
2006-04-16 02:42:34 +02:00
|
|
|
|
|
|
|
|
|
entry = find_installed_monitor();
|
|
|
|
|
|
|
|
|
|
if (!entry) {
|
|
|
|
|
trace("No usable Monitor found: Skip tests\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mi2a.pName = winetest_monitor;
|
|
|
|
|
mi2a.pEnvironment = entry->env;
|
|
|
|
|
mi2a.pDLLName = entry->dllname;
|
|
|
|
|
|
|
|
|
|
/* Testing DeleteMonitor with real options */
|
|
|
|
|
AddMonitorA(NULL, 2, (LPBYTE) &mi2a);
|
|
|
|
|
|
|
|
|
|
SetLastError(MAGIC_DEAD);
|
|
|
|
|
res = DeleteMonitorA(NULL, entry->env, winetest_monitor);
|
|
|
|
|
ok(res, "returned %ld with %ld (expected '!= 0')\n", res, GetLastError());
|
|
|
|
|
|
|
|
|
|
/* Delete the Monitor twice */
|
|
|
|
|
SetLastError(MAGIC_DEAD);
|
|
|
|
|
res = DeleteMonitorA(NULL, entry->env, winetest_monitor);
|
|
|
|
|
/* NT: ERROR_UNKNOWN_PRINT_MONITOR (3000), 9x: ERROR_INVALID_PARAMETER (87) */
|
|
|
|
|
ok( !res &&
|
|
|
|
|
((GetLastError() == ERROR_UNKNOWN_PRINT_MONITOR) ||
|
|
|
|
|
(GetLastError() == ERROR_INVALID_PARAMETER)),
|
|
|
|
|
"returned %ld with %ld (expected '0' with: ERROR_UNKNOWN_PRINT_MONITOR" \
|
|
|
|
|
" or ERROR_INVALID_PARAMETER)\n", res, GetLastError());
|
|
|
|
|
|
|
|
|
|
/* the environment */
|
|
|
|
|
AddMonitorA(NULL, 2, (LPBYTE) &mi2a);
|
|
|
|
|
SetLastError(MAGIC_DEAD);
|
|
|
|
|
res = DeleteMonitorA(NULL, NULL, winetest_monitor);
|
|
|
|
|
ok(res, "returned %ld with %ld (expected '!=0')\n", res, GetLastError());
|
|
|
|
|
|
|
|
|
|
AddMonitorA(NULL, 2, (LPBYTE) &mi2a);
|
|
|
|
|
SetLastError(MAGIC_DEAD);
|
2006-08-19 17:15:59 +02:00
|
|
|
|
res = DeleteMonitorA(NULL, empty, winetest_monitor);
|
2006-04-16 02:42:34 +02:00
|
|
|
|
ok(res, "returned %ld with %ld (expected '!=0')\n", res, GetLastError());
|
|
|
|
|
|
|
|
|
|
AddMonitorA(NULL, 2, (LPBYTE) &mi2a);
|
|
|
|
|
SetLastError(MAGIC_DEAD);
|
2006-09-10 19:01:30 +02:00
|
|
|
|
res = DeleteMonitorA(NULL, invalid_env, winetest_monitor);
|
2006-04-16 02:42:34 +02:00
|
|
|
|
ok(res, "returned %ld with %ld (expected '!=0')\n", res, GetLastError());
|
|
|
|
|
|
|
|
|
|
/* the monitor-name */
|
|
|
|
|
AddMonitorA(NULL, 2, (LPBYTE) &mi2a);
|
|
|
|
|
SetLastError(MAGIC_DEAD);
|
|
|
|
|
res = DeleteMonitorA(NULL, entry->env, NULL);
|
|
|
|
|
/* NT: ERROR_INVALID_PARAMETER (87), 9x: ERROR_INVALID_NAME (123)*/
|
|
|
|
|
ok( !res &&
|
|
|
|
|
((GetLastError() == ERROR_INVALID_PARAMETER) ||
|
|
|
|
|
(GetLastError() == ERROR_INVALID_NAME)),
|
|
|
|
|
"returned %ld with %ld (expected '0' with: ERROR_INVALID_PARAMETER or " \
|
|
|
|
|
"ERROR_INVALID_NAME)\n", res, GetLastError());
|
|
|
|
|
|
|
|
|
|
AddMonitorA(NULL, 2, (LPBYTE) &mi2a);
|
|
|
|
|
SetLastError(MAGIC_DEAD);
|
2006-08-19 17:15:59 +02:00
|
|
|
|
res = DeleteMonitorA(NULL, entry->env, empty);
|
2006-04-16 02:42:34 +02:00
|
|
|
|
/* NT: ERROR_INVALID_PARAMETER (87), 9x: ERROR_INVALID_NAME (123)*/
|
|
|
|
|
ok( !res &&
|
|
|
|
|
((GetLastError() == ERROR_INVALID_PARAMETER) ||
|
|
|
|
|
(GetLastError() == ERROR_INVALID_NAME)),
|
|
|
|
|
"returned %ld with %ld (expected '0' with: ERROR_INVALID_PARAMETER or " \
|
|
|
|
|
"ERROR_INVALID_NAME)\n", res, GetLastError());
|
|
|
|
|
|
|
|
|
|
AddMonitorA(NULL, 2, (LPBYTE) &mi2a);
|
|
|
|
|
SetLastError(MAGIC_DEAD);
|
2006-08-19 17:15:59 +02:00
|
|
|
|
res = DeleteMonitorA(empty, entry->env, winetest_monitor);
|
2006-04-16 02:42:34 +02:00
|
|
|
|
ok(res, "returned %ld with %ld (expected '!=0')\n", res, GetLastError());
|
|
|
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
|
DeleteMonitorA(NULL, entry->env, winetest_monitor);
|
|
|
|
|
}
|
|
|
|
|
|
2006-06-16 09:54:55 +02:00
|
|
|
|
/* ######## */
|
|
|
|
|
|
|
|
|
|
static void test_EnumForms(LPSTR pName)
|
|
|
|
|
{
|
|
|
|
|
DWORD res;
|
|
|
|
|
HANDLE hprinter = 0;
|
|
|
|
|
LPBYTE buffer;
|
|
|
|
|
DWORD cbBuf;
|
|
|
|
|
DWORD pcbNeeded;
|
|
|
|
|
DWORD pcReturned;
|
|
|
|
|
DWORD level;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
res = OpenPrinter(pName, &hprinter, NULL);
|
|
|
|
|
RETURN_ON_DEACTIVATED_SPOOLER(res)
|
|
|
|
|
if (!res || !hprinter)
|
|
|
|
|
{
|
|
|
|
|
/* Open the local Prinserver is not supported on win9x */
|
|
|
|
|
if (pName) trace("Failed to open '%s', skiping the test\n", pName);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* valid levels are 1 and 2 */
|
|
|
|
|
for(level = 0; level < 4; level++) {
|
|
|
|
|
cbBuf = 0xdeadbeef;
|
|
|
|
|
pcReturned = 0xdeadbeef;
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
|
res = EnumFormsA(hprinter, level, NULL, 0, &cbBuf, &pcReturned);
|
|
|
|
|
|
|
|
|
|
/* EnumForms is not implemented in win9x */
|
|
|
|
|
if (!res && (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)) continue;
|
|
|
|
|
|
|
|
|
|
/* EnumForms for the Server not implemented on all NT-Versions */
|
|
|
|
|
if (!res && (GetLastError() == ERROR_INVALID_HANDLE) && !pName) continue;
|
|
|
|
|
|
|
|
|
|
/* Level 2 for EnumForms is not supported on all systems */
|
|
|
|
|
if (!res && (GetLastError() == ERROR_INVALID_LEVEL) && (level == 2)) continue;
|
|
|
|
|
|
|
|
|
|
/* use only a short test, when we test with an invalid level */
|
|
|
|
|
if(!level || (level > 2)) {
|
|
|
|
|
ok( (!res && (GetLastError() == ERROR_INVALID_LEVEL)) ||
|
|
|
|
|
(res && (pcReturned == 0)),
|
|
|
|
|
"(%ld) returned %ld with %ld and 0x%08lx (expected '0' with " \
|
|
|
|
|
"ERROR_INVALID_LEVEL or '!=0' and 0x0)\n",
|
|
|
|
|
level, res, GetLastError(), pcReturned);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ok((!res) && (GetLastError() == ERROR_INSUFFICIENT_BUFFER),
|
|
|
|
|
"(%ld) returned %ld with %ld (expected '0' with " \
|
|
|
|
|
"ERROR_INSUFFICIENT_BUFFER)\n", level, res, GetLastError());
|
|
|
|
|
|
|
|
|
|
buffer = HeapAlloc(GetProcessHeap(), 0, cbBuf *2);
|
|
|
|
|
if (buffer == NULL) continue;
|
|
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
|
res = EnumFormsA(hprinter, level, buffer, cbBuf, &pcbNeeded, &pcReturned);
|
|
|
|
|
ok(res, "(%ld) returned %ld with %ld (expected '!=0')\n",
|
|
|
|
|
level, res, GetLastError());
|
|
|
|
|
/* We can dump the returned Data here */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
|
res = EnumFormsA(hprinter, level, buffer, cbBuf+1, &pcbNeeded, &pcReturned);
|
|
|
|
|
ok( res, "(%ld) returned %ld with %ld (expected '!=0')\n",
|
|
|
|
|
level, res, GetLastError());
|
|
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
|
res = EnumFormsA(hprinter, level, buffer, cbBuf-1, &pcbNeeded, &pcReturned);
|
|
|
|
|
ok( !res && (GetLastError() == ERROR_INSUFFICIENT_BUFFER),
|
|
|
|
|
"(%ld) returned %ld with %ld (expected '0' with " \
|
|
|
|
|
"ERROR_INSUFFICIENT_BUFFER)\n", level, res, GetLastError());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
|
res = EnumFormsA(hprinter, level, NULL, cbBuf, &pcbNeeded, &pcReturned);
|
|
|
|
|
ok( !res && (GetLastError() == ERROR_INVALID_USER_BUFFER) ,
|
|
|
|
|
"(%ld) returned %ld with %ld (expected '0' with "\
|
|
|
|
|
"ERROR_INVALID_USER_BUFFER)\n", level, res, GetLastError());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
|
res = EnumFormsA(hprinter, level, buffer, cbBuf, NULL, &pcReturned);
|
|
|
|
|
ok( !res && (GetLastError() == RPC_X_NULL_REF_POINTER) ,
|
|
|
|
|
"(%ld) returned %ld with %ld (expected '0' with "\
|
|
|
|
|
"RPC_X_NULL_REF_POINTER)\n", level, res, GetLastError());
|
|
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
|
res = EnumFormsA(hprinter, level, buffer, cbBuf, &pcbNeeded, NULL);
|
|
|
|
|
ok( !res && (GetLastError() == RPC_X_NULL_REF_POINTER) ,
|
|
|
|
|
"(%ld) returned %ld with %ld (expected '0' with "\
|
|
|
|
|
"RPC_X_NULL_REF_POINTER)\n", level, res, GetLastError());
|
|
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
|
res = EnumFormsA(0, level, buffer, cbBuf, &pcbNeeded, &pcReturned);
|
|
|
|
|
ok( !res && (GetLastError() == ERROR_INVALID_HANDLE) ,
|
|
|
|
|
"(%ld) returned %ld with %ld (expected '0' with "\
|
|
|
|
|
"ERROR_INVALID_HANDLE)\n", level, res, GetLastError());
|
|
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, buffer);
|
|
|
|
|
} /* for(level ... */
|
|
|
|
|
|
|
|
|
|
ClosePrinter(hprinter);
|
|
|
|
|
}
|
2006-04-16 02:42:34 +02:00
|
|
|
|
|
2006-02-17 17:37:04 +01:00
|
|
|
|
/* ########################### */
|
|
|
|
|
|
|
|
|
|
static void test_EnumMonitors(void)
|
|
|
|
|
{
|
|
|
|
|
DWORD res;
|
|
|
|
|
LPBYTE buffer;
|
|
|
|
|
DWORD cbBuf;
|
|
|
|
|
DWORD pcbNeeded;
|
|
|
|
|
DWORD pcReturned;
|
|
|
|
|
DWORD level;
|
|
|
|
|
|
|
|
|
|
/* valid levels are 1 and 2 */
|
|
|
|
|
for(level = 0; level < 4; level++) {
|
|
|
|
|
cbBuf = MAGIC_DEAD;
|
|
|
|
|
pcReturned = MAGIC_DEAD;
|
|
|
|
|
SetLastError(MAGIC_DEAD);
|
|
|
|
|
res = EnumMonitorsA(NULL, level, NULL, 0, &cbBuf, &pcReturned);
|
|
|
|
|
|
|
|
|
|
RETURN_ON_DEACTIVATED_SPOOLER(res)
|
|
|
|
|
|
|
|
|
|
/* not implemented yet in wine */
|
|
|
|
|
if (!res && (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)) continue;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* use only a short test, when we test with an invalid level */
|
|
|
|
|
if(!level || (level > 2)) {
|
|
|
|
|
ok( (!res && (GetLastError() == ERROR_INVALID_LEVEL)) ||
|
|
|
|
|
(res && (pcReturned == 0)),
|
|
|
|
|
"(%ld) returned %ld with %ld and 0x%08lx (expected '0' with " \
|
|
|
|
|
"ERROR_INVALID_LEVEL or '!=0' and 0x0)\n",
|
|
|
|
|
level, res, GetLastError(), pcReturned);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Level 2 is not supported on win9x */
|
|
|
|
|
if (!res && (GetLastError() == ERROR_INVALID_LEVEL)) {
|
|
|
|
|
trace("Level %ld not supported, skipping tests\n", level);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ok((!res) && (GetLastError() == ERROR_INSUFFICIENT_BUFFER),
|
|
|
|
|
"(%ld) returned %ld with %ld (expected '0' with " \
|
|
|
|
|
"ERROR_INSUFFICIENT_BUFFER)\n", level, res, GetLastError());
|
|
|
|
|
|
|
|
|
|
if (!cbBuf) {
|
|
|
|
|
trace("no valid buffer size returned, skipping tests\n");
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
buffer = HeapAlloc(GetProcessHeap(), 0, cbBuf *2);
|
|
|
|
|
if (buffer == NULL) continue;
|
|
|
|
|
|
|
|
|
|
SetLastError(MAGIC_DEAD);
|
|
|
|
|
pcbNeeded = MAGIC_DEAD;
|
|
|
|
|
res = EnumMonitorsA(NULL, level, buffer, cbBuf, &pcbNeeded, &pcReturned);
|
|
|
|
|
ok(res, "(%ld) returned %ld with %ld (expected '!=0')\n",
|
|
|
|
|
level, res, GetLastError());
|
|
|
|
|
ok(pcbNeeded == cbBuf, "(%ld) returned %ld (expected %ld)\n",
|
|
|
|
|
level, pcbNeeded, cbBuf);
|
|
|
|
|
/* We can validate the returned Data with the Registry here */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SetLastError(MAGIC_DEAD);
|
|
|
|
|
pcReturned = MAGIC_DEAD;
|
|
|
|
|
pcbNeeded = MAGIC_DEAD;
|
|
|
|
|
res = EnumMonitorsA(NULL, level, buffer, cbBuf+1, &pcbNeeded, &pcReturned);
|
|
|
|
|
ok(res, "(%ld) returned %ld with %ld (expected '!=0')\n", level,
|
|
|
|
|
res, GetLastError());
|
|
|
|
|
ok(pcbNeeded == cbBuf, "(%ld) returned %ld (expected %ld)\n", level,
|
|
|
|
|
pcbNeeded, cbBuf);
|
|
|
|
|
|
|
|
|
|
SetLastError(MAGIC_DEAD);
|
|
|
|
|
pcbNeeded = MAGIC_DEAD;
|
|
|
|
|
res = EnumMonitorsA(NULL, level, buffer, cbBuf-1, &pcbNeeded, &pcReturned);
|
|
|
|
|
ok( !res && (GetLastError() == ERROR_INSUFFICIENT_BUFFER),
|
|
|
|
|
"(%ld) returned %ld with %ld (expected '0' with " \
|
|
|
|
|
"ERROR_INSUFFICIENT_BUFFER)\n", level, res, GetLastError());
|
|
|
|
|
|
|
|
|
|
ok(pcbNeeded == cbBuf, "(%ld) returned %ld (expected %ld)\n", level,
|
|
|
|
|
pcbNeeded, cbBuf);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
Do not add the next test:
|
|
|
|
|
w2k+: RPC_X_NULL_REF_POINTER
|
|
|
|
|
NT3.5: ERROR_INVALID_USER_BUFFER
|
|
|
|
|
win9x: crash in winspool.drv
|
|
|
|
|
|
|
|
|
|
res = EnumMonitorsA(NULL, level, NULL, cbBuf, &pcbNeeded, &pcReturned);
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
SetLastError(MAGIC_DEAD);
|
|
|
|
|
pcbNeeded = MAGIC_DEAD;
|
|
|
|
|
pcReturned = MAGIC_DEAD;
|
|
|
|
|
res = EnumMonitorsA(NULL, level, buffer, cbBuf, NULL, &pcReturned);
|
|
|
|
|
ok( res || (!res && (GetLastError() == RPC_X_NULL_REF_POINTER)) ,
|
|
|
|
|
"(%ld) returned %ld with %ld (expected '!=0' or '0' with "\
|
|
|
|
|
"RPC_X_NULL_REF_POINTER)\n", level, res, GetLastError());
|
|
|
|
|
|
|
|
|
|
pcbNeeded = MAGIC_DEAD;
|
|
|
|
|
pcReturned = MAGIC_DEAD;
|
|
|
|
|
SetLastError(MAGIC_DEAD);
|
|
|
|
|
res = EnumMonitorsA(NULL, level, buffer, cbBuf, &pcbNeeded, NULL);
|
|
|
|
|
ok( res || (!res && (GetLastError() == RPC_X_NULL_REF_POINTER)) ,
|
|
|
|
|
"(%ld) returned %ld with %ld (expected '!=0' or '0' with "\
|
|
|
|
|
"RPC_X_NULL_REF_POINTER)\n", level, res, GetLastError());
|
|
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, buffer);
|
|
|
|
|
} /* for(level ... */
|
|
|
|
|
}
|
|
|
|
|
|
2005-11-15 17:51:45 +01:00
|
|
|
|
|
2006-02-01 12:32:10 +01:00
|
|
|
|
static void test_GetDefaultPrinter(void)
|
2004-03-07 04:46:54 +01:00
|
|
|
|
{
|
|
|
|
|
BOOL retval;
|
|
|
|
|
DWORD exact = DEFAULT_PRINTER_SIZE;
|
|
|
|
|
DWORD size;
|
|
|
|
|
char buffer[DEFAULT_PRINTER_SIZE];
|
|
|
|
|
|
2005-12-12 13:02:15 +01:00
|
|
|
|
if (!pGetDefaultPrinterA) return;
|
2004-03-07 04:46:54 +01:00
|
|
|
|
/* only supported on NT like OSes starting with win2k */
|
|
|
|
|
|
2004-06-14 18:54:42 +02:00
|
|
|
|
SetLastError(ERROR_SUCCESS);
|
2005-12-12 13:02:15 +01:00
|
|
|
|
retval = pGetDefaultPrinterA(buffer, &exact);
|
2004-06-14 18:54:42 +02:00
|
|
|
|
if (!retval || !exact || !strlen(buffer) ||
|
|
|
|
|
(ERROR_SUCCESS != GetLastError())) {
|
2004-06-15 22:25:24 +02:00
|
|
|
|
if ((ERROR_FILE_NOT_FOUND == GetLastError()) ||
|
|
|
|
|
(ERROR_INVALID_NAME == GetLastError()))
|
2004-06-14 18:54:42 +02:00
|
|
|
|
trace("this test requires a default printer to be set\n");
|
|
|
|
|
else {
|
|
|
|
|
ok( 0, "function call GetDefaultPrinterA failed unexpected!\n"
|
2004-03-07 04:46:54 +01:00
|
|
|
|
"function returned %s\n"
|
2004-06-14 18:54:42 +02:00
|
|
|
|
"last error 0x%08lx\n"
|
2004-03-07 04:46:54 +01:00
|
|
|
|
"returned buffer size 0x%08lx\n"
|
|
|
|
|
"returned buffer content %s\n",
|
2004-06-14 18:54:42 +02:00
|
|
|
|
retval ? "true" : "false", GetLastError(), exact, buffer);
|
|
|
|
|
}
|
2004-03-07 04:46:54 +01:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
SetLastError(ERROR_SUCCESS);
|
2005-12-12 13:02:15 +01:00
|
|
|
|
retval = pGetDefaultPrinterA(NULL, NULL);
|
2004-03-07 04:46:54 +01:00
|
|
|
|
ok( !retval, "function result wrong! False expected\n");
|
|
|
|
|
ok( ERROR_INVALID_PARAMETER == GetLastError(),
|
|
|
|
|
"Last error wrong! ERROR_INVALID_PARAMETER expected, got 0x%08lx\n",
|
|
|
|
|
GetLastError());
|
|
|
|
|
|
|
|
|
|
SetLastError(ERROR_SUCCESS);
|
2005-12-12 13:02:15 +01:00
|
|
|
|
retval = pGetDefaultPrinterA(buffer, NULL);
|
2004-03-07 04:46:54 +01:00
|
|
|
|
ok( !retval, "function result wrong! False expected\n");
|
|
|
|
|
ok( ERROR_INVALID_PARAMETER == GetLastError(),
|
|
|
|
|
"Last error wrong! ERROR_INVALID_PARAMETER expected, got 0x%08lx\n",
|
|
|
|
|
GetLastError());
|
|
|
|
|
|
|
|
|
|
SetLastError(ERROR_SUCCESS);
|
|
|
|
|
size = 0;
|
2005-12-12 13:02:15 +01:00
|
|
|
|
retval = pGetDefaultPrinterA(NULL, &size);
|
2004-03-07 04:46:54 +01:00
|
|
|
|
ok( !retval, "function result wrong! False expected\n");
|
|
|
|
|
ok( ERROR_INSUFFICIENT_BUFFER == GetLastError(),
|
|
|
|
|
"Last error wrong! ERROR_INSUFFICIENT_BUFFER expected, got 0x%08lx\n",
|
|
|
|
|
GetLastError());
|
|
|
|
|
ok( size == exact, "Parameter size wrong! %ld expected got %ld\n",
|
|
|
|
|
exact, size);
|
|
|
|
|
|
|
|
|
|
SetLastError(ERROR_SUCCESS);
|
|
|
|
|
size = DEFAULT_PRINTER_SIZE;
|
2005-12-12 13:02:15 +01:00
|
|
|
|
retval = pGetDefaultPrinterA(NULL, &size);
|
2004-03-07 04:46:54 +01:00
|
|
|
|
ok( !retval, "function result wrong! False expected\n");
|
|
|
|
|
ok( ERROR_INSUFFICIENT_BUFFER == GetLastError(),
|
|
|
|
|
"Last error wrong! ERROR_INSUFFICIENT_BUFFER expected, got 0x%08lx\n",
|
|
|
|
|
GetLastError());
|
|
|
|
|
ok( size == exact, "Parameter size wrong! %ld expected got %ld\n",
|
|
|
|
|
exact, size);
|
|
|
|
|
|
|
|
|
|
size = 0;
|
2005-12-12 13:02:15 +01:00
|
|
|
|
retval = pGetDefaultPrinterA(buffer, &size);
|
2004-03-07 04:46:54 +01:00
|
|
|
|
ok( !retval, "function result wrong! False expected\n");
|
|
|
|
|
ok( ERROR_INSUFFICIENT_BUFFER == GetLastError(),
|
|
|
|
|
"Last error wrong! ERROR_INSUFFICIENT_BUFFER expected, got 0x%08lx\n",
|
|
|
|
|
GetLastError());
|
|
|
|
|
ok( size == exact, "Parameter size wrong! %ld expected got %ld\n",
|
|
|
|
|
exact, size);
|
|
|
|
|
|
|
|
|
|
size = exact;
|
2005-12-12 13:02:15 +01:00
|
|
|
|
retval = pGetDefaultPrinterA(buffer, &size);
|
2004-03-07 04:46:54 +01:00
|
|
|
|
ok( retval, "function result wrong! True expected\n");
|
|
|
|
|
ok( size == exact, "Parameter size wrong! %ld expected got %ld\n",
|
|
|
|
|
exact, size);
|
|
|
|
|
}
|
|
|
|
|
|
2006-02-01 12:32:10 +01:00
|
|
|
|
static void test_GetPrinterDriverDirectory(void)
|
|
|
|
|
{
|
2006-08-19 17:15:59 +02:00
|
|
|
|
LPBYTE buffer = NULL;
|
|
|
|
|
DWORD cbBuf = 0, pcbNeeded = 0;
|
|
|
|
|
BOOL res;
|
2006-09-10 19:01:30 +02:00
|
|
|
|
|
2003-01-15 01:50:48 +01:00
|
|
|
|
|
2006-02-02 13:50:36 +01:00
|
|
|
|
SetLastError(MAGIC_DEAD);
|
2004-06-16 22:07:02 +02:00
|
|
|
|
res = GetPrinterDriverDirectoryA( NULL, NULL, 1, NULL, 0, &cbBuf);
|
2006-02-02 13:50:36 +01:00
|
|
|
|
trace("first call returned 0x%04x, with %ld: buffer size 0x%08lx\n",
|
|
|
|
|
res, GetLastError(), cbBuf);
|
2003-01-15 01:50:48 +01:00
|
|
|
|
|
2006-02-02 13:50:36 +01:00
|
|
|
|
RETURN_ON_DEACTIVATED_SPOOLER(res)
|
2005-11-15 17:51:45 +01:00
|
|
|
|
ok((res == 0) && (GetLastError() == ERROR_INSUFFICIENT_BUFFER),
|
|
|
|
|
"returned %d with lasterror=%ld (expected '0' with " \
|
|
|
|
|
"ERROR_INSUFFICIENT_BUFFER)\n", res, GetLastError());
|
|
|
|
|
|
2005-10-26 12:08:38 +02:00
|
|
|
|
if (!cbBuf) {
|
|
|
|
|
trace("no valid buffer size returned, skipping tests\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2003-01-15 01:50:48 +01:00
|
|
|
|
buffer = HeapAlloc( GetProcessHeap(), 0, cbBuf*2);
|
2005-11-15 17:51:45 +01:00
|
|
|
|
if (buffer == NULL) return ;
|
2003-01-15 01:50:48 +01:00
|
|
|
|
|
|
|
|
|
res = GetPrinterDriverDirectoryA(NULL, NULL, 1, buffer, cbBuf, &pcbNeeded);
|
2004-01-23 03:10:33 +01:00
|
|
|
|
ok( res, "expected result != 0, got %d\n", res);
|
|
|
|
|
ok( cbBuf == pcbNeeded, "pcbNeeded set to %ld instead of %ld\n",
|
2003-01-15 01:50:48 +01:00
|
|
|
|
pcbNeeded, cbBuf);
|
|
|
|
|
|
|
|
|
|
res = GetPrinterDriverDirectoryA(NULL, NULL, 1, buffer, cbBuf*2, &pcbNeeded);
|
2004-01-23 03:10:33 +01:00
|
|
|
|
ok( res, "expected result != 0, got %d\n", res);
|
|
|
|
|
ok( cbBuf == pcbNeeded, "pcbNeeded set to %ld instead of %ld\n",
|
2003-01-15 01:50:48 +01:00
|
|
|
|
pcbNeeded, cbBuf);
|
|
|
|
|
|
2006-02-02 13:50:36 +01:00
|
|
|
|
SetLastError(MAGIC_DEAD);
|
2003-01-15 01:50:48 +01:00
|
|
|
|
res = GetPrinterDriverDirectoryA( NULL, NULL, 1, buffer, cbBuf-1, &pcbNeeded);
|
2004-01-23 03:10:33 +01:00
|
|
|
|
ok( !res , "expected result == 0, got %d\n", res);
|
|
|
|
|
ok( cbBuf == pcbNeeded, "pcbNeeded set to %ld instead of %ld\n",
|
2003-01-15 01:50:48 +01:00
|
|
|
|
pcbNeeded, cbBuf);
|
2006-01-18 12:26:32 +01:00
|
|
|
|
|
2003-01-15 01:50:48 +01:00
|
|
|
|
ok( ERROR_INSUFFICIENT_BUFFER == GetLastError(),
|
2004-01-23 03:10:33 +01:00
|
|
|
|
"last error set to %ld instead of ERROR_INSUFFICIENT_BUFFER\n",
|
2003-01-15 01:50:48 +01:00
|
|
|
|
GetLastError());
|
2006-01-18 12:26:32 +01:00
|
|
|
|
|
2006-02-02 13:50:36 +01:00
|
|
|
|
/*
|
|
|
|
|
Do not add the next test:
|
|
|
|
|
XPsp2: crash in this app, when the spooler is not running
|
|
|
|
|
NT3.5: ERROR_INVALID_USER_BUFFER
|
|
|
|
|
win9x: ERROR_INVALID_PARAMETER
|
|
|
|
|
|
|
|
|
|
pcbNeeded = MAGIC_DEAD;
|
|
|
|
|
SetLastError(MAGIC_DEAD);
|
2003-01-15 01:50:48 +01:00
|
|
|
|
res = GetPrinterDriverDirectoryA( NULL, NULL, 1, NULL, cbBuf, &pcbNeeded);
|
2006-02-02 13:50:36 +01:00
|
|
|
|
*/
|
2003-01-15 01:50:48 +01:00
|
|
|
|
|
2006-02-02 13:50:36 +01:00
|
|
|
|
SetLastError(MAGIC_DEAD);
|
2003-01-15 01:50:48 +01:00
|
|
|
|
res = GetPrinterDriverDirectoryA( NULL, NULL, 1, buffer, cbBuf, NULL);
|
2003-01-24 01:45:21 +01:00
|
|
|
|
ok( (!res && RPC_X_NULL_REF_POINTER == GetLastError()) || res,
|
|
|
|
|
"expected either result == 0 and "
|
|
|
|
|
"last error == RPC_X_NULL_REF_POINTER or result != 0 "
|
2004-01-23 03:10:33 +01:00
|
|
|
|
"got result %d and last error == %ld\n", res, GetLastError());
|
2003-01-15 01:50:48 +01:00
|
|
|
|
|
2006-02-02 13:50:36 +01:00
|
|
|
|
SetLastError(MAGIC_DEAD);
|
2003-01-15 01:50:48 +01:00
|
|
|
|
res = GetPrinterDriverDirectoryA( NULL, NULL, 1, NULL, cbBuf, NULL);
|
2006-02-02 13:50:36 +01:00
|
|
|
|
ok(res || (GetLastError() == RPC_X_NULL_REF_POINTER),
|
|
|
|
|
"returned %d with %ld (expected '!=0' or '0' with " \
|
2006-02-06 20:58:14 +01:00
|
|
|
|
"RPC_X_NULL_REF_POINTER)\n", res, GetLastError());
|
2006-02-02 13:50:36 +01:00
|
|
|
|
|
|
|
|
|
|
2005-11-23 20:14:43 +01:00
|
|
|
|
/* with a valid buffer, but level is too large */
|
2005-11-15 17:51:45 +01:00
|
|
|
|
buffer[0] = '\0';
|
2006-02-02 13:50:36 +01:00
|
|
|
|
SetLastError(MAGIC_DEAD);
|
2005-11-15 17:51:45 +01:00
|
|
|
|
res = GetPrinterDriverDirectoryA(NULL, NULL, 2, buffer, cbBuf, &pcbNeeded);
|
|
|
|
|
|
|
|
|
|
/* Level not checked in win9x and wine:*/
|
|
|
|
|
if((res != FALSE) && buffer[0])
|
|
|
|
|
{
|
2006-02-02 13:50:36 +01:00
|
|
|
|
trace("Level '2' not checked '%s'\n", buffer);
|
2005-11-15 17:51:45 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ok( !res && (GetLastError() == ERROR_INVALID_LEVEL),
|
|
|
|
|
"returned %d with lasterror=%ld (expected '0' with " \
|
|
|
|
|
"ERROR_INVALID_LEVEL)\n", res, GetLastError());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* printing environments are case insensitive */
|
|
|
|
|
/* "Windows 4.0" is valid for win9x and NT */
|
|
|
|
|
buffer[0] = '\0';
|
2006-02-02 13:50:36 +01:00
|
|
|
|
SetLastError(MAGIC_DEAD);
|
2005-11-15 17:51:45 +01:00
|
|
|
|
res = GetPrinterDriverDirectoryA(NULL, env_win9x_case, 1,
|
|
|
|
|
buffer, cbBuf*2, &pcbNeeded);
|
|
|
|
|
|
|
|
|
|
if(!res && (GetLastError() == ERROR_INSUFFICIENT_BUFFER)) {
|
|
|
|
|
cbBuf = pcbNeeded;
|
|
|
|
|
buffer = HeapReAlloc(GetProcessHeap(), 0, buffer, cbBuf*2);
|
|
|
|
|
if (buffer == NULL) return ;
|
|
|
|
|
|
2006-02-02 13:50:36 +01:00
|
|
|
|
SetLastError(MAGIC_DEAD);
|
2005-11-15 17:51:45 +01:00
|
|
|
|
res = GetPrinterDriverDirectoryA(NULL, env_win9x_case, 1,
|
|
|
|
|
buffer, cbBuf*2, &pcbNeeded);
|
|
|
|
|
}
|
2006-01-18 12:26:32 +01:00
|
|
|
|
|
2005-11-15 17:51:45 +01:00
|
|
|
|
ok(res && buffer[0], "returned %d with " \
|
2006-01-18 12:26:32 +01:00
|
|
|
|
"lasterror=%ld and len=%d (expected '1' with 'len > 0')\n",
|
2005-11-15 17:51:45 +01:00
|
|
|
|
res, GetLastError(), lstrlenA((char *)buffer));
|
|
|
|
|
|
|
|
|
|
buffer[0] = '\0';
|
2006-02-02 13:50:36 +01:00
|
|
|
|
SetLastError(MAGIC_DEAD);
|
2005-11-15 17:51:45 +01:00
|
|
|
|
res = GetPrinterDriverDirectoryA(NULL, env_x86, 1,
|
|
|
|
|
buffer, cbBuf*2, &pcbNeeded);
|
|
|
|
|
|
|
|
|
|
if(!res && (GetLastError() == ERROR_INSUFFICIENT_BUFFER)) {
|
|
|
|
|
cbBuf = pcbNeeded;
|
|
|
|
|
buffer = HeapReAlloc(GetProcessHeap(), 0, buffer, cbBuf*2);
|
|
|
|
|
if (buffer == NULL) return ;
|
|
|
|
|
|
|
|
|
|
buffer[0] = '\0';
|
2006-02-02 13:50:36 +01:00
|
|
|
|
SetLastError(MAGIC_DEAD);
|
2005-11-15 17:51:45 +01:00
|
|
|
|
res = GetPrinterDriverDirectoryA(NULL, env_x86, 1,
|
|
|
|
|
buffer, cbBuf*2, &pcbNeeded);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* "Windows NT x86" is invalid for win9x */
|
|
|
|
|
ok( (res && buffer[0]) ||
|
|
|
|
|
(!res && (GetLastError() == ERROR_INVALID_ENVIRONMENT)),
|
|
|
|
|
"returned %d with lasterror=%ld and len=%d (expected '!= 0' with " \
|
|
|
|
|
"'len > 0' or '0' with ERROR_INVALID_ENVIRONMENT)\n",
|
|
|
|
|
res, GetLastError(), lstrlenA((char *)buffer));
|
|
|
|
|
|
2006-02-01 12:32:10 +01:00
|
|
|
|
/* A Setup-Programm (PDFCreator_0.8.0) use empty strings */
|
|
|
|
|
SetLastError(MAGIC_DEAD);
|
2006-08-19 17:15:59 +02:00
|
|
|
|
res = GetPrinterDriverDirectoryA(empty, empty, 1, buffer, cbBuf*2, &pcbNeeded);
|
2006-02-01 12:32:10 +01:00
|
|
|
|
ok(res, "returned %d with %ld (expected '!=0')\n", res, GetLastError() );
|
|
|
|
|
|
|
|
|
|
SetLastError(MAGIC_DEAD);
|
2006-08-19 17:15:59 +02:00
|
|
|
|
res = GetPrinterDriverDirectoryA(NULL, empty, 1, buffer, cbBuf*2, &pcbNeeded);
|
2006-02-01 12:32:10 +01:00
|
|
|
|
ok(res, "returned %d with %ld (expected '!=0')\n", res, GetLastError() );
|
|
|
|
|
|
|
|
|
|
SetLastError(MAGIC_DEAD);
|
2006-08-19 17:15:59 +02:00
|
|
|
|
res = GetPrinterDriverDirectoryA(empty, NULL, 1, buffer, cbBuf*2, &pcbNeeded);
|
2006-02-01 12:32:10 +01:00
|
|
|
|
ok(res, "returned %d with %ld (expected '!=0')\n", res, GetLastError() );
|
|
|
|
|
|
2003-01-15 01:50:48 +01:00
|
|
|
|
HeapFree( GetProcessHeap(), 0, buffer);
|
|
|
|
|
}
|
|
|
|
|
|
2006-06-09 21:54:19 +02:00
|
|
|
|
/* ##### */
|
|
|
|
|
|
|
|
|
|
static void test_GetPrintProcessorDirectory(void)
|
|
|
|
|
{
|
2006-08-19 17:15:59 +02:00
|
|
|
|
LPBYTE buffer = NULL;
|
|
|
|
|
DWORD cbBuf = 0;
|
|
|
|
|
DWORD pcbNeeded = 0;
|
|
|
|
|
BOOL res;
|
2006-09-10 19:01:30 +02:00
|
|
|
|
|
2006-06-09 21:54:19 +02:00
|
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
|
res = GetPrintProcessorDirectoryA(NULL, NULL, 1, NULL, 0, &cbBuf);
|
|
|
|
|
/* The deactivated Spooler is catched here on NT3.51 */
|
|
|
|
|
RETURN_ON_DEACTIVATED_SPOOLER(res)
|
|
|
|
|
ok( !res && (GetLastError() == ERROR_INSUFFICIENT_BUFFER),
|
|
|
|
|
"returned %d with %ld (expected '0' with ERROR_INSUFFICIENT_BUFFER)\n",
|
|
|
|
|
res, GetLastError());
|
|
|
|
|
|
|
|
|
|
buffer = HeapAlloc(GetProcessHeap(), 0, cbBuf*2);
|
|
|
|
|
if(buffer == NULL) return;
|
|
|
|
|
|
|
|
|
|
buffer[0] = '\0';
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
|
res = GetPrintProcessorDirectoryA(NULL, NULL, 1, buffer, cbBuf, &pcbNeeded);
|
|
|
|
|
ok(res, "returned %d with %ld (expected '!= 0')\n", res, GetLastError());
|
|
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
|
buffer[0] = '\0';
|
|
|
|
|
res = GetPrintProcessorDirectoryA(NULL, NULL, 1, buffer, cbBuf*2, &pcbNeeded);
|
|
|
|
|
ok(res, "returned %d with %ld (expected '!= 0')\n", res, GetLastError());
|
|
|
|
|
|
|
|
|
|
/* Buffer to small */
|
|
|
|
|
buffer[0] = '\0';
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
|
res = GetPrintProcessorDirectoryA( NULL, NULL, 1, buffer, cbBuf-1, &pcbNeeded);
|
|
|
|
|
ok( !res && (GetLastError() == ERROR_INSUFFICIENT_BUFFER),
|
|
|
|
|
"returned %d with %ld (expected '0' with ERROR_INSUFFICIENT_BUFFER)\n",
|
|
|
|
|
res, GetLastError());
|
|
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
|
/* XPsp2: the programm will crash here, when the spooler is not running */
|
|
|
|
|
/* GetPrinterDriverDirectory has the same bug */
|
|
|
|
|
pcbNeeded = 0;
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
|
res = GetPrintProcessorDirectoryA( NULL, NULL, 1, NULL, cbBuf, &pcbNeeded);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
buffer[0] = '\0';
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
|
res = GetPrintProcessorDirectoryA( NULL, NULL, 1, buffer, cbBuf, NULL);
|
|
|
|
|
/* NT: RPC_X_NULL_REF_POINTER, 9x: res != 0 */
|
|
|
|
|
ok( res || (GetLastError() == RPC_X_NULL_REF_POINTER),
|
|
|
|
|
"returned %d with %ld (expected '!= 0' or '0' with " \
|
|
|
|
|
"RPC_X_NULL_REF_POINTER)\n", res, GetLastError());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
buffer[0] = '\0';
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
|
res = GetPrintProcessorDirectoryA( NULL, NULL, 1, NULL, cbBuf, NULL);
|
|
|
|
|
/* NT: RPC_X_NULL_REF_POINTER, 9x: res != 0 */
|
|
|
|
|
ok( res || (GetLastError() == RPC_X_NULL_REF_POINTER),
|
|
|
|
|
"returned %d with %ld (expected '!= 0' or '0' with " \
|
|
|
|
|
"RPC_X_NULL_REF_POINTER)\n", res, GetLastError());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* with a valid buffer, but level is invalid */
|
|
|
|
|
buffer[0] = '\0';
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
|
res = GetPrintProcessorDirectoryA(NULL, NULL, 2, buffer, cbBuf, &pcbNeeded);
|
|
|
|
|
if (res && buffer[0])
|
|
|
|
|
{
|
|
|
|
|
/* Level is ignored in win9x*/
|
|
|
|
|
trace("invalid level (2) was ignored\n");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ok( !res && (GetLastError() == ERROR_INVALID_LEVEL),
|
|
|
|
|
"returned %d with %ld (expected '0' with ERROR_INVALID_LEVEL)\n",
|
|
|
|
|
res, GetLastError());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Empty environment is the same as the default environment */
|
|
|
|
|
buffer[0] = '\0';
|
|
|
|
|
SetLastError(0xdeadbeef);
|
2006-08-19 17:15:59 +02:00
|
|
|
|
res = GetPrintProcessorDirectoryA(NULL, empty, 1, buffer, cbBuf*2, &pcbNeeded);
|
2006-06-09 21:54:19 +02:00
|
|
|
|
ok(res, "returned %d with %ld (expected '!= 0')\n", res, GetLastError());
|
|
|
|
|
|
|
|
|
|
/* "Windows 4.0" is valid for win9x and NT */
|
|
|
|
|
buffer[0] = '\0';
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
|
res = GetPrintProcessorDirectoryA(NULL, env_win9x_case, 1, buffer, cbBuf*2, &pcbNeeded);
|
|
|
|
|
ok(res, "returned %d with %ld (expected '!= 0')\n", res, GetLastError());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* "Windows NT x86" is invalid for win9x */
|
|
|
|
|
buffer[0] = '\0';
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
|
res = GetPrintProcessorDirectoryA(NULL, env_x86, 1, buffer, cbBuf*2, &pcbNeeded);
|
|
|
|
|
ok( res || (GetLastError() == ERROR_INVALID_ENVIRONMENT),
|
|
|
|
|
"returned %d with %ld (expected '!= 0' or '0' with " \
|
|
|
|
|
"ERROR_INVALID_ENVIRONMENT)\n", res, GetLastError());
|
|
|
|
|
|
|
|
|
|
/* invalid on all Systems */
|
|
|
|
|
buffer[0] = '\0';
|
|
|
|
|
SetLastError(0xdeadbeef);
|
2006-08-19 17:15:59 +02:00
|
|
|
|
res = GetPrintProcessorDirectoryA(NULL, invalid_env, 1, buffer, cbBuf*2, &pcbNeeded);
|
2006-06-09 21:54:19 +02:00
|
|
|
|
ok( !res && (GetLastError() == ERROR_INVALID_ENVIRONMENT),
|
|
|
|
|
"returned %d with %ld (expected '0' with ERROR_INVALID_ENVIRONMENT)\n",
|
|
|
|
|
res, GetLastError());
|
|
|
|
|
|
|
|
|
|
/* Empty servername is the same as the local computer */
|
|
|
|
|
buffer[0] = '\0';
|
|
|
|
|
SetLastError(0xdeadbeef);
|
2006-08-19 17:15:59 +02:00
|
|
|
|
res = GetPrintProcessorDirectoryA(empty, NULL, 1, buffer, cbBuf*2, &pcbNeeded);
|
2006-06-09 21:54:19 +02:00
|
|
|
|
ok(res, "returned %d with %ld (expected '!= 0')\n", res, GetLastError());
|
|
|
|
|
|
|
|
|
|
/* invalid on all Systems */
|
|
|
|
|
buffer[0] = '\0';
|
|
|
|
|
SetLastError(0xdeadbeef);
|
2006-08-19 17:15:59 +02:00
|
|
|
|
res = GetPrintProcessorDirectoryA(invalid_server, NULL, 1, buffer, cbBuf*2, &pcbNeeded);
|
2006-06-09 21:54:19 +02:00
|
|
|
|
ok( !res && (GetLastError() == ERROR_INVALID_PARAMETER),
|
|
|
|
|
"returned %d with %ld (expected '0' with ERROR_INVALID_PARAMETER)\n",
|
|
|
|
|
res, GetLastError());
|
|
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, buffer);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ##### */
|
|
|
|
|
|
2006-02-01 12:32:10 +01:00
|
|
|
|
static void test_OpenPrinter(void)
|
2005-12-12 13:02:15 +01:00
|
|
|
|
{
|
2006-08-19 17:15:59 +02:00
|
|
|
|
PRINTER_DEFAULTSA defaults;
|
|
|
|
|
HANDLE hprinter;
|
|
|
|
|
LPSTR default_printer;
|
|
|
|
|
DWORD res;
|
|
|
|
|
DWORD size;
|
|
|
|
|
CHAR buffer[DEFAULT_PRINTER_SIZE];
|
|
|
|
|
LPSTR ptr;
|
2006-09-10 19:01:30 +02:00
|
|
|
|
|
2005-12-12 13:02:15 +01:00
|
|
|
|
|
|
|
|
|
SetLastError(MAGIC_DEAD);
|
|
|
|
|
res = OpenPrinter(NULL, NULL, NULL);
|
2006-02-02 13:50:36 +01:00
|
|
|
|
/* The deactivated Spooler is catched here on NT3.51 */
|
|
|
|
|
RETURN_ON_DEACTIVATED_SPOOLER(res)
|
2005-12-12 13:02:15 +01:00
|
|
|
|
ok(!res && (GetLastError() == ERROR_INVALID_PARAMETER),
|
|
|
|
|
"returned %ld with %ld (expected '0' with ERROR_INVALID_PARAMETER)\n",
|
|
|
|
|
res, GetLastError());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Get Handle for the local Printserver (NT only)*/
|
|
|
|
|
hprinter = (HANDLE) MAGIC_DEAD;
|
|
|
|
|
SetLastError(MAGIC_DEAD);
|
|
|
|
|
res = OpenPrinter(NULL, &hprinter, NULL);
|
2006-02-02 13:50:36 +01:00
|
|
|
|
/* The deactivated Spooler is catched here on XPsp2 */
|
|
|
|
|
RETURN_ON_DEACTIVATED_SPOOLER(res)
|
2005-12-12 13:02:15 +01:00
|
|
|
|
ok(res || (!res && GetLastError() == ERROR_INVALID_PARAMETER),
|
|
|
|
|
"returned %ld with %ld (expected '!=0' or '0' with ERROR_INVALID_PARAMETER)\n",
|
|
|
|
|
res, GetLastError());
|
|
|
|
|
if(res) {
|
|
|
|
|
ClosePrinter(hprinter);
|
|
|
|
|
|
|
|
|
|
defaults.pDatatype=NULL;
|
|
|
|
|
defaults.pDevMode=NULL;
|
|
|
|
|
|
|
|
|
|
defaults.DesiredAccess=0;
|
|
|
|
|
hprinter = (HANDLE) MAGIC_DEAD;
|
|
|
|
|
SetLastError(MAGIC_DEAD);
|
|
|
|
|
res = OpenPrinter(NULL, &hprinter, &defaults);
|
|
|
|
|
ok(res, "returned %ld with %ld (expected '!=0')\n", res, GetLastError());
|
|
|
|
|
if (res) ClosePrinter(hprinter);
|
|
|
|
|
|
|
|
|
|
defaults.DesiredAccess=-1;
|
|
|
|
|
hprinter = (HANDLE) MAGIC_DEAD;
|
|
|
|
|
SetLastError(MAGIC_DEAD);
|
|
|
|
|
res = OpenPrinter(NULL, &hprinter, &defaults);
|
2006-05-11 19:57:48 +02:00
|
|
|
|
todo_wine {
|
2005-12-12 13:02:15 +01:00
|
|
|
|
ok(!res && GetLastError() == ERROR_ACCESS_DENIED,
|
|
|
|
|
"returned %ld with %ld (expected '0' with ERROR_ACCESS_DENIED)\n",
|
|
|
|
|
res, GetLastError());
|
2006-05-11 19:57:48 +02:00
|
|
|
|
}
|
2005-12-12 13:02:15 +01:00
|
|
|
|
if (res) ClosePrinter(hprinter);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
size = sizeof(buffer) - 3 ;
|
|
|
|
|
ptr = buffer;
|
|
|
|
|
ptr[0] = '\\';
|
|
|
|
|
ptr++;
|
|
|
|
|
ptr[0] = '\\';
|
|
|
|
|
ptr++;
|
|
|
|
|
if (GetComputerNameA(ptr, &size)) {
|
|
|
|
|
|
|
|
|
|
hprinter = (HANDLE) MAGIC_DEAD;
|
|
|
|
|
SetLastError(MAGIC_DEAD);
|
|
|
|
|
res = OpenPrinter(buffer, &hprinter, NULL);
|
|
|
|
|
todo_wine {
|
|
|
|
|
ok(res || (!res && GetLastError() == ERROR_INVALID_PARAMETER),
|
|
|
|
|
"returned %ld with %ld (expected '!=0' or '0' with ERROR_INVALID_PARAMETER)\n",
|
|
|
|
|
res, GetLastError());
|
|
|
|
|
}
|
|
|
|
|
if(res) ClosePrinter(hprinter);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Invalid Printername */
|
|
|
|
|
hprinter = (HANDLE) MAGIC_DEAD;
|
|
|
|
|
SetLastError(MAGIC_DEAD);
|
2006-08-19 17:15:59 +02:00
|
|
|
|
res = OpenPrinter(illegal_name, &hprinter, NULL);
|
2005-12-12 13:02:15 +01:00
|
|
|
|
ok(!res && ((GetLastError() == ERROR_INVALID_PRINTER_NAME) ||
|
|
|
|
|
(GetLastError() == ERROR_INVALID_PARAMETER) ),
|
|
|
|
|
"returned %ld with %ld (expected '0' with: ERROR_INVALID_PARAMETER or" \
|
|
|
|
|
"ERROR_INVALID_PRINTER_NAME)\n", res, GetLastError());
|
|
|
|
|
if(res) ClosePrinter(hprinter);
|
|
|
|
|
|
2006-05-11 19:57:48 +02:00
|
|
|
|
hprinter = (HANDLE) MAGIC_DEAD;
|
|
|
|
|
SetLastError(MAGIC_DEAD);
|
2006-08-19 17:15:59 +02:00
|
|
|
|
res = OpenPrinter(empty, &hprinter, NULL);
|
2006-05-11 19:57:48 +02:00
|
|
|
|
/* NT: ERROR_INVALID_PRINTER_NAME, 9x: ERROR_INVALID_PARAMETER */
|
|
|
|
|
ok( !res &&
|
|
|
|
|
((GetLastError() == ERROR_INVALID_PRINTER_NAME) ||
|
|
|
|
|
(GetLastError() == ERROR_INVALID_PARAMETER) ),
|
|
|
|
|
"returned %ld with %ld (expected '0' with: ERROR_INVALID_PRINTER_NAME" \
|
|
|
|
|
" or ERROR_INVALID_PARAMETER)\n", res, GetLastError());
|
|
|
|
|
if(res) ClosePrinter(hprinter);
|
|
|
|
|
|
2005-12-12 13:02:15 +01:00
|
|
|
|
|
|
|
|
|
/* Get Handle for the default Printer */
|
|
|
|
|
if ((default_printer = find_default_printer()))
|
|
|
|
|
{
|
|
|
|
|
hprinter = (HANDLE) MAGIC_DEAD;
|
|
|
|
|
SetLastError(MAGIC_DEAD);
|
|
|
|
|
res = OpenPrinter(default_printer, &hprinter, NULL);
|
2006-02-02 13:50:36 +01:00
|
|
|
|
if((!res) && (GetLastError() == RPC_S_SERVER_UNAVAILABLE))
|
|
|
|
|
{
|
2006-05-11 19:57:48 +02:00
|
|
|
|
trace("The Service 'Spooler' is required for '%s'\n", default_printer);
|
2006-02-02 13:50:36 +01:00
|
|
|
|
return;
|
|
|
|
|
}
|
2005-12-12 13:02:15 +01:00
|
|
|
|
ok(res, "returned %ld with %ld (expected '!=0')\n", res, GetLastError());
|
|
|
|
|
if(res) ClosePrinter(hprinter);
|
|
|
|
|
|
2006-05-11 19:57:48 +02:00
|
|
|
|
SetLastError(MAGIC_DEAD);
|
|
|
|
|
res = OpenPrinter(default_printer, NULL, NULL);
|
|
|
|
|
/* NT: FALSE with ERROR_INVALID_PARAMETER, 9x: TRUE */
|
|
|
|
|
ok(res || (GetLastError() == ERROR_INVALID_PARAMETER),
|
|
|
|
|
"returned %ld with %ld (expected '!=0' or '0' with " \
|
|
|
|
|
"ERROR_INVALID_PARAMETER)\n", res, GetLastError());
|
|
|
|
|
|
2005-12-12 13:02:15 +01:00
|
|
|
|
defaults.pDatatype=NULL;
|
|
|
|
|
defaults.pDevMode=NULL;
|
|
|
|
|
defaults.DesiredAccess=0;
|
|
|
|
|
|
|
|
|
|
hprinter = (HANDLE) MAGIC_DEAD;
|
|
|
|
|
SetLastError(MAGIC_DEAD);
|
|
|
|
|
res = OpenPrinter(default_printer, &hprinter, &defaults);
|
2006-02-02 13:50:36 +01:00
|
|
|
|
ok(res || GetLastError() == ERROR_ACCESS_DENIED,
|
|
|
|
|
"returned %ld with %ld (expected '!=0' or '0' with " \
|
|
|
|
|
"ERROR_ACCESS_DENIED)\n", res, GetLastError());
|
2005-12-12 13:02:15 +01:00
|
|
|
|
if(res) ClosePrinter(hprinter);
|
|
|
|
|
|
2006-07-12 23:31:46 +02:00
|
|
|
|
defaults.pDatatype = empty;
|
2005-12-12 13:02:15 +01:00
|
|
|
|
|
|
|
|
|
hprinter = (HANDLE) MAGIC_DEAD;
|
|
|
|
|
SetLastError(MAGIC_DEAD);
|
|
|
|
|
res = OpenPrinter(default_printer, &hprinter, &defaults);
|
2006-02-23 16:03:32 +01:00
|
|
|
|
/* stop here, when a remote Printserver has no RPC-Service running */
|
|
|
|
|
RETURN_ON_DEACTIVATED_SPOOLER(res)
|
2006-02-02 13:50:36 +01:00
|
|
|
|
ok(res || ((GetLastError() == ERROR_INVALID_DATATYPE) ||
|
|
|
|
|
(GetLastError() == ERROR_ACCESS_DENIED)),
|
2005-12-19 21:19:47 +01:00
|
|
|
|
"returned %ld with %ld (expected '!=0' or '0' with: " \
|
2006-02-02 13:50:36 +01:00
|
|
|
|
"ERROR_INVALID_DATATYPE or ERROR_ACCESS_DENIED)\n",
|
2005-12-12 13:02:15 +01:00
|
|
|
|
res, GetLastError());
|
|
|
|
|
if(res) ClosePrinter(hprinter);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
defaults.pDatatype=NULL;
|
|
|
|
|
defaults.DesiredAccess=PRINTER_ACCESS_USE;
|
|
|
|
|
|
|
|
|
|
hprinter = (HANDLE) MAGIC_DEAD;
|
|
|
|
|
SetLastError(MAGIC_DEAD);
|
|
|
|
|
res = OpenPrinter(default_printer, &hprinter, &defaults);
|
2006-02-02 13:50:36 +01:00
|
|
|
|
ok(res || GetLastError() == ERROR_ACCESS_DENIED,
|
|
|
|
|
"returned %ld with %ld (expected '!=0' or '0' with " \
|
|
|
|
|
"ERROR_ACCESS_DENIED)\n", res, GetLastError());
|
2005-12-12 13:02:15 +01:00
|
|
|
|
if(res) ClosePrinter(hprinter);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
defaults.DesiredAccess=PRINTER_ALL_ACCESS;
|
|
|
|
|
hprinter = (HANDLE) MAGIC_DEAD;
|
|
|
|
|
SetLastError(MAGIC_DEAD);
|
|
|
|
|
res = OpenPrinter(default_printer, &hprinter, &defaults);
|
2006-02-02 13:50:36 +01:00
|
|
|
|
ok(res || GetLastError() == ERROR_ACCESS_DENIED,
|
|
|
|
|
"returned %ld with %ld (expected '!=0' or '0' with " \
|
|
|
|
|
"ERROR_ACCESS_DENIED)\n", res, GetLastError());
|
2005-12-12 13:02:15 +01:00
|
|
|
|
if(res) ClosePrinter(hprinter);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2006-02-20 11:51:10 +01:00
|
|
|
|
|
|
|
|
|
static void test_SetDefaultPrinter(void)
|
|
|
|
|
{
|
|
|
|
|
DWORD res;
|
|
|
|
|
LPSTR default_printer;
|
|
|
|
|
DWORD size = DEFAULT_PRINTER_SIZE;
|
|
|
|
|
CHAR buffer[DEFAULT_PRINTER_SIZE];
|
|
|
|
|
CHAR org_value[DEFAULT_PRINTER_SIZE];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!pSetDefaultPrinterA) return;
|
|
|
|
|
/* only supported on win2k and above */
|
|
|
|
|
|
|
|
|
|
default_printer = find_default_printer();
|
|
|
|
|
|
|
|
|
|
/* backup the original value */
|
|
|
|
|
org_value[0] = '\0';
|
|
|
|
|
SetLastError(MAGIC_DEAD);
|
|
|
|
|
res = GetProfileStringA("windows", "device", NULL, org_value, size);
|
|
|
|
|
|
|
|
|
|
/* first part: with the default Printer */
|
|
|
|
|
SetLastError(MAGIC_DEAD);
|
|
|
|
|
res = pSetDefaultPrinterA("no_printer_with_this_name");
|
|
|
|
|
|
|
|
|
|
RETURN_ON_DEACTIVATED_SPOOLER(res)
|
|
|
|
|
/* spooler is running or we have no spooler here*/
|
|
|
|
|
|
|
|
|
|
/* Not implemented in wine */
|
|
|
|
|
if (!res && (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)) {
|
|
|
|
|
trace("SetDefaultPrinterA() not implemented yet.\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ok(!res && (GetLastError() == ERROR_INVALID_PRINTER_NAME),
|
|
|
|
|
"returned %ld with %ld (expected '0' with " \
|
|
|
|
|
"ERROR_INVALID_PRINTER_NAME)\n", res, GetLastError());
|
|
|
|
|
|
|
|
|
|
WriteProfileStringA("windows", "device", org_value);
|
|
|
|
|
SetLastError(MAGIC_DEAD);
|
|
|
|
|
res = pSetDefaultPrinterA("");
|
|
|
|
|
ok(res || (!res && (GetLastError() == ERROR_INVALID_PRINTER_NAME)),
|
|
|
|
|
"returned %ld with %ld (expected '!=0' or '0' with " \
|
|
|
|
|
"ERROR_INVALID_PRINTER_NAME)\n", res, GetLastError());
|
|
|
|
|
|
|
|
|
|
WriteProfileStringA("windows", "device", org_value);
|
|
|
|
|
SetLastError(MAGIC_DEAD);
|
|
|
|
|
res = pSetDefaultPrinterA(NULL);
|
|
|
|
|
ok(res || (!res && (GetLastError() == ERROR_INVALID_PRINTER_NAME)),
|
|
|
|
|
"returned %ld with %ld (expected '!=0' or '0' with " \
|
|
|
|
|
"ERROR_INVALID_PRINTER_NAME)\n", res, GetLastError());
|
|
|
|
|
|
|
|
|
|
WriteProfileStringA("windows", "device", org_value);
|
|
|
|
|
SetLastError(MAGIC_DEAD);
|
|
|
|
|
res = pSetDefaultPrinterA(default_printer);
|
|
|
|
|
ok(res || (!res && (GetLastError() == ERROR_INVALID_PRINTER_NAME)),
|
|
|
|
|
"returned %ld with %ld (expected '!=0' or '0' with " \
|
|
|
|
|
"ERROR_INVALID_PRINTER_NAME)\n", res, GetLastError());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* second part: always without a default Printer */
|
|
|
|
|
WriteProfileStringA("windows", "device", NULL);
|
|
|
|
|
SetLastError(MAGIC_DEAD);
|
|
|
|
|
res = pSetDefaultPrinterA("no_printer_with_this_name");
|
|
|
|
|
|
|
|
|
|
ok(!res && (GetLastError() == ERROR_INVALID_PRINTER_NAME),
|
|
|
|
|
"returned %ld with %ld (expected '0' with " \
|
|
|
|
|
"ERROR_INVALID_PRINTER_NAME)\n", res, GetLastError());
|
|
|
|
|
|
|
|
|
|
WriteProfileStringA("windows", "device", NULL);
|
|
|
|
|
SetLastError(MAGIC_DEAD);
|
|
|
|
|
res = pSetDefaultPrinterA("");
|
|
|
|
|
/* we get ERROR_INVALID_PRINTER_NAME when no printer is installed */
|
|
|
|
|
ok(res || (!res && (GetLastError() == ERROR_INVALID_PRINTER_NAME)),
|
|
|
|
|
"returned %ld with %ld (expected '!=0' or '0' with " \
|
|
|
|
|
"ERROR_INVALID_PRINTER_NAME)\n", res, GetLastError());
|
|
|
|
|
|
|
|
|
|
WriteProfileStringA("windows", "device", NULL);
|
|
|
|
|
SetLastError(MAGIC_DEAD);
|
|
|
|
|
res = pSetDefaultPrinterA(NULL);
|
|
|
|
|
/* we get ERROR_INVALID_PRINTER_NAME when no printer is installed */
|
|
|
|
|
ok(res || (!res && (GetLastError() == ERROR_INVALID_PRINTER_NAME)),
|
|
|
|
|
"returned %ld with %ld (expected '!=0' or '0' with " \
|
|
|
|
|
"ERROR_INVALID_PRINTER_NAME)\n", res, GetLastError());
|
|
|
|
|
|
|
|
|
|
WriteProfileStringA("windows", "device", NULL);
|
|
|
|
|
SetLastError(MAGIC_DEAD);
|
|
|
|
|
res = pSetDefaultPrinterA(default_printer);
|
|
|
|
|
ok(res || (!res && (GetLastError() == ERROR_INVALID_PRINTER_NAME)),
|
|
|
|
|
"returned %ld with %ld (expected '!=0' or '0' with " \
|
|
|
|
|
"ERROR_INVALID_PRINTER_NAME)\n", res, GetLastError());
|
|
|
|
|
|
|
|
|
|
/* restore the original value */
|
|
|
|
|
res = pSetDefaultPrinterA(default_printer); /* the nice way */
|
|
|
|
|
WriteProfileStringA("windows", "device", org_value); /* the old way */
|
|
|
|
|
|
|
|
|
|
buffer[0] = '\0';
|
|
|
|
|
SetLastError(MAGIC_DEAD);
|
|
|
|
|
res = GetProfileStringA("windows", "device", NULL, buffer, size);
|
|
|
|
|
ok(!lstrcmpA(org_value, buffer), "'%s' (expected '%s')\n", buffer, org_value);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2006-04-14 15:34:57 +02:00
|
|
|
|
static void test_GetPrinterDriver(void)
|
|
|
|
|
{
|
|
|
|
|
LPSTR default_printer;
|
|
|
|
|
HANDLE hprn;
|
|
|
|
|
BOOL ret;
|
|
|
|
|
BYTE *buf;
|
|
|
|
|
INT level;
|
|
|
|
|
DWORD needed, filled;
|
|
|
|
|
|
|
|
|
|
default_printer = find_default_printer();
|
|
|
|
|
if (!default_printer)
|
|
|
|
|
{
|
|
|
|
|
trace("There is no default printer installed, skiping the test\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
hprn = 0;
|
|
|
|
|
ret = OpenPrinter(default_printer, &hprn, NULL);
|
|
|
|
|
if (!ret)
|
|
|
|
|
{
|
|
|
|
|
trace("There is no printers installed, skiping the test\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
ok(hprn != 0, "wrong hprn %p\n", hprn);
|
|
|
|
|
|
|
|
|
|
for (level = -1; level <= 7; level++)
|
|
|
|
|
{
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
|
needed = (DWORD)-1;
|
|
|
|
|
ret = GetPrinterDriver(hprn, NULL, level, NULL, 0, &needed);
|
|
|
|
|
ok(!ret, "level %d: GetPrinterDriver should fail\n", level);
|
|
|
|
|
if (level >= 1 && level <= 6)
|
|
|
|
|
{
|
2006-05-02 05:58:36 +02:00
|
|
|
|
/* Not all levels are supported on all Windows-Versions */
|
|
|
|
|
if(GetLastError() == ERROR_INVALID_LEVEL) continue;
|
2006-04-14 15:34:57 +02:00
|
|
|
|
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "wrong error %ld\n", GetLastError());
|
|
|
|
|
ok(needed > 0,"not expected needed buffer size %ld\n", needed);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2006-05-02 05:58:36 +02:00
|
|
|
|
/* ERROR_OUTOFMEMORY found on win9x */
|
|
|
|
|
ok( ((GetLastError() == ERROR_INVALID_LEVEL) ||
|
|
|
|
|
(GetLastError() == ERROR_OUTOFMEMORY)),
|
|
|
|
|
"%d: returned %d with %ld (expected '0' with: " \
|
|
|
|
|
"ERROR_INVALID_LEVEL or ERROR_OUTOFMEMORY)\n",
|
|
|
|
|
level, ret, GetLastError());
|
|
|
|
|
/* needed is modified in win9x. The modified Value depends on the
|
|
|
|
|
default Printer. testing for "needed == (DWORD)-1" will fail */
|
2006-04-14 15:34:57 +02:00
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
buf = HeapAlloc(GetProcessHeap(), 0, needed);
|
|
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
|
filled = -1;
|
|
|
|
|
ret = GetPrinterDriver(hprn, NULL, level, buf, needed, &filled);
|
|
|
|
|
ok(ret, "level %d: GetPrinterDriver error %ld\n", level, GetLastError());
|
|
|
|
|
ok(needed == filled, "needed %ld != filled %ld\n", needed, filled);
|
|
|
|
|
|
|
|
|
|
if (level == 2)
|
|
|
|
|
{
|
|
|
|
|
DRIVER_INFO_2 *di_2 = (DRIVER_INFO_2 *)buf;
|
|
|
|
|
DWORD calculated = sizeof(*di_2);
|
|
|
|
|
|
2006-05-02 05:58:36 +02:00
|
|
|
|
/* MSDN is wrong: The Drivers on the win9x-CD's have cVersion=0x0400
|
|
|
|
|
NT351: 1, NT4.0+w2k(Kernelmode): 2, w2k and above(Usermode): 3 */
|
|
|
|
|
ok((di_2->cVersion >= 0 && di_2->cVersion <= 3) ||
|
|
|
|
|
(di_2->cVersion == 0x0400), "di_2->cVersion = %ld\n", di_2->cVersion);
|
2006-04-14 15:34:57 +02:00
|
|
|
|
ok(di_2->pName != NULL, "not expected NULL ptr\n");
|
|
|
|
|
ok(di_2->pEnvironment != NULL, "not expected NULL ptr\n");
|
|
|
|
|
ok(di_2->pDriverPath != NULL, "not expected NULL ptr\n");
|
|
|
|
|
ok(di_2->pDataFile != NULL, "not expected NULL ptr\n");
|
|
|
|
|
ok(di_2->pConfigFile != NULL, "not expected NULL ptr\n");
|
|
|
|
|
|
|
|
|
|
trace("cVersion %ld\n", di_2->cVersion);
|
|
|
|
|
trace("pName %s\n", di_2->pName);
|
|
|
|
|
calculated += strlen(di_2->pName) + 1;
|
|
|
|
|
trace("pEnvironment %s\n", di_2->pEnvironment);
|
|
|
|
|
calculated += strlen(di_2->pEnvironment) + 1;
|
|
|
|
|
trace("pDriverPath %s\n", di_2->pDriverPath);
|
|
|
|
|
calculated += strlen(di_2->pDriverPath) + 1;
|
|
|
|
|
trace("pDataFile %s\n", di_2->pDataFile);
|
|
|
|
|
calculated += strlen(di_2->pDataFile) + 1;
|
|
|
|
|
trace("pConfigFile %s\n", di_2->pConfigFile);
|
|
|
|
|
calculated += strlen(di_2->pConfigFile) + 1;
|
|
|
|
|
|
|
|
|
|
/* XP allocates memory for both ANSI and unicode names */
|
|
|
|
|
ok(filled >= calculated,"calculated %ld != filled %ld\n", calculated, filled);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, buf);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
|
ret = ClosePrinter(hprn);
|
|
|
|
|
ok(ret, "ClosePrinter error %ld\n", GetLastError());
|
|
|
|
|
}
|
2006-02-20 11:51:10 +01:00
|
|
|
|
|
2006-04-18 12:36:58 +02:00
|
|
|
|
static void test_DEVMODE(const DEVMODE *dm, LONG dmSize, LPCSTR exp_prn_name)
|
|
|
|
|
{
|
2006-05-02 00:03:51 +02:00
|
|
|
|
/* On NT3.51, some fields in DEVMODE are empty/zero
|
|
|
|
|
(dmDeviceName, dmSpecVersion, dmDriverVersion and dmDriverExtra)
|
|
|
|
|
We skip the Tests on this Platform */
|
|
|
|
|
if (dm->dmSpecVersion || dm->dmDriverVersion || dm->dmDriverExtra) {
|
2006-05-12 15:03:20 +02:00
|
|
|
|
/* The 0-terminated Printername can be larger (MAX_PATH) than CCHDEVICENAME */
|
|
|
|
|
ok(!strncmp(exp_prn_name, (LPCSTR)dm->dmDeviceName, CCHDEVICENAME -1),
|
2006-05-02 00:03:51 +02:00
|
|
|
|
"expected '%s', got '%s'\n", exp_prn_name, dm->dmDeviceName);
|
|
|
|
|
ok(dm->dmSize + dm->dmDriverExtra == dmSize,
|
|
|
|
|
"%u != %ld\n", dm->dmSize + dm->dmDriverExtra, dmSize);
|
|
|
|
|
}
|
2006-04-18 12:36:58 +02:00
|
|
|
|
trace("dmFields %08lx\n", dm->dmFields);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void test_DocumentProperties(void)
|
|
|
|
|
{
|
|
|
|
|
LPSTR default_printer;
|
|
|
|
|
HANDLE hprn;
|
|
|
|
|
LONG dm_size, ret;
|
|
|
|
|
DEVMODE *dm;
|
|
|
|
|
|
|
|
|
|
default_printer = find_default_printer();
|
|
|
|
|
if (!default_printer)
|
|
|
|
|
{
|
|
|
|
|
trace("There is no default printer installed, skiping the test\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
hprn = 0;
|
|
|
|
|
ret = OpenPrinter(default_printer, &hprn, NULL);
|
|
|
|
|
if (!ret)
|
|
|
|
|
{
|
|
|
|
|
trace("There is no printers installed, skiping the test\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
ok(hprn != 0, "wrong hprn %p\n", hprn);
|
|
|
|
|
|
|
|
|
|
dm_size = DocumentProperties(0, hprn, NULL, NULL, NULL, 0);
|
|
|
|
|
trace("DEVMODE required size %ld\n", dm_size);
|
|
|
|
|
ok(dm_size >= sizeof(DEVMODE), "unexpected DocumentProperties ret value %ld\n", dm_size);
|
|
|
|
|
|
|
|
|
|
dm = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dm_size);
|
|
|
|
|
|
|
|
|
|
ret = DocumentProperties(0, hprn, NULL, dm, dm, DM_OUT_BUFFER);
|
|
|
|
|
ok(ret == IDOK, "DocumentProperties ret value %ld != expected IDOK\n", ret);
|
|
|
|
|
|
|
|
|
|
test_DEVMODE(dm, dm_size, default_printer);
|
|
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, dm);
|
|
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
|
ret = ClosePrinter(hprn);
|
|
|
|
|
ok(ret, "ClosePrinter error %ld\n", GetLastError());
|
|
|
|
|
}
|
|
|
|
|
|
2003-01-15 01:50:48 +01:00
|
|
|
|
START_TEST(info)
|
|
|
|
|
{
|
2006-06-16 09:54:55 +02:00
|
|
|
|
LPSTR default_printer;
|
|
|
|
|
|
2005-12-12 13:02:15 +01:00
|
|
|
|
hwinspool = GetModuleHandleA("winspool.drv");
|
|
|
|
|
pGetDefaultPrinterA = (void *) GetProcAddress(hwinspool, "GetDefaultPrinterA");
|
2006-02-20 11:51:10 +01:00
|
|
|
|
pSetDefaultPrinterA = (void *) GetProcAddress(hwinspool, "SetDefaultPrinterA");
|
2005-12-12 13:02:15 +01:00
|
|
|
|
|
2006-06-16 09:54:55 +02:00
|
|
|
|
default_printer = find_default_printer();
|
2005-12-12 13:02:15 +01:00
|
|
|
|
|
2006-04-10 00:29:22 +02:00
|
|
|
|
test_AddMonitor();
|
2006-04-16 02:42:34 +02:00
|
|
|
|
test_DeleteMonitor();
|
2006-04-18 12:36:58 +02:00
|
|
|
|
test_DocumentProperties();
|
2006-06-16 09:54:55 +02:00
|
|
|
|
test_EnumForms(NULL);
|
|
|
|
|
if (default_printer) test_EnumForms(default_printer);
|
2006-02-17 17:37:04 +01:00
|
|
|
|
test_EnumMonitors();
|
2006-02-01 12:32:10 +01:00
|
|
|
|
test_GetDefaultPrinter();
|
|
|
|
|
test_GetPrinterDriverDirectory();
|
2006-06-09 21:54:19 +02:00
|
|
|
|
test_GetPrintProcessorDirectory();
|
2006-02-01 12:32:10 +01:00
|
|
|
|
test_OpenPrinter();
|
2006-04-14 15:34:57 +02:00
|
|
|
|
test_GetPrinterDriver();
|
2006-02-20 11:51:10 +01:00
|
|
|
|
test_SetDefaultPrinter();
|
2003-01-15 01:50:48 +01:00
|
|
|
|
}
|