[gtk+] Move TreeModelSort specific tests to a new sortmodel.c file



commit f1d791355ae1405bf6c4fb76bd421af0931bc773
Author: Kristian Rietveld <kris gtk org>
Date:   Mon May 9 08:37:07 2011 +0200

    Move TreeModelSort specific tests to a new sortmodel.c file

 gtk/tests/Makefile.am   |    2 +-
 gtk/tests/filtermodel.c |   84 ------------------------------------
 gtk/tests/sortmodel.c   |  110 +++++++++++++++++++++++++++++++++++++++++++++++
 gtk/tests/treemodel.c   |    1 +
 gtk/tests/treemodel.h   |    1 +
 5 files changed, 113 insertions(+), 85 deletions(-)
---
diff --git a/gtk/tests/Makefile.am b/gtk/tests/Makefile.am
index 6219d10..d1c87a7 100644
--- a/gtk/tests/Makefile.am
+++ b/gtk/tests/Makefile.am
@@ -28,7 +28,7 @@ testing_SOURCES			 = testing.c
 testing_LDADD			 = $(progs_ldadd)
 
 TEST_PROGS			+= treemodel
-treemodel_SOURCES		 = treemodel.c liststore.c treestore.c filtermodel.c
+treemodel_SOURCES		 = treemodel.c liststore.c treestore.c filtermodel.c sortmodel.c
 treemodel_LDADD			 = $(progs_ldadd)
 
 TEST_PROGS			+= treeview
diff --git a/gtk/tests/filtermodel.c b/gtk/tests/filtermodel.c
index ae2b036..6b259a1 100644
--- a/gtk/tests/filtermodel.c
+++ b/gtk/tests/filtermodel.c
@@ -2364,47 +2364,6 @@ specific_list_store_clear (void)
   gtk_list_store_clear (list);
 }
 
-static void
-specific_bug_300089 (void)
-{
-  /* Test case for GNOME Bugzilla bug 300089.  Written by
-   * Matthias Clasen.
-   */
-  GtkTreeModel *sort_model, *child_model;
-  GtkTreePath *path;
-  GtkTreeIter iter, iter2, sort_iter;
-
-  child_model = GTK_TREE_MODEL (gtk_tree_store_new (1, G_TYPE_STRING));
-
-  gtk_tree_store_append (GTK_TREE_STORE (child_model), &iter, NULL);
-  gtk_tree_store_set (GTK_TREE_STORE (child_model), &iter, 0, "A", -1);
-  gtk_tree_store_append (GTK_TREE_STORE (child_model), &iter, NULL);
-  gtk_tree_store_set (GTK_TREE_STORE (child_model), &iter, 0, "B", -1);
-
-  gtk_tree_store_append (GTK_TREE_STORE (child_model), &iter2, &iter);
-  gtk_tree_store_set (GTK_TREE_STORE (child_model), &iter2, 0, "D", -1);
-  gtk_tree_store_append (GTK_TREE_STORE (child_model), &iter2, &iter);
-  gtk_tree_store_set (GTK_TREE_STORE (child_model), &iter2, 0, "E", -1);
-
-  gtk_tree_store_append (GTK_TREE_STORE (child_model), &iter, NULL);
-  gtk_tree_store_set (GTK_TREE_STORE (child_model), &iter, 0, "C", -1);
-
-
-  sort_model = GTK_TREE_MODEL (gtk_tree_model_sort_new_with_model (child_model));
-  gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (sort_model),
-                                        0, GTK_SORT_ASCENDING);
-
-  path = gtk_tree_path_new_from_indices (1, 1, -1);
-
-  /* make sure a level is constructed */ 
-  gtk_tree_model_get_iter (sort_model, &sort_iter, path);
-
-  /* change the "E" row in a way that causes it to change position */ 
-  gtk_tree_model_get_iter (child_model, &iter, path);
-  gtk_tree_store_set (GTK_TREE_STORE (child_model), &iter, 0, "A", -1);
-}
-
-
 static int
 specific_bug_301558_sort_func (GtkTreeModel *model,
                                GtkTreeIter  *a,
@@ -2622,45 +2581,6 @@ specific_bug_346800 (void)
     }
 }
 
