mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-28 22:41:43 +00:00
testsuite: fix recentmanager failure on win32
Replace unsupported and deprecated 'g_test_trap_fork' by 'g_test_subprocess'. Force 'gtk-recent-files-enabled' to TRUE.
This commit is contained in:
parent
0b0a5a52af
commit
f96c72c4b3
@ -36,6 +36,96 @@ recent_manager_get_default (void)
|
||||
g_assert_true (manager == manager2);
|
||||
}
|
||||
|
||||
static void
|
||||
recent_manager_add_nomime (void)
|
||||
{
|
||||
if (g_test_subprocess ())
|
||||
{
|
||||
GtkRecentManager *manager;
|
||||
GtkRecentData *recent_data;
|
||||
gboolean res;
|
||||
|
||||
manager = gtk_recent_manager_get_default ();
|
||||
|
||||
recent_data = g_new0 (GtkRecentData, 1);
|
||||
|
||||
/* mime type is mandatory */
|
||||
recent_data->mime_type = NULL;
|
||||
recent_data->app_name = (char *)"testrecentchooser";
|
||||
recent_data->app_exec = (char *)"testrecentchooser %u";
|
||||
|
||||
res = gtk_recent_manager_add_full (manager, uri, recent_data);
|
||||
g_assert_false (res);
|
||||
|
||||
g_free (recent_data);
|
||||
return;
|
||||
}
|
||||
|
||||
g_test_trap_subprocess (NULL, 0, 0);
|
||||
g_test_trap_assert_stderr ("*no MIME type was defined*");
|
||||
g_test_trap_assert_failed ();
|
||||
}
|
||||
|
||||
static void
|
||||
recent_manager_add_noapp (void)
|
||||
{
|
||||
if (g_test_subprocess ())
|
||||
{
|
||||
GtkRecentManager *manager;
|
||||
GtkRecentData *recent_data;
|
||||
gboolean res;
|
||||
|
||||
manager = gtk_recent_manager_get_default ();
|
||||
|
||||
recent_data = g_new0 (GtkRecentData, 1);
|
||||
|
||||
/* app name is mandatory */
|
||||
recent_data->mime_type = (char *)"text/plain";
|
||||
recent_data->app_name = NULL;
|
||||
recent_data->app_exec = (char *)"testrecentchooser %u";
|
||||
|
||||
res = gtk_recent_manager_add_full (manager, uri, recent_data);
|
||||
g_assert_false (res);
|
||||
|
||||
g_free (recent_data);
|
||||
return;
|
||||
}
|
||||
|
||||
g_test_trap_subprocess (NULL, 0, 0);
|
||||
g_test_trap_assert_stderr ("*no name of the application*");
|
||||
g_test_trap_assert_failed ();
|
||||
}
|
||||
|
||||
static void
|
||||
recent_manager_add_noexe (void)
|
||||
{
|
||||
if (g_test_subprocess ())
|
||||
{
|
||||
GtkRecentManager *manager;
|
||||
GtkRecentData *recent_data;
|
||||
gboolean res;
|
||||
|
||||
manager = gtk_recent_manager_get_default ();
|
||||
|
||||
recent_data = g_new0 (GtkRecentData, 1);
|
||||
|
||||
/* app exec is mandatory */
|
||||
recent_data->mime_type = (char *)"text/plain";
|
||||
recent_data->app_name = (char *)"testrecentchooser";
|
||||
recent_data->app_exec = NULL;
|
||||
|
||||
res = gtk_recent_manager_add_full (manager, uri, recent_data);
|
||||
g_assert_false (res);
|
||||
|
||||
g_free (recent_data);
|
||||
return;
|
||||
}
|
||||
|
||||
g_test_trap_subprocess (NULL, 0, 0);
|
||||
g_test_trap_assert_stderr ("*no command line for the application*");
|
||||
g_test_trap_assert_failed ();
|
||||
}
|
||||
|
||||
static void
|
||||
recent_manager_add (void)
|
||||
{
|
||||
@ -47,43 +137,6 @@ recent_manager_add (void)
|
||||
|
||||
recent_data = g_new0 (GtkRecentData, 1);
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
|
||||
|
||||
/* mime type is mandatory */
|
||||
recent_data->mime_type = NULL;
|
||||
recent_data->app_name = (char *)"testrecentchooser";
|
||||
recent_data->app_exec = (char *)"testrecentchooser %u";
|
||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
|
||||
{
|
||||
res = gtk_recent_manager_add_full (manager, uri, recent_data);
|
||||
g_assert_false (res);
|
||||
}
|
||||
g_test_trap_assert_failed ();
|
||||
|
||||
/* app name is mandatory */
|
||||
recent_data->mime_type = (char *)"text/plain";
|
||||
recent_data->app_name = NULL;
|
||||
recent_data->app_exec = (char *)"testrecentchooser %u";
|
||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
|
||||
{
|
||||
res = gtk_recent_manager_add_full (manager, uri, recent_data);
|
||||
g_assert_false (res);
|
||||
}
|
||||
g_test_trap_assert_failed ();
|
||||
|
||||
/* app exec is mandatory */
|
||||
recent_data->mime_type = (char *)"text/plain";
|
||||
recent_data->app_name = (char *)"testrecentchooser";
|
||||
recent_data->app_exec = NULL;
|
||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
|
||||
{
|
||||
res = gtk_recent_manager_add_full (manager, uri, recent_data);
|
||||
g_assert_false (res);
|
||||
}
|
||||
g_test_trap_assert_failed ();
|
||||
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS;
|
||||
|
||||
recent_data->mime_type = (char *)"text/plain";
|
||||
recent_data->app_name = (char *)"testrecentchooser";
|
||||
recent_data->app_exec = (char *)"testrecentchooser %u";
|
||||
@ -302,7 +355,14 @@ main (int argc,
|
||||
{
|
||||
gtk_test_init (&argc, &argv, NULL);
|
||||
|
||||
g_object_set (gtk_settings_get_default (),
|
||||
"gtk-recent-files-enabled", TRUE,
|
||||
NULL);
|
||||
|
||||
g_test_add_func ("/recent-manager/get-default", recent_manager_get_default);
|
||||
g_test_add_func ("/recent-manager/add-nomime", recent_manager_add_nomime);
|
||||
g_test_add_func ("/recent-manager/add-noapp", recent_manager_add_noapp);
|
||||
g_test_add_func ("/recent-manager/add-noexe", recent_manager_add_noexe);
|
||||
g_test_add_func ("/recent-manager/add", recent_manager_add);
|
||||
g_test_add_func ("/recent-manager/add-many", recent_manager_add_many);
|
||||
g_test_add_func ("/recent-manager/has-item", recent_manager_has_item);
|
||||
|
Loading…
Reference in New Issue
Block a user