com gtk/php-gtk: The bug tests requested by Steph: test/bug_g tkliststore_insert_before.phpw test/bug_gtktreeiter .phpw test/bug_gtktreemodel_filter_new.phpw test/ bug_gtktreemodel_iter_nth_child.phpw
[email protected] (David Soria Parra) Tue, 27 Dec 2005 18:10:30 +0000
| Newsgroups | php.gtk.cvs |
|---|---|
| Message-ID | <[email protected]> |
Commit: 26fd96c91b9ec76ef2f5cc742aaa333290e006ea Author: Christian Weiske <[email protected]> Tue, 27 Dec 2005 18:10:30 +0000 Parents: 91669f3768f19d67d88841bcd76fd3af676a4022 Branches: master Link: http://git.php.net/?p=gtk/php-gtk.git;a=commitdiff;h=26fd96c91b9ec76ef2f5cc742aaa333290e006ea Log: The bug tests requested by Steph Changed paths: A test/bug_gtkliststore_insert_before.phpw A test/bug_gtktreeiter.phpw A test/bug_gtktreemodel_filter_new.phpw A test/bug_gtktreemodel_iter_nth_child.phpw Diff: 26fd96c91b9ec76ef2f5cc742aaa333290e006ea diff --git a/test/bug_gtkliststore_insert_before.phpw b/test/bug_gtkliststore_insert_before.phpw new file mode 100644 index 0000000..7b083ca --- /dev/null +++ b/test/bug_gtkliststore_insert_before.phpw @@ -0,0 +1,50 @@ +<?php +/** +Description: +------------- +When writing the docs for GtkListStore, I noted the too C-ish style of +insert_before and insert_after. + +> insert_before($iter, $sibling) +inserts a *new* row before $sibling, and changes the $iter to the new +iterator. That pointer change is c-ish and not php-like. + +IMO it should be that way: +> $iter = $store->insert_before($sibling); +or, with an optional parameter as insert() has: +> $iter = $store->insert_before($sibling, array('value0', 'value1')); + +So that one doesn't have to create an GtkTreeIter before one can insert +a row before another one. (And we can't even create that on our own!) + +The same applies to insert_after. +*/ + +$store = new GtkListStore(Gtk::TYPE_STRING); +$iter = $store->append(array('test')); + +//OLD +/* +//current C-ish behavior: +//create new iter +$newiter = $iter->copy(); +//let the function fill it +$store->insert_before($newiter, $iter); + +//should be NULL +var_dump($store->get_value($newiter, 0)); +//should still be "test" +var_dump($store->get_value($iter, 0)); +//should be 2 +var_dump($store->iter_n_children(null)); +/**/ + +//NEW +/**/ +$newiter = $store->insert_before($iter); +//should be NULL now +var_dump($store->get_value($newiter, 0)); +//should be 2 +var_dump($store->iter_n_children(null)); +/**/ +?> \ No newline at end of file diff --git a/test/bug_gtktreeiter.phpw b/test/bug_gtktreeiter.phpw new file mode 100644 index 0000000..4c38685 --- /dev/null +++ b/test/bug_gtktreeiter.phpw @@ -0,0 +1,50 @@ +<?php +/** +Description: +------------- +When trying to compare two GtkTreeIter, I always get true when using +"==", and a false when using "===" for comparison - equal if they point +to the same path or not. +Is that a bug, or are TreeIters not meant to be compared? +*/ + +$store = new GtkListStore(Gtk::TYPE_STRING); +$iter = $store->append(array('test')); +$iter2 = $store->append(array('test2')); + +echo "Value of iter: " . $store->get_value($iter, 0) . "\r\n"; +echo "Value of iter2: " . $store->get_value($iter2, 0) . "\r\n"; + +//should be false +if ($iter == $iter2) { + echo "wrong: different iters equal ==\r\n"; +} else { + echo "ok\r\n"; +} + +//should be false +if ($iter === $iter2) { + echo "wrong: different iters equal ===\r\n"; +} else { + echo "ok\r\n"; +} + + +$iter3 = $store->iter_children(); +echo "Value of iter3: " . $store->get_value($iter3, 0) . "\r\n"; + +//should be true +if ($iter == $iter3) { + echo "ok\r\n"; +} else { + echo "wrong: iters pointing to the same row don't equal ==\r\n"; +} + +//should be true again +if ($iter === $iter3) { + echo "ok\r\n"; +} else { + echo "wrong: iters pointing to the same row don't equal ===\r\n"; +} + +?> \ No newline at end of file diff --git a/test/bug_gtktreemodel_filter_new.phpw b/test/bug_gtktreemodel_filter_new.phpw new file mode 100644 index 0000000..ed58d99 --- /dev/null +++ b/test/bug_gtktreemodel_filter_new.phpw @@ -0,0 +1,12 @@ +<?php +/** +GtkTreeModel::filte_new segfaults if no parameter is given +*/ + +$store = new GtkListStore(Gtk::TYPE_STRING); +$store->append(array('tset')); +//shouldn't crash +echo "waiting for crash\r\n"; +$store2 = $store->filter_new(); +echo "good - no crash"; +?> \ No newline at end of file diff --git a/test/bug_gtktreemodel_iter_nth_child.phpw b/test/bug_gtktreemodel_iter_nth_child.phpw new file mode 100644 index 0000000..8ae2a5e --- /dev/null +++ b/test/bug_gtktreemodel_iter_nth_child.phpw @@ -0,0 +1,30 @@ +<?php +/** +Description: +------------- +Another c-ish method: +> $store->iter_nth_child($iter, $parent, 0); +sets $iter to the first child of $parent instead of returning it. + +It should be that way: +> $iter = $store->iter_nth_child($parent, 0); +*/ + +$store = new GtkTreeStore(Gtk::TYPE_STRING); +$root = $store->append(null, array('root')); +$child = $store->append($root, array('child')); +$child2 = $store->append($root, array('child2')); +//OLD +/* +$store->iter_nth_child($child2, $root, 0); +//should be "child" +var_dump($store->get_value($child2, 0)); +/**/ + +//NEW should be: +/**/ +$child2 = $store->iter_nth_child($root, 0); +//should be "child" +var_dump($store->get_value($child2, 0)); +/**/ +?> \ No newline at end of file