Zac Brown : winhttp/tests: Add test for opening request.
Alexandre Julliard
julliard at winehq.org
Fri Jul 18 06:47:02 CDT 2008
Module: wine
Branch: master
Commit: b2be840e47b2f967031e1bbf8e111ecc991869df
URL: http://source.winehq.org/git/wine.git/?a=commit;h=b2be840e47b2f967031e1bbf8e111ecc991869df
Author: Zac Brown <zac at zacbrown.org>
Date: Thu Jul 17 17:37:23 2008 -0700
winhttp/tests: Add test for opening request.
---
.gitignore | 1 +
Makefile.in | 2 +
configure | 3 +
configure.ac | 1 +
dlls/Makefile.in | 1 +
dlls/winhttp/tests/Makefile.in | 13 ++++++
dlls/winhttp/tests/winhttp.c | 80 ++++++++++++++++++++++++++++++++++++++++
programs/winetest/Makefile.in | 3 +
programs/winetest/winetest.rc | 1 +
9 files changed, 105 insertions(+), 0 deletions(-)
diff --git a/.gitignore b/.gitignore
index 44a8ce1..ab49a43 100644
--- a/.gitignore
+++ b/.gitignore
@@ -333,6 +333,7 @@ programs/winetest/usp10_test.exe
programs/winetest/uxtheme_test.exe
programs/winetest/version_test.exe
programs/winetest/winetest
+programs/winetest/winhttp_test.exe
programs/winetest/wininet_test.exe
programs/winetest/winmm_test.exe
programs/winetest/winspool.drv_test.exe
diff --git a/Makefile.in b/Makefile.in
index 6d54f68..1e7f4d8 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -496,6 +496,7 @@ ALL_MAKEFILES = \
dlls/winex11.drv/Makefile \
dlls/wing32/Makefile \
dlls/winhttp/Makefile \
+ dlls/winhttp/tests/Makefile \
dlls/wininet/Makefile \
dlls/wininet/tests/Makefile \
dlls/winmm/Makefile \
@@ -926,6 +927,7 @@ dlls/winequartz.drv/Makefile: dlls/winequartz.drv/Makefile.in dlls/Makedll.rules
dlls/winex11.drv/Makefile: dlls/winex11.drv/Makefile.in dlls/Makedll.rules
dlls/wing32/Makefile: dlls/wing32/Makefile.in dlls/Makedll.rules
dlls/winhttp/Makefile: dlls/winhttp/Makefile.in dlls/Makedll.rules
+dlls/winhttp/tests/Makefile: dlls/winhttp/tests/Makefile.in dlls/Maketest.rules
dlls/wininet/Makefile: dlls/wininet/Makefile.in dlls/Makedll.rules
dlls/wininet/tests/Makefile: dlls/wininet/tests/Makefile.in dlls/Maketest.rules
dlls/winmm/Makefile: dlls/winmm/Makefile.in dlls/Makedll.rules
diff --git a/configure b/configure
index 36832f3..5baf8dc 100755
--- a/configure
+++ b/configure
@@ -22418,6 +22418,8 @@ ac_config_files="$ac_config_files dlls/wing32/Makefile"
ac_config_files="$ac_config_files dlls/winhttp/Makefile"
+ac_config_files="$ac_config_files dlls/winhttp/tests/Makefile"
+
ac_config_files="$ac_config_files dlls/wininet/Makefile"
ac_config_files="$ac_config_files dlls/wininet/tests/Makefile"
@@ -23484,6 +23486,7 @@ do
"dlls/winex11.drv/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/winex11.drv/Makefile" ;;
"dlls/wing32/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/wing32/Makefile" ;;
"dlls/winhttp/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/winhttp/Makefile" ;;
+ "dlls/winhttp/tests/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/winhttp/tests/Makefile" ;;
"dlls/wininet/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/wininet/Makefile" ;;
"dlls/wininet/tests/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/wininet/tests/Makefile" ;;
"dlls/winmm/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/winmm/Makefile" ;;
diff --git a/configure.ac b/configure.ac
index 8ed54a8..a32bb73 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2038,6 +2038,7 @@ AC_CONFIG_FILES([dlls/winequartz.drv/Makefile])
AC_CONFIG_FILES([dlls/winex11.drv/Makefile])
AC_CONFIG_FILES([dlls/wing32/Makefile])
AC_CONFIG_FILES([dlls/winhttp/Makefile])
+AC_CONFIG_FILES([dlls/winhttp/tests/Makefile])
AC_CONFIG_FILES([dlls/wininet/Makefile])
AC_CONFIG_FILES([dlls/wininet/tests/Makefile])
AC_CONFIG_FILES([dlls/winmm/Makefile])
diff --git a/dlls/Makefile.in b/dlls/Makefile.in
index 73c823f..0eac4a0 100644
--- a/dlls/Makefile.in
+++ b/dlls/Makefile.in
@@ -363,6 +363,7 @@ TESTSUBDIRS = \
usp10/tests \
uxtheme/tests \
version/tests \
+ winhttp/tests \
wininet/tests \
winmm/tests \
winspool.drv/tests \
diff --git a/dlls/winhttp/tests/Makefile.in b/dlls/winhttp/tests/Makefile.in
new file mode 100644
index 0000000..d4efd42
--- /dev/null
+++ b/dlls/winhttp/tests/Makefile.in
@@ -0,0 +1,13 @@
+TOPSRCDIR = @top_srcdir@
+TOPOBJDIR = ../../..
+SRCDIR = @srcdir@
+VPATH = @srcdir@
+TESTDLL = winhttp.dll
+IMPORTS = winhttp kernel32
+
+CTESTS = \
+ winhttp.c
+
+ at MAKE_TEST_RULES@
+
+ at DEPENDENCIES@ # everything below this line is overwritten by make depend
diff --git a/dlls/winhttp/tests/winhttp.c b/dlls/winhttp/tests/winhttp.c
new file mode 100644
index 0000000..d417a56
--- /dev/null
+++ b/dlls/winhttp/tests/winhttp.c
@@ -0,0 +1,80 @@
+/*
+ * WinHTTP - tests
+ *
+ * Copyright 2008 Google (Zac Brown)
+ *
+ * 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 <stdlib.h>
+
+#include <windef.h>
+#include <winbase.h>
+#include <winhttp.h>
+
+#include "wine/test.h"
+
+static const WCHAR test_useragent[] =
+ {'W','i','n','e',' ','R','e','g','r','e','s','s','i','o','n',' ','T','e','s','t',0};
+static const WCHAR test_server[] = {'w','i','n','e','h','q','.','o','r','g',0};
+
+static void test_OpenRequest (void)
+{
+ BOOL ret;
+ HINTERNET session, request, connection;
+
+ session = WinHttpOpen(test_useragent, WINHTTP_ACCESS_TYPE_DEFAULT_PROXY,
+ WINHTTP_NO_PROXY_NAME, WINHTTP_NO_PROXY_BYPASS, 0);
+ todo_wine ok(session != NULL, "WinHttpOpen failed to open session.\n");
+
+ /* Test with a bad server name */
+ SetLastError(0xdeadbeef);
+ connection = WinHttpConnect(session, NULL, INTERNET_DEFAULT_HTTP_PORT, 0);
+ ok (connection == NULL, "WinHttpConnect succeeded in opening connection to NULL server argument.\n");
+ todo_wine ok(GetLastError() == ERROR_INVALID_PARAMETER,
+ "Expected ERROR_INVALID_PARAMETER, got %u.\n", GetLastError());
+
+ /* Test with a valid server name */
+ connection = WinHttpConnect (session, test_server, INTERNET_DEFAULT_HTTP_PORT, 0);
+ todo_wine ok(connection != NULL,
+ "WinHttpConnect failed to open a connection, error: %u.\n", GetLastError());
+
+ request = WinHttpOpenRequest(connection, NULL, NULL, NULL, WINHTTP_NO_REFERER,
+ WINHTTP_DEFAULT_ACCEPT_TYPES, 0);
+ if (request == NULL && GetLastError() == ERROR_WINHTTP_NAME_NOT_RESOLVED)
+ {
+ skip("Network unreachable, skipping.\n");
+ goto done;
+ }
+ todo_wine ok(request != NULL,
+ "WinHttpOpenrequest failed to open a request, error: %u.\n", GetLastError());
+
+ ret = WinHttpSendRequest(request, WINHTTP_NO_ADDITIONAL_HEADERS, 0, NULL, 0, 0, 0);
+ todo_wine ok(ret == TRUE, "WinHttpSendRequest failed: %u\n", GetLastError());
+ ret = WinHttpCloseHandle(request);
+ todo_wine ok(ret == TRUE, "WinHttpCloseHandle failed on closing request, got %d.\n", ret);
+
+ done:
+ ret = WinHttpCloseHandle(connection);
+ todo_wine ok(ret == TRUE, "WinHttpCloseHandle failed on closing connection, got %d.\n", ret);
+ ret = WinHttpCloseHandle(session);
+ todo_wine ok(ret == TRUE, "WinHttpCloseHandle failed on closing session, got %d.\n", ret);
+
+}
+
+START_TEST (winhttp)
+{
+ test_OpenRequest();
+}
diff --git a/programs/winetest/Makefile.in b/programs/winetest/Makefile.in
index 9431466..5ab9840 100644
--- a/programs/winetest/Makefile.in
+++ b/programs/winetest/Makefile.in
@@ -101,6 +101,7 @@ TESTBINS = \
usp10_test.exe \
uxtheme_test.exe \
version_test.exe \
+ winhttp_test.exe \
wininet_test.exe \
winmm_test.exe \
winspool.drv_test.exe \
@@ -261,6 +262,8 @@ uxtheme_test.exe: $(DLLDIR)/uxtheme/tests/uxtheme_test.exe$(DLLEXT)
cp $(DLLDIR)/uxtheme/tests/uxtheme_test.exe$(DLLEXT) $@ && $(STRIP) $@
version_test.exe: $(DLLDIR)/version/tests/version_test.exe$(DLLEXT)
cp $(DLLDIR)/version/tests/version_test.exe$(DLLEXT) $@ && $(STRIP) $@
+winhttp_test.exe: $(DLLDIR)/winhttp/tests/winhttp_test.exe$(DLLEXT)
+ cp $(DLLDIR)/winhttp/tests/winhttp_test.exe$(DLLEXT) $@ && $(STRIP) $@
wininet_test.exe: $(DLLDIR)/wininet/tests/wininet_test.exe$(DLLEXT)
cp $(DLLDIR)/wininet/tests/wininet_test.exe$(DLLEXT) $@ && $(STRIP) $@
winmm_test.exe: $(DLLDIR)/winmm/tests/winmm_test.exe$(DLLEXT)
diff --git a/programs/winetest/winetest.rc b/programs/winetest/winetest.rc
index 8a293a8..1a2ba33 100644
--- a/programs/winetest/winetest.rc
+++ b/programs/winetest/winetest.rc
@@ -162,6 +162,7 @@ userenv_test.exe TESTRES "userenv_test.exe"
usp10_test.exe TESTRES "usp10_test.exe"
uxtheme_test.exe TESTRES "uxtheme_test.exe"
version_test.exe TESTRES "version_test.exe"
+winhttp_test.exe TESTRES "winhttp_test.exe"
wininet_test.exe TESTRES "wininet_test.exe"
winmm_test.exe TESTRES "winmm_test.exe"
winspool.drv_test.exe TESTRES "winspool.drv_test.exe"
More information about the wine-cvs
mailing list