[gtk+] More virtual root unit tests



commit 5b766102fdf9762d83e124813bdde27cd4fb97b8
Author: Kristian Rietveld <kris gtk org>
Date:   Tue Sep 1 18:05:46 2009 +0200

    More virtual root unit tests

 gtk/tests/filtermodel.c |  172 +++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 172 insertions(+), 0 deletions(-)
---
diff --git a/gtk/tests/filtermodel.c b/gtk/tests/filtermodel.c
index 51477a4..872fe88 100644
--- a/gtk/tests/filtermodel.c
+++ b/gtk/tests/filtermodel.c
@@ -716,6 +716,72 @@ unfiltered_hide_single_multi_level (FilterTest    *fixture,
 
 
 static void
+unfiltered_vroot_hide_single (FilterTest    *fixture,
+                              gconstpointer  user_data)
+
+{
+  GtkTreePath *path = (GtkTreePath *)user_data;
+
+  set_path_visibility (fixture, "2:2", FALSE);
+
+  check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
+
+  filter_test_enable_filter (fixture);
+
+  check_filter_model_with_root (fixture, path);
+  check_level_length (fixture->filter, NULL, LEVEL_LENGTH - 1);
+}
+
+static void
+unfiltered_vroot_hide_single_child (FilterTest    *fixture,
+                                    gconstpointer  user_data)
+
+{
+  GtkTreePath *path = (GtkTreePath *)user_data;
+
+  set_path_visibility (fixture, "2:2:2", FALSE);
+
+  check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
+  check_level_length (fixture->filter, "2", LEVEL_LENGTH);
+
+  filter_test_enable_filter (fixture);
+
+  check_filter_model_with_root (fixture, path);
+  check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
+  check_level_length (fixture->filter, "2", LEVEL_LENGTH - 1);
+}
+
+static void
+unfiltered_vroot_hide_single_multi_level (FilterTest    *fixture,
+                                          gconstpointer  user_data)
+
+{
+  GtkTreePath *path = (GtkTreePath *)user_data;
+
+  set_path_visibility (fixture, "2:2:2:2", FALSE);
+  set_path_visibility (fixture, "2:2:2", FALSE);
+
+  check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
+  check_level_length (fixture->filter, "2", LEVEL_LENGTH);
+  check_level_length (fixture->filter, "2:2", LEVEL_LENGTH);
+
+  filter_test_enable_filter (fixture);
+
+  check_filter_model_with_root (fixture, path);
+  check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
+  check_level_length (fixture->filter, "2", LEVEL_LENGTH - 1);
+
+  set_path_visibility (fixture, "2:2:2", TRUE);
+
+  check_filter_model_with_root (fixture, path);
+  check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
+  check_level_length (fixture->filter, "2", LEVEL_LENGTH);
+  check_level_length (fixture->filter, "2:2", LEVEL_LENGTH - 1);
+}
+
+
+
+static void
 unfiltered_show_single (FilterTest    *fixture,
                         gconstpointer  user_data)
 
@@ -781,6 +847,78 @@ unfiltered_show_single_multi_level (FilterTest    *fixture,
 }
 
 
+static void
+unfiltered_vroot_show_single (FilterTest    *fixture,
+                              gconstpointer  user_data)
+
+{
+  GtkTreePath *path = (GtkTreePath *)user_data;
+
+  set_path_visibility (fixture, "2:2", TRUE);
+
+  check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
+
+  filter_test_enable_filter (fixture);
+
+  check_filter_model_with_root (fixture, path);
+  check_level_length (fixture->filter, NULL, 1);
+}
+
+static void
+unfiltered_vroot_show_single_child (FilterTest    *fixture,
+                                    gconstpointer  user_data)
+
+{
+  GtkTreePath *path = (GtkTreePath *)user_data;
+
+  set_path_visibility (fixture, "2:2:2", TRUE);
+
+  check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
+  check_level_length (fixture->filter, "2", LEVEL_LENGTH);
+
+  filter_test_enable_filter (fixture);
+
+  check_filter_model_with_root (fixture, path);
+  check_level_length (fixture->filter, NULL, 0);
+
+  /* From here we are filtered, "2" in the real model is "0" in the filter
+   * model.
+   */
+  set_path_visibility (fixture, "2:2", TRUE);
+  check_level_length (fixture->filter, NULL, 1);
+  check_level_length (fixture->filter, "0", 1);
+}
+
+static void
+unfiltered_vroot_show_single_multi_level (FilterTest    *fixture,
+                                          gconstpointer  user_data)
+
+{
+  GtkTreePath *path = (GtkTreePath *)user_data;
+
+  set_path_visibility (fixture, "2:2:2:2", TRUE);
+  set_path_visibility (fixture, "2:2:2", TRUE);
+
+  check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
+  check_level_length (fixture->filter, "2", LEVEL_LENGTH);
+  check_level_length (fixture->filter, "2:2", LEVEL_LENGTH);
+
+  filter_test_enable_filter (fixture);
+
+  check_filter_model_with_root (fixture, path);
+  check_level_length (fixture->filter, NULL, 0);
+
+  /* From here we are filtered, "2" in the real model is "0" in the filter
+   * model.
+   */
+  set_path_visibility (fixture, "2:2", TRUE);
+  check_filter_model_with_root (fixture, path);
+  check_level_length (fixture->filter, NULL, 1);
+  check_level_length (fixture->filter, "0", 1);
+  check_level_length (fixture->filter, "0:0", 1);
+}
+
+
 static gboolean
 specific_path_dependent_filter_func (GtkTreeModel *model,
                                      GtkTreeIter  *iter,
@@ -1662,6 +1800,24 @@ main (int    argc,
               unfiltered_hide_single_multi_level,
               filter_test_teardown);
 
+  g_test_add ("/FilterModel/unfiltered/hide-single/vroot",
+              FilterTest, gtk_tree_path_new_from_indices (2, -1),
+              filter_test_setup_unfiltered,
+              unfiltered_vroot_hide_single,
+              filter_test_teardown);
+  g_test_add ("/FilterModel/unfiltered/hide-single-child/vroot",
+              FilterTest, gtk_tree_path_new_from_indices (2, -1),
+              filter_test_setup_unfiltered,
+              unfiltered_vroot_hide_single_child,
+              filter_test_teardown);
+  g_test_add ("/FilterModel/unfiltered/hide-single-multi-level/vroot",
+              FilterTest, gtk_tree_path_new_from_indices (2, -1),
+              filter_test_setup_unfiltered,
+              unfiltered_vroot_hide_single_multi_level,
+              filter_test_teardown);
+
+
+
   g_test_add ("/FilterModel/unfiltered/show-single",
               FilterTest, NULL,
               filter_test_setup_empty_unfiltered,
@@ -1678,6 +1834,22 @@ main (int    argc,
               unfiltered_show_single_multi_level,
               filter_test_teardown);
 
+  g_test_add ("/FilterModel/unfiltered/show-single/vroot",
+              FilterTest, gtk_tree_path_new_from_indices (2, -1),
+              filter_test_setup_empty_unfiltered,
+              unfiltered_vroot_show_single,
+              filter_test_teardown);
+  g_test_add ("/FilterModel/unfiltered/show-single-child/vroot",
+              FilterTest, gtk_tree_path_new_from_indices (2, -1),
+              filter_test_setup_empty_unfiltered,
+              unfiltered_vroot_show_single_child,
+              filter_test_teardown);
+  g_test_add ("/FilterModel/unfiltered/show-single-multi-level/vroot",
+              FilterTest, gtk_tree_path_new_from_indices (2, -1),
+              filter_test_setup_empty_unfiltered,
+              unfiltered_vroot_show_single_multi_level,
+              filter_test_teardown);
+
 
   g_test_add_func ("/FilterModel/specific/path-dependent-filter",
                    specific_path_dependent_filter);



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