winscard/tests: Implement test for functions of winscard.dll
Sergey Stepanov
serg_admin at rambler.ru
Wed May 11 06:41:29 CDT 2011
---
configure | 1 +
dlls/winscard/tests/Makefile.in | 7 +++
dlls/winscard/tests/winscard_api.c | 90 ++++++++++++++++++++++++++++++++++++
3 files changed, 98 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 4866321..41349da 100755
--- a/configure
+++ b/configure
@@ -15495,6 +15495,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..bd7d6bb
--- /dev/null
+++ b/dlls/winscard/tests/Makefile.in
@@ -0,0 +1,7 @@
+TESTDLL = winscard.dll
+IMPORTS = winscard advapi32
+
+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..a4ad7a8
--- /dev/null
+++ b/dlls/winscard/tests/winscard_api.c
@@ -0,0 +1,90 @@
+/*
+ * Unit test suite for smart card Functions
+ *
+ * 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 "winsvc.h"
+#include "vfw.h"
+#include "wine/test.h"
+#include "winscard.h"
+#include "shellapi.h"
+
+void test_winscard_api(void){
+ SCARDCONTEXT context;
+ LONG EstablishContext_rezult;
+ LONG IsValidContext_rezult;
+ LONG ReleaseContext_rezult;
+ todo_wine {
+
+ EstablishContext_rezult = SCardEstablishContext(0,NULL,NULL, &context);
+ ok((EstablishContext_rezult == SCARD_S_SUCCESS)||
+ (EstablishContext_rezult == SCARD_E_NO_SERVICE),
+ "Can't connect to service SCardSvr(pcscd daemon) not started 0x%X\n", EstablishContext_rezult);
+
+ if (EstablishContext_rezult == SCARD_S_SUCCESS){
+ IsValidContext_rezult = SCardIsValidContext(context);
+ ok(IsValidContext_rezult == SCARD_S_SUCCESS,
+ "Error call SCardIsValidContext 0x%X\n", IsValidContext_rezult);
+ }
+ else {
+ skip("Test for SCardIsValidContext skiped because service SCardSvr(pcsc daemon) not started EstablishContext rezult = 0x%X\n",
+ EstablishContext_rezult);
+ }
+
+ if (EstablishContext_rezult == SCARD_S_SUCCESS){
+ ReleaseContext_rezult = SCardReleaseContext(context);
+ ok(ReleaseContext_rezult == SCARD_S_SUCCESS,
+ "Error call SCardReleaseContext 0x%X\n", ReleaseContext_rezult);
+ }
+ else {
+ skip("Test for SCardReleaseContext skiped because service SCardSvr(pcsc daemon) not started EstablishContext rezult = 0x%X\n",
+ EstablishContext_rezult);
+ }
+ }
+
+}
+
+START_TEST(winscard_api){
+
+ /* Start service for work with smart cards */
+ SERVICE_STATUS srvStatus;
+ SC_HANDLE SCManager = OpenSCManager(NULL,NULL,SC_MANAGER_CONNECT);
+ SC_HANDLE hService = OpenService(SCManager, "SCardSvr", SERVICE_START);
+ BOOL statStartService = StartService(hService, 0, NULL);
+
+ /*wait until the start smart cards service */
+ hService = OpenService(SCManager, "SCardSvr", SERVICE_QUERY_STATUS);
+ while(QueryServiceStatus(hService, &srvStatus)) {
+ if (srvStatus.dwCurrentState != SERVICE_START_PENDING) break;
+ }
+
+ /* Running test */
+ test_winscard_api();
+
+ /*if we started service wi need stoping service*/
+ hService = OpenService(SCManager, "SCardSvr", SERVICE_STOP);
+ if (statStartService) {
+ ControlService(hService,SERVICE_CONTROL_STOP, &srvStatus);
+ }
+}
--
1.7.4.1
More information about the wine-patches
mailing list