Hans Leidekker : wmiutils: Implement IWbemPath::RemoveNamespaceAt.
Alexandre Julliard
julliard at winehq.org
Thu Jan 17 14:48:50 CST 2013
Module: wine
Branch: master
Commit: 9548eb79ad87782cf04a2d3bd86d1c4b0eecdb32
URL: http://source.winehq.org/git/wine.git/?a=commit;h=9548eb79ad87782cf04a2d3bd86d1c4b0eecdb32
Author: Hans Leidekker <hans at codeweavers.com>
Date: Thu Jan 17 15:30:44 2013 +0100
wmiutils: Implement IWbemPath::RemoveNamespaceAt.
---
dlls/wmiutils/path.c | 18 +++++++-
dlls/wmiutils/tests/path.c | 88 +++++++++++++++++++++++++++++++++++++++++---
2 files changed, 97 insertions(+), 9 deletions(-)
diff --git a/dlls/wmiutils/path.c b/dlls/wmiutils/path.c
index 3f74389..73c1c62 100644
--- a/dlls/wmiutils/path.c
+++ b/dlls/wmiutils/path.c
@@ -525,10 +525,22 @@ static HRESULT WINAPI path_GetNamespaceAt(
static HRESULT WINAPI path_RemoveNamespaceAt(
IWbemPath *iface,
- ULONG uIndex)
+ ULONG idx)
{
- FIXME("%p, %u\n", iface, uIndex);
- return E_NOTIMPL;
+ struct path *path = impl_from_IWbemPath( iface );
+
+ 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(
diff --git a/dlls/wmiutils/tests/path.c b/dlls/wmiutils/tests/path.c
index 8441d86..049d9b3 100644
--- a/dlls/wmiutils/tests/path.c
+++ b/dlls/wmiutils/tests/path.c
@@ -586,6 +586,10 @@ static void test_IWbemPath_GetNamespaceAt(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;
WCHAR buf[16];
ULONG len;
@@ -603,9 +607,7 @@ static void test_IWbemPath_RemoveAllNamespaces(void)
flags = 0;
hr = IWbemPath_GetInfo( path, 0, &flags );
ok( hr == S_OK, "got %08x\n", hr );
- ok( 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),
+ ok( flags == expected_flags,
"got %lx%08lx\n", (unsigned long)(flags >> 32), (unsigned long)flags );
hr = IWbemPath_RemoveAllNamespaces( path );
@@ -614,9 +616,7 @@ static void test_IWbemPath_RemoveAllNamespaces(void)
flags = 0;
hr = IWbemPath_GetInfo( path, 0, &flags );
ok( hr == S_OK, "got %08x\n", hr );
- ok( 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),
+ ok( flags == expected_flags,
"got %lx%08lx\n", (unsigned long)(flags >> 32), (unsigned long)flags );
buf[0] = 0;
@@ -627,6 +627,81 @@ static void test_IWbemPath_RemoveAllNamespaces(void)
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)
{
CoInitialize( NULL );
@@ -640,6 +715,7 @@ START_TEST (path)
test_IWbemPath_SetServer();
test_IWbemPath_GetNamespaceAt();
test_IWbemPath_RemoveAllNamespaces();
+ test_IWbemPath_RemoveNamespaceAt();
CoUninitialize();
}
More information about the wine-cvs
mailing list