msxml3[3/4]: for queries the get_item should change the current position

Mikołaj Zalewski mikolaj at zalewski.pl
Fri May 11 10:48:37 CDT 2007


Another small differance between node lists from childNodes and from 
queries.
-------------- next part --------------
From 8c2eb0e7998d764251e5718ae5fc8616c06dcde4 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Miko=C5=82aj_Zalewski?= <mikolaj at zalewski.pl>
Date: Fri, 11 May 2007 17:04:43 +0200
Subject: [PATCH] msxml3: for queries the get_item should change the current position

---
 dlls/msxml3/queryresult.c  |    1 +
 dlls/msxml3/tests/domdoc.c |   27 ++++++++++++++++++++++++++-
 2 files changed, 27 insertions(+), 1 deletions(-)

diff --git a/dlls/msxml3/queryresult.c b/dlls/msxml3/queryresult.c
index 75ca2c8..a5b34a2 100644
--- a/dlls/msxml3/queryresult.c
+++ b/dlls/msxml3/queryresult.c
@@ -220,6 +220,7 @@ static HRESULT WINAPI queryresult_get_item(
         return S_FALSE;
 
     *listItem = create_node(This->result->nodesetval->nodeTab[index]);
+    This->resultPos = index + 1;
 
     return S_OK;
 }
diff --git a/dlls/msxml3/tests/domdoc.c b/dlls/msxml3/tests/domdoc.c
index 2cee379..1a97442 100644
--- a/dlls/msxml3/tests/domdoc.c
+++ b/dlls/msxml3/tests/domdoc.c
@@ -322,6 +322,8 @@ static char *list_to_string(IXMLDOMNodeList *list)
     *pos = 0;
     return buf;
 }
+
+#define expect_node(node, expstr) { char str[4096]; node_to_string(node, str); ok(strcmp(str, expstr)==0, "Invalid node: %s, exptected %s\n", str, expstr); }
 #define expect_list_and_release(list, expstr) { char *str = list_to_string(list); ok(strcmp(str, expstr)==0, "Invalid node list: %s, exptected %s\n", str, expstr); if (list) IXMLDOMNodeList_Release(list); }
 
 static void test_domdoc( void )
@@ -759,11 +761,25 @@ todo_wine
     if (map)
         IXMLDOMNamedNodeMap_Release( map );
 
-    /* now traverse the tree from the root node */
+    /* now traverse the tree from the root element */
     if (element)
     {
+        IXMLDOMNode *node;
         r = IXMLDOMNode_get_childNodes( element, &list );
         ok( r == S_OK, "get_childNodes returned wrong code\n");
+
+        /* using get_item for child list doesn't advance the position */
+        ole_check(IXMLDOMNodeList_get_item(list, 1, &node));
+        expect_node(node, "E2.E2.D1");
+        IXMLDOMNode_Release(node);
+        ole_check(IXMLDOMNodeList_nextNode(list, &node));
+        expect_node(node, "E1.E2.D1");
+        IXMLDOMNode_Release(node);
+        ole_check(IXMLDOMNodeList_reset(list));
+
+        IXMLDOMNodeList_AddRef(list);
+        expect_list_and_release(list, "E1.E2.D1 E2.E2.D1 E3.E2.D1 E4.E2.D1");
+        ole_check(IXMLDOMNodeList_reset(list));
     }
     else
         ok( FALSE, "no element\n");
@@ -1448,6 +1464,7 @@ static void test_XPath()
     IXMLDOMDocument2 *doc;
     IXMLDOMNode *rootNode;
     IXMLDOMNode *elem1Node;
+    IXMLDOMNode *node;
     IXMLDOMNodeList *list;
 
     r = CoCreateInstance( &CLSID_DOMDocument, NULL,
@@ -1476,6 +1493,14 @@ static void test_XPath()
     expect_list_and_release(list, "E3.E2.E2.D1");
 
     ole_check(IXMLDOMNode_selectNodes(rootNode, _bstr_("elem"), &list));
+    /* using get_item for query results advances the position */
+    ole_check(IXMLDOMNodeList_get_item(list, 1, &node));
+    expect_node(node, "E2.E2.D1");
+    IXMLDOMNode_Release(node);
+    ole_check(IXMLDOMNodeList_nextNode(list, &node));
+    expect_node(node, "E4.E2.D1");
+    IXMLDOMNode_Release(node);
+    ole_check(IXMLDOMNodeList_reset(list));
     expect_list_and_release(list, "E1.E2.D1 E2.E2.D1 E4.E2.D1");
 
     ole_check(IXMLDOMNode_selectNodes(rootNode, _bstr_("."), &list));
-- 
1.4.4.2


More information about the wine-patches mailing list