[XMLLITE_WINETEST]
authorAmine Khaldi <amine.khaldi@reactos.org>
Sat, 28 Sep 2013 15:43:21 +0000 (15:43 +0000)
committerAmine Khaldi <amine.khaldi@reactos.org>
Sat, 28 Sep 2013 15:43:21 +0000 (15:43 +0000)
* Sync with Wine 1.7.1.
CORE-7469

svn path=/trunk/; revision=60440

rostests/winetests/xmllite/CMakeLists.txt
rostests/winetests/xmllite/reader.c

index 91e6f98..7bb8b28 100644 (file)
@@ -1,19 +1,10 @@
 
-add_definitions(-D__ROS_LONG64__)
-
 list(APPEND SOURCE
     reader.c
     writer.c
     testlist.c)
 
-if(NOT MSVC)
-    # FIXME: http://www.cmake.org/Bug/view.php?id=12998
-    #allow_warnings(xmllite_winetest)
-    set_source_files_properties(${SOURCE} PROPERTIES COMPILE_FLAGS "-Wno-error")
-endif()
-
 add_executable(xmllite_winetest ${SOURCE})
-target_link_libraries(xmllite_winetest wine uuid)
 set_module_type(xmllite_winetest win32cui)
-add_importlibs(xmllite_winetest xmllite ole32 msvcrt kernel32 ntdll)
+add_importlibs(xmllite_winetest ole32 msvcrt kernel32)
 add_cd_file(TARGET xmllite_winetest DESTINATION reactos/bin FOR all)
index c205539..ed3d6e1 100644 (file)
@@ -747,7 +747,6 @@ static void test_read_xmldeclaration(void)
 
     hr = IXmlReader_GetDepth(reader, &count);
     ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
-todo_wine
     ok(count == 1, "Expected 1, got %d\n", count);
 
     hr = IXmlReader_MoveToElement(reader);
