localspl/tests: One more Test for InitializePrintMonitor (now
-Wcast-qual save)
Detlef Riekenberg
wine.dev at web.de
Sat Oct 14 05:26:05 CDT 2006
Changelog:
- localspl/tests: One more Test for InitializePrintMonitor
Updated to avoid compiler-warnings with "-Wcast-qual"
--
By by ... Detlef
-------------- next part --------------
Subject: [PATCH] localspl/tests: One more Test for InitializePrintMonitor
Updated to avoid compiler-warnings with "-Wcast-qual"
---
dlls/localspl/tests/Makefile.in | 2 +
dlls/localspl/tests/localmon.c | 56 ++++++++++++++++++++++++++++++++++++---
2 files changed, 52 insertions(+), 6 deletions(-)
d881b1f84b3153b68c1951636e43a951c4baf087
diff --git a/dlls/localspl/tests/Makefile.in b/dlls/localspl/tests/Makefile.in
index 2d70a62..49e849b 100644
--- a/dlls/localspl/tests/Makefile.in
+++ b/dlls/localspl/tests/Makefile.in
@@ -3,7 +3,7 @@ TOPOBJDIR = ../../..
SRCDIR = @srcdir@
VPATH = @srcdir@
TESTDLL = localspl.dll
-IMPORTS = kernel32
+IMPORTS = kernel32 advapi32
CTESTS = \
localmon.c
diff --git a/dlls/localspl/tests/localmon.c b/dlls/localspl/tests/localmon.c
index 72a7048..ad7a605 100644
--- a/dlls/localspl/tests/localmon.c
+++ b/dlls/localspl/tests/localmon.c
@@ -35,19 +35,35 @@
/* ##### */
-static HANDLE hdll;
+static HMODULE hdll;
static LPMONITOREX (WINAPI *pInitializePrintMonitor)(LPWSTR);
-static const WCHAR emptyW[] = {0};
+static LPMONITOREX pm = NULL;
+static WCHAR emptyW[] = {0};
+static WCHAR Monitors_LocalPortW[] = { \
+ 'S','y','s','t','e','m','\\',
+ 'C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\',
+ 'C','o','n','t','r','o','l','\\',
+ 'P','r','i','n','t','\\',
+ 'M','o','n','i','t','o','r','s','\\',
+ 'L','o','c','a','l',' ','P','o','r','t',0};
+static const WCHAR PortsW[] = {'P','o','r','t','s',0};
+static const WCHAR winetest_iniW[] = {'w','i','n','e','t','e','s','t','_','i','n','i',0};
+static const WCHAR winetest_regW[] = {'w','i','n','e','t','e','s','t','_','r','e','g',0};
+static const WCHAR WinNT_CV_PortsW[] = { \
+ 'S','o','f','t','w','a','r','e','\\',
+ 'M','i','c','r','o','s','o','f','t','\\',
+ 'W','i','n','d','o','w','s',' ','N','T','\\',
+ 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
+ 'P','o','r','t','s',0};
+
/* ##### */
static void test_InitializePrintMonitor(void)
{
LPMONITOREX res;
- if (!pInitializePrintMonitor) return;
-
SetLastError(0xdeadbeef);
res = pInitializePrintMonitor(NULL);
ok( (res == NULL) && (GetLastError() == ERROR_INVALID_PARAMETER),
@@ -55,18 +71,48 @@ static void test_InitializePrintMonitor(
"ERROR_INVALID_PARAMETER)\n", res, GetLastError());
SetLastError(0xdeadbeef);
- res = pInitializePrintMonitor((LPWSTR) emptyW);
+ res = pInitializePrintMonitor(emptyW);
ok( (res == NULL) && (GetLastError() == ERROR_INVALID_PARAMETER),
"returned %p with %d\n (expected NULL with " \
"ERROR_INVALID_PARAMETER)\n", res, GetLastError());
+
+ /* Every call with a non-empty string returns the same Pointer */
+ SetLastError(0xdeadbeef);
+ res = pInitializePrintMonitor(Monitors_LocalPortW);
+ ok( res == pm,
+ "returned %p with %d (expected %p)\n", res, GetLastError(), pm);
}
START_TEST(localmon)
{
+ HKEY hPorts;
+
hdll = LoadLibraryA("localspl.dll");
if (!hdll) return;
pInitializePrintMonitor = (void *) GetProcAddress(hdll, "InitializePrintMonitor");
+ if (pInitializePrintMonitor == NULL) return;
+
+ /* Native localmon / localspl.dll need a vaild Port-Entry in:
+ a) since xp: HKLM\Software\Microsoft\Windows NT\CurrentVersion\Ports
+ b) upto w2k: Section "Ports" in win.ini
+ or InitializePortMonitor fails.
+ (with IniFileMapping: Accessing location b is mapped to location a)
+ We create both entries to allow testing the native dlls in wine */
+
+ if (RegCreateKeyW(HKEY_LOCAL_MACHINE, WinNT_CV_PortsW, &hPorts) != ERROR_SUCCESS) return;
+
+ /* This can fail with ERROR_ACCESS_DENIED on windows, but we do not care,
+ because several entries are created during Windows Installation */
+ RegSetValueExW(hPorts, winetest_regW, 0, REG_SZ, (LPBYTE) emptyW, sizeof(emptyW));
+ WriteProfileStringW(PortsW, winetest_iniW, emptyW);
+
+ pm = pInitializePrintMonitor(Monitors_LocalPortW);
test_InitializePrintMonitor();
+
+ /* Cleanup */
+ WriteProfileStringW(PortsW, winetest_iniW, NULL);
+ RegDeleteValueW(hPorts, winetest_regW);
+ RegCloseKey(hPorts);
}
--
1.1.3
More information about the wine-patches
mailing list