Detlef Riekenberg : localui/tests: Add tests for AddPortUI.

Alexandre Julliard julliard at wine.codeweavers.com
Fri May 25 14:43:27 CDT 2007


Module: wine
Branch: master
Commit: 189719c1bb79ad3e15a7d6ff0183c283a64dda84
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=189719c1bb79ad3e15a7d6ff0183c283a64dda84

Author: Detlef Riekenberg <wine.dev at web.de>
Date:   Thu May 24 17:27:51 2007 +0200

localui/tests: Add tests for AddPortUI.

---

 dlls/localui/tests/localui.c |   57 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 57 insertions(+), 0 deletions(-)

diff --git a/dlls/localui/tests/localui.c b/dlls/localui/tests/localui.c
index 414d8d3..7965d3c 100644
--- a/dlls/localui/tests/localui.c
+++ b/dlls/localui/tests/localui.c
@@ -48,6 +48,7 @@ static WCHAR does_not_existW[] = {'d','o','e','s','_','n','o','t','_','e','x','i
 static WCHAR emptyW[] = {0};
 static CHAR  fmt_comA[] = {'C','O','M','%','u',':',0};
 static CHAR  fmt_lptA[] = {'L','P','T','%','u',':',0};
+static WCHAR localportW[] = {'L','o','c','a','l',' ','P','o','r','t',0};
 static WCHAR portname_fileW[] = {'F','I','L','E',':',0};
 
 static LPBYTE pi_buffer;
@@ -123,6 +124,61 @@ static LPWSTR strdupW(LPCWSTR strW)
 
 /* ########################### */
 
+static void test_AddPortUI(void)
+{
+    DWORD   res;
+    LPWSTR  new_portname;
+
+    /* not present before w2k */
+    if (!pAddPortUI) {
+        skip("AddPortUI not found\n");
+        return;
+    }
+
+    SetLastError(0xdeadbeef);
+    res = pAddPortUI(NULL, NULL, NULL, NULL);
+    ok( !res && (GetLastError() == ERROR_UNKNOWN_PORT),
+        "got %d with %u (expected '0' with ERROR_UNKNOWN_PORT)\n",
+        res, GetLastError());
+
+    SetLastError(0xdeadbeef);
+    res = pAddPortUI(NULL, NULL, emptyW, NULL);
+    ok( !res && (GetLastError() == ERROR_UNKNOWN_PORT),
+        "got %d with %u (expected '0' with ERROR_UNKNOWN_PORT)\n",
+        res, GetLastError());
+
+    SetLastError(0xdeadbeef);
+    res = pAddPortUI(NULL, NULL, does_not_existW, NULL);
+    ok( !res && (GetLastError() == ERROR_UNKNOWN_PORT),
+        "got %d with %u (expected '0' with ERROR_UNKNOWN_PORT)\n",
+        res, GetLastError());
+
+    if (winetest_interactive) {
+        SetLastError(0xdeadbeef);
+        new_portname = NULL;
+        /*
+         * - On MSDN, you can read, that no dialogs should be displayed, when hWnd
+         *   is NULL, but native localui does not care
+         * - when the new port already exist,
+         *   TRUE is returned, but new_portname is NULL
+         * - when the new port starts with "COM" or "LPT",
+         *   FALSE is returned with ERROR_NOT_SUPPORTED in windows
+         */
+        res = pAddPortUI(NULL, NULL, localportW, &new_portname);
+        ok( res ||
+            (GetLastError() == ERROR_CANCELLED) ||
+            (GetLastError() == ERROR_ACCESS_DENIED) ||
+            (GetLastError() == ERROR_NOT_SUPPORTED),
+            "got %d with %u and %p (expected '!= 0' or '0' with: "
+            "ERROR_CANCELLED, ERROR_ACCESS_DENIED or ERROR_NOT_SUPPORTED)\n",
+            res, GetLastError(), new_portname);
+
+        GlobalFree(new_portname);
+    }
+}
+
+/* ########################### */
+
 static void test_ConfigurePortUI(void)
 {
     DWORD   res;
@@ -255,6 +311,7 @@ START_TEST(localui)
     /* "FILE:" */
     file_present = find_portinfo2(portname_fileW);
 
+    test_AddPortUI();
     test_ConfigurePortUI();
 
     /* cleanup */




More information about the wine-cvs mailing list