[maemo-commits] [maemo-commits] r16573 - in projects/haf/trunk/hildon-thumbnail: . daemon tests thumbs
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Tue Nov 4 18:50:33 EET 2008
- Previous message: [maemo-commits] r16572 - projects/haf/tags/hildon-fm
- Next message: [maemo-commits] r16574 - in projects/haf/trunk/hildon-thumbnail: . daemon tests thumbs
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: pvanhoof Date: 2008-11-04 18:50:30 +0200 (Tue, 04 Nov 2008) New Revision: 16573 Modified: projects/haf/trunk/hildon-thumbnail/ChangeLog projects/haf/trunk/hildon-thumbnail/daemon/thumbnailer.c projects/haf/trunk/hildon-thumbnail/tests/tests.c projects/haf/trunk/hildon-thumbnail/thumbs/hildon-albumart-factory.h projects/haf/trunk/hildon-thumbnail/thumbs/hildon-thumbnail-factory.c projects/haf/trunk/hildon-thumbnail/thumbs/hildon-thumbnail-factory.h projects/haf/trunk/hildon-thumbnail/thumbs/hildon-thumbnail-obj.c Log: 2008-11-04 Philip Van Hoof <philip at codeminded.be> * tests/tests.c * thumbs/hildon-thumbnail-factory.c * thumbs/hildon-thumbnail-obj.c * thumbs/hildon-thumbnail-factory.h * thumbs/hildon-albumart-factory.h * daemon/thumbnailer.c: Fixed several serious bugs after performing some tests. Fixed the tests to also test the new client API Modified: projects/haf/trunk/hildon-thumbnail/ChangeLog =================================================================== --- projects/haf/trunk/hildon-thumbnail/ChangeLog 2008-11-04 16:17:38 UTC (rev 16572) +++ projects/haf/trunk/hildon-thumbnail/ChangeLog 2008-11-04 16:50:30 UTC (rev 16573) @@ -1,3 +1,13 @@ +2008-11-04 Philip Van Hoof <philip at codeminded.be> + + * tests/tests.c + * thumbs/hildon-thumbnail-factory.c + * thumbs/hildon-thumbnail-obj.c + * thumbs/hildon-thumbnail-factory.h + * thumbs/hildon-albumart-factory.h + * daemon/thumbnailer.c: Fixed several serious bugs after performing some + tests. Fixed the tests to also test the new client API + 2008-11-03 Philip Van Hoof <philip at codeminded.be> * thumbs/hildon-thumbnail-factory.c Modified: projects/haf/trunk/hildon-thumbnail/daemon/thumbnailer.c =================================================================== --- projects/haf/trunk/hildon-thumbnail/daemon/thumbnailer.c 2008-11-04 16:17:38 UTC (rev 16572) +++ projects/haf/trunk/hildon-thumbnail/daemon/thumbnailer.c 2008-11-04 16:50:30 UTC (rev 16573) @@ -397,6 +397,9 @@ "ftps://", "dav://", "nfs://", NULL }; + g_signal_emit (task->object, signals[STARTED_SIGNAL], 0, + task->num); + g_mutex_lock (priv->mutex); priv->tasks = g_list_remove (priv->tasks, task); if (task->unqueued) { @@ -408,9 +411,6 @@ /* We split the request into groups that have items with the same * mime-type and one group with items that already have a thumbnail */ - g_signal_emit (task->object, signals[STARTED_SIGNAL], 0, - task->num); - schemes = g_hash_table_new_full (g_str_hash, g_str_equal, (GDestroyNotify) g_free, (GDestroyNotify) g_hash_table_unref); @@ -718,11 +718,12 @@ g_hash_table_unref (schemes); + +unqueued: + g_signal_emit (task->object, signals[FINISHED_SIGNAL], 0, task->num); -unqueued: - g_object_unref (task->object); g_strfreev (task->urls); if (task->mime_types) @@ -746,7 +747,7 @@ while (from_urls[i] != NULL && to_urls[i] != NULL) { guint y = 0; - for (y = 0; i < 2; y++ ) { + for (y = 0; y < 2; y++ ) { const gchar *from_uri = from_urls[i]; const gchar *to_uri = to_urls[i]; gchar *from_normal = NULL, @@ -799,7 +800,7 @@ while (from_urls[i] != NULL && to_urls[i] != NULL) { guint y = 0; - for (y = 0; i < 2; y++ ) { + for (y = 0; y < 2; y++ ) { const gchar *from_uri = from_urls[i]; const gchar *to_uri = to_urls[i]; gchar *from_s[3] = { NULL, NULL, NULL }; @@ -862,7 +863,7 @@ while (urls[i] != NULL) { guint y = 0; - for (y = 0; i < 2; y++ ) { + for (y = 0; y < 2; y++ ) { const gchar *uri = urls[i]; gchar *normal = NULL, *large = NULL, @@ -1007,8 +1008,9 @@ NULL, NULL, thumbnailer_marshal_VOID__UINT_BOXED_INT_STRING, G_TYPE_NONE, - 3, + 4, G_TYPE_UINT, + G_TYPE_BOXED, G_TYPE_INT, G_TYPE_STRING); Modified: projects/haf/trunk/hildon-thumbnail/tests/tests.c =================================================================== --- projects/haf/trunk/hildon-thumbnail/tests/tests.c 2008-11-04 16:17:38 UTC (rev 16572) +++ projects/haf/trunk/hildon-thumbnail/tests/tests.c 2008-11-04 16:50:30 UTC (rev 16573) @@ -53,6 +53,12 @@ } } +void thumb_callback_new (HildonThumbnailFactory *self, GdkPixbuf *thumbnail, GError *error, gpointer user_data) +{ + g_message("Callback invoked, pixbuf=%08X, error=%s", (int)thumbnail, + error ? error->message : "NULL"); +} + gchar *to_uri(gchar *file) { gchar *str; gchar *cur = g_get_current_dir(); @@ -67,7 +73,7 @@ } // Works only when current directory == top build directory -void test_thumbs() { +void test_thumbs_old() { HildonThumbnailFactoryHandle h, h1, h2; gchar *uri1, *uri2, *uri3,*uri4; char *file1 = "tests/images/Debian.jpg"; @@ -166,6 +172,67 @@ g_free(uri4); } +void test_thumbs_new() { + HildonThumbnailFactory *f; + HildonThumbnailRequest *h1, *h2, *h3, *h4; + + gchar *uri1, *uri2, *uri3,*uri4; + char *file1 = "tests/images/Debian.jpg"; + char *file2 = "tests/images/Splash-Debian.png"; + char *file3 = "tests/images/error-test.png"; + char *file4 = "tests/images/test.mp3"; + + uri1 = to_uri(file1); + uri2 = to_uri(file2); + uri3 = to_uri(file3); + uri4 = to_uri(file4); + + printf("--- Loading new tests ---\n"); + + f = hildon_thumbnail_factory_get_instance (); + + h1 = hildon_thumbnail_factory_request_pixbuf (f, uri1, + 100, 100, FALSE, "image/png", thumb_callback_new, + NULL, NULL); + h2 = hildon_thumbnail_factory_request_pixbuf (f, uri3, + 100, 100, FALSE,"image/png", thumb_callback_new, + NULL, NULL); + h3 = hildon_thumbnail_factory_request_pixbuf (f, uri4, + 100, 100, TRUE, "image/png", thumb_callback_new, + NULL, NULL); + h4 = hildon_thumbnail_factory_request_pixbuf (f, uri4, + 100, 100, FALSE, "image/png", thumb_callback_new, + NULL, NULL); + + + + hildon_thumbnail_factory_join (f); + + g_object_unref (h1); + g_object_unref (h2); + g_object_unref (h3); + g_object_unref (h4); + + g_object_unref (f); + + printf("--- Filemanager tests ---\n"); + // File management functionality + rename(file1, file3); + hildon_thumbnail_factory_move(uri1, uri3); + rename(file3, file1); + hildon_thumbnail_factory_move(uri3, uri1); + link(file1, file3); + hildon_thumbnail_factory_copy(uri1, uri3); + unlink(file3); + hildon_thumbnail_factory_remove(uri3); + + g_free(uri1); + g_free(uri2); + g_free(uri3); + g_free(uri4); +} + + void test_clean() { printf("--- Clean test ---\n"); @@ -176,12 +243,16 @@ int main() { printf("Running tests...\n"); + g_type_init (); + if(!g_file_test("tests/images", G_FILE_TEST_IS_DIR)) { g_error("Tester can't find test images in tests/images directory"); return 1; } + GMainLoop *loop = g_main_loop_new (NULL, FALSE); + hildon_thumbnail_factory_set_debug(TRUE); /* @@ -195,8 +266,17 @@ g_warning("Warning test"); test_clean(); - test_thumbs(); + test_thumbs_old(); + test_clean(); + test_thumbs_new(); + + g_timeout_add_seconds (10, (GSourceFunc) g_main_loop_quit, loop); + + g_main_loop_run (loop); + + g_main_loop_unref (loop); + printf("Done!\n"); return 0; } Modified: projects/haf/trunk/hildon-thumbnail/thumbs/hildon-albumart-factory.h =================================================================== --- projects/haf/trunk/hildon-thumbnail/thumbs/hildon-albumart-factory.h 2008-11-04 16:17:38 UTC (rev 16572) +++ projects/haf/trunk/hildon-thumbnail/thumbs/hildon-albumart-factory.h 2008-11-04 16:50:30 UTC (rev 16573) @@ -51,19 +51,19 @@ typedef struct _HildonAlbumartRequestClass HildonAlbumartRequestClass; struct _HildonAlbumartFactory { - GObject *parent; + GObject parent; }; struct _HildonAlbumartFactoryClass { - GObjectClass *parent_class; + GObjectClass parent_class; }; struct _HildonAlbumartRequest { - GObject *parent; + GObject parent; }; struct _HildonAlbumartRequestClass { - GObjectClass *parent_class; + GObjectClass parent_class; }; GType hildon_albumart_factory_get_type (void); Modified: projects/haf/trunk/hildon-thumbnail/thumbs/hildon-thumbnail-factory.c =================================================================== --- projects/haf/trunk/hildon-thumbnail/thumbs/hildon-thumbnail-factory.c 2008-11-04 16:17:38 UTC (rev 16572) +++ projects/haf/trunk/hildon-thumbnail/thumbs/hildon-thumbnail-factory.c 2008-11-04 16:50:30 UTC (rev 16573) @@ -371,6 +371,8 @@ g_free (cropped_dir); } +static gboolean waiting_for_cb = FALSE; + static void on_got_handle (DBusGProxy *proxy, guint OUT_handle, GError *error, gpointer userdata) { @@ -384,6 +386,8 @@ item->callback (item, item->user_data, NULL, error); g_free (key); } + waiting_for_cb = FALSE; + } typedef struct { @@ -570,6 +574,7 @@ } else mimes = NULL; + waiting_for_cb = TRUE; org_freedesktop_thumbnailer_Generic_queue_async (proxy, (const char **) uris, (const char **) mimes, @@ -597,23 +602,23 @@ static void on_cancelled (DBusGProxy *proxy, GError *error, gpointer userdata) { - ThumbsItem *item = userdata; - gchar *key = g_strdup_printf ("%d", item->handle_id); - - /* Unregister the item */ - g_hash_table_remove (tasks, key); - g_free (key); } void hildon_thumbnail_factory_cancel(HildonThumbnailFactoryHandle handle) { ThumbsItem *item = THUMBS_ITEM (handle); + gchar *key; init(); if (item->handle_id == 0) return; + key = g_strdup_printf ("%d", item->handle_id); + /* Unregister the item */ + g_hash_table_remove (tasks, key); + g_free (key); + /* We don't do real canceling, we just do unqueing */ org_freedesktop_thumbnailer_Generic_unqueue_async (proxy, item->handle_id, on_cancelled, item); @@ -624,8 +629,11 @@ { init(); + while (waiting_for_cb) + g_main_context_iteration (NULL, FALSE); + while(g_hash_table_size (tasks) != 0) { - g_main_context_iteration(NULL, TRUE); + g_main_context_iteration(NULL, FALSE); } } Modified: projects/haf/trunk/hildon-thumbnail/thumbs/hildon-thumbnail-factory.h =================================================================== --- projects/haf/trunk/hildon-thumbnail/thumbs/hildon-thumbnail-factory.h 2008-11-04 16:17:38 UTC (rev 16572) +++ projects/haf/trunk/hildon-thumbnail/thumbs/hildon-thumbnail-factory.h 2008-11-04 16:50:30 UTC (rev 16573) @@ -51,19 +51,19 @@ typedef struct _HildonThumbnailRequestClass HildonThumbnailRequestClass; struct _HildonThumbnailFactory { - GObject *parent; + GObject parent; }; struct _HildonThumbnailFactoryClass { - GObjectClass *parent_class; + GObjectClass parent_class; }; struct _HildonThumbnailRequest { - GObject *parent; + GObject parent; }; struct _HildonThumbnailRequestClass { - GObjectClass *parent_class; + GObjectClass parent_class; }; GType hildon_thumbnail_factory_get_type (void); Modified: projects/haf/trunk/hildon-thumbnail/thumbs/hildon-thumbnail-obj.c =================================================================== --- projects/haf/trunk/hildon-thumbnail/thumbs/hildon-thumbnail-obj.c 2008-11-04 16:17:38 UTC (rev 16572) +++ projects/haf/trunk/hildon-thumbnail/thumbs/hildon-thumbnail-obj.c 2008-11-04 16:50:30 UTC (rev 16573) @@ -204,6 +204,7 @@ g_free (key); } +static gboolean waiting_for_cb = FALSE; static void on_task_error (DBusGProxy *proxy, @@ -353,6 +354,7 @@ g_type_class_add_private (object_class, sizeof (HildonThumbnailFactoryPrivate)); } + static void on_got_handle (DBusGProxy *proxy, guint OUT_handle, GError *error, gpointer userdata) { @@ -373,6 +375,8 @@ r_priv->ucallback (r_priv->factory, NULL, error, r_priv->user_data); } + waiting_for_cb = FALSE; + g_object_unref (request); } @@ -435,6 +439,7 @@ } if (!have) { + waiting_for_cb = TRUE; org_freedesktop_thumbnailer_Generic_queue_async (f_priv->proxy, (const char **) r_priv->uris, (const char **) mime_types, @@ -494,8 +499,11 @@ { HildonThumbnailFactoryPrivate *f_priv = FACTORY_GET_PRIVATE (self); + while (waiting_for_cb) + g_main_context_iteration (NULL, FALSE); + while(g_hash_table_size (f_priv->tasks) != 0) { - g_main_context_iteration (NULL, TRUE); + g_main_context_iteration (NULL, FALSE); } } @@ -529,8 +537,11 @@ HildonThumbnailFactoryPrivate *f_priv = FACTORY_GET_PRIVATE (r_priv->factory); HildonThumbnailRequest *found = g_hash_table_lookup (f_priv->tasks, r_priv->key); + while (waiting_for_cb) + g_main_context_iteration (NULL, FALSE); + while (found) { - g_main_context_iteration (NULL, TRUE); + g_main_context_iteration (NULL, FALSE); found = g_hash_table_lookup (f_priv->tasks, r_priv->key); } }
- Previous message: [maemo-commits] r16572 - projects/haf/tags/hildon-fm
- Next message: [maemo-commits] r16574 - in projects/haf/trunk/hildon-thumbnail: . daemon tests thumbs
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]