[WINSPOOL_APITEST]
authorColin Finck <colin@reactos.org>
Sun, 24 May 2015 16:55:20 +0000 (16:55 +0000)
committerColin Finck <colin@reactos.org>
Sun, 24 May 2015 16:55:20 +0000 (16:55 +0000)
Make the tests actually succeed under Windows Server 2003.

svn path=/branches/colins-printing-for-freedom/; revision=67884

rostests/apitests/winspool/EnumPrintProcessorDatatypes.c
rostests/apitests/winspool/GetPrintProcessorDirectory.c
rostests/apitests/winspool/OpenPrinter.c
rostests/apitests/winspool/StartDocPrinter.c

index 29c7977..f2005c7 100644 (file)
@@ -16,6 +16,7 @@
 START_TEST(EnumPrintProcessorDatatypes)
 {
     DWORD cbNeeded;
+    DWORD cbTemp;
     DWORD dwReturned;
     PDATATYPES_INFO_1W pDatatypesInfo1;
 
@@ -45,22 +46,28 @@ START_TEST(EnumPrintProcessorDatatypes)
     ok(!EnumPrintProcessorDatatypesW(NULL, L"wInPrInT", 1, NULL, 0, &cbNeeded, &dwReturned), "EnumPrintProcessorDatatypesW returns TRUE!\n");
     ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "EnumPrintProcessorDatatypesW returns error %lu!\n", GetLastError());
     ok(cbNeeded > 0, "cbNeeded is 0!\n");
-    ok(dwReturned > 0, "dwReturned is 0!\n");
+    ok(dwReturned == 0, "dwReturned is %lu!\n", dwReturned);
 
     // Now provide the demanded size, but no buffer.
     SetLastError(0xDEADBEEF);
-    ok(!EnumPrintProcessorDatatypesW(NULL, L"wInPrInT", 1, NULL, cbNeeded, &cbNeeded, &dwReturned), "EnumPrintProcessorDatatypesW returns TRUE!\n");
+    ok(!EnumPrintProcessorDatatypesW(NULL, L"wInPrInT", 1, NULL, cbNeeded, &cbTemp, &dwReturned), "EnumPrintProcessorDatatypesW returns TRUE!\n");
     ok(GetLastError() == ERROR_INVALID_USER_BUFFER, "EnumPrintProcessorDatatypesW returns error %lu!\n", GetLastError());
+    ok(cbTemp == 0, "cbTemp is %lu!\n", cbTemp);
+    ok(dwReturned == 0, "dwReturned is %lu!\n", dwReturned);
 
     // This also has to fail the same way when no Print Processor was given at all.
     SetLastError(0xDEADBEEF);
-    ok(!EnumPrintProcessorDatatypesW(NULL, NULL, 1, NULL, cbNeeded, &cbNeeded, &dwReturned), "EnumPrintProcessorDatatypesW returns TRUE!\n");
+    ok(!EnumPrintProcessorDatatypesW(NULL, NULL, 1, NULL, cbNeeded, &cbTemp, &dwReturned), "EnumPrintProcessorDatatypesW returns TRUE!\n");
     ok(GetLastError() == ERROR_INVALID_USER_BUFFER, "EnumPrintProcessorDatatypesW returns error %lu!\n", GetLastError());
+    ok(cbTemp == 0, "cbTemp is %lu!\n", cbTemp);
+    ok(dwReturned == 0, "dwReturned is %lu!\n", dwReturned);
 
     // Same error has to occur with a valid Print Processor, but a size too small.
     SetLastError(0xDEADBEEF);
-    ok(!EnumPrintProcessorDatatypesW(NULL, L"wInPrInT", 1, NULL, cbNeeded, &cbNeeded, &dwReturned), "EnumPrintProcessorDatatypesW returns TRUE!\n");
+    ok(!EnumPrintProcessorDatatypesW(NULL, L"wInPrInT", 1, NULL, cbNeeded, &cbTemp, &dwReturned), "EnumPrintProcessorDatatypesW returns TRUE!\n");
     ok(GetLastError() == ERROR_INVALID_USER_BUFFER, "EnumPrintProcessorDatatypesW returns error %lu!\n", GetLastError());
+    ok(cbTemp == 0, "cbTemp is %lu!\n", cbTemp);
+    ok(dwReturned == 0, "dwReturned is %lu!\n", dwReturned);
 
     // Finally use the function as intended and aim for success!
     pDatatypesInfo1 = HeapAlloc(GetProcessHeap(), 0, cbNeeded);