-
-static void
-specific_bug_364946 (void)
-{
-  /* This is a test case for GNOME Bugzilla bug 364946.  It was written
-   * by Andreas Koehler.
-   */
-  GtkTreeStore *store;
-  GtkTreeIter a, aa, aaa, aab, iter;
-  GtkTreeModel *s_model;
-
-  store = gtk_tree_store_new (1, G_TYPE_STRING);
-
-  gtk_tree_store_append (store, &a, NULL);
-  gtk_tree_store_set (store, &a, 0, "0", -1);
-
-  gtk_tree_store_append (store, &aa, &a);
-  gtk_tree_store_set (store, &aa, 0, "0:0", -1);
-
-  gtk_tree_store_append (store, &aaa, &aa);
-  gtk_tree_store_set (store, &aaa, 0, "0:0:0", -1);
-
-  gtk_tree_store_append (store, &aab, &aa);
-  gtk_tree_store_set (store, &aab, 0, "0:0:1", -1);
-
-  s_model = gtk_tree_model_sort_new_with_model (GTK_TREE_MODEL (store));
-  gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (s_model), 0,
-                                        GTK_SORT_ASCENDING);
-
-  gtk_tree_model_get_iter_from_string (s_model, &iter, "0:0:0");
-
-  gtk_tree_store_set (store, &aaa, 0, "0:0:0", -1);
-  gtk_tree_store_remove (store, &aaa);
-  gtk_tree_store_remove (store, &aab);
-
-  gtk_tree_model_sort_clear_cache (GTK_TREE_MODEL_SORT (s_model));
-}
-
-
 static gboolean
 specific_bug_464173_visible_func (GtkTreeModel *model,
                                   GtkTreeIter  *iter,
@@ -2976,16 +2896,12 @@ register_filter_model_tests (void)
   g_test_add_func ("/TreeModelFilter/specific/list-store-clear",
                    specific_list_store_clear);
 
-  g_test_add_func ("/TreeModelFilter/specific/bug-300089",
-                   specific_bug_300089);
   g_test_add_func ("/TreeModelFilter/specific/bug-301558",
                    specific_bug_301558);
   g_test_add_func ("/TreeModelFilter/specific/bug-311955",
                    specific_bug_311955);
   g_test_add_func ("/TreeModelFilter/specific/bug-346800",
                    specific_bug_346800);
-  g_test_add_func ("/TreeModelFilter/specific/bug-364946",
-                   specific_bug_364946);
   g_test_add_func ("/TreeModelFilter/specific/bug-464173",
                    specific_bug_464173);
   g_test_add_func ("/TreeModelFilter/specific/bug-540201",
diff --git a/gtk/tests/sortmodel.c b/gtk/tests/sortmodel.c
new file mode 100644
index 0000000..d972d8a
--- /dev/null
+++ b/gtk/tests/sortmodel.c
@@ -0,0 +1,110 @@
+/* Extensive GtkTreeModelSort tests.
+ * Copyright (C) 2009,2011  Kristian Rietveld  <kris gtk org>
+ *
+ * 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 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, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <gtk/gtk.h>
+
+#include "treemodel.h"
+
+static void
+specific_bug_300089 (void)
+{
+  /* Test case for GNOME Bugzilla bug 300089.  Written by
+   * Matthias Clasen.
+   */
+  GtkTreeModel *sort_model, *child_model;
+  GtkTreePath *path;
+  GtkTreeIter iter, iter2, sort_iter;
+
+  child_model = GTK_TREE_MODEL (gtk_tree_store_new (1, G_TYPE_STRING));
+
+  gtk_tree_store_append (GTK_TREE_STORE (child_model), &iter, NULL);
+  gtk_tree_store_set (GTK_TREE_STORE (child_model), &iter, 0, "A", -1);
+  gtk_tree_store_append (GTK_TREE_STORE (child_model), &iter, NULL);
+  gtk_tree_store_set (GTK_TREE_STORE (child_model), &iter, 0, "B", -1);
+
+  gtk_tree_store_append (GTK_TREE_STORE (child_model), &iter2, &iter);
+  gtk_tree_store_set (GTK_TREE_STORE (child_model), &iter2, 0, "D", -1);
+  gtk_tree_store_append (GTK_TREE_STORE (child_model), &iter2, &iter);
+  gtk_tree_store_set (GTK_TREE_STORE (child_model), &iter2, 0, "E", -1);
+
+  gtk_tree_store_append (GTK_TREE_STORE (child_model), &iter, NULL);
+  gtk_tree_store_set (GTK_TREE_STORE (child_model), &iter, 0, "C", -1);
+
+
+  sort_model = GTK_TREE_MODEL (gtk_tree_model_sort_new_with_model (child_model));
+  gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (sort_model),
+                                        0, GTK_SORT_ASCENDING);
+
+  path = gtk_tree_path_new_from_indices (1, 1, -1);
+
+  /* make sure a level is constructed */ 
+  gtk_tree_model_get_iter (sort_model, &sort_iter, path);
+
+  /* change the "E" row in a way that causes it to change position */ 
+  gtk_tree_model_get_iter (child_model, &iter, path);
+  gtk_tree_store_set (GTK_TREE_STORE (child_model), &iter, 0, "A", -1);
+}
+
+static void
+specific_bug_364946 (void)
+{
+  /* This is a test case for GNOME Bugzilla bug 364946.  It was written
+   * by Andreas Koehler.
+   */
+  GtkTreeStore *store;
+  GtkTreeIter a, aa, aaa, aab, iter;
+  GtkTreeModel *s_model;
+
+  store = gtk_tree_store_new (1, G_TYPE_STRING);
+
+  gtk_tree_store_append (store, &a, NULL);
+  gtk_tree_store_set (store, &a, 0, "0", -1);
+
+  gtk_tree_store_append (store, &aa, &a);
+  gtk_tree_store_set (store, &aa, 0, "0:0", -1);
+
+  gtk_tree_store_append (store, &aaa, &aa);
+  gtk_tree_store_set (store, &aaa, 0, "0:0:0", -1);
+
+  gtk_tree_store_append (store, &aab, &aa);
+  gtk_tree_store_set (store, &aab, 0, "0:0:1", -1);
+
+  s_model = gtk_tree_model_sort_new_with_model (GTK_TREE_MODEL (store));
+  gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (s_model), 0,
+                                        GTK_SORT_ASCENDING);
+
+  gtk_tree_model_get_iter_from_string (s_model, &iter, "0:0:0");
+
+  gtk_tree_store_set (store, &aaa, 0, "0:0:0", -1);
+  gtk_tree_store_remove (store, &aaa);
+  gtk_tree_store_remove (store, &aab);
+
+  gtk_tree_model_sort_clear_cache (GTK_TREE_MODEL_SORT (s_model));
+}
+
+/* main */
+
+void
+register_sort_model_tests (void)
+{
+  g_test_add_func ("/TreeModelSort/specific/bug-300089",
+                   specific_bug_300089);
+  g_test_add_func ("/TreeModelSort/specific/bug-364946",
+                   specific_bug_364946);
+}
diff --git a/gtk/tests/treemodel.c b/gtk/tests/treemodel.c
index fd91047..9d2a436 100644
--- a/gtk/tests/treemodel.c
+++ b/gtk/tests/treemodel.c
@@ -29,6 +29,7 @@ main (int    argc,
 
   register_list_store_tests ();
   register_tree_store_tests ();
+  register_sort_model_tests ();
   register_filter_model_tests ();
 
   return g_test_run ();
diff --git a/gtk/tests/treemodel.h b/gtk/tests/treemodel.h
index 504f31b..4a46eba 100644
--- a/gtk/tests/treemodel.h
+++ b/gtk/tests/treemodel.h
@@ -19,4 +19,5 @@
 
 void register_list_store_tests ();
 void register_tree_store_tests ();
+void register_sort_model_tests ();
 void register_filter_model_tests ();



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]