1 | #include <gtk/gtk.h> |
2 | |
3 | static void |
4 | test_calendar_set_day (void) |
5 | { |
6 | GtkWidget *cal; |
7 | GTimeZone *tz; |
8 | GDateTime *dt; |
9 | GDateTime *dt2; |
10 | |
11 | cal = gtk_calendar_new (); |
12 | |
13 | #if GLIB_CHECK_VERSION(2,68,0) |
14 | tz = g_time_zone_new_identifier (identifier: "MET" ); |
15 | #else |
16 | tz = g_time_zone_new ("MET" ); |
17 | #endif |
18 | g_assert_nonnull (tz); |
19 | dt = g_date_time_new (tz, year: 1970, month: 3, day: 1, hour: 0, minute: 0, seconds: 0); |
20 | g_assert_nonnull (dt); |
21 | |
22 | gtk_calendar_select_day (GTK_CALENDAR (cal), date: dt); |
23 | |
24 | dt2 = gtk_calendar_get_date (GTK_CALENDAR (cal)); |
25 | g_assert_true (g_date_time_equal (dt, dt2)); |
26 | |
27 | g_date_time_unref (datetime: dt); |
28 | g_date_time_unref (datetime: dt2); |
29 | g_time_zone_unref (tz); |
30 | } |
31 | |
32 | static void |
33 | test_calendar_properties (void) |
34 | { |
35 | GtkWidget *cal; |
36 | GDateTime *dt2; |
37 | |
38 | cal = gtk_calendar_new (); |
39 | |
40 | g_object_set (object: cal, |
41 | first_property_name: "year" , 1970, |
42 | "month" , 2, /* March */ |
43 | "day" , 1, |
44 | NULL); |
45 | |
46 | dt2 = gtk_calendar_get_date (GTK_CALENDAR (cal)); |
47 | g_assert_cmpint (g_date_time_get_year (dt2), ==, 1970); |
48 | g_assert_cmpint (g_date_time_get_month (dt2), ==, 3); |
49 | g_assert_cmpint (g_date_time_get_day_of_month (dt2), ==, 1); |
50 | |
51 | g_date_time_unref (datetime: dt2); |
52 | } |
53 | |
54 | int |
55 | main (int argc, char *argv[]) |
56 | { |
57 | gtk_init (); |
58 | (g_test_init) (argc: &argc, argv: &argv, NULL); |
59 | |
60 | g_test_add_func (testpath: "/calendar/set_day" , test_func: test_calendar_set_day); |
61 | g_test_add_func (testpath: "/calendar/properties" , test_func: test_calendar_properties); |
62 | |
63 | return g_test_run (); |
64 | } |
65 | |