Exemple #1
0
static void
test_remove_node (void)
{
  GtkRBTree *tree;

  tree = create_rbtree (3, 16, g_test_thorough ());

  while (tree->root->count > 1)
    {
      GtkRBTree *find_tree;
      GtkRBNode *find_node;
      guint i;
      
      i = g_test_rand_int_range (0, tree->root->total_count);
      if (!_gtk_rbtree_find_index (tree, i, &find_tree, &find_node))
        {
          /* We search an available index, so we mustn't fail. */
          g_assert_not_reached ();
        }
      
      _gtk_rbtree_test (find_tree);

      if (find_tree->root->count == 1)
        {
          _gtk_rbtree_remove (find_tree);
        }
      else
        _gtk_rbtree_remove_node (find_tree, find_node);
      _gtk_rbtree_test (tree);
    }

  _gtk_rbtree_free (tree);
}
Exemple #2
0
static void
object_test_property (GObject           *object,
                      GParamSpec        *pspec,
                      double             dvalue)
{
  /* test setting of a normal writable property */
  if (pspec->flags & G_PARAM_WRITABLE &&
      !(pspec->flags & (G_PARAM_CONSTRUCT | G_PARAM_CONSTRUCT_ONLY)))
    {
      GValue value = { 0, };
      guint i;
      const IgnoreProperty *ignore_properties;
      /* select value to set */
      g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (pspec));
      pspec_select_value (pspec, &value, dvalue);
      /* ignore untestable properties */
      ignore_properties = list_ignore_properties (FALSE);
      for (i = 0; ignore_properties[i].name; i++)
        if (g_strcmp0 ("", ignore_properties[i].name) ||
            g_type_is_a (G_OBJECT_TYPE (object), g_type_from_name (ignore_properties[i].type_name)) &&
            strcmp (pspec->name, ignore_properties[i].name) == 0 &&
            (MATCH_ANY_VALUE == ignore_properties[i].value ||
             value_as_pointer (&value) == ignore_properties[i].value ||
             (G_VALUE_HOLDS_STRING (&value) &&
              strcmp (g_value_get_string (&value), ignore_properties[i].value) == 0)))
          break;
      /* ignore known property bugs if not testing thoroughly */
      if (ignore_properties[i].name == NULL && !g_test_thorough ())
        {
          ignore_properties = list_ignore_properties (TRUE);
          for (i = 0; ignore_properties[i].name; i++)
            if (g_type_is_a (G_OBJECT_TYPE (object), g_type_from_name (ignore_properties[i].type_name)) &&
                strcmp (pspec->name, ignore_properties[i].name) == 0 &&
                (MATCH_ANY_VALUE == ignore_properties[i].value ||
                 value_as_pointer (&value) == ignore_properties[i].value ||
                 (G_VALUE_HOLDS_STRING (&value) &&
                  strcmp (g_value_get_string (&value), ignore_properties[i].value) == 0)))
              break;
        }
      /* assign unignored properties */
      if (ignore_properties[i].name == NULL)
        {
          if (g_test_verbose ())
            g_print ("PropertyTest: %s::%s := (%s value (%s): %p)\n",
                     g_type_name (G_OBJECT_TYPE (object)), pspec->name,
                     SELECT_NAME (dvalue), g_type_name (G_VALUE_TYPE (&value)),
                     value_as_pointer (&value));
          g_object_set_property (object, pspec->name, &value);
        }
      /* cleanups */
      g_value_unset (&value);
    }
}
Exemple #3
0
/* This function adds all the RTF tests to the test suite. It skips tests that
load WMF and EMF files if those modules are not compiled into GdkPixbuf. The
human tests are only added if the test suite was invoked with '-m=perf
-m=thorough'.*/
void
add_rtf_tests(void)
{
    check_wmf_and_emf();
    
    /* Fail cases */
	/* Nonexistent filename case */
	g_test_add_data_func("/rtf/parse/fail/Nonexistent filename", "", rtf_fail_case);
	/* Cases from http://www.codeproject.com/KB/recipes/RtfConverter.aspx */
	add_tests(codeprojectfailcases, "/rtf/parse/fail/", rtf_fail_case);
	/* Other */
	add_tests(variousfailcases, "/rtf/parse/fail/", rtf_fail_case);

	/* Pass cases */
	/* Examples from 'RTF Pocket Guide' by Sean M. Burke */
	add_tests(rtfbookexamples, "/rtf/parse/pass/", rtf_parse_pass_case);
	/* From http://www.codeproject.com/KB/recipes/RtfConverter.aspx */
	add_tests(codeprojectpasscases, "/rtf/parse/pass/", rtf_parse_pass_case);
	/* Other */
	add_tests(variouspasscases, "/rtf/parse/pass/", rtf_parse_pass_case);
	/* These tests export the RTF to a string and re-import it */
	add_tests(rtfbookexamples, "/rtf/write/", rtf_write_pass_case);
	add_tests(codeprojectpasscases, "/rtf/write/", rtf_write_pass_case);
	add_tests(variouspasscases, "/rtf/write/", rtf_write_pass_case);
    /* RTFD tests */
    g_test_add_data_func("/rtf/parse/pass/RTFD test", "rtfdtest.rtfd", rtf_parse_pass_case);
    g_test_add_data_func("/rtf/write/RTFD test", "rtfdtest.rtfd", rtf_write_pass_case);
    
    /* Human tests -- only on thorough testing */
    if(g_test_thorough())
    {
        add_tests(rtfbookexamples, "/rtf/parse/human/", rtf_parse_human_approval_case);
        add_tests(codeprojectpasscases, "/rtf/parse/human/", rtf_parse_human_approval_case);
        add_tests(variouspasscases, "/rtf/parse/human/", rtf_parse_human_approval_case);
    }
}
Exemple #4
0
int
main (int argc, char **argv)
{
	gtk_test_init (&argc, &argv);

	/* Scrolls before realization */
	add_tests (FALSE, BEFORE, FALSE, 0.0, scroll_no_align);
	if (g_test_thorough ())
		add_tests (TRUE, BEFORE, FALSE, 0.0, scroll_no_align);

	add_tests (FALSE, BEFORE, TRUE, 0.0, scroll_align_0_0);
	if (g_test_thorough ())
		add_tests (TRUE, BEFORE, TRUE, 0.0, scroll_align_0_0);

	add_tests (FALSE, BEFORE, TRUE, 0.5, scroll_align_0_5);
	if (g_test_thorough ())
		add_tests (TRUE, BEFORE, TRUE, 0.5, scroll_align_0_5);

	add_tests (FALSE, BEFORE, TRUE, 1.0, scroll_align_1_0);
	if (g_test_thorough ())
		add_tests (TRUE, BEFORE, TRUE, 1.0, scroll_align_1_0);

	/* Scrolls after realization */
	add_tests (FALSE, AFTER, FALSE, 0.0, scroll_after_no_align);
	if (g_test_thorough ())
		add_tests (TRUE, AFTER, FALSE, 0.0, scroll_after_no_align);

	add_tests (FALSE, AFTER, TRUE, 0.0, scroll_after_align_0_0);
	if (g_test_thorough ())
		add_tests (TRUE, AFTER, TRUE, 0.0, scroll_after_align_0_0);

	add_tests (FALSE, AFTER, TRUE, 0.5, scroll_after_align_0_5);
	if (g_test_thorough ())
		add_tests (TRUE, AFTER, TRUE, 0.5, scroll_after_align_0_5);

	add_tests (FALSE, AFTER, TRUE, 1.0, scroll_after_align_1_0);
	if (g_test_thorough ())
		add_tests (TRUE, AFTER, TRUE, 1.0, scroll_after_align_1_0);

	/* Scroll to end before realization, to a real position after */
	if (g_test_thorough ()) {
		add_tests (FALSE, BOTH, FALSE, 0.0, scroll_both_no_align);
		add_tests (TRUE, BOTH, FALSE, 0.0, scroll_both_no_align);

		add_tests (FALSE, BOTH, TRUE, 0.0, scroll_both_align_0_0);
		add_tests (TRUE, BOTH, TRUE, 0.0, scroll_both_align_0_0);

		add_tests (FALSE, BOTH, TRUE, 0.5, scroll_both_align_0_5);
		add_tests (TRUE, BOTH, TRUE, 0.5, scroll_both_align_0_5);

		add_tests (FALSE, BOTH, TRUE, 1.0, scroll_both_align_1_0);
		add_tests (TRUE, BOTH, TRUE, 1.0, scroll_both_align_1_0);
	}

	/* Test different alignments in view with single row */
	g_test_add ("/TreeView/scrolling/single-row/no-align",
		    ScrollFixture, "0",
		    scroll_fixture_single_setup,
		    scroll_no_align,
		    scroll_fixture_teardown);
	g_test_add ("/TreeView/scrolling/single-row/align-0.0",
		    ScrollFixture, "0",
		    scroll_fixture_single_setup,
		    scroll_align_0_0,
		    scroll_fixture_teardown);
	g_test_add ("/TreeView/scrolling/single-row/align-0.5",
		    ScrollFixture, "0",
		    scroll_fixture_single_setup,
		    scroll_align_0_5,
		    scroll_fixture_teardown);
	g_test_add ("/TreeView/scrolling/single-row/align-1.0",
		    ScrollFixture, "0",
		    scroll_fixture_single_setup,
		    scroll_align_1_0,
		    scroll_fixture_teardown);

	/* Test scrolling in a very large model; also very slow */
	if (g_test_slow ()) {
		g_test_add ("/TreeView/scrolling/large-model/constant-height/middle-no-align",
			    ScrollFixture, "50000",
			    scroll_fixture_constant_big_setup,
			    scroll_no_align,
			    scroll_fixture_teardown);
		g_test_add ("/TreeView/scrolling/large-model/constant-height/end-no-align",
			    ScrollFixture, "99999",
			    scroll_fixture_constant_big_setup,
			    scroll_no_align,
			    scroll_fixture_teardown);

		g_test_add ("/TreeView/scrolling/large-model/mixed-height/middle-no-align",
			    ScrollFixture, "50000",
			    scroll_fixture_mixed_big_setup,
			    scroll_no_align,
			    scroll_fixture_teardown);
		g_test_add ("/TreeView/scrolling/large-model/mixed-height/end-no-align",
			    ScrollFixture, "99999",
			    scroll_fixture_mixed_big_setup,
			    scroll_no_align,
			    scroll_fixture_teardown);
	}

	/* Test scrolling to a newly created row */
	g_test_add ("/TreeView/scrolling/new-row/path-0", ScrollFixture,
		    GINT_TO_POINTER (0),
		    scroll_fixture_constant_setup,
		    scroll_new_row,
		    scroll_fixture_teardown);
	g_test_add ("/TreeView/scrolling/new-row/path-4", ScrollFixture,
		    GINT_TO_POINTER (4),
		    scroll_fixture_constant_setup,
		    scroll_new_row,
		    scroll_fixture_teardown);
	/* We scroll to 8 to test a partial visible row.  The 8 is
	 * based on my font setting of "Vera Sans 11" and
	 * the separators set to 0.  (This should be made dynamic; FIXME).
	 */
	g_test_add ("/TreeView/scrolling/new-row/path-8", ScrollFixture,
		    GINT_TO_POINTER (8),
		    scroll_fixture_constant_setup,
		    scroll_new_row,
		    scroll_fixture_teardown);
	g_test_add ("/TreeView/scrolling/new-row/path-500", ScrollFixture,
		    GINT_TO_POINTER (500),
		    scroll_fixture_constant_setup,
		    scroll_new_row,
		    scroll_fixture_teardown);
	g_test_add ("/TreeView/scrolling/new-row/path-999", ScrollFixture,
		    GINT_TO_POINTER (999),
		    scroll_fixture_constant_setup,
		    scroll_new_row,
		    scroll_fixture_teardown);

	g_test_add ("/TreeView/scrolling/new-row/tree", ScrollFixture,
		    NULL,
		    scroll_fixture_tree_setup,
		    scroll_new_row_tree,
		    scroll_fixture_teardown);

	/* Test scrolling to a newly created row, in a mixed height model */
	g_test_add ("/TreeView/scrolling/new-row-mixed/path-0", ScrollFixture,
		    GINT_TO_POINTER (0),
		    scroll_fixture_mixed_setup,
		    scroll_new_row,
		    scroll_fixture_teardown);
	g_test_add ("/TreeView/scrolling/new-row-mixed/path-3", ScrollFixture,
		    GINT_TO_POINTER (3),
		    scroll_fixture_mixed_setup,
		    scroll_new_row,
		    scroll_fixture_teardown);
	/* We scroll to 8 to test a partial visible row.  The 8 is
	 * based on my font setting of "Vera Sans 11" and
	 * the separators set to 0.  (This should be made dynamic; FIXME).
	 */
	g_test_add ("/TreeView/scrolling/new-row-mixed/path-5", ScrollFixture,
		    GINT_TO_POINTER (5),
		    scroll_fixture_mixed_setup,
		    scroll_new_row,
		    scroll_fixture_teardown);
	g_test_add ("/TreeView/scrolling/new-row-mixed/path-500", ScrollFixture,
		    GINT_TO_POINTER (500),
		    scroll_fixture_mixed_setup,
		    scroll_new_row,
		    scroll_fixture_teardown);
	g_test_add ("/TreeView/scrolling/new-row-mixed/path-999", ScrollFixture,
		    GINT_TO_POINTER (999),
		    scroll_fixture_mixed_setup,
		    scroll_new_row,
		    scroll_fixture_teardown);

	g_test_add ("/TreeView/scrolling/new-row-mixed/tree", ScrollFixture,
		    NULL,
		    scroll_fixture_mixed_tree_setup,
		    scroll_new_row_tree,
		    scroll_fixture_teardown);

	/* Misc. tests */
	g_test_add ("/TreeView/scrolling/specific/bug-316689",
			ScrollFixture, NULL,
		    scroll_fixture_constant_setup, test_bug316689,
		    scroll_fixture_teardown);
	g_test_add_func ("/TreeView/scrolling/specific/bug-359231",
			test_bug359231);
	g_test_add ("/TreeView/scrolling/specific/bug-93584",
		    ScrollFixture, NULL,
		    scroll_fixture_tree_setup, test_bug93584,
		    scroll_fixture_teardown);
	g_test_add ("/TreeView/scrolling/specific/bug-111500",
		    ScrollFixture, NULL,
		    scroll_fixture_tree_setup, test_bug111500,
		    scroll_fixture_teardown);
	g_test_add ("/TreeView/scrolling/specific/bug-111500-mixed",
		    ScrollFixture, NULL,
		    scroll_fixture_mixed_tree_setup, test_bug111500_mixed,
		    scroll_fixture_teardown);
	g_test_add ("/TreeView/scrolling/specific/bug-163214",
		    ScrollFixture, NULL,
		    scroll_fixture_constant_setup, test_bug163214,
		    scroll_fixture_teardown);

	return g_test_run ();
}