localspl/tests: Another test for InitializePrintMonitor

Detlef Riekenberg wine.dev at web.de
Thu Oct 19 16:27:28 CDT 2006


Changelog:
- localspl/tests: Another test for InitializePrintMonitor

"-Wcast-qual" - clean


-- 
 
By by ... Detlef

-------------- next part --------------
Subject: [PATCH] localspl/tests: Another test for InitializePrintMonitor

---

 dlls/localspl/tests/localmon.c |   31 ++++++++++++++++++++++++++-----
 1 files changed, 26 insertions(+), 5 deletions(-)

c42afb3ddcc374f6f69999c6b3a5521157e3e9aa
diff --git a/dlls/localspl/tests/localmon.c b/dlls/localspl/tests/localmon.c
index 72a7048..60d07b7 100644
--- a/dlls/localspl/tests/localmon.c
+++ b/dlls/localspl/tests/localmon.c
@@ -35,19 +35,26 @@
 
 /* ##### */
 
-static HANDLE  hdll;
+static HMODULE  hdll;
 static LPMONITOREX (WINAPI *pInitializePrintMonitor)(LPWSTR);
 
-static const WCHAR emptyW[] =    {0};
+static LPMONITOREX pm;
 
+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 void test_InitializePrintMonitor(void)
 {
     LPMONITOREX res;
 
-    if (!pInitializePrintMonitor) return;
-
     SetLastError(0xdeadbeef);
     res = pInitializePrintMonitor(NULL);
     ok( (res == NULL) && (GetLastError() == ERROR_INVALID_PARAMETER),
@@ -55,18 +62,32 @@ 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)
 {
+    /* This DLL does not exists on Win9x */
     hdll = LoadLibraryA("localspl.dll");
     if (!hdll) return;
 
     pInitializePrintMonitor = (void *) GetProcAddress(hdll, "InitializePrintMonitor");
+    if (!pInitializePrintMonitor) return;
+
+    /* Native localmon.dll / 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 InitializePrintMonitor fails. */
+    pm = pInitializePrintMonitor(Monitors_LocalPortW);
     test_InitializePrintMonitor();
 }
-- 
1.1.3


More information about the wine-patches mailing list