static void test_read_state_(IXmlReader *reader, XmlReadState expected, XmlReadState exp_broken, int todo, int line) { XmlReadState state; HRESULT hr; int broken_state; state = -1; /* invalid value */ hr = IXmlReader_GetProperty(reader, XmlReaderProperty_ReadState, (LONG_PTR*)&state); ok_(__FILE__, line)(hr == S_OK, "Expected S_OK, got %08x\n", hr); if (exp_broken == -1) broken_state = 0; else broken_state = broken(exp_broken == state); if (todo) { todo_wine ok_(__FILE__, line)(state == expected || broken_state, "Expected (%s), got (%s)\n", state_to_str(expected), state_to_str(state)); } else ok_(__FILE__, line)(state == expected || broken_state, "Expected (%s), got (%s)\n", state_to_str(expected), state_to_str(state)); }
static void ok_pos_(IXmlReader *reader, int line, int pos, int line_broken, int pos_broken, int todo, int _line_) { UINT l, p; HRESULT hr; int broken_state; hr = IXmlReader_GetLineNumber(reader, &l); ok_(__FILE__, _line_)(hr == S_OK, "Expected S_OK, got %08x\n", hr); hr = IXmlReader_GetLinePosition(reader, &p); ok_(__FILE__, _line_)(hr == S_OK, "Expected S_OK, got %08x\n", hr); if (line_broken == -1 && pos_broken == -1) broken_state = 0; else broken_state = broken((line_broken == -1 ? line : line_broken) == l && (pos_broken == -1 ? pos : pos_broken) == p); if (todo) todo_wine ok_(__FILE__, _line_)((l == line && pos == p) || broken_state, "Expected (%d,%d), got (%d,%d)\n", line, pos, l, p); else { ok_(__FILE__, _line_)((l == line && pos == p) || broken_state, "Expected (%d,%d), got (%d,%d)\n", line, pos, l, p); } }
static void run_test_(TASKDIALOGCONFIG *info, int expect_button, int expect_radio_button, BOOL verification_checked, const struct message_info *test_messages, const char *context, int test_messages_len, const char *file, int line) { struct message *msg, *msg_start; int ret_button = 0; int ret_radio = 0; BOOL ret_verification = FALSE; HRESULT hr; int i; /* Allocate messages to test against, plus 2 implicit and 1 empty */ msg_start = msg = heap_alloc_zero(sizeof(*msg) * (test_messages_len + 3)); /* Always needed, thus made implicit */ init_test_message(TDN_DIALOG_CONSTRUCTED, 0, 0, msg++); for (i = 0; i < test_messages_len; i++) init_test_message(test_messages[i].message, test_messages[i].wparam, test_messages[i].lparam, msg++); /* Always needed, thus made implicit */ init_test_message(TDN_DESTROYED, 0, 0, msg++); current_message_info = test_messages; flush_sequences(sequences, NUM_MSG_SEQUENCES); hr = pTaskDialogIndirect(info, &ret_button, &ret_radio, &ret_verification); ok_(file, line)(hr == S_OK, "TaskDialogIndirect() failed, got %#x.\n", hr); ok_sequence_(sequences, TASKDIALOG_SEQ_INDEX, msg_start, context, FALSE, file, line); ok_(file, line)(ret_button == expect_button, "Wrong button. Expected %d, got %d\n", expect_button, ret_button); ok_(file, line)(ret_radio == expect_radio_button, "Wrong radio button. Expected %d, got %d\n", expect_radio_button, ret_radio); heap_free(msg_start); }
static void ok_sequence_(struct call_sequence **seq, int sequence_index, const struct call_entry *expected, const char *context, BOOL todo, const char *file, int line) { struct call_sequence *call_seq = seq[sequence_index]; static const struct call_entry end_of_sequence = { LastKind }; const struct call_entry *actual, *sequence; int failcount = 0; struct testcontext ctxt; add_call(seq, sequence_index, &end_of_sequence); sequence = call_seq->sequence; actual = sequence; ctxt.failcount = &failcount; ctxt.todo = todo; ctxt.file = file; ctxt.line = line; while (expected->kind != LastKind && actual->kind != LastKind) { if (expected->kind == actual->kind) { ctxt.kind = expected->kind; switch (actual->kind) { case ScriptAnalysis: test_uint(actual->sa.pos, expected->sa.pos, "position", &ctxt); test_uint(actual->sa.len, expected->sa.len, "length", &ctxt); test_uint(actual->sa.shapes, expected->sa.shapes, "shapes", &ctxt); break; default: ok(0, "%s: callback not handled, %s\n", context, get_analysis_kind_name(actual->kind)); } expected++; actual++; } else if (todo) { failcount++; todo_wine { ok_(file, line) (0, "%s: call %s was expected, but got call %s instead\n", context, get_analysis_kind_name(expected->kind), get_analysis_kind_name(actual->kind)); } flush_sequence(seq, sequence_index); return; } else { ok_(file, line) (0, "%s: call %s was expected, but got call %s instead\n", context, get_analysis_kind_name(expected->kind), get_analysis_kind_name(actual->kind)); expected++; actual++; } }
static void _test_state(unsigned line, IActiveScript *script, SCRIPTSTATE exstate) { SCRIPTSTATE state = -1; HRESULT hres; hres = IActiveScript_GetScriptState(script, &state); ok_(__FILE__,line) (hres == S_OK, "GetScriptState failed: %08x\n", hres); ok_(__FILE__,line) (state == exstate, "state=%d, expected %d\n", state, exstate); }
static void _call_change_type(unsigned line, IVariantChangeType *change_type, VARIANT *dst, VARIANT *src, VARTYPE vt) { HRESULT hres; VariantInit(dst); hres = IVariantChangeType_ChangeType(change_type, dst, src, 0, vt); ok_(__FILE__,line)(hres == S_OK, "ChangeType(%d) failed: %08x\n", vt, hres); ok_(__FILE__,line)(V_VT(dst) == vt, "V_VT(dst) = %d\n", V_VT(dst)); }
static void _test_hash_length(unsigned line, void *handle, ULONG exlen) { ULONG len = 0xdeadbeef, size = 0xdeadbeef; NTSTATUS status; status = BCryptGetProperty(handle, BCRYPT_HASH_LENGTH, (UCHAR *)&len, sizeof(len), &size, 0); ok_(__FILE__,line)(status == STATUS_SUCCESS, "BCryptGetProperty failed: %08x\n", status); ok_(__FILE__,line)(size == sizeof(len), "got %u\n", size); ok_(__FILE__,line)(len == exlen, "len = %u, expected %u\n", len, exlen); }
static void test_locator(unsigned line, int loc_line, int loc_column) { int rcolumn, rline; ISAXLocator_getLineNumber(locator, &rline); ISAXLocator_getColumnNumber(locator, &rcolumn); ok_(__FILE__,line) (rline == loc_line, "unexpected line %d, expected %d\n", rline, loc_line); ok_(__FILE__,line) (rcolumn == loc_column, "unexpected column %d, expected %d\n", rcolumn, loc_column); }
static void _test_strtod_str(int line, const char* string, double value, int length) { char *end; double d; d = p_strtod(string, &end); if (local_isnan(value)) ok_(__FILE__, line)(local_isnan(d), "d = %lf (\"%s\")\n", d, string); else ok_(__FILE__, line)(d == value, "d = %lf (\"%s\")\n", d, string); ok_(__FILE__, line)(end == string + length, "incorrect end (%d, \"%s\")\n", (int)(end - string), string); }
static void test_uint(UINT32 actual, UINT32 expected, const char *name, const struct testcontext *ctxt) { if (expected != actual && ctxt->todo) { (*ctxt->failcount)++; ok_(ctxt->file, ctxt->line) (0, "%s: \"%s\" expecting %u, got %u\n", get_analysis_kind_name(ctxt->kind), name, expected, actual); } else ok_(ctxt->file, ctxt->line) (expected == actual, "%s: \"%s\" expecting %u, got %u\n", get_analysis_kind_name(ctxt->kind), name, expected, actual); }
static void expect_buf_offset_dbg(HMMIO hmmio, LONG off, int line) { MMIOINFO mmio; LONG ret; memset(&mmio, 0, sizeof(mmio)); ret = mmioGetInfo(hmmio, &mmio, 0); ok_(__FILE__, line)(ret == MMSYSERR_NOERROR, "mmioGetInfo error %u\n", ret); ok_(__FILE__, line)(mmio.lBufOffset == 0, "expected 0, got %d\n", mmio.lBufOffset); ret = mmioSeek(hmmio, 0, SEEK_CUR); ok_(__FILE__, line)(ret == off, "expected %d, got %d\n", off, ret); }
static void _test_alg_name(unsigned line, void *handle, const char *exname) { ULONG size = 0xdeadbeef; UCHAR buf[256]; const WCHAR *name = (const WCHAR*)buf; NTSTATUS status; status = BCryptGetProperty(handle, BCRYPT_ALGORITHM_NAME, buf, sizeof(buf), &size, 0); ok_(__FILE__,line)(status == STATUS_SUCCESS, "BCryptGetProperty failed: %08x\n", status); ok_(__FILE__,line)(size == (strlen(exname)+1)*sizeof(WCHAR), "got %u\n", size); ok_(__FILE__,line)(!strcmp_wa(name, exname), "alg name = %s, expected %s\n", wine_dbgstr_w(name), exname); }
static void _get_disp_id(unsigned line, IDispatchEx *dispex, const char *name, HRESULT exhres, DISPID *id) { DISPID id2; BSTR str; HRESULT hres; str = a2bstr(name); hres = IDispatchEx_GetDispID(dispex, str, 0, id); ok_(__FILE__,line)(hres == exhres, "GetDispID(%s) returned %08x, expected %08x\n", name, hres, exhres); hres = IDispatchEx_GetIDsOfNames(dispex, &IID_NULL, &str, 1, 0, &id2); SysFreeString(str); ok_(__FILE__,line)(hres == exhres, "GetIDsOfNames(%s) returned %08x, expected %08x\n", name, hres, exhres); ok_(__FILE__,line)(*id == id2, "GetIDsOfNames(%s) id != id2\n", name); }
static void _test_shortcut_url(unsigned line, IUnknown *unk, const char *exurl) { IUniformResourceLocatorA *locator_a; char *url_a; HRESULT hres; hres = IUnknown_QueryInterface(unk, &IID_IUniformResourceLocatorA, (void**)&locator_a); ok_(__FILE__,line)(hres == S_OK, "Could not get IUniformResourceLocatorA iface: %08x\n", hres); hres = locator_a->lpVtbl->GetURL(locator_a, &url_a); ok_(__FILE__,line)(hres == S_OK, "GetURL failed: %08x\n", hres); ok_(__FILE__,line)(!strcmp(url_a, exurl), "unexpected URL, got %s, expected %s\n", url_a, exurl); CoTaskMemFree(url_a); IUnknown_Release((IUnknown*)locator_a); }
static void _check_pipe_handle_state(int line, HANDLE handle, ULONG read, ULONG completion) { IO_STATUS_BLOCK iosb; FILE_PIPE_INFORMATION fpi; NTSTATUS res; if (handle != INVALID_HANDLE_VALUE) { memset(&fpi, 0x55, sizeof(fpi)); res = pNtQueryInformationFile(handle, &iosb, &fpi, sizeof(fpi), (FILE_INFORMATION_CLASS)23); ok_(__FILE__, line)(!res, "NtQueryInformationFile returned %x\n", res); ok_(__FILE__, line)(fpi.ReadMode == read, "Unexpected ReadMode, expected %x, got %x\n", read, fpi.ReadMode); ok_(__FILE__, line)(fpi.CompletionMode == completion, "Unexpected CompletionMode, expected %x, got %x\n", completion, fpi.CompletionMode); } }
static void check_blob(int line, DWORD cred_type, PCREDENTIALA cred) { if (cred_type == CRED_TYPE_DOMAIN_PASSWORD) { ok_(__FILE__, line)(cred->CredentialBlobSize == 0, "expected CredentialBlobSize of 0 but got %d\n", cred->CredentialBlobSize); ok_(__FILE__, line)(!cred->CredentialBlob, "expected NULL credentials but got %p\n", cred->CredentialBlob); } else { DWORD size=sizeof(TEST_PASSWORD); ok_(__FILE__, line)(cred->CredentialBlobSize == size, "expected CredentialBlobSize of %u but got %u\n", size, cred->CredentialBlobSize); ok_(__FILE__, line)(cred->CredentialBlob != NULL, "CredentialBlob should be present\n"); if (cred->CredentialBlob) ok_(__FILE__, line)(!memcmp(cred->CredentialBlob, TEST_PASSWORD, size), "wrong CredentialBlob\n"); } }
static void _expect_ref(IUnknown* obj, ULONG ref, int line) { ULONG rc; IUnknown_AddRef(obj); rc = IUnknown_Release(obj); ok_(__FILE__,line)(rc == ref, "expected refcount %d, got %d\n", ref, rc); }
static int _okChildInt(const char* file, int line, const char* key, int expected) { INT result; result=GetPrivateProfileIntA("Arguments", key, expected, child_file); return ok_(file, line)(result == expected, "%s expected %d, but got %d\n", key, expected, result); }
static int _okChildPath(const char* file, int line, const char* key, const char* expected) { char* result; result=getChildString("Arguments", key); return ok_(file, line)(StrCmpPath(result, expected) == 0, "%s expected '%s', got '%s'\n", key, expected, result); }
static void getstring_test(LPCWSTR assocName, HKEY progIdKey, ASSOCSTR str, LPCWSTR expected_string, int line) { IQueryAssociations *assoc; HRESULT hr; WCHAR *buffer = NULL; DWORD len; hr = CoCreateInstance(&CLSID_QueryAssociations, NULL, CLSCTX_INPROC_SERVER, &IID_IQueryAssociations, (void*)&assoc); ok_(__FILE__, line)(hr == S_OK, "failed to create IQueryAssociations, 0x%x\n", hr); hr = IQueryAssociations_Init(assoc, ASSOCF_NONE, assocName, progIdKey, NULL); ok_(__FILE__, line)(hr == S_OK, "IQueryAssociations::Init failed, 0x%x\n", hr); hr = IQueryAssociations_GetString(assoc, ASSOCF_NONE, str, NULL, NULL, &len); if (expected_string) { ok_(__FILE__, line)(hr == S_FALSE, "GetString returned 0x%x, expected S_FALSE\n", hr); if (hr != S_FALSE) { /* don't try to allocate memory using uninitialized len */ IQueryAssociations_Release(assoc); return; } buffer = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); ok_(__FILE__, line)(buffer != NULL, "out of memory\n"); hr = IQueryAssociations_GetString(assoc, 0, str, NULL, buffer, &len); ok_(__FILE__, line)(hr == S_OK, "GetString returned 0x%x, expected S_OK\n", hr); ok_(__FILE__, line)(lstrcmpW(buffer, expected_string) == 0, "GetString returned %s, expected %s\n", wine_dbgstr_w(buffer), wine_dbgstr_w(expected_string)); } else { ok_(__FILE__, line)(FAILED(hr), "GetString returned 0x%x, expected failure\n", hr); } IQueryAssociations_Release(assoc); HeapFree(GetProcessHeap(), 0, buffer); }
static void _change_type_fail(unsigned line, IVariantChangeType *change_type, VARIANT *src, VARTYPE vt, HRESULT exhres) { VARIANT v; HRESULT hres; V_VT(&v) = VT_EMPTY; hres = IVariantChangeType_ChangeType(change_type, &v, src, 0, vt); ok_(__FILE__,line)(hres == exhres, "ChangeType failed: %08x, expected %08x\n", hres, exhres); }
static void _test_event_args(unsigned line, const IID *dispiid, const IID *broken_dispiid, DISPID id, WORD wFlags, DISPPARAMS *pdp, VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller) { ok_(__FILE__,line) (id == DISPID_VALUE, "id = %d\n", id); ok_(__FILE__,line) (wFlags == DISPATCH_METHOD, "wFlags = %x\n", wFlags); ok_(__FILE__,line) (pdp != NULL, "pdp == NULL\n"); ok_(__FILE__,line) (pdp->cArgs == 1, "pdp->cArgs = %d\n", pdp->cArgs); ok_(__FILE__,line) (pdp->cNamedArgs == 1, "pdp->cNamedArgs = %d\n", pdp->cNamedArgs); ok_(__FILE__,line) (pdp->rgdispidNamedArgs[0] == DISPID_THIS, "pdp->rgdispidNamedArgs[0] = %d\n", pdp->rgdispidNamedArgs[0]); ok_(__FILE__,line) (V_VT(pdp->rgvarg) == VT_DISPATCH, "V_VT(rgvarg) = %d\n", V_VT(pdp->rgvarg)); ok_(__FILE__,line) (pvarRes != NULL, "pvarRes == NULL\n"); ok_(__FILE__,line) (pei != NULL, "pei == NULL"); ok_(__FILE__,line) (!pspCaller, "pspCaller != NULL\n"); if(dispiid) _test_disp(line, (IUnknown*)V_DISPATCH(pdp->rgvarg), dispiid, broken_dispiid); }
static void _test_key_exists(unsigned line, HKEY root, const char *key_name) { HKEY key; DWORD res; res = RegOpenKeyA(root, key_name, &key); ok_(__FILE__,line)(res == ERROR_SUCCESS, "Could not open key %s\n", key_name); if(res == ERROR_SUCCESS) RegCloseKey(key); }
static void _call_procedure(unsigned line, IDispatchEx *proc, IServiceProvider *caller) { DISPPARAMS dp = {NULL,NULL,0,0}; EXCEPINFO ei = {0}; HRESULT hres; hres = IDispatchEx_InvokeEx(proc, DISPID_VALUE, 0, DISPATCH_METHOD, &dp, NULL, &ei, caller); ok_(__FILE__,line)(hres == S_OK, "InvokeEx failed: %08x\n", hres); }
static void _parse_script_a(unsigned line, IActiveScriptParse *parser, const char *script) { BSTR str; HRESULT hres; str = a2bstr(script); hres = IActiveScriptParse64_ParseScriptText(parser, str, NULL, NULL, NULL, 0, 0, 0, NULL, NULL); SysFreeString(str); ok_(__FILE__,line)(hres == S_OK, "ParseScriptText failed: %08x\n", hres); }
static void _test_key_not_exists(unsigned line, HKEY root, const char *key_name) { HKEY key; DWORD res; res = RegOpenKeyA(root, key_name, &key); ok_(__FILE__,line)(res == ERROR_FILE_NOT_FOUND, "Attempting to open %s returned %u\n", key_name, res); if(res == ERROR_SUCCESS) RegCloseKey(key); }
static void ok_sequence_(struct drawcall_sequence **seq, int sequence_index, const struct drawcall_entry *expected, const char *context, BOOL todo, const char *file, int line) { static const struct drawcall_entry end_of_sequence = { DRAW_LAST_KIND }; struct drawcall_sequence *call_seq = seq[sequence_index]; const struct drawcall_entry *actual, *sequence; int failcount = 0; add_call(seq, sequence_index, &end_of_sequence); sequence = call_seq->sequence; actual = sequence; while (expected->kind != DRAW_LAST_KIND && actual->kind != DRAW_LAST_KIND) { if (expected->kind != actual->kind) { if (todo) { failcount++; todo_wine ok_(file, line) (0, "%s: call %s was expected, but got call %s instead\n", context, get_draw_kind_name(expected->kind), get_draw_kind_name(actual->kind)); flush_sequence(seq, sequence_index); return; } else ok_(file, line) (0, "%s: call %s was expected, but got call %s instead\n", context, get_draw_kind_name(expected->kind), get_draw_kind_name(actual->kind)); } expected++; actual++; } if (todo) { todo_wine { if (expected->kind != DRAW_LAST_KIND || actual->kind != DRAW_LAST_KIND) { failcount++; ok_(file, line) (0, "%s: the call sequence is not complete: expected %s - actual %s\n", context, get_draw_kind_name(expected->kind), get_draw_kind_name(actual->kind)); } } } else if (expected->kind != DRAW_LAST_KIND || actual->kind != DRAW_LAST_KIND)
static HRESULT check_expect_(enum method func, DWORD expect_param, DWORD *set_param, const char *file, int line ) { HRESULT hr; do { todo_wine_if(call_ptr->called_todo) ok_( file, line )( func == call_ptr->method, "unexpected call %s instead of %s\n", method_names[func], method_names[call_ptr->method] ); if (call_ptr->method == func) break; } while ((++call_ptr)->method != end_seq); ok_( file, line )( expect_param == call_ptr->expect_param, "%s: unexpected param %08x expected %08x\n", method_names[func], expect_param, call_ptr->expect_param ); if (set_param) *set_param = call_ptr->set_param; hr = call_ptr->set_ret; if (call_ptr->method != end_seq) call_ptr++; return hr; }
static void _check_file_not_exists(LONG l, LPCSTR filename) { HANDLE file; file = CreateFileA(filename, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); ok_(__FILE__,l)(file == INVALID_HANDLE_VALUE, "expected file not to exist\n"); if (file != INVALID_HANDLE_VALUE) CloseHandle(file); }
static void CheckSize(HWND hwnd, INT width, INT height, const char *msg, int line) { RECT r; SendMessage(hwnd, TCM_GETITEMRECT, 0, (LPARAM)&r); if (width >= 0 && height < 0) { ok_(__FILE__,line) (width == r.right - r.left, "%s: Expected width [%d] got [%d]\n",\ msg, width, r.right - r.left); } else if (height >= 0 && width < 0) { ok_(__FILE__,line) (height == r.bottom - r.top, "%s: Expected height [%d] got [%d]\n",\ msg, height, r.bottom - r.top); } else ok_(__FILE__,line) ((width == r.right - r.left) && (height == r.bottom - r.top ), "%s: Expected [%d,%d] got [%d,%d]\n", msg, width, height, r.right - r.left, r.bottom - r.top); }