@@ -776,6 +775,7 @@ struct test_entry {
     const char *value;
     HRESULT hr;
     HRESULT hr_broken; /* this is set to older version results */
+    int todo : 1;
 };
 
 static struct test_entry comment_tests[] = {
@@ -1053,18 +1053,16 @@ static void test_read_dtd(void)
     str = NULL;
     hr = IXmlReader_GetLocalName(reader, &str, &len);
     ok(hr == S_OK, "got 0x%08x\n", hr);
-todo_wine {
     ok(len == lstrlenW(sysW), "got %u\n", len);
     ok(!lstrcmpW(str, sysW), "got %s\n", wine_dbgstr_w(str));
-}
+
     len = 0;
     str = NULL;
     hr = IXmlReader_GetValue(reader, &str, &len);
     ok(hr == S_OK, "got 0x%08x\n", hr);
-todo_wine {
     ok(len == lstrlenW(sysvalW), "got %u\n", len);
     ok(!lstrcmpW(str, sysvalW), "got %s\n", wine_dbgstr_w(str));
-}
+
     hr = IXmlReader_MoveToElement(reader);
     ok(hr == S_OK, "got 0x%08x\n", hr);
 
@@ -1072,9 +1070,10 @@ todo_wine {
     str = NULL;
     hr = IXmlReader_GetLocalName(reader, &str, &len);
     ok(hr == S_OK, "got 0x%08x\n", hr);
+todo_wine {
     ok(len == lstrlenW(dtdnameW), "got %u\n", len);
     ok(!lstrcmpW(str, dtdnameW), "got %s\n", wine_dbgstr_w(str));
-
+}
     len = 0;
     str = NULL;
     hr = IXmlReader_GetQualifiedName(reader, &str, &len);
@@ -1170,16 +1169,20 @@ static void test_read_element(void)
     ok(hr == S_OK, "got %08x\n", hr);
     ok(depth == 0, "got %d\n", depth);
 
+    type = XmlNodeType_None;
     hr = IXmlReader_Read(reader, &type);
     ok(hr == S_OK, "got %08x\n", hr);
+    ok(type == XmlNodeType_Element, "got %d\n", type);
 
     depth = 1;
     hr = IXmlReader_GetDepth(reader, &depth);
     ok(hr == S_OK, "got %08x\n", hr);
     ok(depth == 0, "got %d\n", depth);
 
+    type = XmlNodeType_None;
     hr = IXmlReader_Read(reader, &type);
     ok(hr == S_OK, "got %08x\n", hr);
+    ok(type == XmlNodeType_Element, "got %d\n", type);
 
     depth = 0;
     hr = IXmlReader_GetDepth(reader, &depth);
@@ -1322,6 +1325,9 @@ static void test_readvaluechunk(void)
 static struct test_entry cdata_tests[] = {
     { "<a><![CDATA[ ]]data ]]></a>", "", " ]]data ", S_OK },
     { "<a><![CDATA[<![CDATA[ data ]]]]></a>", "", "<![CDATA[ data ]]", S_OK },
+    { "<a><![CDATA[\n \r\n \n\n ]]></a>", "", "\n \n \n\n ", S_OK, S_OK, 1 },
+    { "<a><![CDATA[\r \r\r\n \n\n ]]></a>", "", "\n \n\n \n\n ", S_OK, S_OK, 1 },
+    { "<a><![CDATA[\r\r \n\r \r \n\n ]]></a>", "", "\n\n \n\n \n \n\n ", S_OK },
     { NULL }
 };
 
@@ -1365,15 +1371,122 @@ static void test_read_cdata(void)
 
             ok(type == XmlNodeType_CDATA, "got %d for %s\n", type, test->xml);
 
+            str_exp = a2w(test->name);
+
             len = 1;
             str = NULL;
             hr = IXmlReader_GetLocalName(reader, &str, &len);
             ok(hr == S_OK, "got 0x%08x\n", hr);
             ok(len == strlen(test->name), "got %u\n", len);
+            ok(!lstrcmpW(str, str_exp), "got %s\n", wine_dbgstr_w(str));
+
+            str = NULL;
+            hr = IXmlReader_GetLocalName(reader, &str, NULL);
+            ok(hr == S_OK, "got 0x%08x\n", hr);
+            ok(!lstrcmpW(str, str_exp), "got %s\n", wine_dbgstr_w(str));
+
+            free_str(str_exp);
+
+            len = 1;
+            str = NULL;
+            hr = IXmlReader_GetQualifiedName(reader, &str, &len);
+            ok(hr == S_OK, "got 0x%08x\n", hr);
+            ok(len == strlen(test->name), "got %u\n", len);
             str_exp = a2w(test->name);
             ok(!lstrcmpW(str, str_exp), "got %s\n", wine_dbgstr_w(str));
             free_str(str_exp);
 
+            /* value */
+            len = 1;
+            str = NULL;
+            hr = IXmlReader_GetValue(reader, &str, &len);
+            ok(hr == S_OK, "got 0x%08x\n", hr);
+
+            str_exp = a2w(test->value);
+            if (test->todo)
+            {
+            todo_wine {
+                ok(len == strlen(test->value), "got %u\n", len);
+                ok(!lstrcmpW(str, str_exp), "got %s\n", wine_dbgstr_w(str));
+            }
+            }
+            else
+            {
+                ok(len == strlen(test->value), "got %u\n", len);
+                ok(!lstrcmpW(str, str_exp), "got %s\n", wine_dbgstr_w(str));
+            }
+            free_str(str_exp);
+        }
+
+        IStream_Release(stream);
+        test++;
+    }
+
+    IXmlReader_Release(reader);
+}
+
+static struct test_entry text_tests[] = {
+    { "<a>simple text</a>", "", "simple text", S_OK },
+    { "<a>text ]]> text</a>", "", "", WC_E_CDSECTEND },
+    { NULL }
+};
+
+static void test_read_text(void)
+{
+    struct test_entry *test = text_tests;
+    IXmlReader *reader;
+    HRESULT hr;
+
+    hr = pCreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
+    ok(hr == S_OK, "S_OK, got %08x\n", hr);
+
+    while (test->xml)
+    {
+        XmlNodeType type;
+        IStream *stream;
+
+        stream = create_stream_on_data(test->xml, strlen(test->xml)+1);
+        hr = IXmlReader_SetInput(reader, (IUnknown*)stream);
+        ok(hr == S_OK, "got %08x\n", hr);
+
+        type = XmlNodeType_None;
+        hr = IXmlReader_Read(reader, &type);
+
+        /* read one more to get to CDATA */
+        if (type == XmlNodeType_Element)
+        {
+            type = XmlNodeType_None;
+            hr = IXmlReader_Read(reader, &type);
+        }
+
+        if (test->hr_broken)
+            ok(hr == test->hr || broken(hr == test->hr_broken), "got %08x for %s\n", hr, test->xml);
+        else
+            ok(hr == test->hr, "got %08x for %s\n", hr, test->xml);
+        if (hr == S_OK)
+        {
+            const WCHAR *str;
+            WCHAR *str_exp;
+            UINT len;
+
+            ok(type == XmlNodeType_Text, "got %d for %s\n", type, test->xml);
+
+            str_exp = a2w(test->name);
+
+            len = 1;
+            str = NULL;
+            hr = IXmlReader_GetLocalName(reader, &str, &len);
+            ok(hr == S_OK, "got 0x%08x\n", hr);
+            ok(len == strlen(test->name), "got %u\n", len);
+            ok(!lstrcmpW(str, str_exp), "got %s\n", wine_dbgstr_w(str));
+
+            str = NULL;
+            hr = IXmlReader_GetLocalName(reader, &str, NULL);
+            ok(hr == S_OK, "got 0x%08x\n", hr);
+            ok(!lstrcmpW(str, str_exp), "got %s\n", wine_dbgstr_w(str));
+
+            free_str(str_exp);
+
             len = 1;
             str = NULL;
             hr = IXmlReader_GetQualifiedName(reader, &str, &len);
@@ -1383,6 +1496,159 @@ static void test_read_cdata(void)
             ok(!lstrcmpW(str, str_exp), "got %s\n", wine_dbgstr_w(str));
             free_str(str_exp);
 
+            /* value */
+            len = 1;
+            str = NULL;
+            hr = IXmlReader_GetValue(reader, &str, &len);
+            ok(hr == S_OK, "got 0x%08x\n", hr);
+
+            str_exp = a2w(test->value);
+            if (test->todo)
+            {
+            todo_wine {
+                ok(len == strlen(test->value), "got %u\n", len);
+                ok(!lstrcmpW(str, str_exp), "got %s\n", wine_dbgstr_w(str));
+            }
+            }
+            else
+            {
+                ok(len == strlen(test->value), "got %u\n", len);
+                ok(!lstrcmpW(str, str_exp), "got %s\n", wine_dbgstr_w(str));
+            }
+            free_str(str_exp);
+        }
+
+        IStream_Release(stream);
+        test++;
+    }
+
+    IXmlReader_Release(reader);
+}
+
+struct test_entry_empty {
+    const char *xml;
+    BOOL empty;
+};
+
+static struct test_entry_empty empty_element_tests[] = {
+    { "<a></a>", FALSE },
+    { "<a/>", TRUE },
+    { NULL }
+};
+
+static void test_isemptyelement(void)
+{
+    struct test_entry_empty *test = empty_element_tests;
+    IXmlReader *reader;
+    HRESULT hr;
+
+    hr = pCreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
+    ok(hr == S_OK, "S_OK, got %08x\n", hr);
+
+    while (test->xml)
+    {
+        XmlNodeType type;
+        IStream *stream;
+        BOOL ret;
+
+        stream = create_stream_on_data(test->xml, strlen(test->xml)+1);
+        hr = IXmlReader_SetInput(reader, (IUnknown*)stream);
+        ok(hr == S_OK, "got %08x\n", hr);
+
+        type = XmlNodeType_None;
+        hr = IXmlReader_Read(reader, &type);
+        ok(hr == S_OK, "got 0x%08x\n", hr);
+        ok(type == XmlNodeType_Element, "got %d\n", type);
+
+        ret = IXmlReader_IsEmptyElement(reader);
+        ok(ret == test->empty, "got %d, expected %d. xml=%s\n", ret, test->empty, test->xml);
+
+        IStream_Release(stream);
+        test++;
+    }
+
+    IXmlReader_Release(reader);
+}
+
+static struct test_entry attributes_tests[] = {
+    { "<a attr1=\"attrvalue\"/>", "attr1", "attrvalue", S_OK },
+    { "<a attr1=\"a\'\'ttrvalue\"/>", "attr1", "a\'\'ttrvalue", S_OK },
+    { "<a attr1=\'a\"ttrvalue\'/>", "attr1", "a\"ttrvalue", S_OK },
+    { "<a attr1=\' \'/>", "attr1", " ", S_OK },
+    { "<a attr1=\" \"/>", "attr1", " ", S_OK },
+    { "<a attr1=\"\r\n \r \n \t\n\r\"/>", "attr1", "         ", S_OK },
+    { "<a attr1=\" val \"/>", "attr1", " val ", S_OK },
+    { "<a attr1=\"\r\n\tval\n\"/>", "attr1", "  val ", S_OK },
+    { "<a attr1=\"val&#32;\"/>", "attr1", "val ", S_OK },
+    { "<a attr1=\"val&#x20;\"/>", "attr1", "val ", S_OK },
+    { "<a attr1=\"&lt;&gt;&amp;&apos;&quot;\"/>", "attr1", "<>&\'\"", S_OK },
+    { "<a attr1=\"&entname;\"/>", NULL, NULL, WC_E_UNDECLAREDENTITY },
+    { "<a attr1=\"val&#xfffe;\"/>", NULL, NULL, WC_E_XMLCHARACTER },
+    { "<a attr1=\"val &#a;\"/>", NULL, NULL, WC_E_DIGIT, WC_E_SEMICOLON },
+    { "<a attr1=\"val &#12a;\"/>", NULL, NULL, WC_E_SEMICOLON },
+    { "<a attr1=\"val &#x12g;\"/>", NULL, NULL, WC_E_SEMICOLON },
+    { "<a attr1=\"val &#xg;\"/>", NULL, NULL, WC_E_HEXDIGIT, WC_E_SEMICOLON },
+    { "<a attr1=attrvalue/>", NULL, NULL, WC_E_QUOTE },
+    { "<a attr1=\"attr<value\"/>", NULL, NULL, WC_E_LESSTHAN },
+    { "<a attr1=\"&entname\"/>", NULL, NULL, WC_E_SEMICOLON },
+    { NULL }
+};
+
+static void test_read_attribute(void)
+{
+    struct test_entry *test = attributes_tests;
+    IXmlReader *reader;
+    HRESULT hr;
+
+    hr = pCreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
+    ok(hr == S_OK, "S_OK, got %08x\n", hr);
+
+    while (test->xml)
+    {
+        XmlNodeType type;
+        IStream *stream;
+
+        stream = create_stream_on_data(test->xml, strlen(test->xml)+1);
+        hr = IXmlReader_SetInput(reader, (IUnknown*)stream);
+        ok(hr == S_OK, "got %08x\n", hr);
+
+        type = XmlNodeType_None;
+        hr = IXmlReader_Read(reader, &type);
+
+        if (test->hr_broken)
+            ok(hr == test->hr || broken(hr == test->hr_broken), "got %08x for %s\n", hr, test->xml);
+        else
+            ok(hr == test->hr, "got %08x for %s\n", hr, test->xml);
+        if (hr == S_OK)
+        {
+            const WCHAR *str;
+            WCHAR *str_exp;
+            UINT len;
+
+            ok(type == XmlNodeType_Element, "got %d for %s\n", type, test->xml);
+
+            hr = IXmlReader_MoveToFirstAttribute(reader);
+            ok(hr == S_OK, "got 0x%08x\n", hr);
+
+            len = 1;
+            str = NULL;
+            hr = IXmlReader_GetLocalName(reader, &str, &len);
+            ok(hr == S_OK, "got 0x%08x\n", hr);
+            ok(len == strlen(test->name), "got %u\n", len);
+            str_exp = a2w(test->name);
+            ok(!lstrcmpW(str, str_exp), "got %s\n", wine_dbgstr_w(str));
+            free_str(str_exp);
+
+            len = 1;
+            str = NULL;
+            hr = IXmlReader_GetQualifiedName(reader, &str, &len);
+            ok(hr == S_OK, "got 0x%08x\n", hr);
+        todo_wine {
+            ok(len == strlen(test->name), "got %u\n", len);
+            str_exp = a2w(test->name);
+            ok(!lstrcmpW(str, str_exp), "got %s\n", wine_dbgstr_w(str));
+            free_str(str_exp);
+        }
             /* value */
             len = 1;
             str = NULL;
@@ -1417,11 +1683,14 @@ START_TEST(reader)
     test_reader_create();
     test_readerinput();
     test_reader_state();
+    test_read_attribute();
     test_read_cdata();
     test_read_comment();
     test_read_pi();
     test_read_dtd();
     test_read_element();
+    test_isemptyelement();
+    test_read_text();
     test_read_full();
     test_read_pending();
     test_readvaluechunk();