From 137fa2be84fe480251b822921c588e3933096496 Mon Sep 17 00:00:00 2001 From: Patrik Stridvall Date: Wed, 9 Oct 2002 18:12:20 +0000 Subject: [PATCH] Fixed test to not fail behind firewalls or without an internet connection. --- dlls/wininet/tests/http.c | 39 +++++++++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/dlls/wininet/tests/http.c b/dlls/wininet/tests/http.c index 3b3312161ca..92848e75f33 100644 --- a/dlls/wininet/tests/http.c +++ b/dlls/wininet/tests/http.c @@ -90,6 +90,8 @@ void winapi_test(int flags) ok((hi != 0x0),"InternetOpen Failed"); trace("InternetOpenA -->\n"); + if (hi == 0x0) goto abort; + InternetSetStatusCallback(hi,&callback); trace("InternetConnectA <--\n"); @@ -97,6 +99,8 @@ void winapi_test(int flags) ok((hic != 0x0),"InternetConnect Failed"); trace("InternetConnectA -->\n"); + if (hic == 0x0) goto abort; + types = (char*)malloc(100); strcpy(types,"*"); @@ -104,10 +108,20 @@ void winapi_test(int flags) hor = HttpOpenRequestA(hic, "GET", "/about/", 0x0,0x0,(const char**)&types,0x00400800,0xdeadbead); - - ok((hor != 0x0),"HttpOpenRequest Failed"); + if (hor == 0x0 && GetLastError() == 12007 /* ERROR_INTERNET_NAME_NOT_RESOLVED */) { + /* + * If the internet name can't be resolved we are probably behind + * a firewall or in some other way not directly connected to the + * Internet. Not enough reason to fail the test. Just ignore and + * abort. + */ + } else { + ok((hor != 0x0),"HttpOpenRequest Failed"); + } trace("HttpOpenRequestA -->\n"); + if (hor == 0x0) goto abort; + trace("HttpSendRequestA -->\n"); rc = HttpSendRequestA(hor, "", 0xffffffff,0x0,0x0); if (flags) @@ -170,12 +184,21 @@ void winapi_test(int flags) HeapFree(GetProcessHeap(),0,buffer); } } - rc = InternetCloseHandle(hi); - ok ((rc != 0), "InternetCloseHandle failed"); - rc = InternetCloseHandle(hor); - ok ((rc != 0), "InternetCloseHandle failed"); - if (flags) - Sleep(100); +abort: + if (hor != 0x0) { + rc = InternetCloseHandle(hor); + ok ((rc != 0), "InternetCloseHandle of handle opened by HttpOpenRequestA failed"); + } + if (hor != 0x0) { + rc = InternetCloseHandle(hic); + ok ((rc != 0), "InternetCloseHandle of handle opened by InternetConnectA failed"); + } + if (hi != 0x0) { + rc = InternetCloseHandle(hi); + ok ((rc != 0), "InternetCloseHandle of handle opened by InternetOpenA failed"); + if (flags) + Sleep(100); + } }