[3/5] wmiutils: Implement IWbemPath::RemoveAllNamespaces.

Hans Leidekker hans at codeweavers.com
Thu Jan 17 08:30:17 CST 2013


---
 dlls/wmiutils/path.c       |   14 ++++++++++++--
 dlls/wmiutils/tests/path.c |   44 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 56 insertions(+), 2 deletions(-)

diff --git a/dlls/wmiutils/path.c b/dlls/wmiutils/path.c
index 4e5cd64..3f74389 100644
--- a/dlls/wmiutils/path.c
+++ b/dlls/wmiutils/path.c
@@ -534,8 +534,18 @@ static HRESULT WINAPI path_RemoveNamespaceAt(
 static HRESULT WINAPI path_RemoveAllNamespaces(
     IWbemPath *iface)
 {
-    FIXME("%p\n", iface);
-    return E_NOTIMPL;
+    struct path *path = impl_from_IWbemPath( iface );
+    int i;
+
+    TRACE("%p\n", iface);
+
+    for (i = 0; i < path->num_namespaces; i++) heap_free( path->namespaces[i] );
+    path->num_namespaces = 0;
+    heap_free( path->namespaces );
+    path->namespaces = NULL;
+    heap_free( path->len_namespaces );
+    path->len_namespaces = NULL;
+    return S_OK;
 }
 
 static HRESULT WINAPI path_GetScopeCount(
diff --git a/dlls/wmiutils/tests/path.c b/dlls/wmiutils/tests/path.c
index 9911318..8441d86 100644
--- a/dlls/wmiutils/tests/path.c
+++ b/dlls/wmiutils/tests/path.c
@@ -584,6 +584,49 @@ static void test_IWbemPath_GetNamespaceAt(void)
     IWbemPath_Release( path );
 }
 
+static void test_IWbemPath_RemoveAllNamespaces(void)
+{
+    IWbemPath *path;
+    WCHAR buf[16];
+    ULONG len;
+    ULONGLONG flags;
+    HRESULT hr;
+
+    if (!(path = create_path())) return;
+
+    hr = IWbemPath_RemoveAllNamespaces( path );
+    ok( hr == S_OK, "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 == (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),
+        "got %lx%08lx\n", (unsigned long)(flags >> 32), (unsigned long)flags );
+
+    hr = IWbemPath_RemoveAllNamespaces( path );
+    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 == (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),
+        "got %lx%08lx\n", (unsigned long)(flags >> 32), (unsigned long)flags );
+
+    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 );
@@ -596,6 +639,7 @@ START_TEST (path)
     test_IWbemPath_GetInfo();
     test_IWbemPath_SetServer();
     test_IWbemPath_GetNamespaceAt();
+    test_IWbemPath_RemoveAllNamespaces();
 
     CoUninitialize();
 }
-- 
1.7.10.4







More information about the wine-patches mailing list