index bece06e..04d76d2 100644 (file)
@@ -16,6 +16,7 @@
 START_TEST(GetPrintProcessorDirectory)
 {
     DWORD cbNeeded;
+    DWORD cbTemp;
     PWSTR pwszBuffer;
 
     // Try with an invalid level, this needs to be caught first.
@@ -28,6 +29,12 @@ START_TEST(GetPrintProcessorDirectory)
     ok(!GetPrintProcessorDirectoryW(NULL, NULL, 1, NULL, 0, NULL), "GetPrintProcessorDirectoryW returns TRUE!\n");
     ok(GetLastError() == RPC_X_NULL_REF_POINTER, "GetPrintProcessorDirectoryW returns error %lu!\n", GetLastError());
 
+    // Try with an invalid environment as well.
+    SetLastError(0xDEADBEEF);
+    ok(!GetPrintProcessorDirectoryW(NULL, L"invalid", 1, NULL, 0, &cbNeeded), "GetPrintProcessorDirectoryW returns TRUE!\n");
+    ok(GetLastError() == ERROR_INVALID_ENVIRONMENT, "GetPrintProcessorDirectoryW returns error %lu!\n", GetLastError());
+    ok(cbNeeded == 0, "cbNeeded is %lu!\n", cbNeeded);
+
     // Now get the required buffer size by supplying pcbNeeded. This needs to fail with ERROR_INSUFFICIENT_BUFFER.
     SetLastError(0xDEADBEEF);
     ok(!GetPrintProcessorDirectoryW(NULL, NULL, 1, NULL, 0, &cbNeeded), "GetPrintProcessorDirectoryW returns TRUE!\n");
@@ -36,18 +43,15 @@ START_TEST(GetPrintProcessorDirectory)
 
     // Now provide the demanded size, but no buffer.
     SetLastError(0xDEADBEEF);
-    ok(!GetPrintProcessorDirectoryW(NULL, NULL, 1, NULL, cbNeeded, &cbNeeded), "GetPrintProcessorDirectoryW returns TRUE!\n");
+    ok(!GetPrintProcessorDirectoryW(NULL, NULL, 1, NULL, cbNeeded, &cbTemp), "GetPrintProcessorDirectoryW returns TRUE!\n");
     ok(GetLastError() == ERROR_INVALID_USER_BUFFER, "GetPrintProcessorDirectoryW returns error %lu!\n", GetLastError());
+    ok(cbTemp == 0, "cbNeeded is %lu!\n", cbNeeded);
 
     // Same error has to occur with a size too small.
     SetLastError(0xDEADBEEF);
-    ok(!GetPrintProcessorDirectoryW(NULL, NULL, 1, NULL, 1, &cbNeeded), "GetPrintProcessorDirectoryW returns TRUE!\n");
+    ok(!GetPrintProcessorDirectoryW(NULL, NULL, 1, NULL, 1, &cbTemp), "GetPrintProcessorDirectoryW returns TRUE!\n");
     ok(GetLastError() == ERROR_INVALID_USER_BUFFER, "GetPrintProcessorDirectoryW returns error %lu!\n", GetLastError());
-
-    // Try with an invalid environment as well.
-    SetLastError(0xDEADBEEF);
-    ok(!GetPrintProcessorDirectoryW(NULL, L"invalid", 1, NULL, 0, &cbNeeded), "GetPrintProcessorDirectoryW returns TRUE!\n");
-    ok(GetLastError() == ERROR_INVALID_ENVIRONMENT, "GetPrintProcessorDirectoryW returns error %lu!\n", GetLastError());
+    ok(cbTemp == 0, "cbNeeded is %lu!\n", cbNeeded);
 
     // Finally use the function as intended and aim for success!
     pwszBuffer = HeapAlloc(GetProcessHeap(), 0, cbNeeded);
index 7049edf..dfc5dde 100644 (file)
@@ -17,11 +17,14 @@ START_TEST(OpenPrinter)
 {
     HANDLE hPrinter;
 
+    // Give no handle at all, this has to fail
     SetLastError(0xDEADBEEF);
     ok(!OpenPrinterW(NULL, NULL, NULL), "OpenPrinterW returns TRUE!\n");
     ok(GetLastError() == ERROR_INVALID_PARAMETER, "OpenPrinterW returns error %lu!\n", GetLastError());
 
+    // Open a handle to the local print server
     SetLastError(0xDEADBEEF);
-    ok(!OpenPrinterW(NULL, &hPrinter, NULL), "OpenPrinterW returns TRUE!\n");
-    ok(GetLastError() == ERROR_INVALID_PARAMETER, "OpenPrinterW returns error %lu!\n", GetLastError());
+    ok(OpenPrinterW(NULL, &hPrinter, NULL), "OpenPrinterW returns FALSE!\n");
+    ok(GetLastError() == ERROR_SUCCESS, "OpenPrinterW returns error %lu!\n", GetLastError());
+    ClosePrinter(hPrinter);
 }
index 24af7dd..b4b5c43 100644 (file)
@@ -21,12 +21,12 @@ START_TEST(StartDocPrinter)
     SetLastError(0xDEADBEEF);
     dwResult = StartDocPrinterW(NULL, 0, NULL);
     ok(dwResult == 0, "StartDocPrinterW returns %lu!\n", dwResult);
-    ok(GetLastError() == ERROR_INVALID_PARAMETER, "StartDocPrinter returns error %lu!\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_HANDLE, "StartDocPrinter returns error %lu!\n", GetLastError());
 
     SetLastError(0xDEADBEEF);
     dwResult = StartDocPrinterW(NULL, 1, NULL);
     ok(dwResult == 0, "StartDocPrinterW returns %lu!\n", dwResult);
-    ok(GetLastError() == ERROR_INVALID_PARAMETER, "StartDocPrinter returns error %lu!\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_HANDLE, "StartDocPrinter returns error %lu!\n", GetLastError());
 
     SetLastError(0xDEADBEEF);
     dwResult = StartDocPrinterW(NULL, 0, (LPBYTE)&docInfo);