winscard/tests: Add test base functions of winscard.dll

Sergey Stepanov serg_admin at rambler.ru
Wed May 4 05:35:24 CDT 2011


---
 configure                          |    1 +
 dlls/winscard/tests/Makefile.in    |    7 ++++
 dlls/winscard/tests/winscard_api.c |   71 ++++++++++++++++++++++++++++++++++++
 3 files changed, 79 insertions(+), 0 deletions(-)
 create mode 100644 dlls/winscard/tests/Makefile.in
 create mode 100644 dlls/winscard/tests/winscard_api.c

diff --git a/configure b/configure
index b742bfd..f787e82 100755
--- a/configure
+++ b/configure
@@ -15493,6 +15493,7 @@ wine_fn_config_test dlls/winmm/tests winmm_test
 wine_fn_config_dll winnls.dll16 enable_win16
 wine_fn_config_dll winnls32 enable_winnls32 implib
 wine_fn_config_dll winscard enable_winscard implib
+wine_fn_config_test dlls/winscard/tests winscard_test
 wine_fn_config_dll winsock.dll16 enable_win16
 wine_fn_config_dll winspool.drv enable_winspool_drv po,implib winspool
 wine_fn_config_test dlls/winspool.drv/tests winspool.drv_test
diff --git a/dlls/winscard/tests/Makefile.in b/dlls/winscard/tests/Makefile.in
new file mode 100644
index 0000000..aa58d2e
--- /dev/null
+++ b/dlls/winscard/tests/Makefile.in
@@ -0,0 +1,7 @@
+TESTDLL   = winscard.dll
+IMPORTS   = winscard
+
+C_SRCS = \
+	winscard_api.c
+
+ at MAKE_TEST_RULES@
diff --git a/dlls/winscard/tests/winscard_api.c b/dlls/winscard/tests/winscard_api.c
new file mode 100644
index 0000000..29fc22d
--- /dev/null
+++ b/dlls/winscard/tests/winscard_api.c
@@ -0,0 +1,71 @@
+/*
+ * Unit test suite for AVI Functions
+ *
+ * Copyright 2008 Detlef Riekenberg
+ *
+ * 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
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ *
+ */
+
+#include <stdarg.h>
+
+#include "windef.h"
+#include "winbase.h"
+#include "winerror.h"
+#include "wingdi.h"
+#include "vfw.h"
+#include "wine/test.h"
+#include "winscard.h"
+
+
+START_TEST(winscard_api)
+{
+    SCARDCONTEXT context;
+    LPSTR mszReaders = NULL;
+    DWORD cchReaders = 0;
+    SCARDHANDLE hCard;
+    DWORD dwActiveProtocol;
+    SCARD_READERSTATE rgReaderStates;
+    
+    LONG winscard_rezult = SCardEstablishContext(0,NULL,NULL, &context);
+    ok(winscard_rezult != SCARD_F_INTERNAL_ERROR, "Library libpcsclite not load. SCARD_F_INTERNAL_ERROR\n");
+    if (winscard_rezult == SCARD_E_NO_SERVICE)    {
+	trace("Can't connect to service. Maybe daemon <pcscd> not started. Run command <pcscd -f>\n");
+	skip("Get list readers skip because service <pcscd> not avalable SCARD_E_NO_SERVICE\n");
+    } else if (winscard_rezult != SCARD_S_SUCCESS) {
+	trace("Error connect to service <%ix>. See error in scarderr.h\n", winscard_rezult);
+	skip("Get list readers skip because service <pcscd> not avalable <%ix>\n", winscard_rezult);
+    } 
+    else {
+	winscard_rezult = SCardListReadersA(context, NULL, mszReaders, &cchReaders);
+	ok(winscard_rezult != SCARD_F_INTERNAL_ERROR, "Error call SCardGetListReaders. SCARD_F_INTERNAL_ERROR\n");
+        if (winscard_rezult != SCARD_S_SUCCESS) {
+	    trace("Error SCardListReadersA <%ix>. See error in scarderr.h\n", winscard_rezult);
+	    skip("SCardConnectA skip because readers not avalable\n");
+	} 
+	else {
+	    mszReaders = malloc(cchReaders);
+	    winscard_rezult = SCardListReadersA(context, NULL, mszReaders, &cchReaders);
+	    rgReaderStates.szReader = mszReaders;
+	    rgReaderStates.dwCurrentState = 0;
+	    winscard_rezult = SCardGetStatusChangeA(context, 200, &rgReaderStates, 1);
+	    ok(winscard_rezult != SCARD_F_INTERNAL_ERROR, "Error call SCardGetStatusChangeA. SCARD_F_INTERNAL_ERROR\n");
+        }
+        ok(SCARD_F_INTERNAL_ERROR != SCardReleaseContext(context), "Error call SCardReleaseContext. SCARD_F_INTERNAL_ERROR\n"); 
+        if (winscard_rezult != SCARD_S_SUCCESS) {
+	    trace("Error SCardReleaseContext <%ix>. See error in scarderr.h\n", winscard_rezult);
+	}
+    }
+}
-- 
1.7.4.1




More information about the wine-patches mailing list