[gxml] Disable TNode tests to avoid warnings
- From: Daniel Espinosa Ortiz <despinosa src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gxml] Disable TNode tests to avoid warnings
- Date: Wed, 22 Aug 2018 15:10:15 +0000 (UTC)
commit 73e9ddfd74fdc961321575d1363f76eaf8fee389
Author: Daniel Espinosa <esodan gmail com>
Date: Tue Aug 21 17:59:39 2018 -0500
Disable TNode tests to avoid warnings
configure.ac | 7 ++
gxml/Makefile.am | 1 +
gxml/TreeWalker.vala | 158 +++++++++++++++++++++++++++++++++++++++++++++
test/GXmlTest.vala | 9 ++-
test/Makefile.am | 37 ++++++-----
test/gxml-performance.vala | 2 -
6 files changed, 193 insertions(+), 21 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 52044c4..e4fc641 100644
--- a/configure.ac
+++ b/configure.ac
@@ -219,6 +219,13 @@ AC_ARG_ENABLE(performance-tests,
AM_CONDITIONAL(ENABLE_PERFORMANCE_TESTS, [test $performance = yes])
+
+tnode_tests=no
+AC_ARG_ENABLE(test_tnode,
+ AS_HELP_STRING([--enable-test-tnode], [Enable Tests for deprecated TNode classes [default=no]]),
+ [docs=$enableval], [docs="no"])
+AM_CONDITIONAL([ENABLE_TNODE_TESTS], [test x$tnode_tests = xyes])
+
dnl Check Cross Compile
dnl ******************************
dnl Check for Operating System
diff --git a/gxml/Makefile.am b/gxml/Makefile.am
index 861d841..3f830d9 100644
--- a/gxml/Makefile.am
+++ b/gxml/Makefile.am
@@ -12,6 +12,7 @@ BUILT_SOURCES=
# Vala source code
sources = \
+ Collections.vala \
CssSelectorParser.vala \
gxml-init.vala \
namespace-info.vala \
diff --git a/gxml/TreeWalker.vala b/gxml/TreeWalker.vala
new file mode 100644
index 0000000..a0d42ca
--- /dev/null
+++ b/gxml/TreeWalker.vala
@@ -0,0 +1,158 @@
+/* -*- Mode: vala; indent-tabs-mode: nil; c-basic-offset: 2; tab-width: 2 -*- */
+/* GDocument.vala
+ *
+ * Copyright (C) 2018 Daniel Espinosa <esodan gmail com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors:
+ * Daniel Espinosa <esodan gmail com>
+ */
+
+
+[Version (since = "0.18")]
+public class GXml.TreeWalker : Object, GXml.DomTreeWalker {
+ protected DomNode _root;
+ protected int _what_to_show;
+ protected DomNodeFilter? _filter;
+ protected DomNode _current_node = null;
+
+ public DomNode root { get { return root; } }
+ public int what_to_show { get { return _what_to_show; } }
+ public DomNodeFilter? filter { get { return _filter; } }
+ public DomNode current_node { get { return _current_node; } }
+
+ public TreeWalker (DomNode root, DomNode current, int w, DomNodeFilter? filter) {
+ _root = root;
+ _what_to_show = w;
+ _filter = filter;
+ _current_node = current;
+ }
+
+ public DomNode? parent_node() {
+ if (current_node == null) return null;
+ var p = current_node.parent_node;
+ if (p == null) return null;
+ if (_filter != null) {
+ if (_filter.accept_node (p) != DomNodeFilter.FILTER_ACCEPT) return null;
+ }
+ if (p == root) return null;
+ _current_node = p;
+ return _current_node;
+ }
+ public DomNode? first_child () {
+ return traverse (true);
+ }
+ public DomNode? last_child () {
+ return traverse (false);
+ }
+ public DomNode? previous_sibling () {
+ return traverse_sibling (false);
+ }
+ public DomNode? next_sibling () {
+ return traverse_sibling (true);
+ }
+ public DomNode? previous_node () { return null; }// FIXME
+ public DomNode? next_node () { return null; }// FIXME
+
+ private DomNode? traverse (bool first) {
+ if (current_node == null) return null;
+ DomNode n = null;
+ if (first) {
+ n = current_node.first_child;
+ } else {
+ n = current_node.last_child;
+ }
+ if¡ (n == null) return null;
+ while (n != null) {
+ var res = DomNodeFilter.FILTER_ACCEPT
+ if (_filter != null) {
+ res = _filter.accept_node (n);
+ }
+ if (res == DomNodeFilter.FILTER_ACCEPT) {
+ _current_node = n;
+ return _current_node;
+ }
+ if (res == DomNodeFilter.FILTER_SKIP) {
+ DomNode c = null;
+ if (first) {
+ c = n.first_child;
+ } else {
+ c = n.last_child;
+ }
+ if (c != null) {
+ n = c;
+ continue;
+ }
+ DomNode s = null;
+ if (first) {
+ s = n.next_sibling;
+ } else {
+ s = n.previous_sibling;
+ }
+ if (s != null) {
+ n = s;
+ continue;
+ }
+ if (n.parent_node == null
+ || n.parent_node == root
+ || n.parent_node == current_node) {
+ return null;
+ } else {
+ n = n.parent_node;
+ }
+ }
+ }
+ return null;
+ }
+ private DomNode? traverse_sibling (bool next) {
+ if (current_node == null) return null;
+ if (current_node == root) return null;
+ DomNode s = null;
+ if (next) {
+ s = current_node.next_sibling;
+ } else {
+ s = current_node.previous_sibling;
+ }
+ DomNode n = s;
+ while (n != null) {
+ var res = DomNodeFilter.FILTER_ACCEPT;
+ if (_filter != null) {
+ res = _filter.accept_node (n);
+ }
+ if (res == DomNodeFilter.FILTER_ACCEPT) {
+ _current_node = n;
+ return _current_node;
+ }
+ DomNode c = null;
+ if (next) {
+ c = n.first_child;
+ } else {
+ c = n.last_child;
+ }
+ if (res == DomNodeFilter.FILTER_REJECT || c == null) {
+ if (next) {
+ s = n.next_sibling;
+ } else {
+ s = n.previous_sibling;
+ }
+ }
+ n = n.parent_node;
+ if (n == null || n == root) return null;
+ if (_filter != null) {
+ if (_filter.accept_node (n) == DomNodeFilter.FILTER_ACCEPT) return null;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/test/GXmlTest.vala b/test/GXmlTest.vala
index 313c1fb..9be4077 100644
--- a/test/GXmlTest.vala
+++ b/test/GXmlTest.vala
@@ -29,9 +29,8 @@ class GXmlTest {
// Sets 29 as fatal flags, 16 + 8 + 4 + 1; bits 0,2,3,4, recursion,error,critical,warning;
we'll want to undo that warning one so we can catch it
Test.init (ref args);
-
+#if ENABLE_TNODE_TESTS
NodeListTest.add_tests ();
- ValaLibxml2Test.add_tests ();
SerializableTest.add_tests ();
SerializableObjectModelTest.add_tests ();
SerializableObjectModelTDocumentTest.add_tests ();
@@ -43,7 +42,6 @@ class GXmlTest {
SerializableGeeCollectionsTDocumentTest.add_tests ();
SerializableBasicTypeTest.add_tests ();
SerializableEnumerationTest.add_tests ();
- Performance.add_tests ();
TElementTest.add_tests ();
TCDATATest.add_tests ();
TCommentTest.add_tests ();
@@ -55,6 +53,11 @@ class GXmlTest {
SerializablePropertyIntTest.add_tests ();
SerializablePropertyValueListTest.add_tests ();
SerializablePropertyEnumTest.add_tests ();
+#if ENABLE_PERFORMANCE_TESTS
+ Performance.add_tests ();
+#endif
+#endif
+ ValaLibxml2Test.add_tests ();
GDocumentTest.add_tests ();
GElementTest.add_tests ();
GAttributeTest.add_tests ();
diff --git a/test/Makefile.am b/test/Makefile.am
index cdfcb32..7188445 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -30,7 +30,27 @@ sources = \
GXmlTest.vala \
NodeListTest.vala \
ValaLibxml2Test.vala \
+ GDocumentTest.vala \
+ GElementTest.vala \
+ GAttributeTest.vala \
+ GHtmlDocumentTest.vala \
+ DomGDocumentTest.vala \
+ XPathTest.vala \
+ GomDocumentTest.vala \
+ GomElementTest.vala \
+ GomSerializationTest.vala \
+ GomSchemaTest.vala \
+ $(NULL)
+
+if ENABLE_TNODE_TESTS
+sources += \
EnumerationTest.vala \
+ gxml-performance.vala \
+ TElementTest.vala \
+ TDocumentTest.vala \
+ TCDATATest.vala \
+ TCommentTest.vala \
+ TProcessingInstructionTest.vala \
SerializableTest.vala \
SerializablePropertyBoolTest.vala \
SerializablePropertyDoubleTest.vala \
@@ -47,23 +67,8 @@ sources = \
SerializableGeeCollectionsTest.vala \
SerializableGeeCollections-TDocument-Test.vala \
SerializableBasicTypesTest.vala \
- gxml-performance.vala \
- TElementTest.vala \
- TDocumentTest.vala \
- TCDATATest.vala \
- TCommentTest.vala \
- TProcessingInstructionTest.vala \
- GDocumentTest.vala \
- GElementTest.vala \
- GAttributeTest.vala \
- GHtmlDocumentTest.vala \
- DomGDocumentTest.vala \
- XPathTest.vala \
- GomDocumentTest.vala \
- GomElementTest.vala \
- GomSerializationTest.vala \
- GomSchemaTest.vala \
$(NULL)
+endif
vala-stamp: $(sources)
@rm -f vala-temp
diff --git a/test/gxml-performance.vala b/test/gxml-performance.vala
index ae8dac3..ec24b55 100644
--- a/test/gxml-performance.vala
+++ b/test/gxml-performance.vala
@@ -235,7 +235,6 @@ public class Performance
}
public static void add_tests ()
{
-#if ENABLE_PERFORMANCE_TESTS
Test.add_func ("/gxml/performance/read/gomdocument",
() => {
try {
@@ -1003,6 +1002,5 @@ public class Performance
assert_not_reached ();
}
});
-#endif
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]