quartz: Fix support for files with multiple odml indexes.
[wine/wine64.git] / dlls / winhttp / tests / winhttp.c
blobd417a56408702313ea9420d74e05b966f2e36586
1 /*
2 * WinHTTP - tests
4 * Copyright 2008 Google (Zac Brown)
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #include <stdarg.h>
21 #include <stdlib.h>
23 #include <windef.h>
24 #include <winbase.h>
25 #include <winhttp.h>
27 #include "wine/test.h"
29 static const WCHAR test_useragent[] =
30 {'W','i','n','e',' ','R','e','g','r','e','s','s','i','o','n',' ','T','e','s','t',0};
31 static const WCHAR test_server[] = {'w','i','n','e','h','q','.','o','r','g',0};
33 static void test_OpenRequest (void)
35 BOOL ret;
36 HINTERNET session, request, connection;
38 session = WinHttpOpen(test_useragent, WINHTTP_ACCESS_TYPE_DEFAULT_PROXY,
39 WINHTTP_NO_PROXY_NAME, WINHTTP_NO_PROXY_BYPASS, 0);
40 todo_wine ok(session != NULL, "WinHttpOpen failed to open session.\n");
42 /* Test with a bad server name */
43 SetLastError(0xdeadbeef);
44 connection = WinHttpConnect(session, NULL, INTERNET_DEFAULT_HTTP_PORT, 0);
45 ok (connection == NULL, "WinHttpConnect succeeded in opening connection to NULL server argument.\n");
46 todo_wine ok(GetLastError() == ERROR_INVALID_PARAMETER,
47 "Expected ERROR_INVALID_PARAMETER, got %u.\n", GetLastError());
49 /* Test with a valid server name */
50 connection = WinHttpConnect (session, test_server, INTERNET_DEFAULT_HTTP_PORT, 0);
51 todo_wine ok(connection != NULL,
52 "WinHttpConnect failed to open a connection, error: %u.\n", GetLastError());
54 request = WinHttpOpenRequest(connection, NULL, NULL, NULL, WINHTTP_NO_REFERER,
55 WINHTTP_DEFAULT_ACCEPT_TYPES, 0);
56 if (request == NULL && GetLastError() == ERROR_WINHTTP_NAME_NOT_RESOLVED)
58 skip("Network unreachable, skipping.\n");
59 goto done;
61 todo_wine ok(request != NULL,
62 "WinHttpOpenrequest failed to open a request, error: %u.\n", GetLastError());
64 ret = WinHttpSendRequest(request, WINHTTP_NO_ADDITIONAL_HEADERS, 0, NULL, 0, 0, 0);
65 todo_wine ok(ret == TRUE, "WinHttpSendRequest failed: %u\n", GetLastError());
66 ret = WinHttpCloseHandle(request);
67 todo_wine ok(ret == TRUE, "WinHttpCloseHandle failed on closing request, got %d.\n", ret);
69 done:
70 ret = WinHttpCloseHandle(connection);
71 todo_wine ok(ret == TRUE, "WinHttpCloseHandle failed on closing connection, got %d.\n", ret);
72 ret = WinHttpCloseHandle(session);
73 todo_wine ok(ret == TRUE, "WinHttpCloseHandle failed on closing session, got %d.\n", ret);
77 START_TEST (winhttp)
79 test_OpenRequest();