ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
September 2014
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
16 participants
413 discussions
Start a n
N
ew thread
[tkreuzer] 64400: [SPEC2DEF] Fix asm stubs for thiscall functions. CORE-8576 #resolve
by tkreuzer@svn.reactos.org
Author: tkreuzer Date: Mon Sep 29 17:43:32 2014 New Revision: 64400 URL:
http://svn.reactos.org/svn/reactos?rev=64400&view=rev
Log: [SPEC2DEF] Fix asm stubs for thiscall functions. CORE-8576 #resolve Modified: trunk/reactos/tools/spec2def/spec2def.c Modified: trunk/reactos/tools/spec2def/spec2def.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/spec2def/spec2def.c?…
============================================================================== --- trunk/reactos/tools/spec2def/spec2def.c [iso-8859-1] (original) +++ trunk/reactos/tools/spec2def/spec2def.c [iso-8859-1] Mon Sep 29 17:43:32 2014 @@ -385,7 +385,7 @@ } void -Output_symbol(FILE *fileDest, char* pszSymbolName) +Output_stublabel(FILE *fileDest, char* pszSymbolName) { if (giArch == ARCH_ARM) { @@ -429,19 +429,21 @@ sprintf(szNameBuffer, "@_stub_%.*s@%d", pexp->strName.len, pexp->strName.buf, pexp->nStackBytes); } - else if (pexp->nCallingConvention == CC_CDECL || - pexp->nCallingConvention == CC_STUB) + else if ((pexp->nCallingConvention == CC_CDECL) || + (pexp->nCallingConvention == CC_THISCALL) || + (pexp->nCallingConvention == CC_EXTERN) || + (pexp->nCallingConvention == CC_STUB)) { sprintf(szNameBuffer, "__stub_%.*s", pexp->strName.len, pexp->strName.buf); } - else if (pexp->nCallingConvention == CC_EXTERN) - { - sprintf(szNameBuffer, "__stub_%.*s", - pexp->strName.len, pexp->strName.buf); - } - - Output_symbol(fileDest, szNameBuffer); + else + { + fprintf(stderr, "Invalid calling convention"); + return 0; + } + + Output_stublabel(fileDest, szNameBuffer); return 1; }
10 years, 2 months
1
0
0
0
[akhaldi] 64399: [D3DRM_WINETEST] * Import from Wine 1.7.27. CORE-8540
by akhaldi@svn.reactos.org
Author: akhaldi Date: Mon Sep 29 17:34:31 2014 New Revision: 64399 URL:
http://svn.reactos.org/svn/reactos?rev=64399&view=rev
Log: [D3DRM_WINETEST] * Import from Wine 1.7.27. CORE-8540 Added: trunk/rostests/winetests/d3drm/ (with props) trunk/rostests/winetests/d3drm/CMakeLists.txt (with props) trunk/rostests/winetests/d3drm/d3drm.c (with props) trunk/rostests/winetests/d3drm/testlist.c (with props) trunk/rostests/winetests/d3drm/vector.c (with props) Modified: trunk/rostests/winetests/CMakeLists.txt Modified: trunk/rostests/winetests/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/CMakeLists.txt?…
============================================================================== --- trunk/rostests/winetests/CMakeLists.txt [iso-8859-1] (original) +++ trunk/rostests/winetests/CMakeLists.txt [iso-8859-1] Mon Sep 29 17:34:31 2014 @@ -19,6 +19,7 @@ add_subdirectory(crypt32) add_subdirectory(cryptnet) add_subdirectory(cryptui) +add_subdirectory(d3drm) add_subdirectory(devenum) add_subdirectory(dinput) add_subdirectory(dnsapi) Propchange: trunk/rostests/winetests/d3drm/ ------------------------------------------------------------------------------ --- bugtraq:logregex (added) +++ bugtraq:logregex Mon Sep 29 17:34:31 2014 @@ -0,0 +1,2 @@ +([Ii]ssue|[Bb]ug)s? #?(\d+)(,? ?#?(\d+))*(,? ?(and |or )?#?(\d+))? +(\d+) Propchange: trunk/rostests/winetests/d3drm/ ------------------------------------------------------------------------------ bugtraq:message = See issue #%BUGID% for more details. Propchange: trunk/rostests/winetests/d3drm/ ------------------------------------------------------------------------------ bugtraq:url =
http://www.reactos.org/bugzilla/show_bug.cgi?id=%BUGID%
Added: trunk/rostests/winetests/d3drm/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/d3drm/CMakeList…
============================================================================== --- trunk/rostests/winetests/d3drm/CMakeLists.txt (added) +++ trunk/rostests/winetests/d3drm/CMakeLists.txt [iso-8859-1] Mon Sep 29 17:34:31 2014 @@ -0,0 +1,7 @@ + +add_definitions(-DUSE_WINE_TODOS) +add_executable(d3drm_winetest d3drm.c vector.c testlist.c) +target_link_libraries(d3drm_winetest dxguid) +set_module_type(d3drm_winetest win32cui) +add_importlibs(d3drm_winetest ddraw user32 msvcrt kernel32) +add_cd_file(TARGET d3drm_winetest DESTINATION reactos/bin FOR all) Propchange: trunk/rostests/winetests/d3drm/CMakeLists.txt ------------------------------------------------------------------------------ svn:eol-style = native Added: trunk/rostests/winetests/d3drm/d3drm.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/d3drm/d3drm.c?r…
============================================================================== --- trunk/rostests/winetests/d3drm/d3drm.c (added) +++ trunk/rostests/winetests/d3drm/d3drm.c [iso-8859-1] Mon Sep 29 17:34:31 2014 @@ -0,0 +1,1749 @@ +/* + * Copyright 2010, 2012 Christian Costa + * Copyright 2012 André Hentschel + * + * 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 <d3d.h> +#include <initguid.h> +#include <d3drm.h> +#include <d3drmwin.h> + +#include "wine/test.h" + +static HMODULE d3drm_handle = 0; + +static HRESULT (WINAPI * pDirect3DRMCreate)(IDirect3DRM **d3drm); + +#define CHECK_REFCOUNT(obj,rc) \ + { \ + int rc_new = rc; \ + int count = get_refcount( (IUnknown *)obj ); \ + ok(count == rc_new, "Invalid refcount. Expected %d got %d\n", rc_new, count); \ + } + +#define D3DRM_GET_PROC(func) \ + p ## func = (void*)GetProcAddress(d3drm_handle, #func); \ + if(!p ## func) { \ + trace("GetProcAddress(%s) failed\n", #func); \ + FreeLibrary(d3drm_handle); \ + return FALSE; \ + } + +static BOOL InitFunctionPtrs(void) +{ + d3drm_handle = LoadLibraryA("d3drm.dll"); + + if(!d3drm_handle) + { + skip("Could not load d3drm.dll\n"); + return FALSE; + } + + D3DRM_GET_PROC(Direct3DRMCreate) + + return TRUE; +} + +static int get_refcount(IUnknown *object) +{ + IUnknown_AddRef( object ); + return IUnknown_Release( object ); +} + +static BOOL match_float(float a, float b) +{ + return (a - b) < 0.000001f; +} + +static D3DRMMATRIX4D identity = { + { 1.0f, 0.0f, 0.0f, 0.0f }, + { 0.0f, 1.0f, 0.0f, 0.0f }, + { 0.0f, 0.0f, 1.0f, 0.0f }, + { 0.0f, 0.0f, 0.0f, 1.0f } +}; + +static char data_bad_version[] = +"xof 0302txt 0064\n" +"Header Object\n" +"{\n" +"1; 2; 3;\n" +"}\n"; + +static char data_no_mesh[] = +"xof 0302txt 0064\n" +"Header Object\n" +"{\n" +"1; 0; 1;\n" +"}\n"; + +static char data_ok[] = +"xof 0302txt 0064\n" +"Header Object\n" +"{\n" +"1; 0; 1;\n" +"}\n" +"Mesh Object\n" +"{\n" +"4;\n" +"1.0; 0.0; 0.0;,\n" +"0.0; 1.0; 0.0;,\n" +"0.0; 0.0; 1.0;,\n" +"1.0; 1.0; 1.0;;\n" +"3;\n" +"3; 0, 1, 2;,\n" +"3; 1, 2, 3;,\n" +"3; 3, 1, 2;;\n" +"}\n"; + +static char data_full[] = +"xof 0302txt 0064\n" +"Header { 1; 0; 1; }\n" +"Mesh {\n" +" 3;\n" +" 0.1; 0.2; 0.3;,\n" +" 0.4; 0.5; 0.6;,\n" +" 0.7; 0.8; 0.9;;\n" +" 1;\n" +" 3; 0, 1, 2;;\n" +" MeshMaterialList {\n" +" 1; 1; 0;\n" +" Material {\n" +" 0.0; 1.0; 0.0; 1.0;;\n" +" 30.0;\n" +" 1.0; 0.0; 0.0;;\n" +" 0.5; 0.5; 0.5;;\n" +" TextureFileName {\n" +" \"Texture.bmp\";\n" +" }\n" +" }\n" +" }\n" +" MeshNormals {\n" +" 3;\n" +" 1.1; 1.2; 1.3;,\n" +" 1.4; 1.5; 1.6;,\n" +" 1.7; 1.8; 1.9;;\n" +" 1;" +" 3; 0, 1, 2;;\n" +" }\n" +" MeshTextureCoords {\n" +" 3;\n" +" 0.13; 0.17;,\n" +" 0.23; 0.27;,\n" +" 0.33; 0.37;;\n" +" }\n" +"}\n"; + +static char data_d3drm_load[] = +"xof 0302txt 0064\n" +"Header Object\n" +"{\n" +"1; 0; 1;\n" +"}\n" +"Mesh Object1\n" +"{\n" +" 1;\n" +" 0.1; 0.2; 0.3;,\n" +" 1;\n" +" 3; 0, 1, 2;;\n" +"}\n" +"Mesh Object2\n" +"{\n" +" 1;\n" +" 0.1; 0.2; 0.3;,\n" +" 1;\n" +" 3; 0, 1, 2;;\n" +"}\n" +"Frame Scene\n" +"{\n" +" {Object1}\n" +" {Object2}\n" +"}\n" +"Material\n" +"{\n" +" 0.1, 0.2, 0.3, 0.4;;\n" +" 0.5;\n" +" 0.6, 0.7, 0.8;;\n" +" 0.9, 1.0, 1.1;;\n" +"}\n"; + +static char data_frame_mesh_materials[] = +"xof 0302txt 0064\n" +"Header { 1; 0; 1; }\n" +"Frame {\n" +" Mesh mesh1 {\n" +" 5;\n" +" 0.1; 0.2; 0.3;,\n" +" 0.4; 0.5; 0.6;,\n" +" 0.7; 0.8; 0.9;,\n" +" 1.1; 1.2; 1.3;,\n" +" 1.4; 1.5; 1.6;;\n" +" 6;\n" +" 3; 0, 1, 2;,\n" +" 3; 0, 2, 1;,\n" +" 3; 1, 2, 3;,\n" +" 3; 1, 3, 2;,\n" +" 3; 2, 3, 4;,\n" +" 3; 2, 4, 3;;\n" +" MeshMaterialList {\n" +" 3; 6; 0, 1, 1, 2, 2, 2;\n" +" Material mat1 {\n" +" 1.0; 0.0; 0.0; 0.1;;\n" +" 10.0;\n" +" 0.11; 0.12; 0.13;;\n" +" 0.14; 0.15; 0.16;;\n" +" }\n" +" Material mat2 {\n" +" 0.0; 1.0; 0.0; 0.2;;\n" +" 20.0;\n" +" 0.21; 0.22; 0.23;;\n" +" 0.24; 0.25; 0.26;;\n" +" }\n" +" Material mat3 {\n" +" 0.0; 0.0; 1.0; 0.3;;\n" +" 30.0;\n" +" 0.31; 0.32; 0.33;;\n" +" 0.34; 0.35; 0.36;;\n" +" }\n" +" }\n" +" }\n" +"}\n"; + +static void test_MeshBuilder(void) +{ + HRESULT hr; + IDirect3DRM *d3drm; + IDirect3DRMMeshBuilder *pMeshBuilder; + IDirect3DRMMesh *mesh; + D3DRMLOADMEMORY info; + int val; + DWORD val1, val2, val3; + D3DVALUE valu, valv; + D3DVECTOR v[3]; + D3DVECTOR n[4]; + DWORD f[8]; + char name[10]; + DWORD size; + D3DCOLOR color; + CHAR cname[64] = {0}; + + hr = pDirect3DRMCreate(&d3drm); + ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface (hr = %x)\n", hr); + + hr = IDirect3DRM_CreateMeshBuilder(d3drm, &pMeshBuilder); + ok(hr == D3DRM_OK, "Cannot get IDirect3DRMMeshBuilder interface (hr = %x)\n", hr); + + hr = IDirect3DRMMeshBuilder_GetClassName(pMeshBuilder, NULL, cname); + ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr); + hr = IDirect3DRMMeshBuilder_GetClassName(pMeshBuilder, NULL, NULL); + ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr); + size = 1; + hr = IDirect3DRMMeshBuilder_GetClassName(pMeshBuilder, &size, cname); + ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr); + size = sizeof(cname); + hr = IDirect3DRMMeshBuilder_GetClassName(pMeshBuilder, &size, cname); + ok(hr == D3DRM_OK, "Cannot get classname (hr = %x)\n", hr); + ok(size == sizeof("Builder"), "wrong size: %u\n", size); + ok(!strcmp(cname, "Builder"), "Expected cname to be \"Builder\", but got \"%s\"\n", cname); + + info.lpMemory = data_bad_version; + info.dSize = strlen(data_bad_version); + hr = IDirect3DRMMeshBuilder_Load(pMeshBuilder, &info, NULL, D3DRMLOAD_FROMMEMORY, NULL, NULL); + ok(hr == D3DRMERR_BADFILE, "Should have returned D3DRMERR_BADFILE (hr = %x)\n", hr); + + info.lpMemory = data_no_mesh; + info.dSize = strlen(data_no_mesh); + hr = IDirect3DRMMeshBuilder_Load(pMeshBuilder, &info, NULL, D3DRMLOAD_FROMMEMORY, NULL, NULL); + ok(hr == D3DRMERR_NOTFOUND, "Should have returned D3DRMERR_NOTFOUND (hr = %x)\n", hr); + + info.lpMemory = data_ok; + info.dSize = strlen(data_ok); + hr = IDirect3DRMMeshBuilder_Load(pMeshBuilder, &info, NULL, D3DRMLOAD_FROMMEMORY, NULL, NULL); + ok(hr == D3DRM_OK, "Cannot load mesh data (hr = %x)\n", hr); + + size = sizeof(name); + hr = IDirect3DRMMeshBuilder_GetName(pMeshBuilder, &size, name); + ok(hr == D3DRM_OK, "IDirect3DRMMeshBuilder_GetName returned hr = %x\n", hr); + ok(!strcmp(name, "Object"), "Retrieved name '%s' instead of 'Object'\n", name); + size = strlen("Object"); /* No space for null character */ + hr = IDirect3DRMMeshBuilder_GetName(pMeshBuilder, &size, name); + ok(hr == E_INVALIDARG, "IDirect3DRMMeshBuilder_GetName returned hr = %x\n", hr); + hr = IDirect3DRMMeshBuilder_SetName(pMeshBuilder, NULL); + ok(hr == D3DRM_OK, "IDirect3DRMMeshBuilder_SetName returned hr = %x\n", hr); + size = sizeof(name); + hr = IDirect3DRMMeshBuilder_GetName(pMeshBuilder, &size, name); + ok(hr == D3DRM_OK, "IDirect3DRMMeshBuilder_GetName returned hr = %x\n", hr); + ok(size == 0, "Size should be 0 instead of %u\n", size); + hr = IDirect3DRMMeshBuilder_SetName(pMeshBuilder, ""); + ok(hr == D3DRM_OK, "IDirect3DRMMeshBuilder_SetName returned hr = %x\n", hr); + size = sizeof(name); + hr = IDirect3DRMMeshBuilder_GetName(pMeshBuilder, &size, name); + ok(hr == D3DRM_OK, "IDirect3DRMMeshBuilder_GetName returned hr = %x\n", hr); + ok(!strcmp(name, ""), "Retrieved name '%s' instead of ''\n", name); + + val = IDirect3DRMMeshBuilder_GetVertexCount(pMeshBuilder); + ok(val == 4, "Wrong number of vertices %d (must be 4)\n", val); + + val = IDirect3DRMMeshBuilder_GetFaceCount(pMeshBuilder); + ok(val == 3, "Wrong number of faces %d (must be 3)\n", val); + + hr = IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder, &val1, NULL, &val2, NULL, &val3, NULL); + ok(hr == D3DRM_OK, "Cannot get vertices information (hr = %x)\n", hr); + ok(val1 == 4, "Wrong number of vertices %d (must be 4)\n", val1); + ok(val2 == 4, "Wrong number of normals %d (must be 4)\n", val2); + ok(val3 == 22, "Wrong number of face data bytes %d (must be 22)\n", val3); + + /* Check that Load method generated default normals */ + hr = IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder, NULL, NULL, &val2, n, NULL, NULL); + ok(hr == D3DRM_OK, "Cannot get vertices information (hr = %x)\n", hr); + ok(match_float(U1(n[0]).x, 0.577350f), "Wrong component n[0].x = %f (expected %f)\n", U1(n[0]).x, 0.577350f); + ok(match_float(U2(n[0]).y, 0.577350f), "Wrong component n[0].y = %f (expected %f)\n", U2(n[0]).y, 0.577350f); + ok(match_float(U3(n[0]).z, 0.577350f), "Wrong component n[0].z = %f (expected %f)\n", U3(n[0]).z, 0.577350f); + ok(match_float(U1(n[1]).x, -0.229416f), "Wrong component n[1].x = %f (expected %f)\n", U1(n[1]).x, -0.229416f); + ok(match_float(U2(n[1]).y, 0.688247f), "Wrong component n[1].y = %f (expected %f)\n", U2(n[1]).y, 0.688247f); + ok(match_float(U3(n[1]).z, 0.688247f), "Wrong component n[1].z = %f (expected %f)\n", U3(n[1]).z, 0.688247f); + ok(match_float(U1(n[2]).x, -0.229416f), "Wrong component n[2].x = %f (expected %f)\n", U1(n[2]).x, -0.229416f); + ok(match_float(U2(n[2]).y, 0.688247f), "Wrong component n[2].y = %f (expected %f)\n", U2(n[2]).y, 0.688247f); + ok(match_float(U3(n[2]).z, 0.688247f), "Wrong component n[2].z = %f (expected %f)\n", U3(n[2]).z, 0.688247f); + ok(match_float(U1(n[3]).x, -0.577350f), "Wrong component n[3].x = %f (expected %f)\n", U1(n[3]).x, -0.577350f); + ok(match_float(U2(n[3]).y, 0.577350f), "Wrong component n[3].y = %f (expected %f)\n", U2(n[3]).y, 0.577350f); + ok(match_float(U3(n[3]).z, 0.577350f), "Wrong component n[3].z = %f (expected %f)\n", U3(n[3]).z, 0.577350f); + + /* Check that Load method generated default texture coordinates (0.0f, 0.0f) for each vertex */ + valu = 1.23f; + valv = 3.21f; + hr = IDirect3DRMMeshBuilder_GetTextureCoordinates(pMeshBuilder, 0, &valu, &valv); + ok(hr == D3DRM_OK, "Cannot get texture coordinates (hr = %x)\n", hr); + ok(valu == 0.0f, "Wrong coordinate %f (must be 0.0)\n", valu); + ok(valv == 0.0f, "Wrong coordinate %f (must be 0.0)\n", valv); + valu = 1.23f; + valv = 3.21f; + hr = IDirect3DRMMeshBuilder_GetTextureCoordinates(pMeshBuilder, 1, &valu, &valv); + ok(hr == D3DRM_OK, "Cannot get texture coordinates (hr = %x)\n", hr); + ok(valu == 0.0f, "Wrong coordinate %f (must be 0.0)\n", valu); + ok(valv == 0.0f, "Wrong coordinate %f (must be 0.0)\n", valv); + valu = 1.23f; + valv = 3.21f; + hr = IDirect3DRMMeshBuilder_GetTextureCoordinates(pMeshBuilder, 2, &valu, &valv); + ok(hr == D3DRM_OK, "Cannot get texture coordinates (hr = %x)\n", hr); + ok(valu == 0.0f, "Wrong coordinate %f (must be 0.0)\n", valu); + ok(valv == 0.0f, "Wrong coordinate %f (must be 0.0)\n", valv); + valu = 1.23f; + valv = 3.21f; + hr = IDirect3DRMMeshBuilder_GetTextureCoordinates(pMeshBuilder, 3, &valu, &valv); + ok(hr == D3DRM_OK, "Cannot get texture coordinates (hr = %x)\n", hr); + ok(valu == 0.0f, "Wrong coordinate %f (must be 0.0)\n", valu); + ok(valv == 0.0f, "Wrong coordinate %f (must be 0.0)\n", valv); + hr = IDirect3DRMMeshBuilder_GetTextureCoordinates(pMeshBuilder, 4, &valu, &valv); + ok(hr == D3DRMERR_BADVALUE, "Should fail and return D3DRM_BADVALUE (hr = %x)\n", hr); + + valu = 1.23f; + valv = 3.21f; + hr = IDirect3DRMMeshBuilder_SetTextureCoordinates(pMeshBuilder, 0, valu, valv); + ok(hr == D3DRM_OK, "Cannot set texture coordinates (hr = %x)\n", hr); + hr = IDirect3DRMMeshBuilder_SetTextureCoordinates(pMeshBuilder, 4, valu, valv); + ok(hr == D3DRMERR_BADVALUE, "Should fail and return D3DRM_BADVALUE (hr = %x)\n", hr); + + valu = 0.0f; + valv = 0.0f; + hr = IDirect3DRMMeshBuilder_GetTextureCoordinates(pMeshBuilder, 0, &valu, &valv); + ok(hr == D3DRM_OK, "Cannot get texture coordinates (hr = %x)\n", hr); + ok(valu == 1.23f, "Wrong coordinate %f (must be 1.23)\n", valu); + ok(valv == 3.21f, "Wrong coordinate %f (must be 3.21)\n", valv); + + IDirect3DRMMeshBuilder_Release(pMeshBuilder); + + hr = IDirect3DRM_CreateMeshBuilder(d3drm, &pMeshBuilder); + ok(hr == D3DRM_OK, "Cannot get IDirect3DRMMeshBuilder interface (hr = %x)\n", hr); + + /* No group in mesh when mesh builder is not loaded */ + hr = IDirect3DRMMeshBuilder_CreateMesh(pMeshBuilder, &mesh); + ok(hr == D3DRM_OK, "CreateMesh failed returning hr = %x\n", hr); + if (hr == D3DRM_OK) + { + DWORD nb_groups; + + nb_groups = IDirect3DRMMesh_GetGroupCount(mesh); + ok(nb_groups == 0, "GetCroupCount returned %u\n", nb_groups); + + IDirect3DRMMesh_Release(mesh); + } + + info.lpMemory = data_full; + info.dSize = strlen(data_full); + hr = IDirect3DRMMeshBuilder_Load(pMeshBuilder, &info, NULL, D3DRMLOAD_FROMMEMORY, NULL, NULL); + ok(hr == D3DRM_OK, "Cannot load mesh data (hr = %x)\n", hr); + + val = IDirect3DRMMeshBuilder_GetVertexCount(pMeshBuilder); + ok(val == 3, "Wrong number of vertices %d (must be 3)\n", val); + + val = IDirect3DRMMeshBuilder_GetFaceCount(pMeshBuilder); + ok(val == 1, "Wrong number of faces %d (must be 1)\n", val); + + /* Check no buffer size and too small buffer size errors */ + val1 = 1; val2 = 3; val3 = 8; + hr = IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder, &val1, v, &val2, n, &val3, f); + ok(hr == D3DRMERR_BADVALUE, "IDirect3DRMMeshBuilder_GetVertices returned %#x\n", hr); + hr = IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder, NULL, v, &val2, n, &val3, f); + ok(hr == D3DRMERR_BADVALUE, "IDirect3DRMMeshBuilder_GetVertices returned %#x\n", hr); + val1 = 3; val2 = 1; val3 = 8; + hr = IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder, &val1, v, &val2, n, &val3, f); + ok(hr == D3DRMERR_BADVALUE, "IDirect3DRMMeshBuilder_GetVertices returned %#x\n", hr); + hr = IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder, &val1, v, NULL, n, &val3, f); + ok(hr == D3DRMERR_BADVALUE, "IDirect3DRMMeshBuilder_GetVertices returned %#x\n", hr); + val1 = 3; val2 = 3; val3 = 1; + hr = IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder, &val1, v, &val2, n, &val3, f); + ok(hr == D3DRMERR_BADVALUE, "IDirect3DRMMeshBuilder_GetVertices returned %#x\n", hr); + hr = IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder, &val1, v, &val2, n, NULL, f); + ok(hr == D3DRMERR_BADVALUE, "IDirect3DRMMeshBuilder_GetVertices returned %#x\n", hr); + + val1 = 3; val2 = 3; val3 = 8; + hr = IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder, &val1, v, &val2, n, &val3, f); + ok(hr == D3DRM_OK, "Cannot get vertices information (hr = %x)\n", hr); + ok(val1 == 3, "Wrong number of vertices %d (must be 3)\n", val1); + ok(val2 == 3, "Wrong number of normals %d (must be 3)\n", val2); + ok(val3 == 8, "Wrong number of face data bytes %d (must be 8)\n", val3); + ok(U1(v[0]).x == 0.1f, "Wrong component v[0].x = %f (expected 0.1)\n", U1(v[0]).x); + ok(U2(v[0]).y == 0.2f, "Wrong component v[0].y = %f (expected 0.2)\n", U2(v[0]).y); + ok(U3(v[0]).z == 0.3f, "Wrong component v[0].z = %f (expected 0.3)\n", U3(v[0]).z); + ok(U1(v[1]).x == 0.4f, "Wrong component v[1].x = %f (expected 0.4)\n", U1(v[1]).x); + ok(U2(v[1]).y == 0.5f, "Wrong component v[1].y = %f (expected 0.5)\n", U2(v[1]).y); + ok(U3(v[1]).z == 0.6f, "Wrong component v[1].z = %f (expected 0.6)\n", U3(v[1]).z); + ok(U1(v[2]).x == 0.7f, "Wrong component v[2].x = %f (expected 0.7)\n", U1(v[2]).x); + ok(U2(v[2]).y == 0.8f, "Wrong component v[2].y = %f (expected 0.8)\n", U2(v[2]).y); + ok(U3(v[2]).z == 0.9f, "Wrong component v[2].z = %f (expected 0.9)\n", U3(v[2]).z); + ok(U1(n[0]).x == 1.1f, "Wrong component n[0].x = %f (expected 1.1)\n", U1(n[0]).x); + ok(U2(n[0]).y == 1.2f, "Wrong component n[0].y = %f (expected 1.2)\n", U2(n[0]).y); + ok(U3(n[0]).z == 1.3f, "Wrong component n[0].z = %f (expected 1.3)\n", U3(n[0]).z); + ok(U1(n[1]).x == 1.4f, "Wrong component n[1].x = %f (expected 1.4)\n", U1(n[1]).x); + ok(U2(n[1]).y == 1.5f, "Wrong component n[1].y = %f (expected 1.5)\n", U2(n[1]).y); + ok(U3(n[1]).z == 1.6f, "Wrong component n[1].z = %f (expected 1.6)\n", U3(n[1]).z); + ok(U1(n[2]).x == 1.7f, "Wrong component n[2].x = %f (expected 1.7)\n", U1(n[2]).x); + ok(U2(n[2]).y == 1.8f, "Wrong component n[2].y = %f (expected 1.8)\n", U2(n[2]).y); + ok(U3(n[2]).z == 1.9f, "Wrong component n[2].z = %f (expected 1.9)\n", U3(n[2]).z); + ok(f[0] == 3 , "Wrong component f[0] = %d (expected 3)\n", f[0]); + ok(f[1] == 0 , "Wrong component f[1] = %d (expected 0)\n", f[1]); + ok(f[2] == 0 , "Wrong component f[2] = %d (expected 0)\n", f[2]); + ok(f[3] == 1 , "Wrong component f[3] = %d (expected 1)\n", f[3]); + ok(f[4] == 1 , "Wrong component f[4] = %d (expected 1)\n", f[4]); + ok(f[5] == 2 , "Wrong component f[5] = %d (expected 2)\n", f[5]); + ok(f[6] == 2 , "Wrong component f[6] = %d (expected 2)\n", f[6]); + ok(f[7] == 0 , "Wrong component f[7] = %d (expected 0)\n", f[7]); + + hr = IDirect3DRMMeshBuilder_CreateMesh(pMeshBuilder, &mesh); + ok(hr == D3DRM_OK, "CreateMesh failed returning hr = %x\n", hr); + if (hr == D3DRM_OK) + { + DWORD nb_groups; + unsigned nb_vertices, nb_faces, nb_face_vertices; + DWORD data_size; + IDirect3DRMMaterial *material = (IDirect3DRMMaterial *)0xdeadbeef; + IDirect3DRMTexture *texture = (IDirect3DRMTexture *)0xdeadbeef; + D3DVALUE values[3]; + + nb_groups = IDirect3DRMMesh_GetGroupCount(mesh); + ok(nb_groups == 1, "GetCroupCount returned %u\n", nb_groups); + hr = IDirect3DRMMesh_GetGroup(mesh, 1, &nb_vertices, &nb_faces, &nb_face_vertices, &data_size, NULL); + ok(hr == D3DRMERR_BADVALUE, "GetCroup returned hr = %x\n", hr); + hr = IDirect3DRMMesh_GetGroup(mesh, 0, &nb_vertices, &nb_faces, &nb_face_vertices, &data_size, NULL); + ok(hr == D3DRM_OK, "GetCroup failed returning hr = %x\n", hr); + ok(nb_vertices == 3, "Wrong number of vertices %u (must be 3)\n", nb_vertices); + ok(nb_faces == 1, "Wrong number of faces %u (must be 1)\n", nb_faces); + ok(nb_face_vertices == 3, "Wrong number of vertices per face %u (must be 3)\n", nb_face_vertices); + ok(data_size == 3, "Wrong number of face data bytes %u (must be 3)\n", data_size); + color = IDirect3DRMMesh_GetGroupColor(mesh, 0); + ok(color == 0xff00ff00, "Wrong color returned %#x instead of %#x\n", color, 0xff00ff00); + hr = IDirect3DRMMesh_GetGroupTexture(mesh, 0, &texture); + ok(hr == D3DRM_OK, "GetCroupTexture failed returning hr = %x\n", hr); + ok(texture == NULL, "No texture should be present\n"); + hr = IDirect3DRMMesh_GetGroupMaterial(mesh, 0, &material); + ok(hr == D3DRM_OK, "GetCroupMaterial failed returning hr = %x\n", hr); + ok(material != NULL, "No material present\n"); + if ((hr == D3DRM_OK) && material) + { + hr = IDirect3DRMMaterial_GetEmissive(material, &values[0], &values[1], &values[2]); + ok(hr == D3DRM_OK, "GetMaterialEmissive failed returning hr = %x\n", hr); + ok(values[0] == 0.5f, "Emissive red component should be %f instead of %f\n", 0.5f, values[0]); + ok(values[1] == 0.5f, "Emissive green component should be %f instead of %f\n", 0.5f, values[1]); + ok(values[2] == 0.5f, "Emissive blue component should be %f instead of %f\n", 0.5f, values[2]); + hr = IDirect3DRMMaterial_GetSpecular(material, &values[0], &values[1], &values[2]); + ok(hr == D3DRM_OK, "GetMaterialEmissive failed returning hr = %x\n", hr); + ok(values[0] == 1.0f, "Specular red component should be %f instead of %f\n", 1.0f, values[0]); + ok(values[1] == 0.0f, "Specular green component should be %f instead of %f\n", 0.0f, values[1]); + ok(values[2] == 0.0f, "Specular blue component should be %f instead of %f\n", 0.0f, values[2]); + values[0] = IDirect3DRMMaterial_GetPower(material); + ok(values[0] == 30.0f, "Power value should be %f instead of %f\n", 30.0f, values[0]); + } + + IDirect3DRMMesh_Release(mesh); + } + + hr = IDirect3DRMMeshBuilder_Scale(pMeshBuilder, 2, 3 ,4); + ok(hr == D3DRM_OK, "Scale failed returning hr = %x\n", hr); + + hr = IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder, &val1, v, &val2, n, &val3, f); + ok(hr == D3DRM_OK, "Cannot get vertices information (hr = %x)\n", hr); + ok(val2 == 3, "Wrong number of normals %d (must be 3)\n", val2); + ok(val1 == 3, "Wrong number of vertices %d (must be 3)\n", val1); + ok(U1(v[0]).x == 0.1f*2, "Wrong component v[0].x = %f (expected %f)\n", U1(v[0]).x, 0.1f*2); + ok(U2(v[0]).y == 0.2f*3, "Wrong component v[0].y = %f (expected %f)\n", U2(v[0]).y, 0.2f*3); + ok(U3(v[0]).z == 0.3f*4, "Wrong component v[0].z = %f (expected %f)\n", U3(v[0]).z, 0.3f*4); + ok(U1(v[1]).x == 0.4f*2, "Wrong component v[1].x = %f (expected %f)\n", U1(v[1]).x, 0.4f*2); + ok(U2(v[1]).y == 0.5f*3, "Wrong component v[1].y = %f (expected %f)\n", U2(v[1]).y, 0.5f*3); + ok(U3(v[1]).z == 0.6f*4, "Wrong component v[1].z = %f (expected %f)\n", U3(v[1]).z, 0.6f*4); + ok(U1(v[2]).x == 0.7f*2, "Wrong component v[2].x = %f (expected %f)\n", U1(v[2]).x, 0.7f*2); + ok(U2(v[2]).y == 0.8f*3, "Wrong component v[2].y = %f (expected %f)\n", U2(v[2]).y, 0.8f*3); + ok(U3(v[2]).z == 0.9f*4, "Wrong component v[2].z = %f (expected %f)\n", U3(v[2]).z, 0.9f*4); + /* Normals are not affected by Scale */ + ok(U1(n[0]).x == 1.1f, "Wrong component n[0].x = %f (expected %f)\n", U1(n[0]).x, 1.1f); + ok(U2(n[0]).y == 1.2f, "Wrong component n[0].y = %f (expected %f)\n", U2(n[0]).y, 1.2f); + ok(U3(n[0]).z == 1.3f, "Wrong component n[0].z = %f (expected %f)\n", U3(n[0]).z, 1.3f); + ok(U1(n[1]).x == 1.4f, "Wrong component n[1].x = %f (expected %f)\n", U1(n[1]).x, 1.4f); + ok(U2(n[1]).y == 1.5f, "Wrong component n[1].y = %f (expected %f)\n", U2(n[1]).y, 1.5f); + ok(U3(n[1]).z == 1.6f, "Wrong component n[1].z = %f (expected %f)\n", U3(n[1]).z, 1.6f); + ok(U1(n[2]).x == 1.7f, "Wrong component n[2].x = %f (expected %f)\n", U1(n[2]).x, 1.7f); + ok(U2(n[2]).y == 1.8f, "Wrong component n[2].y = %f (expected %f)\n", U2(n[2]).y, 1.8f); + ok(U3(n[2]).z == 1.9f, "Wrong component n[2].z = %f (expected %f)\n", U3(n[2]).z, 1.9f); + + IDirect3DRMMeshBuilder_Release(pMeshBuilder); + + IDirect3DRM_Release(d3drm); +} + +static void test_MeshBuilder3(void) +{ + HRESULT hr; + IDirect3DRM *d3drm; + IDirect3DRM3 *d3drm3; + IDirect3DRMMeshBuilder3 *pMeshBuilder3; + D3DRMLOADMEMORY info; + int val; + DWORD val1; + D3DVALUE valu, valv; + DWORD size; + CHAR cname[64] = {0}; + + hr = pDirect3DRMCreate(&d3drm); + ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface (hr = %x)\n", hr); + + if (FAILED(hr = IDirect3DRM_QueryInterface(d3drm, &IID_IDirect3DRM3, (void **)&d3drm3))) + { + win_skip("Cannot get IDirect3DRM3 interface (hr = %x), skipping tests\n", hr); + IDirect3DRM_Release(d3drm); + return; + } + + hr = IDirect3DRM3_CreateMeshBuilder(d3drm3, &pMeshBuilder3); + ok(hr == D3DRM_OK, "Cannot get IDirect3DRMMeshBuilder3 interface (hr = %x)\n", hr); + + hr = IDirect3DRMMeshBuilder3_GetClassName(pMeshBuilder3, NULL, cname); + ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr); + hr = IDirect3DRMMeshBuilder3_GetClassName(pMeshBuilder3, NULL, NULL); + ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr); + size = 1; + hr = IDirect3DRMMeshBuilder3_GetClassName(pMeshBuilder3, &size, cname); + ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr); + size = sizeof(cname); + hr = IDirect3DRMMeshBuilder3_GetClassName(pMeshBuilder3, &size, cname); + ok(hr == D3DRM_OK, "Cannot get classname (hr = %x)\n", hr); + ok(size == sizeof("Builder"), "wrong size: %u\n", size); + ok(!strcmp(cname, "Builder"), "Expected cname to be \"Builder\", but got \"%s\"\n", cname); + + info.lpMemory = data_bad_version; + info.dSize = strlen(data_bad_version); + hr = IDirect3DRMMeshBuilder3_Load(pMeshBuilder3, &info, NULL, D3DRMLOAD_FROMMEMORY, NULL, NULL); + ok(hr == D3DRMERR_BADFILE, "Should have returned D3DRMERR_BADFILE (hr = %x)\n", hr); + + info.lpMemory = data_no_mesh; + info.dSize = strlen(data_no_mesh); + hr = IDirect3DRMMeshBuilder3_Load(pMeshBuilder3, &info, NULL, D3DRMLOAD_FROMMEMORY, NULL, NULL); + ok(hr == D3DRMERR_NOTFOUND, "Should have returned D3DRMERR_NOTFOUND (hr = %x)\n", hr); + + info.lpMemory = data_ok; + info.dSize = strlen(data_ok); + hr = IDirect3DRMMeshBuilder3_Load(pMeshBuilder3, &info, NULL, D3DRMLOAD_FROMMEMORY, NULL, NULL); + ok(hr == D3DRM_OK, "Cannot load mesh data (hr = %x)\n", hr); + + val = IDirect3DRMMeshBuilder3_GetVertexCount(pMeshBuilder3); + ok(val == 4, "Wrong number of vertices %d (must be 4)\n", val); + + val = IDirect3DRMMeshBuilder3_GetFaceCount(pMeshBuilder3); + ok(val == 3, "Wrong number of faces %d (must be 3)\n", val); + + hr = IDirect3DRMMeshBuilder3_GetVertices(pMeshBuilder3, 0, &val1, NULL); + ok(hr == D3DRM_OK, "Cannot get vertices information (hr = %x)\n", hr); + ok(val1 == 4, "Wrong number of vertices %d (must be 4)\n", val1); + + /* Check that Load method generated default texture coordinates (0.0f, 0.0f) for each vertex */ + valu = 1.23f; + valv = 3.21f; + hr = IDirect3DRMMeshBuilder3_GetTextureCoordinates(pMeshBuilder3, 0, &valu, &valv); + ok(hr == D3DRM_OK, "Cannot get texture coordinates (hr = %x)\n", hr); + ok(valu == 0.0f, "Wrong coordinate %f (must be 0.0)\n", valu); + ok(valv == 0.0f, "Wrong coordinate %f (must be 0.0)\n", valv); + valu = 1.23f; + valv = 3.21f; + hr = IDirect3DRMMeshBuilder3_GetTextureCoordinates(pMeshBuilder3, 1, &valu, &valv); + ok(hr == D3DRM_OK, "Cannot get texture coordinates (hr = %x)\n", hr); + ok(valu == 0.0f, "Wrong coordinate %f (must be 0.0)\n", valu); + ok(valv == 0.0f, "Wrong coordinate %f (must be 0.0)\n", valv); + valu = 1.23f; + valv = 3.21f; + hr = IDirect3DRMMeshBuilder3_GetTextureCoordinates(pMeshBuilder3, 2, &valu, &valv); + ok(hr == D3DRM_OK, "Cannot get texture coordinates (hr = %x)\n", hr); + ok(valu == 0.0f, "Wrong coordinate %f (must be 0.0)\n", valu); + ok(valv == 0.0f, "Wrong coordinate %f (must be 0.0)\n", valv); + valu = 1.23f; + valv = 3.21f; + hr = IDirect3DRMMeshBuilder3_GetTextureCoordinates(pMeshBuilder3, 3, &valu, &valv); + ok(hr == D3DRM_OK, "Cannot get texture coordinates (hr = %x)\n", hr); + ok(valu == 0.0f, "Wrong coordinate %f (must be 0.0)\n", valu); + ok(valv == 0.0f, "Wrong coordinate %f (must be 0.0)\n", valv); + hr = IDirect3DRMMeshBuilder3_GetTextureCoordinates(pMeshBuilder3, 4, &valu, &valv); + ok(hr == D3DRMERR_BADVALUE, "Should fail and return D3DRM_BADVALUE (hr = %x)\n", hr); + + valu = 1.23f; + valv = 3.21f; + hr = IDirect3DRMMeshBuilder3_SetTextureCoordinates(pMeshBuilder3, 0, valu, valv); + ok(hr == D3DRM_OK, "Cannot set texture coordinates (hr = %x)\n", hr); + hr = IDirect3DRMMeshBuilder3_SetTextureCoordinates(pMeshBuilder3, 4, valu, valv); + ok(hr == D3DRMERR_BADVALUE, "Should fail and return D3DRM_BADVALUE (hr = %x)\n", hr); + + valu = 0.0f; + valv = 0.0f; + hr = IDirect3DRMMeshBuilder3_GetTextureCoordinates(pMeshBuilder3, 0, &valu, &valv); + ok(hr == D3DRM_OK, "Cannot get texture coordinates (hr = %x)\n", hr); + ok(valu == 1.23f, "Wrong coordinate %f (must be 1.23)\n", valu); + ok(valv == 3.21f, "Wrong coordinate %f (must be 3.21)\n", valv); + + IDirect3DRMMeshBuilder3_Release(pMeshBuilder3); + IDirect3DRM3_Release(d3drm3); + IDirect3DRM_Release(d3drm); +} + +static void test_Mesh(void) +{ + HRESULT hr; + IDirect3DRM *d3drm; + IDirect3DRMMesh *mesh; + DWORD size; + CHAR cname[64] = {0}; + + hr = pDirect3DRMCreate(&d3drm); + ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface (hr = %x)\n", hr); + + hr = IDirect3DRM_CreateMesh(d3drm, &mesh); + ok(hr == D3DRM_OK, "Cannot get IDirect3DRMMesh interface (hr = %x)\n", hr); + + hr = IDirect3DRMMesh_GetClassName(mesh, NULL, cname); + ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr); + hr = IDirect3DRMMesh_GetClassName(mesh, NULL, NULL); + ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr); + size = 1; + hr = IDirect3DRMMesh_GetClassName(mesh, &size, cname); + ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr); + size = sizeof(cname); + hr = IDirect3DRMMesh_GetClassName(mesh, &size, cname); + ok(hr == D3DRM_OK, "Cannot get classname (hr = %x)\n", hr); + ok(size == sizeof("Mesh"), "wrong size: %u\n", size); + ok(!strcmp(cname, "Mesh"), "Expected cname to be \"Mesh\", but got \"%s\"\n", cname); + + IDirect3DRMMesh_Release(mesh); + + IDirect3DRM_Release(d3drm); +} + +static void test_Face(void) +{ + HRESULT hr; + IDirect3DRM *d3drm; + IDirect3DRM2 *d3drm2; + IDirect3DRM3 *d3drm3; + IDirect3DRMMeshBuilder2 *MeshBuilder2; + IDirect3DRMMeshBuilder3 *MeshBuilder3; + IDirect3DRMFace *face1; + IDirect3DRMFace2 *face2; + IDirect3DRMFaceArray *array1; + D3DRMLOADMEMORY info; + D3DVECTOR v1[4], n1[4], v2[4], n2[4]; + DWORD count; + CHAR cname[64] = {0}; + int icount; + + hr = pDirect3DRMCreate(&d3drm); + ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface (hr = %x)\n", hr); + + hr = IDirect3DRM_CreateFace(d3drm, &face1); + ok(hr == D3DRM_OK, "Cannot get IDirect3DRMFace interface (hr = %x)\n", hr); + if (FAILED(hr)) + { + skip("Cannot get IDirect3DRMFace interface (hr = %x), skipping tests\n", hr); + IDirect3DRM_Release(d3drm); + return; + } + + hr = IDirect3DRMFace_GetClassName(face1, NULL, cname); + ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr); + hr = IDirect3DRMFace_GetClassName(face1, NULL, NULL); + ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr); + count = 1; + hr = IDirect3DRMFace_GetClassName(face1, &count, cname); + ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr); + count = sizeof(cname); + hr = IDirect3DRMFace_GetClassName(face1, &count, cname); + ok(hr == D3DRM_OK, "Cannot get classname (hr = %x)\n", hr); + ok(count == sizeof("Face"), "wrong size: %u\n", count); + ok(!strcmp(cname, "Face"), "Expected cname to be \"Face\", but got \"%s\"\n", cname); + + icount = IDirect3DRMFace_GetVertexCount(face1); + ok(!icount, "wrong VertexCount: %i\n", icount); + + IDirect3DRMFace_Release(face1); + + if (FAILED(hr = IDirect3DRM_QueryInterface(d3drm, &IID_IDirect3DRM2, (void **)&d3drm2))) + { + win_skip("Cannot get IDirect3DRM2 interface (hr = %x), skipping tests\n", hr); + IDirect3DRM_Release(d3drm); + return; + } + + hr = IDirect3DRM2_CreateMeshBuilder(d3drm2, &MeshBuilder2); + ok(hr == D3DRM_OK, "Cannot get IDirect3DRMMeshBuilder2 interface (hr = %x)\n", hr); + + icount = IDirect3DRMMeshBuilder2_GetFaceCount(MeshBuilder2); + ok(!icount, "wrong FaceCount: %i\n", icount); + + array1 = NULL; + hr = IDirect3DRMMeshBuilder2_GetFaces(MeshBuilder2, &array1); + todo_wine + ok(hr == D3DRM_OK, "Cannot get FaceArray (hr = %x)\n", hr); + + hr = IDirect3DRMMeshBuilder2_CreateFace(MeshBuilder2, &face1); + ok(hr == D3DRM_OK, "Cannot get IDirect3DRMFace interface (hr = %x)\n", hr); + + icount = IDirect3DRMMeshBuilder2_GetFaceCount(MeshBuilder2); + todo_wine + ok(icount == 1, "wrong FaceCount: %i\n", icount); + + array1 = NULL; + hr = IDirect3DRMMeshBuilder2_GetFaces(MeshBuilder2, &array1); + todo_wine + ok(hr == D3DRM_OK, "Cannot get FaceArray (hr = %x)\n", hr); + todo_wine + ok(array1 != NULL, "pArray = %p\n", array1); + if (array1) + { + IDirect3DRMFace *face; + count = IDirect3DRMFaceArray_GetSize(array1); + ok(count == 1, "count = %u\n", count); + hr = IDirect3DRMFaceArray_GetElement(array1, 0, &face); + ok(hr == D3DRM_OK, "Cannot get face (hr = %x)\n", hr); + IDirect3DRMFace_Release(face); + IDirect3DRMFaceArray_Release(array1); + } + + icount = IDirect3DRMFace_GetVertexCount(face1); + ok(!icount, "wrong VertexCount: %i\n", icount); + + IDirect3DRMFace_Release(face1); + IDirect3DRMMeshBuilder2_Release(MeshBuilder2); + + if (FAILED(hr = IDirect3DRM_QueryInterface(d3drm, &IID_IDirect3DRM3, (void **)&d3drm3))) + { + win_skip("Cannot get IDirect3DRM3 interface (hr = %x), skipping tests\n", hr); + IDirect3DRM_Release(d3drm); + return; + } + + hr = IDirect3DRM3_CreateMeshBuilder(d3drm3, &MeshBuilder3); + ok(hr == D3DRM_OK, "Cannot get IDirect3DRMMeshBuilder3 interface (hr = %x)\n", hr); + + icount = IDirect3DRMMeshBuilder3_GetFaceCount(MeshBuilder3); + ok(!icount, "wrong FaceCount: %i\n", icount); + + hr = IDirect3DRMMeshBuilder3_CreateFace(MeshBuilder3, &face2); + ok(hr == D3DRM_OK, "Cannot get IDirect3DRMFace2 interface (hr = %x)\n", hr); + + hr = IDirect3DRMFace2_GetClassName(face2, NULL, cname); + ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr); + hr = IDirect3DRMFace2_GetClassName(face2, NULL, NULL); + ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr); + count = 1; + hr = IDirect3DRMFace2_GetClassName(face2, &count, cname); + ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr); + count = sizeof(cname); + hr = IDirect3DRMFace2_GetClassName(face2, &count, cname); + ok(hr == D3DRM_OK, "Cannot get classname (hr = %x)\n", hr); + ok(count == sizeof("Face"), "wrong size: %u\n", count); + ok(!strcmp(cname, "Face"), "Expected cname to be \"Face\", but got \"%s\"\n", cname); + + icount = IDirect3DRMMeshBuilder3_GetFaceCount(MeshBuilder3); + todo_wine + ok(icount == 1, "wrong FaceCount: %i\n", icount); + + array1 = NULL; + hr = IDirect3DRMMeshBuilder3_GetFaces(MeshBuilder3, &array1); + todo_wine + ok(hr == D3DRM_OK, "Cannot get FaceArray (hr = %x)\n", hr); + todo_wine + ok(array1 != NULL, "pArray = %p\n", array1); + if (array1) + { + IDirect3DRMFace *face; + count = IDirect3DRMFaceArray_GetSize(array1); + ok(count == 1, "count = %u\n", count); + hr = IDirect3DRMFaceArray_GetElement(array1, 0, &face); + ok(hr == D3DRM_OK, "Cannot get face (hr = %x)\n", hr); + IDirect3DRMFace_Release(face); + IDirect3DRMFaceArray_Release(array1); + } + + icount = IDirect3DRMFace2_GetVertexCount(face2); + ok(!icount, "wrong VertexCount: %i\n", icount); + + info.lpMemory = data_ok; + info.dSize = strlen(data_ok); + hr = IDirect3DRMMeshBuilder3_Load(MeshBuilder3, &info, NULL, D3DRMLOAD_FROMMEMORY, NULL, NULL); + ok(hr == D3DRM_OK, "Cannot load mesh data (hr = %x)\n", hr); + + icount = IDirect3DRMMeshBuilder3_GetVertexCount(MeshBuilder3); + ok(icount == 4, "Wrong number of vertices %d (must be 4)\n", icount); + + icount = IDirect3DRMMeshBuilder3_GetNormalCount(MeshBuilder3); + ok(icount == 4, "Wrong number of normals %d (must be 4)\n", icount); + + icount = IDirect3DRMMeshBuilder3_GetFaceCount(MeshBuilder3); + todo_wine + ok(icount == 4, "Wrong number of faces %d (must be 4)\n", icount); + + count = 4; + hr = IDirect3DRMMeshBuilder3_GetVertices(MeshBuilder3, 0, &count, v1); + ok(hr == D3DRM_OK, "Cannot get vertices information (hr = %x)\n", hr); + ok(count == 4, "Wrong number of vertices %d (must be 4)\n", count); + + hr = IDirect3DRMMeshBuilder3_GetNormals(MeshBuilder3, 0, &count, n1); + ok(hr == D3DRM_OK, "Cannot get normals information (hr = %x)\n", hr); + ok(count == 4, "Wrong number of normals %d (must be 4)\n", count); + + array1 = NULL; + hr = IDirect3DRMMeshBuilder3_GetFaces(MeshBuilder3, &array1); + todo_wine + ok(hr == D3DRM_OK, "Cannot get FaceArray (hr = %x)\n", hr); + todo_wine + ok(array1 != NULL, "pArray = %p\n", array1); + if (array1) + { + IDirect3DRMFace *face; + count = IDirect3DRMFaceArray_GetSize(array1); + ok(count == 4, "count = %u\n", count); + hr = IDirect3DRMFaceArray_GetElement(array1, 1, &face); + ok(hr == D3DRM_OK, "Cannot get face (hr = %x)\n", hr); + IDirect3DRMFace_GetVertices(face, &count, v2, n2); + ok(hr == D3DRM_OK, "Cannot get vertices information (hr = %x)\n", hr); + ok(count == 3, "Wrong number of vertices %d (must be 3)\n", count); + ok(U1(v2[0]).x == U1(v1[0]).x, "Wrong component v2[0].x = %f (expected %f)\n", + U1(v2[0]).x, U1(v1[0]).x); + ok(U2(v2[0]).y == U2(v1[0]).y, "Wrong component v2[0].y = %f (expected %f)\n", + U2(v2[0]).y, U2(v1[0]).y); + ok(U3(v2[0]).z == U3(v1[0]).z, "Wrong component v2[0].z = %f (expected %f)\n", + U3(v2[0]).z, U3(v1[0]).z); + ok(U1(v2[1]).x == U1(v1[1]).x, "Wrong component v2[1].x = %f (expected %f)\n", + U1(v2[1]).x, U1(v1[1]).x); + ok(U2(v2[1]).y == U2(v1[1]).y, "Wrong component v2[1].y = %f (expected %f)\n", + U2(v2[1]).y, U2(v1[1]).y); + ok(U3(v2[1]).z == U3(v1[1]).z, "Wrong component v2[1].z = %f (expected %f)\n", + U3(v2[1]).z, U3(v1[1]).z); + ok(U1(v2[2]).x == U1(v1[2]).x, "Wrong component v2[2].x = %f (expected %f)\n", + U1(v2[2]).x, U1(v1[2]).x); + ok(U2(v2[2]).y == U2(v1[2]).y, "Wrong component v2[2].y = %f (expected %f)\n", + U2(v2[2]).y, U2(v1[2]).y); + ok(U3(v2[2]).z == U3(v1[2]).z, "Wrong component v2[2].z = %f (expected %f)\n", + U3(v2[2]).z, U3(v1[2]).z); + + ok(U1(n2[0]).x == U1(n1[0]).x, "Wrong component n2[0].x = %f (expected %f)\n", + U1(n2[0]).x, U1(n1[0]).x); + ok(U2(n2[0]).y == U2(n1[0]).y, "Wrong component n2[0].y = %f (expected %f)\n", + U2(n2[0]).y, U2(n1[0]).y); + ok(U3(n2[0]).z == U3(n1[0]).z, "Wrong component n2[0].z = %f (expected %f)\n", + U3(n2[0]).z, U3(n1[0]).z); + ok(U1(n2[1]).x == U1(n1[1]).x, "Wrong component n2[1].x = %f (expected %f)\n", + U1(n2[1]).x, U1(n1[1]).x); + ok(U2(n2[1]).y == U2(n1[1]).y, "Wrong component n2[1].y = %f (expected %f)\n", + U2(n2[1]).y, U2(n1[1]).y); + ok(U3(n2[1]).z == U3(n1[1]).z, "Wrong component n2[1].z = %f (expected %f)\n", + U3(n2[1]).z, U3(n1[1]).z); + ok(U1(n2[2]).x == U1(n1[2]).x, "Wrong component n2[2].x = %f (expected %f)\n", + U1(n2[2]).x, U1(n1[2]).x); + ok(U2(n2[2]).y == U2(n1[2]).y, "Wrong component n2[2].y = %f (expected %f)\n", + U2(n2[2]).y, U2(n1[2]).y); + ok(U3(n2[2]).z == U3(n1[2]).z, "Wrong component n2[2].z = %f (expected %f)\n", + U3(n2[2]).z, U3(n1[2]).z); + + IDirect3DRMFace_Release(face); + IDirect3DRMFaceArray_Release(array1); + } + + IDirect3DRMFace2_Release(face2); + IDirect3DRMMeshBuilder3_Release(MeshBuilder3); + IDirect3DRM3_Release(d3drm3); + IDirect3DRM2_Release(d3drm2); + IDirect3DRM_Release(d3drm); +} + +static void test_Frame(void) +{ + HRESULT hr; + IDirect3DRM *d3drm; + IDirect3DRMFrame *pFrameC; + IDirect3DRMFrame *pFrameP1; + IDirect3DRMFrame *pFrameP2; + IDirect3DRMFrame *pFrameTmp; + IDirect3DRMFrameArray *frame_array; + IDirect3DRMMeshBuilder *mesh_builder; + IDirect3DRMVisual *visual1; + IDirect3DRMVisual *visual_tmp; + IDirect3DRMVisualArray *visual_array; + IDirect3DRMLight *light1; + IDirect3DRMLight *light_tmp; + IDirect3DRMLightArray *light_array; + D3DCOLOR color; + DWORD count; + CHAR cname[64] = {0}; + + hr = pDirect3DRMCreate(&d3drm); + ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface (hr = %x)\n", hr); + + hr = IDirect3DRM_CreateFrame(d3drm, NULL, &pFrameC); + ok(hr == D3DRM_OK, "Cannot get IDirect3DRMFrame interface (hr = %x)\n", hr); + CHECK_REFCOUNT(pFrameC, 1); + + hr = IDirect3DRMFrame_GetClassName(pFrameC, NULL, cname); + ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr); + hr = IDirect3DRMFrame_GetClassName(pFrameC, NULL, NULL); + ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr); + count = 1; + hr = IDirect3DRMFrame_GetClassName(pFrameC, &count, cname); + ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr); + count = sizeof(cname); + hr = IDirect3DRMFrame_GetClassName(pFrameC, &count, cname); + ok(hr == D3DRM_OK, "Cannot get classname (hr = %x)\n", hr); + ok(count == sizeof("Frame"), "wrong size: %u\n", count); + ok(!strcmp(cname, "Frame"), "Expected cname to be \"Frame\", but got \"%s\"\n", cname); + + hr = IDirect3DRMFrame_GetParent(pFrameC, NULL); + ok(hr == D3DRMERR_BADVALUE, "Should fail and return D3DRM_BADVALUE (hr = %x)\n", hr); + pFrameTmp = (void*)0xdeadbeef; + hr = IDirect3DRMFrame_GetParent(pFrameC, &pFrameTmp); + ok(hr == D3DRM_OK, "Cannot get parent frame (hr = %x)\n", hr); + ok(pFrameTmp == NULL, "pFrameTmp = %p\n", pFrameTmp); + CHECK_REFCOUNT(pFrameC, 1); + + frame_array = NULL; + hr = IDirect3DRMFrame_GetChildren(pFrameC, &frame_array); + ok(hr == D3DRM_OK, "Cannot get children (hr = %x)\n", hr); + ok(!!frame_array, "frame_array = %p\n", frame_array); + if (frame_array) + { + count = IDirect3DRMFrameArray_GetSize(frame_array); + ok(count == 0, "count = %u\n", count); + hr = IDirect3DRMFrameArray_GetElement(frame_array, 0, &pFrameTmp); + ok(hr == D3DRMERR_BADVALUE, "Should have returned D3DRMERR_BADVALUE (hr = %x)\n", hr); + ok(pFrameTmp == NULL, "pFrameTmp = %p\n", pFrameTmp); + IDirect3DRMFrameArray_Release(frame_array); + } + + hr = IDirect3DRM_CreateFrame(d3drm, NULL, &pFrameP1); + ok(hr == D3DRM_OK, "Cannot get IDirect3DRMFrame interface (hr = %x)\n", hr); + + /* GetParent with NULL pointer */ + hr = IDirect3DRMFrame_GetParent(pFrameP1, NULL); + ok(hr == D3DRMERR_BADVALUE, "Should have returned D3DRMERR_BADVALUE (hr = %x)\n", hr); + CHECK_REFCOUNT(pFrameP1, 1); + + /* [Add/Delete]Child with NULL pointer */ + hr = IDirect3DRMFrame_AddChild(pFrameP1, NULL); + ok(hr == D3DRMERR_BADOBJECT, "Should have returned D3DRMERR_BADOBJECT (hr = %x)\n", hr); + CHECK_REFCOUNT(pFrameP1, 1); + + hr = IDirect3DRMFrame_DeleteChild(pFrameP1, NULL); + ok(hr == D3DRMERR_BADOBJECT, "Should have returned D3DRMERR_BADOBJECT (hr = %x)\n", hr); + CHECK_REFCOUNT(pFrameP1, 1); + + /* Add child to first parent */ + pFrameTmp = (void*)0xdeadbeef; + hr = IDirect3DRMFrame_GetParent(pFrameP1, &pFrameTmp); + ok(hr == D3DRM_OK, "Cannot get parent frame (hr = %x)\n", hr); + ok(pFrameTmp == NULL, "pFrameTmp = %p\n", pFrameTmp); + + hr = IDirect3DRMFrame_AddChild(pFrameP1, pFrameC); + ok(hr == D3DRM_OK, "Cannot add child frame (hr = %x)\n", hr); + CHECK_REFCOUNT(pFrameP1, 1); + CHECK_REFCOUNT(pFrameC, 2); + + frame_array = NULL; + hr = IDirect3DRMFrame_GetChildren(pFrameP1, &frame_array); + ok(hr == D3DRM_OK, "Cannot get children (hr = %x)\n", hr); + /* In some older version of d3drm, creating IDirect3DRMFrameArray object with GetChildren does not increment refcount of children frames */ + ok((get_refcount((IUnknown*)pFrameC) == 3) || broken(get_refcount((IUnknown*)pFrameC) == 2), + "Invalid refcount. Expected 3 (or 2) got %d\n", get_refcount((IUnknown*)pFrameC)); + if (frame_array) + { + count = IDirect3DRMFrameArray_GetSize(frame_array); + ok(count == 1, "count = %u\n", count); + hr = IDirect3DRMFrameArray_GetElement(frame_array, 0, &pFrameTmp); + ok(hr == D3DRM_OK, "Cannot get element (hr = %x)\n", hr); + ok(pFrameTmp == pFrameC, "pFrameTmp = %p\n", pFrameTmp); + ok((get_refcount((IUnknown*)pFrameC) == 4) || broken(get_refcount((IUnknown*)pFrameC) == 3), + "Invalid refcount. Expected 4 (or 3) got %d\n", get_refcount((IUnknown*)pFrameC)); + IDirect3DRMFrame_Release(pFrameTmp); + ok((get_refcount((IUnknown*)pFrameC) == 3) || broken(get_refcount((IUnknown*)pFrameC) == 2), + "Invalid refcount. Expected 3 (or 2) got %d\n", get_refcount((IUnknown*)pFrameC)); + IDirect3DRMFrameArray_Release(frame_array); + CHECK_REFCOUNT(pFrameC, 2); + } + + pFrameTmp = (void*)0xdeadbeef; + hr = IDirect3DRMFrame_GetParent(pFrameC, &pFrameTmp); + ok(hr == D3DRM_OK, "Cannot get parent frame (hr = %x)\n", hr); + ok(pFrameTmp == pFrameP1, "pFrameTmp = %p\n", pFrameTmp); + CHECK_REFCOUNT(pFrameP1, 2); + + /* Add child to second parent */ + hr = IDirect3DRM_CreateFrame(d3drm, NULL, &pFrameP2); + ok(hr == D3DRM_OK, "Cannot get IDirect3DRMFrame interface (hr = %x)\n", hr); + + hr = IDirect3DRMFrame_AddChild(pFrameP2, pFrameC); + ok(hr == D3DRM_OK, "Cannot add child frame (hr = %x)\n", hr); + CHECK_REFCOUNT(pFrameC, 2); + + frame_array = NULL; + hr = IDirect3DRMFrame_GetChildren(pFrameP2, &frame_array); + ok(hr == D3DRM_OK, "Cannot get children (hr = %x)\n", hr); + if (frame_array) + { + count = IDirect3DRMFrameArray_GetSize(frame_array); + ok(count == 1, "count = %u\n", count); + hr = IDirect3DRMFrameArray_GetElement(frame_array, 0, &pFrameTmp); + ok(hr == D3DRM_OK, "Cannot get element (hr = %x)\n", hr); + ok(pFrameTmp == pFrameC, "pFrameTmp = %p\n", pFrameTmp); + IDirect3DRMFrame_Release(pFrameTmp); + IDirect3DRMFrameArray_Release(frame_array); + } + + frame_array = NULL; + hr = IDirect3DRMFrame_GetChildren(pFrameP1, &frame_array); + ok(hr == D3DRM_OK, "Cannot get children (hr = %x)\n", hr); + if (frame_array) + { + count = IDirect3DRMFrameArray_GetSize(frame_array); + ok(count == 0, "count = %u\n", count); + pFrameTmp = (void*)0xdeadbeef; + hr = IDirect3DRMFrameArray_GetElement(frame_array, 0, &pFrameTmp); + ok(hr == D3DRMERR_BADVALUE, "Should have returned D3DRMERR_BADVALUE (hr = %x)\n", hr); + ok(pFrameTmp == NULL, "pFrameTmp = %p\n", pFrameTmp); + IDirect3DRMFrameArray_Release(frame_array); + } + + pFrameTmp = (void*)0xdeadbeef; + hr = IDirect3DRMFrame_GetParent(pFrameC, &pFrameTmp); + ok(hr == D3DRM_OK, "Cannot get parent frame (hr = %x)\n", hr); + ok(pFrameTmp == pFrameP2, "pFrameTmp = %p\n", pFrameTmp); + CHECK_REFCOUNT(pFrameP2, 2); + CHECK_REFCOUNT(pFrameC, 2); + + /* Add child again */ + hr = IDirect3DRMFrame_AddChild(pFrameP2, pFrameC); + ok(hr == D3DRM_OK, "Cannot add child frame (hr = %x)\n", hr); + CHECK_REFCOUNT(pFrameC, 2); + + frame_array = NULL; + hr = IDirect3DRMFrame_GetChildren(pFrameP2, &frame_array); + ok(hr == D3DRM_OK, "Cannot get children (hr = %x)\n", hr); + if (frame_array) + { + count = IDirect3DRMFrameArray_GetSize(frame_array); + ok(count == 1, "count = %u\n", count); + hr = IDirect3DRMFrameArray_GetElement(frame_array, 0, &pFrameTmp); + ok(hr == D3DRM_OK, "Cannot get element (hr = %x)\n", hr); + ok(pFrameTmp == pFrameC, "pFrameTmp = %p\n", pFrameTmp); + IDirect3DRMFrame_Release(pFrameTmp); + IDirect3DRMFrameArray_Release(frame_array); + } + + /* Delete child */ + hr = IDirect3DRMFrame_DeleteChild(pFrameP2, pFrameC); + ok(hr == D3DRM_OK, "Cannot delete child frame (hr = %x)\n", hr); + CHECK_REFCOUNT(pFrameC, 1); + + frame_array = NULL; + hr = IDirect3DRMFrame_GetChildren(pFrameP2, &frame_array); + ok(hr == D3DRM_OK, "Cannot get children (hr = %x)\n", hr); + if (frame_array) + { + count = IDirect3DRMFrameArray_GetSize(frame_array); + ok(count == 0, "count = %u\n", count); + pFrameTmp = (void*)0xdeadbeef; + hr = IDirect3DRMFrameArray_GetElement(frame_array, 0, &pFrameTmp); + ok(hr == D3DRMERR_BADVALUE, "Should have returned D3DRMERR_BADVALUE (hr = %x)\n", hr); + ok(pFrameTmp == NULL, "pFrameTmp = %p\n", pFrameTmp); + IDirect3DRMFrameArray_Release(frame_array); + } + + pFrameTmp = (void*)0xdeadbeef; + hr = IDirect3DRMFrame_GetParent(pFrameC, &pFrameTmp); + ok(hr == D3DRM_OK, "Cannot get parent frame (hr = %x)\n", hr); + ok(pFrameTmp == NULL, "pFrameTmp = %p\n", pFrameTmp); + + /* Add two children */ + hr = IDirect3DRMFrame_AddChild(pFrameP2, pFrameC); + ok(hr == D3DRM_OK, "Cannot add child frame (hr = %x)\n", hr); + CHECK_REFCOUNT(pFrameC, 2); + + hr = IDirect3DRMFrame_AddChild(pFrameP2, pFrameP1); + ok(hr == D3DRM_OK, "Cannot add child frame (hr = %x)\n", hr); + CHECK_REFCOUNT(pFrameP1, 3); + + frame_array = NULL; + hr = IDirect3DRMFrame_GetChildren(pFrameP2, &frame_array); + ok(hr == D3DRM_OK, "Cannot get children (hr = %x)\n", hr); + if (frame_array) + { + count = IDirect3DRMFrameArray_GetSize(frame_array); + ok(count == 2, "count = %u\n", count); + hr = IDirect3DRMFrameArray_GetElement(frame_array, 0, &pFrameTmp); + ok(hr == D3DRM_OK, "Cannot get element (hr = %x)\n", hr); + ok(pFrameTmp == pFrameC, "pFrameTmp = %p\n", pFrameTmp); + IDirect3DRMFrame_Release(pFrameTmp); + hr = IDirect3DRMFrameArray_GetElement(frame_array, 1, &pFrameTmp); + ok(hr == D3DRM_OK, "Cannot get element (hr = %x)\n", hr); + ok(pFrameTmp == pFrameP1, "pFrameTmp = %p\n", pFrameTmp); + IDirect3DRMFrame_Release(pFrameTmp); + IDirect3DRMFrameArray_Release(frame_array); + } + + /* [Add/Delete]Visual with NULL pointer */ + hr = IDirect3DRMFrame_AddVisual(pFrameP1, NULL); + ok(hr == D3DRMERR_BADOBJECT, "Should have returned D3DRMERR_BADOBJECT (hr = %x)\n", hr); + CHECK_REFCOUNT(pFrameP1, 3); + + hr = IDirect3DRMFrame_DeleteVisual(pFrameP1, NULL); + ok(hr == D3DRMERR_BADOBJECT, "Should have returned D3DRMERR_BADOBJECT (hr = %x)\n", hr); + CHECK_REFCOUNT(pFrameP1, 3); + + /* Create Visual */ + hr = IDirect3DRM_CreateMeshBuilder(d3drm, &mesh_builder); + ok(hr == D3DRM_OK, "Cannot get IDirect3DRMMeshBuilder interface (hr = %x)\n", hr); + visual1 = (IDirect3DRMVisual *)mesh_builder; + + /* Add Visual to first parent */ + hr = IDirect3DRMFrame_AddVisual(pFrameP1, visual1); + ok(hr == D3DRM_OK, "Cannot add visual (hr = %x)\n", hr); + CHECK_REFCOUNT(pFrameP1, 3); + CHECK_REFCOUNT(visual1, 2); + + visual_array = NULL; + hr = IDirect3DRMFrame_GetVisuals(pFrameP1, &visual_array); + ok(hr == D3DRM_OK, "Cannot get visuals (hr = %x)\n", hr); + if (visual_array) + { + count = IDirect3DRMVisualArray_GetSize(visual_array); + ok(count == 1, "count = %u\n", count); + hr = IDirect3DRMVisualArray_GetElement(visual_array, 0, &visual_tmp); + ok(hr == D3DRM_OK, "Cannot get element (hr = %x)\n", hr); + ok(visual_tmp == visual1, "visual_tmp = %p\n", visual_tmp); + IDirect3DRMVisual_Release(visual_tmp); + IDirect3DRMVisualArray_Release(visual_array); + } + + /* Delete Visual */ + hr = IDirect3DRMFrame_DeleteVisual(pFrameP1, visual1); + ok(hr == D3DRM_OK, "Cannot delete visual (hr = %x)\n", hr); + CHECK_REFCOUNT(pFrameP1, 3); + IDirect3DRMMeshBuilder_Release(mesh_builder); + + /* [Add/Delete]Light with NULL pointer */ + hr = IDirect3DRMFrame_AddLight(pFrameP1, NULL); + ok(hr == D3DRMERR_BADOBJECT, "Should have returned D3DRMERR_BADOBJECT (hr = %x)\n", hr); + CHECK_REFCOUNT(pFrameP1, 3); + + hr = IDirect3DRMFrame_DeleteLight(pFrameP1, NULL); + ok(hr == D3DRMERR_BADOBJECT, "Should have returned D3DRMERR_BADOBJECT (hr = %x)\n", hr); + CHECK_REFCOUNT(pFrameP1, 3); + + /* Create Light */ + hr = IDirect3DRM_CreateLightRGB(d3drm, D3DRMLIGHT_SPOT, 0.1, 0.2, 0.3, &light1); + ok(hr == D3DRM_OK, "Cannot get IDirect3DRMLight interface (hr = %x)\n", hr); + + /* Add Light to first parent */ + hr = IDirect3DRMFrame_AddLight(pFrameP1, light1); + ok(hr == D3DRM_OK, "Cannot add light (hr = %x)\n", hr); + CHECK_REFCOUNT(pFrameP1, 3); + CHECK_REFCOUNT(light1, 2); + + light_array = NULL; + hr = IDirect3DRMFrame_GetLights(pFrameP1, &light_array); + ok(hr == D3DRM_OK, "Cannot get lights (hr = %x)\n", hr); + if (light_array) + { + count = IDirect3DRMLightArray_GetSize(light_array); + ok(count == 1, "count = %u\n", count); + hr = IDirect3DRMLightArray_GetElement(light_array, 0, &light_tmp); + ok(hr == D3DRM_OK, "Cannot get element (hr = %x)\n", hr); + ok(light_tmp == light1, "light_tmp = %p\n", light_tmp); + IDirect3DRMLight_Release(light_tmp); + IDirect3DRMLightArray_Release(light_array); + } + + /* Delete Light */ + hr = IDirect3DRMFrame_DeleteLight(pFrameP1, light1); + ok(hr == D3DRM_OK, "Cannot delete light (hr = %x)\n", hr); + CHECK_REFCOUNT(pFrameP1, 3); + IDirect3DRMLight_Release(light1); + + /* Test SceneBackground on first parent */ + color = IDirect3DRMFrame_GetSceneBackground(pFrameP1); + ok(color == 0xff000000, "wrong color (%x)\n", color); + + hr = IDirect3DRMFrame_SetSceneBackground(pFrameP1, 0xff180587); + ok(hr == D3DRM_OK, "Cannot set color (hr = %x)\n", hr); + color = IDirect3DRMFrame_GetSceneBackground(pFrameP1); + ok(color == 0xff180587, "wrong color (%x)\n", color); + + hr = IDirect3DRMFrame_SetSceneBackgroundRGB(pFrameP1, 0.5, 0.5, 0.5); + ok(hr == D3DRM_OK, "Cannot set color (hr = %x)\n", hr); + color = IDirect3DRMFrame_GetSceneBackground(pFrameP1); + ok(color == 0xff7f7f7f, "wrong color (%x)\n", color); + + /* Cleanup */ + IDirect3DRMFrame_Release(pFrameP2); + CHECK_REFCOUNT(pFrameC, 2); + CHECK_REFCOUNT(pFrameP1, 3); + + IDirect3DRMFrame_Release(pFrameC); + IDirect3DRMFrame_Release(pFrameP1); + + IDirect3DRM_Release(d3drm); +} + +static void test_Viewport(void) +{ + IDirectDrawClipper *pClipper; + HRESULT hr; + IDirect3DRM *d3drm; + IDirect3DRMDevice *device; + IDirect3DRMFrame *frame; + IDirect3DRMViewport *viewport; + GUID driver; + HWND window; + RECT rc; + DWORD size; + CHAR cname[64] = {0}; + + window = CreateWindowA("static", "d3drm_test", WS_OVERLAPPEDWINDOW, 0, 0, 300, 200, 0, 0, 0, 0); + GetClientRect(window, &rc); + + hr = pDirect3DRMCreate(&d3drm); + ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface (hr = %x)\n", hr); + + hr = DirectDrawCreateClipper(0, &pClipper, NULL); + ok(hr == DD_OK, "Cannot get IDirectDrawClipper interface (hr = %x)\n", hr); + + hr = IDirectDrawClipper_SetHWnd(pClipper, 0, window); + ok(hr == DD_OK, "Cannot set HWnd to Clipper (hr = %x)\n", hr); + + memcpy(&driver, &IID_IDirect3DRGBDevice, sizeof(GUID)); + hr = IDirect3DRM3_CreateDeviceFromClipper(d3drm, pClipper, &driver, rc.right, rc.bottom, &device); + ok(hr == D3DRM_OK, "Cannot get IDirect3DRMDevice interface (hr = %x)\n", hr); + + hr = IDirect3DRM_CreateFrame(d3drm, NULL, &frame); + ok(hr == D3DRM_OK, "Cannot get IDirect3DRMFrame interface (hr = %x)\n", hr); + + hr = IDirect3DRM_CreateViewport(d3drm, device, frame, rc.left, rc.top, rc.right, rc.bottom, &viewport); + ok(hr == D3DRM_OK, "Cannot get IDirect3DRMViewport interface (hr = %x)\n", hr); + + hr = IDirect3DRMViewport_GetClassName(viewport, NULL, cname); + ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr); + hr = IDirect3DRMViewport_GetClassName(viewport, NULL, NULL); + ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr); + size = 1; + hr = IDirect3DRMViewport_GetClassName(viewport, &size, cname); + ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr); + size = sizeof(cname); + hr = IDirect3DRMViewport_GetClassName(viewport, &size, cname); + ok(hr == D3DRM_OK, "Cannot get classname (hr = %x)\n", hr); + ok(size == sizeof("Viewport"), "wrong size: %u\n", size); + ok(!strcmp(cname, "Viewport"), "Expected cname to be \"Viewport\", but got \"%s\"\n", cname); + + IDirect3DRMViewport_Release(viewport); + IDirect3DRMFrame_Release(frame); + IDirect3DRMDevice_Release(device); + IDirectDrawClipper_Release(pClipper); + + IDirect3DRM_Release(d3drm); + DestroyWindow(window); +} + +static void test_Light(void) +{ + HRESULT hr; + IDirect3DRM *d3drm; + IDirect3DRMLight *light; + D3DRMLIGHTTYPE type; + D3DCOLOR color; + DWORD size; + CHAR cname[64] = {0}; + + hr = pDirect3DRMCreate(&d3drm); + ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface (hr = %x)\n", hr); + + hr = IDirect3DRM_CreateLightRGB(d3drm, D3DRMLIGHT_SPOT, 0.5, 0.5, 0.5, &light); + ok(hr == D3DRM_OK, "Cannot get IDirect3DRMLight interface (hr = %x)\n", hr); + + hr = IDirect3DRMLight_GetClassName(light, NULL, cname); + ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr); + hr = IDirect3DRMLight_GetClassName(light, NULL, NULL); + ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr); + size = 1; + hr = IDirect3DRMLight_GetClassName(light, &size, cname); + ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr); + size = sizeof(cname); + hr = IDirect3DRMLight_GetClassName(light, &size, cname); + ok(hr == D3DRM_OK, "Cannot get classname (hr = %x)\n", hr); + ok(size == sizeof("Light"), "wrong size: %u\n", size); + ok(!strcmp(cname, "Light"), "Expected cname to be \"Light\", but got \"%s\"\n", cname); + + type = IDirect3DRMLight_GetType(light); + ok(type == D3DRMLIGHT_SPOT, "wrong type (%u)\n", type); + + color = IDirect3DRMLight_GetColor(light); + ok(color == 0xff7f7f7f, "wrong color (%x)\n", color); + + hr = IDirect3DRMLight_SetType(light, D3DRMLIGHT_POINT); + ok(hr == D3DRM_OK, "Cannot set type (hr = %x)\n", hr); + type = IDirect3DRMLight_GetType(light); + ok(type == D3DRMLIGHT_POINT, "wrong type (%u)\n", type); + + hr = IDirect3DRMLight_SetColor(light, 0xff180587); + ok(hr == D3DRM_OK, "Cannot set color (hr = %x)\n", hr); + color = IDirect3DRMLight_GetColor(light); + ok(color == 0xff180587, "wrong color (%x)\n", color); + + hr = IDirect3DRMLight_SetColorRGB(light, 0.5, 0.5, 0.5); + ok(hr == D3DRM_OK, "Cannot set color (hr = %x)\n", hr); + color = IDirect3DRMLight_GetColor(light); + ok(color == 0xff7f7f7f, "wrong color (%x)\n", color); + + IDirect3DRMLight_Release(light); + + IDirect3DRM_Release(d3drm); +} + +static void test_Material2(void) +{ + HRESULT hr; + IDirect3DRM *d3drm; + IDirect3DRM3 *d3drm3; + IDirect3DRMMaterial2 *material2; + D3DVALUE r, g, b; + DWORD size; + CHAR cname[64] = {0}; + + hr = pDirect3DRMCreate(&d3drm); + ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface (hr = %x)\n", hr); + + if (FAILED(hr = IDirect3DRM_QueryInterface(d3drm, &IID_IDirect3DRM3, (void **)&d3drm3))) + { + win_skip("Cannot get IDirect3DRM3 interface (hr = %x), skipping tests\n", hr); + IDirect3DRM_Release(d3drm); + return; + } + + hr = IDirect3DRM3_CreateMaterial(d3drm3, 18.5f, &material2); + ok(hr == D3DRM_OK, "Cannot get IDirect3DRMMaterial2 interface (hr = %x)\n", hr); + + hr = IDirect3DRMMaterial2_GetClassName(material2, NULL, cname); + ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr); + hr = IDirect3DRMMaterial2_GetClassName(material2, NULL, NULL); + ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr); + size = 1; + hr = IDirect3DRMMaterial2_GetClassName(material2, &size, cname); + ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr); + size = sizeof(cname); + hr = IDirect3DRMMaterial2_GetClassName(material2, &size, cname); + ok(hr == D3DRM_OK, "Cannot get classname (hr = %x)\n", hr); + ok(size == sizeof("Material"), "wrong size: %u\n", size); + ok(!strcmp(cname, "Material"), "Expected cname to be \"Material\", but got \"%s\"\n", cname); + + r = IDirect3DRMMaterial2_GetPower(material2); + ok(r == 18.5f, "wrong power (%f)\n", r); + + hr = IDirect3DRMMaterial2_GetEmissive(material2, &r, &g, &b); + ok(hr == D3DRM_OK, "Cannot get emissive (hr = %x)\n", hr); + ok(r == 0.0f && g == 0.0f && b == 0.0f, "wrong emissive r=%f g=%f b=%f, expected r=0.0 g=0.0 b=0.0\n", r, g, b); + + hr = IDirect3DRMMaterial2_GetSpecular(material2, &r, &g, &b); + ok(hr == D3DRM_OK, "Cannot get emissive (hr = %x)\n", hr); + ok(r == 1.0f && g == 1.0f && b == 1.0f, "wrong specular r=%f g=%f b=%f, expected r=1.0 g=1.0 b=1.0\n", r, g, b); + + hr = IDirect3DRMMaterial2_GetAmbient(material2, &r, &g, &b); + ok(hr == D3DRM_OK, "Cannot get emissive (hr = %x)\n", hr); + ok(r == 0.0f && g == 0.0f && b == 0.0f, "wrong ambient r=%f g=%f b=%f, expected r=0.0 g=0.0 b=0.0\n", r, g, b); + + hr = IDirect3DRMMaterial2_SetPower(material2, 5.87f); + ok(hr == D3DRM_OK, "Cannot set power (hr = %x)\n", hr); + r = IDirect3DRMMaterial2_GetPower(material2); + ok(r == 5.87f, "wrong power (%f)\n", r); + + hr = IDirect3DRMMaterial2_SetEmissive(material2, 0.5f, 0.5f, 0.5f); + ok(hr == D3DRM_OK, "Cannot set emissive (hr = %x)\n", hr); + hr = IDirect3DRMMaterial2_GetEmissive(material2, &r, &g, &b); + ok(hr == D3DRM_OK, "Cannot get emissive (hr = %x)\n", hr); + ok(r == 0.5f && g == 0.5f && b == 0.5f, "wrong emissive r=%f g=%f b=%f, expected r=0.5 g=0.5 b=0.5\n", r, g, b); + + hr = IDirect3DRMMaterial2_SetSpecular(material2, 0.6f, 0.6f, 0.6f); + ok(hr == D3DRM_OK, "Cannot set specular (hr = %x)\n", hr); + hr = IDirect3DRMMaterial2_GetSpecular(material2, &r, &g, &b); + ok(hr == D3DRM_OK, "Cannot get specular (hr = %x)\n", hr); + ok(r == 0.6f && g == 0.6f && b == 0.6f, "wrong specular r=%f g=%f b=%f, expected r=0.6 g=0.6 b=0.6\n", r, g, b); + + hr = IDirect3DRMMaterial2_SetAmbient(material2, 0.7f, 0.7f, 0.7f); + ok(hr == D3DRM_OK, "Cannot set ambient (hr = %x)\n", hr); + hr = IDirect3DRMMaterial2_GetAmbient(material2, &r, &g, &b); + ok(hr == D3DRM_OK, "Cannot get ambient (hr = %x)\n", hr); + ok(r == 0.7f && g == 0.7f && b == 0.7f, "wrong ambient r=%f g=%f b=%f, expected r=0.7 g=0.7 b=0.7\n", r, g, b); + + IDirect3DRMMaterial2_Release(material2); + + IDirect3DRM3_Release(d3drm3); + IDirect3DRM_Release(d3drm); +} + +static void test_Texture(void) +{ + HRESULT hr; + IDirect3DRM *d3drm; + IDirect3DRMTexture *texture; + D3DRMIMAGE initimg = { + 2, 2, 1, 1, 32, + TRUE, 2 * sizeof(DWORD), NULL, NULL, + 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000, 0, NULL + }; + DWORD pixel[4] = { 20000, 30000, 10000, 0 }; + DWORD size; + CHAR cname[64] = {0}; + + hr = pDirect3DRMCreate(&d3drm); + ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface (hr = %x)\n", hr); + + initimg.buffer1 = &pixel; + hr = IDirect3DRM_CreateTexture(d3drm, &initimg, &texture); + ok(hr == D3DRM_OK, "Cannot get IDirect3DRMTexture interface (hr = %x)\n", hr); + + hr = IDirect3DRMTexture_GetClassName(texture, NULL, cname); + ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr); + hr = IDirect3DRMTexture_GetClassName(texture, NULL, NULL); + ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr); + size = 1; + hr = IDirect3DRMTexture_GetClassName(texture, &size, cname); + ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr); + size = sizeof(cname); + hr = IDirect3DRMTexture_GetClassName(texture, &size, cname); + ok(hr == D3DRM_OK, "Cannot get classname (hr = %x)\n", hr); + ok(size == sizeof("Texture"), "wrong size: %u\n", size); + ok(!strcmp(cname, "Texture"), "Expected cname to be \"Texture\", but got \"%s\"\n", cname); + + IDirect3DRMTexture_Release(texture); + + IDirect3DRM_Release(d3drm); +} + +static void test_Device(void) +{ + IDirectDrawClipper *pClipper; + HRESULT hr; + IDirect3DRM *d3drm; + IDirect3DRMDevice *device; + IDirect3DRMWinDevice *win_device; + GUID driver; + HWND window; + RECT rc; + DWORD size; + CHAR cname[64] = {0}; + + window = CreateWindowA("static", "d3drm_test", WS_OVERLAPPEDWINDOW, 0, 0, 300, 200, 0, 0, 0, 0); + GetClientRect(window, &rc); + + hr = pDirect3DRMCreate(&d3drm); + ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface (hr = %x)\n", hr); + + hr = DirectDrawCreateClipper(0, &pClipper, NULL); + ok(hr == DD_OK, "Cannot get IDirectDrawClipper interface (hr = %x)\n", hr); + + hr = IDirectDrawClipper_SetHWnd(pClipper, 0, window); + ok(hr == DD_OK, "Cannot set HWnd to Clipper (hr = %x)\n", hr); + + memcpy(&driver, &IID_IDirect3DRGBDevice, sizeof(GUID)); + hr = IDirect3DRM3_CreateDeviceFromClipper(d3drm, pClipper, &driver, rc.right, rc.bottom, &device); + ok(hr == D3DRM_OK, "Cannot get IDirect3DRMDevice interface (hr = %x)\n", hr); + + hr = IDirect3DRMDevice_GetClassName(device, NULL, cname); + ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr); + hr = IDirect3DRMDevice_GetClassName(device, NULL, NULL); + ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr); + size = 1; + hr = IDirect3DRMDevice_GetClassName(device, &size, cname); + ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr); + size = sizeof(cname); + hr = IDirect3DRMDevice_GetClassName(device, &size, cname); + ok(hr == D3DRM_OK, "Cannot get classname (hr = %x)\n", hr); + ok(size == sizeof("Device"), "wrong size: %u\n", size); + ok(!strcmp(cname, "Device"), "Expected cname to be \"Device\", but got \"%s\"\n", cname); + + /* WinDevice */ + if (FAILED(hr = IDirect3DRMDevice_QueryInterface(device, &IID_IDirect3DRMWinDevice, (void **)&win_device))) + { + win_skip("Cannot get IDirect3DRMWinDevice interface (hr = %x), skipping tests\n", hr); + goto cleanup; + } + + hr = IDirect3DRMWinDevice_GetClassName(win_device, NULL, cname); + ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr); + hr = IDirect3DRMWinDevice_GetClassName(win_device, NULL, NULL); + ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr); + size = 1; + hr = IDirect3DRMWinDevice_GetClassName(win_device, &size, cname); + ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr); + size = sizeof(cname); + hr = IDirect3DRMWinDevice_GetClassName(win_device, &size, cname); + ok(hr == D3DRM_OK, "Cannot get classname (hr = %x)\n", hr); + ok(size == sizeof("Device"), "wrong size: %u\n", size); + ok(!strcmp(cname, "Device"), "Expected cname to be \"Device\", but got \"%s\"\n", cname); + + IDirect3DRMWinDevice_Release(win_device); + +cleanup: + IDirect3DRMDevice_Release(device); + IDirectDrawClipper_Release(pClipper); + + IDirect3DRM_Release(d3drm); + DestroyWindow(window); +} + +static void test_frame_transform(void) +{ + HRESULT hr; + IDirect3DRM *d3drm; + IDirect3DRMFrame *frame; + D3DRMMATRIX4D matrix; + + hr = pDirect3DRMCreate(&d3drm); + ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface (hr = %x)\n", hr); + + hr = IDirect3DRM_CreateFrame(d3drm, NULL, &frame); + ok(hr == D3DRM_OK, "Cannot get IDirect3DRMFrame interface (hr = %x)\n", hr); + + hr = IDirect3DRMFrame_GetTransform(frame, matrix); + ok(hr == D3DRM_OK, "IDirect3DRMFrame_GetTransform returned hr = %x\n", hr); + ok(!memcmp(matrix, identity, sizeof(D3DRMMATRIX4D)), "Returned matrix is not identity\n"); + + IDirect3DRMFrame_Release(frame); + IDirect3DRM_Release(d3drm); +} + +static int nb_objects = 0; +static const GUID* refiids[] = +{ + &IID_IDirect3DRMMeshBuilder, + &IID_IDirect3DRMMeshBuilder, + &IID_IDirect3DRMFrame, + &IID_IDirect3DRMMaterial /* Not taken into account and not notified */ +}; + +static void __cdecl object_load_callback(IDirect3DRMObject *object, REFIID objectguid, void *arg) +{ + ok(object != NULL, "Arg 1 should not be null\n"); + ok(IsEqualGUID(objectguid, refiids[nb_objects]), "Arg 2 is incorrect\n"); + ok(arg == (void *)0xdeadbeef, "Arg 3 should be 0xdeadbeef (got %p)\n", arg); + nb_objects++; +} + +static void test_d3drm_load(void) +{ + HRESULT hr; + IDirect3DRM *d3drm; + D3DRMLOADMEMORY info; + const GUID* req_refiids[] = { &IID_IDirect3DRMMeshBuilder, &IID_IDirect3DRMFrame, &IID_IDirect3DRMMaterial }; + + hr = pDirect3DRMCreate(&d3drm); + ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface (hr = %x)\n", hr); + + info.lpMemory = data_d3drm_load; + info.dSize = strlen(data_d3drm_load); + hr = IDirect3DRM_Load(d3drm, &info, NULL, (GUID **)req_refiids, 3, D3DRMLOAD_FROMMEMORY, + object_load_callback, (void *)0xdeadbeef, NULL, NULL, NULL); + ok(hr == D3DRM_OK, "Cannot load data (hr = %x)\n", hr); + ok(nb_objects == 3, "Should have loaded 3 objects (got %d)\n", nb_objects); + + IDirect3DRM_Release(d3drm); +} + +IDirect3DRMMeshBuilder *mesh_builder = NULL; + +static void __cdecl object_load_callback_frame(IDirect3DRMObject *object, REFIID object_guid, void *arg) +{ + HRESULT hr; + IDirect3DRMFrame *frame; + IDirect3DRMVisualArray *array; + IDirect3DRMVisual *visual; + ULONG size; + char name[128]; + + hr = IDirect3DRMObject_QueryInterface(object, &IID_IDirect3DRMFrame, (void**)&frame); + ok(hr == D3DRM_OK, "IDirect3DRMObject_QueryInterface returned %x\n", hr); + + hr = IDirect3DRMFrame_GetVisuals(frame, &array); + ok(hr == D3DRM_OK, "IDirect3DRMFrame_GetVisuals returned %x\n", hr); + + size = IDirect3DRMVisualArray_GetSize(array); + ok(size == 1, "Wrong size %u returned, expected 1\n", size); + + hr = IDirect3DRMVisualArray_GetElement(array, 0, &visual); + ok(hr == D3DRM_OK, "IDirect3DRMVisualArray_GetElement returned %x\n", hr); + + hr = IDirect3DRMVisual_QueryInterface(visual, &IID_IDirect3DRMMeshBuilder, (void**)&mesh_builder); + ok(hr == D3DRM_OK, "IDirect3DRMVisualArray_GetSize returned %x\n", hr); + + size = sizeof(name); + hr = IDirect3DRMMeshBuilder_GetName(mesh_builder, &size, name); + ok(hr == D3DRM_OK, "IDirect3DRMMeshBuilder_GetName returned %x\n", hr); + ok(!strcmp(name, "mesh1"), "Wrong name %s, expected mesh1\n", name); + + IDirect3DRMVisual_Release(visual); + IDirect3DRMVisualArray_Release(array); + IDirect3DRMFrame_Release(frame); +} + +struct { + int vertex_count; + int face_count; + int vertex_per_face; + int face_data_size; + DWORD color; + float power; + float specular[3]; + float emissive[3]; +} groups[3] = { + { 4, 3, 3, 9, 0x4c0000ff, 30.0f, { 0.31f, 0.32f, 0.33f }, { 0.34f, 0.35f, 0.36f } }, + { 4, 2, 3, 6, 0x3300ff00, 20.0f, { 0.21f, 0.22f, 0.23f }, { 0.24f, 0.25f, 0.26f } }, + { 3, 1, 3, 3, 0x19ff0000, 10.0f, { 0.11f, 0.12f, 0.13f }, { 0.14f, 0.15f, 0.16f } } +}; + +static void test_frame_mesh_materials(void) +{ + HRESULT hr; + IDirect3DRM *d3drm; + D3DRMLOADMEMORY info; + const GUID *req_refiids[] = { &IID_IDirect3DRMFrame }; + IDirect3DRMMesh *mesh; + ULONG size; + IDirect3DRMMaterial *material; + IDirect3DRMTexture *texture; + int i; + + hr = pDirect3DRMCreate(&d3drm); + ok(hr == D3DRM_OK, "Direct3DRMCreate returned %x\n", hr); + + info.lpMemory = data_frame_mesh_materials; + info.dSize = strlen(data_frame_mesh_materials); + hr = IDirect3DRM_Load(d3drm, &info, NULL, (GUID**)req_refiids, 1, D3DRMLOAD_FROMMEMORY, object_load_callback_frame, (void*)0xdeadbeef, NULL, NULL, NULL); + ok(hr == D3DRM_OK, "Cannot load data (hr = %x)\n", hr); + + hr = IDirect3DRMMeshBuilder_CreateMesh(mesh_builder, &mesh); + ok(hr == D3DRM_OK, "IDirect3DRMMeshBuilder_CreateMesh returned %x\n", hr); + + size = IDirect3DRMMesh_GetGroupCount(mesh); + ok(size == 3, "Wrong size %u returned, expected 3\n", size); + + for (i = 0; i < size; i++) + { + D3DVALUE red, green, blue, power; + D3DCOLOR color; + unsigned vertex_count, face_count, vertex_per_face; + DWORD face_data_size; + + hr = IDirect3DRMMesh_GetGroup(mesh, i, &vertex_count, &face_count, &vertex_per_face, &face_data_size, NULL); + ok(hr == D3DRM_OK, "Group %d: IDirect3DRMMesh_GetGroup returned %x\n", i, hr); + ok(vertex_count == groups[i].vertex_count, "Group %d: Wrong vertex count %d, expected %d\n", i, vertex_count, groups[i].vertex_count); + ok(face_count == groups[i].face_count, "Group %d: Wrong face count %d; expected %d\n", i, face_count, groups[i].face_count); + ok(vertex_per_face == groups[i].vertex_per_face, "Group %d: Wrong vertex per face %d, expected %d\n", i, vertex_per_face, groups[i].vertex_per_face); + ok(face_data_size == groups[i].face_data_size, "Group %d: Wrong face data size %d, expected %d\n", i, face_data_size, groups[i].face_data_size); + + color = IDirect3DRMMesh_GetGroupColor(mesh, i); + ok(color == groups[i].color, "Group %d: Wrong color %x, expected %x\n", i, color, groups[i].color); + + hr = IDirect3DRMMesh_GetGroupMaterial(mesh, i, &material); + ok(hr == D3DRM_OK, "Group %d: IDirect3DRMMesh_GetGroupMaterial returned %x\n", i, hr); + ok(material != NULL, "Group %d: No material\n", i); + power = IDirect3DRMMaterial_GetPower(material); + ok(power == groups[i].power, "Group %d: Wrong power %f, expected %f\n", i, power, groups[i].power); + hr = IDirect3DRMMaterial_GetSpecular(material, &red, &green, &blue); + ok(hr == D3DRM_OK, "Group %d: IDirect3DRMMaterial_GetSpecular returned %x\n", i, hr); + ok(red == groups[i].specular[0], "Group %d: Wrong specular red %f, expected %f\n", i, red, groups[i].specular[0]); + ok(green == groups[i].specular[1], "Group %d: Wrong specular green %f, pD3DRMexpected %f\n", i, green, groups[i].specular[1]); + ok(blue == groups[i].specular[2], "Group %d: Wrong specular blue %f, expected %f\n", i, blue, groups[i].specular[2]); + hr = IDirect3DRMMaterial_GetEmissive(material, &red, &green, &blue); + ok(hr == D3DRM_OK, "Group %d: IDirect3DRMMaterial_GetEmissive returned %x\n", i, hr); + ok(red == groups[i].emissive[0], "Group %d: Wrong emissive red %f, expected %f\n", i, red, groups[i].emissive[0]); + ok(green == groups[i].emissive[1], "Group %d: Wrong emissive green %f, expected %f\n", i, green, groups[i].emissive[1]); + ok(blue == groups[i].emissive[2], "Group %d: Wrong emissive blue %f, expected %f\n", i, blue, groups[i].emissive[2]); + + hr = IDirect3DRMMesh_GetGroupTexture(mesh, i, &texture); + ok(hr == D3DRM_OK, "Group %d: IDirect3DRMMesh_GetGroupTexture returned %x\n", i, hr); + ok(!texture, "Group %d: Unexpected texture\n", i); + + if (material) + IDirect3DRMMaterial_Release(material); + if (texture) + IDirect3DRMTexture_Release(texture); + } + + IDirect3DRMMesh_Release(mesh); + IDirect3DRMMeshBuilder_Release(mesh_builder); + IDirect3DRM_Release(d3drm); +} + +START_TEST(d3drm) +{ + if (!InitFunctionPtrs()) + return; + + test_MeshBuilder(); + test_MeshBuilder3(); + test_Mesh(); + test_Face(); + test_Frame(); + test_Device(); + test_Viewport(); + test_Light(); + test_Material2(); + test_Texture(); + test_frame_transform(); + test_d3drm_load(); + test_frame_mesh_materials(); + + FreeLibrary(d3drm_handle); +} Propchange: trunk/rostests/winetests/d3drm/d3drm.c ------------------------------------------------------------------------------ svn:eol-style = native Added: trunk/rostests/winetests/d3drm/testlist.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/d3drm/testlist.…
============================================================================== --- trunk/rostests/winetests/d3drm/testlist.c (added) +++ trunk/rostests/winetests/d3drm/testlist.c [iso-8859-1] Mon Sep 29 17:34:31 2014 @@ -0,0 +1,14 @@ +/* Automatically generated by make depend; DO NOT EDIT!! */ + +#define STANDALONE +#include <wine/test.h> + +extern void func_d3drm(void); +extern void func_vector(void); + +const struct test winetest_testlist[] = +{ + { "d3drm", func_d3drm }, + { "vector", func_vector }, + { 0, 0 } +}; Propchange: trunk/rostests/winetests/d3drm/testlist.c ------------------------------------------------------------------------------ svn:eol-style = native Added: trunk/rostests/winetests/d3drm/vector.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/d3drm/vector.c?…
============================================================================== --- trunk/rostests/winetests/d3drm/vector.c (added) +++ trunk/rostests/winetests/d3drm/vector.c [iso-8859-1] Mon Sep 29 17:34:31 2014 @@ -0,0 +1,367 @@ +/* + * Copyright 2007 Vijay Kiran Kamuju + * Copyright 2007 David Adam + * + * 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 <math.h> + +#include "d3drmdef.h" + +#include "wine/test.h" + +#define PI (4.0f*atanf(1.0f)) +#define admit_error 0.000001f + +#define expect_mat( expectedmat, gotmat)\ +{ \ + int i,j; \ + BOOL equal = TRUE; \ + for (i=0; i<4; i++)\ + {\ + for (j=0; j<4; j++)\ + {\ + if (fabs(expectedmat[i][j]-gotmat[i][j])>admit_error)\ + {\ + equal = FALSE;\ + }\ + }\ + }\ + ok(equal, "Expected matrix=\n(%f,%f,%f,%f\n %f,%f,%f,%f\n %f,%f,%f,%f\n %f,%f,%f,%f\n)\n\n" \ + "Got matrix=\n(%f,%f,%f,%f\n %f,%f,%f,%f\n %f,%f,%f,%f\n %f,%f,%f,%f)\n", \ + expectedmat[0][0],expectedmat[0][1],expectedmat[0][2],expectedmat[0][3], \ + expectedmat[1][0],expectedmat[1][1],expectedmat[1][2],expectedmat[1][3], \ + expectedmat[2][0],expectedmat[2][1],expectedmat[2][2],expectedmat[2][3], \ + expectedmat[3][0],expectedmat[3][1],expectedmat[3][2],expectedmat[3][3], \ + gotmat[0][0],gotmat[0][1],gotmat[0][2],gotmat[0][3], \ + gotmat[1][0],gotmat[1][1],gotmat[1][2],gotmat[1][3], \ + gotmat[2][0],gotmat[2][1],gotmat[2][2],gotmat[2][3], \ + gotmat[3][0],gotmat[3][1],gotmat[3][2],gotmat[3][3] ); \ +} + +#define expect_quat(expectedquat,gotquat) \ + ok( (fabs(U1(expectedquat.v).x-U1(gotquat.v).x)<admit_error) && \ + (fabs(U2(expectedquat.v).y-U2(gotquat.v).y)<admit_error) && \ + (fabs(U3(expectedquat.v).z-U3(gotquat.v).z)<admit_error) && \ + (fabs(expectedquat.s-gotquat.s)<admit_error), \ + "Expected Quaternion %f %f %f %f , Got Quaternion %f %f %f %f\n", \ + expectedquat.s,U1(expectedquat.v).x,U2(expectedquat.v).y,U3(expectedquat.v).z, \ + gotquat.s,U1(gotquat.v).x,U2(gotquat.v).y,U3(gotquat.v).z); + +#define expect_vec(expectedvec,gotvec) \ + ok( ((fabs(U1(expectedvec).x-U1(gotvec).x)<admit_error)&&(fabs(U2(expectedvec).y-U2(gotvec).y)<admit_error)&&(fabs(U3(expectedvec).z-U3(gotvec).z)<admit_error)), \ + "Expected Vector= (%f, %f, %f)\n , Got Vector= (%f, %f, %f)\n", \ + U1(expectedvec).x,U2(expectedvec).y,U3(expectedvec).z, U1(gotvec).x, U2(gotvec).y, U3(gotvec).z); + +static HMODULE d3drm_handle = 0; + +static void (WINAPI * pD3DRMMatrixFromQuaternion)(D3DRMMATRIX4D, D3DRMQUATERNION *); +static D3DVECTOR *(WINAPI *pD3DRMVectorAdd)(D3DVECTOR *, D3DVECTOR *, D3DVECTOR *); +static D3DVECTOR *(WINAPI *pD3DRMVectorCrossProduct)(D3DVECTOR *, D3DVECTOR *, D3DVECTOR *); +static D3DVALUE (WINAPI *pD3DRMVectorDotProduct)(D3DVECTOR *, D3DVECTOR *); +static D3DVALUE (WINAPI *pD3DRMVectorModulus)(D3DVECTOR *); +static D3DVECTOR *(WINAPI *pD3DRMVectorNormalize)(D3DVECTOR *); +static D3DVECTOR *(WINAPI *pD3DRMVectorReflect)(D3DVECTOR *, D3DVECTOR *, D3DVECTOR *); +static D3DVECTOR *(WINAPI *pD3DRMVectorRotate)(D3DVECTOR *, D3DVECTOR *, D3DVECTOR *, D3DVALUE); +static D3DVECTOR *(WINAPI *pD3DRMVectorScale)(D3DVECTOR *, D3DVECTOR *, D3DVALUE); +static D3DVECTOR *(WINAPI *pD3DRMVectorSubtract)(D3DVECTOR *, D3DVECTOR *, D3DVECTOR *); +static D3DRMQUATERNION *(WINAPI *pD3DRMQuaternionFromRotation)(D3DRMQUATERNION*, D3DVECTOR *, D3DVALUE); +static D3DRMQUATERNION *(WINAPI * pD3DRMQuaternionSlerp)(D3DRMQUATERNION *, + D3DRMQUATERNION *, D3DRMQUATERNION *, D3DVALUE); +static D3DCOLOR (WINAPI * pD3DRMCreateColorRGB)(D3DVALUE, D3DVALUE, D3DVALUE); +static D3DCOLOR (WINAPI * pD3DRMCreateColorRGBA)(D3DVALUE, D3DVALUE, D3DVALUE, D3DVALUE); +static D3DVALUE (WINAPI * pD3DRMColorGetAlpha)(D3DCOLOR); +static D3DVALUE (WINAPI * pD3DRMColorGetBlue)(D3DCOLOR); +static D3DVALUE (WINAPI * pD3DRMColorGetGreen)(D3DCOLOR); +static D3DVALUE (WINAPI * pD3DRMColorGetRed)(D3DCOLOR); + +#define D3DRM_GET_PROC(func) \ + p ## func = (void*)GetProcAddress(d3drm_handle, #func); \ + if(!p ## func) { \ + trace("GetProcAddress(%s) failed\n", #func); \ + FreeLibrary(d3drm_handle); \ + return FALSE; \ + } + +static BOOL InitFunctionPtrs(void) +{ + d3drm_handle = LoadLibraryA("d3drm.dll"); + + if(!d3drm_handle) + { + skip("Could not load d3drm.dll\n"); + return FALSE; + } + + D3DRM_GET_PROC(D3DRMMatrixFromQuaternion) + D3DRM_GET_PROC(D3DRMVectorAdd) + D3DRM_GET_PROC(D3DRMVectorCrossProduct) + D3DRM_GET_PROC(D3DRMVectorDotProduct) + D3DRM_GET_PROC(D3DRMVectorModulus) + D3DRM_GET_PROC(D3DRMVectorNormalize) + D3DRM_GET_PROC(D3DRMVectorReflect) + D3DRM_GET_PROC(D3DRMVectorRotate) + D3DRM_GET_PROC(D3DRMVectorScale) + D3DRM_GET_PROC(D3DRMVectorSubtract) + D3DRM_GET_PROC(D3DRMQuaternionFromRotation) + D3DRM_GET_PROC(D3DRMQuaternionSlerp) + D3DRM_GET_PROC(D3DRMCreateColorRGB) + D3DRM_GET_PROC(D3DRMCreateColorRGBA) + D3DRM_GET_PROC(D3DRMColorGetAlpha) + D3DRM_GET_PROC(D3DRMColorGetBlue) + D3DRM_GET_PROC(D3DRMColorGetGreen) + D3DRM_GET_PROC(D3DRMColorGetRed) + + return TRUE; +} + + +static void VectorTest(void) +{ + D3DVALUE mod,par,theta; + D3DVECTOR e,r,u,v,w,axis,casnul,norm,ray,self; + + U1(u).x=2.0f; U2(u).y=2.0f; U3(u).z=1.0f; + U1(v).x=4.0f; U2(v).y=4.0f; U3(v).z=0.0f; + + +/*______________________VectorAdd_________________________________*/ + pD3DRMVectorAdd(&r,&u,&v); + U1(e).x=6.0f; U2(e).y=6.0f; U3(e).z=1.0f; + expect_vec(e,r); + + U1(self).x=9.0f; U2(self).y=18.0f; U3(self).z=27.0f; + pD3DRMVectorAdd(&self,&self,&u); + U1(e).x=11.0f; U2(e).y=20.0f; U3(e).z=28.0f; + expect_vec(e,self); + +/*_______________________VectorSubtract__________________________*/ + pD3DRMVectorSubtract(&r,&u,&v); + U1(e).x=-2.0f; U2(e).y=-2.0f; U3(e).z=1.0f; + expect_vec(e,r); + + U1(self).x=9.0f; U2(self).y=18.0f; U3(self).z=27.0f; + pD3DRMVectorSubtract(&self,&self,&u); + U1(e).x=7.0f; U2(e).y=16.0f; U3(e).z=26.0f; + expect_vec(e,self); + +/*_______________________VectorCrossProduct_______________________*/ + pD3DRMVectorCrossProduct(&r,&u,&v); + U1(e).x=-4.0f; U2(e).y=4.0f; U3(e).z=0.0f; + expect_vec(e,r); + + U1(self).x=9.0f; U2(self).y=18.0f; U3(self).z=27.0f; + pD3DRMVectorCrossProduct(&self,&self,&u); + U1(e).x=-36.0f; U2(e).y=45.0f; U3(e).z=-18.0f; + expect_vec(e,self); + +/*_______________________VectorDotProduct__________________________*/ + mod=pD3DRMVectorDotProduct(&u,&v); + ok((mod == 16.0f), "Expected 16.0f, Got %f\n", mod); + +/*_______________________VectorModulus_____________________________*/ + mod=pD3DRMVectorModulus(&u); + ok((mod == 3.0f), "Expected 3.0f, Got %f\n", mod); + +/*_______________________VectorNormalize___________________________*/ + pD3DRMVectorNormalize(&u); + U1(e).x=2.0f/3.0f; U2(e).y=2.0f/3.0f; U3(e).z=1.0f/3.0f; + expect_vec(e,u); + +/* If u is the NULL vector, MSDN says that the return vector is NULL. In fact, the returned vector is (1,0,0). The following test case prove it. */ + + U1(casnul).x=0.0f; U2(casnul).y=0.0f; U3(casnul).z=0.0f; + pD3DRMVectorNormalize(&casnul); + U1(e).x=1.0f; U2(e).y=0.0f; U3(e).z=0.0f; + expect_vec(e,casnul); + +/*____________________VectorReflect_________________________________*/ + U1(ray).x=3.0f; U2(ray).y=-4.0f; U3(ray).z=5.0f; + U1(norm).x=1.0f; U2(norm).y=-2.0f; U3(norm).z=6.0f; + U1(e).x=79.0f; U2(e).y=-160.0f; U3(e).z=487.0f; + pD3DRMVectorReflect(&r,&ray,&norm); + expect_vec(e,r); + +/*_______________________VectorRotate_______________________________*/ + U1(w).x=3.0f; U2(w).y=4.0f; U3(w).z=0.0f; + U1(axis).x=0.0f; U2(axis).y=0.0f; U3(axis).z=1.0f; + theta=2.0f*PI/3.0f; + pD3DRMVectorRotate(&r,&w,&axis,theta); + U1(e).x=-0.3f-0.4f*sqrtf(3.0f); U2(e).y=0.3f*sqrtf(3.0f)-0.4f; U3(e).z=0.0f; + expect_vec(e,r); + +/* The same formula gives D3DRMVectorRotate, for theta in [-PI/2;+PI/2] or not. The following test proves this fact.*/ + theta=-PI/4.0f; + pD3DRMVectorRotate(&r,&w,&axis,theta); + U1(e).x=1.4f/sqrtf(2.0f); U2(e).y=0.2f/sqrtf(2.0f); U3(e).z=0.0f; + expect_vec(e,r); + + theta=PI/8.0f; + pD3DRMVectorRotate(&self,&self,&axis,theta); + U1(e).x=0.989950; U2(e).y=0.141421f; U3(e).z=0.0f; + expect_vec(e,r); + +/*_______________________VectorScale__________________________*/ + par=2.5f; + pD3DRMVectorScale(&r,&v,par); + U1(e).x=10.0f; U2(e).y=10.0f; U3(e).z=0.0f; + expect_vec(e,r); + + U1(self).x=9.0f; U2(self).y=18.0f; U3(self).z=27.0f; + pD3DRMVectorScale(&self,&self,2); + U1(e).x=18.0f; U2(e).y=36.0f; U3(e).z=54.0f; + expect_vec(e,self); +} + +static void MatrixTest(void) +{ + D3DRMQUATERNION q; + D3DRMMATRIX4D exp,mat; + + exp[0][0]=-49.0f; exp[0][1]=4.0f; exp[0][2]=22.0f; exp[0][3]=0.0f; + exp[1][0]=20.0f; exp[1][1]=-39.0f; exp[1][2]=20.0f; exp[1][3]=0.0f; + exp[2][0]=10.0f; exp[2][1]=28.0f; exp[2][2]=-25.0f; exp[2][3]=0.0f; + exp[3][0]=0.0f; exp[3][1]=0.0f; exp[3][2]=0.0f; exp[3][3]=1.0f; + q.s=1.0f; U1(q.v).x=2.0f; U2(q.v).y=3.0f; U3(q.v).z=4.0f; + + pD3DRMMatrixFromQuaternion(mat,&q); + expect_mat(exp,mat); +} + +static void QuaternionTest(void) +{ + D3DVECTOR axis; + D3DVALUE par,theta; + D3DRMQUATERNION q,q1,q1final,q2,q2final,r; + +/*_________________QuaternionFromRotation___________________*/ + U1(axis).x=1.0f; U2(axis).y=1.0f; U3(axis).z=1.0f; + theta=2.0f*PI/3.0f; + pD3DRMQuaternionFromRotation(&r,&axis,theta); + q.s=0.5f; U1(q.v).x=0.5f; U2(q.v).y=0.5f; U3(q.v).z=0.5f; + expect_quat(q,r); + +/*_________________QuaternionSlerp_________________________*/ +/* If the angle of the two quaternions is in ]PI/2;3PI/2[, QuaternionSlerp + * interpolates between the first quaternion and the opposite of the second one. + * The test proves this fact. */ + par=0.31f; + q1.s=1.0f; U1(q1.v).x=2.0f; U2(q1.v).y=3.0f; U3(q1.v).z=50.0f; + q2.s=-4.0f; U1(q2.v).x=6.0f; U2(q2.v).y=7.0f; U3(q2.v).z=8.0f; +/* The angle between q1 and q2 is in [-PI/2,PI/2]. So, one interpolates between q1 and q2. */ + q.s = -0.55f; U1(q.v).x=3.24f; U2(q.v).y=4.24f; U3(q.v).z=36.98f; + pD3DRMQuaternionSlerp(&r,&q1,&q2,par); + expect_quat(q,r); + + q1.s=1.0f; U1(q1.v).x=2.0f; U2(q1.v).y=3.0f; U3(q1.v).z=50.0f; + q2.s=-94.0f; U1(q2.v).x=6.0f; U2(q2.v).y=7.0f; U3(q2.v).z=-8.0f; +/* The angle between q1 and q2 is not in [-PI/2,PI/2]. So, one interpolates between q1 and -q2. */ + q.s=29.83f; U1(q.v).x=-0.48f; U2(q.v).y=-0.10f; U3(q.v).z=36.98f; + pD3DRMQuaternionSlerp(&r,&q1,&q2,par); + expect_quat(q,r); + +/* Test the spherical interpolation part */ + q1.s=0.1f; U1(q1.v).x=0.2f; U2(q1.v).y=0.3f; U3(q1.v).z=0.4f; + q2.s=0.5f; U1(q2.v).x=0.6f; U2(q2.v).y=0.7f; U3(q2.v).z=0.8f; + q.s = 0.243943f; U1(q.v).x = 0.351172f; U2(q.v).y = 0.458401f; U3(q.v).z = 0.565629f; + + q1final=q1; + q2final=q2; + pD3DRMQuaternionSlerp(&r,&q1,&q2,par); + expect_quat(q,r); + +/* Test to show that the input quaternions are not changed */ + expect_quat(q1,q1final); + expect_quat(q2,q2final); +} + +static void ColorTest(void) +{ + D3DCOLOR color, expected_color, got_color; + D3DVALUE expected, got, red, green, blue, alpha; + +/*___________D3DRMCreateColorRGB_________________________*/ + red=0.8f; + green=0.3f; + blue=0.55f; + expected_color=0xffcc4c8c; + got_color=pD3DRMCreateColorRGB(red,green,blue); + ok((expected_color==got_color),"Expected color=%x, Got color=%x\n",expected_color,got_color); + +/*___________D3DRMCreateColorRGBA________________________*/ + red=0.1f; + green=0.4f; + blue=0.7f; + alpha=0.58f; + expected_color=0x931966b2; + got_color=pD3DRMCreateColorRGBA(red,green,blue,alpha); + ok((expected_color==got_color),"Expected color=%x, Got color=%x\n",expected_color,got_color); + +/* if a component is <0 then, then one considers this component as 0. The following test proves this fact (test only with the red component). */ + red=-0.88f; + green=0.4f; + blue=0.6f; + alpha=0.41f; + expected_color=0x68006699; + got_color=pD3DRMCreateColorRGBA(red,green,blue,alpha); + ok((expected_color==got_color),"Expected color=%x, Got color=%x\n",expected_color,got_color); + +/* if a component is >1 then, then one considers this component as 1. The following test proves this fact (test only with the red component). */ + red=2.37f; + green=0.4f; + blue=0.6f; + alpha=0.41f; + expected_color=0x68ff6699; + got_color=pD3DRMCreateColorRGBA(red,green,blue,alpha); + ok((expected_color==got_color),"Expected color=%x, Got color=%x\n",expected_color,got_color); + +/*___________D3DRMColorGetAlpha_________________________*/ + color=0x0e4921bf; + expected=14.0f/255.0f; + got=pD3DRMColorGetAlpha(color); + ok((fabs(expected-got)<admit_error),"Expected=%f, Got=%f\n",expected,got); + +/*___________D3DRMColorGetBlue__________________________*/ + color=0xc82a1455; + expected=1.0f/3.0f; + got=pD3DRMColorGetBlue(color); + ok((fabs(expected-got)<admit_error),"Expected=%f, Got=%f\n",expected,got); + +/*___________D3DRMColorGetGreen_________________________*/ + color=0xad971203; + expected=6.0f/85.0f; + got=pD3DRMColorGetGreen(color); + ok((fabs(expected-got)<admit_error),"Expected=%f, Got=%f\n",expected,got); + +/*___________D3DRMColorGetRed__________________________*/ + color=0xb62d7a1c; + expected=3.0f/17.0f; + got=pD3DRMColorGetRed(color); + ok((fabs(expected-got)<admit_error),"Expected=%f, Got=%f\n",expected,got); +} + +START_TEST(vector) +{ + if(!InitFunctionPtrs()) + return; + + VectorTest(); + MatrixTest(); + QuaternionTest(); + ColorTest(); + + FreeLibrary(d3drm_handle); +} Propchange: trunk/rostests/winetests/d3drm/vector.c ------------------------------------------------------------------------------ svn:eol-style = native
10 years, 2 months
1
0
0
0
[akhaldi] 64398: [D3DRM] * Import from Wine 1.7.27. CORE-8082 #resolve #comment Imported in r64396. Thanks! CORE-8540
by akhaldi@svn.reactos.org
Author: akhaldi Date: Mon Sep 29 17:24:32 2014 New Revision: 64398 URL:
http://svn.reactos.org/svn/reactos?rev=64398&view=rev
Log: [D3DRM] * Import from Wine 1.7.27. CORE-8082 #resolve #comment Imported in r64396. Thanks! CORE-8540 Added: trunk/reactos/dll/directx/wine/d3drm/ (with props) trunk/reactos/dll/directx/wine/d3drm/CMakeLists.txt (with props) trunk/reactos/dll/directx/wine/d3drm/d3drm.c (with props) trunk/reactos/dll/directx/wine/d3drm/d3drm.spec (with props) trunk/reactos/dll/directx/wine/d3drm/d3drm_main.c (with props) trunk/reactos/dll/directx/wine/d3drm/d3drm_private.h (with props) trunk/reactos/dll/directx/wine/d3drm/device.c (with props) trunk/reactos/dll/directx/wine/d3drm/face.c (with props) trunk/reactos/dll/directx/wine/d3drm/frame.c (with props) trunk/reactos/dll/directx/wine/d3drm/light.c (with props) trunk/reactos/dll/directx/wine/d3drm/material.c (with props) trunk/reactos/dll/directx/wine/d3drm/math.c (with props) trunk/reactos/dll/directx/wine/d3drm/meshbuilder.c (with props) trunk/reactos/dll/directx/wine/d3drm/texture.c (with props) trunk/reactos/dll/directx/wine/d3drm/version.rc (with props) trunk/reactos/dll/directx/wine/d3drm/viewport.c (with props) Modified: trunk/reactos/dll/directx/wine/CMakeLists.txt trunk/reactos/media/doc/README.WINE [This mail would be too long, it was shortened to contain the URLs only.] Modified: trunk/reactos/dll/directx/wine/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/wine/CMakeList…
Added: trunk/reactos/dll/directx/wine/d3drm/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/wine/d3drm/CMa…
Added: trunk/reactos/dll/directx/wine/d3drm/d3drm.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/wine/d3drm/d3d…
Added: trunk/reactos/dll/directx/wine/d3drm/d3drm.spec URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/wine/d3drm/d3d…
Added: trunk/reactos/dll/directx/wine/d3drm/d3drm_main.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/wine/d3drm/d3d…
Added: trunk/reactos/dll/directx/wine/d3drm/d3drm_private.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/wine/d3drm/d3d…
Added: trunk/reactos/dll/directx/wine/d3drm/device.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/wine/d3drm/dev…
Added: trunk/reactos/dll/directx/wine/d3drm/face.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/wine/d3drm/fac…
Added: trunk/reactos/dll/directx/wine/d3drm/frame.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/wine/d3drm/fra…
Added: trunk/reactos/dll/directx/wine/d3drm/light.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/wine/d3drm/lig…
Added: trunk/reactos/dll/directx/wine/d3drm/material.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/wine/d3drm/mat…
Added: trunk/reactos/dll/directx/wine/d3drm/math.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/wine/d3drm/mat…
Added: trunk/reactos/dll/directx/wine/d3drm/meshbuilder.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/wine/d3drm/mes…
Added: trunk/reactos/dll/directx/wine/d3drm/texture.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/wine/d3drm/tex…
Added: trunk/reactos/dll/directx/wine/d3drm/version.rc URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/wine/d3drm/ver…
Added: trunk/reactos/dll/directx/wine/d3drm/viewport.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/wine/d3drm/vie…
Modified: trunk/reactos/media/doc/README.WINE URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/media/doc/README.WINE?rev=…
10 years, 2 months
1
0
0
0
[akhaldi] 64397: [PSDK] * Update d3drm.h and d3drmdef.h. * Import d3drmobj.h and d3drmwin.h. * Guard against redefinition of MAKE_DDHRESULT. [DXSDK] * Get rid of this d3drmwin.h. * Guard against re...
by akhaldi@svn.reactos.org
Author: akhaldi Date: Mon Sep 29 17:03:05 2014 New Revision: 64397 URL:
http://svn.reactos.org/svn/reactos?rev=64397&view=rev
Log: [PSDK] * Update d3drm.h and d3drmdef.h. * Import d3drmobj.h and d3drmwin.h. * Guard against redefinition of MAKE_DDHRESULT. [DXSDK] * Get rid of this d3drmwin.h. * Guard against redefinition of MAKE_DDHRESULT. CORE-8540 CORE-8082 Added: trunk/reactos/include/psdk/d3drmobj.h (with props) trunk/reactos/include/psdk/d3drmwin.h (with props) Removed: trunk/reactos/include/dxsdk/d3drmwin.h Modified: trunk/reactos/include/dxsdk/dxfile.h trunk/reactos/include/psdk/d3drm.h trunk/reactos/include/psdk/d3drmdef.h trunk/reactos/include/psdk/ddraw.h [This mail would be too long, it was shortened to contain the URLs only.] Removed: trunk/reactos/include/dxsdk/d3drmwin.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/dxsdk/d3drmwin.h?r…
Modified: trunk/reactos/include/dxsdk/dxfile.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/dxsdk/dxfile.h?rev…
Modified: trunk/reactos/include/psdk/d3drm.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/psdk/d3drm.h?rev=6…
Modified: trunk/reactos/include/psdk/d3drmdef.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/psdk/d3drmdef.h?re…
Added: trunk/reactos/include/psdk/d3drmobj.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/psdk/d3drmobj.h?re…
Added: trunk/reactos/include/psdk/d3drmwin.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/psdk/d3drmwin.h?re…
Modified: trunk/reactos/include/psdk/ddraw.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/psdk/ddraw.h?rev=6…
10 years, 2 months
1
0
0
0
[jgardou] 64396: [NTOS/CM] - Add NtQueryKey(KeyNameInformation) implementation. CORE-8581 #resolve
by jgardou@svn.reactos.org
Author: jgardou Date: Mon Sep 29 16:27:16 2014 New Revision: 64396 URL:
http://svn.reactos.org/svn/reactos?rev=64396&view=rev
Log: [NTOS/CM] - Add NtQueryKey(KeyNameInformation) implementation. CORE-8581 #resolve Modified: trunk/reactos/ntoskrnl/config/cmapi.c Modified: trunk/reactos/ntoskrnl/config/cmapi.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/config/cmapi.c?re…
============================================================================== --- trunk/reactos/ntoskrnl/config/cmapi.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/config/cmapi.c [iso-8859-1] Mon Sep 29 16:27:16 2014 @@ -1514,13 +1514,103 @@ return STATUS_SUCCESS; } +static +NTSTATUS +CmpQueryNameInformation( + _In_ PCM_KEY_CONTROL_BLOCK Kcb, + _Out_opt_ PKEY_NAME_INFORMATION KeyNameInfo, + _In_ ULONG Length, + _Out_ PULONG ResultLength) +{ + ULONG NeededLength; + PCM_KEY_CONTROL_BLOCK CurrentKcb; + + NeededLength = 0; + CurrentKcb = Kcb; + + /* Count the needed buffer size */ + while (CurrentKcb) + { + if (CurrentKcb->NameBlock->Compressed) + NeededLength += CmpCompressedNameSize(CurrentKcb->NameBlock->Name, CurrentKcb->NameBlock->NameLength); + else + NeededLength += CurrentKcb->NameBlock->NameLength; + + NeededLength += sizeof(OBJ_NAME_PATH_SEPARATOR); + + CurrentKcb = CurrentKcb->ParentKcb; + } + + _SEH2_TRY + { + *ResultLength = NeededLength + FIELD_OFFSET(KEY_NAME_INFORMATION, Name[0]); + if (Length < *ResultLength) + return STATUS_BUFFER_TOO_SMALL; + } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + return _SEH2_GetExceptionCode(); + } + _SEH2_END; + + /* Do the real copy */ + KeyNameInfo->NameLength = 0; + CurrentKcb = Kcb; + while (CurrentKcb) + { + ULONG NameLength; + + _SEH2_TRY + { + if (CurrentKcb->NameBlock->Compressed) + { + NameLength = CmpCompressedNameSize(CurrentKcb->NameBlock->Name, CurrentKcb->NameBlock->NameLength); + /* Copy the compressed name */ + CmpCopyCompressedName(&KeyNameInfo->Name[(NeededLength - NameLength)/sizeof(WCHAR)], + NameLength, + CurrentKcb->NameBlock->Name, + CurrentKcb->NameBlock->NameLength); + } + else + { + NameLength = CurrentKcb->NameBlock->NameLength; + /* Otherwise, copy the raw name */ + RtlCopyMemory(&KeyNameInfo->Name[(NeededLength - NameLength)/sizeof(WCHAR)], + CurrentKcb->NameBlock->Name, + NameLength); + } + + NeededLength -= NameLength; + NeededLength -= sizeof(OBJ_NAME_PATH_SEPARATOR); + /* Add path separator */ + KeyNameInfo->Name[NeededLength/sizeof(WCHAR)] = OBJ_NAME_PATH_SEPARATOR; + KeyNameInfo->NameLength += NameLength + sizeof(OBJ_NAME_PATH_SEPARATOR); + } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + return _SEH2_GetExceptionCode(); + } + _SEH2_END; + + CurrentKcb = CurrentKcb->ParentKcb; + } + + /* Make sure we copied everything */ + ASSERT(NeededLength == 0); + ASSERT(KeyNameInfo->Name[0] == OBJ_NAME_PATH_SEPARATOR); + + /* We're done */ + return STATUS_SUCCESS; +} + + NTSTATUS NTAPI -CmQueryKey(IN PCM_KEY_CONTROL_BLOCK Kcb, - IN KEY_INFORMATION_CLASS KeyInformationClass, - IN PVOID KeyInformation, - IN ULONG Length, - IN PULONG ResultLength) +CmQueryKey(_In_ PCM_KEY_CONTROL_BLOCK Kcb, + _In_ KEY_INFORMATION_CLASS KeyInformationClass, + _Out_opt_ PVOID KeyInformation, + _In_ ULONG Length, + _Out_ PULONG ResultLength) { NTSTATUS Status; PHHIVE Hive; @@ -1588,12 +1678,12 @@ ResultLength); break; - /* Unsupported class for now */ case KeyNameInformation: - - /* Print message and fail */ - DPRINT1("Unsupported class: %d!\n", KeyInformationClass); - Status = STATUS_NOT_IMPLEMENTED; + /* Call the internal API */ + Status = CmpQueryNameInformation(Kcb, + KeyInformation, + Length, + ResultLength); break; /* Illegal classes */
10 years, 2 months
1
0
0
0
[dquintana] 64395: [RSHELL] * Implement skeleton shell dde parser. [SHELL32] * Copy over the skeleton from rshell, and fill in the handlers for ViewFolder and ExploreFolder, with rudimentary implem...
by dquintana@svn.reactos.org
Author: dquintana Date: Mon Sep 29 16:22:21 2014 New Revision: 64395 URL:
http://svn.reactos.org/svn/reactos?rev=64395&view=rev
Log: [RSHELL] * Implement skeleton shell dde parser. [SHELL32] * Copy over the skeleton from rshell, and fill in the handlers for ViewFolder and ExploreFolder, with rudimentary implementations. CORE-7552 Modified: branches/shell-experiments/base/shell/rshell/ShellDDE.cpp branches/shell-experiments/dll/win32/shell32/dde.cpp Modified: branches/shell-experiments/base/shell/rshell/ShellDDE.cpp URL:
http://svn.reactos.org/svn/reactos/branches/shell-experiments/base/shell/rs…
============================================================================== --- branches/shell-experiments/base/shell/rshell/ShellDDE.cpp [iso-8859-1] (original) +++ branches/shell-experiments/base/shell/rshell/ShellDDE.cpp [iso-8859-1] Mon Sep 29 16:22:21 2014 @@ -21,8 +21,20 @@ #include "precomp.h" #include <ddeml.h> #include <strsafe.h> +#include <shlwapi_undoc.h> WINE_DEFAULT_DEBUG_CHANNEL(shelldde); + +typedef DWORD(CALLBACK * pfnCommandHandler)(PWSTR strCommand, PWSTR strPath, LPITEMIDLIST pidl, INT unkS); + +struct DDECommandHandler +{ + WCHAR Command[32]; + pfnCommandHandler Handler; +}; + +extern DDECommandHandler HandlerList []; +extern const int HandlerListLength; /* DDE Instance ID */ static DWORD dwDDEInst; @@ -34,6 +46,8 @@ static HSZ hszAppProperties; static HSZ hszFolders; +static BOOL bInitialized; + static BOOL Dde_OnConnect(HSZ hszTopic, HSZ hszService) { WCHAR szTopic[MAX_PATH]; @@ -54,7 +68,7 @@ DdeQueryStringW(dwDDEInst, hszTopic, szTopic, _countof(szTopic), CP_WINUNICODE); DdeQueryStringW(dwDDEInst, hszService, szService, _countof(szService), CP_WINUNICODE); - + DbgPrint("Dde_OnConnectConfirm: hconv=%p, topic=%S, service=%S\n", hconv, szTopic, szService); } @@ -82,6 +96,32 @@ DbgPrint("Dde_OnRequest: uFmt=%d, hconv=%p, topic=%S, item=%S\n", hconv, szTopic, szItem); return NULL; +} + +static LPITEMIDLIST _ILReadFromSharedMemory(PCWSTR strField) +{ + LPITEMIDLIST ret = NULL; + + // Ensure it really is an IDLIST-formatted parameter + // Format for IDLIST params: ":pid:shared" + if (*strField != L':') + return NULL; + + HANDLE hData = (HANDLE) StrToIntW(strField + 1); + PWSTR strSecond = StrChrW(strField + 1, L':'); + + if (strSecond) + { + int pid = StrToIntW(strSecond + 1); + void* pvShared = SHLockShared(hData, pid); + if (pvShared) + { + ret = ILClone((LPCITEMIDLIST) pvShared); + SHUnlockShared(pvShared); + SHFreeShared(hData, pid); + } + } + return ret; } static DWORD Dde_OnExecute(HCONV hconv, HSZ hszTopic, HDDEDATA hdata) @@ -92,7 +132,7 @@ DdeQueryStringW(dwDDEInst, hszTopic, szTopic, _countof(szTopic), CP_WINUNICODE); - pszCommand = (WCHAR*)DdeAccessData(hdata, NULL); + pszCommand = (WCHAR*) DdeAccessData(hdata, NULL); if (!pszCommand) return DDE_FNOTPROCESSED; @@ -103,15 +143,139 @@ DbgPrint("Dde_OnExecute: hconv=%p, topic=%S, command=%S\n", hconv, szTopic, pszCommand); /* - [ViewFolder("%l", %I, %S)] -- Open a folder in standard mode [ExploreFolder("%l", %I, %S)] -- Open a folder in "explore" mode (file tree is shown to the left by default) [FindFolder("%l", %I)] -- Open a folder in "find" mode (search panel is shown to the left by default) [ShellFile("%1","%1",%S)] -- Execute the contents of the specified .SCF file - + + Approximate grammar (Upper names define rules, <lower> names define terminals, single-quotes are literals): + + Rules + Command = ('[' Function ']') | Function + Function = <identifier> '(' Parameters ')' + Parameters = (<quoted-string> (',' <idlist> (',' <number>)?)?)? + + Terminals + <identifier> = [a-zA-Z]+ + <quoted-string> = \"([^\"]|\\.)\" + <idlist> = \:[0-9]+\:[0-9]+ + <number> = [0-9]+ */ - return DDE_FACK; + WCHAR Command[MAX_PATH] = L""; + WCHAR Path[MAX_PATH] = L""; + LPITEMIDLIST IdList = NULL; + INT UnknownParameter = 0; + + // Simplified parsing (assumes the command will not be TOO broken): + + PWSTR cmd = szCommand; + // 1. if starts with [, skip first char + if (*cmd == L'[') + cmd++; + + if (*cmd == L']') + { + ERR("Empty command. Nothing to run.\n"); + return DDE_FNOTPROCESSED; + } + + // Read until first (, and take text before ( as command name + { + PWSTR cmdEnd = StrChrW(cmd, L'('); + + if (!cmdEnd) + { + ERR("Could not find '('. Invalid command.\n"); + return DDE_FNOTPROCESSED; + } + + *cmdEnd = 0; + + StringCchCopy(Command, _countof(Command), cmd); + + cmd = cmdEnd + 1; + } + + // Read first param after (, expecting quoted string + if (*cmd != L')') + { + // Copy unescaped string + PWSTR dst = Path; + BOOL isQuote = FALSE; + + PWSTR arg = cmd; + + while (*arg && (isQuote || *arg != L',')) + { + if (*arg == L'"') + { + isQuote = !isQuote; + if (isQuote && arg != cmd) // do not copy the " at the beginning of the string + { + *(dst++) = L'"'; + } + } + else + { + *(dst++) = *arg; + } + + arg++; + } + + cmd = arg + 1; + + while (*cmd == L' ') + cmd++; + } + + // Read second param, expecting an idlist in shared memory + if (*cmd != L')') + { + if (*cmd != ':') + { + ERR("Expected ':'. Invalid command.\n"); + return DDE_FNOTPROCESSED; + } + + PWSTR idlistEnd = StrChrW(cmd, L','); + + if (!idlistEnd) + idlistEnd = StrChrW(cmd, L')'); + + if (!idlistEnd) + { + ERR("Expected ',' or ')'. Invalid command.\n"); + return DDE_FNOTPROCESSED; + } + + IdList = _ILReadFromSharedMemory(cmd); + + cmd = idlistEnd + 1; + } + + // Read third param, expecting an integer + if (*cmd != L')') + { + UnknownParameter = StrToIntW(cmd); + } + + DbgPrint("Parse end: cmd=%S, S=%d, pidl=%p, path=%S\n", Command, UnknownParameter, IdList, Path); + + // Find handler in list + for (int i = 0; i < HandlerListLength; i++) + { + DDECommandHandler & handler = HandlerList[i]; + if (StrCmpW(handler.Command, Command) == 0) + { + return handler.Handler(Command, Path, IdList, UnknownParameter); + } + } + + // No handler found + ERR("Unknown command %S\n", Command); + return DDE_FNOTPROCESSED; } static void Dde_OnDisconnect(HCONV hconv) @@ -132,26 +296,26 @@ switch (uType) { case XTYP_CONNECT: - return (HDDEDATA)(DWORD_PTR)Dde_OnConnect(hsz1, hsz2); + return (HDDEDATA) (DWORD_PTR) Dde_OnConnect(hsz1, hsz2); case XTYP_CONNECT_CONFIRM: Dde_OnConnectConfirm(hconv, hsz1, hsz2); return NULL; case XTYP_WILDCONNECT: - return (HDDEDATA)(DWORD_PTR)Dde_OnWildConnect(hsz1, hsz2); + return (HDDEDATA) (DWORD_PTR) Dde_OnWildConnect(hsz1, hsz2); case XTYP_REQUEST: return Dde_OnRequest(uFmt, hconv, hsz1, hsz2); case XTYP_EXECUTE: - return (HDDEDATA)(DWORD_PTR)Dde_OnExecute(hconv, hsz1, hdata); + return (HDDEDATA) (DWORD_PTR) Dde_OnExecute(hconv, hsz1, hdata); case XTYP_DISCONNECT: Dde_OnDisconnect(hconv); return NULL; + case XTYP_REGISTER: + return NULL; default: DbgPrint("DdeCallback: unknown uType=%d\n", uType); - case XTYP_REGISTER: return NULL; } } - /************************************************************************* * ShellDDEInit (SHELL32.@) * @@ -168,7 +332,7 @@ { DbgPrint("ShellDDEInit bInit = %s\n", bInit ? "TRUE" : "FALSE"); - if (bInit) + if (bInit && !bInitialized) { DdeInitializeW(&dwDDEInst, DdeCallback, CBF_FAIL_ADVISES | CBF_FAIL_POKES, 0); @@ -178,19 +342,67 @@ hszAppProperties = DdeCreateStringHandleW(dwDDEInst, L"AppProperties", CP_WINUNICODE); hszFolders = DdeCreateStringHandleW(dwDDEInst, L"Folders", CP_WINUNICODE); - DdeNameService(dwDDEInst, hszFolders, 0, DNS_FILTEROFF); - } - else + if (hszProgmanTopic && hszProgmanService && + hszShell && hszAppProperties && hszFolders && + DdeNameService(dwDDEInst, hszFolders, 0, DNS_REGISTER) && + DdeNameService(dwDDEInst, hszProgmanService, 0, DNS_REGISTER) && + DdeNameService(dwDDEInst, hszShell, 0, DNS_REGISTER)) + { + bInitialized = TRUE; + } + } + else if (!bInit && bInitialized) { /* unregister all services */ DdeNameService(dwDDEInst, 0, 0, DNS_UNREGISTER); - DdeFreeStringHandle(dwDDEInst, hszFolders); - DdeFreeStringHandle(dwDDEInst, hszAppProperties); - DdeFreeStringHandle(dwDDEInst, hszShell); - DdeFreeStringHandle(dwDDEInst, hszProgmanService); - DdeFreeStringHandle(dwDDEInst, hszProgmanTopic); + if (hszFolders) + DdeFreeStringHandle(dwDDEInst, hszFolders); + if (hszAppProperties) + DdeFreeStringHandle(dwDDEInst, hszAppProperties); + if (hszShell) + DdeFreeStringHandle(dwDDEInst, hszShell); + if (hszProgmanService) + DdeFreeStringHandle(dwDDEInst, hszProgmanService); + if (hszProgmanTopic) + DdeFreeStringHandle(dwDDEInst, hszProgmanTopic); DdeUninitialize(dwDDEInst); - } -} + + bInitialized = FALSE; + } +} + +static DWORD CALLBACK DDE_OnViewFolder(PWSTR strCommand, PWSTR strPath, LPITEMIDLIST pidl, INT unkS) +{ + UNIMPLEMENTED; + return DDE_FACK; +} + +static DWORD CALLBACK DDW_OnExploreFolder(PWSTR strCommand, PWSTR strPath, LPITEMIDLIST pidl, INT unkS) +{ + UNIMPLEMENTED; + return DDE_FACK; +} + +static DWORD CALLBACK DDE_OnFindFolder(PWSTR strCommand, PWSTR strPath, LPITEMIDLIST pidl, INT unkS) +{ + UNIMPLEMENTED; + return DDE_FNOTPROCESSED; +} + +static DWORD CALLBACK DDE_OnShellFile(PWSTR strCommand, PWSTR strPath, LPITEMIDLIST pidl, INT unkS) +{ + UNIMPLEMENTED; + return DDE_FNOTPROCESSED; +} + +DDECommandHandler HandlerList [] = { + + { L"ViewFolder", DDE_OnViewFolder }, + { L"ExploreFolder", DDW_OnExploreFolder }, + { L"FindFolder", DDE_OnFindFolder }, + { L"ShellFile", DDE_OnShellFile } +}; + +const int HandlerListLength = _countof(HandlerList); Modified: branches/shell-experiments/dll/win32/shell32/dde.cpp URL:
http://svn.reactos.org/svn/reactos/branches/shell-experiments/dll/win32/she…
============================================================================== --- branches/shell-experiments/dll/win32/shell32/dde.cpp [iso-8859-1] (original) +++ branches/shell-experiments/dll/win32/shell32/dde.cpp [iso-8859-1] Mon Sep 29 16:22:21 2014 @@ -19,69 +19,268 @@ */ #include "precomp.h" - -WINE_DEFAULT_DEBUG_CHANNEL(shell); +#include <ddeml.h> +#include <strsafe.h> +#include <shlwapi_undoc.h> + +WINE_DEFAULT_DEBUG_CHANNEL(shelldde); + +typedef DWORD(CALLBACK * pfnCommandHandler)(PWSTR strCommand, PWSTR strPath, LPITEMIDLIST pidl, INT unkS); + +struct DDECommandHandler +{ + WCHAR Command[32]; + pfnCommandHandler Handler; +}; + +extern DDECommandHandler HandlerList []; +extern const int HandlerListLength; + +/* DDE Instance ID */ +static DWORD dwDDEInst; /* String handles */ static HSZ hszProgmanTopic; static HSZ hszProgmanService; -static HSZ hszAsterisk; static HSZ hszShell; static HSZ hszAppProperties; static HSZ hszFolders; -/* DDE Instance ID */ -static DWORD dwDDEInst; - - -static BOOL __inline Dde_OnConnect(HSZ hszTopic, HSZ hszService) -{ - if ((hszTopic == hszProgmanTopic) && (hszService == hszProgmanService)) - return TRUE; - if ((hszTopic == hszProgmanTopic) && (hszService == hszAppProperties)) - return TRUE; - if ((hszTopic == hszShell) && (hszService == hszFolders)) - return TRUE; - if ((hszTopic == hszShell) && (hszService == hszAppProperties)) - return TRUE; + +static BOOL bInitialized; + +static BOOL Dde_OnConnect(HSZ hszTopic, HSZ hszService) +{ + WCHAR szTopic[MAX_PATH]; + WCHAR szService[MAX_PATH]; + + DdeQueryStringW(dwDDEInst, hszTopic, szTopic, _countof(szTopic), CP_WINUNICODE); + DdeQueryStringW(dwDDEInst, hszService, szService, _countof(szService), CP_WINUNICODE); + + DbgPrint("Dde_OnConnect: topic=%S, service=%S\n", szTopic, szService); + + return TRUE; +} + +static void Dde_OnConnectConfirm(HCONV hconv, HSZ hszTopic, HSZ hszService) +{ + WCHAR szTopic[MAX_PATH]; + WCHAR szService[MAX_PATH]; + + DdeQueryStringW(dwDDEInst, hszTopic, szTopic, _countof(szTopic), CP_WINUNICODE); + DdeQueryStringW(dwDDEInst, hszService, szService, _countof(szService), CP_WINUNICODE); + + DbgPrint("Dde_OnConnectConfirm: hconv=%p, topic=%S, service=%S\n", hconv, szTopic, szService); +} + +static BOOL Dde_OnWildConnect(HSZ hszTopic, HSZ hszService) +{ + WCHAR szTopic[MAX_PATH]; + WCHAR szService[MAX_PATH]; + + DdeQueryStringW(dwDDEInst, hszTopic, szTopic, _countof(szTopic), CP_WINUNICODE); + DdeQueryStringW(dwDDEInst, hszService, szService, _countof(szService), CP_WINUNICODE); + + DbgPrint("Dde_OnWildConnect: topic=%S, service=%S\n", szTopic, szService); + return FALSE; } -static void __inline Dde_OnConnectConfirm(HCONV hconv, HSZ hszTopic, HSZ hszService) -{ - FIXME("stub\n"); -} - -static BOOL __inline Dde_OnWildConnect(HSZ hszTopic, HSZ hszService) -{ - FIXME("stub\n"); - return FALSE; -} - -static HDDEDATA __inline Dde_OnRequest(UINT uFmt, HCONV hconv, HSZ hszTopic, - HSZ hszItem) -{ - FIXME("stub\n"); +static HDDEDATA Dde_OnRequest(UINT uFmt, HCONV hconv, HSZ hszTopic, HSZ hszItem) +{ + WCHAR szTopic[MAX_PATH]; + WCHAR szItem[MAX_PATH]; + + DdeQueryStringW(dwDDEInst, hszTopic, szTopic, _countof(szTopic), CP_WINUNICODE); + DdeQueryStringW(dwDDEInst, hszItem, szItem, _countof(szItem), CP_WINUNICODE); + + DbgPrint("Dde_OnRequest: uFmt=%d, hconv=%p, topic=%S, item=%S\n", hconv, szTopic, szItem); + return NULL; } -static DWORD __inline Dde_OnExecute(HCONV hconv, HSZ hszTopic, HDDEDATA hdata) -{ - BYTE * pszCommand; - - pszCommand = DdeAccessData(hdata, NULL); +static LPITEMIDLIST _ILReadFromSharedMemory(PCWSTR strField) +{ + LPITEMIDLIST ret = NULL; + + // Ensure it really is an IDLIST-formatted parameter + // Format for IDLIST params: ":pid:shared" + if (*strField != L':') + return NULL; + + HANDLE hData = (HANDLE) StrToIntW(strField + 1); + PWSTR strSecond = StrChrW(strField + 1, L':'); + + if (strSecond) + { + int pid = StrToIntW(strSecond + 1); + void* pvShared = SHLockShared(hData, pid); + if (pvShared) + { + ret = ILClone((LPCITEMIDLIST) pvShared); + SHUnlockShared(pvShared); + SHFreeShared(hData, pid); + } + } + return ret; +} + +static DWORD Dde_OnExecute(HCONV hconv, HSZ hszTopic, HDDEDATA hdata) +{ + WCHAR szTopic[MAX_PATH]; + WCHAR szCommand[MAX_PATH]; + WCHAR *pszCommand; + + DdeQueryStringW(dwDDEInst, hszTopic, szTopic, _countof(szTopic), CP_WINUNICODE); + + pszCommand = (WCHAR*) DdeAccessData(hdata, NULL); if (!pszCommand) return DDE_FNOTPROCESSED; - FIXME("stub: %s\n", pszCommand); + StringCchCopyW(szCommand, _countof(szCommand), pszCommand); DdeUnaccessData(hdata); + DbgPrint("Dde_OnExecute: hconv=%p, topic=%S, command=%S\n", hconv, szTopic, pszCommand); + + /* + [ViewFolder("%l", %I, %S)] -- Open a folder in standard mode + [ExploreFolder("%l", %I, %S)] -- Open a folder in "explore" mode (file tree is shown to the left by default) + [FindFolder("%l", %I)] -- Open a folder in "find" mode (search panel is shown to the left by default) + [ShellFile("%1","%1",%S)] -- Execute the contents of the specified .SCF file + + Approximate grammar (Upper names define rules, <lower> names define terminals, single-quotes are literals): + + Rules + Command = ('[' Function ']') | Function + Function = <identifier> '(' Parameters ')' + Parameters = (<quoted-string> (',' <idlist> (',' <number>)?)?)? + + Terminals + <identifier> = [a-zA-Z]+ + <quoted-string> = \"([^\"]|\\.)\" + <idlist> = \:[0-9]+\:[0-9]+ + <number> = [0-9]+ + */ + + WCHAR Command[MAX_PATH] = L""; + WCHAR Path[MAX_PATH] = L""; + LPITEMIDLIST IdList = NULL; + INT UnknownParameter = 0; + + // Simplified parsing (assumes the command will not be TOO broken): + + PWSTR cmd = szCommand; + // 1. if starts with [, skip first char + if (*cmd == L'[') + cmd++; + + if (*cmd == L']') + { + ERR("Empty command. Nothing to run.\n"); + return DDE_FNOTPROCESSED; + } + + // Read until first (, and take text before ( as command name + { + PWSTR cmdEnd = StrChrW(cmd, L'('); + + if (!cmdEnd) + { + ERR("Could not find '('. Invalid command.\n"); + return DDE_FNOTPROCESSED; + } + + *cmdEnd = 0; + + StringCchCopy(Command, _countof(Command), cmd); + + cmd = cmdEnd + 1; + } + + // Read first param after (, expecting quoted string + if (*cmd != L')') + { + // Copy unescaped string + PWSTR dst = Path; + BOOL isQuote = FALSE; + + PWSTR arg = cmd; + + while (*arg && (isQuote || *arg != L',')) + { + if (*arg == L'"') + { + isQuote = !isQuote; + if (isQuote && arg != cmd) // do not copy the " at the beginning of the string + { + *(dst++) = L'"'; + } + } + else + { + *(dst++) = *arg; + } + + arg++; + } + + cmd = arg + 1; + + while (*cmd == L' ') + cmd++; + } + + // Read second param, expecting an idlist in shared memory + if (*cmd != L')') + { + if (*cmd != ':') + { + ERR("Expected ':'. Invalid command.\n"); + return DDE_FNOTPROCESSED; + } + + PWSTR idlistEnd = StrChrW(cmd, L','); + + if (!idlistEnd) + idlistEnd = StrChrW(cmd, L')'); + + if (!idlistEnd) + { + ERR("Expected ',' or ')'. Invalid command.\n"); + return DDE_FNOTPROCESSED; + } + + IdList = _ILReadFromSharedMemory(cmd); + + cmd = idlistEnd + 1; + } + + // Read third param, expecting an integer + if (*cmd != L')') + { + UnknownParameter = StrToIntW(cmd); + } + + DbgPrint("Parse end: cmd=%S, S=%d, pidl=%p, path=%S\n", Command, UnknownParameter, IdList, Path); + + // Find handler in list + for (int i = 0; i < HandlerListLength; i++) + { + DDECommandHandler & handler = HandlerList[i]; + if (StrCmpW(handler.Command, Command) == 0) + { + return handler.Handler(Command, Path, IdList, UnknownParameter); + } + } + + // No handler found + ERR("Unknown command %S\n", Command); return DDE_FNOTPROCESSED; } -static void __inline Dde_OnDisconnect(HCONV hconv) -{ - FIXME("stub\n"); +static void Dde_OnDisconnect(HCONV hconv) +{ + DbgPrint("Dde_OnDisconnect: hconv=%p\n", hconv); } static HDDEDATA CALLBACK DdeCallback( @@ -97,24 +296,26 @@ switch (uType) { case XTYP_CONNECT: - return (HDDEDATA)(DWORD_PTR)Dde_OnConnect(hsz1, hsz2); + return (HDDEDATA) (DWORD_PTR) Dde_OnConnect(hsz1, hsz2); case XTYP_CONNECT_CONFIRM: Dde_OnConnectConfirm(hconv, hsz1, hsz2); return NULL; case XTYP_WILDCONNECT: - return (HDDEDATA)(DWORD_PTR)Dde_OnWildConnect(hsz1, hsz2); + return (HDDEDATA) (DWORD_PTR) Dde_OnWildConnect(hsz1, hsz2); case XTYP_REQUEST: return Dde_OnRequest(uFmt, hconv, hsz1, hsz2); case XTYP_EXECUTE: - return (HDDEDATA)(DWORD_PTR)Dde_OnExecute(hconv, hsz1, hdata); + return (HDDEDATA) (DWORD_PTR) Dde_OnExecute(hconv, hsz1, hdata); case XTYP_DISCONNECT: Dde_OnDisconnect(hconv); return NULL; + case XTYP_REGISTER: + return NULL; default: + DbgPrint("DdeCallback: unknown uType=%d\n", uType); return NULL; } } - /************************************************************************* * ShellDDEInit (SHELL32.@) * @@ -129,42 +330,95 @@ */ EXTERN_C void WINAPI ShellDDEInit(BOOL bInit) { - TRACE("bInit = %s\n", bInit ? "TRUE" : "FALSE"); - - if (bInit) - { - static const WCHAR wszProgman[] = {'P','r','o','g','m','a','n',0}; - static const WCHAR wszAsterisk[] = {'*',0}; - static const WCHAR wszShell[] = {'S','h','e','l','l',0}; - static const WCHAR wszAppProperties[] = - {'A','p','p','P','r','o','p','e','r','t','i','e','s',0}; - static const WCHAR wszFolders[] = {'F','o','l','d','e','r','s',0}; - + DbgPrint("ShellDDEInit bInit = %s\n", bInit ? "TRUE" : "FALSE"); + + if (bInit && !bInitialized) + { DdeInitializeW(&dwDDEInst, DdeCallback, CBF_FAIL_ADVISES | CBF_FAIL_POKES, 0); - hszProgmanTopic = DdeCreateStringHandleW(dwDDEInst, wszProgman, CP_WINUNICODE); - hszProgmanService = DdeCreateStringHandleW(dwDDEInst, wszProgman, CP_WINUNICODE); - hszAsterisk = DdeCreateStringHandleW(dwDDEInst, wszAsterisk, CP_WINUNICODE); - hszShell = DdeCreateStringHandleW(dwDDEInst, wszShell, CP_WINUNICODE); - hszAppProperties = DdeCreateStringHandleW(dwDDEInst, wszAppProperties, CP_WINUNICODE); - hszFolders = DdeCreateStringHandleW(dwDDEInst, wszFolders, CP_WINUNICODE); - - DdeNameService(dwDDEInst, hszFolders, 0, DNS_REGISTER); - DdeNameService(dwDDEInst, hszProgmanService, 0, DNS_REGISTER); - DdeNameService(dwDDEInst, hszShell, 0, DNS_REGISTER); - } - else + hszProgmanTopic = DdeCreateStringHandleW(dwDDEInst, L"Progman", CP_WINUNICODE); + hszProgmanService = DdeCreateStringHandleW(dwDDEInst, L"Progman", CP_WINUNICODE); + hszShell = DdeCreateStringHandleW(dwDDEInst, L"Shell", CP_WINUNICODE); + hszAppProperties = DdeCreateStringHandleW(dwDDEInst, L"AppProperties", CP_WINUNICODE); + hszFolders = DdeCreateStringHandleW(dwDDEInst, L"Folders", CP_WINUNICODE); + + if (hszProgmanTopic && hszProgmanService && + hszShell && hszAppProperties && hszFolders && + DdeNameService(dwDDEInst, hszFolders, 0, DNS_REGISTER) && + DdeNameService(dwDDEInst, hszProgmanService, 0, DNS_REGISTER) && + DdeNameService(dwDDEInst, hszShell, 0, DNS_REGISTER)) + { + bInitialized = TRUE; + } + } + else if (!bInit && bInitialized) { /* unregister all services */ DdeNameService(dwDDEInst, 0, 0, DNS_UNREGISTER); - DdeFreeStringHandle(dwDDEInst, hszFolders); - DdeFreeStringHandle(dwDDEInst, hszAppProperties); - DdeFreeStringHandle(dwDDEInst, hszShell); - DdeFreeStringHandle(dwDDEInst, hszAsterisk); - DdeFreeStringHandle(dwDDEInst, hszProgmanService); - DdeFreeStringHandle(dwDDEInst, hszProgmanTopic); + if (hszFolders) + DdeFreeStringHandle(dwDDEInst, hszFolders); + if (hszAppProperties) + DdeFreeStringHandle(dwDDEInst, hszAppProperties); + if (hszShell) + DdeFreeStringHandle(dwDDEInst, hszShell); + if (hszProgmanService) + DdeFreeStringHandle(dwDDEInst, hszProgmanService); + if (hszProgmanTopic) + DdeFreeStringHandle(dwDDEInst, hszProgmanTopic); DdeUninitialize(dwDDEInst); - } -} + + bInitialized = FALSE; + } +} + +static DWORD CALLBACK DDE_OnViewFolder(PWSTR strCommand, PWSTR strPath, LPITEMIDLIST pidl, INT unkS) +{ + if (!pidl) + pidl = ILCreateFromPathW(strPath); + + if (!pidl) + return DDE_FNOTPROCESSED; + + if (FAILED(SHOpenNewFrame(pidl, NULL, 0, 0))) + return DDE_FNOTPROCESSED; + + return DDE_FACK; +} + +static DWORD CALLBACK DDW_OnExploreFolder(PWSTR strCommand, PWSTR strPath, LPITEMIDLIST pidl, INT unkS) +{ + if (!pidl) + pidl = ILCreateFromPathW(strPath); + + if (!pidl) + return DDE_FNOTPROCESSED; + + if (FAILED(SHOpenNewFrame(pidl, NULL, 0, SH_EXPLORER_CMDLINE_FLAG_E))) + return DDE_FNOTPROCESSED; + + return DDE_FACK; +} + +static DWORD CALLBACK DDE_OnFindFolder(PWSTR strCommand, PWSTR strPath, LPITEMIDLIST pidl, INT unkS) +{ + UNIMPLEMENTED; + return DDE_FNOTPROCESSED; +} + +static DWORD CALLBACK DDE_OnShellFile(PWSTR strCommand, PWSTR strPath, LPITEMIDLIST pidl, INT unkS) +{ + UNIMPLEMENTED; + return DDE_FNOTPROCESSED; +} + +DDECommandHandler HandlerList [] = { + + { L"ViewFolder", DDE_OnViewFolder }, + { L"ExploreFolder", DDW_OnExploreFolder }, + { L"FindFolder", DDE_OnFindFolder }, + { L"ShellFile", DDE_OnShellFile } +}; + +const int HandlerListLength = _countof(HandlerList);
10 years, 2 months
1
0
0
0
[jgardou] 64394: [NTDLL_APITEST] - Add tests for NtQueryKey(KeyNameInformation) [ADVAPI32_APITEST] - Don't be so generous and claim back my code. @Thomas: If you ever find out how buggy it is, feel...
by jgardou@svn.reactos.org
Author: jgardou Date: Mon Sep 29 16:21:53 2014 New Revision: 64394 URL:
http://svn.reactos.org/svn/reactos?rev=64394&view=rev
Log: [NTDLL_APITEST] - Add tests for NtQueryKey(KeyNameInformation) [ADVAPI32_APITEST] - Don't be so generous and claim back my code. @Thomas: If you ever find out how buggy it is, feel free to claim it back. ;-) Added: trunk/rostests/apitests/ntdll/NtQueryKey.c (with props) Modified: trunk/rostests/apitests/advapi32/HKEY_CLASSES_ROOT.c trunk/rostests/apitests/ntdll/CMakeLists.txt trunk/rostests/apitests/ntdll/testlist.c Modified: trunk/rostests/apitests/advapi32/HKEY_CLASSES_ROOT.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/advapi32/HKEY_CL…
============================================================================== --- trunk/rostests/apitests/advapi32/HKEY_CLASSES_ROOT.c [iso-8859-1] (original) +++ trunk/rostests/apitests/advapi32/HKEY_CLASSES_ROOT.c [iso-8859-1] Mon Sep 29 16:21:53 2014 @@ -1,8 +1,8 @@ /* * PROJECT: ReactOS api tests * LICENSE: GPLv2+ - See COPYING in the top level directory - * PURPOSE: Test for CreateService - * PROGRAMMER: Thomas Faber <thomas.faber(a)reactos.org> + * PURPOSE: Test for the HKEY_CLASSES_ROOT key + * PROGRAMMER: Jérôme Gardou <jerome.gardou(a)reactos.org> */ #include <apitest.h> Modified: trunk/rostests/apitests/ntdll/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/ntdll/CMakeLists…
============================================================================== --- trunk/rostests/apitests/ntdll/CMakeLists.txt [iso-8859-1] (original) +++ trunk/rostests/apitests/ntdll/CMakeLists.txt [iso-8859-1] Mon Sep 29 16:21:53 2014 @@ -10,6 +10,7 @@ NtMapViewOfSection.c NtMutant.c NtProtectVirtualMemory.c + NtQueryKey.c NtQuerySystemEnvironmentValue.c NtQueryVolumeInformationFile.c NtSaveKey.c Added: trunk/rostests/apitests/ntdll/NtQueryKey.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/ntdll/NtQueryKey…
============================================================================== --- trunk/rostests/apitests/ntdll/NtQueryKey.c (added) +++ trunk/rostests/apitests/ntdll/NtQueryKey.c [iso-8859-1] Mon Sep 29 16:21:53 2014 @@ -0,0 +1,99 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: GPLv2+ - See COPYING in the top level directory + * PURPOSE: Tests for the NtQueryKey API + * PROGRAMMER: Jérôme Gardou <jerome.gardou(a)reactos.org> + */ + +#include <apitest.h> + +#define WIN32_NO_STATUS +#include <ndk/rtlfuncs.h> +#include <ndk/cmfuncs.h> +#include <ndk/cmtypes.h> +#include <ndk/obfuncs.h> + +static +void +Test_KeyNameInformation(void) +{ + UNICODE_STRING HKLM_Name = RTL_CONSTANT_STRING(L"\\Registry\\Machine"); + UNICODE_STRING HKLM_Software_Name = RTL_CONSTANT_STRING(L"\\Registry\\Machine\\Software"); + UNICODE_STRING Software_Name = RTL_CONSTANT_STRING(L"Software"); + UNICODE_STRING InfoName; + HANDLE HKLM_Key, HKLM_Software_Key; + PKEY_NAME_INFORMATION NameInformation; + ULONG InfoLength; + OBJECT_ATTRIBUTES ObjectAttributes; + NTSTATUS Status; + + /* Open the HKCU key */ + InitializeObjectAttributes(&ObjectAttributes, + &HKLM_Name, + OBJ_CASE_INSENSITIVE, + NULL, + NULL); + Status = NtOpenKey(&HKLM_Key, KEY_READ, &ObjectAttributes); + ok_ntstatus(Status, STATUS_SUCCESS); + + /* Get the name info length */ + InfoLength = 0; + Status = NtQueryKey(HKLM_Key, KeyNameInformation, NULL, 0, &InfoLength); + ok_ntstatus(Status, STATUS_BUFFER_TOO_SMALL); + ok_size_t(InfoLength, FIELD_OFFSET(KEY_NAME_INFORMATION, Name[HKLM_Name.Length/sizeof(WCHAR)])); + + /* Get it for real */ + NameInformation = RtlAllocateHeap(RtlGetProcessHeap(), 0, InfoLength); + ok(NameInformation != NULL, "\n"); + + Status = NtQueryKey(HKLM_Key, KeyNameInformation, NameInformation, InfoLength, &InfoLength); + ok_ntstatus(Status, STATUS_SUCCESS); + ok_size_t(InfoLength, FIELD_OFFSET(KEY_NAME_INFORMATION, Name[HKLM_Name.Length/sizeof(WCHAR)])); + ok_size_t(NameInformation->NameLength, HKLM_Name.Length); + + RtlInitUnicodeString(&InfoName, NameInformation->Name); + InfoName.Length = NameInformation->NameLength; + ok(RtlCompareUnicodeString(&InfoName, &HKLM_Name, TRUE) == 0, "%.*S\n", + InfoName.Length, InfoName.Buffer); + + RtlFreeHeap(RtlGetProcessHeap(), 0, NameInformation); + + /* Open one subkey */ + InitializeObjectAttributes(&ObjectAttributes, + &Software_Name, + OBJ_CASE_INSENSITIVE, + HKLM_Key, + NULL); + Status = NtOpenKey(&HKLM_Software_Key, KEY_READ, &ObjectAttributes); + ok_ntstatus(Status, STATUS_SUCCESS); + + /* Get the name info length */ + InfoLength = 0; + Status = NtQueryKey(HKLM_Software_Key, KeyNameInformation, NULL, 0, &InfoLength); + ok_ntstatus(Status, STATUS_BUFFER_TOO_SMALL); + ok_size_t(InfoLength, FIELD_OFFSET(KEY_NAME_INFORMATION, Name[HKLM_Software_Name.Length/sizeof(WCHAR)])); + + /* Get it for real */ + NameInformation = RtlAllocateHeap(RtlGetProcessHeap(), 0, InfoLength); + ok(NameInformation != NULL, "\n"); + + Status = NtQueryKey(HKLM_Software_Key, KeyNameInformation, NameInformation, InfoLength, &InfoLength); + ok_ntstatus(Status, STATUS_SUCCESS); + ok_size_t(InfoLength, FIELD_OFFSET(KEY_NAME_INFORMATION, Name[HKLM_Software_Name.Length/sizeof(WCHAR)])); + ok_size_t(NameInformation->NameLength, HKLM_Software_Name.Length); + + RtlInitUnicodeString(&InfoName, NameInformation->Name); + InfoName.Length = NameInformation->NameLength; + ok(RtlCompareUnicodeString(&InfoName, &HKLM_Software_Name, TRUE) == 0, "%.*S\n", + InfoName.Length, InfoName.Buffer); + + RtlFreeHeap(RtlGetProcessHeap(), 0, NameInformation); + + NtClose(HKLM_Software_Key); + NtClose(HKLM_Key); +} + +START_TEST(NtQueryKey) +{ + Test_KeyNameInformation(); +} Propchange: trunk/rostests/apitests/ntdll/NtQueryKey.c ------------------------------------------------------------------------------ charset = UTF-8 Propchange: trunk/rostests/apitests/ntdll/NtQueryKey.c ------------------------------------------------------------------------------ svn:eol-style = native Propchange: trunk/rostests/apitests/ntdll/NtQueryKey.c ------------------------------------------------------------------------------ svn:mime-type = text/plain Modified: trunk/rostests/apitests/ntdll/testlist.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/ntdll/testlist.c…
============================================================================== --- trunk/rostests/apitests/ntdll/testlist.c [iso-8859-1] (original) +++ trunk/rostests/apitests/ntdll/testlist.c [iso-8859-1] Mon Sep 29 16:21:53 2014 @@ -13,6 +13,7 @@ extern void func_NtMapViewOfSection(void); extern void func_NtMutant(void); extern void func_NtProtectVirtualMemory(void); +extern void func_NtQueryKey(void); extern void func_NtQuerySystemEnvironmentValue(void); extern void func_NtQueryVolumeInformationFile(void); extern void func_NtSaveKey(void); @@ -44,6 +45,7 @@ { "NtMapViewOfSection", func_NtMapViewOfSection }, { "NtMutant", func_NtMutant }, { "NtProtectVirtualMemory", func_NtProtectVirtualMemory }, + { "NtQueryKey", func_NtQueryKey }, { "NtQuerySystemEnvironmentValue", func_NtQuerySystemEnvironmentValue }, { "NtQueryVolumeInformationFile", func_NtQueryVolumeInformationFile }, { "NtSaveKey", func_NtSaveKey},
10 years, 2 months
1
0
0
0
[jgardou] 64393: [ADVAPI32_APITEST] - Add a few tests regarding HKEY_CLASSES_ROOT special keys.
by jgardou@svn.reactos.org
Author: jgardou Date: Mon Sep 29 13:35:59 2014 New Revision: 64393 URL:
http://svn.reactos.org/svn/reactos?rev=64393&view=rev
Log: [ADVAPI32_APITEST] - Add a few tests regarding HKEY_CLASSES_ROOT special keys. Added: trunk/rostests/apitests/advapi32/HKEY_CLASSES_ROOT.c (with props) Modified: trunk/rostests/apitests/advapi32/CMakeLists.txt trunk/rostests/apitests/advapi32/testlist.c Modified: trunk/rostests/apitests/advapi32/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/advapi32/CMakeLi…
============================================================================== --- trunk/rostests/apitests/advapi32/CMakeLists.txt [iso-8859-1] (original) +++ trunk/rostests/apitests/advapi32/CMakeLists.txt [iso-8859-1] Mon Sep 29 13:35:59 2014 @@ -1,6 +1,7 @@ list(APPEND SOURCE CreateService.c + HKEY_CLASSES_ROOT.c LockDatabase.c QueryServiceConfig2.c RtlEncryptMemory.c Added: trunk/rostests/apitests/advapi32/HKEY_CLASSES_ROOT.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/advapi32/HKEY_CL…
============================================================================== --- trunk/rostests/apitests/advapi32/HKEY_CLASSES_ROOT.c (added) +++ trunk/rostests/apitests/advapi32/HKEY_CLASSES_ROOT.c [iso-8859-1] Mon Sep 29 13:35:59 2014 @@ -0,0 +1,83 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: GPLv2+ - See COPYING in the top level directory + * PURPOSE: Test for CreateService + * PROGRAMMER: Thomas Faber <thomas.faber(a)reactos.org> + */ + +#include <apitest.h> + +#define WIN32_NO_STATUS +#include <winreg.h> +#include <ndk/rtlfuncs.h> +#include <ndk/cmfuncs.h> +#include <ndk/cmtypes.h> + +#define IS_HKCR(hk) ((UINT_PTR)hk > 0 && ((UINT_PTR)hk & 3) == 2) + +static +void +Test_KeyInformation(void) +{ + HKEY KeyHandle; + DWORD ErrorCode; + NTSTATUS Status; + UNICODE_STRING KeyName = RTL_CONSTANT_STRING(L"\\Registry\\Machine\\Software\\Classes\\CLSID"); + UNICODE_STRING InfoName; + CHAR Buffer[FIELD_OFFSET(KEY_NAME_INFORMATION, Name[512])]; + PKEY_NAME_INFORMATION NameInfo = (PKEY_NAME_INFORMATION)Buffer; + ULONG ResultLength; + + + ErrorCode = RegOpenKeyExW(HKEY_CLASSES_ROOT, L"CLSID", 0, KEY_READ, &KeyHandle); + ok_dec(ErrorCode, ERROR_SUCCESS); + ok(IS_HKCR(KeyHandle), "\n"); + + Status = NtQueryKey(KeyHandle, KeyNameInformation, NameInfo, sizeof(Buffer), &ResultLength); + ok_ntstatus(Status, STATUS_SUCCESS); + RtlInitUnicodeString(&InfoName, NameInfo->Name); + InfoName.Length = NameInfo->NameLength; + ok(RtlCompareUnicodeString(&KeyName, &InfoName, TRUE) == 0, "%.*S\n", InfoName.Length, InfoName.Buffer); + + RegCloseKey(KeyHandle); +} + +static +void +Test_DuplicateHandle(void) +{ + HKEY KeyHandle, DupHandle; + DWORD ErrorCode; + BOOL Duplicated; + NTSTATUS Status; + UNICODE_STRING KeyName = RTL_CONSTANT_STRING(L"\\Registry\\Machine\\Software\\Classes\\CLSID"); + UNICODE_STRING InfoName; + CHAR Buffer[FIELD_OFFSET(KEY_NAME_INFORMATION, Name[512])]; + PKEY_NAME_INFORMATION NameInfo = (PKEY_NAME_INFORMATION)Buffer; + ULONG ResultLength; + + + ErrorCode = RegOpenKeyExW(HKEY_CLASSES_ROOT, L"CLSID", 0, KEY_READ, &KeyHandle); + ok_dec(ErrorCode, ERROR_SUCCESS); + ok(IS_HKCR(KeyHandle), "\n"); + + Duplicated = DuplicateHandle(GetCurrentProcess(), KeyHandle, GetCurrentProcess(), (PHANDLE)&DupHandle, 0, 0, DUPLICATE_SAME_ACCESS); + ok(Duplicated, "\n"); + ok(DupHandle != NULL, "\n"); + ok(!IS_HKCR(DupHandle), "\n"); + + Status = NtQueryKey(DupHandle, KeyNameInformation, NameInfo, sizeof(Buffer), &ResultLength); + ok_ntstatus(Status, STATUS_SUCCESS); + RtlInitUnicodeString(&InfoName, NameInfo->Name); + InfoName.Length = NameInfo->NameLength; + ok(RtlCompareUnicodeString(&KeyName, &InfoName, TRUE) == 0, "%S\n", NameInfo->Name); + + RegCloseKey(KeyHandle); + RegCloseKey(DupHandle); +} + +START_TEST(HKEY_CLASSES_ROOT) +{ + Test_KeyInformation(); + Test_DuplicateHandle(); +} Propchange: trunk/rostests/apitests/advapi32/HKEY_CLASSES_ROOT.c ------------------------------------------------------------------------------ charset = UTF-8 Propchange: trunk/rostests/apitests/advapi32/HKEY_CLASSES_ROOT.c ------------------------------------------------------------------------------ svn:eol-style = native Propchange: trunk/rostests/apitests/advapi32/HKEY_CLASSES_ROOT.c ------------------------------------------------------------------------------ svn:mime-type = text/plain Modified: trunk/rostests/apitests/advapi32/testlist.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/advapi32/testlis…
============================================================================== --- trunk/rostests/apitests/advapi32/testlist.c [iso-8859-1] (original) +++ trunk/rostests/apitests/advapi32/testlist.c [iso-8859-1] Mon Sep 29 13:35:59 2014 @@ -4,6 +4,7 @@ #include <apitest.h> extern void func_CreateService(void); +extern void func_HKEY_CLASSES_ROOT(void); extern void func_LockDatabase(void); extern void func_QueryServiceConfig2(void); extern void func_RtlEncryptMemory(void); @@ -12,6 +13,7 @@ const struct test winetest_testlist[] = { { "CreateService", func_CreateService }, + { "HKEY_CLASSES_ROOT", func_HKEY_CLASSES_ROOT }, { "LockDatabase" , func_LockDatabase }, { "QueryServiceConfig2", func_QueryServiceConfig2 }, { "RtlEncryptMemory", func_RtlEncryptMemory },
10 years, 2 months
1
0
0
0
[jgardou] 64392: [NDK] - Fix KEY_NAME_INFORMATION structure
by jgardou@svn.reactos.org
Author: jgardou Date: Mon Sep 29 13:32:44 2014 New Revision: 64392 URL:
http://svn.reactos.org/svn/reactos?rev=64392&view=rev
Log: [NDK] - Fix KEY_NAME_INFORMATION structure Modified: trunk/reactos/include/ndk/cmtypes.h Modified: trunk/reactos/include/ndk/cmtypes.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/ndk/cmtypes.h?rev=…
============================================================================== --- trunk/reactos/include/ndk/cmtypes.h [iso-8859-1] (original) +++ trunk/reactos/include/ndk/cmtypes.h [iso-8859-1] Mon Sep 29 13:32:44 2014 @@ -296,6 +296,7 @@ typedef struct _KEY_NAME_INFORMATION { + ULONG NameLength; WCHAR Name[1]; } KEY_NAME_INFORMATION, *PKEY_NAME_INFORMATION;
10 years, 2 months
1
0
0
0
[akhaldi] 64391: [MMDEVAPI_WINETEST] * Sync with Wine 1.7.27. CORE-8540
by akhaldi@svn.reactos.org
Author: akhaldi Date: Mon Sep 29 13:17:17 2014 New Revision: 64391 URL:
http://svn.reactos.org/svn/reactos?rev=64391&view=rev
Log: [MMDEVAPI_WINETEST] * Sync with Wine 1.7.27. CORE-8540 Modified: trunk/rostests/winetests/mmdevapi/capture.c trunk/rostests/winetests/mmdevapi/dependency.c trunk/rostests/winetests/mmdevapi/propstore.c trunk/rostests/winetests/mmdevapi/render.c Modified: trunk/rostests/winetests/mmdevapi/capture.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/mmdevapi/captur…
============================================================================== --- trunk/rostests/winetests/mmdevapi/capture.c [iso-8859-1] (original) +++ trunk/rostests/winetests/mmdevapi/capture.c [iso-8859-1] Mon Sep 29 13:17:17 2014 @@ -424,7 +424,7 @@ /* Still receiving events! */ r = WaitForSingleObject(handle, 20); - todo_wine ok(r == WAIT_OBJECT_0, "Wait(event) after Stop gave %x\n", r); + ok(r == WAIT_OBJECT_0, "Wait(event) after Stop gave %x\n", r); hr = IAudioClient_Reset(ac); ok(hr == S_OK, "Reset failed: %08x\n", hr); @@ -432,13 +432,13 @@ ok(ResetEvent(handle), "ResetEvent\n"); r = WaitForSingleObject(handle, 120); - todo_wine ok(r == WAIT_OBJECT_0, "Wait(event) after Reset gave %x\n", r); + ok(r == WAIT_OBJECT_0, "Wait(event) after Reset gave %x\n", r); hr = IAudioClient_SetEventHandle(ac, NULL); ok(hr == E_INVALIDARG, "SetEventHandle(NULL) returns %08x\n", hr); r = WaitForSingleObject(handle, 70); - todo_wine ok(r == WAIT_OBJECT_0, "Wait(NULL event) gave %x\n", r); + ok(r == WAIT_OBJECT_0, "Wait(NULL event) gave %x\n", r); hr = IAudioClient_Start(ac); ok(hr == S_OK, "Start failed: %08x\n", hr); Modified: trunk/rostests/winetests/mmdevapi/dependency.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/mmdevapi/depend…
============================================================================== --- trunk/rostests/winetests/mmdevapi/dependency.c [iso-8859-1] (original) +++ trunk/rostests/winetests/mmdevapi/dependency.c [iso-8859-1] Mon Sep 29 13:17:17 2014 @@ -30,17 +30,6 @@ #include "dshow.h" #include "dsound.h" -static inline const char *dump_guid( const GUID *id ) -{ - static char data[39]; - if (!id) return "(null)"; - wsprintfA( data, "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}", - id->Data1, id->Data2, id->Data3, - id->Data4[0], id->Data4[1], id->Data4[2], id->Data4[3], - id->Data4[4], id->Data4[5], id->Data4[6], id->Data4[7] ); - return data; -} - START_TEST(dependency) { HRESULT hr; @@ -68,24 +57,24 @@ goto cleanup; } - ok(!GetModuleHandle("dsound.dll"), "dsound.dll was already loaded!\n"); + ok(!GetModuleHandleA("dsound.dll"), "dsound.dll was already loaded!\n"); hr = IMMDevice_Activate(dev, &IID_IDirectSound8, CLSCTX_INPROC_SERVER, NULL, (void**)&ds8); ok(hr == S_OK, "Activating ds8 interface failed: 0x%08x\n", hr); if (hr == S_OK) { - ok(GetModuleHandle("dsound.dll") != NULL, "dsound.dll not loaded!\n"); + ok(GetModuleHandleA("dsound.dll") != NULL, "dsound.dll not loaded!\n"); ok(ds8 != NULL, "ds8 pointer is null\n"); } if (ds8) IDirectSound8_Release(ds8); - ok(!GetModuleHandle("quartz.dll"), "quartz.dll was already loaded!\n"); + ok(!GetModuleHandleA("quartz.dll"), "quartz.dll was already loaded!\n"); hr = IMMDevice_Activate(dev, &IID_IBaseFilter, CLSCTX_INPROC_SERVER, NULL, (void**)&bf); ok(hr == S_OK, "Activating bf failed: 0x%08x\n", hr); if (hr == S_OK) { - ok(GetModuleHandle("quartz.dll") != NULL, "quartz.dll not loaded!\n"); + ok(GetModuleHandleA("quartz.dll") != NULL, "quartz.dll not loaded!\n"); ok(bf != NULL, "bf pointer is null\n"); if (bf) { @@ -93,7 +82,7 @@ hr = IBaseFilter_GetClassID(bf, &clsid); ok(hr == S_OK, "GetClassId failed with 0x%08x\n", hr); if (hr == S_OK) - ok(IsEqualCLSID(&clsid, &CLSID_DSoundRender), "Wrong class id %s\n", dump_guid(&clsid)); + ok(IsEqualCLSID(&clsid, &CLSID_DSoundRender), "Wrong class id %s\n", wine_dbgstr_guid(&clsid)); } } Modified: trunk/rostests/winetests/mmdevapi/propstore.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/mmdevapi/propst…
============================================================================== --- trunk/rostests/winetests/mmdevapi/propstore.c [iso-8859-1] (original) +++ trunk/rostests/winetests/mmdevapi/propstore.c [iso-8859-1] Mon Sep 29 13:17:17 2014 @@ -81,6 +81,34 @@ CoTaskMemFree(pv.u.pwszVal); } +static void test_getat(IPropertyStore *store) +{ + HRESULT hr; + DWORD propcount; + DWORD prop; + PROPERTYKEY pkey; + BOOL found_name = FALSE; + BOOL found_desc = FALSE; + char temp[128]; + temp[sizeof(temp)-1] = 0; + + hr = IPropertyStore_GetCount(store, &propcount); + + ok(hr == S_OK, "Failed with %08x\n", hr); + ok(propcount > 0, "Propcount %d should be greather than zero\n", propcount); + + for (prop = 0; prop < propcount; prop++) { + hr = IPropertyStore_GetAt(store, prop, &pkey); + ok(hr == S_OK, "Failed with %08x\n", hr); + if (IsEqualPropertyKey(pkey, DEVPKEY_Device_FriendlyName)) + found_name = TRUE; + if (IsEqualPropertyKey(pkey, DEVPKEY_Device_DeviceDesc)) + found_desc = TRUE; + } + ok(found_name || broken(!found_name), "DEVPKEY_Device_FriendlyName not found\n"); + ok(found_desc == TRUE, "DEVPKEY_Device_DeviceDesc not found\n"); +} + START_TEST(propstore) { HRESULT hr; @@ -127,6 +155,7 @@ { test_propertystore(store); test_deviceinterface(store); + test_getat(store); IPropertyStore_Release(store); } IMMDevice_Release(dev); Modified: trunk/rostests/winetests/mmdevapi/render.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/mmdevapi/render…
============================================================================== --- trunk/rostests/winetests/mmdevapi/render.c [iso-8859-1] (original) +++ trunk/rostests/winetests/mmdevapi/render.c [iso-8859-1] Mon Sep 29 13:17:17 2014 @@ -36,6 +36,7 @@ #include "unknwn.h" #include "uuids.h" #include "mmdeviceapi.h" +#include "mmsystem.h" #include "audioclient.h" #include "audiopolicy.h" @@ -58,16 +59,6 @@ static HRESULT hexcl = S_OK; /* or AUDCLNT_E_EXCLUSIVE_MODE_NOT_ALLOWED */ static const LARGE_INTEGER ullZero; - -static inline const char *dbgstr_guid( const GUID *id ) -{ - static char ret[256]; - sprintf(ret, "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}", - id->Data1, id->Data2, id->Data3, - id->Data4[0], id->Data4[1], id->Data4[2], id->Data4[3], - id->Data4[4], id->Data4[5], id->Data4[6], id->Data4[7] ); - return ret; -} #define PI 3.14159265358979323846L static DWORD wave_generate_tone(PWAVEFORMATEX pwfx, BYTE* data, UINT32 frames) @@ -255,7 +246,8 @@ ok(hr == AUDCLNT_E_NOT_INITIALIZED, "Initialize with invalid sharemode returns %08x\n", hr); hr = IAudioClient_Initialize(ac, AUDCLNT_SHAREMODE_SHARED, 0xffffffff, 5000000, 0, pwfx, NULL); - ok(hr == E_INVALIDARG, "Initialize with invalid flags returns %08x\n", hr); + ok(hr == E_INVALIDARG || + hr == AUDCLNT_E_INVALID_STREAM_FLAG, "Initialize with invalid flags returns %08x\n", hr); /* A period != 0 is ignored and the call succeeds. * Since we can only initialize successfully once, skip those tests. @@ -455,9 +447,10 @@ * Some cards Initialize 44100|48000x16x1 yet claim no support; * F. Gouget's w7 bots do that for 12000|96000x8|16x1|2 */ ok(hrs == S_OK ? hr == S_OK || broken(hr == AUDCLNT_E_ENDPOINT_CREATE_FAILED) - : hr == AUDCLNT_E_ENDPOINT_CREATE_FAILED || broken(hr == S_OK && - ((fmt.nChannels == 1 && fmt.wBitsPerSample == 16) || - (fmt.nSamplesPerSec == 12000 || fmt.nSamplesPerSec == 96000))), + : hr == AUDCLNT_E_ENDPOINT_CREATE_FAILED || hr == AUDCLNT_E_UNSUPPORTED_FORMAT || + broken(hr == S_OK && + ((fmt.nChannels == 1 && fmt.wBitsPerSample == 16) || + (fmt.nSamplesPerSec == 12000 || fmt.nSamplesPerSec == 96000))), "Initialize(exclus., %ux%2ux%u) returns %08x\n", fmt.nSamplesPerSec, fmt.wBitsPerSample, fmt.nChannels, hr); @@ -658,7 +651,7 @@ /* Still receiving events! */ r = WaitForSingleObject(event, 20); - todo_wine ok(r == WAIT_OBJECT_0, "Wait(event) after Stop gave %x\n", r); + ok(r == WAIT_OBJECT_0, "Wait(event) after Stop gave %x\n", r); hr = IAudioClient_Reset(ac); ok(hr == S_OK, "Reset failed: %08x\n", hr); @@ -666,13 +659,13 @@ ok(ResetEvent(event), "ResetEvent\n"); r = WaitForSingleObject(event, 120); - todo_wine ok(r == WAIT_OBJECT_0, "Wait(event) after Reset gave %x\n", r); + ok(r == WAIT_OBJECT_0, "Wait(event) after Reset gave %x\n", r); hr = IAudioClient_SetEventHandle(ac, NULL); ok(hr == E_INVALIDARG, "SetEventHandle(NULL) returns %08x\n", hr); r = WaitForSingleObject(event, 70); - todo_wine ok(r == WAIT_OBJECT_0, "Wait(NULL event) gave %x\n", r); + ok(r == WAIT_OBJECT_0, "Wait(NULL event) gave %x\n", r); /* test releasing a playing stream */ hr = IAudioClient_Start(ac); @@ -689,8 +682,8 @@ IAudioRenderClient *arc; WAVEFORMATEX *pwfx; REFERENCE_TIME minp, defp; - BYTE *buf; - UINT32 psize, pad, written; + BYTE *buf, silence; + UINT32 psize, pad, written, i; hr = IMMDevice_Activate(dev, &IID_IAudioClient, CLSCTX_INPROC_SERVER, NULL, (void**)&ac); @@ -708,6 +701,11 @@ ok(hr == S_OK, "Initialize failed: %08x\n", hr); if(hr != S_OK) return; + + if(pwfx->wBitsPerSample == 8) + silence = 128; + else + silence = 0; /** GetDevicePeriod * Default (= shared) device period is 10ms (e.g. 441 frames at 44100), @@ -735,6 +733,12 @@ hr = IAudioRenderClient_GetBuffer(arc, psize, &buf); ok(hr == S_OK, "GetBuffer failed: %08x\n", hr); ok(buf != NULL, "NULL buffer returned\n"); + for(i = 0; i < psize * pwfx->nBlockAlign; ++i){ + if(buf[i] != silence){ + ok(0, "buffer has data in it already\n"); + break; + } + } hr = IAudioRenderClient_GetBuffer(arc, 0, &buf); ok(hr == AUDCLNT_E_OUT_OF_ORDER, "GetBuffer 0 size failed: %08x\n", hr); @@ -870,7 +874,7 @@ hr = IAudioClient_GetDevicePeriod(ac, &defp, &minp); ok(hr == S_OK, "GetDevicePeriod failed: %08x\n", hr); - ok(minp <= period, "desired period %u to small for %u\n", (ULONG)period, (ULONG)minp); + ok(minp <= period, "desired period %u too small for %u\n", (ULONG)period, (ULONG)minp); if (share) { trace("Testing shared mode\n"); @@ -931,7 +935,7 @@ if (share) ok(gbsize == bufsize, "BufferSize %u at rate %u\n", gbsize, pwfx->nSamplesPerSec); - else todo_wine + else ok(gbsize == parts * fragment || gbsize == MulDiv(bufsize, 1, 1024) * 1024, "BufferSize %u misfits fragment size %u at rate %u\n", gbsize, fragment, pwfx->nSamplesPerSec); @@ -951,7 +955,7 @@ trace("Clock Frequency %u\n", (UINT)freq); /* MSDN says it's arbitrary units, but shared mode is unlikely to change */ - if (share) todo_wine + if (share) ok(freq == pwfx->nSamplesPerSec * pwfx->nBlockAlign, "Clock Frequency %u\n", (UINT)freq); else
10 years, 2 months
1
0
0
0
← Newer
1
2
3
4
5
6
7
...
42
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
Results per page:
10
25
50
100
200