Author: pschweitzer
Date: Sun Sep 7 08:50:21 2008
New Revision: 36031
URL:
http://svn.reactos.org/svn/reactos?rev=36031&view=rev
Log:
Commit 2/2
Imported mstask_winetest.exe, winhttp_winetest.exe from Wine HEAD
Added:
trunk/rostests/winetests/mstask/ (with props)
trunk/rostests/winetests/mstask/mstask.rbuild (with props)
trunk/rostests/winetests/mstask/task.c (with props)
trunk/rostests/winetests/mstask/task_scheduler.c (with props)
trunk/rostests/winetests/mstask/task_trigger.c (with props)
trunk/rostests/winetests/mstask/testlist.c (with props)
trunk/rostests/winetests/winhttp/ (with props)
trunk/rostests/winetests/winhttp/notification.c (with props)
trunk/rostests/winetests/winhttp/testlist.c (with props)
trunk/rostests/winetests/winhttp/winhttp.c (with props)
trunk/rostests/winetests/winhttp/winhttp.rbuild (with props)
Modified:
trunk/rostests/winetests/directory.rbuild
Modified: trunk/rostests/winetests/directory.rbuild
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/directory.rbuil…
==============================================================================
--- trunk/rostests/winetests/directory.rbuild [iso-8859-1] (original)
+++ trunk/rostests/winetests/directory.rbuild [iso-8859-1] Sun Sep 7 08:50:21 2008
@@ -57,6 +57,9 @@
</directory>
<directory name="msi">
<xi:include href="msi/msi.rbuild" />
+ </directory>
+ <directory name="mstask">
+ <xi:include href="mstask/mstask.rbuild" />
</directory>
<directory name="msvcrt">
<xi:include href="msvcrt/msvcrt.rbuild" />
@@ -124,6 +127,9 @@
<directory name="version">
<xi:include href="version/version.rbuild" />
</directory>
+ <directory name="winhttp">
+ <xi:include href="winhttp/winhttp.rbuild" />
+ </directory>
<directory name="wininet">
<xi:include href="wininet/wininet.rbuild" />
</directory>
Propchange: trunk/rostests/winetests/mstask/
------------------------------------------------------------------------------
--- bugtraq:logregex (added)
+++ bugtraq:logregex Sun Sep 7 08:50:21 2008
@@ -1,0 +1,2 @@
+([Ii]ssue|[Bb]ug)s? #?(\d+)(,? ?#?(\d+))*(,? ?(and |or )?#?(\d+))?
+(\d+)
Propchange: trunk/rostests/winetests/mstask/
------------------------------------------------------------------------------
bugtraq:message = See issue #%BUGID% for more details.
Propchange: trunk/rostests/winetests/mstask/
------------------------------------------------------------------------------
bugtraq:url =
http://www.reactos.org/bugzilla/show_bug.cgi?id=%BUGID%
Propchange: trunk/rostests/winetests/mstask/
------------------------------------------------------------------------------
tsvn:logminsize = 10
Added: trunk/rostests/winetests/mstask/mstask.rbuild
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/mstask/mstask.r…
==============================================================================
--- trunk/rostests/winetests/mstask/mstask.rbuild (added)
+++ trunk/rostests/winetests/mstask/mstask.rbuild [iso-8859-1] Sun Sep 7 08:50:21 2008
@@ -1,0 +1,17 @@
+<?xml version="1.0"?>
+<!DOCTYPE module SYSTEM "../../../tools/rbuild/project.dtd">
+<group>
+<module name="mstask_winetest" type="win32cui"
installbase="bin" installname="mstask_winetest.exe"
allowwarnings="true">
+ <include base="mstask_winetest">.</include>
+ <define name="WINVER">0x600</define>
+ <define name="_WIN32_WINNT">0x600</define>
+ <file>task.c</file>
+ <file>task_scheduler.c</file>
+ <file>task_trigger.c</file>
+ <file>testlist.c</file>
+ <library>wine</library>
+ <library>ole32</library>
+ <library>kernel32</library>
+ <library>ntdll</library>
+</module>
+</group>
Propchange: trunk/rostests/winetests/mstask/mstask.rbuild
------------------------------------------------------------------------------
svn:eol-style = native
Added: trunk/rostests/winetests/mstask/task.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/mstask/task.c?r…
==============================================================================
--- trunk/rostests/winetests/mstask/task.c (added)
+++ trunk/rostests/winetests/mstask/task.c [iso-8859-1] Sun Sep 7 08:50:21 2008
@@ -1,0 +1,520 @@
+/*
+ * Test suite for Task interface
+ *
+ * Copyright (C) 2008 Google (Roy Shea)
+ *
+ * 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
+ */
+
+#define COBJMACROS
+
+#include "corerror.h"
+#include "mstask.h"
+#include "wine/test.h"
+
+static ITaskScheduler *test_task_scheduler;
+static ITask *test_task;
+static const WCHAR empty[] = {0};
+
+/* allocate some tmp string space */
+/* FIXME: this is not 100% thread-safe */
+static char *get_tmp_space(int size)
+{
+ static char *list[16];
+ static long pos;
+ char *ret;
+ int idx;
+
+ idx = ++pos % (sizeof(list)/sizeof(list[0]));
+ if ((ret = realloc(list[idx], size)))
+ list[idx] = ret;
+ return ret;
+}
+
+static const char *dbgstr_w(LPCWSTR str)
+{
+ char *buf;
+ int len;
+ if(!str)
+ return "(null)";
+ len = lstrlenW(str) + 1;
+ buf = get_tmp_space(len);
+ WideCharToMultiByte(CP_ACP, 0, str, -1, buf, len, NULL, NULL);
+ return buf;
+}
+
+static BOOL setup_task(void)
+{
+ HRESULT hres;
+ const WCHAR task_name[] =
{'T','e','s','t','i','n','g', 0};
+
+ hres = CoCreateInstance(&CLSID_CTaskScheduler, NULL, CLSCTX_INPROC_SERVER,
+ &IID_ITaskScheduler, (void **) &test_task_scheduler);
+ if(hres != S_OK)
+ return FALSE;
+ hres = ITaskScheduler_NewWorkItem(test_task_scheduler, task_name, &CLSID_CTask,
+ &IID_ITask, (IUnknown**)&test_task);
+ if(hres != S_OK)
+ {
+ ITaskScheduler_Release(test_task_scheduler);
+ return FALSE;
+ }
+ return TRUE;
+}
+
+static void cleanup_task(void)
+{
+ ITask_Release(test_task);
+ ITaskScheduler_Release(test_task_scheduler);
+}
+
+static LPCWSTR path_resolve_name(LPCWSTR base_name)
+{
+ static WCHAR buffer[MAX_PATH];
+ int len;
+
+ len = SearchPathW(NULL, base_name, NULL, 0, NULL, NULL);
+ if (len == 0)
+ return base_name;
+ else if (len < MAX_PATH)
+ {
+ SearchPathW(NULL, base_name, NULL, MAX_PATH, buffer, NULL);
+ return buffer;
+ }
+ return NULL;
+}
+
+static void test_SetApplicationName_GetApplicationName(void)
+{
+ BOOL setup;
+ HRESULT hres;
+ LPWSTR stored_name;
+ LPCWSTR full_name;
+ const WCHAR non_application_name[] =
{'N','o','S','u','c','h',
+
'A','p','p','l','i','c','a','t','i','o','n',
0};
+ const WCHAR notepad_exe[] = {
+
'n','o','t','e','p','a','d','.','e','x','e',
0};
+ const WCHAR notepad[] =
{'n','o','t','e','p','a','d', 0};
+
+ setup = setup_task();
+ ok(setup, "Failed to setup test_task\n");
+ if (!setup)
+ {
+ skip("Failed to create task. Skipping tests.\n");
+ return;
+ }
+
+ /* Attempt getting before setting application name */
+ hres = ITask_GetApplicationName(test_task, &stored_name);
+ ok(hres == S_OK, "GetApplicationName failed: %08x\n", hres);
+ if (hres == S_OK)
+ {
+ ok(!lstrcmpW(stored_name, empty),
+ "Got %s, expected empty string\n", dbgstr_w(stored_name));
+ CoTaskMemFree(stored_name);
+ }
+
+ /* Set application name to a nonexistent application and then get
+ * the application name that is actually stored */
+ hres = ITask_SetApplicationName(test_task, non_application_name);
+ ok(hres == S_OK, "Failed setting name %s: %08x\n",
+ dbgstr_w(non_application_name), hres);
+ hres = ITask_GetApplicationName(test_task, &stored_name);
+ ok(hres == S_OK, "GetApplicationName failed: %08x\n", hres);
+ if (hres == S_OK)
+ {
+ full_name = path_resolve_name(non_application_name);
+ ok(!lstrcmpW(stored_name, full_name), "Got %s, expected %s\n",
+ dbgstr_w(stored_name), dbgstr_w(full_name));
+ CoTaskMemFree(stored_name);
+ }
+
+ /* Set a valid application name with program type extension and then
+ * get the stored name */
+ hres = ITask_SetApplicationName(test_task, notepad_exe);
+ ok(hres == S_OK, "Failed setting name %s: %08x\n",
+ dbgstr_w(notepad_exe), hres);
+ hres = ITask_GetApplicationName(test_task, &stored_name);
+ ok(hres == S_OK, "GetApplicationName failed: %08x\n", hres);
+ if (hres == S_OK)
+ {
+ full_name = path_resolve_name(notepad_exe);
+ ok(!lstrcmpW(stored_name, full_name), "Got %s, expected %s\n",
+ dbgstr_w(stored_name), dbgstr_w(full_name));
+ CoTaskMemFree(stored_name);
+ }
+
+ /* Set a valid application name without program type extension and
+ * then get the stored name */
+ hres = ITask_SetApplicationName(test_task, notepad);
+ ok(hres == S_OK, "Failed setting name %s: %08x\n", dbgstr_w(notepad),
hres);
+ hres = ITask_GetApplicationName(test_task, &stored_name);
+ ok(hres == S_OK, "GetApplicationName failed: %08x\n", hres);
+ if (hres == S_OK)
+ {
+ full_name = path_resolve_name(notepad);
+ ok(!lstrcmpW(stored_name, full_name), "Got %s, expected %s\n",
+ dbgstr_w(stored_name), dbgstr_w(full_name));
+ CoTaskMemFree(stored_name);
+ }
+
+ /* After having a valid application name set, set application the name
+ * to a nonexistent application and then get the name that is
+ * actually stored */
+ hres = ITask_SetApplicationName(test_task, non_application_name);
+ ok(hres == S_OK, "Failed setting name %s: %08x\n",
+ dbgstr_w(non_application_name), hres);
+ hres = ITask_GetApplicationName(test_task, &stored_name);
+ ok(hres == S_OK, "GetApplicationName failed: %08x\n", hres);
+ if (hres == S_OK)
+ {
+ full_name = path_resolve_name(non_application_name);
+ ok(!lstrcmpW(stored_name, full_name), "Got %s, expected %s\n",
+ dbgstr_w(stored_name), dbgstr_w(full_name));
+ CoTaskMemFree(stored_name);
+ }
+
+ /* Clear application name */
+ hres = ITask_SetApplicationName(test_task, empty);
+ ok(hres == S_OK, "Failed setting name %s: %08x\n", dbgstr_w(empty), hres);
+ hres = ITask_GetApplicationName(test_task, &stored_name);
+ ok(hres == S_OK, "GetApplicationName failed: %08x\n", hres);
+ if (hres == S_OK)
+ {
+ ok(!lstrcmpW(stored_name, empty),
+ "Got %s, expected empty string\n", dbgstr_w(stored_name));
+ CoTaskMemFree(stored_name);
+ }
+
+ cleanup_task();
+ return;
+}
+
+static void test_CreateTrigger(void)
+{
+ BOOL setup;
+ HRESULT hres;
+ WORD trigger_index;
+ ITaskTrigger *test_trigger;
+
+ setup = setup_task();
+ ok(setup, "Failed to setup test_task\n");
+ if (!setup)
+ {
+ skip("Failed to create task. Skipping tests.\n");
+ return;
+ }
+
+ hres = ITask_CreateTrigger(test_task, &trigger_index, &test_trigger);
+ ok(hres == S_OK, "Failed to create trigger: 0x%08x\n", hres);
+ if (hres != S_OK)
+ {
+ cleanup_task();
+ return;
+ }
+
+ ITaskTrigger_Release(test_trigger);
+ cleanup_task();
+ return;
+}
+
+static void test_SetParameters_GetParameters(void)
+{
+ BOOL setup;
+ HRESULT hres;
+ LPWSTR parameters;
+ const WCHAR parameters_a[] =
{'f','o','o','.','t','x','t', 0};
+ const WCHAR parameters_b[] =
{'f','o','o','.','t','x','t','
',
+
'b','a','r','.','t','x','t', 0};
+
+ setup = setup_task();
+ ok(setup, "Failed to setup test_task\n");
+ if (!setup)
+ {
+ skip("Failed to create task. Skipping tests.\n");
+ return;
+ }
+
+ /* Get parameters before setting them */
+ hres = ITask_GetParameters(test_task, ¶meters);
+ ok(hres == S_OK, "GetParameters failed: %08x\n", hres);
+ if (hres == S_OK)
+ {
+ ok(!lstrcmpW(parameters, empty),
+ "Got %s, expected empty string\n", dbgstr_w(parameters));
+ CoTaskMemFree(parameters);
+ }
+
+ /* Set parameters to a simple string */
+ hres = ITask_SetParameters(test_task, parameters_a);
+ ok(hres == S_OK, "Failed setting parameters %s: %08x\n",
+ dbgstr_w(parameters_a), hres);
+ hres = ITask_GetParameters(test_task, ¶meters);
+ ok(hres == S_OK, "GetParameters failed: %08x\n", hres);
+ if (hres == S_OK)
+ {
+ ok(!lstrcmpW(parameters, parameters_a), "Got %s, expected %s\n",
+ dbgstr_w(parameters), dbgstr_w(parameters_a));
+ CoTaskMemFree(parameters);
+ }
+
+ /* Update parameters to a different simple string */
+ hres = ITask_SetParameters(test_task, parameters_b);
+ ok(hres == S_OK, "Failed setting parameters %s: %08x\n",
+ dbgstr_w(parameters_b), hres);
+ hres = ITask_GetParameters(test_task, ¶meters);
+ ok(hres == S_OK, "GetParameters failed: %08x\n", hres);
+ if (hres == S_OK)
+ {
+ ok(!lstrcmpW(parameters, parameters_b), "Got %s, expected %s\n",
+ dbgstr_w(parameters), dbgstr_w(parameters_b));
+ CoTaskMemFree(parameters);
+ }
+
+ /* Clear parameters */
+ hres = ITask_SetParameters(test_task, empty);
+ ok(hres == S_OK, "Failed setting parameters %s: %08x\n",
+ dbgstr_w(empty), hres);
+ hres = ITask_GetParameters(test_task, ¶meters);
+ ok(hres == S_OK, "GetParameters failed: %08x\n", hres);
+ if (hres == S_OK)
+ {
+ ok(!lstrcmpW(parameters, empty),
+ "Got %s, expected empty string\n", dbgstr_w(parameters));
+ CoTaskMemFree(parameters);
+ }
+
+ cleanup_task();
+ return;
+}
+
+static void test_SetComment_GetComment(void)
+{
+ BOOL setup;
+ HRESULT hres;
+ LPWSTR comment;
+ const WCHAR comment_a[] =
{'C','o','m','m','e','n','t','.',
0};
+ const WCHAR comment_b[] =
{'L','o','n','g','e','r',' ',
+
'c','o','m','m','e','n','t','.',
0};
+
+ setup = setup_task();
+ ok(setup, "Failed to setup test_task\n");
+ if (!setup)
+ {
+ skip("Failed to create task. Skipping tests.\n");
+ return;
+ }
+
+ /* Get comment before setting it*/
+ hres = ITask_GetComment(test_task, &comment);
+ ok(hres == S_OK, "GetComment failed: %08x\n", hres);
+ if (hres == S_OK)
+ {
+ ok(!lstrcmpW(comment, empty),
+ "Got %s, expected empty string\n", dbgstr_w(comment));
+ CoTaskMemFree(comment);
+ }
+
+ /* Set comment to a simple string */
+ hres = ITask_SetComment(test_task, comment_a);
+ ok(hres == S_OK, "Failed setting comment %s: %08x\n",
+ dbgstr_w(comment_a), hres);
+ hres = ITask_GetComment(test_task, &comment);
+ ok(hres == S_OK, "GetComment failed: %08x\n", hres);
+ if (hres == S_OK)
+ {
+ ok(!lstrcmpW(comment, comment_a), "Got %s, expected %s\n",
+ dbgstr_w(comment), dbgstr_w(comment_a));
+ CoTaskMemFree(comment);
+ }
+
+ /* Update comment to a different simple string */
+ hres = ITask_SetComment(test_task, comment_b);
+ ok(hres == S_OK, "Failed setting comment %s: %08x\n",
+ dbgstr_w(comment_b), hres);
+ hres = ITask_GetComment(test_task, &comment);
+ ok(hres == S_OK, "GetComment failed: %08x\n", hres);
+ if (hres == S_OK)
+ {
+ ok(!lstrcmpW(comment, comment_b), "Got %s, expected %s\n",
+ dbgstr_w(comment), dbgstr_w(comment_b));
+ CoTaskMemFree(comment);
+ }
+
+ /* Clear comment */
+ hres = ITask_SetComment(test_task, empty);
+ ok(hres == S_OK, "Failed setting comment %s: %08x\n",
+ dbgstr_w(empty), hres);
+ hres = ITask_GetComment(test_task, &comment);
+ ok(hres == S_OK, "GetComment failed: %08x\n", hres);
+ if (hres == S_OK)
+ {
+ ok(!lstrcmpW(comment, empty),
+ "Got %s, expected empty string\n", dbgstr_w(comment));
+ CoTaskMemFree(comment);
+ }
+
+ cleanup_task();
+ return;
+}
+
+static void test_SetMaxRunTime_GetMaxRunTime(void)
+{
+ BOOL setup;
+ HRESULT hres;
+ DWORD max_run_time;
+
+ setup = setup_task();
+ ok(setup, "Failed to setup test_task\n");
+ if (!setup)
+ {
+ skip("Failed to create task. Skipping tests.\n");
+ return;
+ }
+
+ /* Default time is 3 days:
+ * 3 days * 24 hours * 60 minutes * 60 seconds * 1000 ms = 259200000 */
+ max_run_time = 0;
+ hres = ITask_GetMaxRunTime(test_task, &max_run_time);
+ ok(hres == S_OK, "Failed to get max runtime: 0x%08x\n", hres);
+ ok(max_run_time == 259200000, "Expected 259200000: %d\n", max_run_time);
+
+ /* Basic set test */
+ max_run_time = 0;
+ hres = ITask_SetMaxRunTime(test_task, 1234);
+ ok(hres == S_OK, "Failed to set max runtime: 0x%08x\n", hres);
+ hres = ITask_GetMaxRunTime(test_task, &max_run_time);
+ ok(hres == S_OK, "Failed to get max runtime: 0x%08x\n", hres);
+ ok(max_run_time == 1234, "Expected 1234: %d\n", max_run_time);
+
+ /* Verify that time can be set to zero */
+ max_run_time = 1;
+ hres = ITask_SetMaxRunTime(test_task, 0);
+ ok(hres == S_OK, "Failed to set max runtime: 0x%08x\n", hres);
+ hres = ITask_GetMaxRunTime(test_task, &max_run_time);
+ ok(hres == S_OK, "Failed to get max runtime: 0x%08x\n", hres);
+ ok(max_run_time == 0, "Expected 0: %d\n", max_run_time);
+
+ /* Check resolution by setting time to one */
+ max_run_time = 0;
+ hres = ITask_SetMaxRunTime(test_task, 1);
+ ok(hres == S_OK, "Failed to set max runtime: 0x%08x\n", hres);
+ hres = ITask_GetMaxRunTime(test_task, &max_run_time);
+ ok(hres == S_OK, "Failed to get max runtime: 0x%08x\n", hres);
+ ok(max_run_time == 1, "Expected 1: %d\n", max_run_time);
+
+ /* Verify that time can be set to INFINITE */
+ max_run_time = 0;
+ hres = ITask_SetMaxRunTime(test_task, INFINITE);
+ ok(hres == S_OK, "Failed to set max runtime: 0x%08x\n", hres);
+ hres = ITask_GetMaxRunTime(test_task, &max_run_time);
+ ok(hres == S_OK, "Failed to get max runtime: 0x%08x\n", hres);
+ ok(max_run_time == INFINITE, "Expected INFINITE: %d\n", max_run_time);
+
+ cleanup_task();
+ return;
+}
+
+static void test_SetAccountInformation_GetAccountInformation(void)
+{
+ BOOL setup;
+ HRESULT hres;
+ LPWSTR account_name;
+ const WCHAR dummy_account_name[] = {'N', 'o', 'S',
'u', 'c', 'h',
+ 'A', 'c', 'c', 'o', 'u', 'n',
't', 0};
+ const WCHAR dummy_account_name_b[] = {'N', 'o', 'S',
'u', 'c', 'h',
+ 'A', 'c', 'c', 'o', 'u', 'n',
't', 'B', 0};
+
+ setup = setup_task();
+ ok(setup, "Failed to setup test_task\n");
+ if (!setup)
+ {
+ skip("Failed to create task. Skipping tests.\n");
+ return;
+ }
+
+ /* Get account information before it is set */
+ hres = ITask_GetAccountInformation(test_task, &account_name);
+ /* WinXP returns HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND): 0x80070002 but
+ * Win2K returns SCHED_E_CANNOT_OPEN_TASK: 0x8004130d
+ * Win9x doesn't support security services */
+ if (hres == SCHED_E_NO_SECURITY_SERVICES)
+ {
+ win_skip("Security services are not supported\n");
+ cleanup_task();
+ return;
+ }
+ ok(hres == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) ||
+ hres == SCHED_E_CANNOT_OPEN_TASK,
+ "Unset account name generated: 0x%08x\n", hres);
+
+ /* Attempt to set to a dummy account without a password */
+ /* This test passes on WinXP but fails on Win2K */
+ hres = ITask_SetAccountInformation(test_task, dummy_account_name, NULL);
+ ok(hres == S_OK,
+ "Failed setting dummy account with no password: %08x\n", hres);
+ hres = ITask_GetAccountInformation(test_task, &account_name);
+ ok(hres == S_OK, "GetAccountInformation failed: %08x\n", hres);
+ if (hres == S_OK)
+ {
+ ok(!lstrcmpW(account_name, dummy_account_name),
+ "Got %s, expected %s\n", dbgstr_w(account_name),
+ dbgstr_w(dummy_account_name));
+ CoTaskMemFree(account_name);
+ }
+
+ /* Attempt to set to a dummy account with a (invalid) password */
+ /* This test passes on WinXP but fails on Win2K */
+ hres = ITask_SetAccountInformation(test_task, dummy_account_name_b,
+ dummy_account_name_b);
+ ok(hres == S_OK,
+ "Failed setting dummy account with password: %08x\n", hres);
+ hres = ITask_GetAccountInformation(test_task, &account_name);
+ ok(hres == S_OK, "GetAccountInformation failed: %08x\n", hres);
+ if (hres == S_OK)
+ {
+ ok(!lstrcmpW(account_name, dummy_account_name_b),
+ "Got %s, expected %s\n", dbgstr_w(account_name),
+ dbgstr_w(dummy_account_name_b));
+ CoTaskMemFree(account_name);
+ }
+
+ /* Attempt to set to the local system account */
+ hres = ITask_SetAccountInformation(test_task, empty, NULL);
+ ok(hres == S_OK, "Failed setting system account: %08x\n", hres);
+ hres = ITask_GetAccountInformation(test_task, &account_name);
+ ok(hres == S_OK, "GetAccountInformation failed: %08x\n", hres);
+ if (hres == S_OK)
+ {
+ ok(!lstrcmpW(account_name, empty),
+ "Got %s, expected empty string\n", dbgstr_w(account_name));
+ CoTaskMemFree(account_name);
+ }
+
+ cleanup_task();
+ return;
+}
+
+START_TEST(task)
+{
+ CoInitialize(NULL);
+ test_SetApplicationName_GetApplicationName();
+ test_CreateTrigger();
+ test_SetParameters_GetParameters();
+ test_SetComment_GetComment();
+ test_SetMaxRunTime_GetMaxRunTime();
+ test_SetAccountInformation_GetAccountInformation();
+ CoUninitialize();
+}
Propchange: trunk/rostests/winetests/mstask/task.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: trunk/rostests/winetests/mstask/task_scheduler.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/mstask/task_sch…
==============================================================================
--- trunk/rostests/winetests/mstask/task_scheduler.c (added)
+++ trunk/rostests/winetests/mstask/task_scheduler.c [iso-8859-1] Sun Sep 7 08:50:21
2008
@@ -1,0 +1,111 @@
+/*
+ * Test suite for TaskScheduler interface
+ *
+ * Copyright (C) 2008 Google (Roy Shea)
+ *
+ * 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
+ */
+
+#define COBJMACROS
+
+#include "corerror.h"
+
+#include "initguid.h"
+#include "mstask.h"
+#include "wine/test.h"
+
+static ITaskScheduler *test_task_scheduler;
+
+static void test_NewWorkItem(void)
+{
+ HRESULT hres;
+ ITask *task;
+ const WCHAR task_name[] = {'T', 'e', 's', 't',
'i', 'n', 'g', 0};
+ GUID GUID_BAD;
+
+ /* Initialize a GUID that will not be a recognized CLSID or a IID */
+ CoCreateGuid(&GUID_BAD);
+
+ /* Create TaskScheduler */
+ hres = CoCreateInstance(&CLSID_CTaskScheduler, NULL, CLSCTX_INPROC_SERVER,
+ &IID_ITaskScheduler, (void **) &test_task_scheduler);
+ ok(hres == S_OK, "CTaskScheduler CoCreateInstance failed: %08x\n", hres);
+ if (hres != S_OK)
+ {
+ skip("Failed to create task scheduler. Skipping tests.\n");
+ return;
+ }
+
+ /* Test basic task creation */
+ hres = ITaskScheduler_NewWorkItem(test_task_scheduler, task_name,
+ &CLSID_CTask, &IID_ITask, (IUnknown**)&task);
+ ok(hres == S_OK, "NewNetworkItem failed: %08x\n", hres);
+ if (hres == S_OK)
+ ITask_Release(task);
+
+ /* Task creation attempt using invalid work item class ID */
+ hres = ITaskScheduler_NewWorkItem(test_task_scheduler, task_name,
+ &GUID_BAD, &IID_ITask, (IUnknown**)&task);
+ ok(hres == CLASS_E_CLASSNOTAVAILABLE,
+ "Expected CLASS_E_CLASSNOTAVAILABLE: %08x\n", hres);
+
+ /* Task creation attempt using invalid interface ID */
+ hres = ITaskScheduler_NewWorkItem(test_task_scheduler, task_name,
+ &CLSID_CTask, &GUID_BAD, (IUnknown**)&task);
+ ok(hres == E_NOINTERFACE, "Expected E_NOINTERFACE: %08x\n", hres);
+
+ /* Task creation attempt using invalid work item class and interface ID */
+ hres = ITaskScheduler_NewWorkItem(test_task_scheduler, task_name,
+ &GUID_BAD, &GUID_BAD, (IUnknown**)&task);
+ ok(hres == CLASS_E_CLASSNOTAVAILABLE,
+ "Expected CLASS_E_CLASSNOTAVAILABLE: %08x\n", hres);
+
+ ITaskScheduler_Release(test_task_scheduler);
+ return;
+}
+
+static void test_Activate(void)
+{
+ HRESULT hres;
+ ITask *task = NULL;
+ const WCHAR not_task_name[] =
+ {'N', 'o', 'S', 'u', 'c',
'h', 'T', 'a', 's', 'k', 0};
+
+ /* Create TaskScheduler */
+ hres = CoCreateInstance(&CLSID_CTaskScheduler, NULL, CLSCTX_INPROC_SERVER,
+ &IID_ITaskScheduler, (void **) &test_task_scheduler);
+ ok(hres == S_OK, "CTaskScheduler CoCreateInstance failed: %08x\n", hres);
+ if (hres != S_OK)
+ {
+ skip("Failed to create task scheduler. Skipping tests.\n");
+ return;
+ }
+
+ /* Attempt to activate a nonexistent task */
+ hres = ITaskScheduler_Activate(test_task_scheduler, not_task_name,
+ &IID_ITask, (IUnknown**)&task);
+ ok(hres == COR_E_FILENOTFOUND, "Expected COR_E_FILENOTFOUND: %08x\n",
hres);
+
+ ITaskScheduler_Release(test_task_scheduler);
+ return;
+}
+
+START_TEST(task_scheduler)
+{
+ CoInitialize(NULL);
+ test_NewWorkItem();
+ test_Activate();
+ CoUninitialize();
+}
Propchange: trunk/rostests/winetests/mstask/task_scheduler.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: trunk/rostests/winetests/mstask/task_trigger.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/mstask/task_tri…
==============================================================================
--- trunk/rostests/winetests/mstask/task_trigger.c (added)
+++ trunk/rostests/winetests/mstask/task_trigger.c [iso-8859-1] Sun Sep 7 08:50:21 2008
@@ -1,0 +1,380 @@
+/*
+ * Test suite for Task interface
+ *
+ * Copyright (C) 2008 Google (Roy Shea)
+ *
+ * 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
+ */
+
+#define COBJMACROS
+
+#include <corerror.h>
+
+#include "mstask.h"
+#include "wine/test.h"
+
+static ITaskScheduler *test_task_scheduler;
+static ITask *test_task;
+static ITaskTrigger *test_trigger;
+static WORD trigger_index;
+
+static BOOL setup_trigger(void)
+{
+ HRESULT hres;
+ const WCHAR task_name[] =
{'T','e','s','t','i','n','g', 0};
+
+ hres = CoCreateInstance(&CLSID_CTaskScheduler, NULL, CLSCTX_INPROC_SERVER,
+ &IID_ITaskScheduler, (void **) &test_task_scheduler);
+ if(hres != S_OK)
+ return FALSE;
+ hres = ITaskScheduler_NewWorkItem(test_task_scheduler, task_name,
+ &CLSID_CTask, &IID_ITask, (IUnknown**)&test_task);
+ if(hres != S_OK)
+ {
+ ITaskScheduler_Release(test_task_scheduler);
+ return FALSE;
+ }
+ hres = ITask_CreateTrigger(test_task, &trigger_index, &test_trigger);
+ if(hres != S_OK)
+ {
+ ITask_Release(test_task);
+ ITaskScheduler_Release(test_task_scheduler);
+ return FALSE;
+ }
+ return TRUE;
+}
+
+static void cleanup_trigger(void)
+{
+ ITaskTrigger_Release(test_trigger);
+ ITask_Release(test_task);
+ ITaskScheduler_Release(test_task_scheduler);
+}
+
+static BOOL compare_trigger_state(TASK_TRIGGER found_state,
+ TASK_TRIGGER expected_state)
+{
+ ok(found_state.cbTriggerSize == expected_state.cbTriggerSize,
+ "cbTriggerSize: Found %d but expected %d\n",
+ found_state.cbTriggerSize, expected_state.cbTriggerSize);
+
+ ok(found_state.Reserved1 == expected_state.Reserved1,
+ "Reserved1: Found %d but expected %d\n",
+ found_state.Reserved1, expected_state.Reserved1);
+
+ ok(found_state.wBeginYear == expected_state.wBeginYear,
+ "wBeginYear: Found %d but expected %d\n",
+ found_state.wBeginYear, expected_state.wBeginYear);
+
+ ok(found_state.wBeginMonth == expected_state.wBeginMonth,
+ "wBeginMonth: Found %d but expected %d\n",
+ found_state.wBeginMonth, expected_state.wBeginMonth);
+
+ ok(found_state.wBeginDay == expected_state.wBeginDay,
+ "wBeginDay: Found %d but expected %d\n",
+ found_state.wBeginDay, expected_state.wBeginDay);
+
+ ok(found_state.wEndYear == expected_state.wEndYear,
+ "wEndYear: Found %d but expected %d\n",
+ found_state.wEndYear, expected_state.wEndYear);
+
+ ok(found_state.wEndMonth == expected_state.wEndMonth,
+ "wEndMonth: Found %d but expected %d\n",
+ found_state.wEndMonth, expected_state.wEndMonth);
+
+ ok(found_state.wEndDay == expected_state.wEndDay,
+ "wEndDay: Found %d but expected %d\n",
+ found_state.wEndDay, expected_state.wEndDay);
+
+ ok(found_state.wStartHour == expected_state.wStartHour,
+ "wStartHour: Found %d but expected %d\n",
+ found_state.wStartHour, expected_state.wStartHour);
+
+ ok(found_state.wStartMinute == expected_state.wStartMinute,
+ "wStartMinute: Found %d but expected %d\n",
+ found_state.wStartMinute, expected_state.wStartMinute);
+
+ ok(found_state.MinutesDuration == expected_state.MinutesDuration,
+ "MinutesDuration: Found %d but expected %d\n",
+ found_state.MinutesDuration, expected_state.MinutesDuration);
+
+ ok(found_state.MinutesInterval == expected_state.MinutesInterval,
+ "MinutesInterval: Found %d but expected %d\n",
+ found_state.MinutesInterval, expected_state.MinutesInterval);
+
+ ok(found_state.rgFlags == expected_state.rgFlags,
+ "rgFlags: Found %d but expected %d\n",
+ found_state.rgFlags, expected_state.rgFlags);
+
+ ok(found_state.TriggerType == expected_state.TriggerType,
+ "TriggerType: Found %d but expected %d\n",
+ found_state.TriggerType, expected_state.TriggerType);
+
+ ok(found_state.Type.Daily.DaysInterval == expected_state.Type.Daily.DaysInterval,
+ "Type.Daily.DaysInterval: Found %d but expected %d\n",
+ found_state.Type.Daily.DaysInterval,
expected_state.Type.Daily.DaysInterval);
+
+ ok(found_state.Reserved2 == expected_state.Reserved2,
+ "Reserved2: Found %d but expected %d\n",
+ found_state.Reserved2, expected_state.Reserved2);
+
+ ok(found_state.wRandomMinutesInterval == expected_state.wRandomMinutesInterval,
+ "wRandomMinutesInterval: Found %d but expected %d\n",
+ found_state.wRandomMinutesInterval, expected_state.wRandomMinutesInterval);
+
+ return TRUE;
+}
+
+static void test_SetTrigger_GetTrigger(void)
+{
+ BOOL setup;
+ HRESULT hres;
+ TASK_TRIGGER trigger_state;
+ TASK_TRIGGER empty_trigger_state = {
+ sizeof(trigger_state), 0,
+ 0, 0, 0,
+ 0, 0, 0,
+ 0, 0, 0, 0,
+ TASK_TRIGGER_FLAG_DISABLED, TASK_TIME_TRIGGER_DAILY, {{1}},
+ 0, 0
+ };
+ TASK_TRIGGER normal_trigger_state = {
+ sizeof(trigger_state), 0,
+ 1980, 1, 1,
+ 2980, 2, 2,
+ 3, 3,
+ 0, 0,
+ TASK_TRIGGER_FLAG_DISABLED, TASK_TIME_TRIGGER_DAILY, {{1}},
+ 0, 0
+ };
+ SYSTEMTIME time;
+
+ setup = setup_trigger();
+ ok(setup, "Failed to setup test_task\n");
+ if (!setup)
+ {
+ skip("Failed to create task. Skipping tests.\n");
+ return;
+ }
+
+ /* Setup a trigger with base values for this test run */
+ GetLocalTime(&time);
+ empty_trigger_state.wStartHour = time.wHour;
+ empty_trigger_state.wStartMinute = time.wMinute;
+ empty_trigger_state.wBeginYear = time.wYear;
+ empty_trigger_state.wBeginMonth = time.wMonth;
+ empty_trigger_state.wBeginDay = time.wDay;
+
+ /* Test trigger state after trigger creation but before setting * state */
+ memset(&trigger_state, 0xcf, sizeof(trigger_state));
+ trigger_state.cbTriggerSize = sizeof(trigger_state);
+ hres = ITaskTrigger_GetTrigger(test_trigger, &trigger_state);
+ ok(hres == S_OK, "Failed to set trigger: 0x%08x\n", hres);
+ compare_trigger_state(trigger_state, empty_trigger_state);
+
+ /* Test setting basic empty trigger */
+ hres = ITaskTrigger_SetTrigger(test_trigger, &empty_trigger_state);
+ ok(hres == S_OK, "Failed to set trigger: 0x%08x\n", hres);
+ memset(&trigger_state, 0xcf, sizeof(trigger_state));
+ trigger_state.cbTriggerSize = sizeof(trigger_state);
+ hres = ITaskTrigger_GetTrigger(test_trigger, &trigger_state);
+ ok(hres == S_OK, "Failed to GetTrigger\n");
+ compare_trigger_state(trigger_state, empty_trigger_state);
+
+ /* Test setting basic non-empty trigger */
+ hres = ITaskTrigger_SetTrigger(test_trigger, &normal_trigger_state);
+ ok(hres == S_OK, "Failed to set trigger: 0x%08x\n", hres);
+ memset(&trigger_state, 0xcf, sizeof(trigger_state));
+ trigger_state.cbTriggerSize = sizeof(trigger_state);
+ hres = ITaskTrigger_GetTrigger(test_trigger, &trigger_state);
+ ok(hres == S_OK, "Failed to GetTrigger\n");
+ compare_trigger_state(trigger_state, normal_trigger_state);
+
+ /* The following tests modify the normal_trigger_state structure
+ * before each test, and return the normal_trigger_state structure
+ * back to its original valid state after each test. This keeps
+ * each test run independent. */
+
+ /* Test setting trigger with invalid cbTriggerSize */
+ normal_trigger_state.cbTriggerSize = sizeof(trigger_state) - 1;
+ hres = ITaskTrigger_SetTrigger(test_trigger, &normal_trigger_state);
+ ok(hres == E_INVALIDARG, "Expected E_INVALIDARG: 0x%08x\n", hres);
+ normal_trigger_state.cbTriggerSize = sizeof(trigger_state) + 1;
+ hres = ITaskTrigger_SetTrigger(test_trigger, &normal_trigger_state);
+ ok(hres == E_INVALIDARG, "Expected E_INVALIDARG: 0x%08x\n", hres);
+ normal_trigger_state.cbTriggerSize = sizeof(trigger_state);
+
+ /* Test setting trigger with invalid Reserved fields */
+ normal_trigger_state.Reserved1 = 80;
+ normal_trigger_state.Reserved2 = 80;
+ hres = ITaskTrigger_SetTrigger(test_trigger, &normal_trigger_state);
+ ok(hres == S_OK, "Failed to set trigger: 0x%08x\n", hres);
+ memset(&trigger_state, 0xcf, sizeof(trigger_state));
+ trigger_state.cbTriggerSize = sizeof(trigger_state);
+ hres = ITaskTrigger_GetTrigger(test_trigger, &trigger_state);
+ ok(trigger_state.Reserved1 == 0 && trigger_state.Reserved2 == 0,
+ "Reserved fields should be set to zero\n");
+ normal_trigger_state.Reserved1 = 0;
+ normal_trigger_state.Reserved2 = 0;
+
+ /* Test setting trigger with invalid month */
+ normal_trigger_state.wBeginMonth = 0;
+ hres = ITaskTrigger_SetTrigger(test_trigger, &normal_trigger_state);
+ ok(hres == E_INVALIDARG, "Expected E_INVALIDARG: 0x%08x\n", hres);
+ normal_trigger_state.wBeginMonth = 13;
+ hres = ITaskTrigger_SetTrigger(test_trigger, &normal_trigger_state);
+ ok(hres == E_INVALIDARG, "Expected E_INVALIDARG: 0x%08x\n", hres);
+ normal_trigger_state.wBeginMonth = 1;
+
+ /* Test setting trigger with invalid begin date */
+ normal_trigger_state.wBeginDay = 0;
+ hres = ITaskTrigger_SetTrigger(test_trigger, &normal_trigger_state);
+ ok(hres == E_INVALIDARG, "Expected E_INVALIDARG: 0x%08x\n", hres);
+ normal_trigger_state.wBeginDay = 32;
+ hres = ITaskTrigger_SetTrigger(test_trigger, &normal_trigger_state);
+ ok(hres == E_INVALIDARG, "Expected E_INVALIDARG: 0x%08x\n", hres);
+ normal_trigger_state.wBeginMonth = 2;
+ normal_trigger_state.wBeginDay = 30;
+ hres = ITaskTrigger_SetTrigger(test_trigger, &normal_trigger_state);
+ ok(hres == E_INVALIDARG, "Expected E_INVALIDARG: 0x%08x\n", hres);
+ normal_trigger_state.wBeginMonth = 1;
+ normal_trigger_state.wBeginDay = 1;
+
+ /* Test setting trigger invalid end date */
+ normal_trigger_state.wEndYear = 0;
+ normal_trigger_state.wEndMonth = 200;
+ normal_trigger_state.wEndDay = 200;
+ hres = ITaskTrigger_SetTrigger(test_trigger, &normal_trigger_state);
+ ok(hres == S_OK, "Failed to set trigger: 0x%08x\n", hres);
+ memset(&trigger_state, 0xcf, sizeof(trigger_state));
+ trigger_state.cbTriggerSize = sizeof(trigger_state);
+ hres = ITaskTrigger_GetTrigger(test_trigger, &trigger_state);
+ ok(trigger_state.wEndYear == 0, "End year should be 0: %d\n",
+ trigger_state.wEndYear);
+ ok(trigger_state.wEndMonth == 200, "End month should be 200: %d\n",
+ trigger_state.wEndMonth);
+ ok(trigger_state.wEndDay == 200, "End day should be 200: %d\n",
+ trigger_state.wEndDay);
+ normal_trigger_state.rgFlags =
+ TASK_TRIGGER_FLAG_DISABLED | TASK_TRIGGER_FLAG_HAS_END_DATE;
+ hres = ITaskTrigger_SetTrigger(test_trigger, &normal_trigger_state);
+ ok(hres == E_INVALIDARG, "Expected E_INVALIDARG: 0x%08x\n", hres);
+ normal_trigger_state.rgFlags = TASK_TRIGGER_FLAG_DISABLED;
+ normal_trigger_state.wEndYear = 2980;
+ normal_trigger_state.wEndMonth = 1;
+ normal_trigger_state.wEndDay = 1;
+
+ /* Test setting trigger with invalid hour or minute*/
+ normal_trigger_state.wStartHour = 24;
+ hres = ITaskTrigger_SetTrigger(test_trigger, &normal_trigger_state);
+ ok(hres == E_INVALIDARG, "Expected E_INVALIDARG: 0x%08x\n", hres);
+ normal_trigger_state.wStartHour = 3;
+ normal_trigger_state.wStartHour = 60;
+ hres = ITaskTrigger_SetTrigger(test_trigger, &normal_trigger_state);
+ ok(hres == E_INVALIDARG, "Expected E_INVALIDARG: 0x%08x\n", hres);
+ normal_trigger_state.wStartHour = 3;
+
+ /* Test setting trigger with invalid duration / interval pairs */
+ normal_trigger_state.MinutesDuration = 5;
+ normal_trigger_state.MinutesInterval = 5;
+ hres = ITaskTrigger_SetTrigger(test_trigger, &normal_trigger_state);
+ ok(hres == E_INVALIDARG, "Expected E_INVALIDARG: 0x%08x\n", hres);
+ normal_trigger_state.MinutesDuration = 5;
+ normal_trigger_state.MinutesInterval = 6;
+ hres = ITaskTrigger_SetTrigger(test_trigger, &normal_trigger_state);
+ ok(hres == E_INVALIDARG, "Expected E_INVALIDARG: 0x%08x\n", hres);
+ normal_trigger_state.MinutesDuration = 0;
+ normal_trigger_state.MinutesInterval = 6;
+ hres = ITaskTrigger_SetTrigger(test_trigger, &normal_trigger_state);
+ ok(hres == E_INVALIDARG, "Expected E_INVALIDARG: 0x%08x\n", hres);
+ normal_trigger_state.MinutesDuration = 5;
+ normal_trigger_state.MinutesInterval = 0;
+ ok(hres == E_INVALIDARG, "Expected E_INVALIDARG: 0x%08x\n", hres);
+ normal_trigger_state.MinutesDuration = 0;
+ normal_trigger_state.MinutesInterval = 0;
+
+ /* Test setting trigger with end date before start date */
+ normal_trigger_state.wEndYear = 1979;
+ hres = ITaskTrigger_SetTrigger(test_trigger, &normal_trigger_state);
+ ok(hres == S_OK, "Failed to set trigger: 0x%08x\n", hres);
+ normal_trigger_state.rgFlags =
+ TASK_TRIGGER_FLAG_DISABLED | TASK_TRIGGER_FLAG_HAS_END_DATE;
+ hres = ITaskTrigger_SetTrigger(test_trigger, &normal_trigger_state);
+ ok(hres == S_OK, "Failed to set trigger: 0x%08x\n", hres);
+ normal_trigger_state.rgFlags = TASK_TRIGGER_FLAG_DISABLED;
+ normal_trigger_state.wEndYear = 2980;
+ normal_trigger_state.wEndMonth = 1;
+ normal_trigger_state.wEndDay = 1;
+
+
+ /* Test setting trigger with invalid TriggerType and Type */
+ normal_trigger_state.TriggerType = TASK_TIME_TRIGGER_ONCE;
+ normal_trigger_state.Type.Weekly.WeeksInterval = 2;
+ normal_trigger_state.Type.Weekly.rgfDaysOfTheWeek = (TASK_MONDAY | TASK_TUESDAY);
+ hres = ITaskTrigger_SetTrigger(test_trigger, &normal_trigger_state);
+ ok(hres == S_OK, "Failed to set trigger: 0x%08x\n", hres);
+ memset(&trigger_state, 0xcf, sizeof(trigger_state));
+ trigger_state.cbTriggerSize = sizeof(trigger_state);
+ hres = ITaskTrigger_GetTrigger(test_trigger, &trigger_state);
+ ok(trigger_state.Type.Weekly.WeeksInterval == 0xcfcf,
+ "Expected WeeksInterval set remain untouched: %d\n",
+ trigger_state.Type.Weekly.WeeksInterval);
+ ok(trigger_state.Type.Weekly.rgfDaysOfTheWeek == 0xcfcf,
+ "Expected WeeksInterval set remain untouched: %d\n",
+ trigger_state.Type.Weekly.rgfDaysOfTheWeek);
+ normal_trigger_state.TriggerType = TASK_TIME_TRIGGER_DAILY;
+ normal_trigger_state.Type.Daily.DaysInterval = 1;
+ hres = ITaskTrigger_SetTrigger(test_trigger, &normal_trigger_state);
+
+ /* Test setting trigger with set wRandomMinutesInterval */
+ normal_trigger_state.wRandomMinutesInterval = 5;
+ hres = ITaskTrigger_SetTrigger(test_trigger, &normal_trigger_state);
+ ok(hres == S_OK, "Failed to set trigger: 0x%08x\n", hres);
+ memset(&trigger_state, 0xcf, sizeof(trigger_state));
+ trigger_state.cbTriggerSize = sizeof(trigger_state);
+ hres = ITaskTrigger_GetTrigger(test_trigger, &trigger_state);
+ ok(trigger_state.wRandomMinutesInterval == 0,
+ "wRandomMinutesInterval should be set to zero\n");
+ normal_trigger_state.wRandomMinutesInterval = 0;
+
+ /* Test GetTrigger using invalid cbTriggerSiz in pTrigger. In
+ * contrast to available documentation, this succeeds in practice. */
+ hres = ITaskTrigger_SetTrigger(test_trigger, &normal_trigger_state);
+ ok(hres == S_OK, "Failed to set trigger: 0x%08x\n", hres);
+ memset(&trigger_state, 0xcf, sizeof(trigger_state));
+ trigger_state.cbTriggerSize = sizeof(trigger_state) - 1;
+ hres = ITaskTrigger_GetTrigger(test_trigger, &trigger_state);
+ ok(hres == S_OK, "Failed to GetTrigger\n");
+ ok(compare_trigger_state(trigger_state, normal_trigger_state),
+ "Invalid state\n");
+ memset(&trigger_state, 0xcf, sizeof(trigger_state));
+ trigger_state.cbTriggerSize = 0;
+ hres = ITaskTrigger_GetTrigger(test_trigger, &trigger_state);
+ ok(hres == S_OK, "Failed to GetTrigger\n");
+ ok(compare_trigger_state(trigger_state, normal_trigger_state),
+ "Invalid state\n");
+
+
+ cleanup_trigger();
+ return;
+}
+
+
+START_TEST(task_trigger)
+{
+ CoInitialize(NULL);
+ test_SetTrigger_GetTrigger();
+ CoUninitialize();
+}
Propchange: trunk/rostests/winetests/mstask/task_trigger.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: trunk/rostests/winetests/mstask/testlist.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/mstask/testlist…
==============================================================================
--- trunk/rostests/winetests/mstask/testlist.c (added)
+++ trunk/rostests/winetests/mstask/testlist.c [iso-8859-1] Sun Sep 7 08:50:21 2008
@@ -1,0 +1,19 @@
+/* Automatically generated file; DO NOT EDIT!! */
+
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+
+#define STANDALONE
+#include "wine/test.h"
+
+extern void func_task(void);
+extern void func_task_scheduler(void);
+extern void func_task_trigger(void);
+
+const struct test winetest_testlist[] =
+{
+ { "task", func_task },
+ { "task_scheduler", func_task_scheduler },
+ { "task_trigger", func_task_trigger },
+ { 0, 0 }
+};
Propchange: trunk/rostests/winetests/mstask/testlist.c
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: trunk/rostests/winetests/winhttp/
------------------------------------------------------------------------------
--- bugtraq:logregex (added)
+++ bugtraq:logregex Sun Sep 7 08:50:21 2008
@@ -1,0 +1,2 @@
+([Ii]ssue|[Bb]ug)s? #?(\d+)(,? ?#?(\d+))*(,? ?(and |or )?#?(\d+))?
+(\d+)
Propchange: trunk/rostests/winetests/winhttp/
------------------------------------------------------------------------------
bugtraq:message = See issue #%BUGID% for more details.
Propchange: trunk/rostests/winetests/winhttp/
------------------------------------------------------------------------------
bugtraq:url =
http://www.reactos.org/bugzilla/show_bug.cgi?id=%BUGID%
Propchange: trunk/rostests/winetests/winhttp/
------------------------------------------------------------------------------
tsvn:logminsize = 10
Added: trunk/rostests/winetests/winhttp/notification.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/winhttp/notific…
==============================================================================
--- trunk/rostests/winetests/winhttp/notification.c (added)
+++ trunk/rostests/winetests/winhttp/notification.c [iso-8859-1] Sun Sep 7 08:50:21 2008
@@ -1,0 +1,267 @@
+/*
+ * test status notifications
+ *
+ * Copyright 2008 Hans Leidekker for CodeWeavers
+ *
+ * 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 user_agent[] =
{'w','i','n','e','t','e','s','t',0};
+
+enum api
+{
+ winhttp_connect = 1,
+ winhttp_open_request,
+ winhttp_send_request,
+ winhttp_receive_response,
+ winhttp_close_handle
+};
+
+struct notification
+{
+ enum api function; /* api responsible for notification */
+ unsigned int status; /* status received */
+ int todo;
+};
+
+struct info
+{
+ enum api function;
+ const struct notification *test;
+ unsigned int count;
+ unsigned int index;
+};
+
+static void CALLBACK check_notification( HINTERNET handle, DWORD_PTR context, DWORD
status, LPVOID buffer, DWORD buflen )
+{
+ struct info *info = (struct info *)context;
+ unsigned int i = info->index;
+
+ if (status == WINHTTP_CALLBACK_STATUS_HANDLE_CREATED)
+ {
+ DWORD size = sizeof(struct info *);
+ WinHttpQueryOption( handle, WINHTTP_OPTION_CONTEXT_VALUE, &info, &size
);
+ }
+ ok(i < info->count, "unexpected notification 0x%08x\n", status);
+ if (i >= info->count) return;
+ if (!info->test[i].todo)
+ {
+ ok(info->test[i].status == status, "expected status 0x%08x got
0x%08x\n", info->test[i].status, status);
+ ok(info->test[i].function == info->function, "expected function %u got
%u\n", info->test[i].function, info->function);
+ }
+ else todo_wine
+ {
+ ok(info->test[i].status == status, "expected status 0x%08x got
0x%08x\n", info->test[i].status, status);
+ ok(info->test[i].function == info->function, "expected function %u got
%u\n", info->test[i].function, info->function);
+ }
+ info->index++;
+}
+
+static const struct notification cache_test[] =
+{
+ { winhttp_connect, WINHTTP_CALLBACK_STATUS_HANDLE_CREATED, 0 },
+ { winhttp_open_request, WINHTTP_CALLBACK_STATUS_HANDLE_CREATED, 0 },
+ { winhttp_send_request, WINHTTP_CALLBACK_STATUS_RESOLVING_NAME, 0 },
+ { winhttp_send_request, WINHTTP_CALLBACK_STATUS_NAME_RESOLVED, 0 },
+ { winhttp_send_request, WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER, 0 },
+ { winhttp_send_request, WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER, 0 },
+ { winhttp_send_request, WINHTTP_CALLBACK_STATUS_SENDING_REQUEST, 0 },
+ { winhttp_send_request, WINHTTP_CALLBACK_STATUS_REQUEST_SENT, 0 },
+ { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE, 0 },
+ { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED, 0 },
+ { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_CLOSING_CONNECTION, 0 },
+ { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_CONNECTION_CLOSED, 0 },
+ { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING, 0 },
+ { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING, 1 },
+ { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING, 1 }
+};
+
+static void test_connection_cache( void )
+{
+ static const WCHAR codeweavers[] =
{'w','w','w','.','c','o','d','e','w','e','a','v','e','r','s','.','c','o','m',0};
+
+ HANDLE ses, con, req;
+ DWORD size, status;
+ BOOL ret;
+ struct info info, *context = &info;
+
+ info.test = cache_test;
+ info.count = sizeof(cache_test) / sizeof(cache_test[0]);
+ info.index = 0;
+
+ ses = WinHttpOpen( user_agent, 0, NULL, NULL, 0 );
+ ok(ses != NULL, "failed to open session %u\n", GetLastError());
+
+ WinHttpSetStatusCallback( ses, check_notification,
WINHTTP_CALLBACK_FLAG_ALL_COMPLETIONS | WINHTTP_CALLBACK_FLAG_ALL_NOTIFICATIONS, 0 );
+
+ ret = WinHttpSetOption( ses, WINHTTP_OPTION_CONTEXT_VALUE, &context,
sizeof(struct info *) );
+ ok(ret, "failed to set context value %u\n", GetLastError());
+
+ info.function = winhttp_connect;
+ con = WinHttpConnect( ses, codeweavers, 0, 0 );
+ ok(con != NULL, "failed to open a connection %u\n", GetLastError());
+
+ info.function = winhttp_open_request;
+ req = WinHttpOpenRequest( con, NULL, NULL, NULL, NULL, NULL, 0 );
+ ok(req != NULL, "failed to open a request %u\n", GetLastError());
+
+ info.function = winhttp_send_request;
+ ret = WinHttpSendRequest( req, NULL, 0, NULL, 0, 0, 0 );
+ ok(ret, "failed to send request %u\n", GetLastError());
+
+ info.function = winhttp_receive_response;
+ ret = WinHttpReceiveResponse( req, NULL );
+ ok(ret, "failed to receive response %u\n", GetLastError());
+
+ size = sizeof(status);
+ ret = WinHttpQueryHeaders( req, WINHTTP_QUERY_STATUS_CODE |
WINHTTP_QUERY_FLAG_NUMBER, NULL, &status, &size, NULL );
+ ok(ret, "failed unexpectedly %u\n", GetLastError());
+ ok(status == 200, "request failed unexpectedly %u\n", status);
+
+ info.function = winhttp_close_handle;
+ WinHttpCloseHandle( req );
+ WinHttpCloseHandle( con );
+ WinHttpCloseHandle( ses );
+
+ Sleep(2000); /* make sure connection is evicted from cache */
+
+ info.index = 0;
+
+ ses = WinHttpOpen( user_agent, 0, NULL, NULL, 0 );
+ ok(ses != NULL, "failed to open session %u\n", GetLastError());
+
+ WinHttpSetStatusCallback( ses, check_notification,
WINHTTP_CALLBACK_FLAG_ALL_COMPLETIONS | WINHTTP_CALLBACK_FLAG_ALL_NOTIFICATIONS, 0 );
+
+ ret = WinHttpSetOption( ses, WINHTTP_OPTION_CONTEXT_VALUE, &context,
sizeof(struct info *) );
+ ok(ret, "failed to set context value %u\n", GetLastError());
+
+ info.function = winhttp_connect;
+ con = WinHttpConnect( ses, codeweavers, 0, 0 );
+ ok(con != NULL, "failed to open a connection %u\n", GetLastError());
+
+ info.function = winhttp_open_request;
+ req = WinHttpOpenRequest( con, NULL, NULL, NULL, NULL, NULL, 0 );
+ ok(req != NULL, "failed to open a request %u\n", GetLastError());
+
+ ret = WinHttpSetOption( req, WINHTTP_OPTION_CONTEXT_VALUE, &context,
sizeof(struct info *) );
+ ok(ret, "failed to set context value %u\n", GetLastError());
+
+ info.function = winhttp_send_request;
+ ret = WinHttpSendRequest( req, NULL, 0, NULL, 0, 0, 0 );
+ ok(ret, "failed to send request %u\n", GetLastError());
+
+ info.function = winhttp_receive_response;
+ ret = WinHttpReceiveResponse( req, NULL );
+ ok(ret, "failed to receive response %u\n", GetLastError());
+
+ size = sizeof(status);
+ ret = WinHttpQueryHeaders( req, WINHTTP_QUERY_STATUS_CODE |
WINHTTP_QUERY_FLAG_NUMBER, NULL, &status, &size, NULL );
+ ok(ret, "failed unexpectedly %u\n", GetLastError());
+ ok(status == 200, "request failed unexpectedly %u\n", status);
+
+ info.function = winhttp_close_handle;
+ WinHttpCloseHandle( req );
+ WinHttpCloseHandle( con );
+ WinHttpCloseHandle( ses );
+}
+
+static const struct notification redirect_test[] =
+{
+ { winhttp_connect, WINHTTP_CALLBACK_STATUS_HANDLE_CREATED, 0 },
+ { winhttp_open_request, WINHTTP_CALLBACK_STATUS_HANDLE_CREATED, 0 },
+ { winhttp_send_request, WINHTTP_CALLBACK_STATUS_RESOLVING_NAME, 0 },
+ { winhttp_send_request, WINHTTP_CALLBACK_STATUS_NAME_RESOLVED, 0 },
+ { winhttp_send_request, WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER, 0 },
+ { winhttp_send_request, WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER, 0 },
+ { winhttp_send_request, WINHTTP_CALLBACK_STATUS_SENDING_REQUEST, 0 },
+ { winhttp_send_request, WINHTTP_CALLBACK_STATUS_REQUEST_SENT, 0 },
+ { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE, 0 },
+ { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED, 0 },
+ { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_REDIRECT, 0 },
+ { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RESOLVING_NAME, 0 },
+ { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_NAME_RESOLVED, 0 },
+ { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER, 0 },
+ { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER, 0 },
+ { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_SENDING_REQUEST, 0 },
+ { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_REQUEST_SENT, 0 },
+ { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE, 0 },
+ { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED, 0 },
+ { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_CLOSING_CONNECTION, 0 },
+ { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_CONNECTION_CLOSED, 0 },
+ { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING, 0 },
+ { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING, 1 },
+ { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING, 1 }
+};
+
+static void test_redirect( void )
+{
+ static const WCHAR codeweavers[] =
{'c','o','d','e','w','e','a','v','e','r','s','.','c','o','m',0};
+
+ HANDLE ses, con, req;
+ DWORD size, status;
+ BOOL ret;
+ struct info info, *context = &info;
+
+ info.test = redirect_test;
+ info.count = sizeof(redirect_test) / sizeof(redirect_test[0]);
+ info.index = 0;
+
+ ses = WinHttpOpen( user_agent, 0, NULL, NULL, 0 );
+ ok(ses != NULL, "failed to open session %u\n", GetLastError());
+
+ WinHttpSetStatusCallback( ses, check_notification,
WINHTTP_CALLBACK_FLAG_ALL_COMPLETIONS | WINHTTP_CALLBACK_FLAG_ALL_NOTIFICATIONS, 0 );
+
+ ret = WinHttpSetOption( ses, WINHTTP_OPTION_CONTEXT_VALUE, &context,
sizeof(struct info *) );
+ ok(ret, "failed to set context value %u\n", GetLastError());
+
+ info.function = winhttp_connect;
+ con = WinHttpConnect( ses, codeweavers, 0, 0 );
+ ok(con != NULL, "failed to open a connection %u\n", GetLastError());
+
+ info.function = winhttp_open_request;
+ req = WinHttpOpenRequest( con, NULL, NULL, NULL, NULL, NULL, 0 );
+ ok(req != NULL, "failed to open a request %u\n", GetLastError());
+
+ info.function = winhttp_send_request;
+ ret = WinHttpSendRequest( req, NULL, 0, NULL, 0, 0, 0 );
+
+ info.function = winhttp_receive_response;
+ ret = WinHttpReceiveResponse( req, NULL );
+ ok(ret, "failed to receive response %u\n", GetLastError());
+
+ size = sizeof(status);
+ ret = WinHttpQueryHeaders( req, WINHTTP_QUERY_STATUS_CODE |
WINHTTP_QUERY_FLAG_NUMBER, NULL, &status, &size, NULL );
+ ok(ret, "failed unexpectedly %u\n", GetLastError());
+ ok(status == 200, "request failed unexpectedly %u\n", status);
+
+ info.function = winhttp_close_handle;
+ WinHttpCloseHandle( req );
+ WinHttpCloseHandle( con );
+ WinHttpCloseHandle( ses );
+}
+
+START_TEST (notification)
+{
+ test_connection_cache();
+ test_redirect();
+}
Propchange: trunk/rostests/winetests/winhttp/notification.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: trunk/rostests/winetests/winhttp/testlist.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/winhttp/testlis…
==============================================================================
--- trunk/rostests/winetests/winhttp/testlist.c (added)
+++ trunk/rostests/winetests/winhttp/testlist.c [iso-8859-1] Sun Sep 7 08:50:21 2008
@@ -1,0 +1,13 @@
+/* Automatically generated file; DO NOT EDIT!! */
+
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+
+#define STANDALONE
+#include "wine/test.h"
+
+
+const struct test winetest_testlist[] =
+{
+ { 0, 0 }
+};
Propchange: trunk/rostests/winetests/winhttp/testlist.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: trunk/rostests/winetests/winhttp/winhttp.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/winhttp/winhttp…
==============================================================================
--- trunk/rostests/winetests/winhttp/winhttp.c (added)
+++ trunk/rostests/winetests/winhttp/winhttp.c [iso-8859-1] Sun Sep 7 08:50:21 2008
@@ -1,0 +1,670 @@
+/*
+ * 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);
+ 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");
+ 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);
+ 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;
+ }
+ 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);
+ ok(ret == TRUE, "WinHttpSendRequest failed: %u\n", GetLastError());
+ ret = WinHttpCloseHandle(request);
+ ok(ret == TRUE, "WinHttpCloseHandle failed on closing request, got %d.\n",
ret);
+
+ done:
+ ret = WinHttpCloseHandle(connection);
+ ok(ret == TRUE, "WinHttpCloseHandle failed on closing connection, got
%d.\n", ret);
+ ret = WinHttpCloseHandle(session);
+ ok(ret == TRUE, "WinHttpCloseHandle failed on closing session, got %d.\n",
ret);
+
+}
+
+static void test_SendRequest (void)
+{
+ HINTERNET session, request, connection;
+ DWORD header_len, optional_len, total_len;
+ DWORD bytes_rw;
+ BOOL ret;
+ CHAR buffer[256];
+ int i;
+
+ static const WCHAR test_site[] =
{'c','r','o','s','s','o','v','e','r','.',
+
'c','o','d','e','w','e','a','v','e','r','s','.','c','o','m',0};
+ static const WCHAR content_type[] =
+
{'C','o','n','t','e','n','t','-','T','y','p','e',':','
','a','p','p','l','i','c','a','t','i','o','n',
+
'/','x','-','w','w','w','-','f','o','r','m','-','u','r','l','e','n','c','o','d','e','d',0};
+ static const WCHAR test_file[] =
{'/','p','o','s','t','t','e','s','t','.','p','h','p',0};
+ static const WCHAR test_verb[] =
{'P','O','S','T',0};
+ static CHAR post_data[] = "mode=Test";
+ static CHAR test_post[] = "mode => Test\\0\n";
+
+ header_len = -1L;
+ total_len = optional_len = sizeof(post_data);
+ memset(buffer, 0xff, sizeof(buffer));
+
+ session = WinHttpOpen(test_useragent, WINHTTP_ACCESS_TYPE_DEFAULT_PROXY,
+ WINHTTP_NO_PROXY_NAME, WINHTTP_NO_PROXY_BYPASS, 0);
+ ok(session != NULL, "WinHttpOpen failed to open session.\n");
+
+ connection = WinHttpConnect (session, test_site, INTERNET_DEFAULT_HTTP_PORT, 0);
+ ok(connection != NULL, "WinHttpConnect failed to open a connection, error:
%u.\n", GetLastError());
+
+ request = WinHttpOpenRequest(connection, test_verb, test_file, NULL,
WINHTTP_NO_REFERER,
+ WINHTTP_DEFAULT_ACCEPT_TYPES, WINHTTP_FLAG_BYPASS_PROXY_CACHE);
+ if (request == NULL && GetLastError() == ERROR_WINHTTP_NAME_NOT_RESOLVED)
+ {
+ skip("Network unreachable, skipping.\n");
+ goto done;
+ }
+ ok(request != NULL, "WinHttpOpenrequest failed to open a request, error:
%u.\n", GetLastError());
+
+ ret = WinHttpSendRequest(request, content_type, header_len, post_data, optional_len,
total_len, 0);
+ ok(ret == TRUE, "WinHttpSendRequest failed: %u\n", GetLastError());
+
+ for (i = 3; post_data[i]; i++)
+ {
+ bytes_rw = -1;
+ ret = WinHttpWriteData(request, &post_data[i], 1, &bytes_rw);
+ ok(ret == TRUE, "WinHttpWriteData failed: %u.\n", GetLastError());
+ ok(bytes_rw == 1, "WinHttpWriteData failed, wrote %u bytes instead of 1
byte.\n", bytes_rw);
+ }
+
+ ret = WinHttpReceiveResponse(request, NULL);
+ ok(ret == TRUE, "WinHttpReceiveResponse failed: %u.\n", GetLastError());
+
+ bytes_rw = -1;
+ ret = WinHttpReadData(request, buffer, sizeof(buffer) - 1, &bytes_rw);
+ ok(ret == TRUE, "WinHttpReadData failed: %u.\n", GetLastError());
+
+ ok(bytes_rw == strlen(test_post), "Read %u bytes instead of %d.\n",
bytes_rw, lstrlen(test_post));
+ ok(strncmp(buffer, test_post, bytes_rw) == 0, "Data read did not match, got
'%s'.\n", buffer);
+
+ ret = WinHttpCloseHandle(request);
+ ok(ret == TRUE, "WinHttpCloseHandle failed on closing request, got %d.\n",
ret);
+ done:
+ ret = WinHttpCloseHandle(connection);
+ ok(ret == TRUE, "WinHttpCloseHandle failed on closing connection, got
%d.\n", ret);
+ ret = WinHttpCloseHandle(session);
+ ok(ret == TRUE, "WinHttpCloseHandle failed on closing session, got %d.\n",
ret);
+}
+
+static void test_WinHttpTimeFromSystemTime(void)
+{
+ BOOL ret;
+ static const SYSTEMTIME time = {2008, 7, 1, 28, 10, 5, 52, 0};
+ static const WCHAR expected_string[] =
+ {'M','o','n',',','
','2','8',' ','J','u','l','
','2','0','0','8',' ',
+
'1','0',':','0','5',':','5','2','
','G','M','T',0};
+ WCHAR time_string[WINHTTP_TIME_FORMAT_BUFSIZE+1];
+
+ ret = WinHttpTimeFromSystemTime(&time, time_string);
+ ok(ret == TRUE, "WinHttpTimeFromSystemTime failed: %u\n", GetLastError());
+ ok(memcmp(time_string, expected_string, sizeof(expected_string)) == 0,
+ "Time string returned did not match expected time string.\n");
+}
+
+static void test_WinHttpTimeToSystemTime(void)
+{
+ BOOL ret;
+ SYSTEMTIME time;
+ static const SYSTEMTIME expected_time = {2008, 7, 1, 28, 10, 5, 52, 0};
+ static const WCHAR time_string1[] =
+ {'M','o','n',',','
','2','8',' ','J','u','l','
','2','0','0','8',' ',
+ +
'1','0',':','0','5',':','5','2','
','G','M','T','\n',0};
+ static const WCHAR time_string2[] =
+ {' ','m','o','n','
','2','8',' ','j','u','l','
','2','0','0','8',' ',
+ '1','0',' ','0','5','
','5','2','\n',0};
+
+ ret = WinHttpTimeToSystemTime(time_string1, &time);
+ ok(ret == TRUE, "WinHttpTimeToSystemTime failed: %u\n", GetLastError());
+ ok(memcmp(&time, &expected_time, sizeof(SYSTEMTIME)) == 0,
+ "Returned SYSTEMTIME structure did not match expected SYSTEMTIME
structure.\n");
+
+ ret = WinHttpTimeToSystemTime(time_string2, &time);
+ ok(ret == TRUE, "WinHttpTimeToSystemTime failed: %u\n", GetLastError());
+ ok(memcmp(&time, &expected_time, sizeof(SYSTEMTIME)) == 0,
+ "Returned SYSTEMTIME structure did not match expected SYSTEMTIME
structure.\n");
+}
+
+static void test_WinHttpAddHeaders(void)
+{
+ HINTERNET session, request, connection;
+ BOOL ret;
+ WCHAR buffer[MAX_PATH];
+ WCHAR check_buffer[MAX_PATH];
+ DWORD index, len, oldlen;
+
+ static const WCHAR test_site[] =
{'c','r','o','s','s','o','v','e','r','.',
+
'c','o','d','e','w','e','a','v','e','r','s','.','c','o','m',0};
+ static const WCHAR test_file[] =
{'/','p','o','s','t','t','e','s','t','.','p','h','p',0};
+ static const WCHAR test_verb[] =
{'P','O','S','T',0};
+
+ static const WCHAR test_header_begin[] =
+ {'P','O','S','T','
','/','p','o','s','t','t','e','s','t','.','p','h','p','
','H','T','T','P','/','1'};
+ static const WCHAR test_header_end[] =
{'\r','\n','\r','\n',0};
+ static const WCHAR test_header_name[] =
{'W','a','r','n','i','n','g',0};
+
+ static const WCHAR test_flag_coalesce[] =
{'t','e','s','t','2',',','
','t','e','s','t','4',0};
+ static const WCHAR test_flag_coalesce_comma[] =
+ {'t','e','s','t','2',',','
','t','e','s','t','4',',','
','t','e','s','t','5',0};
+ static const WCHAR test_flag_coalesce_semicolon[] =
+ {'t','e','s','t','2',',','
','t','e','s','t','4',',','
','t','e','s','t','5',';','
','t','e','s','t','6',0};
+
+ static const WCHAR field[] =
{'f','i','e','l','d',0};
+ static const WCHAR value[] =
{'v','a','l','u','e',' ',0};
+
+ static const WCHAR test_headers[][14] =
+ {
+
{'W','a','r','n','i','n','g',':','t','e','s','t','1',0},
+
{'W','a','r','n','i','n','g',':','t','e','s','t','2',0},
+
{'W','a','r','n','i','n','g',':','t','e','s','t','3',0},
+
{'W','a','r','n','i','n','g',':','t','e','s','t','4',0},
+
{'W','a','r','n','i','n','g',':','t','e','s','t','5',0},
+
{'W','a','r','n','i','n','g',':','t','e','s','t','6',0},
+
{'W','a','r','n','i','n','g',':','t','e','s','t','7',0},
+ {0},
+ {':',0},
+ {'a',':',0},
+ {':','b',0},
+ {'c','d',0},
+ {' ','e',' ',':','f',0},
+
{'f','i','e','l','d',':','
','v','a','l','u','e',' ',0}
+ };
+ static const WCHAR test_indices[][6] =
+ {
+ {'t','e','s','t','1',0},
+ {'t','e','s','t','2',0},
+ {'t','e','s','t','3',0},
+ {'t','e','s','t','4',0}
+ };
+
+ session = WinHttpOpen(test_useragent, WINHTTP_ACCESS_TYPE_DEFAULT_PROXY,
+ WINHTTP_NO_PROXY_NAME, WINHTTP_NO_PROXY_BYPASS, 0);
+ ok(session != NULL, "WinHttpOpen failed to open session.\n");
+
+ connection = WinHttpConnect (session, test_site, INTERNET_DEFAULT_HTTP_PORT, 0);
+ ok(connection != NULL, "WinHttpConnect failed to open a connection, error:
%u.\n", GetLastError());
+
+ request = WinHttpOpenRequest(connection, test_verb, test_file, 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;
+ }
+ ok(request != NULL, "WinHttpOpenRequest failed to open a request, error:
%u.\n", GetLastError());
+
+ index = 0;
+ len = sizeof(buffer);
+ ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_CUSTOM |
WINHTTP_QUERY_FLAG_REQUEST_HEADERS,
+ test_header_name, buffer, &len, &index);
+ ok(ret == FALSE, "WinHttpQueryHeaders unexpectedly succeeded, found
'Warning' header.\n");
+ ret = WinHttpAddRequestHeaders(request, test_headers[0], -1L,
WINHTTP_ADDREQ_FLAG_ADD);
+ ok(ret == TRUE, "WinHttpAddRequestHeader failed to add new header, got %d with
error %u.\n", ret, GetLastError());
+
+ index = 0;
+ len = sizeof(buffer);
+ ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_CUSTOM |
WINHTTP_QUERY_FLAG_REQUEST_HEADERS,
+ test_header_name, buffer, &len, &index);
+ ok(ret == TRUE, "WinHttpQueryHeaders failed: %u\n", GetLastError());
+ ok(index == 1, "WinHttpQueryHeaders failed: header index not
incremented\n");
+ ok(memcmp(buffer, test_indices[0], sizeof(test_indices[0])) == 0,
"WinHttpQueryHeaders failed: incorrect string returned\n");
+ ok(len == 5*sizeof(WCHAR), "WinHttpQueryHeaders failed: invalid length returned,
expected 5, got %d\n", len);
+
+ ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_CUSTOM |
WINHTTP_QUERY_FLAG_REQUEST_HEADERS,
+ test_header_name, buffer, &len, &index);
+ ok(ret == FALSE, "WinHttpQueryHeaders unexpectedly succeeded, second index
should not exist.\n");
+
+ /* Try to fetch the header info with a buffer that's big enough to fit the
+ * string but not the NULL terminator.
+ */
+ index = 0;
+ len = 5*sizeof(WCHAR);
+ memcpy(buffer, check_buffer, sizeof(buffer));
+ ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_CUSTOM |
WINHTTP_QUERY_FLAG_REQUEST_HEADERS,
+ test_header_name, buffer, &len, &index);
+ ok(ret == FALSE, "WinHttpQueryHeaders unexpectedly succeeded with a buffer
that's too small.\n");
+ ok(memcmp(buffer, check_buffer, sizeof(buffer)) == 0,
+ "WinHttpQueryHeaders failed, modified the buffer when it should not
have.\n");
+ ok(len == 6*sizeof(WCHAR), "WinHttpQueryHeaders returned invalid length,
expected 12, got %d\n", len);
+
+ /* Try with a NULL buffer */
+ index = 0;
+ len = sizeof(buffer);
+ SetLastError(0xdeadbeef);
+ ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_RAW_HEADERS_CRLF |
WINHTTP_QUERY_FLAG_REQUEST_HEADERS,
+ test_header_name, NULL, &len, &index);
+ ok(ret == FALSE, "WinHttpQueryHeaders unexpectedly succeeded.\n");
+ ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Expected
ERROR_INSUFFICIENT_BUFFER, got %u\n", GetLastError());
+ ok(len > 40, "WinHttpQueryHeaders returned invalid length: expected greater
than 40, got %d\n", len);
+ ok(index == 0, "WinHttpQueryHeaders incorrectly incremented header
index.\n");
+
+ /* Try with a NULL buffer and a length that's too small */
+ index = 0;
+ len = 10;
+ SetLastError(0xdeadbeef);
+ ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_RAW_HEADERS_CRLF |
WINHTTP_QUERY_FLAG_REQUEST_HEADERS,
+ test_header_name, NULL, &len, &index);
+ ok(ret == FALSE, "WinHttpQueryHeaders unexpectedly succeeded.\n");
+ ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER,
+ "WinHttpQueryHeaders set incorrect error: expected ERROR_INSUFFICENT_BUFFER,
go %u\n", GetLastError());
+ ok(len > 40, "WinHttpQueryHeaders returned invalid length: expected greater
than 40, got %d\n", len);
+ ok(index == 0, "WinHttpQueryHeaders incorrectly incremented header
index.\n");
+
+ index = 0;
+ len = 0;
+ SetLastError(0xdeadbeef);
+ ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_RAW_HEADERS_CRLF |
WINHTTP_QUERY_FLAG_REQUEST_HEADERS,
+ test_header_name, NULL, &len, &index);
+ ok(ret == FALSE, "WinHttpQueryHeaders unexpectedly succeeded.\n");
+ ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER,
+ "WinHttpQueryHeaders set incorrect error: expected
ERROR_INSUFFICIENT_BUFFER, got %u\n", GetLastError());
+ ok(len > 40, "WinHttpQueryHeaders returned invalid length: expected greater
than 40, got %d\n", len);
+ ok(index == 0, "WinHttpQueryHeaders failed: index was incremented.\n");
+
+ /* valid query */
+ oldlen = len;
+ index = 0;
+ len = sizeof(buffer);
+ memset(buffer, 0xff, sizeof(buffer));
+ ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_RAW_HEADERS_CRLF |
WINHTTP_QUERY_FLAG_REQUEST_HEADERS,
+ test_header_name, buffer, &len, &index);
+ ok(ret == TRUE, "WinHttpQueryHeaders failed: got %d\n", ret);
+ ok(len + sizeof(WCHAR) <= oldlen, "WinHttpQueryHeaders resulting length
longer than advertized.\n");
+ ok((len < sizeof(buffer) - sizeof(WCHAR)) && buffer[len / sizeof(WCHAR)]
== 0, "WinHttpQueryHeaders did not append NULL terminator\n");
+ ok(len == lstrlenW(buffer) * sizeof(WCHAR), "WinHttpQueryHeaders returned
incorrect length.\n");
+ ok(memcmp(buffer, test_header_begin, sizeof(test_header_begin)) == 0,
+ "WinHttpQueryHeaders returned invalid beginning of header string.\n");
+ ok(memcmp(buffer + lstrlenW(buffer) - 4, test_header_end, sizeof(test_header_end)) ==
0,
+ "WinHttpQueryHeaders returned invalid end of header string.\n");
+ ok(index == 0, "WinHttpQueryHeaders incremented header index.\n");
+
+ index = 0;
+ len = 0;
+ SetLastError(0xdeadbeef);
+ ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_RAW_HEADERS |
WINHTTP_QUERY_FLAG_REQUEST_HEADERS,
+ test_header_name, NULL, &len, &index);
+ ok(ret == FALSE, "WinHttpQueryHeaders unexpectedly succeeded.\n");
+ ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER,
+ "WinHttpQueryHeaders set incorrect error: expected
ERROR_INSUFFICIENT_BUFFER, got %u\n", GetLastError());
+ ok(len > 40, "WinHttpQueryHeaders returned invalid length: expected greater
than 40, got %d\n", len);
+ ok(index == 0, "WinHttpQueryHeaders failed: index was incremented.\n");
+
+ oldlen = len;
+ index = 0;
+ len = sizeof(buffer);
+ memset(buffer, 0xff, sizeof(buffer));
+ ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_RAW_HEADERS |
WINHTTP_QUERY_FLAG_REQUEST_HEADERS,
+ test_header_name, buffer, &len, &index);
+ ok(ret == TRUE, "WinHttpQueryHeaders failed %u\n", GetLastError());
+ ok(len + sizeof(WCHAR) <= oldlen, "resulting length longer than
advertized\n");
+ ok((len < sizeof(buffer) - sizeof(WCHAR)) && !buffer[len / sizeof(WCHAR)]
&& !buffer[len / sizeof(WCHAR) - 1],
+ "no double NULL terminator\n");
+ ok(!memcmp(buffer, test_header_begin, sizeof(test_header_begin)), "invalid
beginning of header string\n");
+ ok(index == 0, "header index was incremented\n");
+
+ /* tests for more indices */
+ ret = WinHttpAddRequestHeaders(request, test_headers[1], -1L,
WINHTTP_ADDREQ_FLAG_ADD);
+ ok(ret == TRUE, "WinHttpAddRequestHeaders failed to add duplicate header:
%d\n", ret);
+
+ index = 0;
+ len = sizeof(buffer);
+ ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_CUSTOM |
WINHTTP_QUERY_FLAG_REQUEST_HEADERS,
+ test_header_name, buffer, &len, &index);
+ ok(ret == TRUE, "WinHttpQueryHeaders failed: %u\n", GetLastError());
+ ok(index == 1, "WinHttpQueryHeaders failed to increment index.\n");
+ ok(memcmp(buffer, test_indices[0], sizeof(test_indices[0])) == 0,
"WinHttpQueryHeaders returned incorrect string.\n");
+
+ len = sizeof(buffer);
+ ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_CUSTOM |
WINHTTP_QUERY_FLAG_REQUEST_HEADERS,
+ test_header_name, buffer, &len, &index);
+ ok(ret == TRUE, "WinHttpQueryHeaders failed: %u\n", GetLastError());
+ ok(index == 2, "WinHttpQueryHeaders failed to increment index.\n");
+ ok(memcmp(buffer, test_indices[1], sizeof(test_indices[1])) == 0,
"WinHttpQueryHeaders returned incorrect string.\n");
+
+ ret = WinHttpAddRequestHeaders(request, test_headers[2], -1L,
WINHTTP_ADDREQ_FLAG_REPLACE);
+ ok(ret == TRUE, "WinHttpAddRequestHeaders failed to add duplicate
header.\n");
+
+ index = 0;
+ len = sizeof(buffer);
+ ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_CUSTOM |
WINHTTP_QUERY_FLAG_REQUEST_HEADERS,
+ test_header_name, buffer, &len, &index);
+ ok(ret == TRUE, "WinHttpQueryHeaders failed: %u\n", GetLastError());
+ ok(index == 1, "WinHttpQueryHeaders failed to increment index.\n");
+ ok(memcmp(buffer, test_indices[1], sizeof(test_indices[1])) == 0,
"WinHttpQueryHeaders returned incorrect string.\n");
+
+ len = sizeof(buffer);
+ ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_CUSTOM |
WINHTTP_QUERY_FLAG_REQUEST_HEADERS,
+ test_header_name, buffer, &len, &index);
+ ok(ret == TRUE, "WinHttpQueryHeaders failed: %u\n", GetLastError());
+ ok(index == 2, "WinHttpQueryHeaders failed to increment index.\n");
+ ok(memcmp(buffer, test_indices[2], sizeof(test_indices[2])) == 0,
"WinHttpQueryHeaders returned incorrect string.\n");
+
+ /* add if new flag */
+ ret = WinHttpAddRequestHeaders(request, test_headers[3], -1L,
WINHTTP_ADDREQ_FLAG_ADD_IF_NEW);
+ ok(ret == FALSE, "WinHttpAddRequestHeaders incorrectly replaced existing
header.\n");
+
+ index = 0;
+ len = sizeof(buffer);
+ ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_CUSTOM |
WINHTTP_QUERY_FLAG_REQUEST_HEADERS,
+ test_header_name, buffer, &len, &index);
+ ok(ret == TRUE, "WinHttpQueryHeaders failed: %u\n", GetLastError());
+ ok(index == 1, "WinHttpQueryHeaders failed to increment index.\n");
+ ok(memcmp(buffer, test_indices[1], sizeof(test_indices[1])) == 0,
"WinHttpQueryHeaders returned incorrect string.\n");
+
+ len = sizeof(buffer);
+ ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_CUSTOM |
WINHTTP_QUERY_FLAG_REQUEST_HEADERS,
+ test_header_name, buffer, &len, &index);
+ ok(ret == TRUE, "WinHttpQueryHeaders failed: %u\n", GetLastError());
+ ok(index == 2, "WinHttpQueryHeaders failed to increment index.\n");
+ ok(memcmp(buffer, test_indices[2], sizeof(test_indices[2])) == 0,
"WinHttpQueryHeaders returned incorrect string.\n");
+
+ len = sizeof(buffer);
+ ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_CUSTOM |
WINHTTP_QUERY_FLAG_REQUEST_HEADERS,
+ test_header_name, buffer, &len, &index);
+ ok(ret == FALSE, "WinHttpQueryHeaders succeeded unexpectedly, found third
header.\n");
+
+ /* coalesce flag */
+ ret = WinHttpAddRequestHeaders(request, test_headers[3], -1L,
WINHTTP_ADDREQ_FLAG_COALESCE);
+ ok(ret == TRUE, "WinHttpAddRequestHeaders failed with flag
WINHTTP_ADDREQ_FLAG_COALESCE.\n");
+
+ index = 0;
+ len = sizeof(buffer);
+ ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_CUSTOM |
WINHTTP_QUERY_FLAG_REQUEST_HEADERS,
+ test_header_name, buffer, &len, &index);
+ ok(ret == TRUE, "WinHttpQueryHeaders failed: %u\n", GetLastError());
+ ok(index == 1, "WinHttpQueryHeaders failed to increment index.\n");
+ ok(memcmp(buffer, test_flag_coalesce, sizeof(test_flag_coalesce)) == 0,
"WinHttpQueryHeaders returned incorrect string.\n");
+
+ len = sizeof(buffer);
+ ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_CUSTOM |
WINHTTP_QUERY_FLAG_REQUEST_HEADERS,
+ test_header_name, buffer, &len, &index);
+ ok(ret == TRUE, "WinHttpQueryHeaders failed: %u\n", GetLastError());
+ ok(index == 2, "WinHttpQueryHeaders failed to increment index.\n");
+ ok(memcmp(buffer, test_indices[2], sizeof(test_indices[2])) == 0,
"WinHttpQueryHeaders returned incorrect string.\n");
+
+ len = sizeof(buffer);
+ ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_CUSTOM |
WINHTTP_QUERY_FLAG_REQUEST_HEADERS,
+ test_header_name, buffer, &len, &index);
+ ok(ret == FALSE, "WinHttpQueryHeaders succeeded unexpectedly, found third
header.\n");
+
+ /* coalesce with comma flag */
+ ret = WinHttpAddRequestHeaders(request, test_headers[4], -1L,
WINHTTP_ADDREQ_FLAG_COALESCE_WITH_COMMA);
+ ok(ret == TRUE, "WinHttpAddRequestHeaders failed with flag
WINHTTP_ADDREQ_FLAG_COALESCE_WITH_COMMA.\n");
+
+ index = 0;
+ len = sizeof(buffer);
+ ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_CUSTOM |
WINHTTP_QUERY_FLAG_REQUEST_HEADERS,
+ test_header_name, buffer, &len, &index);
+ ok(ret == TRUE, "WinHttpQueryHeaders failed: %u\n", GetLastError());
+ ok(index == 1, "WinHttpQueryHeaders failed to increment index.\n");
+ ok(memcmp(buffer, test_flag_coalesce_comma, sizeof(test_flag_coalesce_comma)) == 0,
+ "WinHttpQueryHeaders returned incorrect string.\n");
+
+ len = sizeof(buffer);
+ ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_CUSTOM |
WINHTTP_QUERY_FLAG_REQUEST_HEADERS,
+ test_header_name, buffer, &len, &index);
+ ok(ret == TRUE, "WinHttpQueryHeaders failed: %u\n", GetLastError());
+ ok(index == 2, "WinHttpQueryHeaders failed to increment index.\n");
+ ok(memcmp(buffer, test_indices[2], sizeof(test_indices[2])) == 0,
"WinHttpQueryHeaders returned incorrect string.\n");
+
+ len = sizeof(buffer);
+ ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_CUSTOM |
WINHTTP_QUERY_FLAG_REQUEST_HEADERS,
+ test_header_name, buffer, &len, &index);
+ ok(ret == FALSE, "WinHttpQueryHeaders succeeded unexpectedly, found third
header.\n");
+
+
+ /* coalesce with semicolon flag */
+ ret = WinHttpAddRequestHeaders(request, test_headers[5], -1L,
WINHTTP_ADDREQ_FLAG_COALESCE_WITH_SEMICOLON);
+ ok(ret == TRUE, "WinHttpAddRequestHeaders failed with flag
WINHTTP_ADDREQ_FLAG_COALESCE_WITH_SEMICOLON.\n");
+
+ index = 0;
+ len = sizeof(buffer);
+ ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_CUSTOM |
WINHTTP_QUERY_FLAG_REQUEST_HEADERS,
+ test_header_name, buffer, &len, &index);
+ ok(ret == TRUE, "WinHttpQueryHeaders failed: %u\n", GetLastError());
+ ok(index == 1, "WinHttpQueryHeaders failed to increment index.\n");
+ ok(memcmp(buffer, test_flag_coalesce_semicolon, sizeof(test_flag_coalesce_semicolon))
== 0,
+ "WinHttpQueryHeaders returned incorrect string.\n");
+
+ len = sizeof(buffer);
+ ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_CUSTOM |
WINHTTP_QUERY_FLAG_REQUEST_HEADERS,
+ test_header_name, buffer, &len, &index);
+ ok(ret == TRUE, "WinHttpQueryHeaders failed: %u\n", GetLastError());
+ ok(index == 2, "WinHttpQueryHeaders failed to increment index.\n");
+ ok(memcmp(buffer, test_indices[2], sizeof(test_indices[2])) == 0,
"WinHttpQueryHeaders returned incorrect string.\n");
+
+ len = sizeof(buffer);
+ ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_CUSTOM |
WINHTTP_QUERY_FLAG_REQUEST_HEADERS,
+ test_header_name, buffer, &len, &index);
+ ok(ret == FALSE, "WinHttpQueryHeaders succeeded unexpectedly, found third
header.\n");
+
+ /* add and replace flags */
+ ret = WinHttpAddRequestHeaders(request, test_headers[3], -1L, WINHTTP_ADDREQ_FLAG_ADD
| WINHTTP_ADDREQ_FLAG_REPLACE);
+ ok(ret == TRUE, "WinHttpAddRequestHeaders failed with flag
WINHTTP_ADDREQ_FLAG_ADD | WINHTTP_ADDREQ_FLAG_REPLACE.\n");
+
+ index = 0;
+ len = sizeof(buffer);
+ ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_CUSTOM |
WINHTTP_QUERY_FLAG_REQUEST_HEADERS,
+ test_header_name, buffer, &len, &index);
+ ok(ret == TRUE, "WinHttpQueryHeaders failed: %u\n", GetLastError());
+ ok(index == 1, "WinHttpQueryHeaders failed to increment index.\n");
+ ok(memcmp(buffer, test_indices[2], sizeof(test_indices[2])) == 0,
"WinHttpQueryHeaders returned incorrect string.\n");
+
+ len = sizeof(buffer);
+ ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_CUSTOM |
WINHTTP_QUERY_FLAG_REQUEST_HEADERS,
+ test_header_name, buffer, &len, &index);
+ ok(ret == TRUE, "WinHttpQueryHeaders failed: %u\n", GetLastError());
+ ok(index == 2, "WinHttpQueryHeaders failed to increment index.\n");
+ ok(memcmp(buffer, test_indices[3], sizeof(test_indices[2])) == 0,
"WinHttpQueryHeaders returned incorrect string.\n");
+
+ len = sizeof(buffer);
+ ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_CUSTOM |
WINHTTP_QUERY_FLAG_REQUEST_HEADERS,
+ test_header_name, buffer, &len, &index);
+ ok(ret == FALSE, "WinHttpQueryHeaders succeeded unexpectedly, found third
header.\n");
+
+ ret = WinHttpAddRequestHeaders(request, test_headers[8], ~0UL,
WINHTTP_ADDREQ_FLAG_ADD);
+ ok(!ret, "WinHttpAddRequestHeaders failed\n");
+
+ ret = WinHttpAddRequestHeaders(request, test_headers[9], ~0UL,
WINHTTP_ADDREQ_FLAG_ADD);
+ ok(ret, "WinHttpAddRequestHeaders failed\n");
+
+ ret = WinHttpAddRequestHeaders(request, test_headers[10], ~0UL,
WINHTTP_ADDREQ_FLAG_ADD);
+ ok(!ret, "WinHttpAddRequestHeaders failed\n");
+
+ ret = WinHttpAddRequestHeaders(request, test_headers[11], ~0UL,
WINHTTP_ADDREQ_FLAG_ADD);
+ ok(!ret, "WinHttpAddRequestHeaders failed\n");
+
+ ret = WinHttpAddRequestHeaders(request, test_headers[12], ~0UL,
WINHTTP_ADDREQ_FLAG_ADD);
+ ok(!ret, "WinHttpAddRequestHeaders failed\n");
+
+ ret = WinHttpAddRequestHeaders(request, test_headers[13], ~0UL,
WINHTTP_ADDREQ_FLAG_ADD);
+ ok(ret, "WinHttpAddRequestHeaders failed\n");
+
+ index = 0;
+ buffer[0] = 0;
+ len = sizeof(buffer);
+ ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_CUSTOM |
WINHTTP_QUERY_FLAG_REQUEST_HEADERS,
+ field, buffer, &len, &index);
+ ok(ret, "WinHttpQueryHeaders failed: %u\n", GetLastError());
+ ok(!memcmp(buffer, value, sizeof(value)), "unexpected result\n");
+
+ ret = WinHttpCloseHandle(request);
+ ok(ret == TRUE, "WinHttpCloseHandle failed on closing request, got %d.\n",
ret);
+ done:
+ ret = WinHttpCloseHandle(connection);
+ ok(ret == TRUE, "WinHttpCloseHandle failed on closing connection, got
%d.\n", ret);
+ ret = WinHttpCloseHandle(session);
+ ok(ret == TRUE, "WinHttpCloseHandle failed on closing session, got %d.\n",
ret);
+
+}
+
+static void test_secure_connection(void)
+{
+ static const WCHAR google[] =
{'w','w','w','.','g','o','o','g','l','e','.','c','o','m',0};
+
+ HANDLE ses, con, req;
+ DWORD size, status, policy;
+ BOOL ret;
+
+ ses = WinHttpOpen(test_useragent, 0, NULL, NULL, 0);
+ ok(ses != NULL, "failed to open session %u\n", GetLastError());
+
+ policy = WINHTTP_OPTION_REDIRECT_POLICY_ALWAYS;
+ ret = WinHttpSetOption(ses, WINHTTP_OPTION_REDIRECT_POLICY, &policy,
sizeof(policy));
+ ok(ret, "failed to set redirect policy %u\n", GetLastError());
+
+ con = WinHttpConnect(ses, google, 443, 0);
+ ok(con != NULL, "failed to open a connection %u\n", GetLastError());
+
+ /* try without setting WINHTTP_FLAG_SECURE */
+ req = WinHttpOpenRequest(con, NULL, NULL, NULL, NULL, NULL, 0);
+ ok(req != NULL, "failed to open a request %u\n", GetLastError());
+
+ ret = WinHttpSendRequest(req, NULL, 0, NULL, 0, 0, 0);
+ ok(ret, "failed to send request %u\n", GetLastError());
+
+ ret = WinHttpReceiveResponse(req, NULL);
+ ok(!ret, "succeeded unexpectedly\n");
+
+ size = 0;
+ ret = WinHttpQueryHeaders(req, WINHTTP_QUERY_RAW_HEADERS_CRLF, NULL, NULL, &size,
NULL);
+ ok(!ret, "succeeded unexpectedly\n");
+
+ WinHttpCloseHandle(req);
+
+ req = WinHttpOpenRequest(con, NULL, NULL, NULL, NULL, NULL, WINHTTP_FLAG_SECURE);
+ ok(req != NULL, "failed to open a request %u\n", GetLastError());
+
+ ret = WinHttpSendRequest(req, NULL, 0, NULL, 0, 0, 0);
+ ok(ret, "failed to send request %u\n", GetLastError());
+
+ ret = WinHttpReceiveResponse(req, NULL);
+ ok(ret, "failed to receive response %u\n", GetLastError());
+
+ size = sizeof(status);
+ ret = WinHttpQueryHeaders(req, WINHTTP_QUERY_STATUS_CODE | WINHTTP_QUERY_FLAG_NUMBER,
NULL, &status, &size, NULL);
+ ok(ret, "failed unexpectedly %u\n", GetLastError());
+ ok(status == 200, "request failed unexpectedly %u\n", status);
+
+ size = 0;
+ ret = WinHttpQueryHeaders(req, WINHTTP_QUERY_RAW_HEADERS_CRLF, NULL, NULL, &size,
NULL);
+ ok(!ret, "succeeded unexpectedly\n");
+
+ WinHttpCloseHandle(req);
+ WinHttpCloseHandle(con);
+ WinHttpCloseHandle(ses);
+}
+
+static void test_request_parameter_defaults(void)
+{
+ static const WCHAR empty[] = {0};
+ static const WCHAR codeweavers[] =
{'c','o','d','e','w','e','a','v','e','r','s','.','c','o','m',0};
+
+ HANDLE ses, con, req;
+ DWORD size, status;
+ BOOL ret;
+
+ ses = WinHttpOpen(test_useragent, 0, NULL, NULL, 0);
+ ok(ses != NULL, "failed to open session %u\n", GetLastError());
+
+ con = WinHttpConnect(ses, codeweavers, 0, 0);
+ ok(con != NULL, "failed to open a connection %u\n", GetLastError());
+
+ req = WinHttpOpenRequest(con, NULL, NULL, NULL, NULL, NULL, 0);
+ ok(req != NULL, "failed to open a request %u\n", GetLastError());
+
+ ret = WinHttpSendRequest(req, NULL, 0, NULL, 0, 0, 0);
+ ok(ret, "failed to send request %u\n", GetLastError());
+
+ ret = WinHttpReceiveResponse(req, NULL);
+ ok(ret, "failed to receive response %u\n", GetLastError());
+
+ size = sizeof(status);
+ ret = WinHttpQueryHeaders(req, WINHTTP_QUERY_STATUS_CODE | WINHTTP_QUERY_FLAG_NUMBER,
NULL, &status, &size, NULL);
+ ok(ret, "failed unexpectedly %u\n", GetLastError());
+ ok(status == 200, "request failed unexpectedly %u\n", status);
+
+ WinHttpCloseHandle(req);
+
+ req = WinHttpOpenRequest(con, empty, empty, empty, NULL, NULL, 0);
+ ok(req != NULL, "failed to open a request %u\n", GetLastError());
+
+ ret = WinHttpSendRequest(req, NULL, 0, NULL, 0, 0, 0);
+ ok(ret, "failed to send request %u\n", GetLastError());
+
+ ret = WinHttpReceiveResponse(req, NULL);
+ ok(ret, "failed to receive response %u\n", GetLastError());
+
+ size = sizeof(status);
+ ret = WinHttpQueryHeaders(req, WINHTTP_QUERY_STATUS_CODE | WINHTTP_QUERY_FLAG_NUMBER,
NULL, &status, &size, NULL);
+ ok(ret, "failed unexpectedly %u\n", GetLastError());
+ ok(status == 200, "request failed unexpectedly %u\n", status);
+
+ WinHttpCloseHandle(req);
+ WinHttpCloseHandle(con);
+ WinHttpCloseHandle(ses);
+}
+
+START_TEST (winhttp)
+{
+ test_OpenRequest();
+ test_SendRequest();
+ test_WinHttpTimeFromSystemTime();
+ test_WinHttpTimeToSystemTime();
+ test_WinHttpAddHeaders();
+ test_secure_connection();
+ test_request_parameter_defaults();
+}
Propchange: trunk/rostests/winetests/winhttp/winhttp.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: trunk/rostests/winetests/winhttp/winhttp.rbuild
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/winhttp/winhttp…
==============================================================================
--- trunk/rostests/winetests/winhttp/winhttp.rbuild (added)
+++ trunk/rostests/winetests/winhttp/winhttp.rbuild [iso-8859-1] Sun Sep 7 08:50:21 2008
@@ -1,0 +1,16 @@
+<?xml version="1.0"?>
+<!DOCTYPE module SYSTEM "../../../tools/rbuild/project.dtd">
+<group>
+<module name="winhttp_winetest" type="win32cui"
installbase="bin" installname="winhttp_winetest.exe"
allowwarnings="true">
+ <include base="winhttp_winetest">.</include>
+ <define name="WINVER">0x600</define>
+ <define name="_WIN32_WINNT">0x600</define>
+ <file>notification.c</file>
+ <file>testlist.c</file>
+ <file>winhttp.c</file>
+ <library>wine</library>
+ <library>winhttp</library>
+ <library>kernel32</library>
+ <library>ntdll</library>
+</module>
+</group>
Propchange: trunk/rostests/winetests/winhttp/winhttp.rbuild
------------------------------------------------------------------------------
svn:eol-style = native