[cheese/libcheese] Adding test for CheeseCamera
- From: Luciana Fujii Pontello <lufujii src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [cheese/libcheese] Adding test for CheeseCamera
- Date: Mon, 31 Jan 2011 21:18:16 +0000 (UTC)
commit 8a40a361f0293f3698780c215deee2ca75638ecb
Author: Luciana Fujii Pontello <luciana fujii eti br>
Date: Mon Jan 31 16:57:45 2011 -0200
Adding test for CheeseCamera
cheese-test-camera creates a CheeseCamera and takes a photo that will be
saved in testcamera.jpeg after five seconds.
tests/Makefile.am | 6 +++-
tests/cheese-test-camera.c | 78 ++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 83 insertions(+), 1 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 6a40bb4..5a54375 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -12,7 +12,7 @@ INCLUDES = \
-I top_srcdir@/libcheese \
$(NULL)
-EXAMPLES = cheese-test-widget cheese-test-monitor cheese-test-chooser
+EXAMPLES = cheese-test-widget cheese-test-camera cheese-test-monitor cheese-test-chooser
if HAVE_XTEST
noinst_PROGRAMS = $(EXAMPLES) test-webcam-button
@@ -21,6 +21,7 @@ noinst_PROGRAMS = $(EXAMPLES)
endif
cheese_test_widget_SOURCES = cheese-test-widget.c
+cheese_test_camera_SOURCES = cheese-test-camera.c
cheese_test_monitor_SOURCES = cheese-test-monitor.c
test_webcam_button_SOURCES = test-webcam-button.c
@@ -28,6 +29,9 @@ cheese_test_widget_LDADD = $(CHEESE_LIBS) \
$(top_builddir)/libcheese/libcheese.la \
$(top_builddir)/libcheese/libcheese-gtk.la \
$(NULL)
+cheese_test_camera_LDADD = $(CHEESE_LIBS) \
+ $(top_builddir)/libcheese/libcheese.la \
+ $(NULL)
cheese_test_monitor_LDADD = $(CHEESE_LIBS) \
$(top_builddir)/libcheese/libcheese.la \
$(top_builddir)/libcheese/libcheese-gtk.la \
diff --git a/tests/cheese-test-camera.c b/tests/cheese-test-camera.c
new file mode 100644
index 0000000..516db7c
--- /dev/null
+++ b/tests/cheese-test-camera.c
@@ -0,0 +1,78 @@
+
+#include "cheese-config.h"
+
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+#include <clutter-gtk/clutter-gtk.h>
+#include <gst/gst.h>
+#include "cheese-camera.h"
+
+static gboolean
+delete_callback (GtkWidget *window,
+ GdkEvent *event,
+ gpointer data)
+{
+ gtk_widget_destroy (window);
+ gtk_main_quit ();
+ return FALSE;
+}
+
+static gboolean
+time_cb (CheeseCamera *camera)
+{
+ cheese_camera_take_photo (camera, "testcamera.jpeg");
+ return FALSE;
+}
+
+int
+main (int argc, char **argv)
+{
+ GtkWidget *window;
+ GtkWidget *screen;
+ CheeseCamera *camera;
+ ClutterActor *stage;
+ ClutterActor *texture;
+
+ g_thread_init (NULL);
+ gdk_threads_init ();
+ gst_init (&argc, &argv);
+
+ bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALEDIR);
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+ textdomain (GETTEXT_PACKAGE);
+
+ gtk_clutter_init (&argc, &argv);
+
+ window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ gtk_window_set_default_size (GTK_WINDOW (window), 400, 300);
+ g_signal_connect (G_OBJECT (window), "delete-event",
+ G_CALLBACK (delete_callback), NULL);
+
+ screen = gtk_clutter_embed_new ();
+ stage = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (screen));
+ texture = clutter_texture_new ();
+
+ clutter_actor_set_size (texture, 400, 300);
+ clutter_container_add_actor (CLUTTER_CONTAINER (stage), texture);
+
+ gtk_widget_show (screen);
+ clutter_actor_show (texture);
+
+ gdk_threads_enter ();
+ camera = cheese_camera_new (CLUTTER_TEXTURE (texture), NULL, 640, 480);
+ gdk_threads_leave ();
+
+ cheese_camera_setup (camera, NULL, NULL);
+
+ gtk_container_add (GTK_CONTAINER (window), screen);
+
+ gtk_widget_show_all (window);
+
+ cheese_camera_play (camera);
+
+ g_timeout_add_seconds (5, (GSourceFunc) (time_cb), camera);
+
+ gtk_main ();
+
+ return 0;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]