mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-14 12:41:07 +00:00
Merge branch 'testsuite-asserts' into 'master'
testsuite: Reduce use of g_assert See merge request GNOME/gtk!3431
This commit is contained in:
commit
74238b5429
@ -77,7 +77,7 @@ load_ui_file (GFile *file, gboolean generate)
|
||||
ui_file = g_file_get_path (file);
|
||||
|
||||
css_file = test_get_other_file (ui_file, ".css");
|
||||
g_assert (css_file != NULL);
|
||||
g_assert_nonnull (css_file);
|
||||
|
||||
provider = gtk_css_provider_new ();
|
||||
gtk_css_provider_load_from_path (provider, css_file);
|
||||
@ -90,7 +90,7 @@ load_ui_file (GFile *file, gboolean generate)
|
||||
if (window == NULL)
|
||||
window = GTK_WIDGET (gtk_builder_get_object (builder, "window"));
|
||||
|
||||
g_assert (window != NULL);
|
||||
g_assert_nonnull (window);
|
||||
|
||||
|
||||
output = NULL;
|
||||
|
@ -84,7 +84,7 @@ test_parse (gconstpointer data)
|
||||
g_assert_nonnull (bytes);
|
||||
g_assert_no_error (error);
|
||||
if (test->mimetype == NULL)
|
||||
g_assert (mimetype == NULL);
|
||||
g_assert_null (mimetype);
|
||||
else
|
||||
g_assert_cmpstr (mimetype, ==, test->mimetype);
|
||||
|
||||
|
@ -80,7 +80,7 @@ load_ui_file (GFile *file, gboolean generate)
|
||||
builder = gtk_builder_new_from_file (ui_file);
|
||||
window = GTK_WIDGET (gtk_builder_get_object (builder, "window1"));
|
||||
|
||||
g_assert (window != NULL);
|
||||
g_assert_nonnull (window);
|
||||
|
||||
output = NULL;
|
||||
g_signal_connect (window, "map", G_CALLBACK (style_context_changed), &output);
|
||||
|
@ -97,7 +97,7 @@ load_ui_file (GFile *file, gboolean generate)
|
||||
ui_file = g_file_get_path (file);
|
||||
|
||||
css_file = test_get_other_file (ui_file, ".css");
|
||||
g_assert (css_file != NULL);
|
||||
g_assert_nonnull (css_file);
|
||||
|
||||
provider = gtk_css_provider_new ();
|
||||
gtk_css_provider_load_from_path (provider, css_file);
|
||||
@ -108,7 +108,7 @@ load_ui_file (GFile *file, gboolean generate)
|
||||
builder = gtk_builder_new_from_file (ui_file);
|
||||
window = GTK_WIDGET (gtk_builder_get_object (builder, "window1"));
|
||||
|
||||
g_assert (window != NULL);
|
||||
g_assert_nonnull (window);
|
||||
|
||||
output = NULL;
|
||||
g_signal_connect (window, "map", G_CALLBACK (style_context_changed), &output);
|
||||
@ -125,7 +125,7 @@ load_ui_file (GFile *file, gboolean generate)
|
||||
}
|
||||
|
||||
reference_file = test_get_other_file (ui_file, ".nodes");
|
||||
g_assert (reference_file != NULL);
|
||||
g_assert_nonnull (reference_file);
|
||||
|
||||
diff = diff_with_file (reference_file, output, -1, &error);
|
||||
g_assert_no_error (error);
|
||||
|
@ -67,7 +67,7 @@ gdk_array(test_splice) (void)
|
||||
gsize old_size = gdk_array(get_size) (&v);
|
||||
|
||||
pos = g_random_int_range (0, old_size + 1);
|
||||
g_assert (pos <= old_size);
|
||||
g_assert_true (pos <= old_size);
|
||||
remove = g_random_int_range (0, 4);
|
||||
remove = MIN (remove, old_size - pos);
|
||||
add = g_random_int_range (0, 4);
|
||||
|
@ -9,10 +9,10 @@ test_unset_display_subprocess1 (void)
|
||||
|
||||
g_unsetenv ("DISPLAY");
|
||||
|
||||
g_assert (!gtk_init_check ());
|
||||
g_assert_false (gtk_init_check ());
|
||||
manager = gdk_display_manager_get ();
|
||||
g_assert (manager != NULL);
|
||||
g_assert (gdk_display_manager_get_default_display (manager) == NULL);
|
||||
g_assert_nonnull (manager);
|
||||
g_assert_null (gdk_display_manager_get_default_display (manager));
|
||||
}
|
||||
|
||||
static void
|
||||
@ -41,10 +41,10 @@ test_bad_display_subprocess1 (void)
|
||||
|
||||
g_setenv ("DISPLAY", "poo", TRUE);
|
||||
|
||||
g_assert (!gtk_init_check ());
|
||||
g_assert_false (gtk_init_check ());
|
||||
manager = gdk_display_manager_get ();
|
||||
g_assert (manager != NULL);
|
||||
g_assert (gdk_display_manager_get_default_display (manager) == NULL);
|
||||
g_assert_nonnull (manager);
|
||||
g_assert_null (gdk_display_manager_get_default_display (manager));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -26,8 +26,8 @@ test_to_text_list (void)
|
||||
length = 25;
|
||||
n = gdk_x11_display_text_property_to_text_list (display, encoding, format, text, length, &list);
|
||||
g_assert_cmpint (n, ==, 2);
|
||||
g_assert (g_str_has_prefix (list[0], "abcdef "));
|
||||
g_assert (g_str_has_prefix (list[1], "ABCDEF "));
|
||||
g_assert_true (g_str_has_prefix (list[0], "abcdef "));
|
||||
g_assert_true (g_str_has_prefix (list[1], "ABCDEF "));
|
||||
|
||||
gdk_x11_free_text_list (list);
|
||||
}
|
||||
|
@ -9,62 +9,62 @@ test_color_parse (void)
|
||||
gboolean res;
|
||||
|
||||
res = gdk_rgba_parse (&color, "foo");
|
||||
g_assert (!res);
|
||||
g_assert_true (!res);
|
||||
|
||||
res = gdk_rgba_parse (&color, "");
|
||||
g_assert (!res);
|
||||
g_assert_true (!res);
|
||||
|
||||
expected.red = 100/255.;
|
||||
expected.green = 90/255.;
|
||||
expected.blue = 80/255.;
|
||||
expected.alpha = 0.1;
|
||||
res = gdk_rgba_parse (&color, "rgba(100,90,80,0.1)");
|
||||
g_assert (res);
|
||||
g_assert (gdk_rgba_equal (&color, &expected));
|
||||
g_assert_true (res);
|
||||
g_assert_true (gdk_rgba_equal (&color, &expected));
|
||||
|
||||
expected.red = 0.4;
|
||||
expected.green = 0.3;
|
||||
expected.blue = 0.2;
|
||||
expected.alpha = 0.1;
|
||||
res = gdk_rgba_parse (&color, "rgba(40%,30%,20%,0.1)");
|
||||
g_assert (res);
|
||||
g_assert (gdk_rgba_equal (&color, &expected));
|
||||
g_assert_true (res);
|
||||
g_assert_true (gdk_rgba_equal (&color, &expected));
|
||||
|
||||
res = gdk_rgba_parse (&color, "rgba( 40 % , 30 % , 20 % , 0.1 )");
|
||||
g_assert (res);
|
||||
g_assert (gdk_rgba_equal (&color, &expected));
|
||||
g_assert_true (res);
|
||||
g_assert_true (gdk_rgba_equal (&color, &expected));
|
||||
|
||||
expected.red = 1.0;
|
||||
expected.green = 0.0;
|
||||
expected.blue = 0.0;
|
||||
expected.alpha = 1.0;
|
||||
res = gdk_rgba_parse (&color, "red");
|
||||
g_assert (res);
|
||||
g_assert (gdk_rgba_equal (&color, &expected));
|
||||
g_assert_true (res);
|
||||
g_assert_true (gdk_rgba_equal (&color, &expected));
|
||||
|
||||
expected.red = 0.0;
|
||||
expected.green = 0x8080 / 65535.;
|
||||
expected.blue = 1.0;
|
||||
expected.alpha = 1.0;
|
||||
res = gdk_rgba_parse (&color, "#0080ff");
|
||||
g_assert (res);
|
||||
g_assert (gdk_rgba_equal (&color, &expected));
|
||||
g_assert_true (res);
|
||||
g_assert_true (gdk_rgba_equal (&color, &expected));
|
||||
|
||||
expected.red = 0.0;
|
||||
expected.green = 0.0;
|
||||
expected.blue = 0.0;
|
||||
expected.alpha = 1.0;
|
||||
res = gdk_rgba_parse (&color, "rgb(0,0,0)");
|
||||
g_assert (res);
|
||||
g_assert (gdk_rgba_equal (&color, &expected));
|
||||
g_assert_true (res);
|
||||
g_assert_true (gdk_rgba_equal (&color, &expected));
|
||||
|
||||
expected.red = 0.0;
|
||||
expected.green = 0x8080 / 65535.;
|
||||
expected.blue = 1.0;
|
||||
expected.alpha = 0x8888 / 65535.;
|
||||
res = gdk_rgba_parse (&color, "#0080ff88");
|
||||
g_assert (res);
|
||||
g_assert (gdk_rgba_equal (&color, &expected));
|
||||
g_assert_true (res);
|
||||
g_assert_true (gdk_rgba_equal (&color, &expected));
|
||||
}
|
||||
|
||||
static void
|
||||
@ -88,7 +88,7 @@ test_color_to_string (void)
|
||||
orig = g_strdup (setlocale (LC_ALL, NULL));
|
||||
res = gdk_rgba_to_string (&rgba);
|
||||
gdk_rgba_parse (&out, res);
|
||||
g_assert (gdk_rgba_equal (&rgba, &out));
|
||||
g_assert_true (gdk_rgba_equal (&rgba, &out));
|
||||
|
||||
setlocale (LC_ALL, "de_DE.utf-8");
|
||||
res_de = gdk_rgba_to_string (&rgba);
|
||||
@ -118,7 +118,7 @@ test_color_copy (void)
|
||||
rgba.alpha = 0.9;
|
||||
|
||||
out = gdk_rgba_copy (&rgba);
|
||||
g_assert (gdk_rgba_equal (&rgba, out));
|
||||
g_assert_true (gdk_rgba_equal (&rgba, out));
|
||||
|
||||
gdk_rgba_free (out);
|
||||
}
|
||||
@ -132,28 +132,28 @@ test_color_parse_nonsense (void)
|
||||
/*http://bugzilla.gnome.org/show_bug.cgi?id=667485 */
|
||||
|
||||
res = gdk_rgba_parse (&color, "rgb(,,)");
|
||||
g_assert (!res);
|
||||
g_assert_false (res);
|
||||
|
||||
res = gdk_rgba_parse (&color, "rgb(%,%,%)");
|
||||
g_assert (!res);
|
||||
g_assert_false (res);
|
||||
|
||||
res = gdk_rgba_parse (&color, "rgb(nan,nan,nan)");
|
||||
g_assert (!res);
|
||||
g_assert_false (res);
|
||||
|
||||
res = gdk_rgba_parse (&color, "rgb(inf,inf,inf)");
|
||||
g_assert (!res);
|
||||
g_assert_false (res);
|
||||
|
||||
res = gdk_rgba_parse (&color, "rgb(1p12,0,0)");
|
||||
g_assert (!res);
|
||||
g_assert_false (res);
|
||||
|
||||
res = gdk_rgba_parse (&color, "rgb(5d1%,1,1)");
|
||||
g_assert (!res);
|
||||
g_assert_false (res);
|
||||
|
||||
res = gdk_rgba_parse (&color, "rgb(0,0,0)moo");
|
||||
g_assert (!res);
|
||||
g_assert_false (res);
|
||||
|
||||
res = gdk_rgba_parse (&color, "rgb(0,0,0) moo");
|
||||
g_assert (!res);
|
||||
g_assert_false (res);
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -21,7 +21,7 @@ test_list_seats (void)
|
||||
seat = l->data;
|
||||
|
||||
g_assert_true (GDK_IS_SEAT (seat));
|
||||
g_assert (gdk_seat_get_display (seat) == display);
|
||||
g_assert_true (gdk_seat_get_display (seat) == display);
|
||||
|
||||
if (seat == seat0)
|
||||
found_default = TRUE;
|
||||
|
@ -275,6 +275,7 @@ save_image (cairo_surface_t *surface,
|
||||
{
|
||||
GError *error = NULL;
|
||||
char *filename;
|
||||
int ret;
|
||||
|
||||
filename = get_output_file (test_name, extension, &error);
|
||||
if (filename == NULL)
|
||||
@ -285,7 +286,8 @@ save_image (cairo_surface_t *surface,
|
||||
}
|
||||
|
||||
g_test_message ("Storing test result image at %s", filename);
|
||||
g_assert (cairo_surface_write_to_png (surface, filename) == CAIRO_STATUS_SUCCESS);
|
||||
ret = cairo_surface_write_to_png (surface, filename);
|
||||
g_assert_true (ret == CAIRO_STATUS_SUCCESS);
|
||||
|
||||
g_free (filename);
|
||||
}
|
||||
|
@ -34,9 +34,9 @@ get_surface_size (cairo_surface_t *surface,
|
||||
cairo_clip_extents (cr, &x1, &y1, &x2, &y2);
|
||||
cairo_destroy (cr);
|
||||
|
||||
g_assert (x1 == 0 && y1 == 0);
|
||||
g_assert (x2 > 0 && y2 > 0);
|
||||
g_assert ((int) x2 == x2 && (int) y2 == y2);
|
||||
g_assert_true (x1 == 0 && y1 == 0);
|
||||
g_assert_true (x2 > 0 && y2 > 0);
|
||||
g_assert_true ((int) x2 == x2 && (int) y2 == y2);
|
||||
|
||||
*width = x2;
|
||||
*height = y2;
|
||||
@ -62,7 +62,7 @@ coerce_surface_for_comparison (cairo_surface_t *surface,
|
||||
|
||||
cairo_destroy (cr);
|
||||
|
||||
g_assert (cairo_surface_status (coerced) == CAIRO_STATUS_SUCCESS);
|
||||
g_assert_true (cairo_surface_status (coerced) == CAIRO_STATUS_SUCCESS);
|
||||
|
||||
return coerced;
|
||||
}
|
||||
@ -110,7 +110,7 @@ buffer_diff_core (const guchar *buf_a,
|
||||
diff = cairo_image_surface_create (CAIRO_FORMAT_RGB24,
|
||||
width,
|
||||
height);
|
||||
g_assert (cairo_surface_status (diff) == CAIRO_STATUS_SUCCESS);
|
||||
g_assert_true (cairo_surface_status (diff) == CAIRO_STATUS_SUCCESS);
|
||||
buf_diff = cairo_image_surface_get_data (diff);
|
||||
stride_diff = cairo_image_surface_get_stride (diff);
|
||||
row = (guint32 *) (buf_diff + y * stride_diff);
|
||||
|
@ -209,7 +209,7 @@ reftest_inhibit_snapshot (void)
|
||||
G_MODULE_EXPORT void
|
||||
reftest_uninhibit_snapshot (void)
|
||||
{
|
||||
g_assert (inhibit_count > 0);
|
||||
g_assert_true (inhibit_count > 0);
|
||||
inhibit_count--;
|
||||
}
|
||||
|
||||
@ -260,7 +260,7 @@ snapshot_widget (GtkWidget *widget)
|
||||
GdkPaintable *paintable;
|
||||
cairo_surface_t *surface;
|
||||
|
||||
g_assert (gtk_widget_get_realized (widget));
|
||||
g_assert_true (gtk_widget_get_realized (widget));
|
||||
|
||||
loop = g_main_loop_new (NULL, FALSE);
|
||||
|
||||
@ -304,7 +304,7 @@ reftest_snapshot_ui_file (const char *ui_file)
|
||||
g_assert_no_error (error);
|
||||
window = builder_get_toplevel (builder);
|
||||
g_object_unref (builder);
|
||||
g_assert (window);
|
||||
g_assert_true (window);
|
||||
|
||||
gtk_widget_show (window);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user