gtk+ r20431 - in trunk: . gtk/tests
- From: pborelli svn gnome org
- To: svn-commits-list gnome org
- Subject: gtk+ r20431 - in trunk: . gtk/tests
- Date: Tue, 17 Jun 2008 15:46:40 +0000 (UTC)
Author: pborelli
Date: Tue Jun 17 15:46:40 2008
New Revision: 20431
URL: http://svn.gnome.org/viewvc/gtk+?rev=20431&view=rev
Log:
2008-06-17 Paolo Borelli <pborelli katamail com>
* gtk/tests/recentmanager.c: more tests for GtkRecentManager.
Modified:
trunk/ChangeLog
trunk/gtk/tests/recentmanager.c
Modified: trunk/gtk/tests/recentmanager.c
==============================================================================
--- trunk/gtk/tests/recentmanager.c (original)
+++ trunk/gtk/tests/recentmanager.c Tue Jun 17 15:46:40 2008
@@ -22,6 +22,7 @@
#include <gtk/gtk.h>
const gchar *uri = "file:///tmp/testrecentchooser.txt";
+const gchar *uri2 = "file:///tmp/testrecentchooser2.txt";
static void
recent_manager_get_default (void)
@@ -110,6 +111,67 @@
}
static void
+recent_manager_move_item (void)
+{
+ GtkRecentManager *manager;
+ gboolean res;
+ GError *error;
+
+ manager = gtk_recent_manager_get_default ();
+
+ error = NULL;
+ res = gtk_recent_manager_move_item (manager,
+ "file:///tmp/testrecentdoesnotexist.txt",
+ uri2,
+ &error);
+ g_assert (res == FALSE);
+ g_assert (error != NULL);
+ g_assert (error->domain == GTK_RECENT_MANAGER_ERROR);
+ g_assert (error->code == GTK_RECENT_MANAGER_ERROR_NOT_FOUND);
+ g_error_free (error);
+
+ error = NULL;
+ res = gtk_recent_manager_move_item (manager, uri, uri2, &error);
+ g_assert (res == TRUE);
+ g_assert (error == NULL);
+
+ res = gtk_recent_manager_has_item (manager, uri);
+ g_assert (res == FALSE);
+
+ res = gtk_recent_manager_has_item (manager, uri2);
+ g_assert (res == TRUE);
+}
+
+static void
+recent_manager_lookup_item (void)
+{
+ GtkRecentManager *manager;
+ GtkRecentInfo *info;
+ GError *error;
+
+ manager = gtk_recent_manager_get_default ();
+
+ error = NULL;
+ info = gtk_recent_manager_lookup_item (manager,
+ "file:///tmp/testrecentdoesnotexist.txt",
+ &error);
+ g_assert (info == NULL);
+ g_assert (error != NULL);
+ g_assert (error->domain == GTK_RECENT_MANAGER_ERROR);
+ g_assert (error->code == GTK_RECENT_MANAGER_ERROR_NOT_FOUND);
+ g_error_free (error);
+
+ error = NULL;
+ info = gtk_recent_manager_lookup_item (manager, uri2, &error);
+ g_assert (info != NULL);
+ g_assert (error == NULL);
+
+ g_assert (gtk_recent_info_has_application (info, "testrecentchooser"));
+
+ gtk_recent_info_unref (info);
+}
+
+static void
recent_manager_remove_item (void)
{
GtkRecentManager *manager;
@@ -130,14 +192,42 @@
/* remove an item that's actually there */
error = NULL;
- res = gtk_recent_manager_remove_item (manager, uri, &error);
+ res = gtk_recent_manager_remove_item (manager, uri2, &error);
g_assert (res == TRUE);
g_assert (error == NULL);
- res = gtk_recent_manager_has_item (manager, uri);
+ res = gtk_recent_manager_has_item (manager, uri2);
g_assert (res == FALSE);
}
+static void
+recent_manager_purge (void)
+{
+ GtkRecentManager *manager;
+ GtkRecentData *recent_data;
+ gint n;
+ GError *error;
+
+ manager = gtk_recent_manager_get_default ();
+
+ /* purge, add 1, purge again and check that 1 item has been purged */
+ error = NULL;
+ n = gtk_recent_manager_purge_items (manager, &error);
+ g_assert (error == NULL);
+
+ recent_data = g_slice_new0 (GtkRecentData);
+ recent_data->mime_type = "text/plain";
+ recent_data->app_name = "testrecentchooser";
+ recent_data->app_exec = "testrecentchooser %u";
+ gtk_recent_manager_add_full (manager, uri, recent_data);
+ g_slice_free (GtkRecentData, recent_data);
+
+ error = NULL;
+ n = gtk_recent_manager_purge_items (manager, &error);
+ g_assert (error == NULL);
+ g_assert (n == 1);
+}
+
int
main (int argc,
char **argv)
@@ -150,8 +240,14 @@
recent_manager_add);
g_test_add_func ("/recent-manager/has-item",
recent_manager_has_item);
+ g_test_add_func ("/recent-manager/move-item",
+ recent_manager_move_item);
+ g_test_add_func ("/recent-manager/lookup-item",
+ recent_manager_lookup_item);
g_test_add_func ("/recent-manager/remove-item",
recent_manager_remove_item);
+ g_test_add_func ("/recent-manager/purge",
+ recent_manager_purge);
return g_test_run ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]