Module: wine Branch: master Commit: ddecb6aae5d61fad0b95a76fe3e4ae178b4af8d8 URL: http://source.winehq.org/git/wine.git/?a=commit;h=ddecb6aae5d61fad0b95a76fe3...
Author: Christian Costa titan.costa@gmail.com Date: Sun Feb 19 21:02:42 2012 +0100
d3dxof: Add tests for IDirectXFileData_GetName.
---
dlls/d3dxof/tests/d3dxof.c | 95 ++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 92 insertions(+), 3 deletions(-)
diff --git a/dlls/d3dxof/tests/d3dxof.c b/dlls/d3dxof/tests/d3dxof.c index 5c6315a..40ad10c 100644 --- a/dlls/d3dxof/tests/d3dxof.c +++ b/dlls/d3dxof/tests/d3dxof.c @@ -84,6 +84,13 @@ static char empty_bzip_file[] = "xof 0302bzip0064\x11\x00\x00\x00\x01\x00\x05\x0 static char empty_cmp_file[] = "xof 0302cmp 0064"; static char empty_xxxx_file[] = "xof 0302xxxx0064";
+static char object_noname[] = +"xof 0302txt 0064\n" +"Header\n" +"{\n" +"1; 2; 3;\n" +"}\n"; + static void init_function_pointers(void) { /* We have to use LoadLibrary as no d3dxof functions are referenced directly */ @@ -115,7 +122,7 @@ static void test_refcount(void)
hr = pDirectXFileCreate(&lpDirectXFile); ok(hr == DXFILE_OK, "DirectXFileCreate: %x\n", hr); - if(!lpDirectXFile) + if (!lpDirectXFile) { skip("Couldn't create DirectXFile interface\n"); return; @@ -187,7 +194,7 @@ static void test_CreateEnumObject(void)
hr = pDirectXFileCreate(&lpDirectXFile); ok(hr == DXFILE_OK, "DirectXFileCreate: %x\n", hr); - if(!lpDirectXFile) + if (!lpDirectXFile) { skip("Couldn't create DirectXFile interface\n"); return; @@ -369,6 +376,87 @@ static void test_compressed_files(void) IDirectXFile_Release(dxfile); }
+static void test_getname(void) +{ + HRESULT hr; + ULONG ref; + LPDIRECTXFILE lpDirectXFile = NULL; + LPDIRECTXFILEENUMOBJECT lpdxfeo; + LPDIRECTXFILEDATA lpdxfd; + DXFILELOADMEMORY dxflm; + char name[100]; + DWORD length; + + if (!pDirectXFileCreate) + { + win_skip("DirectXFileCreate is not available\n"); + return; + } + + hr = pDirectXFileCreate(&lpDirectXFile); + ok(hr == DXFILE_OK, "DirectXFileCreate: %x\n", hr); + if (!lpDirectXFile) + { + skip("Couldn't create DirectXFile interface\n"); + return; + } + + hr = IDirectXFile_RegisterTemplates(lpDirectXFile, template, sizeof(template) - 1); + ok(hr == DXFILE_OK, "IDirectXFileImpl_RegisterTemplates: %x\n", hr); + + /* Check object with name */ + dxflm.lpMemory = &object; + dxflm.dSize = sizeof(object) - 1; + hr = IDirectXFile_CreateEnumObject(lpDirectXFile, &dxflm, DXFILELOAD_FROMMEMORY, &lpdxfeo); + ok(hr == DXFILE_OK, "IDirectXFile_CreateEnumObject: %x\n", hr); + hr = IDirectXFileEnumObject_GetNextDataObject(lpdxfeo, &lpdxfd); + ok(hr == DXFILE_OK, "IDirectXFileEnumObject_GetNextDataObject: %x\n", hr); + + hr = IDirectXFileData_GetName(lpdxfd, NULL, NULL); + ok(hr == DXFILEERR_BADVALUE, "IDirectXFileData_GetName: %x\n", hr); + hr = IDirectXFileData_GetName(lpdxfd, name, NULL); + ok(hr == DXFILEERR_BADVALUE, "IDirectXFileData_GetName: %x\n", hr); + hr = IDirectXFileData_GetName(lpdxfd, NULL, &length); + ok(hr == DXFILE_OK, "IDirectXFileData_GetName: %x\n", hr); + ok(length == 7, "Returned length should be 7 instead of %u\n", length); + length = sizeof(name); + hr = IDirectXFileData_GetName(lpdxfd, name, &length); + ok(hr == DXFILE_OK, "IDirectXFileData_GetName: %x\n", hr); + ok(length == 7, "Returned length should be 7 instead of %u\n", length); + ok(!strcmp(name, "Object"), "Returned string should be 'Object' intead of '%s'\n", name); + length = 3; + hr = IDirectXFileData_GetName(lpdxfd, name, &length); + ok(hr == DXFILEERR_BADVALUE, "IDirectXFileData_GetName: %x\n", hr); + + ref = IDirectXFileEnumObject_Release(lpdxfeo); + ok(ref == 0, "Got refcount %d, expected 0\n", ref); + ref = IDirectXFileData_Release(lpdxfd); + ok(ref == 0, "Got refcount %d, expected 0\n", ref); + + /* Check object without name */ + dxflm.lpMemory = &object_noname; + dxflm.dSize = sizeof(object_noname) - 1; + hr = IDirectXFile_CreateEnumObject(lpDirectXFile, &dxflm, DXFILELOAD_FROMMEMORY, &lpdxfeo); + ok(hr == DXFILE_OK, "IDirectXFile_CreateEnumObject: %x\n", hr); + hr = IDirectXFileEnumObject_GetNextDataObject(lpdxfeo, &lpdxfd); + ok(hr == DXFILE_OK, "IDirectXFileEnumObject_GetNextDataObject: %x\n", hr); + + hr = IDirectXFileData_GetName(lpdxfd, NULL, &length); + ok(hr == DXFILE_OK, "IDirectXFileData_GetName: %x\n", hr); + ok(length == 0, "Returned length should be 0 instead of %u\n", length); + length = sizeof(name); + hr = IDirectXFileData_GetName(lpdxfd, name, &length); + ok(hr == DXFILE_OK, "IDirectXFileData_GetName: %x\n", hr); + ok(length == 0, "Returned length should be 0 instead of %u\n", length); + + ref = IDirectXFileEnumObject_Release(lpdxfeo); + ok(ref == 0, "Got refcount %d, expected 0\n", ref); + ref = IDirectXFileData_Release(lpdxfd); + ok(ref == 0, "Got refcount %d, expected 0\n", ref); + ref = IDirectXFile_Release(lpDirectXFile); + ok(ref == 0, "Got refcount %d, expected 0\n", ref); +} + /* Set it to 1 to expand the string when dumping the object. This is useful when there is * only one string in a sub-object (very common). Use with care, this may lead to a crash. */ #define EXPAND_STRING 0 @@ -381,7 +469,7 @@ static void process_data(LPDIRECTXFILEDATA lpDirectXFileData, int* plevel) CONST GUID* clsid_type = NULL; char str_clsid[40]; char str_clsid_type[40]; - DWORD len= 100; + DWORD len = 100; LPDIRECTXFILEOBJECT pChildObj; int i; int j = 0; @@ -545,6 +633,7 @@ START_TEST(d3dxof) test_CreateEnumObject(); test_file_types(); test_compressed_files(); + test_getname(); test_dump();
FreeLibrary(hd3dxof);