From: Vibhav Pant vibhavp@gmail.com
--- dlls/wintypes/propertyset.c | 24 +++++++++++- dlls/wintypes/tests/wintypes.c | 71 +++++++++++++--------------------- 2 files changed, 49 insertions(+), 46 deletions(-)
diff --git a/dlls/wintypes/propertyset.c b/dlls/wintypes/propertyset.c index 579aa5cdc60..d92893af5c8 100644 --- a/dlls/wintypes/propertyset.c +++ b/dlls/wintypes/propertyset.c @@ -198,8 +198,28 @@ DEFINE_IINSPECTABLE( propertyset_IMap, IMap_HSTRING_IInspectable, struct propert
static HRESULT STDMETHODCALLTYPE propertyset_Lookup( IMap_HSTRING_IInspectable *iface, HSTRING key, IInspectable **value ) { - FIXME( "(%p, %s, %p) stub!\n", iface, debugstr_hstring( key ), value ); - return E_NOTIMPL; + struct propertyset *impl = impl_from_IMap_HSTRING_IInspectable( iface ); + struct rb_entry *entry; + HRESULT hr; + + TRACE( "(%p, %s, %p)\n", iface, debugstr_hstring( key ), value ); + + AcquireSRWLockExclusive( &impl->lock ); + entry = rb_get( &impl->entries, key ); + if (!entry) + { + *value = NULL; + hr = E_BOUNDS; + } + else + { + *value = RB_ENTRY_VALUE( entry, struct map_entry, entry )->value; + IInspectable_AddRef( *value ); + hr = S_OK; + } + ReleaseSRWLockExclusive( &impl->lock ); + + return hr; }
static HRESULT STDMETHODCALLTYPE propertyset_get_Size( IMap_HSTRING_IInspectable *iface, UINT32 *size ) diff --git a/dlls/wintypes/tests/wintypes.c b/dlls/wintypes/tests/wintypes.c index 5dc95648bb0..47d09aac792 100644 --- a/dlls/wintypes/tests/wintypes.c +++ b/dlls/wintypes/tests/wintypes.c @@ -1264,6 +1264,9 @@ static void test_IPropertySet(void) IObservableMap_HSTRING_IInspectable *observable_map; IIterable_IKeyValuePair_HSTRING_IInspectable *iterable; IIterator_IKeyValuePair_HSTRING_IInspectable *iterator; + IPropertyValue *propval; + UINT32 uint32; + UINT64 uint64; BOOLEAN boolean; HRESULT hr; HSTRING name, key1, key2; @@ -1318,7 +1321,6 @@ static void test_IPropertySet(void) ok( hr == S_OK, "HasKey failed, got %#lx\n", hr ); ok( !boolean, "Got boolean %d.\n", boolean ); hr = IMap_HSTRING_IInspectable_Lookup( map, NULL, &val ); - todo_wine ok( hr == E_BOUNDS, "Got hr %#lx\n", hr );
hr = IPropertyValueStatics_CreateUInt32( propval_statics, 0xdeadbeef, &val1 ); @@ -1340,27 +1342,20 @@ static void test_IPropertySet(void) ok( hr == S_OK, "HasKey failed, got %#lx\n", hr ); ok( boolean, "Got boolean %d.\n", boolean ); hr = IMap_HSTRING_IInspectable_Lookup( map, NULL, &val ); - todo_wine ok( hr == S_OK, "Lookup failed, got %#lx\n", hr ); - if (SUCCEEDED(hr)) - { - IPropertyValue *propval; - UINT32 uint32 = 0; - - hr = IInspectable_QueryInterface( val, &IID_IPropertyValue, (void **)&propval ); - IInspectable_Release( val ); - ok( hr == S_OK, "QueryInterface failed, got %#lx\n", hr ); - hr = IPropertyValue_GetUInt32( propval, &uint32 ); - IPropertyValue_Release( propval ); - ok( hr == S_OK, "GetUInt32, got %#lx\n", hr ); - ok( uint32 == 0xc0decafe, "Got uint32 %u\n", uint32 ); - } + hr = IInspectable_QueryInterface( val, &IID_IPropertyValue, (void **)&propval ); + IInspectable_Release( val ); + ok( hr == S_OK, "QueryInterface failed, got %#lx\n", hr ); + uint32 = 0; + hr = IPropertyValue_GetUInt32( propval, &uint32 ); + IPropertyValue_Release( propval ); + ok( hr == S_OK, "GetUInt32, got %#lx\n", hr ); + ok( uint32 == 0xc0decafe, "Got uint32 %u\n", uint32 );
hr = WindowsCreateString( L"foo", 3, &key1 ); ok( hr == S_OK, "WindowsCreateString failed, got %#lx\n", hr ); boolean = TRUE; hr = IMap_HSTRING_IInspectable_Lookup( map, key1, &val ); - todo_wine ok( hr == E_BOUNDS, "Got hr %#lx\n", hr ); hr = IMap_HSTRING_IInspectable_Insert( map, key1, val1, &boolean ); IInspectable_Release( val1 ); @@ -1371,21 +1366,15 @@ static void test_IPropertySet(void) ok( hr == S_OK, "HasKey failed, got %#lx\n", hr ); ok( boolean, "Got boolean %d.\n", boolean ); hr = IMap_HSTRING_IInspectable_Lookup( map, key1, &val ); - todo_wine ok( hr == S_OK, "Lookup failed, got %#lx\n", hr ); - if (SUCCEEDED(hr)) - { - IPropertyValue *propval; - UINT32 uint32 = 0; - - hr = IInspectable_QueryInterface( val, &IID_IPropertyValue, (void **)&propval ); - IInspectable_Release( val ); - ok( hr == S_OK, "QueryInterface failed, got %#lx\n", hr ); - hr = IPropertyValue_GetUInt32( propval, &uint32 ); - IPropertyValue_Release( propval ); - ok( hr == S_OK, "GetUInt32, got %#lx\n", hr ); - ok( uint32 == 0xdeadbeef, "Got uint32 %u\n", uint32 ); - } + hr = IInspectable_QueryInterface( val, &IID_IPropertyValue, (void **)&propval ); + IInspectable_Release( val ); + ok( hr == S_OK, "QueryInterface failed, got %#lx\n", hr ); + uint32 = 0; + hr = IPropertyValue_GetUInt32( propval, &uint32 ); + IPropertyValue_Release( propval ); + ok( hr == S_OK, "GetUInt32, got %#lx\n", hr ); + ok( uint32 == 0xdeadbeef, "Got uint32 %u\n", uint32 ); WindowsDeleteString( key1 );
hr = WindowsCreateString( L"bar", 3, &key2 ); @@ -1406,21 +1395,15 @@ static void test_IPropertySet(void) ok( hr == S_OK, "HasKey failed, got %#lx\n", hr ); ok( boolean, "Got boolean %d.\n", boolean ); hr = IMap_HSTRING_IInspectable_Lookup( map, key2, &val ); - todo_wine ok( hr == S_OK, "Lookup failed, got %#lx\n", hr ); - if (SUCCEEDED(hr)) - { - IPropertyValue *propval; - UINT64 uint64 = 0; - - hr = IInspectable_QueryInterface( val, &IID_IPropertyValue, (void **)&propval ); - IInspectable_Release( val ); - ok( hr == S_OK, "QueryInterface failed, got %#lx\n", hr ); - hr = IPropertyValue_GetUInt64( propval, &uint64 ); - IPropertyValue_Release( propval ); - ok( hr == S_OK, "GetUInt32, got %#lx\n", hr ); - ok( uint64 == 0xdeadbeefdeadbeef, "Got uint64 %I64u\n", uint64 ); - } + hr = IInspectable_QueryInterface( val, &IID_IPropertyValue, (void **)&propval ); + IInspectable_Release( val ); + ok( hr == S_OK, "QueryInterface failed, got %#lx\n", hr ); + uint64 = 0; + hr = IPropertyValue_GetUInt64( propval, &uint64 ); + IPropertyValue_Release( propval ); + ok( hr == S_OK, "GetUInt32, got %#lx\n", hr ); + ok( uint64 == 0xdeadbeefdeadbeef, "Got uint64 %I64u\n", uint64 ); WindowsDeleteString( key2 );
hr = IMap_HSTRING_IInspectable_QueryInterface( map, &IID_IIterable_IKeyValuePair_HSTRING_IInspectable,