2 * This file is part of hildon-libs
4 * Copyright (C) 2005 Nokia Corporation.
6 * Contact: Luc Pionchon <luc.pionchon@nokia.com>
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public License
10 * as published by the Free Software Foundation; either version 2.1 of
11 * the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
33 #include <hildon-widgets/hildon-date-editor.h>
34 #include <hildon-widgets/hildon-time-editor.h>
35 #include <hildon-widgets/hildon-calendar-popup.h>
40 void init_test (void);
41 testcase* get_tests (void);
46 gtk_init (&plop, NULL);
49 /* time editor: new time: ok parameters */
52 HildonTimeEditor *time_editor;
55 time_editor = HILDON_TIME_EDITOR(hildon_time_editor_new());
60 /* time editor: get time: ok parameters */
63 HildonTimeEditor *time_editor;
64 guint hours = 99, minutes = 99, seconds = 99;
68 time_editor = HILDON_TIME_EDITOR(hildon_time_editor_new());
69 hildon_time_editor_get_time( time_editor, &hours, &minutes, &seconds );
71 assert (hours >= 0 && hours < 24);
72 assert (minutes >= 0 && minutes < 60);
73 assert (seconds >= 0 && seconds < 60);
78 /* time editor: get time: null time editor */
81 HildonTimeEditor *time_editor = NULL;
82 guint hours = 99, minutes = 99, seconds = 99;
86 hildon_time_editor_get_time( time_editor, &hours, &minutes, &seconds );
88 assert (hours >= 0 && hours < 24);
89 assert (minutes >= 0 && minutes < 60);
90 assert (seconds >= 0 && seconds < 60);
95 /* time editor: get time: null minutes */
98 HildonTimeEditor *time_editor = NULL;
99 guint hours = 99, seconds = 99;
103 hildon_time_editor_get_time (time_editor, &hours, NULL, &seconds);
108 /* time editor: get time: null hours */
111 HildonTimeEditor *time_editor = NULL;
112 guint minutes = 99, seconds = 99;
116 hildon_time_editor_get_time (time_editor, NULL, &minutes, &seconds);
121 /* time editor: get time: null hours, null minutes, null seconds */
124 HildonTimeEditor *time_editor = NULL;
128 hildon_time_editor_get_time (time_editor, NULL, NULL, NULL);
133 /* time editor: get time: null seconds */
136 HildonTimeEditor *time_editor = NULL;
137 guint hours = 99, minutes = 99;;
141 hildon_time_editor_get_time (time_editor, &hours, &minutes, NULL);
146 /* time editor: set time: hours, minutes, seconds are the minimum */
149 HildonTimeEditor *time_editor;
150 guint hours = 0, minutes = 0, seconds = 0;
154 time_editor = HILDON_TIME_EDITOR(hildon_time_editor_new());
156 hildon_time_editor_set_time (time_editor, hours, minutes, seconds);
157 hildon_time_editor_get_time (time_editor, &hours, &minutes, &seconds);
160 assert (minutes == 0);
161 assert (seconds == 0);
166 /* time editor: set time: ok parameters */
169 HildonTimeEditor *time_editor;
170 guint hours = 12, minutes = 30, seconds = 30;
174 time_editor = HILDON_TIME_EDITOR(hildon_time_editor_new());
176 hildon_time_editor_set_time (time_editor, hours, minutes, seconds);
177 hildon_time_editor_get_time (time_editor, &hours, &minutes, &seconds);
179 assert (hours == 12);
180 assert (minutes == 30);
181 assert (seconds == 30);
186 /* time editor: set time: hours on limit */
189 HildonTimeEditor *time_editor;
190 guint hours = 24, minutes = 30, seconds = 0;
194 time_editor = HILDON_TIME_EDITOR(hildon_time_editor_new());
196 hildon_time_editor_set_time (time_editor, hours, minutes, seconds);
197 hildon_time_editor_get_time (time_editor, &hours, &minutes, &seconds);
199 assert (hours == 24);
200 assert (minutes == 30);
201 assert (seconds == 0);
207 /* time editor: set time: minutes on limit */
210 HildonTimeEditor *time_editor;
211 guint hours = 12, minutes = 60, seconds = 0;
215 time_editor = HILDON_TIME_EDITOR(hildon_time_editor_new());
217 hildon_time_editor_set_time (time_editor, hours, minutes, seconds);
218 hildon_time_editor_get_time (time_editor, &hours, &minutes, &seconds);
220 assert (hours == 12);
221 assert (minutes == 60);
222 assert (seconds == 0);
228 /* time editor: set time: seconds on limit */
229 static int test03da()
231 HildonTimeEditor *time_editor;
232 guint hours = 12, minutes = 30, seconds = 60;
236 time_editor = HILDON_TIME_EDITOR(hildon_time_editor_new());
238 hildon_time_editor_set_time (time_editor, hours, minutes, seconds);
239 hildon_time_editor_get_time (time_editor, &hours, &minutes, &seconds);
241 assert (hours == 12);
242 assert (minutes == 30);
243 assert (seconds == 60);
249 /* time editor: set time: hours, minutes on limit */
252 HildonTimeEditor *time_editor;
253 guint hours = 24, minutes = 60, seconds = 0;
257 time_editor = HILDON_TIME_EDITOR(hildon_time_editor_new());
259 hildon_time_editor_set_time (time_editor, hours, minutes, seconds);
260 hildon_time_editor_get_time (time_editor, &hours, &minutes, &seconds);
262 assert (hours == 24);
263 assert (minutes == 60);
264 assert (seconds == 0);
269 /* time editor: set time: hours, minutes, second on limit */
270 static int test03ea()
272 HildonTimeEditor *time_editor;
273 guint hours = 24, minutes = 60, seconds = 60;
277 time_editor = HILDON_TIME_EDITOR(hildon_time_editor_new());
279 hildon_time_editor_set_time (time_editor, hours, minutes, seconds);
280 hildon_time_editor_get_time (time_editor, &hours, &minutes, &seconds);
282 assert( hours == 24 );
283 assert( minutes == 60 );
284 assert( seconds == 60 );
289 /* time editor: set time: hours, minutes over max */
292 HildonTimeEditor *time_editor;
293 guint hours = 25, minutes = 61, seconds = 0;
297 time_editor = HILDON_TIME_EDITOR(hildon_time_editor_new());
299 hildon_time_editor_set_time (time_editor, hours, minutes, seconds);
300 hildon_time_editor_get_time (time_editor, &hours, &minutes, &seconds);
302 assert (hours == 25);
303 assert (minutes == 61);
304 assert (seconds == 0);
309 /* time editor: set time: hours, minutes, seconds over max */
310 static int test03fa()
312 HildonTimeEditor *time_editor;
313 guint hours = 25, minutes = 61, seconds = 61;
317 time_editor = HILDON_TIME_EDITOR(hildon_time_editor_new());
319 hildon_time_editor_set_time (time_editor, hours, minutes, seconds);
320 hildon_time_editor_get_time (time_editor, &hours, &minutes, &seconds);
322 assert (hours == 25);
323 assert (minutes == 61);
324 assert (seconds == 61);
329 /* time editor: set time: null time editor*/
332 HildonTimeEditor *time_editor = NULL;
333 guint hours = 23, minutes = 59, seconds = 0;
337 hildon_time_editor_set_time (time_editor, hours, minutes, seconds);
342 /* time editor: show seconds: ok parameters */
345 HildonTimeEditor *time_editor = NULL;
349 time_editor = HILDON_TIME_EDITOR( hildon_time_editor_new () );
350 #ifndef HILDON_DISABLE_DEPRECATED
351 hildon_time_editor_show_seconds( time_editor, TRUE );
353 hildon_time_editor_set_show_seconds (time_editor, TRUE);
359 /* time editor: show seconds: null time editor*/
362 HildonTimeEditor *time_editor = NULL;
364 #ifndef HILDON_DISABLE_DEPRECATED
365 hildon_time_editor_show_seconds( time_editor, TRUE );
367 hildon_time_editor_set_show_seconds (time_editor, TRUE);
373 /* time editor: get type: */
380 t = hildon_time_editor_get_type();
387 /* date editor: new: ok parameters */
390 HildonDateEditor *date_editor;
393 date_editor = HILDON_DATE_EDITOR(hildon_date_editor_new());
394 assert (date_editor);
398 /* date editor: get date: ok parameters */
401 HildonDateEditor *date_editor;
402 guint year = 99999, month = 99, day = 999;
406 date_editor = HILDON_DATE_EDITOR(hildon_date_editor_new());
408 hildon_date_editor_get_date (date_editor, &year, &month, &day);
411 assert (month > 0 && month < 13);
412 assert (day > 0 && day < 32);
417 /* date editor: get date: null date editor */
420 HildonDateEditor *date_editor = NULL;
421 guint year = 99999, month = 99, day = 999;
425 hildon_date_editor_get_date (date_editor, &year, &month, &day);
428 assert (month > 0 && month < 13);
429 assert (day > 0 && day < 32);
434 /* date editor: get date: null year */
437 HildonDateEditor *date_editor;
438 guint month = 99, day = 999;
442 date_editor = HILDON_DATE_EDITOR(hildon_date_editor_new());
444 hildon_date_editor_get_date (date_editor, NULL, &month, &day);
449 /* date editor: get date: null month */
452 HildonDateEditor *date_editor;
453 guint month = 99, day = 999;
457 date_editor = HILDON_DATE_EDITOR(hildon_date_editor_new());
459 hildon_date_editor_get_date (date_editor, &month, NULL, &day);
464 /* date editor: get date: null day */
467 HildonDateEditor *date_editor;
468 guint year = 99999, month = 99;
472 date_editor = HILDON_DATE_EDITOR(hildon_date_editor_new());
474 hildon_date_editor_get_date (date_editor, &year, &month, NULL);
479 /* date editor: get date: null year, month, day */
482 HildonDateEditor *date_editor;
486 date_editor = HILDON_DATE_EDITOR(hildon_date_editor_new());
488 hildon_date_editor_get_date (date_editor, NULL, NULL, NULL);
493 /* date editor: set date: year, month, day are zero */
496 HildonDateEditor *date_editor;
497 guint year = 0, month = 0, day = 0;
501 date_editor = HILDON_DATE_EDITOR(hildon_date_editor_new());
503 hildon_date_editor_set_date (date_editor, year, month, day);
504 hildon_date_editor_get_date (date_editor, &year, &month, &day);
513 /* date editor: set date: year, month, day are the minumum */
514 static int test07ai()
516 HildonDateEditor *date_editor;
517 guint year = 1, month = 1, day = 1;
521 date_editor = HILDON_DATE_EDITOR(hildon_date_editor_new());
523 hildon_date_editor_set_date (date_editor, year, month, day);
524 hildon_date_editor_get_date (date_editor, &year, &month, &day);
533 /* date editor: set date: month less than minimum */
536 HildonDateEditor *date_editor;
537 guint year = 2003, month = 0, day = 2;
541 date_editor = HILDON_DATE_EDITOR(hildon_date_editor_new());
543 hildon_date_editor_set_date (date_editor, year, month, day);
544 hildon_date_editor_get_date (date_editor, &year, &month, &day);
546 assert (year == 2003);
553 /* date editor: set date: day less than minimum */
556 HildonDateEditor *date_editor;
557 guint year = 2003, month = 12, day = 0;
561 date_editor = HILDON_DATE_EDITOR(hildon_date_editor_new());
563 hildon_date_editor_set_date (date_editor, year, month, day);
564 hildon_date_editor_get_date (date_editor, &year, &month, &day);
566 assert (year == 2003);
567 assert (month == 12);
573 /* date editor: set date: ok parameters */
576 HildonDateEditor *date_editor;
577 guint year = 2003, month = 12, day = 2;
581 date_editor = HILDON_DATE_EDITOR(hildon_date_editor_new());
583 hildon_date_editor_set_date (date_editor, year, month, day);
584 hildon_date_editor_get_date (date_editor, &year, &month, &day);
586 assert (year == 2003);
587 assert (month == 12);
593 /* date editor: set date: big year, should be ok */
596 HildonDateEditor *date_editor;
597 /* hmm.. year seems to fail between 2020 and 2030 */
598 guint year = 2500, month = 12, day = 2;
602 date_editor = HILDON_DATE_EDITOR(hildon_date_editor_new());
604 hildon_date_editor_set_date (date_editor, year, month, day);
605 hildon_date_editor_get_date (date_editor, &year, &month, &day);
607 assert (year == 2500);
608 assert (month == 12);
614 /* date editor: set date: month over max */
617 HildonDateEditor *date_editor;
618 guint year = 2003, month = 13, day = 2;
622 date_editor = HILDON_DATE_EDITOR(hildon_date_editor_new());
624 hildon_date_editor_set_date (date_editor, year, month, day);
625 hildon_date_editor_get_date (date_editor, &year, &month, &day);
627 assert (year == 2003);
628 assert (month == 13);
634 /* date editor: set date: day over max */
637 HildonDateEditor *date_editor;
638 guint year = 2003, month = 11, day = 31;
642 date_editor = HILDON_DATE_EDITOR(hildon_date_editor_new());
644 hildon_date_editor_set_date (date_editor, year, month, day);
645 hildon_date_editor_get_date (date_editor, &year, &month, &day);
647 assert (year == 2003);
648 assert (month == 11);
654 /* date editor: set date: null date editor */
659 hildon_date_editor_set_date (NULL, 0, 0, 0);
667 {*test01a, " 01a_time_editor_new", EXPECT_OK},
668 {*test02a, " 02a_time_editor_get_time", EXPECT_OK},
669 {*test02b, " 02b_time_editor_get_time_null", EXPECT_ASSERT},
670 {*test02c, " 02c_time_editor_get_time_null2", EXPECT_ASSERT},
671 {*test02d, " 02d_time_editor_get_time_null3", EXPECT_ASSERT},
672 {*test02e, " 02e_time_editor_get_time_null4", EXPECT_ASSERT},
673 {*test02f, " 02e_time_editor_get_time_null5", EXPECT_ASSERT},
674 {*test03a, " 03a_time_editor_set_time_both_0", EXPECT_OK},
675 {*test03b, " 03b_..._both_between", EXPECT_OK},
676 {*test03c, " 03c_..._hours_limit", EXPECT_ASSERT},
677 {*test03d, " 03d_..._minutes_limit", EXPECT_ASSERT},
678 {*test03da," 03d_..._seconds_limit", EXPECT_ASSERT},
679 {*test03e, " 03e_..._both_limit", EXPECT_ASSERT},
680 {*test03ea," 03e_..._all_limit", EXPECT_ASSERT},
681 {*test03f, " 03f_..._both_over", EXPECT_ASSERT},
682 {*test03fa," 03f_..._all_over", EXPECT_ASSERT},
683 {*test03g, " 03g_..._null", EXPECT_ASSERT},
684 {*test03h, " 03h_show_seconds_ok", EXPECT_OK},
685 {*test03i, " 03i_show_seconds_null", EXPECT_ASSERT},
686 {*test04a, " 04a_time_editor_get_type", EXPECT_OK},
687 {*test05a, " 05a_date_editor_new", EXPECT_OK},
688 {*test06a, " 06a_date_editor_get_date", EXPECT_OK},
689 {*test06b, " 06b_date_editor_get_date_null", EXPECT_ASSERT},
690 {*test06c, " 06c_date_editor_get_date_null2", EXPECT_ASSERT},
691 {*test06d, " 06d_date_editor_get_date_null3", EXPECT_ASSERT},
692 {*test06e, " 06e_date_editor_get_date_null4", EXPECT_ASSERT},
693 {*test06f, " 06f_date_editor_get_date_null5", EXPECT_ASSERT},
694 {*test07a, " 07a_date_editor_set_date_valid1", EXPECT_ASSERT},
695 {*test07ai," 07ai_date_editor_set_date_valid1a", EXPECT_OK},
696 {*test07b, " 07b_date_editor_set_date_valid2", EXPECT_ASSERT},
697 {*test07c, " 07c_date_editor_set_date_valid3", EXPECT_ASSERT},
698 {*test07d, " 07d_date_editor_set_date_valid4", EXPECT_OK},
699 {*test07e, " 07e_date_editor_set_date_valid5", EXPECT_OK},
700 {*test07f, " 07f_date_editor_set_date_valid6", EXPECT_ASSERT},
701 {*test07g, " 07g_date_editor_set_date_valid7", EXPECT_ASSERT},
702 {*test07h, " 07h_date_editor_set_date_null", EXPECT_ASSERT},
704 {0} /*REMEMBER THE TERMINATING NULL*/
707 /*use EXPECT_ASSERT for the tests that are _ment_ to throw assert so they are
708 consider passed when they throw assert and failed when tehy do not*/
710 testcase* get_tests (void)
712 g_log_set_always_fatal (G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING);