wmiutils: Implement IWbemPath::RemoveNamespaceAt.

This commit is contained in:
Hans Leidekker 2013-01-17 15:30:44 +01:00 committed by Alexandre Julliard
parent 5391929491
commit 9548eb79ad
2 changed files with 97 additions and 9 deletions

View File

@ -525,10 +525,22 @@ static HRESULT WINAPI path_GetNamespaceAt(
static HRESULT WINAPI path_RemoveNamespaceAt( static HRESULT WINAPI path_RemoveNamespaceAt(
IWbemPath *iface, IWbemPath *iface,
ULONG uIndex) ULONG idx)
{ {
FIXME("%p, %u\n", iface, uIndex); struct path *path = impl_from_IWbemPath( iface );
return E_NOTIMPL;
TRACE("%p, %u\n", iface, idx);
if (idx >= path->num_namespaces) return WBEM_E_INVALID_PARAMETER;
heap_free( path->namespaces[idx] );
while (idx < path->num_namespaces - 1)
{
path->namespaces[idx] = path->namespaces[idx + 1];
path->len_namespaces[idx] = path->len_namespaces[idx + 1];
idx++;
}
path->num_namespaces--;
return S_OK;
} }
static HRESULT WINAPI path_RemoveAllNamespaces( static HRESULT WINAPI path_RemoveAllNamespaces(

View File

@ -586,6 +586,10 @@ static void test_IWbemPath_GetNamespaceAt(void)
static void test_IWbemPath_RemoveAllNamespaces(void) static void test_IWbemPath_RemoveAllNamespaces(void)
{ {
static const ULONGLONG expected_flags =
WBEMPATH_INFO_ANON_LOCAL_MACHINE | WBEMPATH_INFO_IS_INST_REF |
WBEMPATH_INFO_HAS_SUBSCOPES | WBEMPATH_INFO_V2_COMPLIANT |
WBEMPATH_INFO_CIM_COMPLIANT | WBEMPATH_INFO_PATH_HAD_SERVER;
IWbemPath *path; IWbemPath *path;
WCHAR buf[16]; WCHAR buf[16];
ULONG len; ULONG len;
@ -603,9 +607,7 @@ static void test_IWbemPath_RemoveAllNamespaces(void)
flags = 0; flags = 0;
hr = IWbemPath_GetInfo( path, 0, &flags ); hr = IWbemPath_GetInfo( path, 0, &flags );
ok( hr == S_OK, "got %08x\n", hr ); ok( hr == S_OK, "got %08x\n", hr );
ok( flags == (WBEMPATH_INFO_ANON_LOCAL_MACHINE | WBEMPATH_INFO_IS_INST_REF | ok( flags == expected_flags,
WBEMPATH_INFO_HAS_SUBSCOPES | WBEMPATH_INFO_V2_COMPLIANT |
WBEMPATH_INFO_CIM_COMPLIANT | WBEMPATH_INFO_PATH_HAD_SERVER),
"got %lx%08lx\n", (unsigned long)(flags >> 32), (unsigned long)flags ); "got %lx%08lx\n", (unsigned long)(flags >> 32), (unsigned long)flags );
hr = IWbemPath_RemoveAllNamespaces( path ); hr = IWbemPath_RemoveAllNamespaces( path );
@ -614,9 +616,7 @@ static void test_IWbemPath_RemoveAllNamespaces(void)
flags = 0; flags = 0;
hr = IWbemPath_GetInfo( path, 0, &flags ); hr = IWbemPath_GetInfo( path, 0, &flags );
ok( hr == S_OK, "got %08x\n", hr ); ok( hr == S_OK, "got %08x\n", hr );
ok( flags == (WBEMPATH_INFO_ANON_LOCAL_MACHINE | WBEMPATH_INFO_IS_INST_REF | ok( flags == expected_flags,
WBEMPATH_INFO_HAS_SUBSCOPES | WBEMPATH_INFO_V2_COMPLIANT |
WBEMPATH_INFO_CIM_COMPLIANT | WBEMPATH_INFO_PATH_HAD_SERVER),
"got %lx%08lx\n", (unsigned long)(flags >> 32), (unsigned long)flags ); "got %lx%08lx\n", (unsigned long)(flags >> 32), (unsigned long)flags );
buf[0] = 0; buf[0] = 0;
@ -627,6 +627,81 @@ static void test_IWbemPath_RemoveAllNamespaces(void)
IWbemPath_Release( path ); IWbemPath_Release( path );
} }
static void test_IWbemPath_RemoveNamespaceAt(void)
{
static const ULONGLONG expected_flags =
WBEMPATH_INFO_ANON_LOCAL_MACHINE | WBEMPATH_INFO_IS_INST_REF |
WBEMPATH_INFO_HAS_SUBSCOPES | WBEMPATH_INFO_V2_COMPLIANT |
WBEMPATH_INFO_CIM_COMPLIANT | WBEMPATH_INFO_PATH_HAD_SERVER;
static const WCHAR cimv2W[] = {'c','i','m','v','2',0};
IWbemPath *path;
WCHAR buf[16];
ULONG len, count;
ULONGLONG flags;
HRESULT hr;
if (!(path = create_path())) return;
hr = IWbemPath_RemoveNamespaceAt( path, 0 );
ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
hr = IWbemPath_SetText( path, WBEMPATH_CREATE_ACCEPT_ALL, path17 );
ok( hr == S_OK, "got %08x\n", hr );
flags = 0;
hr = IWbemPath_GetInfo( path, 0, &flags );
ok( hr == S_OK, "got %08x\n", hr );
ok( flags == expected_flags,
"got %lx%08lx\n", (unsigned long)(flags >> 32), (unsigned long)flags );
count = 0xdeadbeef;
hr = IWbemPath_GetNamespaceCount( path, &count );
ok( hr == S_OK, "got %08x\n", hr );
ok( count == 2, "got %u\n", count );
hr = IWbemPath_RemoveNamespaceAt( path, 0 );
ok( hr == S_OK, "got %08x\n", hr );
flags = 0;
hr = IWbemPath_GetInfo( path, 0, &flags );
ok( hr == S_OK, "got %08x\n", hr );
ok( flags == expected_flags,
"got %lx%08lx\n", (unsigned long)(flags >> 32), (unsigned long)flags );
count = 0xdeadbeef;
hr = IWbemPath_GetNamespaceCount( path, &count );
ok( hr == S_OK, "got %08x\n", hr );
ok( count == 1, "got %u\n", count );
buf[0] = 0;
len = sizeof(buf) / sizeof(buf[0]);
hr = IWbemPath_GetNamespaceAt( path, 0, &len, buf );
ok( hr == S_OK, "got %08x\n", hr );
ok( !lstrcmpW( buf, cimv2W ), "unexpected buffer contents %s\n", wine_dbgstr_w(buf) );
ok( len == lstrlenW( cimv2W ) + 1, "unexpected length %u\n", len );
hr = IWbemPath_RemoveNamespaceAt( path, 0 );
ok( hr == S_OK, "got %08x\n", hr );
flags = 0;
hr = IWbemPath_GetInfo( path, 0, &flags );
ok( hr == S_OK, "got %08x\n", hr );
ok( flags == expected_flags,
"got %lx%08lx\n", (unsigned long)(flags >> 32), (unsigned long)flags );
count = 0xdeadbeef;
hr = IWbemPath_GetNamespaceCount( path, &count );
ok( hr == S_OK, "got %08x\n", hr );
ok( !count, "got %u\n", count );
buf[0] = 0;
len = sizeof(buf) / sizeof(buf[0]);
hr = IWbemPath_GetNamespaceAt( path, 0, &len, buf );
ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
IWbemPath_Release( path );
}
START_TEST (path) START_TEST (path)
{ {
CoInitialize( NULL ); CoInitialize( NULL );
@ -640,6 +715,7 @@ START_TEST (path)
test_IWbemPath_SetServer(); test_IWbemPath_SetServer();
test_IWbemPath_GetNamespaceAt(); test_IWbemPath_GetNamespaceAt();
test_IWbemPath_RemoveAllNamespaces(); test_IWbemPath_RemoveAllNamespaces();
test_IWbemPath_RemoveNamespaceAt();
CoUninitialize(); CoUninitialize();
} }