summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDodji Seketeli <dodji@src.gnome.org>2003-03-06 22:22:58 +0000
committerDodji Seketeli <dodji@src.gnome.org>2003-03-06 22:22:58 +0000
commitcd1ad798d4a3706f68d0021f46c1cdd587acc0ac (patch)
treefbd0112d96a71c4d312d97d4c50882cdb436c6a8 /tests
parent0477c340c8e20f1d32164f1f193134777ddf3d44 (diff)
downloadlibcroco-cd1ad798d4a3706f68d0021f46c1cdd587acc0ac.tar.gz
went forward in the selectors stuff debugging.
Diffstat (limited to 'tests')
-rw-r--r--tests/test-inputs/test5.1.css5
-rw-r--r--tests/test5-main.c70
2 files changed, 67 insertions, 8 deletions
diff --git a/tests/test-inputs/test5.1.css b/tests/test-inputs/test5.1.css
new file mode 100644
index 0000000..9b7cef8
--- /dev/null
+++ b/tests/test-inputs/test5.1.css
@@ -0,0 +1,5 @@
+E0 {prop0: val0}
+E0+E1{pro1:val1}
+E1 E1-1 {prop2: val2}
+E1 > E1-1 {prop3: val3}
+document E1-1 {prop4: val4} \ No newline at end of file
diff --git a/tests/test5-main.c b/tests/test5-main.c
index 4121596..55fc77b 100644
--- a/tests/test5-main.c
+++ b/tests/test5-main.c
@@ -56,6 +56,11 @@ display_about (char *prg_name) ;
static enum CRStatus
test_sel_eng (guchar * a_file_uri) ;
+static void
+walk_xml_tree_and_lookup_rules (CRSelEng *a_sel_eng,
+ CRStyleSheet *a_sheet,
+ xmlNode *a_node) ;
+
/**
*Displays the usage of the test
*facility.
@@ -69,8 +74,7 @@ display_help (char *prg_name)
g_print ("usage: %s <file-to-parse>\n", prg_name) ;
g_print ("\t <file-to-parse>: the file to parse\n") ;
g_print ("\n\n") ;
- g_print ("Tests the cr_parser_parse () method.\n") ;
- g_print ("Tests the parsing following the css core syntax\n") ;
+ g_print ("Test the selection engine") ;
g_print ("Returns OK if the status is CR_OK, KO otherwise\n") ;
g_print ("\n\n") ;
}
@@ -95,6 +99,58 @@ display_about (char *prg_name)
}
+static void
+walk_xml_tree_and_lookup_rules (CRSelEng *a_sel_eng,
+ CRStyleSheet *a_sheet,
+ xmlNode *a_node)
+{
+ CRStatement **stmts_tab = NULL;
+ gulong tab_len = 0, i= 0 ;
+ enum CRStatus status = CR_OK ;
+
+ xmlNode *cur_node = a_node ;
+
+ for (cur_node = a_node ;cur_node ; cur_node = cur_node->next)
+ {
+ status = cr_sel_eng_sel_get_matched_rulesets
+ (a_sel_eng, a_sheet,
+ cur_node, &stmts_tab, &tab_len) ;
+
+ if (status == CR_OK && tab_len)
+ {
+ g_print ("'''''''''''''''''''''''''\n") ;
+ g_print ("xml start element: %s\n",
+ cur_node->name);
+
+ for (i = 0 ; i < tab_len; i++)
+ {
+ if (stmts_tab[i])
+ {
+ g_print ("\n") ;
+ cr_statement_dump (stmts_tab[i],
+ stdout, 2) ;
+ }
+ }
+ g_print ("xml end element: %s\n",
+ cur_node->name);
+ g_print ("'''''''''''''''''''''''''\n") ;
+
+ if (stmts_tab)
+ {
+ g_free (stmts_tab) ;
+ stmts_tab= NULL ;
+ }
+ }
+
+ if (cur_node->children)
+ {
+ walk_xml_tree_and_lookup_rules
+ (a_sel_eng, a_sheet,
+ cur_node->children) ;
+ }
+ }
+}
+
/**
*The test of the cr_input_read_byte() method.
*Reads the each byte of a_file_uri using the
@@ -113,8 +169,6 @@ test_sel_eng (guchar * a_file_uri)
xmlDoc * xml_doc = NULL ;
xmlNode *cur_node = NULL ;
CRSelEng *selection_engine = NULL ;
- CRStatement **stmts_tab = NULL ;
- gulong tab_len = 0 ;
g_return_val_if_fail (a_file_uri, CR_BAD_PARAM_ERROR) ;
@@ -137,11 +191,11 @@ test_sel_eng (guchar * a_file_uri)
selection_engine = cr_sel_eng_new () ;
- cur_node = xml_doc->children->children ;
+ cur_node = xml_doc->children ;
- status = cr_sel_eng_sel_get_matched_rulesets
- (selection_engine, stylesheet,
- cur_node, &stmts_tab, &tab_len) ;
+ walk_xml_tree_and_lookup_rules (selection_engine,
+ stylesheet,
+ cur_node) ;
if (parser)
{