com gtk/php-gtk: Fixed the both convert methods and added unit test for them: ext/gtk+/gtktreeview.overrides test/unittests/GtkTreeModelFilterTest.php

[email protected] (David Soria Parra)
Newsgroups php.gtk.cvs
Message-ID <[email protected]>
Commit:    33623929708c2d883e8b311712106902f91505b3
Author:    Christian Weiske <[email protected]>         Sat, 1 Jul 2006 10:02:20 +0000
Parents:   0b1b973e07d249bcf6930c8a4a5f12e42ba61791
Branches:  master

Link:       http://git.php.net/?p=gtk/php-gtk.git;a=commitdiff;h=33623929708c2d883e8b311712106902f91505b3

Log:
Fixed the both convert methods and added unit test for them

Changed paths:
  M  ext/gtk+/gtktreeview.overrides
  M  test/unittests/GtkTreeModelFilterTest.php


Diff:
33623929708c2d883e8b311712106902f91505b3
diff --git a/ext/gtk+/gtktreeview.overrides b/ext/gtk+/gtktreeview.overrides
index 63190a0..06ac1fb 100644
--- a/ext/gtk+/gtktreeview.overrides
+++ b/ext/gtk+/gtktreeview.overrides
@@ -1430,7 +1430,7 @@ ZEND_END_ARG_INFO();
 override gtk_tree_model_filter_convert_child_iter_to_iter
 PHP_METHOD
 {
-    GtkTreeIter *filter_iter = NULL, *child_iter = NULL;
+    GtkTreeIter filter_iter, *child_iter = NULL;
     zval *php_child_iter;
 
     NOT_STATIC_METHOD();
@@ -1446,7 +1446,7 @@ PHP_METHOD
         return;
     }
 
-    gtk_tree_model_filter_convert_child_iter_to_iter(GTK_TREE_MODEL_FILTER(PHPG_GOBJECT(this_ptr)), filter_iter, child_iter);
+    gtk_tree_model_filter_convert_child_iter_to_iter(GTK_TREE_MODEL_FILTER(PHPG_GOBJECT(this_ptr)), &filter_iter, child_iter);
 
     phpg_gboxed_new(&return_value, GTK_TYPE_TREE_ITER, &filter_iter, TRUE, TRUE TSRMLS_CC);
 }
@@ -1462,7 +1462,7 @@ ZEND_END_ARG_INFO();
 override gtk_tree_model_filter_convert_iter_to_child_iter
 PHP_METHOD
 {
-    GtkTreeIter *child_iter = NULL, *filter_iter = NULL;
+    GtkTreeIter child_iter, *filter_iter = NULL;
     zval *php_filter_iter;
 
     NOT_STATIC_METHOD();
@@ -1478,7 +1478,7 @@ PHP_METHOD
         return;
     }
 
-    gtk_tree_model_filter_convert_iter_to_child_iter(GTK_TREE_MODEL_FILTER(PHPG_GOBJECT(this_ptr)), child_iter, filter_iter);
+    gtk_tree_model_filter_convert_iter_to_child_iter(GTK_TREE_MODEL_FILTER(PHPG_GOBJECT(this_ptr)), &child_iter, filter_iter);
 
     phpg_gboxed_new(&return_value, GTK_TYPE_TREE_ITER, &child_iter, TRUE, TRUE TSRMLS_CC);
 }
diff --git a/test/unittests/GtkTreeModelFilterTest.php b/test/unittests/GtkTreeModelFilterTest.php
index 76a2ac4..ab5ace6 100644
--- a/test/unittests/GtkTreeModelFilterTest.php
+++ b/test/unittests/GtkTreeModelFilterTest.php
@@ -47,12 +47,16 @@ class GtkTreeModelFilterTest extends PHPUnit2_Framework_TestCase {
         $this->c = $this->mod->append(null, array('c'));
 
 
-        $path_a = $this->mod->get_string_from_iter($this->a);
+        $path_a = $this->mod->get_path($this->a);
+        $this->assertNotNull($path_a);
         $this->tmf = new GtkTreeModelFilter($this->mod, $path_a);
 
         $this->assertEquals(3, $this->mod->iter_n_children(null));
         $this->assertEquals(4, $this->mod->iter_n_children($this->a));
 
+        $this->assertNotNull($this->tmf->get_property('child-model'));
+        $this->assertEquals($this->mod, $this->tmf->get_property('child-model'));
+
         $this->assertNotNull($this->tmf->get_property('virtual-root'));
         $this->assertEquals(4, $this->tmf->iter_n_children(null));
     }
@@ -75,11 +79,31 @@ class GtkTreeModelFilterTest extends PHPUnit2_Framework_TestCase {
     }
 
     /**
-     * @todo Implement testConvert_child_iter_to_iter().
+     *
      */
     public function testConvert_child_iter_to_iter() {
-        // Remove the following line when you implement this test.
-        throw new PHPUnit2_Framework_IncompleteTestError;
+        $child_a = $this->mod->get_iter_first();
+        $this->assertNotNull($child_a);
+        $this->assertType('GtkTreeIter', $child_a);
+        $this->assertEquals('a', $this->mod->get_value($child_a, 0));
+
+        $child_aa = $this->mod->iter_nth_child($child_a, 0);
+        $this->assertNotNull($child_aa);
+        $this->assertType('GtkTreeIter', $child_aa);
+        $this->assertEquals('aa', $this->mod->get_value($child_aa, 0));
+
+
+        $aa = $this->tmf->convert_child_iter_to_iter($child_aa);
+        $this->assertNotNull($aa);
+        $this->assertType('GtkTreeIter', $aa);
+        $this->assertEquals(
+            $this->tmf->get_value($aa, 0),
+            $this->mod->get_value($child_aa, 0)
+        );
+
+        //This should return NULL if the virtual root would work
+        $a = $this->tmf->convert_child_iter_to_iter($child_a);
+        //FIXME: check for null when virtual root works
     }
 
     /**
@@ -95,6 +119,7 @@ class GtkTreeModelFilterTest extends PHPUnit2_Framework_TestCase {
      */
     public function testConvert_iter_to_child_iter() {
         $a = $this->tmf->get_iter_first();
+        $this->assertNotNull($a);
         $this->assertType('GtkTreeIter', $a);
 //        var_dump($this->tmf->get_value($a, 0));
         $this->assertEquals('aa', $this->tmf->get_value($a, 0));
@@ -103,9 +128,10 @@ class GtkTreeModelFilterTest extends PHPUnit2_Framework_TestCase {
         $this->assertNotNull($child_a);
         $this->assertType('GtkTreeIter', $child_a);
         $this->assertEquals(
-            'aa',
+            $this->tmf->get_value($a, 0),
             $this->mod->get_value($child_a, 0)
         );
+
     }
 
     /**
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.