2 * Copyright © 2011 Lucas Baudin <xapantu@gmail.com>
4 * Licensed under the GNU General Public License Version 2
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 #include <glib/gi18n.h>
27 #include <clutter-gtk/clutter-gtk.h>
28 #include "cheese-avatar-chooser.h"
29 #include "cheese-flash.h"
30 #include "cheese-widget.h"
31 #include "um-crop-area.h"
32 #include "cheese-gtk.h"
34 /* CheeseAvatarChooser */
38 GtkWidget
*chooser
, *select_button
;
40 chooser
= gtk_test_create_widget (CHEESE_TYPE_AVATAR_CHOOSER
, NULL
);
41 g_assert (chooser
!= NULL
);
43 /* Check that all the child widgets were successfully instantiated. */
44 select_button
= gtk_test_find_widget (chooser
, "Select", GTK_TYPE_BUTTON
);
45 g_assert (select_button
!= NULL
);
46 g_assert (GTK_IS_BUTTON (select_button
));
53 GtkWidget
*flash
, *window
;
55 window
= gtk_test_create_simple_window ("CheeseFlash", "CheeseFlash test");
56 g_assert (window
!= NULL
);
58 /* Window must be realised to have a GdkWindow. */
59 gtk_widget_show (window
);
61 flash
= gtk_test_create_widget (CHEESE_TYPE_FLASH
, "parent", window
, NULL
);
62 g_assert (flash
!= NULL
);
64 cheese_flash_fire (CHEESE_FLASH (flash
));
72 GdkPixbuf
*pixbuf
, *pixbuf2
;
74 crop_area
= gtk_test_create_widget (UM_TYPE_CROP_AREA
, NULL
);
75 pixbuf
= gdk_pixbuf_new (GDK_COLORSPACE_RGB
, FALSE
, 8, 800, 480);
76 um_crop_area_set_min_size (UM_CROP_AREA (crop_area
), 200, 100);
77 um_crop_area_set_picture (UM_CROP_AREA (crop_area
), pixbuf
);
78 pixbuf2
= um_crop_area_get_picture (UM_CROP_AREA (crop_area
));
80 /* It must be 2*min_size. */
81 g_assert_cmpint (gdk_pixbuf_get_width (pixbuf2
), ==, 400);
82 g_assert_cmpint (gdk_pixbuf_get_height (pixbuf2
), ==, 200);
84 g_object_unref (pixbuf
);
85 g_object_unref (pixbuf2
);
89 static void widget (void)
93 widget
= gtk_test_create_widget (CHEESE_TYPE_WIDGET
, NULL
);
94 g_assert (widget
!= NULL
);
97 int main (int argc
, gchar
*argv
[])
99 gtk_test_init (&argc
, &argv
, NULL
);
100 if (!cheese_gtk_init (&argc
, &argv
))
103 g_test_add_func ("/libcheese-gtk/avatar_chooser", avatar_chooser
);
104 g_test_add_func ("/libcheese-gtk/flash", flash
);
105 g_test_add_func ("/libcheese-gtk/um_crop_area", um_crop_area
);
106 g_test_add_func ("/libcheese-gtk/widget", widget
);
108 return g_test_run ();