From: Vibhav Pant vibhavp@gmail.com
--- dlls/windows.devices.enumeration/collection.c | 40 +++++++++++++++++-- .../tests/devices.c | 6 +-- 2 files changed, 39 insertions(+), 7 deletions(-)
diff --git a/dlls/windows.devices.enumeration/collection.c b/dlls/windows.devices.enumeration/collection.c index ac0ea8c7fe4..5b893735a42 100644 --- a/dlls/windows.devices.enumeration/collection.c +++ b/dlls/windows.devices.enumeration/collection.c @@ -143,16 +143,48 @@ static HRESULT STDMETHODCALLTYPE vectorview_DeviceInformation_IndexOf( IVectorVi IDeviceInformation *elem, UINT32 *index, boolean *found ) { - FIXME( "(%p, %p, %p, %p) stub!\n", iface, elem, index, found ); - return E_NOTIMPL; + struct vectorview_DeviceInformation *impl; + UINT32 i; + + TRACE( "(%p, %p, %p, %p)\n", iface, elem, index, found ); + + impl = impl_from_IVectorView_DeviceInformation( iface ); + for (i = 0; i < impl->len; i++) + if (elem == impl->devices[i]) + break; + + if (i < impl->len) + { + *found = TRUE; + *index = i; + } + else + { + *found = FALSE; + *index = 0; + } + + return S_OK; }
static HRESULT STDMETHODCALLTYPE vectorview_DeviceInformation_GetMany( IVectorView_DeviceInformation *iface, UINT32 start, UINT32 size, IDeviceInformation **items, UINT32 *copied ) { - FIXME( "(%p, %u, %u, %p, %p) stub!\n", iface, start, size, items, copied ); - return E_NOTIMPL; + struct vectorview_DeviceInformation *impl; + UINT32 i; + + TRACE( "(%p, %u, %u, %p, %p)\n", iface, start, size, items, copied ); + impl = impl_from_IVectorView_DeviceInformation( iface ); + memset( items, 0, size * sizeof( *items ) ); + + for (i = start; i < impl->len && i < start + size; i++) + { + items[i] = impl->devices[i - start]; + IUnknown_AddRef( items[i] ); + } + *copied = i - start; + return S_OK; }
const static IVectorView_DeviceInformationVtbl vectorview_DeviceInformation_vtbl = diff --git a/dlls/windows.devices.enumeration/tests/devices.c b/dlls/windows.devices.enumeration/tests/devices.c index eb865d8c5ba..4d04e1582a9 100644 --- a/dlls/windows.devices.enumeration/tests/devices.c +++ b/dlls/windows.devices.enumeration/tests/devices.c @@ -500,7 +500,7 @@ static void test_DeviceInformation( void ) test_DeviceInformation_obj(__LINE__, info); IDeviceInformation_Release( info ); hr = IVectorView_DeviceInformation_IndexOf( info_collection, info, &idx2, &found ); - todo_wine ok( SUCCEEDED( hr ), "got %#lx\n", hr ); + ok( SUCCEEDED( hr ), "got %#lx\n", hr ); if (SUCCEEDED( hr )) { ok( found, "Expected IndexOf to return true\n" ); @@ -517,9 +517,9 @@ static void test_DeviceInformation( void ) UINT32 copied = 0;
hr = IVectorView_DeviceInformation_GetMany( info_collection, 0, size, devices, &copied ); - todo_wine ok( SUCCEEDED( hr ), "got %#lx\n", hr ); + ok( SUCCEEDED( hr ), "got %#lx\n", hr ); if (SUCCEEDED( hr )) - todo_wine ok( copied == size, "%u != %u\n", copied, size ); + ok( copied == size, "%u != %u\n", copied, size ); for(idx = 0; idx < copied; idx++) { IDeviceInformation *info = NULL;