forked from AuroraMiddleware/gtk
sortlistmodel: Test that the model is stable
Stability is measured relative to the child model, not relative to the previous sorter.
This commit is contained in:
parent
2c519b006d
commit
b67ffe9650
@ -394,6 +394,28 @@ test_remove_items (void)
|
|||||||
g_object_unref (sort);
|
g_object_unref (sort);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_stability (void)
|
||||||
|
{
|
||||||
|
GtkSortListModel *sort;
|
||||||
|
GListStore *store;
|
||||||
|
GtkSorter *sorter;
|
||||||
|
|
||||||
|
store = new_store ((guint[]) { 11, 31, 21, 1, 0 });
|
||||||
|
sort = new_model (store);
|
||||||
|
assert_model (sort, "1 11 21 31");
|
||||||
|
assert_changes (sort, "");
|
||||||
|
|
||||||
|
sorter = gtk_custom_sorter_new (compare_modulo, GUINT_TO_POINTER (5), NULL);
|
||||||
|
gtk_sort_list_model_set_sorter (sort, sorter);
|
||||||
|
g_object_unref (sorter);
|
||||||
|
assert_model (sort, "11 31 21 1");
|
||||||
|
assert_changes (sort, "0-4+4");
|
||||||
|
|
||||||
|
g_object_unref (store);
|
||||||
|
g_object_unref (sort);
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, char *argv[])
|
main (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
@ -411,6 +433,7 @@ main (int argc, char *argv[])
|
|||||||
g_test_add_func ("/sortlistmodel/add_items", test_add_items);
|
g_test_add_func ("/sortlistmodel/add_items", test_add_items);
|
||||||
g_test_add_func ("/sortlistmodel/remove_items", test_remove_items);
|
g_test_add_func ("/sortlistmodel/remove_items", test_remove_items);
|
||||||
#endif
|
#endif
|
||||||
|
g_test_add_func ("/sortlistmodel/stability", test_stability);
|
||||||
|
|
||||||
return g_test_run ();
|
return g_test_run ();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user