[PATCH 1/2] dpvoice/tests: Add GetCompressionTypes tests.
Alex Henrie
alexhenrie24 at gmail.com
Thu Jan 15 02:35:48 CST 2015
---
dlls/dpvoice/tests/voice.c | 184 ++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 182 insertions(+), 2 deletions(-)
diff --git a/dlls/dpvoice/tests/voice.c b/dlls/dpvoice/tests/voice.c
index 8048280..9a0af4e 100644
--- a/dlls/dpvoice/tests/voice.c
+++ b/dlls/dpvoice/tests/voice.c
@@ -343,6 +343,173 @@ static void create_voicetest(void)
}
}
+static void test_GetCompressionTypes(HRESULT (__stdcall *GetCompressionTypes)(void*,void*,DWORD*,DWORD*,DWORD),
+ void *iface, const char *name)
+{
+ DVCOMPRESSIONINFO data[32];
+ HRESULT ret;
+ DWORD data_size, num_elements;
+ int i, j;
+ LPWSTR string_loc;
+ BOOL found_pcm;
+
+ /* some variables are initialized to 99 just to check that they are not overwritten with 0 */
+ static struct
+ {
+ /* inputs */
+ DWORD data_size;
+ DWORD num_elements;
+ DWORD flags;
+ /* expected output */
+ HRESULT ret;
+ /* test flags */
+ enum
+ {
+ NULL_DATA = 1,
+ NULL_DATA_SIZE = 2,
+ NULL_NUM_ELEMENTS = 4,
+ SHARED_VARIABLE = 8
+ }
+ test_flags;
+ }
+ tests[] =
+ {
+ /* tests NULL data */
+ { 99, 99, 0, DVERR_BUFFERTOOSMALL, NULL_DATA },
+
+ /* tests NULL data_size */
+ { 0, 99, 0, DVERR_INVALIDPOINTER, NULL_DATA_SIZE },
+
+ /* tests NULL num_elements */
+ { 99, 0, 0, DVERR_INVALIDPOINTER, NULL_NUM_ELEMENTS },
+
+ /* tests passing the same pointer for data_size and num_elements */
+ { 10, 0, 0, DVERR_BUFFERTOOSMALL, SHARED_VARIABLE },
+
+ /* tests the same as above but with an ample buffer */
+ { sizeof(data) - 1, 0, 0, DVERR_BUFFERTOOSMALL, SHARED_VARIABLE },
+
+ /* tests flags!=0 */
+ { 99, 99, 1, DVERR_INVALIDFLAGS },
+
+ /* tests data_size=0 */
+ { 0, 99, 0, DVERR_BUFFERTOOSMALL },
+
+ /* tests data_size=1 */
+ { 1, 99, 0, DVERR_BUFFERTOOSMALL },
+
+ /* tests data_size = sizeof(DVCOMPRESSIONINFO) */
+ { sizeof(DVCOMPRESSIONINFO), 99, 0, DVERR_BUFFERTOOSMALL },
+
+ /* tests data_size = returned data_size - 1 */
+ { 0 /* initialized later */, 99, 0, DVERR_BUFFERTOOSMALL },
+
+ /* tests data_size = returned data_size */
+ { 0 /* initialized later */, 99, 0, DV_OK },
+
+ /* tests data_size = returned data_size + 1 */
+ { 0 /* initialized later */, 99, 0, DV_OK }
+ };
+
+ if(GetCompressionTypes(iface, NULL, NULL, NULL, 0) == E_NOTIMPL)
+ {
+ skip("%s: GetCompressionTypes not implemented\n", name);
+ return;
+ }
+
+ ret = GetCompressionTypes(iface, NULL, &data_size, &num_elements, 0);
+ ok(ret == DVERR_BUFFERTOOSMALL,
+ "%s: expected ret=%x got ret=%x\n", name, DVERR_BUFFERTOOSMALL, ret);
+ ok(data_size > sizeof(DVCOMPRESSIONINFO) && data_size < sizeof(data) - 1,
+ "%s: expected data_size between %i and %i got data_size=%i\n",
+ name, sizeof(DVCOMPRESSIONINFO), sizeof(data) - 1, data_size);
+ tests[sizeof(tests) / sizeof(tests[0]) - 3].data_size = data_size - 1;
+ tests[sizeof(tests) / sizeof(tests[0]) - 2].data_size = data_size;
+ tests[sizeof(tests) / sizeof(tests[0]) - 1].data_size = data_size + 1;
+
+ for(i = 0; i < sizeof(tests) / sizeof(tests[0]); i++)
+ {
+ memset(data, 0x23, sizeof(data));
+
+ data_size = tests[i].data_size;
+ num_elements = tests[i].num_elements;
+
+ ret = GetCompressionTypes(
+ iface,
+ tests[i].test_flags & NULL_DATA ? NULL : data,
+ tests[i].test_flags & NULL_DATA_SIZE ? NULL : &data_size,
+ tests[i].test_flags & NULL_NUM_ELEMENTS ? NULL :
+ tests[i].test_flags & SHARED_VARIABLE ? &data_size : &num_elements,
+ tests[i].flags
+ );
+
+ ok(ret == tests[i].ret,
+ "%s: tests[%i]: expected ret=%x got ret=%x\n", name, i, tests[i].ret, ret);
+
+ if(ret == DV_OK || ret == DVERR_BUFFERTOOSMALL)
+ {
+ ok(data_size > sizeof(DVCOMPRESSIONINFO),
+ "%s: tests[%i]: expected data_size>%i got data_size=%i\n",
+ name, i, sizeof(DVCOMPRESSIONINFO), data_size);
+ if(!(tests[i].test_flags & SHARED_VARIABLE))
+ ok(num_elements > 0,
+ "%s: tests[%i]: expected num_elements>0 got num_elements=%i\n",
+ name, i, num_elements);
+ }
+ else
+ {
+ ok(data_size == tests[i].data_size,
+ "%s: tests[%i]: expected data_size=%i got data_size=%i\n",
+ name, i, tests[i].data_size, data_size);
+ ok(num_elements == tests[i].num_elements,
+ "%s: tests[%i]: expected num_elements=%i got num_elements=%i\n",
+ name, i, tests[i].num_elements, num_elements);
+ }
+
+ if(ret == DV_OK)
+ {
+ string_loc = (LPWSTR)((char*)data + num_elements * sizeof(DVCOMPRESSIONINFO));
+ found_pcm = FALSE;
+ for(j = 0; j < num_elements; j++)
+ {
+ if(memcmp(&data[j].guidType, &DPVCTGUID_NONE, sizeof(GUID)) == 0)
+ {
+ ok(data[j].dwMaxBitsPerSecond == 64000,
+ "%s: tests[%i]: data[%i]: expected dwMaxBitsPerSecond=64000 got dwMaxBitsPerSecond=%i\n",
+ name, i, j, data[j].dwMaxBitsPerSecond);
+ found_pcm = TRUE;
+ }
+ ok(data[j].dwSize == 80,
+ "%s: tests[%i]: data[%i]: expected dwSize=80 got dwSize=%i\n",
+ name, i, j, data[j].dwSize);
+ ok(data[j].lpszName == string_loc,
+ "%s: tests[%i]: data[%i]: expected lpszName=%p got lpszName=%p\n",
+ name, i, j, string_loc, data[j].lpszName);
+ ok(!data[j].lpszDescription,
+ "%s: tests[%i]: data[%i]: expected lpszDescription=NULL got lpszDescription=%s\n",
+ name, i, j, wine_dbgstr_w(data[j].lpszDescription));
+ ok(!data[j].dwFlags,
+ "%s: tests[%i]: data[%i]: expected dwFlags=0 got dwFlags=%i\n",
+ name, i, j, data[j].dwFlags);
+ string_loc += lstrlenW(data[j].lpszName) + 1;
+ }
+ ok((char*)string_loc == (char*)data + data_size,
+ "%s: tests[%i]: expected string_loc=%p got string_loc=%p\n",
+ name, i, (char*)data + data_size, string_loc);
+ ok(*(char*)string_loc == 0x23,
+ "%s: tests[%i]: expected *(char*)string_loc=0x23 got *(char*)string_loc=0x%x\n",
+ name, i, *(char*)string_loc);
+ ok(found_pcm, "%s: tests[%i]: MS-PCM codec not found\n", name, i);
+ }
+ else
+ {
+ ok(*(char*)data == 0x23,
+ "%s: tests[%i]: expected *(char*)data=0x23 got *(char*)data=0x%x\n",
+ name, i, *(char*)data);
+ }
+ }
+}
+
START_TEST(voice)
{
HRESULT hr;
@@ -354,9 +521,22 @@ START_TEST(voice)
create_voicetest();
- if(test_init_dpvoice_server() && test_init_dpvoice_client())
+ if(test_init_dpvoice_server())
+ {
+ test_GetCompressionTypes((void*)vserver->lpVtbl->GetCompressionTypes, vserver, "server");
+
+ if(test_init_dpvoice_client())
+ {
+ test_GetCompressionTypes((void*)vclient->lpVtbl->GetCompressionTypes, vclient, "client");
+ }
+ else
+ {
+ skip("client failed to initialize\n");
+ }
+ }
+ else
{
- /* TODO */
+ skip("server failed to initialize\n");
}
test_cleanup_dpvoice();
--
2.2.2
More information about the wine-patches
mailing list