summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2021-05-07 12:57:55 +0000
committerMatthias Clasen <mclasen@redhat.com>2021-05-07 12:57:55 +0000
commit17a799aeb2eae064e671891f893cc83a5434a767 (patch)
tree6b331e6d1aa3fdb977c4bbae8c01bf9c728c6f1c
parent633d783f0cf088823dcf13b25edf2af75390167b (diff)
parenta3f528301802b029b376531d59e222faf7686076 (diff)
downloadgtk+-17a799aeb2eae064e671891f893cc83a5434a767.tar.gz
Merge branch 'matthiasc/for-master' into 'master'
Add some calendar tests See merge request GNOME/gtk!3528
-rw-r--r--testsuite/gtk/calendar.c64
-rw-r--r--testsuite/gtk/meson.build1
2 files changed, 65 insertions, 0 deletions
diff --git a/testsuite/gtk/calendar.c b/testsuite/gtk/calendar.c
new file mode 100644
index 0000000000..c513f56c41
--- /dev/null
+++ b/testsuite/gtk/calendar.c
@@ -0,0 +1,64 @@
+#include <gtk/gtk.h>
+
+static void
+test_calendar_set_day (void)
+{
+ GtkWidget *cal;
+ GTimeZone *tz;
+ GDateTime *dt;
+ GDateTime *dt2;
+
+ cal = gtk_calendar_new ();
+
+#if GLIB_CHECK_VERSION(2,68,0)
+ tz = g_time_zone_new_identifier ("MET");
+#else
+ tz = g_time_zone_new ("MET");
+#endif
+ g_assert_nonnull (tz);
+ dt = g_date_time_new (tz, 1970, 3, 1, 0, 0, 0);
+ g_assert_nonnull (dt);
+
+ gtk_calendar_select_day (GTK_CALENDAR (cal), dt);
+
+ dt2 = gtk_calendar_get_date (GTK_CALENDAR (cal));
+ g_assert_true (g_date_time_equal (dt, dt2));
+
+ g_date_time_unref (dt);
+ g_date_time_unref (dt2);
+ g_time_zone_unref (tz);
+}
+
+static void
+test_calendar_properties (void)
+{
+ GtkWidget *cal;
+ GDateTime *dt2;
+
+ cal = gtk_calendar_new ();
+
+ g_object_set (cal,
+ "year", 1970,
+ "month", 2, /* March */
+ "day", 1,
+ NULL);
+
+ dt2 = gtk_calendar_get_date (GTK_CALENDAR (cal));
+ g_assert_cmpint (g_date_time_get_year (dt2), ==, 1970);
+ g_assert_cmpint (g_date_time_get_month (dt2), ==, 3);
+ g_assert_cmpint (g_date_time_get_day_of_month (dt2), ==, 1);
+
+ g_date_time_unref (dt2);
+}
+
+int
+main (int argc, char *argv[])
+{
+ gtk_init ();
+ (g_test_init) (&argc, &argv, NULL);
+
+ g_test_add_func ("/calendar/set_day", test_calendar_set_day);
+ g_test_add_func ("/calendar/properties", test_calendar_properties);
+
+ return g_test_run ();
+}
diff --git a/testsuite/gtk/meson.build b/testsuite/gtk/meson.build
index bf812be140..f2d6491287 100644
--- a/testsuite/gtk/meson.build
+++ b/testsuite/gtk/meson.build
@@ -31,6 +31,7 @@ tests = [
'link_args': gtk_tests_export_dynamic_ldflag,
},
{ 'name': 'builderparser' },
+ { 'name': 'calendar' },
{ 'name': 'cellarea' },
{ 'name': 'check-icon-names' },
{ 'name': 'cssprovider' },