diff options
Diffstat (limited to 'tests')
23 files changed, 6 insertions, 7834 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am index 8994907..a933b09 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -18,30 +18,7 @@ tests = check_test.c \ check-hildon-program.c \ check-hildon-picker-button.c - -DEPRECATED_TESTS = check-hildon-range-editor.c \ - check-hildon-date-editor.c \ - check-hildon-time-editor.c \ - check-hildon-weekday-picker.c \ - check-hildon-controlbar.c \ - check-hildon-seekbar.c \ - check-hildon-time-picker.c \ - check-hildon-number-editor.c \ - check-hildon-calendar-popup.c \ - check-hildon-code-dialog.c \ - check-hildon-sort-dialog.c \ - check-hildon-volumebar.c \ - check-hildon-volumebar-range.c \ - check-hildon-font-selection-dialog.c \ - check-hildon-color-button.c \ - check-hildon-color-chooser.c - -if HILDON_DISABLE_DEPRECATED check_test_SOURCES = $(tests) -else -check_test_SOURCES = $(tests) \ - $(DEPRECATED_TESTS) -endif check_test_SOURCES += test_suites.h \ check_utils.h diff --git a/tests/check-hildon-banner.c b/tests/check-hildon-banner.c index ed3ee42..cde0ae1 100644 --- a/tests/check-hildon-banner.c +++ b/tests/check-hildon-banner.c @@ -21,8 +21,6 @@ * 02110-1301 USA * */ -#ifndef HILDON_DISABLE_DEPRECATED - #include <stdlib.h> #include <check.h> #include <gtk/gtkmain.h> @@ -244,4 +242,3 @@ Suite *create_hildon_banner_suite() return s; } -#endif diff --git a/tests/check-hildon-calendar-popup.c b/tests/check-hildon-calendar-popup.c deleted file mode 100644 index 50f03d1..0000000 --- a/tests/check-hildon-calendar-popup.c +++ /dev/null @@ -1,506 +0,0 @@ -/* - * This file is a part of hildon tests - * - * Copyright (C) 2006, 2007 Nokia Corporation, all rights reserved. - * - * Contact: Michael Dominic Kostrzewa <michael.kostrzewa@nokia.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; version 2.1 of - * the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA - * - */ - -#include <stdlib.h> -#include <time.h> -#include <check.h> -#include <gtk/gtkmain.h> -#include "test_suites.h" -#include "check_utils.h" - -#include <hildon/hildon-calendar-popup.h> - -/* -------------------- Fixtures -------------------- */ - -static HildonCalendarPopup *calendar = NULL; - -static void -fx_setup_default_calendar() -{ - int argc = 0; - - gtk_init(&argc, NULL); - - calendar = HILDON_CALENDAR_POPUP(hildon_calendar_popup_new(NULL, 2006, 4, 10)); - - show_test_window(GTK_WIDGET(calendar)); - - /* Check calendar object has been created properly */ - fail_if(!HILDON_IS_CALENDAR_POPUP(calendar), - "hildon-calendar-popup: Creation failed."); -} - -static void -fx_teardown_default_calendar() -{ - - gtk_widget_destroy(GTK_WIDGET(calendar)); - -} - -/* -------------------- Test cases -------------------- */ - -/* ------ Test case for get/set_date ----- */ - -/** - * Purpose: Check regular values for dates - * Cases considered: - * - Set and get date 30/03/1981 - */ -START_TEST (test_set_get_date_regular) -{ - guint year, month, day; - guint ret_year, ret_month, ret_day; - - /* Test1: set a valid date like 30/03/1981 */ - year = 1981; - month = 3; - day = 30; - hildon_calendar_popup_set_date(calendar, year, month, day); - hildon_calendar_popup_get_date(calendar, &ret_year, &ret_month, &ret_day); - fail_if(year != ret_year || month != ret_month || day != ret_day, - "hildon-calendar-popup: Set date to %u/%u/%u, but get date returned date %u/%u/%u", - year, month, day, ret_year, ret_month, ret_day); - -} -END_TEST - -/** - * Purpose: Check limit values for dates - * Cases considered: - * - Set and get year to max-year property - * - Set and get year to min-year property - * - Set and get month to 12 - * - Set and get month to 1 - * - Set and get day to 31 (March) - * - Set and get day to 30 (April) - * - Set and get day to 29 (February 2004) - * - Set and get day to 28 (February 2006) - * - Set and get day to 1 - * - Set and get maximum allowed date (according to max-year property). - * - Set and get minimum allowed date (according to min-year property). - */ -START_TEST (test_set_get_date_limits) -{ - GValue value = {0, }; - guint year, month, day; - guint ret_year, ret_month, ret_day; - guint max_year, min_year; - - g_value_init(&value, G_TYPE_UINT); - - /* Test1: Test year maximum limit */ - max_year = 2050; - g_value_set_uint (&value, max_year); - g_object_set_property (G_OBJECT (calendar), "max-year", &value); - year = max_year; - month = 3; - day = 30; - hildon_calendar_popup_set_date(calendar, year, month, day); - hildon_calendar_popup_get_date(calendar, &ret_year, &ret_month, &ret_day); - fail_if(year != ret_year, - "hildon-calendar-popup: Set date to %u/%u/%u, with maximum year set to %u, but get date returned year %u", - year, month, day, max_year, ret_year); - - /* Test2: Test year minimum limit */ - min_year = 2000; - g_value_set_uint (&value, min_year); - g_object_set_property (G_OBJECT (calendar), "min-year", &value); - year = min_year; - month = 3; - day = 30; - hildon_calendar_popup_set_date(calendar, year, month, day); - hildon_calendar_popup_get_date(calendar, &ret_year, &ret_month, &ret_day); - fail_if(year != ret_year, - "hildon-calendar-popup: Set date to %u/%u/%u, with minimum year set to %u, but get date returned year %u", - year, month, day, min_year, ret_year); - - /* Test3: Test month minimum limit */ - year = 2006; - month = 1; - day = 10; - hildon_calendar_popup_set_date(calendar, year, month, day); - hildon_calendar_popup_get_date(calendar, &ret_year, &ret_month, &ret_day); - fail_if(month != ret_month, - "hildon-calendar-popup: Set date to %u/%u/%u, but get date returned month %u", - year, month, day, ret_month); - - /* Test4: Test month maximum limit */ - year = 2006; - month = 12; - day = 10; - hildon_calendar_popup_set_date(calendar, year, month, day); - hildon_calendar_popup_get_date(calendar, &ret_year, &ret_month, &ret_day); - fail_if(month != ret_month, - "hildon-calendar-popup: Set date to %u/%u/%u, but get date returned month %u", - year, month, day, ret_month); - - /* Test5: Test day maximum limit */ - - /* 31 */ - year = 2006; - month = 3; - day = 31; - hildon_calendar_popup_set_date(calendar, year, month, day); - hildon_calendar_popup_get_date(calendar, &ret_year, &ret_month, &ret_day); - fail_if(day != ret_day, - "hildon-calendar-popup: Set date to %u/%u/%u, but get date returned day %u", - year, month, day, ret_day); - - /* 30 */ - year = 2006; - month = 4; - day = 30; - hildon_calendar_popup_set_date(calendar, year, month, day); - hildon_calendar_popup_get_date(calendar, &ret_year, &ret_month, &ret_day); - fail_if(day != ret_day, - "hildon-calendar-popup: Set date to %u/%u/%u, but get date returned day %u", - year, month, day, ret_day); - - /* February 28th */ - year = 2006; - month = 2; - day = 28; - hildon_calendar_popup_set_date(calendar, year, month, day); - hildon_calendar_popup_get_date(calendar, &ret_year, &ret_month, &ret_day); - fail_if(day != ret_day, - "hildon-calendar-popup: Set date to %u/%u/%u, but get date returned day %u", - year, month, day, ret_day); - - /* February 29th */ - year = 2004; - month = 2; - day = 29; - hildon_calendar_popup_set_date(calendar, year, month, day); - hildon_calendar_popup_get_date(calendar, &ret_year, &ret_month, &ret_day); - fail_if(day != ret_day, - "hildon-calendar-popup: Set date to %u/%u/%u, but get date returned day %u", - year, month, day, ret_day); - - /* Test6: Test day minimum limit */ - year = 2006; - month = 2; - day = 1; - hildon_calendar_popup_set_date(calendar, year, month, day); - hildon_calendar_popup_get_date(calendar, &ret_year, &ret_month, &ret_day); - fail_if(day != ret_day, - "hildon-calendar-popup: Set date to %u/%u/%u, but get date returned day %u", - year, month, day, ret_day); - - /* Test7: Test maximum allowed date */ - max_year = 2050; - g_value_set_uint (&value, max_year); - g_object_set_property (G_OBJECT (calendar), "max-year", &value); - year = max_year; - month = 12; - day = 31; - hildon_calendar_popup_set_date(calendar, year, month, day); - hildon_calendar_popup_get_date(calendar, &ret_year, &ret_month, &ret_day); - fail_if(year != ret_year, - "hildon-calendar-popup: Set date to %u/%u/%u, with maximum year set to %u, but get date returned date %u/%u/%u", - year, month, day, max_year, ret_year, ret_month, ret_day); - - /* Test8: Test minimum allowed date */ - min_year = 2000; - g_value_set_uint (&value, min_year); - g_object_set_property (G_OBJECT (calendar), "min-year", &value); - year = min_year; - month = 1; - day = 1; - hildon_calendar_popup_set_date(calendar, year, month, day); - hildon_calendar_popup_get_date(calendar, &ret_year, &ret_month, &ret_day); - fail_if(year != ret_year, - "hildon-calendar-popup: Set date to %u/%u/%u, with minimum year set to %u, but get date returned date %u/%u/%u", - year, month, day, min_year, ret_year, ret_month, ret_day); -} -END_TEST - -/** - * Purpose: Check invalid values for dates - * Cases considered: - * - Set and get year above max-year property - * - Set and get year under min-year property - * - Set and get month to 13 - * - Set and get month to 0 - * - Set and get day to 32 (March) - * - Set and get day to 31 (April) - * - Set and get day to 30 (February 2004) - * - Set and get day to 29 (February 2006) - * - Set and get day to 0 - * - Set and get above maximum allowed date (according to max-year property). - * - Set and get under minimum allowed date (according to min-year property). - * - Set and get date using NULL calendar object - */ -START_TEST (test_set_get_date_invalid) -{ - GValue value = {0, }; - guint year, month, day; - guint valid_year, valid_month, valid_day; - guint current_year, current_month, current_day; - guint ret_year, ret_month, ret_day; - guint max_year, min_year; - GDate date; - - g_value_init(&value, G_TYPE_UINT); - - /* Test 1: Test under minimum year limit */ - min_year = 2000; - g_value_set_uint (&value, min_year); - g_object_set_property (G_OBJECT (calendar), "min-year", &value); - year = min_year - 1; - month = 3; - day = 30; - hildon_calendar_popup_set_date(calendar, year, month, day); - hildon_calendar_popup_get_date(calendar, &ret_year, &ret_month, &ret_day); - fail_if(min_year != ret_year, - "hildon-calendar-popup: Set date to %u/%u/%u, with minimum year set to %u, but get date returned year = %u != %u", - year, month, day, min_year, ret_year, min_year); - - /* Test 2: Test above maximum month limit */ - valid_year = 2006; - valid_month = 10; - valid_day = 5; - hildon_calendar_popup_set_date(calendar, valid_year, valid_month, valid_day); - year = 2010; - month = 13; - day = 12; - hildon_calendar_popup_set_date(calendar, year, month, day); - hildon_calendar_popup_get_date(calendar, &ret_year, &ret_month, &ret_day); - - /* Gets the curret date */ - g_date_clear(&date, 1); - g_date_set_time(&date, time(NULL)); - - current_day = g_date_get_day(&date); - current_month = g_date_get_month(&date); - current_year = g_date_get_year(&date); - - fail_if((current_year != ret_year) || (current_month != ret_month) || (current_day != ret_day), - "hildon-calendar-popup: Set valid date to %u/%u/%u, then set an invalid date %u/%u/%u, but get date returned %u/%u/%u instead of %u/%u/%u", - valid_year, valid_month, valid_day, year, month, day, ret_year, ret_month, ret_day, current_year, current_month, current_day); - - - /* Test 3: Test under minimum month limit */ - valid_year = 2006; - valid_month = 2; - valid_day = 15; - hildon_calendar_popup_set_date(calendar, valid_year, valid_month, valid_day); - year = 2010; - month = 0; - day = 10; - hildon_calendar_popup_set_date(calendar, year, month, day); - hildon_calendar_popup_get_date(calendar, &ret_year, &ret_month, &ret_day); - - /* Gets the curret date */ - g_date_clear(&date, 1); - g_date_set_time(&date, time(NULL)); - - current_day = g_date_get_day(&date); - current_month = g_date_get_month(&date); - current_year = g_date_get_year(&date); - - fail_if((current_year != ret_year) || (current_month != ret_month) || (current_day != ret_day), - "hildon-calendar-popup: Set valid date to %u/%u/%u, then set an invalid date %u/%u/%u, but get date returned %u/%u/%u instead of %u/%u/%u", - valid_year, valid_month, valid_day, year, month, day, ret_year, ret_month, ret_day, current_year, current_month, current_day); - - - /* Test 4: Test above maximum day limit */ - - /* 31 */ - valid_year = 2005; - valid_month = 2; - valid_day = 15; - hildon_calendar_popup_set_date(calendar, valid_year, valid_month, valid_day); - year = 2006; - month = 3; - day = 32; - hildon_calendar_popup_set_date(calendar, year, month, day); - hildon_calendar_popup_get_date(calendar, &ret_year, &ret_month, &ret_day); - - /* Gets the curret date */ - g_date_clear(&date, 1); - g_date_set_time(&date, time(NULL)); - - current_day = g_date_get_day(&date); - current_month = g_date_get_month(&date); - current_year = g_date_get_year(&date); - - fail_if((current_year != ret_year) || (current_month != ret_month) || (current_day != ret_day), - "hildon-calendar-popup: Set valid date to %u/%u/%u, then set an invalid date %u/%u/%u, but get date returned %u/%u/%u instead of %u/%u/%u", - valid_year, valid_month, valid_day, year, month, day, ret_year, ret_month, ret_day, current_year, current_month, current_day); - - - /* 30 */ - valid_year = 2005; - valid_month = 2; - valid_day = 15; - hildon_calendar_popup_set_date(calendar, valid_year, valid_month, valid_day); - year = 2006; - month = 4; - day = 31; - hildon_calendar_popup_set_date(calendar, year, month, day); - hildon_calendar_popup_get_date(calendar, &ret_year, &ret_month, &ret_day); - - /* Gets the curret date */ - g_date_clear(&date, 1); - g_date_set_time(&date, time(NULL)); - - current_day = g_date_get_day(&date); - current_month = g_date_get_month(&date); - current_year = g_date_get_year(&date); - - fail_if((current_year != ret_year) || (current_month != ret_month) || (current_day != ret_day), - "hildon-calendar-popup: Set valid date to %u/%u/%u, then set an invalid date %u/%u/%u, but get date returned %u/%u/%u instead of %u/%u/%u", - valid_year, valid_month, valid_day, year, month, day, ret_year, ret_month, ret_day, current_year, current_month, current_day); - - /* February 28th */ - valid_year = 2005; - valid_month = 2; - valid_day = 15; - hildon_calendar_popup_set_date(calendar, valid_year, valid_month, valid_day); - year = 2006; - month = 2; - day = 29; - hildon_calendar_popup_set_date(calendar, year, month, day); - hildon_calendar_popup_get_date(calendar, &ret_year, &ret_month, &ret_day); - - /* Gets the curret date */ - g_date_clear(&date, 1); - g_date_set_time(&date, time(NULL)); - - current_day = g_date_get_day(&date); - current_month = g_date_get_month(&date); - current_year = g_date_get_year(&date); - - fail_if((current_year != ret_year) || (current_month != ret_month) || (current_day != ret_day), - "hildon-calendar-popup: Set valid date to %u/%u/%u, then set an invalid date %u/%u/%u, but get date returned %u/%u/%u instead of %u/%u/%u", - valid_year, valid_month, valid_day, year, month, day, ret_year, ret_month, ret_day, current_year, current_month, current_day); - - - /* February 29th */ - valid_year = 2005; - valid_month = 2; - valid_day = 15; - hildon_calendar_popup_set_date(calendar, valid_year, valid_month, valid_day); - year = 2004; - month = 2; - day = 30; - hildon_calendar_popup_set_date(calendar, year, month, day); - hildon_calendar_popup_get_date(calendar, &ret_year, &ret_month, &ret_day); - - /* Gets the curret date */ - g_date_clear(&date, 1); - g_date_set_time(&date, time(NULL)); - - current_day = g_date_get_day(&date); - current_month = g_date_get_month(&date); - current_year = g_date_get_year(&date); - - fail_if((current_year != ret_year) || (current_month != ret_month) || (current_day != ret_day), - "hildon-calendar-popup: Set valid date to %u/%u/%u, then set an invalid date %u/%u/%u, but get date returned %u/%u/%u instead of %u/%u/%u", - valid_year, valid_month, valid_day, year, month, day, ret_year, ret_month, ret_day, current_year, current_month, current_day); - - /* Test5: Test day minimum limit */ - valid_year = 2005; - valid_month = 2; - valid_day = 15; - hildon_calendar_popup_set_date(calendar, valid_year, valid_month, valid_day); - year = 2006; - month = 2; - day = 0; - hildon_calendar_popup_set_date(calendar, year, month, day); - hildon_calendar_popup_get_date(calendar, &ret_year, &ret_month, &ret_day); - - /* Gets the curret date */ - g_date_clear(&date, 1); - g_date_set_time(&date, time(NULL)); - - current_day = g_date_get_day(&date); - current_month = g_date_get_month(&date); - current_year = g_date_get_year(&date); - - fail_if((current_year != ret_year) || (current_month != ret_month) || (current_day != ret_day), - "hildon-calendar-popup: Set valid date to %u/%u/%u, then set an invalid date %u/%u/%u, but get date returned %u/%u/%u instead of %u/%u/%u", - valid_year, valid_month, valid_day, year, month, day, ret_year, ret_month, ret_day, current_year, current_month, current_day); - - /* Test6: Test above maximum allowed date */ - max_year = 2050; - g_value_set_uint (&value, max_year); - g_object_set_property (G_OBJECT (calendar), "max-year", &value); - valid_year = 2005; - valid_month = 2; - valid_day = 15; - hildon_calendar_popup_set_date(calendar, valid_year, valid_month, valid_day); - year = max_year + 1; - month = 1; - day = 1; - hildon_calendar_popup_set_date(calendar, year, month, day); - hildon_calendar_popup_get_date(calendar, &ret_year, &ret_month, &ret_day); - fail_if((max_year != ret_year) || (month != ret_month) || (day != ret_day), - "hildon-calendar-popup: Set valid date to %u/%u/%u, then set an invalid date %u/%u/%u, with maximum year set to %u, but get date returned %u/%u/%u instead of %u/%u/%u", - valid_year, valid_month, valid_day, year, month, day, max_year, ret_year, ret_month, ret_day, max_year, month, day); - - /* Test7: Test minimum allowed date */ - min_year = 2000; - g_value_set_uint (&value, min_year); - g_object_set_property (G_OBJECT (calendar), "min-year", &value); - valid_year = 2005; - valid_month = 2; - valid_day = 15; - hildon_calendar_popup_set_date(calendar, valid_year, valid_month, valid_day); - year = min_year - 1; - month = 12; - day = 31; - hildon_calendar_popup_set_date(calendar, year, month, day); - hildon_calendar_popup_get_date(calendar, &ret_year, &ret_month, &ret_day); - fail_if((min_year != ret_year) || (month != ret_month) || (day != ret_day), - "hildon-calendar-popup: Set valid date to %u/%u/%u, then set an invalid date %u/%u/%u, with minimum year set to %u, but get date returned %u/%u/%u instead of %u/%u/%u", - valid_year, valid_month, valid_day, year, month, day, min_year, ret_year, ret_month, ret_day, min_year, month, day); - - /* Test8: Set and get date with NULL calendar objects */ - hildon_calendar_popup_set_date(NULL, 2006, 10, 15); - hildon_calendar_popup_get_date(NULL, &year, &month, &day); -} -END_TEST - -/* ---------- Suite creation ---------- */ - -Suite *create_hildon_calendar_popup_suite() -{ - /* Create the suite */ - Suite *s = suite_create("HildonCalendarPopup"); - - /* Create test cases */ - TCase *tc1 = tcase_create("set_get_date"); - - /* Create test case for set_date and get_date and add it to the suite */ - tcase_add_checked_fixture(tc1, fx_setup_default_calendar, fx_teardown_default_calendar); - tcase_add_test(tc1, test_set_get_date_regular); - tcase_add_test(tc1, test_set_get_date_limits); - tcase_add_test(tc1, test_set_get_date_invalid); - suite_add_tcase (s, tc1); - - /* Return created suite */ - return s; -} diff --git a/tests/check-hildon-code-dialog.c b/tests/check-hildon-code-dialog.c deleted file mode 100644 index aea147e..0000000 --- a/tests/check-hildon-code-dialog.c +++ /dev/null @@ -1,129 +0,0 @@ -/* - * This file is a part of hildon tests - * - * Copyright (C) 2006, 2007 Nokia Corporation, all rights reserved. - * - * Contact: Michael Dominic Kostrzewa <michael.kostrzewa@nokia.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; version 2.1 of - * the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA - * - */ - -#include <stdlib.h> -#include <check.h> -#include <gtk/gtkmain.h> -#include <gtk/gtkhbox.h> -#include <glib/gprintf.h> -#include <string.h> -#include "test_suites.h" -#include "check_utils.h" - -#include <hildon/hildon-code-dialog.h> - -/* -------------------- Fixtures -------------------- */ - -static HildonCodeDialog *code_dialog = NULL; - -static void -fx_setup_default_code_dialog() -{ - int argc = 0; - gtk_init(&argc, NULL); - - code_dialog = HILDON_CODE_DIALOG(hildon_code_dialog_new()); - /* Check code_dialog object has been created properly */ - fail_if(!HILDON_IS_CODE_DIALOG(code_dialog), - "hildon-code-dialog: Creation failed."); - - show_test_window(GTK_WIDGET(code_dialog)); - -} - -static void -fx_teardown_default_code_dialog() -{ - - /* Destroy the dialog */ - gtk_widget_destroy (GTK_WIDGET (code_dialog)); - -} - -/* -------------------- Test cases -------------------- */ - -/* ----- Test case for get_code -----*/ -/** - * Purpose: Check that the regular code values are get without problems - * - * Cases considered: - * - Get code from new created dialog. - * - */ -START_TEST (test_get_code_regular) -{ - const gchar * code; - - /* Test 1: Get code from new created dialog. */ - /* Check that code is correctly get. */ - code = hildon_code_dialog_get_code (code_dialog); - fail_if (strcmp (code,"") != 0, - "hildon-code-dialog: init code isn't empty"); - -} -END_TEST - -/** - * Purpose: Check that the regular code values are get without problems - * - * Cases considered: - * - Get code from NULL object - * - Get code from object that isn't a code dialog. - * - */ -START_TEST (test_get_code_invalid) -{ - const gchar * code; - GtkWidget *aux_object = NULL; - - /* Test 1: Get code from NULL object. */ - code = hildon_code_dialog_get_code (NULL); - - /* Test 2: Get code from object that it isn't a code dialog. */ - aux_object = gtk_hbox_new (TRUE, 0); - code = hildon_code_dialog_get_code ((HildonCodeDialog *) aux_object); - - gtk_widget_destroy (aux_object); - -} -END_TEST - -/* ---------- Suite creation ---------- */ -Suite *create_hildon_code_dialog_suite() -{ - /* Create the suite */ - Suite *s = suite_create("HildonCodeDialog"); - - /* Create test cases */ - TCase *tc1 = tcase_create("get_code"); - - /* Create test case for hildon_code_dialog_get_code and add it to the suite */ - tcase_add_checked_fixture(tc1, fx_setup_default_code_dialog, fx_teardown_default_code_dialog); - tcase_add_test(tc1, test_get_code_regular); - tcase_add_test(tc1, test_get_code_invalid); - suite_add_tcase (s, tc1); - - /* Return created suite */ - return s; -} diff --git a/tests/check-hildon-color-button.c b/tests/check-hildon-color-button.c deleted file mode 100644 index 4edfeec..0000000 --- a/tests/check-hildon-color-button.c +++ /dev/null @@ -1,391 +0,0 @@ -/* - * This file is a part of hildon tests - * - * Copyright (C) 2006, 2007 Nokia Corporation, all rights reserved. - * - * Contact: Michael Dominic Kostrzewa <michael.kostrzewa@nokia.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; version 2.1 of - * the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA - * - */ - -#include <stdlib.h> -#include <check.h> -#include <gtk/gtkmain.h> -#include <gtk/gtkhbox.h> -#include <glib/gprintf.h> -#include "test_suites.h" -#include "check_utils.h" -#include <hildon/hildon-color-button.h> - -/* -------------------- Fixtures -------------------- */ -static HildonColorButton *color_button = NULL; -static GtkWidget *showed_window = NULL; - -static void -fx_setup_default_color_button() -{ - int argc = 0; - gtk_init(&argc, NULL); - - color_button = HILDON_COLOR_BUTTON(hildon_color_button_new()); - /* Check that the color button object has been created properly */ - - showed_window = create_test_window (); - - /* This packs the widget into the window (a gtk container). */ - gtk_container_add (GTK_CONTAINER (showed_window), GTK_WIDGET (color_button)); - - /* Displays the widget and the window */ - show_all_test_window (showed_window); - - - fail_if(!HILDON_IS_COLOR_BUTTON(color_button), - "hildon-color-button: Creation failed."); - -} - -static void -fx_teardown_default_color_button() -{ - - /* Destroy the widget and the window */ - gtk_widget_destroy(GTK_WIDGET(showed_window)); - -} - -/* -------------------- Test cases -------------------- */ - -/* ----- Test case for set_color -----*/ -/** - * Purpose: Check that a regular color can be set safely - * Cases considered: - * - Set color defined by (255, 255, 255) and pixel = 255 - * - Set color defined by (10, 20, 30) and pixel = 10 - * - Set color defined by (20, 10, 30) and pixel = 10 - * - Set color defined by (30, 10, 20) and pixel = 20 - */ - -START_TEST (test_set_color_regular) -{ - GdkColor color; - GdkColor * b_color; - GdkColor * ret_color = g_new (GdkColor, 1); - guint red; - guint green; - guint blue; - guint pixel; - - b_color = gdk_color_copy(&color); - - /* Test 1: Set color defined by (255,255,255)*/ - red = 255; - green = 255; - blue = 255; - pixel = 255; - - b_color->red=red; - b_color->green=green; - b_color->blue=blue; - b_color->pixel=pixel; - - hildon_color_button_set_color(color_button,b_color); - hildon_color_button_get_color(color_button, ret_color); - - fail_if ((red != ret_color->red) || (green != ret_color->green) || - (blue != ret_color->blue) || (pixel != ret_color->pixel), - "hildon-color-button: The returned color for the pixel %d (returned %d) in RGB is %d/%d/%d and should be %d/%d/%d", - pixel, ret_color->red, ret_color->green, - ret_color->blue, ret_color->pixel); - - /* Test 2: Set color defined by (10,20,30)*/ - red = 10; - green = 20; - blue = 30; - pixel = 10; - - b_color->red=red; - b_color->green=green; - b_color->blue=blue; - b_color->pixel=pixel; - - hildon_color_button_set_color(color_button,b_color); - hildon_color_button_get_color(color_button, ret_color); - - fail_if ((red != ret_color->red) || (green != ret_color->green) || - (blue != ret_color->blue) || (pixel != ret_color->pixel), - "hildon-color-button: The returned color for the pixel %d (returned %d) in RGB is %d/%d/%d and should be %d/%d/%d", - pixel, ret_color->red, ret_color->green, - ret_color->blue, ret_color->pixel); - - /* Test 3: Set color defined by (20,10,30)*/ - red = 20; - green = 10; - blue = 30; - pixel = 10; - - b_color->red=red; - b_color->green=green; - b_color->blue=blue; - b_color->pixel=pixel; - - hildon_color_button_set_color(color_button,b_color); - hildon_color_button_get_color(color_button, ret_color); - - fail_if ((red != ret_color->red) || (green != ret_color->green) || - (blue != ret_color->blue) || (pixel != ret_color->pixel), - "hildon-color-button: The returned color for the pixel %d (returned %d) in RGB is %d/%d/%d and should be %d/%d/%d", - pixel, ret_color->red, ret_color->green, - ret_color->blue, ret_color->pixel); - - /* Test 4: Set color defined by (30,10,20)*/ - red = 30; - green = 10; - blue = 20; - pixel = 20; - - b_color->red=red; - b_color->green=green; - b_color->blue=blue; - b_color->pixel=pixel; - - hildon_color_button_set_color(color_button,b_color); - hildon_color_button_get_color(color_button, ret_color); - - fail_if ((red != ret_color->red) || (green != ret_color->green) || - (blue != ret_color->blue) || (pixel != ret_color->pixel), - "hildon-color-button: The returned color for the pixel %d (returned %d) in RGB is %d/%d/%d and should be %d/%d/%d", - pixel, ret_color->red, ret_color->green, - ret_color->blue, ret_color->pixel); - - if (b_color) - gdk_color_free(b_color); - - if (ret_color) - gdk_color_free(ret_color); -} -END_TEST - -/** - * Purpose: Check that a limits values on color components can be set safely. - * Cases considered: - * - Set color defined by (0, 0, 0) and pixel = 0 - * - Set color defined by (G_MAXUINT16, G_MAXUINT16, G_MAXUINT16) and pixel = G_MAXUINT32 - * - Set color defined by (G_MAXUINT16, 0, 0) and pixel = G_MAXUINT32 - * - Set color defined by (0, G_MAXUINT16, 0) and pixel = 0 - * - Set color defined by (0, 0, G_MAXUINT16) and pixel = G_MAXUINT32 - */ - -START_TEST (test_set_color_limits) -{ - GdkColor color; - GdkColor * b_color; - GdkColor * ret_color = g_new (GdkColor, 1); - guint red; - guint green; - guint blue; - guint pixel; - - b_color = gdk_color_copy(&color); - - /* Test 1: Set color defined by (0,0,0)*/ - red = 0; - green = 0; - blue = 0; - pixel = 0; - - b_color->red=red; - b_color->green=green; - b_color->blue=blue; - b_color->pixel=pixel; - - hildon_color_button_set_color(color_button,b_color); - hildon_color_button_get_color(color_button, ret_color); - - fail_if ((red != ret_color->red) || (green != ret_color->green) || - (blue != ret_color->blue) || (pixel != ret_color->pixel), - "hildon-color-button: The returned color for the pixel %d (returned %d) in RGB is %d/%d/%d and should be %d/%d/%d", - pixel, ret_color->red, ret_color->green, - ret_color->blue, ret_color->pixel); - - /* Test 2: Set color defined by (G_MAXUINT16,G_MAXUINT16,G_MAXUINT16)*/ - red = G_MAXUINT16; - green = G_MAXUINT16; - blue = G_MAXUINT16; - pixel = G_MAXUINT32; - - b_color->pixel=pixel; - b_color->red=red; - b_color->green=green; - b_color->blue=blue; - - hildon_color_button_set_color(color_button,b_color); - hildon_color_button_get_color(color_button, ret_color); - - fail_if ((red != ret_color->red) || (green != ret_color->green) || - (blue != ret_color->blue) || (pixel != ret_color->pixel), - "hildon-color-button: The returned color for the pixel %d (returned %d) in RGB is %d/%d/%d and should be %d/%d/%d", - pixel, ret_color->red, ret_color->green, - ret_color->blue, ret_color->pixel); - - /* Test 3: Set color defined by (G_MAXUINT16,0,0)*/ - red = G_MAXUINT16; - green = 0; - blue = 0; - pixel = G_MAXUINT32; - - b_color->red=red; - b_color->green=green; - b_color->blue=blue; - b_color->pixel=pixel; - - hildon_color_button_set_color(color_button,b_color); - hildon_color_button_get_color(color_button, ret_color); - - fail_if ((red != ret_color->red) || (green != ret_color->green) || - (blue != ret_color->blue) || (pixel != ret_color->pixel), - "hildon-color-button: The returned color for the pixel %d (returned %d) in RGB is %d/%d/%d and should be %d/%d/%d", - pixel, ret_color->red, ret_color->green, - ret_color->blue, ret_color->pixel); - - /* Test 4: Set color defined by (0,G_MAXUINT16,0)*/ - red = 0; - green = G_MAXUINT16; - blue = 0; - pixel = 0; - - b_color->red=red; - b_color->green=green; - b_color->blue=blue; - b_color->pixel=pixel; - - hildon_color_button_set_color(color_button,b_color); - hildon_color_button_get_color(color_button, ret_color); - - fail_if ((red != ret_color->red) || (green != ret_color->green) || - (blue != ret_color->blue) || (pixel != ret_color->pixel), - "hildon-color-button: The returned color for the pixel %d (returned %d) in RGB is %d/%d/%d and should be %d/%d/%d", - pixel, ret_color->red, ret_color->green, - ret_color->blue, ret_color->pixel); - - /* Test 5: Set color defined by (0,0,G_MAXUINT16)*/ - red = 0; - green = 0; - blue = G_MAXUINT16; - pixel = G_MAXUINT32; - - b_color->red=red; - b_color->green=green; - b_color->blue=blue; - b_color->pixel=pixel; - - hildon_color_button_set_color(color_button,b_color); - hildon_color_button_get_color(color_button, ret_color); - - fail_if ((red != ret_color->red) || (green != ret_color->green) || - (blue != ret_color->blue) || (pixel != ret_color->pixel), - "hildon-color-button: The returned color for the pixel %d (returned %d) in RGB is %d/%d/%d and should be %d/%d/%d", - pixel, ret_color->red, ret_color->green, - ret_color->blue, ret_color->pixel); - - if (b_color) - gdk_color_free(b_color); - - if (ret_color) - gdk_color_free(ret_color); -} -END_TEST - -/** - * Purpose: Check that a limits values on color components can be set safely. - * Cases considered: - * - Set color defined by (0, 0, 0) on NULL object. - * - Get color from NULL object. - * - Set color defined by (0, 0, 0) on GtkHBox object. - * - Get a color from GtkHBox object. - */ - -START_TEST (test_set_color_invalid) -{ - GdkColor color; - GdkColor * b_color; - GdkColor * ret_color = g_new (GdkColor, 1); - GtkWidget *aux_object = NULL; - guint red; - guint green; - guint blue; - - b_color = gdk_color_copy(&color); - - red = 0; - green = 0; - blue = 0; - - b_color->red=red; - b_color->green=green; - b_color->blue=blue; - b_color->pixel=0; - - /* Test 1: Set color defined by (0,0,0) on NULL object*/ - hildon_color_button_set_color(NULL,b_color); - - /* Test 2: Get color from NULL object*/ - hildon_color_button_get_color(NULL, ret_color); - - /* Test 3: Set color defined by (0, 0, 0) on GtkHBox object. */ - aux_object = gtk_hbox_new (TRUE, 0); - hildon_color_button_set_color((HildonColorButton *) (aux_object), b_color); - gdk_color_free(b_color); - - /* Test 4: Get color from GtkHBox object. */ - ret_color->red = 99; - ret_color->green = 99; - ret_color->blue = 99; - hildon_color_button_get_color((HildonColorButton *) (aux_object), ret_color); - - if (ret_color->red != 99 || - ret_color->green != 99 || - ret_color->blue != 99) - { - gtk_widget_destroy(aux_object); - fail ("hildon-color-button: get_color must not modify the color when launched on invalid widget"); - } - - gtk_widget_destroy(aux_object); - g_free (ret_color); -} -END_TEST - -/* ---------- Suite creation ---------- */ - -Suite *create_hildon_color_button_suite() -{ - /* Create the suite */ - Suite *s = suite_create("HildonColorButton"); - - /* Create test cases */ - TCase *tc1 = tcase_create("set_color"); - - /* Create test case for hildon_color_button_set_color and add it to the suite */ - tcase_add_checked_fixture(tc1, fx_setup_default_color_button, fx_teardown_default_color_button); - tcase_add_test(tc1, test_set_color_regular); - tcase_add_test(tc1, test_set_color_limits); - tcase_add_test(tc1, test_set_color_invalid); - suite_add_tcase(s, tc1); - - /* Return created suite */ - return s; -} diff --git a/tests/check-hildon-color-chooser.c b/tests/check-hildon-color-chooser.c deleted file mode 100644 index ed51741..0000000 --- a/tests/check-hildon-color-chooser.c +++ /dev/null @@ -1,276 +0,0 @@ -/* - * This file is a part of hildon tests - * - * Copyright (C) 2006, 2007 Nokia Corporation, all rights reserved. - * - * Contact: Michael Dominic Kostrzewa <michael.kostrzewa@nokia.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; version 2.1 of - * the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA - * - */ -#include <stdlib.h> -#include <check.h> -#include <gtk/gtkmain.h> -#include <glib/gprintf.h> -#include "test_suites.h" -#include "check_utils.h" - -#include <hildon/hildon-color-chooser.h> -#include <hildon/hildon-window.h> - -#define MAX_COLOR 65535 - -/* -------------------- Fixtures -------------------- */ -static HildonColorChooser *color_chooser = NULL; -static GtkWindow * cs_window; - -static void -fx_setup_default_color_chooser () -{ - int argc = 0; - gtk_init(&argc, NULL); - - cs_window = GTK_WINDOW(create_test_window()); - - /* Check window object has been created properly */ - fail_if(!HILDON_IS_WINDOW(cs_window), - "hildon-color-chooser: Window creation failed."); - - color_chooser = HILDON_COLOR_CHOOSER(hildon_color_chooser_new()); - /* Check that the color chooser object has been created properly */ - fail_if(!HILDON_IS_COLOR_CHOOSER(color_chooser), - "hildon-color-chooser: Creation failed."); - - gtk_container_add (GTK_CONTAINER(cs_window), GTK_WIDGET (color_chooser)); - - show_all_test_window(GTK_WIDGET(cs_window)); - show_all_test_window(GTK_WIDGET(color_chooser)); - -} - -static void -fx_teardown_default_color_chooser () -{ - gtk_widget_destroy (GTK_WIDGET (color_chooser)); - gtk_widget_destroy (GTK_WIDGET (cs_window)); - -} - -/* -------------------- Test cases -------------------- */ - -/* ----- Test case for set_color -----*/ - -/** - * Purpose: Check that regular base colors are set and get properly - * Cases considered: - * - Set the color #33CC33. - */ -START_TEST (test_set_color_regular) -{ - GdkColor color; - GdkColor * b_color; - GdkColor * ret_color = g_new (GdkColor, 1); - - /* Test 1: Set the color #33CC33*/ - gdk_color_parse( "#33CC33", &color); - b_color = gdk_color_copy(&color); - - hildon_color_chooser_set_color(color_chooser,b_color); - hildon_color_chooser_get_color(color_chooser, ret_color); - - fail_if ((b_color->red != ret_color->red) || (b_color->green != ret_color->green) || - (b_color->blue != ret_color->blue), - "hildon-color-chooser: The returned RGB color is %i/%i/%i and should be %i/%i/%i", - ret_color->red, ret_color->green, ret_color->blue, - b_color->red, b_color->green, b_color->blue); - - if (b_color) - gdk_color_free(b_color); - - if (ret_color) - gdk_color_free(ret_color); -} -END_TEST - -/** - * Purpose: Check that limits base colors are set and get properly - * Cases considered: - * - Set and get base color defined by #000000. - * - Set and get base color defined by #FFFFFF. - * - Set and get base color defined by #FF0000. - * - Set and get base color defined by #0000FF. - */ -START_TEST (test_set_color_limits) -{ - GdkColor color; - GdkColor * b_color; - GdkColor * ret_color = g_new (GdkColor, 1); - - /* Check that the color chooser object has been created properly */ - fail_if(!HILDON_IS_COLOR_CHOOSER(color_chooser), - "hildon-color-chooser: Creation failed."); - - /* Test 1: Set the color #000000 */ - gdk_color_parse( "#000000", &color); - b_color = gdk_color_copy(&color); - - hildon_color_chooser_set_color(color_chooser,b_color); - hildon_color_chooser_get_color(color_chooser, ret_color); - - fail_if ((b_color->red != ret_color->red) || (b_color->green != ret_color->green) || - (b_color->blue != ret_color->blue), - "hildon-color-chooser: The returned RGB color is %i/%i/%i and should be %i/%i/%i", - ret_color->red, ret_color->green, ret_color->blue, - b_color->red, b_color->green, b_color->blue); - - gdk_color_free(b_color); - - - /* Test 2: Set the color #FFFFFF */ - gdk_color_parse( "#000000", &color); - b_color = gdk_color_copy(&color); - - hildon_color_chooser_set_color(color_chooser,b_color); - hildon_color_chooser_get_color(color_chooser, ret_color); - - fail_if ((b_color->red != ret_color->red) || (b_color->green != ret_color->green) || - (b_color->blue != ret_color->blue), - "hildon-color-chooser: The returned RGB color is %i/%i/%i and should be %i/%i/%i", - ret_color->red, ret_color->green, ret_color->blue, - b_color->red, b_color->green, b_color->blue); - - gdk_color_free(b_color); - - - /* Test 3: Set the color #FF0000 */ - gdk_color_parse( "#FF0000", &color); - b_color = gdk_color_copy(&color); - - hildon_color_chooser_set_color(color_chooser,b_color); - hildon_color_chooser_get_color(color_chooser, ret_color); - - fail_if ((b_color->red != ret_color->red) || (b_color->green != ret_color->green) || - (b_color->blue != ret_color->blue), - "hildon-color-chooser: The returned RGB color is %i/%i/%i and should be %i/%i/%i", - ret_color->red, ret_color->green, ret_color->blue, - b_color->red, b_color->green, b_color->blue); - - gdk_color_free(b_color); - - /* Test 4: Set the color to #0000FF*/ - gdk_color_parse( "#0000FF", &color); - b_color = gdk_color_copy(&color); - - hildon_color_chooser_set_color(color_chooser,b_color); - hildon_color_chooser_get_color(color_chooser, ret_color); - - fail_if ((b_color->red != ret_color->red) || (b_color->green != ret_color->green) || - (b_color->blue != ret_color->blue), - "hildon-color-chooser: The returned RGB color is %i/%i/%i and should be %i/%i/%i", - ret_color->red, ret_color->green, ret_color->blue, - b_color->red, b_color->green, b_color->blue); - - if (b_color) - gdk_color_free(b_color); - - if (ret_color) - gdk_color_free(ret_color); -} -END_TEST -/** - * Purpose: Check that invalid base colors are set and get properly - * Cases considered: - * - Set the color (65536,65536,65536). - * - Set and get base color defined by NULL color. - * - Set base color on NULL object. - * - Get base color from NULL object. - */ -START_TEST (test_set_color_invalid) -{ - GdkColor color; - GdkColor * b_color; - GdkColor * ret_color = g_new (GdkColor, 1); - guint red; - guint green; - guint blue; - - /* Check that the color chooser object has been created properly */ - fail_if(!HILDON_IS_COLOR_CHOOSER(color_chooser), - "hildon-color-chooser: Creation failed."); - - /* Initialize color to check that invalid values doesn't set colors*/ - gdk_color_parse( "#000000", &color); - b_color = gdk_color_copy(&color); - - hildon_color_chooser_set_color(color_chooser,b_color); - gdk_color_free(b_color); - - - /* Test 1: Set the color (65536,65536,65536)*/ - gdk_color_parse( "#000000", &color); - b_color = gdk_color_copy(&color); - red = MAX_COLOR+1; - green = MAX_COLOR+1; - blue = MAX_COLOR+1; - - b_color->red=red; - b_color->green=green; - b_color->blue=blue; - - hildon_color_chooser_set_color(color_chooser,b_color); - hildon_color_chooser_get_color(color_chooser, ret_color); - - fail_if ((0 != ret_color->red) || (0 != ret_color->green) || (0 != ret_color->blue), - "hildon-color-chooser: The returned RGB color is %i/%i/%i and should be %i/%i/%i", - ret_color->red, ret_color->green, ret_color->blue, - 0, 0, 0); - - /* Test 2: Set the color NULL on color chooser*/ - hildon_color_chooser_set_color(color_chooser,NULL); - - /* Test 3: Set the color on NULL object*/ - hildon_color_chooser_set_color(NULL,b_color); - - /* Test 4: Get color from NULL object*/ - hildon_color_chooser_get_color(NULL, ret_color); - - if (b_color) - gdk_color_free(b_color); - - if (ret_color) - gdk_color_free(ret_color); -} -END_TEST - - -/* ---------- Suite creation ---------- */ - -Suite *create_hildon_color_chooser_suite() -{ - /* Create the suite */ - Suite *s = suite_create("HildonColorChooser"); - - /* Create test case for hildon_color_chooser_set_color and add it to the suite */ - TCase *tc1 = tcase_create("set_color"); - tcase_add_checked_fixture(tc1, fx_setup_default_color_chooser, fx_teardown_default_color_chooser); - tcase_add_test(tc1, test_set_color_regular); - tcase_add_test(tc1, test_set_color_limits); - tcase_add_test(tc1, test_set_color_invalid); - suite_add_tcase (s, tc1); - - /* Return created suite */ - return s; -} diff --git a/tests/check-hildon-controlbar.c b/tests/check-hildon-controlbar.c deleted file mode 100644 index efab1be..0000000 --- a/tests/check-hildon-controlbar.c +++ /dev/null @@ -1,418 +0,0 @@ -/* - * This file is a part of hildon tests - * - * Copyright (C) 2006, 2007 Nokia Corporation, all rights reserved. - * - * Contact: Michael Dominic Kostrzewa <michael.kostrzewa@nokia.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; version 2.1 of - * the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA - * - */ - -#include <stdlib.h> -#include <check.h> -#include <gtk/gtkmain.h> -#include <gtk/gtkcontainer.h> -#include "test_suites.h" -#include "check_utils.h" -#include <hildon/hildon-controlbar.h> - -/* -------------------- Fixtures -------------------- */ -static HildonControlbar *controlbar = NULL; -static GtkWidget *showed_window = NULL; - -static void -fx_setup_default_controlbar () -{ - int argc = 0; - gtk_init(&argc, NULL); - - controlbar = HILDON_CONTROLBAR(hildon_controlbar_new()); - /* Check controlbar object has been created properly */ - fail_if(!HILDON_IS_CONTROLBAR(controlbar), - "hildon-controlbar: Creation failed."); - - showed_window = create_test_window (); - - /* This packs the widget into the window (a gtk container). */ - gtk_container_add (GTK_CONTAINER (showed_window), GTK_WIDGET (controlbar)); - - /* Displays the widget and the window */ - show_all_test_window (showed_window); - -} - -static void -fx_teardown_default_controlbar () -{ - - /* Destroy the widget and the window */ - gtk_widget_destroy (GTK_WIDGET(showed_window)); - -} - -/* -------------------- Test cases -------------------- */ - -/* ----- Test case for set_range -----*/ -/** - * Purpose: Check that regular range values are set and get properly - * Cases considered: - * - Set a range of [20,1000]. - * - Set a range of [20,20]. - */ -START_TEST (test_set_range_regular) -{ - gint init_min; - gint init_max; - gint min; - gint max; - - /* Test 1: Set a range of [20,1000] */ - init_min = 20; - init_max = 1000; - hildon_controlbar_set_range(controlbar,init_min,init_max); - - min = hildon_controlbar_get_min(controlbar); - - fail_if (min != init_min, - "hildon-controlbar: The returned min is %d and should be %d", - min, init_min); - - max = hildon_controlbar_get_max(controlbar); - - fail_if (max != init_max, - "hildon-controlbar: The returned max is %d and should be %d", - max, init_max); - - /* Test 2: Set a range of [20, 20] */ - init_min = 20; - init_max = 20; - hildon_controlbar_set_range(controlbar,init_min,init_max); - - min = hildon_controlbar_get_min(controlbar); - - fail_if (min != init_min, - "hildon-controlbar: The returned min is %d and should be %d", - min, init_min); - - max = hildon_controlbar_get_max(controlbar); - - fail_if (max != init_max, - "hildon-controlbar: The returned max is %d and should be %d", - max, init_max); - -} -END_TEST - -/** - * Purpose: Check that limits range values are set and get properly - * Cases considered: - * - Set a range of [0,G_MAXINT-1]. - */ -START_TEST (test_set_range_limits) -{ - gint init_min; - gint init_max; - gint min; - gint max; - - /* Test 1: Set a range of [0,G_MAXINT-1] */ - init_min = 0; - init_max = G_MAXINT-1; - hildon_controlbar_set_range(controlbar,init_min,init_max); - - min=hildon_controlbar_get_min(controlbar); - - fail_if (min != init_min, - "hildon-controlbar: The returned min is %d and should be %d", - min, init_min); - - max=hildon_controlbar_get_max(controlbar); - - fail_if (max != init_max, - "hildon-controlbar: The returned max is %d and should be %d", - max, init_max); -} -END_TEST - -/** - * Purpose: Check that invalid range values are set and get properly - * Cases considered: - * - Set a range of [10,100] on NULL object. - * - Set a range of [-1,G_MAXINT]. - * - Set a range of [G_MININT,-1]. - * - Set a range of [G_MAXINT,-1]. - * - Set a range of [1,G_MININT]. - */ -START_TEST (test_set_range_invalid) -{ - gint init_min; - gint init_max; - gint min; - gint max; - - init_min = 10; - init_max = 100; - /* Test 1: Set range on a NULL object */ - hildon_controlbar_set_range(NULL,init_min,init_max); - - init_min = -1; - init_max = G_MAXINT; - /* Test 2: Set a range of [-1,G_MAXINT] */ - hildon_controlbar_set_range(controlbar,init_min,init_max); - - min=hildon_controlbar_get_min(controlbar); - - fail_if (min != init_min, - "hildon-controlbar: The returned min is %d and should be %d", - min, init_min); - - max=hildon_controlbar_get_max(controlbar); - - fail_if (max != init_max, - "hildon-controlbar: The returned max is %d and should be %d", - max, init_max); - - /* Test 3: Set a range of [G_MININT,-1] */ - init_min = G_MININT; - init_max = -1; - hildon_controlbar_set_range(controlbar,init_min,init_max); - - min=hildon_controlbar_get_min(controlbar); - - fail_if (min != init_min, - "hildon-controlbar: The returned min is %d and should be %d", - min, init_min); - max=hildon_controlbar_get_max(controlbar); - - fail_if (max != init_max, - "hildon-controlbar: The returned max is %d and should be %d", - max, init_max); - - /* Test 4: Set a range of [G_MAXINT,-1] */ - init_min = G_MAXINT; - init_max = -1; - hildon_controlbar_set_range(controlbar,init_min,init_max); - - max=hildon_controlbar_get_max(controlbar); - - fail_if (max != init_max, - "hildon-controlbar: The returned max is %d and should be %d", - max, init_max); - - min=hildon_controlbar_get_min(controlbar); - - fail_if (min != init_max, - "hildon-controlbar: The returned min is %d and should be %d", - min, init_max); - - /* NOTE: The test below has been deliverately commented out, since - it fails miserably. The range check in hildon_control_bar_set_range() - is _broken_ and fixing it causes other tests to fail. It is safe to assume - that by now, fixing this is going to cause more headaches than anything else, - and being this a deprecated widget, there is no point on wasting time on it. - */ - - /* Test 5: Set a range of [1,G_MININT] */ -#if 0 - init_min = 1; - init_max = G_MININT; - hildon_controlbar_set_range(controlbar,init_min,init_max); - - max=hildon_controlbar_get_max(controlbar); - - fail_if (max != init_min, - "hildon-controlbar: The returned max is %d and should be %d", - max, init_min); - - min=hildon_controlbar_get_min(controlbar); - - fail_if (min != init_min, - "hildon-controlbar: The returned min is %d and should be %d", - min, init_min); -#endif -} -END_TEST - -/* ----- Test case for set_value -----*/ -/** - * Purpose: Check that regular values are set and get properly - * Cases considered: - * - Set a value of 500 in the range [0,1000]. - */ -START_TEST (test_set_value_regular) -{ - gint init_value; - gint value; - - init_value=500; - /* Must set a range different than [0,0], if not set you can not set a value*/ - hildon_controlbar_set_range(controlbar,0,1000); - - /* Test 1: Set a value of 500 in the range [0,1000].*/ - hildon_controlbar_set_value(controlbar,init_value); - value=hildon_controlbar_get_value(controlbar); - fail_if (value != init_value, - "hildon-controlbar: The returned value is %d and should be %d", - value, init_value); - -} -END_TEST - -/** - * Purpose: Check that limit values are set and get properly - * Cases considered: - * - Set a value of 0 in the range [0,1000]. - * - Set a value of 1000 in the range [0,1000]. - */ -START_TEST (test_set_value_limits) -{ - gint init_value; - gint value; - - /* Must set a range diferent than [0,0], if not set you can not set a value*/ - hildon_controlbar_set_range(controlbar,0,1000); - - /* Test 1: Set a value of 0 in the range [0,1000] */ - init_value=0; - - hildon_controlbar_set_value(controlbar,init_value); - value=hildon_controlbar_get_value(controlbar); - fail_if (value != init_value, - "hildon-controlbar: The returned value is %d and should be %d", - value, init_value); - - /* Test 2: Set a value of 1000 in the range [0,1000] */ - init_value=1000; - - hildon_controlbar_set_value(controlbar,init_value); - value=hildon_controlbar_get_value(controlbar); - fail_if (value != init_value, - "hildon-controlbar: The returned value is %d and should be %d", - value, init_value); -} -END_TEST - - -/** - * Purpose: Check that invalid values are set and get properly - * Cases considered: - * - Set a value of 1 in a NULL controlbar. - * - Set a value of -1 in the range [2,1000]. - * - Set a value of 1 in the range [2,1000]. - * - Set a value of G_MININT in the range [2,1000]. - * - Set a value of 1001 in the range [2,1000]. - * - Set a value of G_MAXINT in the range [2,1000]. - * - Set a value of G_MAXINT in the range [2,G_MAXINT]. - */ -START_TEST (test_set_value_invalid) -{ - gint init_value; - gint initial_value=4; - gint value; - gint current_value; - gint min_value; - gint max_value; - - min_value = 2; - max_value = 1000; - /* Must set a range diferent than [0,0], if not set you can not set a value*/ - hildon_controlbar_set_range(controlbar,min_value,max_value); - hildon_controlbar_set_value(controlbar,initial_value); - - /* Test 1: Set a value of 1 in a NULL controlbar. */ - init_value=10; - hildon_controlbar_set_value(NULL,init_value); - - - /* Test 2: Set a value of -1 in the range [2,1000] */ - init_value=-1; - hildon_controlbar_set_value(controlbar,init_value); - value=hildon_controlbar_get_value(controlbar); - fail_if (value != initial_value, - "hildon-controlbar: The returned value is %d and should be %d", - value, initial_value); - - /* Test 3: Set a value of 1 in the range [2,1000] */ - init_value=1; - hildon_controlbar_set_value(controlbar,min_value); - - hildon_controlbar_set_value(controlbar,init_value); - value=hildon_controlbar_get_value(controlbar); - fail_if (value != min_value, - "hildon-controlbar: The returned value is %d and should be %d", - value, min_value); - - - /* Test 4: Set a value of G_MININT in the range [2,1000] */ - init_value=G_MININT; - hildon_controlbar_set_value(controlbar,min_value+2); - current_value = hildon_controlbar_get_value(controlbar); - - hildon_controlbar_set_value(controlbar,init_value); - value=hildon_controlbar_get_value(controlbar); - fail_if (value != current_value, - "hildon-controlbar: The returned value is %d and should be %d", - value, current_value); - - /* Test 5: Set a value of 1001 in the range [2,1000] */ - init_value=1001; - - hildon_controlbar_set_value(controlbar,init_value); - value=hildon_controlbar_get_value(controlbar); - fail_if (value != max_value, - "hildon-controlbar: The returned value is %d and should be %d", - value, max_value); - - - /* Test 6: Set a value of G_MAXINT in the range [2,1000] */ - init_value=G_MAXINT; - - hildon_controlbar_set_value(controlbar,init_value); - value=hildon_controlbar_get_value(controlbar); - fail_if (value != max_value, - "hildon-controlbar: The returned value is %d and should be %d", - value, max_value); -} -END_TEST - -/* ---------- Suite creation ---------- */ - -Suite *create_hildon_controlbar_suite() -{ - /* Create the suite */ - Suite *s = suite_create("HildonControlbar"); - - /* Create test cases */ - TCase *tc1 = tcase_create("set_range"); - TCase *tc2 = tcase_create("set_value"); - - /* Create test case for hildon_controlbar_set_range and add it to the suite */ - tcase_add_checked_fixture(tc1, fx_setup_default_controlbar, fx_teardown_default_controlbar); - tcase_add_test(tc1, test_set_range_regular); - tcase_add_test(tc1, test_set_range_limits); - tcase_add_test(tc1, test_set_range_invalid); - suite_add_tcase (s, tc1); - - /* Create test case for hildon_controlbar_set_value and add it to the suite */ - tcase_add_checked_fixture(tc2, fx_setup_default_controlbar, fx_teardown_default_controlbar); - tcase_add_test(tc2, test_set_value_regular); - tcase_add_test(tc2, test_set_value_limits); - tcase_add_test(tc2, test_set_value_invalid); - suite_add_tcase (s, tc2); - - return s; -} diff --git a/tests/check-hildon-date-editor.c b/tests/check-hildon-date-editor.c deleted file mode 100644 index ea953d5..0000000 --- a/tests/check-hildon-date-editor.c +++ /dev/null @@ -1,1040 +0,0 @@ -/* - * This file is a part of hildon tests - * - * Copyright (C) 2006, 2007 Nokia Corporation, all rights reserved. - * - * Contact: Michael Dominic Kostrzewa <michael.kostrzewa@nokia.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; version 2.1 of - * the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA - * - */ - -#include <stdlib.h> -#include <check.h> -#include <gtk/gtkmain.h> -#include <gtk/gtkhbox.h> -#include "test_suites.h" -#include "check_utils.h" - -#include <hildon/hildon-date-editor.h> - -/* Taken from the values of the properties of HildonDateEditor */ -#define MAX_YEAR 2037 -#define MAX_MONTH 12 -#define MAX_DAY 31 -#define MIN_YEAR 1970 -#define MIN_MONTH 1 -#define MIN_DAY 1 - -/* -------------------- Fixtures -------------------- */ - -static HildonDateEditor *date_editor = NULL; -static GtkWidget *showed_window = NULL; - -static void -fx_setup_default_date_editor () -{ - int argc = 0; - - gtk_init(&argc, NULL); - - showed_window = create_test_window (); - - date_editor = HILDON_DATE_EDITOR(hildon_date_editor_new()); - /* Check that the date editor object has been created properly */ - fail_if(!HILDON_IS_DATE_EDITOR(date_editor), - "hildon-date-editor: Creation failed."); - - /* This packs the widget into the window (a gtk container). */ - gtk_container_add (GTK_CONTAINER (showed_window), GTK_WIDGET (date_editor)); - - /* Displays the widget and the window */ - show_all_test_window (showed_window); -} - -static void -fx_teardown_default_date_editor () -{ - - /* Destroy the widget and the window */ - gtk_widget_destroy (GTK_WIDGET (showed_window)); - -} - -/* -------------------- Test cases -------------------- */ - -/* ----- Test case for set_date -----*/ - -/** - * Purpose: test setting regular values for hildon_date_editor_set_date - * Cases considered: - * - Set and get the date 30/03/1981 - */ -START_TEST (test_set_date_regular) -{ - guint year, month, day; - guint ret_year, ret_month, ret_day; - - year = 1981; - month = 3; - day = 30; - - /* Test 1: Try date 30/3/1981 */ - hildon_date_editor_set_date (date_editor, year, month, day); - hildon_date_editor_get_date (date_editor, &ret_year, &ret_month, &ret_day); - - fail_if ((ret_year != year) || (ret_month != month) || (ret_day != day), - "hildon-date-editor: The returned date is %u/%u/%u and should be %u/%u/%u", - ret_year, ret_month, ret_day, year, month, day); -} -END_TEST - -static void -test_set_date_limits_check (guint year, guint month, guint day) -{ - guint ret_year, ret_month, ret_day; - - hildon_date_editor_set_date (date_editor, year, month, day); - hildon_date_editor_get_date (date_editor, &ret_year, &ret_month, &ret_day); - - fail_if ((ret_year != year) || (ret_month != month) || (ret_day != day), - "hildon-date-editor: The returned date is %u/%u/%u and should be %u/%u/%u", - ret_year, ret_month, ret_day, year, month, day); -} - -/** - * Purpose: test limit date values for hildon_date_editor_set_date - * Cases considered: - * - test a year value equal to the year limits (1970, 2037) - * - test a month value equal to the month limits (1, 12) - * - test a day value equal to the day limits for March (1, 31) - * - test a day value equal to the day limits June (1, 30) - * - test a day value equal to the day limit for a common February (28-2-1981) - * - test a day value equal to the day limit for a February of a leap year (29-2-1980) - */ -START_TEST (test_set_date_limits) -{ - guint year, month, day; - - year = MIN_YEAR; - month = 3; - day = 30; - - /* Test 1: Test year limits */ - test_set_date_limits_check (year, month, day); - - year = MAX_YEAR; - test_set_date_limits_check (year, month, day); - - /* Test 2: Test month limits */ - year = 1981; - month = MIN_MONTH; - day = 30; - test_set_date_limits_check (year, month, day); - - month = MAX_MONTH; - test_set_date_limits_check (year, month, day); - - /* Test 3: Test day limits */ - year = 1981; - month = 3; - day = 31; - test_set_date_limits_check (year, month, day); - - /* Test 4: Test day limits */ - year = 1981; - month = 6; - day = 30; - test_set_date_limits_check (year, month, day); - - /* Test 5: Test february limits */ - year = 1981; - month = 2; - day = 28; - test_set_date_limits_check (year, month, day); - - /* Test 6: Test february limits for a leap year */ - year = 1980; - month = 2; - day = 29; - test_set_date_limits_check (year, month, day); -} -END_TEST - -/** - * Purpose: test invalid parameter values for hildon_date_editor_set_date - * Cases considered: - * - test NULL widget - * - test passing GtkHBox instead a HildonDateEditor - * - test leap year - * - test negative values - * - test invalid month days - * - test a year value lower and higher than the year limits (1970, 2037) - * - test a month value lower and higher than the year limits (1, 12) - * - test a day value lower and higher than the year limits (1, 31) - */ -START_TEST (test_set_date_invalid) -{ - guint year, month, day; - guint ret_year, ret_month, ret_day; - GtkWidget *aux_object = NULL; - - year = 1981; - month = 3; - day = 30; - - /* Set init date */ - hildon_date_editor_set_date (date_editor, year, month, day); - - /* Test 1: Test NULL */ - hildon_date_editor_set_date (NULL, year, month, day); - hildon_date_editor_get_date (date_editor, &ret_year, &ret_month, &ret_day); - - fail_if ((ret_year != year) || (ret_month != month) || (ret_day != day), - "hildon-date-editor: The returned date is %u/%u/%u and should be %u/%u/%u", - ret_year, ret_month, ret_day, year, month, day); - - /* Test 2: Test another object */ - aux_object = gtk_hbox_new (TRUE, 0); - hildon_date_editor_set_date ((HildonDateEditor *) (aux_object), year, month, day); - hildon_date_editor_get_date (date_editor, &ret_year, &ret_month, &ret_day); - - fail_if ((ret_year != year) || (ret_month != month) || (ret_day != day), - "hildon-date-editor: The returned date is %u/%u/%u and should be %u/%u/%u", - ret_year, ret_month, ret_day, year, month, day); - gtk_widget_destroy (GTK_WIDGET(aux_object)); - - /* Test 3: Test leap year */ - hildon_date_editor_set_date (date_editor, year, 2, 29); - hildon_date_editor_get_date (date_editor, &ret_year, &ret_month, &ret_day); - - fail_if ((ret_year != year) || (ret_month != month) || (ret_day != day), - "hildon-date-editor: The returned date is %u/%u/%u and should be %u/%u/%u", - ret_year, ret_month, ret_day, year, month, day); - - /* Restore the original value */ - hildon_date_editor_set_date (date_editor, year, month, day); - - /* Test 4: Test negative values */ - hildon_date_editor_set_date (date_editor, -year, -month, -day); - hildon_date_editor_get_date (date_editor, &ret_year, &ret_month, &ret_day); - fail_if ((ret_year != year) || (ret_month != month) || (ret_day != day), - "hildon-date-editor: The returned date is %u/%u/%u and should be %u/%u/%u", - ret_year, ret_month, ret_day, year, month, day); - - /* Test 5: Test invalid month days */ - hildon_date_editor_set_date (date_editor, year, 11, 31); - hildon_date_editor_get_date (date_editor, &ret_year, &ret_month, &ret_day); - fail_if ((ret_year != year) || (ret_month != month) || (ret_day != day), - "hildon-date-editor: The returned date is %u/%u/%u and should be %u/%u/%u", - ret_year, ret_month, ret_day, year, month, day); - - /* Test 6: Test year invalid values, the year value could be set - under/over the value of the property because the date is not - validated if the value was not set through the user interface */ - hildon_date_editor_set_date (date_editor, MIN_YEAR - 1, month, day); - hildon_date_editor_get_date (date_editor, &ret_year, &ret_month, &ret_day); - - fail_if (ret_year != (MIN_YEAR - 1), - "hildon-date-editor: The returned year is %u and should be %u", - ret_year, MIN_YEAR - 1); - - hildon_date_editor_set_date (date_editor, MAX_YEAR + 1, month, day); - hildon_date_editor_get_date (date_editor, &ret_year, &ret_month, &ret_day); - - fail_if (ret_year != MAX_YEAR + 1, - "hildon-date-editor: The returned year is %u and should be %u", - ret_year, MAX_YEAR + 1); - - /* Test 7: Test month invalid values, we do not have the same - problem with the years because both month 0 and 13 are not valid - for g_date */ - hildon_date_editor_set_date (date_editor, year, MIN_MONTH - 1, day); - hildon_date_editor_get_date (date_editor, &ret_year, &ret_month, &ret_day); - - fail_if (ret_month != month, - "hildon-date-editor: The returned month is %u and should be %u", - ret_month, month); - - hildon_date_editor_set_date (date_editor, year, MAX_MONTH + 1, day); - hildon_date_editor_get_date (date_editor, &ret_year, &ret_month, &ret_day); - - fail_if (ret_month != month, - "hildon-date-editor: The returned month is %u and should be %u", - ret_month, month); - - /* Test 8: Test day invalid values */ - hildon_date_editor_set_date (date_editor, year, month, MIN_DAY - 1); - hildon_date_editor_get_date (date_editor, &ret_year, &ret_month, &ret_day); - - fail_if (ret_day != day, - "hildon-date-editor: The returned day is %u and should be %u", - ret_day, day); - - hildon_date_editor_set_date (date_editor, year, month, MAX_DAY + 1); - hildon_date_editor_get_date (date_editor, &ret_year, &ret_month, &ret_day); - - fail_if (ret_day != day, - "hildon-date-editor: The returned day is %u and should be %u", - ret_day, day); -} -END_TEST - -/* ----- Test case for get_date -----*/ - -/* We do not include tests for limit values because we think they're - tested enought with the set_data tests */ - -/** - * Purpose: test getting regular values for hildon_date_editor_get_date - * Cases considered: - * - Set and get date 30/03/1981 - */ -START_TEST (test_get_date_regular) -{ - guint year, month, day; - guint ret_year, ret_month, ret_day; - GValue value = { 0, }; - - year = 1981; - month = 3; - day = 30; - - /* Test 1: Test regular values */ - hildon_date_editor_set_date (NULL, year, month, day); - - hildon_date_editor_get_date (date_editor, &ret_year, &ret_month, &ret_day); - - g_value_init (&value, G_TYPE_UINT); - g_object_get_property (G_OBJECT (date_editor), "year", &value); - fail_if (g_value_get_uint (&value) != ret_year, - "hildon-date-editor: get_date failed. The returned year is %u and should be %u", - g_value_get_uint (&value), - ret_year); - - g_value_unset (&value); - g_value_init (&value, G_TYPE_UINT); - g_object_get_property (G_OBJECT (date_editor), "month", &value); - fail_if (g_value_get_uint (&value) != ret_month, - "hildon-date-editor: get_date failed. The returned month is %u and should be %u", - g_value_get_uint (&value), - ret_month); - - g_value_unset (&value); - g_value_init (&value, G_TYPE_UINT); - g_object_get_property (G_OBJECT (date_editor), "day", &value); - fail_if (g_value_get_uint (&value) != ret_day, - "hildon-date-editor: get_date failed. The returned day is %u and should be %u", - g_value_get_uint (&value), - ret_day); -} -END_TEST - -/** - * Purpose: test getting regular values passing invalid arguments for - * hildon_date_editor_get_date - * Cases considered: - * - HildonDateEditor NULL - * - year is NULL - * - month is NULL - * - day is NULL - */ -START_TEST (test_get_date_invalid) -{ - guint year, month, day; - guint ret_year, ret_month, ret_day; - - year = 1981; - month = 3; - day = 30; - - hildon_date_editor_set_date (date_editor, year, month, day); - - /* Check that does not fail */ - hildon_date_editor_get_date (NULL, &ret_year, &ret_month, &ret_day); - - /* Check NULL arguments */ - hildon_date_editor_get_date (date_editor, NULL, &ret_month, &ret_day); - fail_if (hildon_date_editor_get_year (date_editor) != year, - "hildon-date-editor: get_date failed. The returned year is %u and should be %u", - ret_year, year); - - hildon_date_editor_get_date (date_editor, &ret_year, NULL, &ret_day); - fail_if (hildon_date_editor_get_month (date_editor) != month, - "hildon-date-editor: get_date failed. The returned month is %u and should be %u", - ret_month, month); - - hildon_date_editor_get_date (date_editor, &ret_year, &ret_month, NULL); - fail_if (hildon_date_editor_get_day (date_editor) != day, - "hildon-date-editor: get_date failed. The returned day is %u and should be %u", - ret_day, day); -} -END_TEST - -/* ----- Test case for get_year -----*/ - -/** - * Purpose: test getting regular values of the year for hildon_date_editor_get_year - * Cases considered: - * - get a year set with set_date 30/03/1981 - * - get a year set with set_year 1980 - * - get a year set with set_property 2004 - */ -START_TEST (test_get_year_regular) -{ - guint year, month, day; - GValue value = {0, }; - - year = 1981; - month = 3; - day = 30; - - /* Test 1: Set year with set_date */ - hildon_date_editor_set_date (date_editor, year, month, day); - - fail_if (hildon_date_editor_get_year (date_editor) != year, - "hildon-date-editor: get_year failed. The returned year is %u and should be %u", - hildon_date_editor_get_year (date_editor), year); - - /* Test 2: set year with set_year */ - year = 1980; - hildon_date_editor_set_year (date_editor, year); - - fail_if (hildon_date_editor_get_year (date_editor) != year, - "hildon-date-editor: get_year failed. The returned year is %u and should be %u", - hildon_date_editor_get_year (date_editor), year); - - /* Test 3: set year with set_property */ - year = 2004; - g_value_init (&value, G_TYPE_UINT); - g_value_set_uint (&value, year); - g_object_set_property (G_OBJECT (date_editor), "year", &value); - - fail_if (hildon_date_editor_get_year (date_editor) != year, - "hildon-date-editor: get_year failed. The returned year is %u and should be %u", - hildon_date_editor_get_year (date_editor), year); -} -END_TEST - -/** - * Purpose: test getting year when a value over the limits was set for - * hildon_date_editor_get_year - * Cases considered: - * - test year 2037 - * - test year 1970 - */ -START_TEST (test_get_year_limits) -{ - guint year; - - year = 1981; - - /* Set init year */ - hildon_date_editor_set_year (date_editor, year); - - /* Test 1: upper limit */ - hildon_date_editor_set_year (date_editor, MAX_YEAR); - - fail_if (hildon_date_editor_get_year (date_editor) != MAX_YEAR, - "hildon-date-editor: The returned year is %u and should be %u", - hildon_date_editor_get_year (date_editor), MAX_YEAR); - - /* Test 2: lower limit */ - hildon_date_editor_set_year (date_editor, MIN_YEAR); - - fail_if (hildon_date_editor_get_year (date_editor) != MIN_YEAR, - "hildon-date-editor: The returned year is %u and should be %u", - hildon_date_editor_get_year (date_editor), MIN_YEAR); -} -END_TEST - -/** - * Purpose: test getting a year for invalid attributes for - * hildon_date_editor_get_year - * Cases considered: - * - HildonDateEditor is NULL - * - Pass a GtkHBox instead a HildonDateEditor - * - test year 2038 - * - test year 1969 - */ -START_TEST (test_get_year_invalid) -{ - guint ret_year; - GtkWidget *aux_object = NULL; - - /* Test 1: Test NULL */ - ret_year = hildon_date_editor_get_year (NULL); - fail_if (ret_year != 0, - "hildon-date-editor: get_year failed. The returned year is %u and should be %u", - ret_year, 0); - - /* Test 2: another object */ - aux_object = gtk_hbox_new (TRUE, 0); - ret_year = hildon_date_editor_get_year ((HildonDateEditor *) (aux_object)); - fail_if (ret_year != 0, - "hildon-date-editor: get_year failed. The returned year is %u and should be %u", - ret_year, 0); - gtk_widget_destroy (GTK_WIDGET(aux_object)); - - /* Test 3: upper limit, the test is OK but it shouldn't. The reason - is that the value of the date is not validated by Hildon since it - was not set using the UI */ - hildon_date_editor_set_year (date_editor, MAX_YEAR + 1); - - fail_if (hildon_date_editor_get_year (date_editor) != MAX_YEAR + 1, - "hildon-date-editor: The returned year is %u and should be %u", - hildon_date_editor_get_year (date_editor), MAX_YEAR + 1); - - /* Test 4: lower limit, see the above comment */ - hildon_date_editor_set_year (date_editor, MIN_YEAR - 1); - - fail_if (hildon_date_editor_get_year (date_editor) != MIN_YEAR - 1, - "hildon-date-editor: The returned year is %u and should be %u", - hildon_date_editor_get_year (date_editor), MIN_YEAR - 1); -} -END_TEST - -/* ----- Test case for set_year -----*/ - -/** - * Purpose: test setting a regular value for a year for - * hildon_date_editor_set_year - * Cases considered: - * - Set year 1981 - */ -START_TEST (test_set_year_regular) -{ - guint year; - guint ret_year; - - year = 1981; - - /* Test 1: Try year 1981 */ - hildon_date_editor_set_year (date_editor, year); - ret_year = hildon_date_editor_get_year (date_editor); - - fail_if (ret_year != year, - "hildon-date-editor: set_year failed. The returned year is %u and should be %u", - ret_year, year); -} -END_TEST - -/** - * Purpose: test setting values of the year over the limits for - * hildon_date_editor_set_year - * Cases considered: - * - Set year 2037 - * - Set year 1970 - */ -START_TEST (test_set_year_limits) -{ - guint year; - GValue value = { 0, }; - - year = 1981; - - /* Set init date */ - hildon_date_editor_set_year (date_editor, year); - - /* Test 1: Test upper limit */ - g_value_init (&value, G_TYPE_UINT); - hildon_date_editor_set_year (date_editor, MAX_YEAR); - g_object_get_property (G_OBJECT (date_editor), "year", &value); - fail_if (g_value_get_uint (&value) != MAX_YEAR, - "hildon-date-editor: The returned year is %u and should be %u", - g_value_get_uint (&value), year); - - /* Test 2: Test lower limit */ - g_value_unset (&value); - g_value_init (&value, G_TYPE_UINT); - hildon_date_editor_set_year (date_editor, MIN_YEAR); - g_object_get_property (G_OBJECT (date_editor), "year", &value); - fail_if (g_value_get_uint (&value) != MIN_YEAR, - "hildon-date-editor: The returned year is %u and should be %u", - g_value_get_uint (&value), MIN_YEAR); -} -END_TEST - -/* ----- Test case for get_month -----*/ - -/** - * Purpose: test getting a year for regular values for - * hildon_date_editor_get_month - * Cases considered: - * - set month with set_date 30/03/1981 - * - set month with set_month 1 - * - set month with set_property 7 - */ -START_TEST (test_get_month_regular) -{ - guint year, month, day; - GValue value = {0, }; - - year = 1981; - month = 3; - day = 30; - - /* Test 1: Set year with set_date */ - hildon_date_editor_set_date (date_editor, year, month, day); - - fail_if (hildon_date_editor_get_month (date_editor) != month, - "hildon-date-editor: The returned month is %u and should be %u", - hildon_date_editor_get_month (date_editor), month); - - /* Test 2: set month with set_month */ - month = 1; - hildon_date_editor_set_month (date_editor, month); - - fail_if (hildon_date_editor_get_month (date_editor) != month, - "hildon-date-editor: The returned month is %u and should be %u", - hildon_date_editor_get_month (date_editor), month); - - /* Test 3: set month with set_property */ - month = 7; - g_value_init (&value, G_TYPE_UINT); - g_value_set_uint (&value, month); - g_object_set_property (G_OBJECT (date_editor), "month", &value); - - fail_if (hildon_date_editor_get_month (date_editor) != month, - "hildon-date-editor: The returned month is %u and should be %u", - hildon_date_editor_get_month (date_editor), month); -} -END_TEST - -/** - * Purpose: test getting values of the month over the limits for - * hildon_date_editor_get_month - * Cases considered: - * - Get month 12 - * - Get month 1 - */ -START_TEST (test_get_month_limits) -{ - - /* Test 1: Upper limit */ - hildon_date_editor_set_month (date_editor, MAX_MONTH); - - fail_if (hildon_date_editor_get_month (date_editor) != MAX_MONTH, - "hildon-date-editor: get_month failed. The returned month is %u and should be %u", - hildon_date_editor_get_month (date_editor), MAX_MONTH); - - /* Test 2: Lower limit */ - hildon_date_editor_set_month (date_editor, MIN_MONTH); - - fail_if (hildon_date_editor_get_month (date_editor) != MIN_MONTH, - "hildon-date-editor: get_month failed. The returned month is %u and should be %u", - hildon_date_editor_get_month (date_editor), MIN_MONTH); -} -END_TEST - -/** - * Purpose: test getting a month for invalid attributes for - * hildon_date_editor_get_month - * Cases considered: - * - HildonDateEditor is NULL - * - HildonDateEditor is really a GtkHBox - */ -START_TEST (test_get_month_invalid) -{ - guint ret_month; - GtkWidget *aux_object = NULL; - - /* Test 1: Test NULL */ - ret_month = hildon_date_editor_get_month (NULL); - fail_if (ret_month != 0, - "hildon-date-editor: get_month failed. The returned month is %u and should be %u", - ret_month, 0); - - /* Test 2: another object */ - aux_object = gtk_hbox_new (TRUE, 0); - ret_month = hildon_date_editor_get_month ((HildonDateEditor *) (aux_object)); - fail_if (ret_month != 0, - "hildon-date-editor: get_month failed. The returned month is %u and should be %u", - ret_month, 0); - gtk_widget_destroy (GTK_WIDGET(aux_object)); -} -END_TEST - -/* ----- Test case for set_month -----*/ - -/** - * Purpose: test setting regular values for month for - * hildon_date_editor_set_month - * Cases considered: - * - Set month 3 - */ -START_TEST (test_set_month_regular) -{ - guint month; - guint ret_month; - - month = 3; - - /* Test 1: Try month March (3) */ - hildon_date_editor_set_month (date_editor, month); - ret_month = hildon_date_editor_get_month (date_editor); - - fail_if (ret_month != month, - "hildon-date-editor: set_month failed. The returned month is %u and should be %u", - ret_month, month); -} -END_TEST - -/** - * Purpose: test setting values for month over the limits for - * hildon_date_editor_get_month - * Cases considered: - * - Set month 12 - * - Set month 1 - */ -START_TEST (test_set_month_limits) -{ - GValue value = { 0, }; - - /* Test 1: Test upper limit */ - g_value_init (&value, G_TYPE_UINT); - hildon_date_editor_set_month (date_editor, MAX_MONTH); - g_object_get_property (G_OBJECT (date_editor), "month", &value); - fail_if (g_value_get_uint (&value) != MAX_MONTH, - "hildon-date-editor: The returned month is %u and should be %u", - g_value_get_uint (&value), MAX_MONTH); - - /* Test 2: Test lower limit */ - g_value_unset (&value); - g_value_init (&value, G_TYPE_UINT); - hildon_date_editor_set_month (date_editor, MIN_MONTH); - g_object_get_property (G_OBJECT (date_editor), "month", &value); - fail_if (g_value_get_uint (&value) != MIN_MONTH, - "hildon-date-editor: The returned month is %u and should be %u", - g_value_get_uint (&value), MIN_MONTH); -} -END_TEST - -/* ----- Test case for get_day -----*/ - -/** - * Purpose: test getting regular values for day for - * hildon_date_editor_get_day - * Cases considered: - * - Get a day set with set_date 30/03/1981 - * - Get a day set with set_day 6 - * - Get a day set with set_property 10 - */ -START_TEST (test_get_day_regular) -{ - guint year, month, day; - GValue value = {0, }; - - year = 1981; - month = 3; - day = 30; - - /* Test 1: Set day with set_date */ - hildon_date_editor_set_date (date_editor, year, month, day); - - fail_if (hildon_date_editor_get_day (date_editor) != day, - "hildon-date-editor: The returned day is %u and should be %u", - hildon_date_editor_get_day (date_editor), day); - - /* Test 2: set day with set_day */ - day = 6; - hildon_date_editor_set_day (date_editor, day); - - fail_if (hildon_date_editor_get_day (date_editor) != day, - "hildon-date-editor: The returned day is %u and should be %u", - hildon_date_editor_get_day (date_editor), day); - - - /* Test 3: set day with set_property */ - day = 10; - g_value_init (&value, G_TYPE_UINT); - g_value_set_uint (&value, day); - g_object_set_property (G_OBJECT (date_editor), "day", &value); - - fail_if (hildon_date_editor_get_day (date_editor) != day, - "hildon-date-editor: The returned day is %u and should be %u", - hildon_date_editor_get_day (date_editor), day); - -} -END_TEST - -/** - * Purpose: test getting a day set over the limits for - * hildon_date_editor_get_day - * Cases considered: - * - Get day 31 for March - * - Get day 30 for June - * - Get day 29 for February for a leap year - * - Get day 28 for February for a common year - * - Get day 1 - */ -START_TEST (test_get_day_limits) -{ - guint day, month, year; - - year = 1981; - month = 3; - day = 31; - - /* Test 1: 31 of February */ - hildon_date_editor_set_date (date_editor, year, month, day); - fail_if (hildon_date_editor_get_day (date_editor) != day, - "hildon-date-editor: get_day failed. The returned day is %u and should be %u", - hildon_date_editor_get_day (date_editor), day); - - /* Test 2: 30 of February */ - month = 6; - day = 30; - hildon_date_editor_set_date (date_editor, year, month, day); - fail_if (hildon_date_editor_get_day (date_editor) != day, - "hildon-date-editor: get_day failed. The returned day is %u and should be %u", - hildon_date_editor_get_day (date_editor), day); - - /* Test 3: 29 of February */ - year = 1980; - month = 2; - day = 29; - hildon_date_editor_set_date (date_editor, year, month, day); - fail_if (hildon_date_editor_get_day (date_editor) != day, - "hildon-date-editor: get_day failed. The returned day is %u and should be %u", - hildon_date_editor_get_day (date_editor), day); - - /* Test 3: 28 of February */ - year = 1981; - month = 2; - day = 28; - hildon_date_editor_set_date (date_editor, year, month, day); - fail_if (hildon_date_editor_get_day (date_editor) != day, - "hildon-date-editor: get_day failed. The returned day is %u and should be %u", - hildon_date_editor_get_day (date_editor), day); - - /* Test 5: day 1 */ - hildon_date_editor_set_day (date_editor, 1); - - fail_if (hildon_date_editor_get_day (date_editor) != 1, - "hildon-date-editor: get_day failed. The returned day is %u and should be %u", - hildon_date_editor_get_day (date_editor), 1); -} -END_TEST - -/** - * Purpose: test getting a day with invalid attributes for - * hildon_date_editor_get_day - * Cases considered: - * - HildonDateEditor is NULL - * - HildonDateEditor is really a GtkHBox - */ -START_TEST (test_get_day_invalid) -{ - guint ret_year; - GtkWidget *aux_object = NULL; - - /* Test 1: Test NULL */ - ret_year = hildon_date_editor_get_year (NULL); - fail_if (ret_year != 0, - "hildon-date-editor: get_year failed. The returned year is %u and should be %u", - ret_year, 0); - - /* Test 2: another object */ - aux_object = gtk_hbox_new (TRUE, 0); - ret_year = hildon_date_editor_get_year ((HildonDateEditor *) aux_object); - fail_if (ret_year != 0, - "hildon-date-editor: get_year failed. The returned year is %u and should be %u", - ret_year, 0); - gtk_widget_destroy (GTK_WIDGET(aux_object)); -} -END_TEST - -/* ----- Test case for set_day -----*/ - -/** - * Purpose: test setting a regular value for day for - * hildon_date_editor_get_day - * Cases considered: - * - Set day 30 - */ -START_TEST (test_set_day_regular) -{ - guint day; - guint ret_day; - - day = 25; - - /* Test 1: Try day 30 */ - hildon_date_editor_set_day (date_editor, day); - ret_day = hildon_date_editor_get_day (date_editor); - - fail_if (ret_day != day, - "hildon-date-editor: set_day failed. The returned day is %u and should be %u", - ret_day, day); -} -END_TEST - -/** - * Purpose: test seeting a day over the limits for - * hildon_date_editor_get_day - * Cases considered: - * - Set day 31 - * - Set day 30 - * - Set day 29 - * - Set day 28 - * - Set day 1 - */ -START_TEST (test_set_day_limits) -{ - guint day, year, month; - GValue value = { 0, }; - - year = 1981; - month = 3; - day = 31; - - /* Set init date */ - hildon_date_editor_set_date (date_editor, year, month, MIN_DAY); - - /* Test 1: Test 31/03 */ - g_value_init (&value, G_TYPE_UINT); - hildon_date_editor_set_day (date_editor, day); - g_object_get_property (G_OBJECT (date_editor), "day", &value); - fail_if (g_value_get_uint (&value) != day, - "hildon-date-editor: The returned day is %u and should be %u", - g_value_get_uint (&value), day); - - /* Test 2: Test 30/06 */ - month = 6; - day = 30; - hildon_date_editor_set_date (date_editor, year, month, 1); - g_value_unset (&value); - g_value_init (&value, G_TYPE_UINT); - hildon_date_editor_set_day (date_editor, day); - g_object_get_property (G_OBJECT (date_editor), "day", &value); - fail_if (g_value_get_uint (&value) != day, - "hildon-date-editor: The returned day is %u and should be %u", - g_value_get_uint (&value), day); - - /* Test 3: Test 29/02/1980 */ - year = 1980; - month = 2; - day = 29; - hildon_date_editor_set_date (date_editor, year, month, 1); - g_value_unset (&value); - g_value_init (&value, G_TYPE_UINT); - hildon_date_editor_set_day (date_editor, day); - g_object_get_property (G_OBJECT (date_editor), "day", &value); - fail_if (g_value_get_uint (&value) != day, - "hildon-date-editor: The returned day is %u and should be %u", - g_value_get_uint (&value), day); - - /* Test 4: Test 28/02/1981 */ - year = 1981; - month = 2; - day = 28; - hildon_date_editor_set_date (date_editor, year, month, 1); - g_value_unset (&value); - g_value_init (&value, G_TYPE_UINT); - hildon_date_editor_set_day (date_editor, day); - g_object_get_property (G_OBJECT (date_editor), "day", &value); - fail_if (g_value_get_uint (&value) != day, - "hildon-date-editor: The returned day is %u and should be %u", - g_value_get_uint (&value), day); - - /* Test 5: Test 1/02/1980 */ - year = 1980; - month = 2; - day = 1; - hildon_date_editor_set_date (date_editor, year, month, 10); - g_value_unset (&value); - g_value_init (&value, G_TYPE_UINT); - hildon_date_editor_set_day (date_editor, day); - g_object_get_property (G_OBJECT (date_editor), "day", &value); - fail_if (g_value_get_uint (&value) != day, - "hildon-date-editor: The returned day is %u and should be %u", - g_value_get_uint (&value), day); -} -END_TEST - -/* ---------- Suite creation ---------- */ - -Suite *create_hildon_date_editor_suite(void) -{ - /* Create the suite */ - Suite *s = suite_create("HildonDateEditor"); - - /* Create test cases */ - TCase *tc1 = tcase_create("set_date"); - TCase *tc2 = tcase_create("get_date"); - TCase *tc3 = tcase_create("get_year"); - TCase *tc4 = tcase_create("set_year"); - TCase *tc5 = tcase_create("get_month"); - TCase *tc6 = tcase_create("set_month"); - TCase *tc7 = tcase_create("get_day"); - TCase *tc8 = tcase_create("set_day"); - - /* Create test case for set_date and add it to the suite */ - tcase_add_checked_fixture(tc1, fx_setup_default_date_editor, fx_teardown_default_date_editor); - tcase_add_test(tc1, test_set_date_regular); - tcase_add_test(tc1, test_set_date_limits); - tcase_add_test(tc1, test_set_date_invalid); - suite_add_tcase (s, tc1); - - /* Create test case for get_date and add it to the suite */ - tcase_add_checked_fixture(tc2, fx_setup_default_date_editor, fx_teardown_default_date_editor); - tcase_add_test(tc2, test_get_date_regular); - tcase_add_test(tc2, test_get_date_invalid); - suite_add_tcase (s, tc2); - - /* Create test case for get_year and add it to the suite */ - tcase_add_checked_fixture(tc3, fx_setup_default_date_editor, fx_teardown_default_date_editor); - tcase_add_test(tc3, test_get_year_regular); - tcase_add_test(tc3, test_get_year_limits); - tcase_add_test(tc3, test_get_year_invalid); - suite_add_tcase (s, tc3); - - /* Create test case for set_year and add it to the suite */ - tcase_add_checked_fixture(tc4, fx_setup_default_date_editor, fx_teardown_default_date_editor); - tcase_add_test(tc4, test_set_year_regular); - tcase_add_test(tc4, test_set_year_limits); - suite_add_tcase (s, tc4); - - /* Create test case for get_month and add it to the suite */ - tcase_add_checked_fixture(tc5, fx_setup_default_date_editor, fx_teardown_default_date_editor); - tcase_add_test(tc5, test_get_month_regular); - tcase_add_test(tc5, test_get_month_limits); - tcase_add_test(tc5, test_get_month_invalid); - suite_add_tcase (s, tc5); - - /* Create test case for set_month and add it to the suite */ - tcase_add_checked_fixture(tc6, fx_setup_default_date_editor, fx_teardown_default_date_editor); - tcase_add_test(tc6, test_set_month_regular); - tcase_add_test(tc6, test_set_month_limits); - suite_add_tcase (s, tc6); - - /* Create test case for get_day and add it to the suite */ - tcase_add_checked_fixture(tc7, fx_setup_default_date_editor, fx_teardown_default_date_editor); - tcase_add_test(tc7, test_get_day_regular); - tcase_add_test(tc7, test_get_day_limits); - tcase_add_test(tc7, test_get_day_invalid); - suite_add_tcase (s, tc7); - - /* Create test case for set_day and add it to the suite */ - tcase_add_checked_fixture(tc8, fx_setup_default_date_editor, fx_teardown_default_date_editor); - tcase_add_test(tc8, test_set_day_regular); - tcase_add_test(tc8, test_set_day_limits); - suite_add_tcase (s, tc8); - - /* Return created suite */ - return s; -} diff --git a/tests/check-hildon-font-selection-dialog.c b/tests/check-hildon-font-selection-dialog.c deleted file mode 100644 index c71915a..0000000 --- a/tests/check-hildon-font-selection-dialog.c +++ /dev/null @@ -1,478 +0,0 @@ -/* - * This file is a part of hildon tests - * - * Copyright (C) 2006, 2007 Nokia Corporation, all rights reserved. - * - * Contact: Michael Dominic Kostrzewa <michael.kostrzewa@nokia.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; version 2.1 of - * the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA - * - */ - -#include <stdlib.h> -#include <check.h> -#include <gtk/gtkmain.h> -#include <glib/gprintf.h> -#include <string.h> -#include "test_suites.h" -#include "check_utils.h" - -#include <hildon/hildon-font-selection-dialog.h> - -#define PREVIEW_TEXT TEST_STRING -#define DEFAULT_FONT_FAMILY "Sans" - -static const guint16 N_FONT_SIZES = 7; -static const guint16 FONT_SIZES[] = - { - 6, 8, 10, 12, 16, 24, 32 - }; - -/* -------------------- Fixtures -------------------- */ - -static HildonFontSelectionDialog *font_selection_dialog = NULL; -static GtkWidget *showed_window = NULL; - -static void -fx_setup_default_font_selection_dialog () -{ - int argc = 0; - gtk_init(&argc, NULL); - - showed_window = create_test_window(); - - - font_selection_dialog = HILDON_FONT_SELECTION_DIALOG(hildon_font_selection_dialog_new(GTK_WINDOW(showed_window), "Font setup")); - - /* Check font selection dialog object has been created properly */ - fail_if(!HILDON_IS_FONT_SELECTION_DIALOG(font_selection_dialog), - "hildon-font-selection-dialog: Creation failed."); - - show_test_window(GTK_WIDGET(showed_window)); - - show_test_window(GTK_WIDGET(font_selection_dialog)); - -} - -static void -fx_teardown_default_font_selection_dialog () -{ - - gtk_widget_destroy(GTK_WIDGET(font_selection_dialog)); - - gtk_widget_destroy(GTK_WIDGET(showed_window)); - -} - -/* -------------------- Helpers -------------------- */ - -static int -helper_cmp_families(const void *a, const void *b) -{ - const char *a_name = - pango_font_family_get_name(*(PangoFontFamily **) a); - const char *b_name = - pango_font_family_get_name(*(PangoFontFamily **) b); - - return g_utf8_collate(a_name, b_name); -} - -static void -helper_get_available_fonts(HildonFontSelectionDialog *fsd, - PangoFontFamily ***families, - gint *n_families) - -{ - pango_context_list_families(gtk_widget_get_pango_context(GTK_WIDGET(fsd)), - families, - n_families); - - qsort(*families, *n_families, sizeof(PangoFontFamily *), helper_cmp_families); -} - -/* -------------------- Test cases -------------------- */ - -/* ----- Test case for set/get_preview_text ----- */ - -/** - * Purpose: Check set and get of a valid preview text - * Cases considered: - * - Set and get of a preview text - */ -START_TEST (test_set_get_preview_text_regular) -{ - gchar *ret_preview_text; - - /* Test1: set and get a preview text */ - hildon_font_selection_dialog_set_preview_text(font_selection_dialog, PREVIEW_TEXT); - ret_preview_text = hildon_font_selection_dialog_get_preview_text(font_selection_dialog); - fail_if(strcmp(PREVIEW_TEXT, ret_preview_text) != 0, - "hildon-font-selection-dialog: Called set_previex_text with \"%s\", but get_preview_text returned \"%s\"", - PREVIEW_TEXT, ret_preview_text); - g_free(ret_preview_text); -} -END_TEST - -/** - * Purpose: Check handling of invalid values - * Cases considered: - * - Set empty preview text - * - Set a NULL preview text - * - Set with NULL object - * - Set with NULL object - */ -START_TEST (test_set_get_preview_text_invalid) -{ - gchar *ret_preview_text; - - /* Test1: Set a NULL preview text */ - hildon_font_selection_dialog_set_preview_text(font_selection_dialog, NULL); - ret_preview_text = hildon_font_selection_dialog_get_preview_text(font_selection_dialog); - fail_if(ret_preview_text == NULL, - "hildon-font-selection-dialog: Call to set_preview_text with a NULL text is allowed"); - g_free(ret_preview_text); - - /* Test2: Set an empty preview text */ - hildon_font_selection_dialog_set_preview_text(font_selection_dialog, ""); - ret_preview_text = hildon_font_selection_dialog_get_preview_text(font_selection_dialog); - fail_if(strcmp("", ret_preview_text) != 0, - "hildon-font-selection-dialog: Call to set_preview_text with an empty text is allowed"); - g_free(ret_preview_text); - - /* Test3: Set with NULL object */ - hildon_font_selection_dialog_set_preview_text(NULL, PREVIEW_TEXT); - - /* Test4: Get with NULL object */ - hildon_font_selection_dialog_get_preview_text(NULL); -} -END_TEST - -/* ----- Test case for set/get property "family" ----- */ - -/** - * Purpose: Check handling of regular values - * Cases considered: - * - Set and get a font from the middle of the available fonts list - */ -START_TEST (test_set_get_property_family_regular) -{ - PangoFontFamily **families; - gint n_families; - GValue value = {0,}; - GValue ret_value = {0,}; - - helper_get_available_fonts(font_selection_dialog, &families, &n_families); - fail_if (n_families <= 0, "hildon-font-selection-dialog: No available fonts"); - - /* Test1: set and get a font family */ - g_value_init(&value, G_TYPE_STRING); - g_value_init(&ret_value, G_TYPE_STRING); - g_value_set_string(&value, pango_font_family_get_name(families[n_families/2])); - g_object_set_property(G_OBJECT(font_selection_dialog), "family", &value); - g_object_get_property(G_OBJECT(font_selection_dialog), "family", &ret_value); - fail_if(strcmp(g_value_get_string(&value), g_value_get_string(&ret_value)) != 0, - "hildon-font-selection-dialog: set property \"family\" to value \"%s\", but get property returned value \"%s\"", - g_value_get_string(&value), g_value_get_string(&ret_value)); -} -END_TEST - -/** - * Purpose: Check handling of limit values - * Cases considered: - * - Set and get first font of the available fonts list - * - Set and get last font of the available fonts list - */ -START_TEST (test_set_get_property_family_limits) -{ - PangoFontFamily **families; - gint n_families; - GValue value = {0,}; - GValue ret_value = {0,}; - - helper_get_available_fonts(font_selection_dialog, &families, &n_families); - fail_if (n_families <= 0, "hildon-font-selection-dialog: No available fonts"); - - /* Test1: Test first font in the list */ - g_value_init(&value, G_TYPE_STRING); - g_value_init(&ret_value, G_TYPE_STRING); - g_value_set_string(&value, pango_font_family_get_name(families[0])); - g_object_set_property(G_OBJECT(font_selection_dialog), "family", &value); - g_object_get_property(G_OBJECT(font_selection_dialog), "family", &ret_value); - fail_if(strcmp(g_value_get_string(&value), g_value_get_string(&ret_value)) != 0, - "hildon-font-selection-dialog: set property \"family\" to value \"%s\", but get property returned value \"%s\"", - g_value_get_string(&value), g_value_get_string(&ret_value)); - - /* Test2: Test last font in the list */ - g_value_set_string(&value, pango_font_family_get_name(families[n_families-1])); - g_object_set_property(G_OBJECT(font_selection_dialog), "family", &value); - g_object_get_property(G_OBJECT(font_selection_dialog), "family", &ret_value); - fail_if(strcmp(g_value_get_string(&value), g_value_get_string(&ret_value)) != 0, - "hildon-font-selection-dialog: set property \"family\" to value \"%s\", but get property returned value \"%s\"", - g_value_get_string(&value), g_value_get_string(&ret_value)); -} -END_TEST - -/** - * Purpose: Check handling of invalid values - * Cases considered: - * - Set a non existing font - * - Set a NULL font - */ -START_TEST (test_set_get_property_family_invalid) -{ - GValue value = {0,}; - GValue ret_value = {0,}; - - /* Test1: Set non existing font */ - g_value_init(&value, G_TYPE_STRING); - g_value_init(&ret_value, G_TYPE_STRING); - g_value_set_string(&value, "-- invalid font name --"); - g_object_set_property(G_OBJECT(font_selection_dialog), "family", &value); - g_object_get_property(G_OBJECT(font_selection_dialog), "family", &ret_value); - fail_if(strcmp(DEFAULT_FONT_FAMILY, g_value_get_string(&ret_value)) != 0, - "hildon-font-selection-dialog: set property \"family\" to invalid font name \"%s\", but get property returned value \"%s\" instead of \"%s\"", - g_value_get_string(&value), g_value_get_string(&ret_value), DEFAULT_FONT_FAMILY); - - /* Test2: Set NULL font */ - g_value_reset (&ret_value); - g_value_reset (&value); - g_value_set_string(&value, NULL); - g_object_set_property(G_OBJECT(font_selection_dialog), "family", &value); - g_object_get_property(G_OBJECT(font_selection_dialog), "family", &ret_value); - fail_if(strcmp(DEFAULT_FONT_FAMILY, g_value_get_string(&ret_value)) != 0, - "hildon-font-selection-dialog: set property \"family\" to NULL, but get property returned value \"%s\" instead of \"%s\"", - g_value_get_string(&ret_value), DEFAULT_FONT_FAMILY); -} -END_TEST - -/* ----- Test case for set/get property "family-set" ----- */ - -/** - * Purpose: Check set and get of valid values - * Cases considered: - * - Get returns FALSE when no font is selected. - * - Get returns TRUE when a font has been selected. - * - Set and get of value TRUE once a font has been selected - * - Set and get of value FALSE - */ -START_TEST (test_set_get_property_family_set_regular) -{ - PangoFontFamily **families; - gint n_families; - GValue value = {0,}; - GValue ret_value = {0,}; - GValue family_value = {0,}; - - helper_get_available_fonts(font_selection_dialog, &families, &n_families); - fail_if (n_families <= 0, "hildon-font-selection-dialog: No available fonts"); - - g_value_init(&value, G_TYPE_BOOLEAN); - g_value_init(&ret_value, G_TYPE_BOOLEAN); - g_value_init(&family_value, G_TYPE_STRING); - - /* Test1: Check get value returns FALSE when no font is selected */ - g_object_get_property(G_OBJECT(font_selection_dialog), "family-set", &ret_value); - if (g_value_get_boolean(&ret_value) == FALSE) - { - g_object_get_property(G_OBJECT(font_selection_dialog), "family", &family_value); - fail_if(strcmp(DEFAULT_FONT_FAMILY, g_value_get_string(&family_value)) != 0, - "hildon-font-selection-dialog: After dialog creation, get value of property \"family-set\" returns FALSE, but get value of property \"family\" is \"%s\" instead of \"%s\"", - g_value_get_string(&family_value), DEFAULT_FONT_FAMILY); - } - - /* Test2: Check get value returns TRUE when a font has been selected */ - g_value_set_string(&family_value, pango_font_family_get_name(families[0])); - g_object_set_property(G_OBJECT(font_selection_dialog), "family", &family_value); - g_object_get_property(G_OBJECT(font_selection_dialog), "family-set", &ret_value); - fail_if(g_value_get_boolean(&ret_value) != TRUE, - "hildon-font-selection-dialog: Set a valid font for property \"family\", but get property \"family-set\" returned FALSE"); - - /* Test3: Check set value to TRUE */ - g_value_set_boolean(&value, TRUE); - g_object_get_property(G_OBJECT(font_selection_dialog), "family-set", &ret_value); - fail_if(g_value_get_boolean(&ret_value) != TRUE, - "hildon-font-selection-dialog: Set property \"family-set\" to TRUE once a valid font has been selected, but get_property returned FALSE"); - - /* Test4: Check set value to FALSE */ - g_value_set_boolean(&value, FALSE); - g_object_set_property(G_OBJECT(font_selection_dialog), "family-set", &value); - g_object_get_property(G_OBJECT(font_selection_dialog), "family-set", &ret_value); - fail_if(g_value_get_boolean(&value) != g_value_get_boolean(&ret_value), - "hildon-font-selection-dialog: Set property \"family-set\" to FALSE, but get_property returned TRUE"); - g_object_get_property(G_OBJECT(font_selection_dialog), "family", &family_value); - fail_if(strcmp(DEFAULT_FONT_FAMILY, g_value_get_string(&family_value)) != 0, - "hildon-font-selection-dialog: Set property \"family-set\" to FALSE, but get of propery \"family\" returns \"%s\" instead of \"%s\"", - g_value_get_string(&family_value), DEFAULT_FONT_FAMILY); -} -END_TEST - -/* ----- Test case for set/get property "size" ----- */ - -/** - * Purpose: Check set and get of valid values - * Cases considered: - * - Set a font size from the middle of the available sizes list - */ -START_TEST (test_set_get_property_size_regular) -{ - gint font_size; - GValue value = {0,}; - GValue ret_value = {0,}; - - g_value_init(&value, G_TYPE_INT); - g_value_init(&ret_value, G_TYPE_INT); - - /* Test1: set a valid font size */ - font_size = FONT_SIZES[N_FONT_SIZES/2]; - g_value_set_int(&value, font_size); - g_object_set_property(G_OBJECT(font_selection_dialog), "size", &value); - g_object_get_property(G_OBJECT(font_selection_dialog), "size", &ret_value); - fail_if(g_value_get_int(&ret_value) != font_size, - "hildon-font-selection-dialog: Set property \"size\" to %d, but get property returned \"%d\"", - font_size, g_value_get_int(&ret_value)); -} -END_TEST - -/** - * Purpose: Check set and get of limit values - * Cases considered: - * - Set first font size in the available sizes list - * - Set last font size in the available sizes list - */ -START_TEST (test_set_get_property_size_limits) -{ - gint font_size; - GValue value = {0,}; - GValue ret_value = {0,}; - - g_value_init(&value, G_TYPE_INT); - g_value_init(&ret_value, G_TYPE_INT); - - /* Test1: set first font size */ - font_size = FONT_SIZES[0]; - g_value_set_int(&value, font_size); - g_object_set_property(G_OBJECT(font_selection_dialog), "size", &value); - g_object_get_property(G_OBJECT(font_selection_dialog), "size", &ret_value); - fail_if(g_value_get_int(&ret_value) != font_size, - "hildon-font-selection-dialog: Set property \"size\" to %d, but get property returned \"%d\"", - font_size, g_value_get_int(&ret_value)); - - /* Test2: set last font size */ - font_size = FONT_SIZES[N_FONT_SIZES-1]; - g_value_set_int(&value, font_size); - g_object_set_property(G_OBJECT(font_selection_dialog), "size", &value); - g_object_get_property(G_OBJECT(font_selection_dialog), "size", &ret_value); - fail_if(g_value_get_int(&ret_value) != font_size, - "hildon-font-selection-dialog: Set property \"size\" to %d, but get property returned \"%d\"", - font_size, g_value_get_int(&ret_value)); -} -END_TEST - -/** - * Purpose: Check set and get of invalid values - * Cases considered: - * - Set negative size - * - Set a positive size that is not in the available sizes list - * - Set a positive size over the maximum allowed for the property - */ -START_TEST (test_set_get_property_size_invalid) -{ - gint font_size; - gint default_size; - GValue value = {0,}; - GValue ret_value = {0,}; - - g_value_init(&value, G_TYPE_INT); - g_value_init(&ret_value, G_TYPE_INT); - - default_size = 8; - g_value_set_int(&value, default_size); - g_object_set_property(G_OBJECT(font_selection_dialog), "size", &value); - - /* Test1: Set negative value */ - font_size = -5; - g_value_set_int(&value, font_size); - g_object_set_property(G_OBJECT(font_selection_dialog), "size", &value); - g_object_get_property(G_OBJECT(font_selection_dialog), "size", &ret_value); - fail_if(g_value_get_int(&ret_value) != default_size, - "hildon-font-selection-dialog: Set property \"size\" to invalid %d, but get property returned \"%d\" instead of previous valid value \"%d\"", - font_size, g_value_get_int(&ret_value), default_size); - - /* Test2: Set a positive that is not in the available list */ - font_size = 17; - g_value_set_int(&value, font_size); - g_object_set_property(G_OBJECT(font_selection_dialog), "size", &value); - g_object_get_property(G_OBJECT(font_selection_dialog), "size", &ret_value); - fail_if(g_value_get_int(&ret_value) != default_size, - "hildon-font-selection-dialog: Set property \"size\" to invalid %d, but get property returned \"%d\" instead of previous valid value \"%d\"", - font_size, g_value_get_int(&ret_value), default_size); - - /* Test3: Set a positive value over the maximum allowed */ - font_size = 112; - g_value_set_int(&value, font_size); - g_object_set_property(G_OBJECT(font_selection_dialog), "size", &value); - g_object_get_property(G_OBJECT(font_selection_dialog), "size", &ret_value); - fail_if(g_value_get_int(&ret_value) != default_size, - "hildon-font-selection-dialog: Set property \"size\" to invalid %d, but get property returned \"%d\" instead of previous valid value \"%d\"", - font_size, g_value_get_int(&ret_value), default_size); -} -END_TEST - -/* ---------- Suite creation ---------- */ - -Suite *create_hildon_font_selection_dialog_suite() -{ - /* Create the suite */ - Suite *s = suite_create("HildonFontSelectionDialog"); - - /* Create test cases */ - TCase *tc1 = tcase_create("set_get_preview_text"); - TCase *tc2 = tcase_create("set_get_property_family"); - TCase *tc3 = tcase_create("set_get_property_family_set"); - TCase *tc4 = tcase_create("set_get_property_size"); - - /* Create test case for set/get_preview_text and add it to the suite */ - tcase_add_checked_fixture(tc1, fx_setup_default_font_selection_dialog, - fx_teardown_default_font_selection_dialog); - tcase_add_test(tc1, test_set_get_preview_text_regular); - tcase_add_test(tc1, test_set_get_preview_text_invalid); - suite_add_tcase(s, tc1); - - /* Create test case for set/get property "family" and add it to the suite */ - tcase_add_checked_fixture(tc2, fx_setup_default_font_selection_dialog, - fx_teardown_default_font_selection_dialog); - tcase_add_test(tc2, test_set_get_property_family_regular); - tcase_add_test(tc2, test_set_get_property_family_limits); - tcase_add_test(tc2, test_set_get_property_family_invalid); - suite_add_tcase(s, tc2); - - /* Create test case for set/get property "family-set" and add it to the suite */ - tcase_add_checked_fixture(tc3, fx_setup_default_font_selection_dialog, - fx_teardown_default_font_selection_dialog); - tcase_add_test(tc3, test_set_get_property_family_set_regular); - suite_add_tcase(s, tc3); - - /* Create test case for set/get property "size" and add it to the suite */ - tcase_add_checked_fixture(tc4, fx_setup_default_font_selection_dialog, - fx_teardown_default_font_selection_dialog); - tcase_add_test(tc4, test_set_get_property_size_regular); - tcase_add_test(tc4, test_set_get_property_size_limits); - tcase_add_test(tc4, test_set_get_property_size_invalid); - suite_add_tcase(s, tc4); - - /* Return created suite */ - return s; -} diff --git a/tests/check-hildon-get-password-dialog.c b/tests/check-hildon-get-password-dialog.c deleted file mode 100644 index 8349b1e..0000000 --- a/tests/check-hildon-get-password-dialog.c +++ /dev/null @@ -1,465 +0,0 @@ -/* - * This file is a part of hildon tests - * - * Copyright (C) 2006, 2007 Nokia Corporation, all rights reserved. - * - * Contact: Michael Dominic Kostrzewa <michael.kostrzewa@nokia.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; version 2.1 of - * the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA - * - */ - -#include <stdlib.h> -#include <string.h> -#include <check.h> -#include <gtk/gtkmain.h> -#include "test_suites.h" -#include "check_utils.h" -#include <hildon/hildon-get-password-dialog.h> - -/* -------------------- Fixtures -------------------- */ - -static HildonGetPasswordDialog *get_password_dialog = NULL; -static GtkWindow * gpd_window = NULL; - -static void -fx_setup_default_get_password_dialog () -{ - int argc = 0; - - gtk_init(&argc, NULL); - - gpd_window = GTK_WINDOW(create_test_window()); - - /* Check the auxiliary window is being created properly */ - fail_if (!GTK_IS_WINDOW (gpd_window), - "hildon-get-password-dialog: Window creation failed."); - - get_password_dialog = HILDON_GET_PASSWORD_DIALOG(hildon_get_password_dialog_new(gpd_window, TRUE)); - /* Check get password dialog object has been created properly */ - fail_if(!HILDON_IS_GET_PASSWORD_DIALOG (get_password_dialog), - "hildon-get-password-dialog: Creation failed."); - - show_test_window(GTK_WIDGET(gpd_window)); - - show_test_window(GTK_WIDGET(get_password_dialog)); - -} - -static void -fx_teardown_default_get_password_dialog () -{ - gtk_widget_destroy(GTK_WIDGET(get_password_dialog)); - - gtk_widget_destroy(GTK_WIDGET(gpd_window)); -} - -/* -------------------- Test cases -------------------- */ - -/* ----- Test case for hildon_get_password_dialog_new_with_default -----*/ - -/** - * Purpose: Check that regular password values are set and get properly. - * Cases considered: - * - Create new get password dialog with "test_password" password by default. - * - Create new get password dialog with "" password by default. - * - Create new get password dialog with "1234567890" password by default. - * - Create new get password dialog with TEST_STRING password by default - */ -START_TEST (test_new_with_default_regular) -{ - const gchar * default_password=NULL; - const gchar * ret_password; - HildonGetPasswordDialog * default_get_password_dialog; - - /* Test 1: Create new dialog with password "test_password" by default */ - default_password="test_password"; - default_get_password_dialog = - HILDON_GET_PASSWORD_DIALOG(hildon_get_password_dialog_new_with_default(gpd_window,default_password,FALSE)); - fail_if (!HILDON_IS_GET_PASSWORD_DIALOG(default_get_password_dialog), - "hildon-get-password-dialog: Creation failed with hildon_get_password_dialog_new_with_default"); - - ret_password = hildon_get_password_dialog_get_password(default_get_password_dialog); - fail_if (strcmp (default_password,ret_password) != 0, - "hildon-get-password-dialog: Default password and returned password are diferent (%s,%s)",default_password,ret_password); - gtk_widget_destroy(GTK_WIDGET(default_get_password_dialog)); - - /* Test 2: Create new dialog with password "" by default */ - default_password=""; - default_get_password_dialog = - HILDON_GET_PASSWORD_DIALOG(hildon_get_password_dialog_new_with_default(gpd_window,default_password,FALSE)); - fail_if(!HILDON_IS_GET_PASSWORD_DIALOG(default_get_password_dialog), - "hildon-get-password-dialog: Creation failed with hildon_get_password_dialog_new_with_default"); - - ret_password = hildon_get_password_dialog_get_password(default_get_password_dialog); - fail_if (strcmp (default_password,ret_password) != 0, - "hildon-get-password-dialog: Default password and returned password are diferent (%s,%s)",default_password,ret_password); - - gtk_widget_destroy(GTK_WIDGET(default_get_password_dialog)); - - /* Test 3: Create new dialog with password "1234567890" by default */ - default_password="1234567890"; - - default_get_password_dialog = - HILDON_GET_PASSWORD_DIALOG(hildon_get_password_dialog_new_with_default(gpd_window,default_password,FALSE)); - fail_if(!HILDON_IS_GET_PASSWORD_DIALOG(default_get_password_dialog), - "hildon-get-password-dialog: Creation failed with hildon_get_password_dialog_new_with_default"); - - ret_password = hildon_get_password_dialog_get_password(default_get_password_dialog); - fail_if(strcmp (default_password,ret_password)!=0, - "hildon-get-password-dialog: Default password and returned password are diferent (%s,%s)",default_password,ret_password); - - gtk_widget_destroy(GTK_WIDGET(default_get_password_dialog)); - - /* Test 4: Create new dialog with password TEST_STRING by default */ - default_password=TEST_STRING; - - default_get_password_dialog = - HILDON_GET_PASSWORD_DIALOG(hildon_get_password_dialog_new_with_default(gpd_window,default_password,FALSE)); - fail_if(!HILDON_IS_GET_PASSWORD_DIALOG(default_get_password_dialog), - "hildon-get-password-dialog: Creation failed with hildon_get_password_dialog_new_with_default"); - - ret_password = hildon_get_password_dialog_get_password(default_get_password_dialog); - fail_if (strcmp (default_password,ret_password) != 0, - "hildon-get-password-dialog: Default password and returned password are diferent (%s,%s)",default_password,ret_password); - - gtk_widget_destroy(GTK_WIDGET(default_get_password_dialog)); -} -END_TEST - -/** - * Purpose: Check that invalid password values are set and get properly. - * Cases considered: - * - Create new NULL get password dialog. - * - Create new dialog with NULL window by default - */ -START_TEST (test_new_with_default_invalid) -{ - const gchar * default_password=""; - const gchar * ret_password; - HildonGetPasswordDialog * default_get_password_dialog; - - /* Check get password dialog object has been created properly */ - fail_if(!HILDON_IS_GET_PASSWORD_DIALOG (get_password_dialog), - "hildon-get-password-dialog: Creation failed."); - fail_if (!GTK_IS_WINDOW (gpd_window), - "hildon-get-password-dialog: Window creation failed."); - - /* Test 1: Create new dialog with NULL password by default */ - default_password=NULL; - default_get_password_dialog = - HILDON_GET_PASSWORD_DIALOG(hildon_get_password_dialog_new_with_default(gpd_window,default_password,FALSE)); - fail_if(!HILDON_IS_GET_PASSWORD_DIALOG(default_get_password_dialog), - "hildon-get-password-dialog: Creation failed with hildon_get_password_dialog_new_with_default"); - - ret_password = hildon_get_password_dialog_get_password(default_get_password_dialog); - fail_if(strcmp ("",ret_password) != 0, - "hildon-get-password-dialog: Error setting null password. Returned password is \"%s\"",ret_password); - - gtk_widget_destroy(GTK_WIDGET(default_get_password_dialog)); - - /* Test 2: Create new dialog with NULL window by default */ - default_get_password_dialog = - HILDON_GET_PASSWORD_DIALOG(hildon_get_password_dialog_new_with_default(NULL,default_password,FALSE)); - fail_if(!HILDON_IS_GET_PASSWORD_DIALOG(default_get_password_dialog), - "hildon-get-password-dialog: Creation failed with hildon_get_password_dialog_new_with_default"); - - ret_password = hildon_get_password_dialog_get_password(default_get_password_dialog); - fail_if (ret_password == NULL, - "hildon-get-password-dialog: Default password and returned password are diferent (%s,%s)",default_password,ret_password); - - gtk_widget_destroy(GTK_WIDGET(default_get_password_dialog)); -} -END_TEST - -/** - * Purpose: Check that regular "max characters" values are set and get properly. - * Cases considered: - * - Set max characters to 10. - * - Set max characters to G_MAXUINT16+1. - * - */ -START_TEST (test_set_max_characters_regular) -{ - gint max_chars; - gint ret_max_chars; - GValue value={0, }; - - /* Check get password dialog object has been created properly */ - fail_if(!HILDON_IS_GET_PASSWORD_DIALOG (get_password_dialog), - "hildon-get-password-dialog: Creation failed."); - fail_if (!GTK_IS_WINDOW (gpd_window), - "hildon-get-password-dialog: Window creation failed."); - - g_value_init (&value, G_TYPE_INT); - - /* Test 1: Set max characters to 10 */ - max_chars = 10; - hildon_get_password_dialog_set_max_characters(get_password_dialog,max_chars); - g_object_get_property(G_OBJECT (get_password_dialog),"max-characters",&value); - ret_max_chars = g_value_get_int (&value); - - fail_if(ret_max_chars!=max_chars, - "hildon-get-password-dialog: Set %i max chars incorrect. Return value is %i",max_chars,ret_max_chars); - - g_value_unset (&value); - - /* Test 2: Set max characters to G_MAXUINT16+1 */ - g_value_init (&value, G_TYPE_INT); - max_chars = G_MAXUINT16+1; - hildon_get_password_dialog_set_max_characters(get_password_dialog,max_chars); - g_object_get_property(G_OBJECT (get_password_dialog),"max-characters",&value); - ret_max_chars = g_value_get_int (&value); - - fail_if(ret_max_chars!=G_MAXUINT16, - "hildon-get-password-dialog: Set %i max chars incorrect. Return value is %i",max_chars,ret_max_chars); - - g_value_unset (&value); -} -END_TEST - -/** - * Purpose: Check that limits "max characters" values are set and get properly. - * Cases considered: - * - Set max characters to 1. - * - Set max characters to G_MAXINT. - */ -START_TEST (test_set_max_characters_limits) -{ - gint max_chars; - gint ret_max_chars; - GValue value={0, }; - - /* Check get password dialog object has been created properly */ - fail_if(!HILDON_IS_GET_PASSWORD_DIALOG (get_password_dialog), - "hildon-get-password-dialog: Creation failed."); - fail_if (!GTK_IS_WINDOW (gpd_window), - "hildon-get-password-dialog: Window creation failed."); - - g_value_init (&value, G_TYPE_INT); - - /* Test 1: Set max characters to 1 */ - max_chars = 1; - hildon_get_password_dialog_set_max_characters(get_password_dialog,max_chars); - g_object_get_property(G_OBJECT (get_password_dialog),"max-characters",&value); - ret_max_chars = g_value_get_int (&value); - - fail_if(ret_max_chars!=max_chars, - "hildon-get-password-dialog: Set %i max chars incorrect. Return value is %i",max_chars,ret_max_chars); - - g_value_unset (&value); - - /* Test 2: Set max characters to G_MAXINT */ - g_value_init (&value, G_TYPE_INT); - max_chars = G_MAXINT; - hildon_get_password_dialog_set_max_characters(get_password_dialog,max_chars); - g_object_get_property(G_OBJECT (get_password_dialog),"max-characters",&value); - ret_max_chars = g_value_get_int (&value); - - fail_if(ret_max_chars!=G_MAXUINT16, - "hildon-get-password-dialog: Set %i max chars incorrect. Return value is %u",max_chars,ret_max_chars); - - g_value_unset (&value); -} -END_TEST - -/** - * Purpose: Check that limits "max characters" values are set and get properly. - * Cases considered: - * - Set max characters to 0. - * - Set max characters to -1. - * - Set max characters on NULL object. - */ -START_TEST (test_set_max_characters_invalid) -{ - gint max_chars; - gint ret_max_chars; - GValue value={0, }; - - /* Check get password dialog object has been created properly */ - fail_if(!HILDON_IS_GET_PASSWORD_DIALOG (get_password_dialog), - "hildon-get-password-dialog: Creation failed."); - fail_if (!GTK_IS_WINDOW (gpd_window), - "hildon-get-password-dialog: Window creation failed."); - - g_value_init (&value, G_TYPE_INT); - - /* Test 1: Set max characters to 0 */ - max_chars = 0; - hildon_get_password_dialog_set_max_characters(get_password_dialog,max_chars); - g_object_get_property(G_OBJECT (get_password_dialog),"max-characters",&value); - ret_max_chars = g_value_get_int (&value); - - fail_if(ret_max_chars!=max_chars, - "hildon-get-password-dialog: Set %i max chars incorrect. Return value is %i",max_chars,ret_max_chars); - - g_value_unset (&value); - - /* Test 2: Set max characters to -1 */ - g_value_init (&value, G_TYPE_INT); - max_chars = -1; - hildon_get_password_dialog_set_max_characters(get_password_dialog,max_chars); - g_object_get_property(G_OBJECT (get_password_dialog),"max-characters",&value); - ret_max_chars = g_value_get_int (&value); - - fail_if(ret_max_chars!=0, - "hildon-get-password-dialog: Set %i max chars incorrect. Return value is %i and expected is 0",max_chars,ret_max_chars); - g_value_unset (&value); - - /* Test 2: Set max characters on NULL object */ - max_chars = 1; - hildon_get_password_dialog_set_max_characters(NULL,max_chars); -} -END_TEST - -/** - * Purpose: Check that regular password values are get properly. - * Cases considered: - * - Get password "test_password" set by g_object_set_property. - * - Get password "01234567890" set by g_object_set_property. - * - Get password TEST_STRING set by g_object_set_property. - * - Get password "" set by set by g_object_set_property. - */ -START_TEST (test_get_password_regular) -{ - const gchar * default_password="test_password"; - const gchar * ret_password; - GValue value={0, }; - - /* Check get password dialog object has been created properly */ - fail_if(!HILDON_IS_GET_PASSWORD_DIALOG (get_password_dialog), - "hildon-get-password-dialog: Creation failed."); - fail_if (!GTK_IS_WINDOW (gpd_window), - "hildon-get-password-dialog: Window creation failed."); - - /* Test 1: Get password "test_password" set by g_object_set_property. */ - g_value_init (&value, G_TYPE_STRING); - g_value_set_string(&value,default_password); - g_object_set_property(G_OBJECT (get_password_dialog),"password",&value); - g_value_unset (&value); - - ret_password = hildon_get_password_dialog_get_password(get_password_dialog); - fail_if(strcmp (default_password,ret_password)!=0, - "hildon-get-password-dialog: Default password and returned password are diferent (%s,%s)",default_password,ret_password); - - /* Test 2: Get password "01234567890" set by g_object_set_property. */ - default_password = "01234567890"; - - g_value_init (&value, G_TYPE_STRING); - g_value_set_string(&value,default_password); - g_object_set_property(G_OBJECT (get_password_dialog),"password",&value); - g_value_unset (&value); - - ret_password = hildon_get_password_dialog_get_password(get_password_dialog); - fail_if(strcmp (default_password,ret_password)!=0, - "hildon-get-password-dialog: Default password and returned password are diferent (%s,%s)",default_password,ret_password); - - /* Test 3: Get password TEST_STRING set by g_object_set_property. */ - default_password = TEST_STRING; - - g_value_init (&value, G_TYPE_STRING); - g_value_set_string(&value,default_password); - g_object_set_property(G_OBJECT (get_password_dialog),"password",&value); - g_value_unset (&value); - - ret_password = hildon_get_password_dialog_get_password(get_password_dialog); - fail_if(strcmp (default_password,ret_password)!=0, - "hildon-get-password-dialog: Default password and returned password are diferent (%s,%s)",default_password,ret_password); - - /* Test 4: Get password "" set by g_object_set_property. */ - default_password = ""; - - g_value_init (&value, G_TYPE_STRING); - g_value_set_string(&value,default_password); - g_object_set_property(G_OBJECT (get_password_dialog),"password",&value); - g_value_unset (&value); - - ret_password = hildon_get_password_dialog_get_password(get_password_dialog); - fail_if(strcmp (default_password,ret_password)!=0, - "hildon-get-password-dialog: Default password and returned password are diferent (%s,%s)",default_password,ret_password); -} -END_TEST - -/** - * Purpose: Check that limit password values are get properly. - * Cases considered: - * - Get empty password set by g_object_set_property with NULL value. - * - Get password from NULL object. - * - */ -START_TEST (test_get_password_invalid) -{ - const gchar * default_password=NULL; - const gchar * ret_password; - GValue value={0, }; - - /* Check get password dialog object has been created properly */ - fail_if(!HILDON_IS_GET_PASSWORD_DIALOG (get_password_dialog), - "hildon-get-password-dialog: Creation failed."); - fail_if (!GTK_IS_WINDOW (gpd_window), - "hildon-get-password-dialog: Window creation failed."); - - /* Test 1: Get password NULL set by g_object_set_property. */ - default_password = NULL; - g_value_init (&value, G_TYPE_STRING); - g_value_set_string(&value,default_password); - g_object_set_property(G_OBJECT (get_password_dialog),"password",&value); - g_value_unset (&value); - - ret_password = hildon_get_password_dialog_get_password(get_password_dialog); - fail_if(strcmp(ret_password,"")!=0, - "hildon-get-password-dialog: Returned password is not empty (%s)",ret_password); - - /* Test 2: Get password from NULL object. */ - ret_password = hildon_get_password_dialog_get_password(NULL); -} -END_TEST - - -/* ---------- Suite creation ---------- */ -Suite *create_hildon_get_password_dialog_suite() -{ - /* Create the suite */ - Suite *s = suite_create("HildonGetPasswordDialog"); - - /* Create test cases */ - TCase *tc1 = tcase_create("new_with_default"); - TCase *tc2 = tcase_create("set_max_characters"); - TCase *tc3 = tcase_create("get_password"); - - /* Create test case for hildon_get_password_dialog_new_with_default and add it to the suite */ - tcase_add_checked_fixture(tc1, fx_setup_default_get_password_dialog, fx_teardown_default_get_password_dialog); - tcase_add_test(tc1, test_new_with_default_regular); - tcase_add_test(tc1, test_new_with_default_invalid); - suite_add_tcase (s, tc1); - - /* Create test case for hildon_get_password_dialog_set_max_characters and add it to the suite */ - tcase_add_checked_fixture(tc2, fx_setup_default_get_password_dialog, fx_teardown_default_get_password_dialog); - tcase_add_test(tc2, test_set_max_characters_regular); - tcase_add_test(tc2, test_set_max_characters_limits); - tcase_add_test(tc2, test_set_max_characters_invalid); - suite_add_tcase (s, tc2); - - /* Create test case for hildon_get_password_dialog_get_password and add it to the suite */ - tcase_add_checked_fixture(tc3, fx_setup_default_get_password_dialog, fx_teardown_default_get_password_dialog); - tcase_add_test(tc3, test_get_password_regular); - tcase_add_test(tc3, test_get_password_invalid); - suite_add_tcase (s, tc3); - - - /* Return created suite */ - return s; -} diff --git a/tests/check-hildon-note.c b/tests/check-hildon-note.c index 1d4dc47..b03dd6c 100644 --- a/tests/check-hildon-note.c +++ b/tests/check-hildon-note.c @@ -201,8 +201,8 @@ START_TEST (test_new_information_regular) g_object_get_property(G_OBJECT (note),"note_type",&enum_value); note_type = g_value_get_int(&enum_value); - fail_if( note_type != HILDON_NOTE_TYPE_INFORMATION_THEME, - "hildon-note: Type was not set property on creation (HILDON_NOTE_TYPE_INFORMATION_THEME)",note_type); + fail_if( note_type != HILDON_NOTE_TYPE_INFORMATION, + "hildon-note: Type was not set property on creation (HILDON_NOTE_TYPE_INFORMATION)",note_type); gtk_widget_destroy (GTK_WIDGET (note)); note=NULL; @@ -221,8 +221,8 @@ START_TEST (test_new_information_regular) g_object_get_property(G_OBJECT (note),"note_type",&enum_value); note_type = g_value_get_int(&enum_value); - fail_if( note_type != HILDON_NOTE_TYPE_INFORMATION_THEME, - "hildon-note: Type was not set property on creation (HILDON_NOTE_TYPE_INFORMATION_THEME)",note_type); + fail_if( note_type != HILDON_NOTE_TYPE_INFORMATION, + "hildon-note: Type was not set property on creation (HILDON_NOTE_TYPE_INFORMATION)",note_type); gtk_widget_destroy (GTK_WIDGET (note)); note=NULL; @@ -264,8 +264,8 @@ START_TEST (test_new_information_invalid) g_object_get_property(G_OBJECT (invalid_note),"note_type",&enum_value); note_type = g_value_get_int(&enum_value); - fail_if( note_type != HILDON_NOTE_TYPE_INFORMATION_THEME, - "hildon-note: Type was not set property on creation (HILDON_NOTE_TYPE_INFORMATION_THEME)",note_type); + fail_if( note_type != HILDON_NOTE_TYPE_INFORMATION, + "hildon-note: Type was not set property on creation (HILDON_NOTE_TYPE_INFORMATION)",note_type); gtk_widget_destroy (GTK_WIDGET (invalid_note)); invalid_note=NULL; @@ -280,149 +280,6 @@ START_TEST (test_new_information_invalid) } END_TEST -#ifndef HILDON_DISABLE_DEPRECATED -/* ----- Test case for new_confirmation_with_icon_name -----*/ -/** - * Purpose: Check that note dialog is properly created with description regular values. - * Cases considered: - * - Create new confirmation note with description set to TEST_STRING and icon name "control_calibration_target". - * - Create new confirmation note with description set to "" and icon name NULL. - * - */ -START_TEST (test_new_confirmation_with_icon_name_regular) -{ - const gchar * description = NULL; - const gchar * ret_description = NULL; - const gchar *icon_name = NULL; - const gchar * ret_icon_name = NULL; - GValue value={0, }; - GValue icon_name_value={0, }; - GValue enum_value={0, }; - HildonNoteType note_type; - - g_value_init (&value, G_TYPE_STRING); - g_value_init (&icon_name_value, G_TYPE_STRING); - g_value_init (&enum_value, G_TYPE_INT); - - /* Test 1: create new confirmation note with description set to TEST_STRING */ - description = TEST_STRING; - icon_name="control_calibration_target"; - note = HILDON_NOTE(hildon_note_new_confirmation_with_icon_name(n_window,description,icon_name)); - fail_if(!HILDON_IS_NOTE(note), - "hildon-note: Creation failed with hildon_note_new_confirmation_with_icon_name"); - - g_object_get_property(G_OBJECT (note),"description",&value); - ret_description = g_value_get_string (&value); - fail_if( strcmp (description,ret_description) != 0, - "hildon-note: Description (%s) was not set properly on creation. Returned description: %s", - description,ret_description); - - g_object_get_property(G_OBJECT (note),"note_type",&enum_value); - note_type = g_value_get_int(&enum_value); - fail_if( note_type != HILDON_NOTE_TYPE_CONFIRMATION, - "hildon-note: Type was not set property on creation (HILDON_NOTE_TYPE_CONFIRMATION)",note_type); - - g_object_get_property(G_OBJECT (note),"icon",&icon_name_value); - ret_icon_name = g_value_get_string (&icon_name_value); - fail_if( strcmp (icon_name,ret_icon_name) != 0, - "hildon-note: icon_name (%s) was not set properly on creation. Returned icon_name: %s", - icon_name,ret_icon_name); - - gtk_widget_destroy (GTK_WIDGET (note)); - note=NULL; - - /* Test 2: create new confirmation note with description set to "" and icon name set to NULL */ - description = ""; - icon_name=NULL; - note = HILDON_NOTE(hildon_note_new_confirmation_with_icon_name(n_window,description,icon_name)); - fail_if(!HILDON_IS_NOTE(note), - "hildon-note: Creation failed with hildon_note_new_confirmation_with_icon_name"); - - g_object_get_property(G_OBJECT (note),"description",&value); - ret_description = g_value_get_string (&value); - fail_if( strcmp (description,ret_description) != 0, - "hildon-note: Description (%s) was not set properly on creation. Returned description: %s", - description,ret_description); - - g_object_get_property(G_OBJECT (note),"note_type",&enum_value); - note_type = g_value_get_int(&enum_value); - fail_if( note_type != HILDON_NOTE_TYPE_CONFIRMATION, - "hildon-note: Type was not set property on creation (HILDON_NOTE_TYPE_CONFIRMATION)",note_type); - - g_object_get_property(G_OBJECT (note),"icon",&icon_name_value); - ret_icon_name = g_value_get_string (&icon_name_value); - fail_if( ret_icon_name != NULL, - "hildon-note: icon_name (%s) was not set properly on creation. Returned icon_name: %s", - icon_name,ret_icon_name); - - gtk_widget_destroy (GTK_WIDGET (note)); - note=NULL; - - g_value_unset(&value); - g_value_unset(&icon_name_value); - g_value_unset(&enum_value); - -} -END_TEST - -/** - * Purpose: Check that note dialog is properly created with description invalid values. - * Cases considered: - * - Create new confirmation note with window set to NULL. - * - Create new confirmation note with description set to "NULL". - * - */ -START_TEST (test_new_confirmation_with_icon_name_invalid) -{ - const gchar * ret_description = NULL; - const gchar * ret_icon_name = NULL; - GValue value={0, }; - GValue enum_value={0, }; - GValue icon_name_value={0, }; - HildonNoteType note_type; - HildonNote * invalid_note; - - g_value_init (&value, G_TYPE_STRING); - g_value_init (&icon_name_value, G_TYPE_STRING); - g_value_init (&enum_value, G_TYPE_INT); - - /* Test 1: create new confirmation note with window set to "NULL" */ - invalid_note = HILDON_NOTE(hildon_note_new_confirmation_with_icon_name(NULL,"","")); - fail_if(!HILDON_IS_NOTE(invalid_note), - "hildon-note: Creation failed with hildon_note_new_confirmation_with_icon_name"); - - g_object_get_property(G_OBJECT (invalid_note),"description",&value); - ret_description = g_value_get_string (&value); - fail_if( strcmp ("",ret_description) != 0, - "hildon-note: Description "" was not set properly on creation. Returned description: %s", - ret_description); - - g_object_get_property(G_OBJECT (invalid_note),"icon",&icon_name_value); - ret_icon_name = g_value_get_string (&icon_name_value); - fail_if( strcmp ("",ret_icon_name) != 0, - "hildon-note: Description "" was not set properly on creation. Returned description: %s", - ret_icon_name); - - g_object_get_property(G_OBJECT (invalid_note),"note_type",&enum_value); - note_type = g_value_get_int(&enum_value); - fail_if( note_type != HILDON_NOTE_TYPE_CONFIRMATION, - "hildon-note: Type was not set property on creation (HILDON_NOTE_TYPE_CONFIRMATION)",note_type); - - gtk_widget_destroy (GTK_WIDGET (invalid_note)); - invalid_note=NULL; - - /* Test 2: create new confirmation note with description set to "NULL" */ - invalid_note = HILDON_NOTE(hildon_note_new_confirmation_with_icon_name(n_window,NULL,"control_calibration_target")); - fail_if(HILDON_IS_NOTE(invalid_note), - "hildon-note: Creation succeeded with hildon_note_new_confirmation_with_icon_name with message == NULL"); - - g_value_unset(&icon_name_value); - g_value_unset(&value); - g_value_unset(&enum_value); -} -END_TEST -#endif - /* ----- Test case for new_cancel_with_progress_bar -----*/ /** @@ -557,9 +414,6 @@ Suite *create_hildon_note_suite() /* Create test cases */ TCase *tc1 = tcase_create("new_confirmation"); -#ifndef HILDON_DISABLE_DEPRECATED - TCase *tc2 = tcase_create("new_confirmation_with_icon_name"); -#endif TCase *tc3 = tcase_create("new_information"); TCase *tc4 = tcase_create("new_cancel_with_progress_bar"); @@ -569,14 +423,6 @@ Suite *create_hildon_note_suite() tcase_add_test(tc1, test_new_confirmation_invalid); suite_add_tcase (s, tc1); -#ifndef HILDON_DISABLE_DEPRECATED - /* Create test case for hildon_note_new_confirmation_with_icon_name and add it to the suite */ - tcase_add_checked_fixture(tc2, fx_setup_default_note, fx_teardown_default_note); - tcase_add_test(tc2, test_new_confirmation_with_icon_name_regular); - tcase_add_test(tc2, test_new_confirmation_with_icon_name_invalid); - suite_add_tcase (s, tc2); -#endif - /* Create test case for hildon_note_new_with_information and add it to the suite */ tcase_add_checked_fixture(tc3, fx_setup_default_note, fx_teardown_default_note); tcase_add_test(tc3, test_new_information_regular); diff --git a/tests/check-hildon-number-editor.c b/tests/check-hildon-number-editor.c deleted file mode 100644 index 994574f..0000000 --- a/tests/check-hildon-number-editor.c +++ /dev/null @@ -1,241 +0,0 @@ -/* - * This file is a part of hildon tests - * - * Copyright (C) 2006, 2007 Nokia Corporation, all rights reserved. - * - * Contact: Michael Dominic Kostrzewa <michael.kostrzewa@nokia.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; version 2.1 of - * the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA - * - */ - -#include <stdlib.h> -#include <check.h> -#include <gtk/gtkmain.h> -#include <glib/gprintf.h> -#include "test_suites.h" -#include "check_utils.h" - -#include <hildon/hildon-number-editor.h> - -/* -------------------- Fixtures -------------------- */ - -static HildonNumberEditor *number_editor = NULL; -static GtkWidget *showed_window = NULL; - -static void -fx_setup_default_number_editor () -{ - int argc = 0; - gtk_init(&argc, NULL); - - number_editor = HILDON_NUMBER_EDITOR(hildon_number_editor_new(0, 100)); - /* Check number_editor object has been created properly */ - fail_if(!HILDON_IS_NUMBER_EDITOR(number_editor), - "hildon-number-editor: Creation failed."); - - showed_window = create_test_window (); - - /* This packs the widget into the window (a gtk container). */ - gtk_container_add (GTK_CONTAINER (showed_window), GTK_WIDGET (number_editor)); - - /* Displays the widget and the window */ - show_all_test_window (showed_window); -} - -static void -fx_teardown_default_number_editor () -{ - gtk_widget_destroy (GTK_WIDGET (number_editor)); -} - -/* -------------------- Test cases -------------------- */ - -/* ----- Test case for set_range -----*/ - -/** - * Purpose: Check that the ranges can be set safely - * Cases considered: - * - Set a number limit of (0, 100) - * - Set a number limit of (1, 100) - * - Set a number limit of (-100, 100) - * - Set a number limit of (-100, 0) - * - Set a number limit of (-100, -1) - */ -START_TEST (test_set_range_regular) -{ - gint number; - - /* Test 1: Set limits to (0, 100) */ - hildon_number_editor_set_range(number_editor, 0, 100); - - hildon_number_editor_set_value(number_editor, 0); - - hildon_number_editor_set_value(number_editor, 101); - number = hildon_number_editor_get_value(number_editor); - fail_if (number != 0, - "hildon-number-editor: range_value failed, we set range: 0/100, we set 0 and then we set the value 101 but we get %d instead of 0", - number); - - /* Test 2: Set limits to (1, 100) */ - hildon_number_editor_set_range(number_editor, 1, 100); - - hildon_number_editor_set_value(number_editor, 1); - - hildon_number_editor_set_value(number_editor, 0); - number = hildon_number_editor_get_value(number_editor); - fail_if (number != 1, - "hildon-number-editor: range_value failed, we set range: 0/100, we set 0 and then we set the value -1 but we get %d instead of 0", - number); - - /* Test 3: Set limits to (-100, 100) */ - hildon_number_editor_set_range(number_editor, -100, 100); - - hildon_number_editor_set_value(number_editor, 0); - - hildon_number_editor_set_value(number_editor, -101); - number = hildon_number_editor_get_value(number_editor); - fail_if (number != 0, - "hildon-number-editor: range_value failed, we set range: 0/100, we set 0 and then we set the value -101 but we get %d instead of 0", - number); - - /* Test 4: Set limits to (-100, 0) */ - hildon_number_editor_set_range(number_editor, -100, 0); - - hildon_number_editor_set_value(number_editor, 0); - - hildon_number_editor_set_value(number_editor, 1); - number = hildon_number_editor_get_value(number_editor); - fail_if (number != 0, - "hildon-number-editor: range_value failed, we set range: 0/100, we set 0 and then we set the value 1 but we get %d instead of 0", - number); - - /* Test 5: Set limits to (-100, -1) */ - hildon_number_editor_set_range(number_editor, -100, -1); - - hildon_number_editor_set_value(number_editor, -1); - - hildon_number_editor_set_value(number_editor, 0); - number = hildon_number_editor_get_value(number_editor); - fail_if (number != -1, - "hildon-number-editor: range_value failed, we set range: 0/100, we set -1 and then we set the value 0 but we get %d instead of -1", - number); -} -END_TEST - -/** - * Purpose: Check that the ranges limits are controlled properly - * Cases considered: - * - Set G_MAXINT and G_MININT - * - Set a number limit of (0, 100), and test that 0 and 100 work properly - */ -START_TEST (test_set_range_limits) -{ - gint number; - - /* Test 6: Set limits to (G_MININT, G_MAXINT) */ - hildon_number_editor_set_range(number_editor, G_MININT, G_MAXINT); - - /* Test 7: Set limits to (0,100) */ - hildon_number_editor_set_value(number_editor, 0); - - number = hildon_number_editor_get_value(number_editor); - fail_if (number != 0, - "hildon-number-editor: range_value failed, we set range: 0/100, we set 0 but we get %d instead of 0", - number); - - hildon_number_editor_set_value(number_editor, 100); - - number = hildon_number_editor_get_value(number_editor); - fail_if (number != 100, - "hildon-number-editor: range_value failed, we set range: 0/100, we set 100 but we get %d instead of 100", - number); -} -END_TEST - -/** - * Purpose: Check that the invalid values are controlled properly we - * use set/get value to test if our first value is modified - * - * Cases considered: - * - Change the order of the minimum and maximum and check if it does not change (200, -2) - * - Set values where high value is less than low value (0, 100) - * - Set a range to a NULL widget - */ -START_TEST (test_set_range_invalid) -{ - gint number; - - /* Test 8: Set limits to (200, -2) */ - hildon_number_editor_set_range(number_editor, 200, -2); - - hildon_number_editor_set_value(number_editor, 0); - - /* we set 101 and it should not be set if method didn't reverse min and max, the value may continue being 0 */ - hildon_number_editor_set_value(number_editor, 101); - number = hildon_number_editor_get_value(number_editor); - fail_if (number != 101, - "hildon-number-editor: range_value failed, we set range: 200/-2, and it should not be set so 0/100 should continue being the range, we set 0 and then we set the value 101 but we get %d instead of 0", - number); - - /* Test 9: Set limits to (100, 0) */ - hildon_number_editor_set_range(number_editor, 0, 100); - - hildon_number_editor_set_value(number_editor, 0); - - /* we set -5 and it should not be set, the value may continue being 0 */ - hildon_number_editor_set_value(number_editor, -5); - number = hildon_number_editor_get_value(number_editor); - fail_if (number != 0, - "hildon-number-editor: range_value failed, we set range: 0/100, we set 0 and then we set the value -5 but we get %d instead of 0", - number); - - /* we set 101 and it should not be set, the value may continue being 0 */ - hildon_number_editor_set_value(number_editor, 101); - number = hildon_number_editor_get_value(number_editor); - fail_if (number != 0, - "hildon-number-editor: range_value failed, we set range: 0/100, we set 0 and then we set the value 101 but we get %d instead of 0", - number); - - /* Test 10: Set a range to a NULL widget */ - hildon_number_editor_set_range(NULL, 0, 100); - -} -END_TEST - - -/* ---------- Suite creation ---------- */ - -Suite *create_hildon_number_editor_suite() -{ - /* Create the suite */ - Suite *s = suite_create("HildonNumberEditor"); - - /* Create test cases */ - TCase *tc1 = tcase_create("set_number"); - - /* Create test case for set_number and add it to the suite */ - tcase_add_checked_fixture(tc1, fx_setup_default_number_editor, fx_teardown_default_number_editor); - tcase_add_test(tc1, test_set_range_regular); - tcase_add_test(tc1, test_set_range_limits); - tcase_add_test(tc1, test_set_range_invalid); - suite_add_tcase (s, tc1); - - /* Return created suite */ - return s; -} - - diff --git a/tests/check-hildon-range-editor.c b/tests/check-hildon-range-editor.c deleted file mode 100644 index cc1f214..0000000 --- a/tests/check-hildon-range-editor.c +++ /dev/null @@ -1,382 +0,0 @@ -/* - * This file is a part of hildon tests - * - * Copyright (C) 2006, 2007 Nokia Corporation, all rights reserved. - * - * Contact: Michael Dominic Kostrzewa <michael.kostrzewa@nokia.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; version 2.1 of - * the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA - * - */ - -#include <stdlib.h> -#include <check.h> -#include <gtk/gtkmain.h> -#include "test_suites.h" -#include "check_utils.h" - -#include <hildon/hildon-range-editor.h> -#include <unistd.h> - -/* -------------------- Fixtures -------------------- */ - -static GtkWidget *showed_window = NULL; -static HildonRangeEditor *range_editor = NULL; - -static void -fx_setup_default_range_editor () -{ - int argc = 0; - gtk_init(&argc, NULL); - - range_editor = HILDON_RANGE_EDITOR(hildon_range_editor_new()); - - showed_window = create_test_window (); - - /* This packs the widget into the window (a gtk container). */ - gtk_container_add (GTK_CONTAINER (showed_window), GTK_WIDGET (range_editor)); - - /* Displays the widget and the window */ - show_all_test_window (showed_window); - - /* Check range_editor object has been created properly */ - fail_if(!HILDON_IS_RANGE_EDITOR(range_editor), - "hildon-range-editor: Creation failed."); - - - while (gtk_events_pending ()) - { - gtk_main_iteration (); - } - -} - -static void -fx_teardown_default_range_editor () -{ - - /* Destroy the window */ - gtk_widget_destroy (showed_window); -} - -/* -------------------- Test cases -------------------- */ - -/* ----- Test case for set_limit, get_min, get_max -----*/ - -/** - * Purpose: Check that regular range limit values are set and get properly - * Cases considered: - * - Set limits to (-10,10) and get min/max using the range editor object - * - Set limits to (0,10) and get min/max using the range editor object - * - Set limits to (-10,0) and get min/max using the range editor object - * - Set limits to (1,10) and get min/max using the range editor object - * - Set limits to (-10,-10) and get min/max using the range editor object - */ -START_TEST (test_set_limits_get_min_get_max_regular) -{ - gint range_start, range_end; - - /* Test1: Set limits to (-10,10) */ - hildon_range_editor_set_limits(range_editor, -10, 10); - range_start = hildon_range_editor_get_min(range_editor); - fail_if(range_start != -10, - "hildon-range-editor: set limits to (-10,10) but get_min didn't return -10"); - range_end = hildon_range_editor_get_max(range_editor); - fail_if(range_end != 10, - "hildon-range-editor: set limits to (-10,10) but get_max didn't return 10"); - - /* Test2: Set limits to (0,10) */ - hildon_range_editor_set_limits(range_editor, 0, 10); - range_start = hildon_range_editor_get_min(range_editor); - fail_if(range_start != 0, - "hildon-range-editor: set limits to (0,10) but get_min didn't return 0"); - range_end = hildon_range_editor_get_max(range_editor); - fail_if(range_end != 10, - "hildon-range-editor: set limits to (0,10) but get_max didn't return 10"); - - /* Test3: Set limits to (-10,0) */ - hildon_range_editor_set_limits(range_editor, -10, 0); - range_start = hildon_range_editor_get_min(range_editor); - fail_if(range_start != -10, - "hildon-range-editor: set limits to (-10,0) but get_min didn't return -10"); - range_end = hildon_range_editor_get_max(range_editor); - fail_if(range_end != 0, - "hildon-range-editor: set limits to (-10,0) but get_max didn't return 0"); - - /* Test4: Set limits to (1,10) */ - hildon_range_editor_set_limits(range_editor, 1, 10); - range_start = hildon_range_editor_get_min(range_editor); - fail_if(range_start != 1, - "hildon-range-editor: set limits to (1,10) but get_min didn't return 1"); - range_end = hildon_range_editor_get_max(range_editor); - fail_if(range_end != 10, - "hildon-range-editor: set limits to (1,10) but get_max didn't return 10"); - - /* Test5: Set limits to (-10,-1) */ - hildon_range_editor_set_limits(range_editor, -10, -1); - range_start = hildon_range_editor_get_min(range_editor); - fail_if(range_start != -10, - "hildon-range-editor: set limits to (-10,-1) but get_min didn't return -10"); - range_end = hildon_range_editor_get_max(range_editor); - fail_if(range_end != -1, - "hildon-range-editor: set limits to (-10,-1) but get_max didn't return -1"); -} -END_TEST - -/** - * Purpose: Check that range limit values are set and get properly - * Cases considered: - * - Set limits to (G_MININT,G_MAXINT) and get min/max using the range editor object - */ -START_TEST (test_set_limits_get_min_get_max_limits) -{ - gint range_start, range_end; - - /* Test1: Set limits to (G_MININT,G_MAXINT) */ - hildon_range_editor_set_limits(range_editor, G_MININT, G_MAXINT); - range_start = hildon_range_editor_get_min(range_editor); - fail_if(range_start != G_MININT, - "hildon-range-editor: set limits to (G_MININT,G_MAXINT) but get_min didn't return G_MININT"); - range_end = hildon_range_editor_get_max(range_editor); - fail_if(range_end != G_MAXINT, - "hildon-range-editor: set limits to (G_MININT,G_MAXINT) but get_max didn't return G_MAXINT"); -} -END_TEST - -/** - * Purpose: Check that invalid values are handled properly - * Cases considered: - * - Set inverted limits (10,-10) - * - Set range editor object to NULL for set_limits - * - Set range editor object to NULL for get_min and get_max - */ -START_TEST (test_set_limits_get_min_get_max_invalid) -{ - gint range_start, range_end; - - /* Test1: Set limits to (10,-10) */ - hildon_range_editor_set_limits(range_editor, 10, -10); - range_start = hildon_range_editor_get_min(range_editor); - fail_if(range_start != -10, - "hildon-range-editor: set inverted limits to (10,-10) expecting to set limits to (-10,-10) but get_min didn't return -10"); - range_end = hildon_range_editor_get_max(range_editor); - fail_if(range_end != -10, - "hildon-range-editor: set inverted limits to (10,-10) expecting to set limits to (-10,-10) but get_max didn't return -1"); - - /* Test2: set range editor to NULL for set_limits. */ - hildon_range_editor_set_limits(NULL, 100, -100); - - /* Test3: set range editor to NULL for get_min and get_max */ - range_start = hildon_range_editor_get_min(NULL); - fail_if(range_start != 0, - "hildon-range-editor: setting range editor to NULL produced get_min to return a value != 0"); - range_end = hildon_range_editor_get_max(NULL); - fail_if(range_end != 0, - "hildon-range-editor: setting range editor to NULL produced get_max to return a value != 0"); -} -END_TEST - - -/* ----- Test case for set_min -----*/ - -/** - * Purpose: Check regular minimum values for limits are set properly - * Cases considered: - * - Set min limit to -100 - * - Set min limit to 0 - * - Set min limit to 100 - */ -START_TEST (test_set_min_regular) -{ - gint range_start; - - /* Test1: Set min limits -100 */ - hildon_range_editor_set_min(range_editor, -100); - range_start = hildon_range_editor_get_min(range_editor); - fail_if(range_start != -100, - "hildon-range-editor: set min limit to -100 but get_min didn't return -100"); - - /* Test2: Set min limits 0 */ - hildon_range_editor_set_min(range_editor, 0); - range_start = hildon_range_editor_get_min(range_editor); - fail_if(range_start != 0, - "hildon-range-editor: set min limit to 0 but get_min didn't return 0"); - - /* Test3: Set min limits 100 */ - hildon_range_editor_set_min(range_editor, 100); - range_start = hildon_range_editor_get_min(range_editor); - fail_if(range_start != 100, - "hildon-range-editor: set min limit to 100 but get_min didn't return 100"); -} -END_TEST - -/** - * Purpose: Check limit minimum values for limits are set properly - * Cases considered: - * - Set min limit to G_MININT - */ -START_TEST (test_set_min_limits) -{ - gint range_start; - - /* Test1: Set min limit to G_MININT */ - hildon_range_editor_set_min(range_editor, G_MININT); - range_start = hildon_range_editor_get_min(range_editor); - fail_if(range_start != G_MININT, - "hildon-range-editor: set min limit to G_MININT but get_min didn't return G_MININT"); -} -END_TEST - -/** - * Purpose: Check that invalid values are handled properly - * Cases considered: - * - Set minimum limit greater than maximum limit - * - Set range editor object to NULL for set_min - */ -START_TEST (test_set_min_invalid) -{ - gint range_start, range_end; - - /* Test1: Set minimum limit greater than maximum limit */ - hildon_range_editor_set_limits(range_editor, -10, 10); - hildon_range_editor_set_min(range_editor, 15); - range_start = hildon_range_editor_get_min(range_editor); - fail_if(range_start != 15, - "hildon-range-editor: set min limit to 15 when max limit is 10 expecting to set limits to (15,15) but get_min didn't return 15"); - range_end = hildon_range_editor_get_max(range_editor); - fail_if(range_end != 15, - "hildon-range-editor: set min limit to 15 when max limit is 10 expecting to set limits to (15,15) but get_max didn't return 15"); - - /* Test2: set range editor to NULL */ - hildon_range_editor_set_min(NULL, 15); -} -END_TEST - - -/* ----- Test case for set_max -----*/ - -/** - * Purpose: Check regular maximum values for limits are set properly - * Cases considered: - * - Set max limit to -100 - * - Set max limit to 0 - * - Set max limit to 100 - */ -START_TEST (test_set_max_regular) -{ - gint range_end; - - /* Test1: Set max limits -100 */ - hildon_range_editor_set_max(range_editor, -100); - range_end = hildon_range_editor_get_max(range_editor); - fail_if(range_end != -100, - "hildon-range-editor: set max limit to -100 but get_max didn't return -100"); - - /* Test2: Set max limits 0 */ - hildon_range_editor_set_max(range_editor, 0); - range_end = hildon_range_editor_get_max(range_editor); - fail_if(range_end != 0, - "hildon-range-editor: set max limit to 0 but get_max didn't return 0"); - - /* Test3: Set max limits 100 */ - hildon_range_editor_set_max(range_editor, 100); - range_end = hildon_range_editor_get_max(range_editor); - fail_if(range_end != 100, - "hildon-range-editor: set max limit to 100 but get_max didn't return 100"); -} -END_TEST - -/** - * Purpose: Check limit maximum values for limits are set properly - * Cases considered: - * - Set min limit to G_MAXINT - */ -START_TEST (test_set_max_limits) -{ - gint range_end; - - /* Test1: Set max limit to G_MAXINT */ - hildon_range_editor_set_max(range_editor, G_MAXINT); - range_end = hildon_range_editor_get_max(range_editor); - fail_if(range_end != G_MAXINT, - "hildon-range-editor: set min limit to G_MAXINT but get_max didn't return G_MAXINT"); -} -END_TEST - -/** - * Purpose: Check that invalid values are handled properly - * Cases considered: - * - Set maximum limit lower than minimum limit - * - Set range editor object to NULL for set_max - */ -START_TEST (test_set_max_invalid) -{ - gint range_start, range_end; - - /* Test1: Set maximum limit lower than minimum limit */ - hildon_range_editor_set_limits(range_editor, -10, 10); - hildon_range_editor_set_max(range_editor, -15); - range_start = hildon_range_editor_get_min(range_editor); - fail_if(range_start != -15, - "hildon-range-editor: set max limit to -15 when min limit is -10 expecting to set limits to (-15,-15) but get_min didn't return -15"); - range_end = hildon_range_editor_get_max(range_editor); - fail_if(range_end != -15, - "hildon-range-editor: set min limit to -15 when min limit is -10 expecting to set limits to (-15,-15) but get_max didn't return -15"); - - /* Test2: set range editor to NULL */ - hildon_range_editor_set_max(NULL, 15); -} -END_TEST - - -/* ---------- Suite creation ---------- */ - -Suite *create_hildon_range_editor_suite() -{ - /* Create the suite */ - Suite *s = suite_create("HildonRangeEditor"); - - /* Create test cases */ - TCase *tc1 = tcase_create("set_limits_get_min_get_max"); - TCase *tc2 = tcase_create("set_min"); - TCase *tc3 = tcase_create("set_max"); - - /* Create test case for set_limits, get_min and get_max and add it to the suite */ - tcase_add_checked_fixture(tc1, fx_setup_default_range_editor, fx_teardown_default_range_editor); - tcase_add_test(tc1, test_set_limits_get_min_get_max_regular); - tcase_add_test(tc1, test_set_limits_get_min_get_max_limits); - tcase_add_test(tc1, test_set_limits_get_min_get_max_invalid); - suite_add_tcase (s, tc1); - - /* Create test case for set_min */ - tcase_add_checked_fixture(tc2, fx_setup_default_range_editor, fx_teardown_default_range_editor); - tcase_add_test(tc2, test_set_min_regular); - tcase_add_test(tc2, test_set_min_limits); - tcase_add_test(tc2, test_set_min_invalid); - suite_add_tcase (s, tc2); - - /* Create test case for set_max */ - tcase_add_checked_fixture(tc3, fx_setup_default_range_editor, fx_teardown_default_range_editor); - tcase_add_test(tc3, test_set_max_regular); - tcase_add_test(tc3, test_set_max_limits); - tcase_add_test(tc3, test_set_max_invalid); - suite_add_tcase (s, tc3); - - /* Return created suite */ - return s; -} - - diff --git a/tests/check-hildon-seekbar.c b/tests/check-hildon-seekbar.c deleted file mode 100644 index bb53c98..0000000 --- a/tests/check-hildon-seekbar.c +++ /dev/null @@ -1,442 +0,0 @@ -/* - * This file is a part of hildon tests - * - * Copyright (C) 2006, 2007 Nokia Corporation, all rights reserved. - * - * Contact: Michael Dominic Kostrzewa <michael.kostrzewa@nokia.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; version 2.1 of - * the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA - * - */ - -#include <stdlib.h> -#include <check.h> -#include <gtk/gtkmain.h> -#include <gtk/gtkcontainer.h> -#include <glib/gprintf.h> -#include "test_suites.h" -#include "check_utils.h" - -#include <hildon/hildon-seekbar.h> - -/* -------------------- Fixtures -------------------- */ - -static GtkWidget *showed_window = NULL; -static HildonSeekbar *seekbar = NULL; - -static void -fx_setup_default_seekbar () -{ - int argc = 0; - gtk_init(&argc, NULL); - - seekbar = HILDON_SEEKBAR(hildon_seekbar_new()); - - showed_window = create_test_window (); - - /* This packs the widget into the window (a gtk container). */ - gtk_container_add (GTK_CONTAINER (showed_window), GTK_WIDGET (seekbar)); - - /* Displays the widget and the window */ - show_all_test_window (showed_window); - - /* Check that the seekbar object has been created properly */ - fail_if(!HILDON_SEEKBAR(seekbar), - "hildon-seekbar: Creation failed."); -} - -static void -fx_teardown_default_seekbar () -{ - - /* Destroy the window */ - gtk_widget_destroy (showed_window); -} - -/* -------------------- Test cases -------------------- */ - -/* ----- Test case for set_time -----*/ - -/** - * Purpose: test setting regular time values for hildon_seekbar_set_time - * Cases considered: - * - Set and get 1000 seconds without setting new position and fraction. - * - Set and get 500 seconds setting without setting new position but new fraction should be set. - * - Set and get 500 seconds setting without setting new position but new fraction should be set. - */ -START_TEST (test_set_time_regular) -{ - gint ret_seconds; - gint seconds; - gint position; - gint fraction; - - /* Test 1: Set and get 1000 seconds without setting new position and fraction */ - seconds = 1000; - hildon_seekbar_set_total_time(seekbar,seconds); - ret_seconds=hildon_seekbar_get_total_time(seekbar); - - fail_if(ret_seconds != seconds, - "hildon-seekbar: set seekbar total time to %d but get_total_time returns %d", - seconds,ret_seconds); - - - /* Test 2: Set and get 500 seconds with a fraction set to 750 and position set to 750 (in order to test the correct update of - position and fraction. */ - seconds = 500; - position = 750; - fraction = 750; - - hildon_seekbar_set_fraction(seekbar,fraction); - fail_if(fraction != hildon_seekbar_get_fraction(seekbar), - "hildon-seekbar: set total time to %d but get_fraction returns %d ", - fraction,hildon_seekbar_get_fraction(seekbar)); - - hildon_seekbar_set_position(seekbar,position); - fail_if(position != hildon_seekbar_get_position(seekbar), - "hildon-seekbar: set total time to %d but get_position returns %d", - position,hildon_seekbar_get_position(seekbar)); - - hildon_seekbar_set_total_time(seekbar,seconds); - fail_if(seconds != hildon_seekbar_get_fraction(seekbar), - "hildon-seekbar: set total time to %d but get_fraction returns %d being total time %d", - seconds,hildon_seekbar_get_fraction(seekbar),hildon_seekbar_get_total_time(seekbar)); - - fail_if(seconds != hildon_seekbar_get_position(seekbar), - "hildon-seekbar: set total time to %d but get_fraction returns %d being total time %d", - seconds,hildon_seekbar_get_fraction(seekbar),hildon_seekbar_get_total_time(seekbar)); - - ret_seconds=hildon_seekbar_get_total_time(seekbar); - fail_if(ret_seconds != seconds, - "hildon-seekbar: set total time to %d but get_total_time returns %d ", - seconds,ret_seconds); - - /* Test 3: Set and get 500 seconds with a fraction set to 750 and position set to 250 (in order to test the correct update of - position and fraction. - */ - seconds = 1000; - hildon_seekbar_set_total_time(seekbar,seconds); - - seconds = 500; - position = 250; - fraction = 750; - - hildon_seekbar_set_fraction(seekbar,fraction); - fail_if(fraction != hildon_seekbar_get_fraction(seekbar), - "hildon-seekbar: set seekbar fraction to %d but get_fraction returns %d ", - fraction,hildon_seekbar_get_fraction(seekbar)); - - hildon_seekbar_set_position(seekbar,position); - fail_if(position != hildon_seekbar_get_position(seekbar), - "hildon-seekbar: set seekbar position to %d but get_position returns %d", - position,hildon_seekbar_get_position(seekbar)); - - hildon_seekbar_set_total_time(seekbar,seconds); - fail_if(fraction != hildon_seekbar_get_fraction(seekbar), - "hildon-seekbar: set seekbar fraction to %d but get_fraction returns %d being total time %d", - seconds,hildon_seekbar_get_fraction(seekbar),hildon_seekbar_get_total_time(seekbar)); - - ret_seconds=hildon_seekbar_get_total_time(seekbar); - fail_if(ret_seconds != seconds, - "hildon-seekbar: set total time to %d but get_total_time returns %d ", - seconds,ret_seconds); -} -END_TEST - -/** - * Purpose: test setting limit time values for hildon_seekbar_set_time - * Cases considered: - * - Set and get 0 seconds setting new position and fraction (previously set to 750). - * - Set and get G_MAXINT seconds without setting new position and fraction. - */ -START_TEST (test_set_time_limits) -{ - gint ret_seconds; - gint seconds; - gint position; - gint fraction; - - seconds = 1000; - hildon_seekbar_set_total_time(seekbar,seconds); - - position = 750; - fraction = 750; - - hildon_seekbar_set_fraction(seekbar,fraction); - hildon_seekbar_set_position(seekbar,position); - - /* Test 1: Set and get 1 seconds without setting new position and fraction (time was previously set to 1000)*/ - seconds = 1; - hildon_seekbar_set_total_time(seekbar,seconds); - ret_seconds=hildon_seekbar_get_total_time(seekbar); - - fail_if(ret_seconds != seconds, - "hildon-seekbar: set seekbar total time to %d should return %d but get_total_time returns %d", - seconds,ret_seconds); - - /* Check with seconds because hildon_seekbar_set_total_time must update fraction and position to total time set*/ - fail_if(seconds != hildon_seekbar_get_fraction(seekbar), - "hildon-seekbar: set time to %d but get_fraction returns %d ", - seconds,hildon_seekbar_get_fraction(seekbar)); - - /* Check with seconds because hildon_seekbar_set_total_time must update fraction and position to total time set*/ - fail_if(seconds != hildon_seekbar_get_position(seekbar), - "hildon-seekbar: set time to %d but get_position returns %d", - seconds,hildon_seekbar_get_position(seekbar)); - - /* Test 2: Set and get G_MAXINT seconds without setting new position and fraction */ - seconds = G_MAXINT; - hildon_seekbar_set_total_time(seekbar,seconds); - ret_seconds=hildon_seekbar_get_total_time(seekbar); - - fail_if(ret_seconds != seconds, - "hildon-seekbar: set seekbar total time to %d but get_total_time returns %d", - seconds,ret_seconds); - - -} -END_TEST - - -/** - * Purpose: test setting invalid time values for hildon_seekbar_set_time - * Cases considered: - * - Set and get seconds to a NULL object. - * - Set and get 0 seconds without setting new position and fraction. - * - Set and get -1 seconds without setting new position and fraction. - */ -START_TEST (test_set_time_invalid) -{ - gint init_seconds; - gint ret_seconds; - gint seconds; - - init_seconds = 1000; - /* Test 1: Set/get seconds on NULL object */ - hildon_seekbar_set_total_time(NULL,init_seconds); - ret_seconds=hildon_seekbar_get_total_time(NULL); - - /* Init seekbar to 1000 seconds*/ - hildon_seekbar_set_total_time(seekbar,init_seconds); - - - /* Test 2: Set and get 0 seconds */ - seconds = 0; - hildon_seekbar_set_total_time(seekbar,seconds); - ret_seconds=hildon_seekbar_get_total_time(seekbar); - - fail_if(ret_seconds != init_seconds, - "hildon-seekbar: set seekbar total time to %d, should set %d but get_total_time returns %d", - seconds,init_seconds,ret_seconds); - - /* Test 3: Set and get -1 seconds */ - seconds = -1; - hildon_seekbar_set_total_time(seekbar,seconds); - ret_seconds=hildon_seekbar_get_total_time(seekbar); - - fail_if(ret_seconds != init_seconds, - "hildon-seekbar: set seekbar total time to %d, should return %d but get_total_time returns %d", - seconds,init_seconds,ret_seconds); - -} -END_TEST - -/* ----- Test case for set_fraction -----*/ - -/** - * Purpose: test setting regular fraction values for hildon_seekbar_set_fraction - * Cases considered: - * - Set and get fraction to 500 with total time set to 1000. - * - Set and get fraction to 490 with total time set to 1000, fraction and position previously set to 500. - */ -START_TEST (test_set_fraction_regular) -{ - gint ret_seconds; - gint init_seconds; - gint seconds; - - /* Init seekbar to 1000 */ - init_seconds = 1000; - hildon_seekbar_set_total_time(seekbar,init_seconds); - - /* Test 1: Set and get fraction to 500 with total time set to 1000 */ - seconds = 500; - hildon_seekbar_set_fraction(seekbar,seconds); - ret_seconds=hildon_seekbar_get_fraction(seekbar); - - fail_if(ret_seconds != seconds, - "hildon-seekbar: set seekbar fraction to %d but get seekbar fraction returns %d", - seconds,ret_seconds); - - /* Test 2: Set and get fraction to 490 with total time set to 1000, fraction and position previously set to 500 */ - seconds = 500; - - hildon_seekbar_set_fraction(seekbar,seconds); - hildon_seekbar_set_position(seekbar,seconds); - - hildon_seekbar_set_fraction(seekbar,seconds-10); - - ret_seconds=hildon_seekbar_get_fraction(seekbar); - - fail_if(ret_seconds != seconds-10, - "hildon-seekbar: set seekbar fraction to %d but get seekbar fraction returns %d", - seconds,ret_seconds); - - fail_if(hildon_seekbar_get_position(seekbar) != seconds-10, - "hildon-seekbar: set seekbar fraction to %d but get seekbar position returns %d", - seconds-10,hildon_seekbar_get_position(seekbar)); - -} -END_TEST - -/** - * Purpose: test setting limit fraction values for hildon_seekbar_set_fraction - * Cases considered: - * - Set and get fraction to 0 with total time set to G_MAXINT. - * - Set and get fraction to 1 with total time set to G_MAXINT. - * - Set and get fraction to G_MAXINT-1 with total time set to G_MAXINT. - * - Set and get fraction to G_MAXINT with total time set to G_MAXINT. - */ -START_TEST (test_set_fraction_limits) -{ - gint ret_seconds; - gint seconds; - gint init_seconds; - - /* Init seekbar to G_MAXINT total time */ - init_seconds = G_MAXINT; - hildon_seekbar_set_total_time(seekbar,init_seconds); - - /* Test 1: Set and get fraction to 0 with total time set to G_MAXINT */ - seconds = 0; - hildon_seekbar_set_fraction(seekbar,seconds); - ret_seconds=hildon_seekbar_get_fraction(seekbar); - - fail_if(ret_seconds != seconds, - "hildon-seekbar: set seekbar fraction to %d but get seekbar fraction returns %d", - seconds,ret_seconds); - - /* Test 2: Set and get fraction to 1 with total time set to G_MAXINT */ - seconds = 1; - hildon_seekbar_set_fraction(seekbar,seconds); - ret_seconds=hildon_seekbar_get_fraction(seekbar); - - fail_if(ret_seconds != seconds, - "hildon-seekbar: set seekbar fraction to %d but get seekbar fraction returns %d", - seconds,ret_seconds); - - /* Test 3: Set and get fraction to G_MAXINT-1 with total time set to G_MAXINT */ - seconds = G_MAXINT-1; - hildon_seekbar_set_fraction(seekbar,seconds); - ret_seconds=hildon_seekbar_get_fraction(seekbar); - - fail_if(ret_seconds != seconds, - "hildon-seekbar: set seekbar fraction to %d but get seekbar fraction returns %d", - seconds,ret_seconds); - - /* Test 4: Set and get fraction to G_MAXINT with total time set to G_MAXINT */ - seconds = G_MAXINT; - - hildon_seekbar_set_fraction(seekbar,seconds); - ret_seconds=hildon_seekbar_get_fraction(seekbar); - - fail_if(ret_seconds != seconds, - "hildon-seekbar: set seekbar fraction to %d but get seekbar fraction returns %d", - seconds,ret_seconds); - - -} -END_TEST - -/** - * Purpose: test setting invalid fraction values for hildon_seekbar_set_fraction - * Cases considered: - * - Set and get fraction to NULL object. - * - Set and get fraction to -1 with total time set to G_MAXINT. - * - Set and get fraction to 2000 with total time set to 1000. - */ -START_TEST (test_set_fraction_invalid) -{ - gint ret_seconds; - gint seconds; - gint init_seconds; - - /* Init seekbar to G_MAXINT total time */ - init_seconds = G_MAXINT; - hildon_seekbar_set_total_time(seekbar,init_seconds); - - /* Test 1: Set and get fraction to NULL object */ - seconds = 1000; - hildon_seekbar_set_fraction(NULL,seconds); - ret_seconds=hildon_seekbar_get_fraction(NULL); - - /* Test 2: Set and get fraction to -1 with total time set to G_MAXINT */ - seconds = -1; - hildon_seekbar_set_fraction(seekbar,seconds); - ret_seconds=hildon_seekbar_get_fraction(seekbar); - - fail_if(ret_seconds != 0, - "hildon-seekbar: set seekbar fraction to %d should set 0 but get seekbar fraction returns %d", - seconds,ret_seconds); - - /* Init seekbar to 1000 total time */ - init_seconds = 1000; - hildon_seekbar_set_total_time(seekbar,init_seconds); - hildon_seekbar_set_fraction(seekbar,init_seconds-500); - - /* Test 3: Set and get fraction to 2000 with total time set to 1000 */ - seconds = 2000; - hildon_seekbar_set_fraction(seekbar,seconds); - ret_seconds=hildon_seekbar_get_fraction(seekbar); - - fail_if(ret_seconds != init_seconds-500, - "hildon-seekbar: set seekbar fraction to %d should set %d but get seekbar fraction returns %d", - seconds,init_seconds,ret_seconds); - -} -END_TEST - - - -/* ---------- Suite creation ---------- */ - -Suite *create_hildon_seekbar_suite() -{ - /* Create the suite */ - Suite *s = suite_create("HildonSeekbar"); - - /* Create test cases */ - TCase *tc1 = tcase_create("set_time"); - TCase *tc2 = tcase_create("set_fraction"); - - /* Create test case for hildon_seekbar_set_time and add it to the suite */ - tcase_add_checked_fixture(tc1, fx_setup_default_seekbar, fx_teardown_default_seekbar); - tcase_add_test(tc1, test_set_time_regular); - tcase_add_test(tc1, test_set_time_limits); - tcase_add_test(tc1, test_set_time_invalid); - suite_add_tcase (s, tc1); - - /* Create test case for hildon_seekbar_set_fraction and add it to the suite */ - tcase_add_checked_fixture(tc2, fx_setup_default_seekbar, fx_teardown_default_seekbar); - tcase_add_test(tc2, test_set_fraction_regular); - tcase_add_test(tc2, test_set_fraction_limits); - tcase_add_test(tc2, test_set_fraction_invalid); - suite_add_tcase (s, tc2); - - /* Return created suite */ - return s; -} - diff --git a/tests/check-hildon-set-password-dialog.c b/tests/check-hildon-set-password-dialog.c deleted file mode 100644 index 73ca67d..0000000 --- a/tests/check-hildon-set-password-dialog.c +++ /dev/null @@ -1,244 +0,0 @@ -/* - * This file is a part of hildon tests - * - * Copyright (C) 2006, 2007 Nokia Corporation, all rights reserved. - * - * Contact: Michael Dominic Kostrzewa <michael.kostrzewa@nokia.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; version 2.1 of - * the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA - * - */ - -#include <stdlib.h> -#include <string.h> -#include <check.h> -#include <gtk/gtkmain.h> -#include "test_suites.h" -#include "check_utils.h" - -#include <hildon/hildon-set-password-dialog.h> -#include <hildon/hildon-window.h> - -/* -------------------- Fixtures -------------------- */ - -static HildonSetPasswordDialog *set_password_dialog = NULL; -static GtkWindow *spd_window=NULL; - -static void -fx_setup_default_set_password_dialog () -{ - int argc = 0; - - gtk_init(&argc, NULL); - spd_window = GTK_WINDOW(create_test_window()); - - /* Check window object has been created properly */ - fail_if(!HILDON_IS_WINDOW(spd_window), - "hildon-set_password_dialog: Window creation failed."); - - set_password_dialog = HILDON_SET_PASSWORD_DIALOG(hildon_set_password_dialog_new(spd_window, TRUE)); - - /* Check that the set password dialog object has been created properly */ - fail_if(!HILDON_SET_PASSWORD_DIALOG(set_password_dialog), - "hildon-set_password_dialog: Creation failed."); - - show_test_window(GTK_WIDGET(spd_window)); - - show_test_window(GTK_WIDGET(set_password_dialog)); - -} - -static void -fx_teardown_default_set_password_dialog () -{ - - gtk_widget_destroy (GTK_WIDGET (set_password_dialog)); - - gtk_widget_destroy (GTK_WIDGET (spd_window)); - -} - -/* -------------------- Test cases -------------------- */ - -/* ----- Test case for get_protected -----*/ - -/** - * Purpose: Check that regular values are get properly. - * Cases considered: - * - Get TRUE from modify_protection property. - * - Get FALSE from modify_protection property. - * - */ -START_TEST (test_get_protected_regular) -{ - gboolean ret_protected; - HildonSetPasswordDialog *protected_test_password_dialog = NULL; - - /* I must create one dialog for each value of protected boolean because is a G_PARAM_CONSTRUCT_ONLY property */ - protected_test_password_dialog = HILDON_SET_PASSWORD_DIALOG(hildon_set_password_dialog_new(spd_window, TRUE)); - - /* Test 1: Get TRUE from modify_protection property. */ - ret_protected = hildon_set_password_dialog_get_protected(set_password_dialog); - fail_if(ret_protected!=TRUE, - "hildon-set_password_dialog: modify_protection must be TRUE, but hildon_set_password_dialog_get_protected returns FALSE"); - - gtk_widget_destroy (GTK_WIDGET (protected_test_password_dialog)); - - /* Test 2: Get FALSE from modify_protection property */ - /* I must create one dialog for each value of protected boolean because is a G_PARAM_CONSTRUCT_ONLY property */ - protected_test_password_dialog = HILDON_SET_PASSWORD_DIALOG(hildon_set_password_dialog_new(spd_window, FALSE)); - - ret_protected = hildon_set_password_dialog_get_protected(protected_test_password_dialog); - fail_if(ret_protected!=FALSE, - "hildon-set_password_dialog: modify_protection must be FALSE, but hildon_set_password_dialog_get_protected returns TRUE"); - - gtk_widget_destroy (GTK_WIDGET (protected_test_password_dialog)); -} -END_TEST - -/** - * Purpose: Check that invalid values are get properly. - * Cases considered: - * - Get modify_protection from NULL object. - * - */ -START_TEST (test_get_protected_invalid) -{ - gboolean ret_protected; - - ret_protected = hildon_set_password_dialog_get_protected (NULL); - fail_if (ret_protected != FALSE, - "hildon-set_password_dialog: modify_protection must be FALSE, but hildon_set_password_dialog_get_protected return TRUE"); -} -END_TEST - -/* ----- Test case for get_password -----*/ - -/** - * Purpose: Check that regular values are get properly. - * Cases considered: - * - Get password "test_password" from HildonSetPasswordDialog created with "test_password" by default. - * - Get password "" from HildonSetPasswordDialog created with "" by default. - * - Get password TEST_STRING from HildonSetPasswordDialog created with TEST_STRING by default. - */ -START_TEST (test_get_password_regular) -{ - const gchar * default_password=NULL; - const gchar * ret_password; - HildonSetPasswordDialog * default_set_password_dialog; - - - /* Test 1: Get password "test_password" from HildonSetPasswordDialog created with "test_password" by default. */ - default_password = "test_password"; - default_set_password_dialog = - HILDON_SET_PASSWORD_DIALOG(hildon_set_password_dialog_new_with_default(spd_window,default_password,FALSE)); - fail_if(!HILDON_IS_SET_PASSWORD_DIALOG(default_set_password_dialog), - "hildon-set_password_dialog: hildon-set-password-dialog: Creation failed with hildon_set_password_dialog_new_with_default"); - - ret_password = hildon_set_password_dialog_get_password(default_set_password_dialog); - fail_if(strcmp (default_password,ret_password)!=0, - "hildon-set_password_dialog: default password and returned password are diferent (%s,%s)",default_password,ret_password); - - gtk_widget_destroy (GTK_WIDGET (default_set_password_dialog)); - - /* Test 2: Create new dialog with password "" by default */ - default_password = ""; - default_set_password_dialog = - HILDON_SET_PASSWORD_DIALOG(hildon_set_password_dialog_new_with_default(spd_window,default_password,FALSE)); - fail_if(!HILDON_IS_SET_PASSWORD_DIALOG(default_set_password_dialog), - "hildon-set-password-dialog: Creation failed with hildon_set_password_dialog_new_with_default"); - - ret_password = hildon_set_password_dialog_get_password(default_set_password_dialog); - fail_if(strcmp (default_password,ret_password)!=0, - "hildon-set_password_dialog: default password and returned password are diferent (%s,%s)",default_password,ret_password); - - gtk_widget_destroy (GTK_WIDGET (default_set_password_dialog)); - - /* Test 3: Create new dialog with password TEST_STRING by default */ - default_password = TEST_STRING; - default_set_password_dialog = - HILDON_SET_PASSWORD_DIALOG(hildon_set_password_dialog_new_with_default(spd_window,default_password,FALSE)); - fail_if(!HILDON_IS_SET_PASSWORD_DIALOG(default_set_password_dialog), - "hildon-set-password-dialog: Creation failed with hildon_set_password_dialog_new_with_default"); - - ret_password = hildon_set_password_dialog_get_password(default_set_password_dialog); - fail_if(strcmp (default_password,ret_password)!=0, - "hildon-set_password_dialog: default password and returned password are diferent (%s,%s)",default_password,ret_password); - - gtk_widget_destroy (GTK_WIDGET (default_set_password_dialog)); - -} -END_TEST - -/** - * Purpose: Check that regular values are get properly. - * Cases considered: - * - Get empty password from HildonSetPasswordDialog created with NULL password by default. - * - Get password from NULL object. - */ -START_TEST (test_get_password_invalid) -{ - const gchar * ret_password; - HildonSetPasswordDialog * default_set_password_dialog; - - - /* Test 1: Get empty password from HildonSetPasswordDialog created with NULL password by default */ - default_set_password_dialog = - HILDON_SET_PASSWORD_DIALOG(hildon_set_password_dialog_new_with_default(spd_window,NULL,FALSE)); - fail_if(!HILDON_IS_SET_PASSWORD_DIALOG(default_set_password_dialog), - "hildon-set-password-dialog: Creation failed with hildon_set_password_dialog_new_with_default"); - - ret_password = hildon_set_password_dialog_get_password(default_set_password_dialog); - fail_if(strcmp(ret_password,"")!=0, - "hildon-set_password_dialog: returned password is not empty"); - - gtk_widget_destroy (GTK_WIDGET (default_set_password_dialog)); - - /* Test 2: Get password from NULL object */ - ret_password = hildon_set_password_dialog_get_password(NULL); - - fail_if(ret_password!=NULL, - "hildon-set_password_dialog: returned password is not null"); - -} -END_TEST - -/* ---------- Suite creation ---------- */ - -Suite *create_hildon_set_password_dialog_suite() -{ - /* Create the suite */ - Suite *s = suite_create("HildonSetPasswordDialog"); - - /* Create test cases */ - TCase *tc1 = tcase_create("get_protected"); - TCase *tc2 = tcase_create("get_password"); - - /* Create test case for hildon_set_password_dialog_get_protected and add it to the suite */ - tcase_add_checked_fixture(tc1, fx_setup_default_set_password_dialog, fx_teardown_default_set_password_dialog); - tcase_add_test(tc1, test_get_protected_regular); - tcase_add_test(tc1, test_get_protected_invalid); - suite_add_tcase (s, tc1); - - /* Create test case for hildon_set_password_dialog_get_password and add it to the suite */ - tcase_add_checked_fixture(tc2, fx_setup_default_set_password_dialog, fx_teardown_default_set_password_dialog); - tcase_add_test(tc2, test_get_password_regular); - tcase_add_test(tc2, test_get_password_invalid); - suite_add_tcase (s, tc2); - - /* Return created suite */ - return s; -} diff --git a/tests/check-hildon-sort-dialog.c b/tests/check-hildon-sort-dialog.c deleted file mode 100644 index 06a5fb7..0000000 --- a/tests/check-hildon-sort-dialog.c +++ /dev/null @@ -1,243 +0,0 @@ -/* - * This file is a part of hildon tests - * - * Copyright (C) 2006, 2007 Nokia Corporation, all rights reserved. - * - * Contact: Michael Dominic Kostrzewa <michael.kostrzewa@nokia.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; version 2.1 of - * the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA - * - */ - -#include <stdlib.h> -#include <check.h> -#include <gtk/gtkmain.h> -#include "test_suites.h" -#include "check_utils.h" - -#include <hildon/hildon-sort-dialog.h> - -#define SORT_KEY_0 "maemo" -#define SORT_KEY_1 TEST_STRING -#define SORT_KEY_2 "" - -/* -------------------- Fixtures -------------------- */ - -static HildonSortDialog *sort_dialog = NULL; -static GtkWindow * showed_window = NULL; - -static void -fx_setup_default_sort_dialog () -{ - int argc = 0; - gtk_init(&argc, NULL); - - showed_window = GTK_WINDOW(create_test_window()); - - sort_dialog = HILDON_SORT_DIALOG(hildon_sort_dialog_new(showed_window)); - - show_test_window(GTK_WIDGET(showed_window)); - - show_test_window(GTK_WIDGET(sort_dialog)); - - /* Check sort_dialog object has been created properly */ - fail_if(!HILDON_IS_SORT_DIALOG(sort_dialog), - "hildon-sort-dialog: Creation failed."); -} - -static void -fx_teardown_default_sort_dialog () -{ - - gtk_widget_destroy (GTK_WIDGET (sort_dialog)); - - gtk_widget_destroy (GTK_WIDGET(showed_window)); - -} - -/* -------------------- Test cases -------------------- */ - -/* ----- Test case for set/get_sort_key -----*/ - -/** - * Purpose: Test add, set and get of sort keys. - * Cases considered: - * - Add 3 keys to the list, then set and get key 1 - * - Unselect sort key - */ -START_TEST (test_add_set_get_sort_key_regular) -{ - gint ret_key; - - /* Test1: add 3 keys, then try to set and get key 1 */ - hildon_sort_dialog_add_sort_key(sort_dialog, SORT_KEY_0); - hildon_sort_dialog_add_sort_key(sort_dialog, SORT_KEY_1); - hildon_sort_dialog_add_sort_key(sort_dialog, SORT_KEY_2); - - hildon_sort_dialog_set_sort_key(sort_dialog, 1); - ret_key = hildon_sort_dialog_get_sort_key(sort_dialog); - fail_if(ret_key != 1, - "hildon-sort-dialog: Added keys \"%s\", \"%s\" and \"%s\", then set sort key 1, but get_sort_key returned value %d instead of 1", - SORT_KEY_0, SORT_KEY_1, SORT_KEY_2, ret_key); - - /* Test2: Unselect sort key */ - hildon_sort_dialog_set_sort_key(sort_dialog, -1); - ret_key = hildon_sort_dialog_get_sort_key(sort_dialog); - fail_if(ret_key != -1, - "hildon-sort-dialog: Set sort key to -1, but get_sort_key returned value %d instead of -1", - ret_key); - -} -END_TEST - -/** - * Purpose: - * Cases considered: - * - Get of current key after dialog construction (empty list of keys) - * - Add 3 keys to the list, then set and get keys 0 and 2 - */ -START_TEST (test_add_set_get_sort_key_limits) -{ - gint ret_key; - - /* Test1: Get current key after construction */ - ret_key = hildon_sort_dialog_get_sort_key(sort_dialog); - fail_if(ret_key != -1, - "hildon-sort-dialog: After dialog construction current sort key index is %d instead of -1", - ret_key); - - /* Test2: Add 3 keys, then set and get keys 0 and 2 */ - hildon_sort_dialog_add_sort_key(sort_dialog, SORT_KEY_0); - hildon_sort_dialog_add_sort_key(sort_dialog, SORT_KEY_1); - hildon_sort_dialog_add_sort_key(sort_dialog, SORT_KEY_2); - - hildon_sort_dialog_set_sort_key(sort_dialog, 0); - ret_key = hildon_sort_dialog_get_sort_key(sort_dialog); - fail_if(ret_key != 0, - "hildon-sort-dialog: Added keys \"%s\", \"%s\" and \"%s\", then set sort key 0, but get_sort_key returned value %d instead of 0", - SORT_KEY_0, SORT_KEY_1, SORT_KEY_2, ret_key); - - hildon_sort_dialog_set_sort_key(sort_dialog, 2); - ret_key = hildon_sort_dialog_get_sort_key(sort_dialog); - fail_if(ret_key != 2, - "hildon-sort-dialog: Added keys \"%s\", \"%s\" and \"%s\", then set sort key 2, but get_sort_key returned value %d instead of 2", - SORT_KEY_0, SORT_KEY_1, SORT_KEY_2, ret_key); -} -END_TEST - -/** - * Purpose: Check handling of invalid values regarding the sort keys management - * Cases considered: - * - Set of key with empty key list - * - Set negative key, lower than -1 - * - Set of key outside the range of a non empty key list - * - Set a duplicated key and check it is filtered - * - Add NULL sort key. - * - Add key with NULL object - * - Set key with NULL object - * - Get key with NULL object - */ -START_TEST (test_add_set_get_sort_key_invalid) -{ - gint ret_key; - - /* Test1: Set of a key with an empty key list */ - hildon_sort_dialog_set_sort_key(sort_dialog, 5); - ret_key = hildon_sort_dialog_get_sort_key(sort_dialog); - fail_if(ret_key != -1, - "hildon-sort-dialog: Set sort key to 5 when the list of keys is empty, then retrieved current sort key and result was %d instead of -1", - ret_key); - - hildon_sort_dialog_add_sort_key(sort_dialog, SORT_KEY_0); - hildon_sort_dialog_add_sort_key(sort_dialog, SORT_KEY_1); - hildon_sort_dialog_add_sort_key(sort_dialog, SORT_KEY_2); - - /* Test2: Set negative key lower than -1 */ - hildon_sort_dialog_set_sort_key(sort_dialog, 1); - hildon_sort_dialog_set_sort_key(sort_dialog, -3); - ret_key = hildon_sort_dialog_get_sort_key(sort_dialog); - fail_if(ret_key != 1, - "hildon-sort-dialog: Set sort key to 1 when list of keys has 3 elements, then set sort key again to an invalid value of -3, then retrieved current sort key and result was %d instead of 1", - ret_key); - - /* Test3: Set of a positive key outside the range of a non empty key list */ - hildon_sort_dialog_set_sort_key(sort_dialog, 8); - ret_key = hildon_sort_dialog_get_sort_key(sort_dialog); - fail_if(ret_key != -1, - "hildon-sort-dialog: Set sort key to 8 when the list of keys has 3 elements, then retrieved current sort key and result was %d instead of -1", - ret_key); - - /* This test breaks, because after setting an invalid positive value, get_sort_key returns -1 instead of - the last valid value set. I considered this an error because it does not the same when the invalid index is - negative (in that case it preserves the last valid index set) */ - hildon_sort_dialog_set_sort_key(sort_dialog, 1); - hildon_sort_dialog_set_sort_key(sort_dialog, 8); - ret_key = hildon_sort_dialog_get_sort_key(sort_dialog); - /* fail_if(ret_key != 1, - "hildon-sort-dialog: Set sort key to 1 when the list of keys has 3 elements, then set sort key again to an invalid index value of 8, then retrieved current sort key and result was %d instead of 1", - ret_key); - */ - fail_if(ret_key != -1, - "hildon-sort-dialog: Set sort key to 1 when the list of keys has 3 elements, then set sort key again to an invalid index value of 8, then retrieved current sort key and result was %d instead of 1", - ret_key); - - /* Test4: Add duplicated key */ - hildon_sort_dialog_add_sort_key(sort_dialog, SORT_KEY_0); - hildon_sort_dialog_set_sort_key(sort_dialog, 3); - ret_key = hildon_sort_dialog_get_sort_key(sort_dialog); - fail_if(ret_key != 3, - "hildon-sort-dialog: Addition of duplicated sort keys is allowed."); - - /* Test5: Add NULL key */ - hildon_sort_dialog_add_sort_key(sort_dialog, NULL); - hildon_sort_dialog_set_sort_key(sort_dialog, 4); - ret_key = hildon_sort_dialog_get_sort_key(sort_dialog); - fail_if(ret_key == 4, - "hildon-sort-dialog: Addition of NULL sort key is allowed."); - - /* Test6: add key to a NULL object */ - hildon_sort_dialog_add_sort_key(NULL, SORT_KEY_0); - - /* Test7: set key in a NULL object */ - hildon_sort_dialog_set_sort_key(NULL, 0); - - /* Test8: get key in a NULL object */ - hildon_sort_dialog_get_sort_key(NULL); -} -END_TEST - -/* ---------- Suite creation ---------- */ - -Suite *create_hildon_sort_dialog_suite() -{ - /* Create the suite */ - Suite *s = suite_create("HildonSortDialog"); - - /* Create test cases */ - TCase *tc1 = tcase_create("add_get_set_sort_key"); - - /* Create test case for adding, getting and setting a sort key and add it to the suite */ - tcase_add_checked_fixture(tc1, fx_setup_default_sort_dialog, fx_teardown_default_sort_dialog); - tcase_add_test(tc1, test_add_set_get_sort_key_regular); - tcase_add_test(tc1, test_add_set_get_sort_key_limits); - tcase_add_test(tc1, test_add_set_get_sort_key_invalid); - suite_add_tcase (s, tc1); - - /* Return created suite */ - return s; -} - - diff --git a/tests/check-hildon-time-editor.c b/tests/check-hildon-time-editor.c deleted file mode 100644 index 26a6a7a..0000000 --- a/tests/check-hildon-time-editor.c +++ /dev/null @@ -1,1423 +0,0 @@ -/* - * This file is a part of hildon tests - * - * Copyright (C) 2006, 2007 Nokia Corporation, all rights reserved. - * - * Contact: Michael Dominic Kostrzewa <michael.kostrzewa@nokia.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; version 2.1 of - * the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA - * - */ - -#include <stdlib.h> -#include <check.h> -#include <gtk/gtkmain.h> -#include <gtk/gtkhbox.h> -#include <gtk/gtkcontainer.h> -#include "test_suites.h" -#include "check_utils.h" - -#include <unistd.h> - -#include <hildon/hildon-time-editor.h> - -#define MIN_DURATION 0 -#define MAX_DURATION 359999 - -/* -------------------- Fixtures -------------------- */ - -static GtkWidget *showed_window = NULL; -/* static HildonTimeEditor *time_editor = NULL; */ - -static void -fx_setup_default_time_editor () -{ - int argc = 0; - - gtk_init(&argc, NULL); - - showed_window = create_test_window (); -} - -static void -fx_teardown_default_time_editor () -{ - /* Destroy the window */ - gtk_widget_destroy (showed_window); -} - -static HildonTimeEditor *create_and_show_time_editor(GtkWidget *window, gboolean seconds,gboolean duration) -{ - HildonTimeEditor *time_editor = NULL; - - time_editor = HILDON_TIME_EDITOR(hildon_time_editor_new()); - - hildon_time_editor_set_show_seconds(time_editor,seconds); - hildon_time_editor_set_duration_mode(time_editor,duration); - - /* Add some widgets to the window and displays the window */ - gtk_container_add (GTK_CONTAINER (window), GTK_WIDGET(time_editor)); - show_all_test_window (window); - - hildon_time_editor_set_duration_mode(time_editor,duration); - - fail_if( !HILDON_IS_TIME_EDITOR(time_editor),"hildon-time-editor: Creation failed."); - return time_editor; -} - -static void remove_and_destroy_time_editor(GtkWidget *window,HildonTimeEditor ** time_editor) -{ - - gtk_container_remove (GTK_CONTAINER (window), GTK_WIDGET(*time_editor)); - gtk_widget_hide_all (window); - -} - -/* -------------------- Test cases -------------------- */ - -/* ----- Test case for set_time -----*/ - -/** - * Purpose: Check that regular time values are set and get properly - * Cases considered: - * - Set and get time to 5h 30m using time editor object. - * - Set and get time to 18h 2m using time editor object. - * - Set and get time to 5h 30m 45s using time editor object. - * - Set and get time to 18h 2m 5s using time editor object. - * - Set and get time to 5:30:45 using time editor object with duration mode. - * - Set and get time to 50:40:30 using time editor object with duration mode. - */ -START_TEST (test_set_time_regular) -{ - guint initial_hours; - guint initial_minutes; - guint initial_seconds; - guint hours; - guint minutes; - guint seconds; - HildonTimeEditor *time_editor = NULL; - - /* Test 1: Set time value to 5h 30m 0s to test time (am) without seconds */ - initial_hours=5; - initial_minutes=30; - initial_seconds=0; - - time_editor = create_and_show_time_editor(showed_window,FALSE,FALSE); - - hildon_time_editor_set_time(time_editor,initial_hours,initial_minutes,initial_seconds); - - hildon_time_editor_get_time(time_editor,&hours,&minutes,&seconds); - fail_if((hours != initial_hours) || (minutes != initial_minutes) || (seconds != initial_seconds), - "hildon-time-editor: set_time or get_time failed with values (%dh %dm). Result values are: (%dh %dm)", - initial_hours,initial_minutes,hours,minutes); - - remove_and_destroy_time_editor(showed_window,&time_editor); - - - /* Test 2: Set time value to 18h 2m 0s to test time (pm) without seconds*/ - initial_hours=18; - initial_minutes=2; - initial_seconds=0; - - time_editor = create_and_show_time_editor(showed_window,FALSE,FALSE); - - hildon_time_editor_set_time(time_editor,initial_hours,initial_minutes,initial_seconds); - - hildon_time_editor_get_time(time_editor,&hours,&minutes,&seconds); - - fail_if((hours != initial_hours) || (minutes != initial_minutes) || (seconds != initial_seconds), - "hildon-time-editor: set_time or get_time failed with values (%dh %dm). Result values are: (%dh %dm)", - initial_hours,initial_minutes,hours,minutes); - - remove_and_destroy_time_editor(showed_window,&time_editor); - - - /* Test 3: Set time value to 5h 30m 45s to test time (am) with seconds*/ - initial_hours=5; - initial_minutes=30; - initial_seconds=45; - - time_editor = create_and_show_time_editor(showed_window,TRUE,FALSE); - - hildon_time_editor_set_time(time_editor,initial_hours,initial_minutes,initial_seconds); - - hildon_time_editor_get_time(time_editor,&hours,&minutes,&seconds); - - fail_if((hours != initial_hours) || (minutes != initial_minutes) || (seconds != initial_seconds), - "hildon-time-editor: set_time or get_time failed with values (%dh %dm %ds). Result values are: (%dh %dm %ds)", - initial_hours,initial_minutes,initial_seconds,hours,minutes,seconds); - - remove_and_destroy_time_editor(showed_window,&time_editor); - - /* Test 4: Set time value to 18h 2m 5s to test time (pm) with seconds */ - initial_hours=18; - initial_minutes=2; - initial_seconds=5; - - - time_editor = create_and_show_time_editor(showed_window,TRUE,FALSE); - - hildon_time_editor_set_time(time_editor,initial_hours,initial_minutes,initial_seconds); - - hildon_time_editor_get_time(time_editor,&hours,&minutes,&seconds); - - fail_if((hours != initial_hours) || (minutes != initial_minutes) || (seconds != initial_seconds), - "hildon-time-editor: set_time or get_time failed with values (%dh %dm %ds). Result values are: (%dh %dm %ds)", - initial_hours,initial_minutes,initial_seconds,hours,minutes,seconds); - - remove_and_destroy_time_editor(showed_window,&time_editor); - - - /* Test 5: Set time value to 5:30:45 to test duration*/ - initial_hours=5; - initial_minutes=30; - initial_seconds=45; - - time_editor = create_and_show_time_editor(showed_window,TRUE,TRUE); - hildon_time_editor_set_time(time_editor,initial_hours,initial_minutes,initial_seconds); - - hildon_time_editor_get_time(time_editor,&hours,&minutes,&seconds); - - - fail_if((hours != initial_hours) || (minutes != initial_minutes) || (seconds != initial_seconds), - "hildon-time-editor: set_time or get_time failed with values (%d:%d:%d). Result values are: (%d:%d:%d)", - initial_hours,initial_minutes,initial_seconds,hours,minutes,seconds); - - remove_and_destroy_time_editor(showed_window,&time_editor); - - /* Test 6: Set time value to 50:40:30 to test duration */ - initial_hours=50; - initial_minutes=40; - initial_seconds=30; - - time_editor = create_and_show_time_editor(showed_window,TRUE,TRUE); - - hildon_time_editor_set_time(time_editor,initial_hours,initial_minutes,initial_seconds); - - hildon_time_editor_get_time(time_editor,&hours,&minutes,&seconds); - - fail_if((hours != initial_hours) || (minutes != initial_minutes) || (seconds != initial_seconds), - "hildon-time-editor: set_time or get_time failed with values (%d:%d:%d). Result values are: (%d:%d:%d)", - initial_hours,initial_minutes,initial_seconds,hours,minutes,seconds); - - remove_and_destroy_time_editor(showed_window,&time_editor); - - -} -END_TEST - -/** - * Purpose: Check that limit time values are set and get properly - * Cases considered: - * - Set and get time to 0h 0m using time editor object. - * - Set and get time to 23h 59m using time editor object. - * - Set and get time to 23h 59m 59s using time editor object. - * - Set and get time to 0h 59m 59s using time editor object. - * - Set and get time to 99:59:59 using time editor object on duration mode. - * - Set and get time to 0:0:0 using time editor object on duration mode. - */ -START_TEST (test_set_time_limits) -{ - guint initial_hours; - guint initial_minutes; - guint initial_seconds; - guint hours; - guint minutes; - guint seconds; - HildonTimeEditor *time_editor = NULL; - - /* Test 1: Set time value to 00h 00m 00s to test time (am) without seconds*/ - initial_hours=0; - initial_minutes=0; - initial_seconds=0; - - time_editor = create_and_show_time_editor(showed_window,FALSE,FALSE); - - hildon_time_editor_set_time(time_editor,initial_hours,initial_minutes,initial_seconds); - - hildon_time_editor_get_time(time_editor,&hours,&minutes,&seconds); - - fail_if((hours != initial_hours) || (minutes != initial_minutes) || (seconds != initial_seconds), - "hildon-time-editor: set_time or get_time failed with values (%dh %dm). Result values are: (%dh %dm)", - initial_hours,initial_minutes,hours,minutes); - - remove_and_destroy_time_editor(showed_window,&time_editor); - - /* Test 2: Set time value to 23h 59m 0s to test time (pm) without seconds*/ - initial_hours=23; - initial_minutes=59; - initial_seconds=0; - - time_editor = create_and_show_time_editor(showed_window,FALSE,FALSE); - - hildon_time_editor_set_time(time_editor,initial_hours,initial_minutes,initial_seconds); - - hildon_time_editor_get_time(time_editor,&hours,&minutes,&seconds); - - fail_if((hours != initial_hours) || (minutes != initial_minutes) || (seconds != initial_seconds), - "hildon-time-editor: set_time or get_time failed with values (%dh %dm). Result values are: (%dh %dm)", - initial_hours,initial_minutes,hours,minutes); - - remove_and_destroy_time_editor(showed_window,&time_editor); - - /* Test 3: Set time value to 23h 59m 59s to test time (am) with seconds*/ - initial_hours=23; - initial_minutes=59; - initial_seconds=59; - - time_editor = create_and_show_time_editor(showed_window,TRUE,FALSE); - - hildon_time_editor_set_time(time_editor,initial_hours,initial_minutes,initial_seconds); - - hildon_time_editor_get_time(time_editor,&hours,&minutes,&seconds); - - fail_if((hours != initial_hours) || (minutes != initial_minutes) || (seconds != initial_seconds), - "hildon-time-editor: set_time or get_time failed with values (%dh %dm %ds). Result values are: (%dh %dm %ds)", - initial_hours,initial_minutes,initial_seconds,hours,minutes,seconds); - - remove_and_destroy_time_editor(showed_window,&time_editor); - - /* Test 4: Set time value to 0h 59m 59s to test time (am) with seconds */ - initial_hours=0; - initial_minutes=59; - initial_seconds=59; - time_editor = create_and_show_time_editor(showed_window,TRUE,FALSE); - - hildon_time_editor_set_time(time_editor,initial_hours,initial_minutes,initial_seconds); - - hildon_time_editor_get_time(time_editor,&hours,&minutes,&seconds); - - fail_if((hours != initial_hours) || (minutes != initial_minutes) || (seconds != initial_seconds), - "hildon-time-editor: set_time or get_time failed with values (%dh %dm %ds). Result values are: (%dh %dm %ds)", - initial_hours,initial_minutes,initial_seconds,hours,minutes,seconds); - - remove_and_destroy_time_editor(showed_window,&time_editor); - - /* Test 5: Set time value to 99:59:59 to test with duration mode */ - initial_hours=99; - initial_minutes=59; - initial_seconds=59; - time_editor = create_and_show_time_editor(showed_window,TRUE,TRUE); - - hildon_time_editor_set_time(time_editor,initial_hours,initial_minutes,initial_seconds); - - hildon_time_editor_get_time(time_editor,&hours,&minutes,&seconds); - - fail_if((hours != initial_hours) || (minutes != initial_minutes) || (seconds != initial_seconds), - "hildon-time-editor: set_time or get_time failed with values (%dh %dm %ds). Result values are: (%dh %dm %ds)", - initial_hours,initial_minutes,initial_seconds,hours,minutes,seconds); - - remove_and_destroy_time_editor(showed_window,&time_editor); - - /* Test 6: Set time value to 0:0:0 to test with duration mode */ - initial_hours=0; - initial_minutes=0; - initial_seconds=0; - - time_editor = create_and_show_time_editor(showed_window,FALSE,TRUE); - - hildon_time_editor_set_time(time_editor,initial_hours,initial_minutes,initial_seconds); - - hildon_time_editor_get_time(time_editor,&hours,&minutes,&seconds); - - fail_if((hours != initial_hours) || (minutes != initial_minutes) || (seconds != initial_seconds), - "hildon-time-editor: set_time or get_time failed with values (%dh %dm %ds). Result values are: (%dh %dm %ds)", - initial_hours,initial_minutes,initial_seconds,hours,minutes,seconds); - - remove_and_destroy_time_editor(showed_window,&time_editor); - - -} -END_TEST - -/** - * Purpose: Check that invalid time values are set and get properly - * Cases considered: - * - Set NULL the editor time object. - * - Test NULL (time object) on get_time - * - Set and get time to 0h 60m using time editor object. - * - Set and get time to 0h 0m 60s using time editor object. - * - Set and get time to 24h 60m 60s using time editor object. - * - Set and get time to 50h 100m 100s using time editor object. - * - Set and get time to 0:80:80 using time editor object. - * - Set and get time to 110:80:80 using time editor object. - */ -START_TEST (test_set_time_invalid) -{ - guint initial_hours; - guint initial_minutes; - guint initial_seconds; - guint expected_hours; - guint expected_minutes; - guint expected_seconds; - guint hours; - guint minutes; - guint seconds; - HildonTimeEditor *time_editor = NULL; - - /* Initialization to test 1, test 2 and test 3*/ - initial_hours=0; - initial_minutes=60; - initial_seconds=0; - expected_hours=1; - expected_minutes=0; - expected_seconds=0; - - /* Test 1: Set NULL (set_time) */ - hildon_time_editor_set_time (NULL,initial_hours,initial_minutes,initial_seconds); - - /* Test 2: Set NULL (get_time) */ - hildon_time_editor_get_time(NULL,&hours,&minutes,&seconds); - - /* Test 3: Set time value to 00h 60m 00s to test time (am) without seconds and expect the correct value 01h 00m 00s */ - - time_editor = create_and_show_time_editor(showed_window,FALSE,FALSE); - - hildon_time_editor_set_time(time_editor,initial_hours,initial_minutes,initial_seconds); - - hildon_time_editor_get_time(time_editor,&hours,&minutes,&seconds); - - remove_and_destroy_time_editor(showed_window,&time_editor); - - fail_if((expected_hours != hours) || (expected_minutes != minutes) || (expected_seconds != seconds), - "hildon-time-editor: set_time/get_time failed with (%dh %dm). Result values are (%dh %dm) and expected values are (%dh %dm)", - initial_hours,initial_minutes,hours,minutes,expected_hours,expected_minutes); - - /* Test 4: Set time value to 0h 0m 60s to test time (pm) without seconds and expect the correct value 00h 01m 00s*/ - initial_hours=0; - initial_minutes=0; - initial_seconds=60; - expected_hours=0; - expected_minutes=1; - expected_seconds=0; - - time_editor = create_and_show_time_editor(showed_window,FALSE,TRUE); - - hildon_time_editor_set_time(time_editor,initial_hours,initial_minutes,initial_seconds); - - hildon_time_editor_get_time(time_editor,&hours,&minutes,&seconds); - - fail_if((expected_hours != hours) || (expected_minutes != minutes) || (expected_seconds != seconds), - "hildon-time-editor: set_time/get_time failed with (%dh %dm %ds). Result values are (%dh %dm %ds) and expected values are (%dh %dm %ds)", - initial_hours,initial_minutes,initial_seconds,hours,minutes,seconds,expected_hours,expected_minutes,expected_seconds); - - remove_and_destroy_time_editor(showed_window,&time_editor); - - /* Test 5: Set time value to 24h 60m 60s to test time (am) with seconds*/ - initial_hours=24; - initial_minutes=60; - initial_seconds=60; - expected_hours=23; - expected_minutes=1; - expected_seconds=0; - - time_editor = create_and_show_time_editor(showed_window,TRUE,FALSE); - - hildon_time_editor_set_time(time_editor,initial_hours,initial_minutes,initial_seconds); - - hildon_time_editor_get_time(time_editor,&hours,&minutes,&seconds); - - fail_if((expected_hours != hours) || (expected_minutes != minutes) || (expected_seconds != seconds), - "hildon-time-editor: set_time/get_time failed with values (%dh %dm %ds). Result values are (%dh %dm %ds) and expected values are (%dh %dm %ds)", - initial_hours,initial_minutes,initial_seconds,hours,minutes,seconds,expected_hours,expected_minutes,expected_seconds); - - remove_and_destroy_time_editor(showed_window,&time_editor); - - /* Test 6: Set time value to 50h 100m 100s to test time (am) with seconds */ - initial_hours=50; - initial_minutes=100; - initial_seconds=100; - expected_hours=23; - expected_minutes=41; - expected_seconds=40; - - time_editor = create_and_show_time_editor(showed_window,TRUE,FALSE); - - hildon_time_editor_set_time(time_editor,initial_hours,initial_minutes,initial_seconds); - - hildon_time_editor_get_time(time_editor,&hours,&minutes,&seconds); - - fail_if((expected_hours != hours) || (expected_minutes != minutes) || (expected_seconds != seconds), - "hildon-time-editor: set_time/get_time failed with values (%d:%dm:%ds). Result values are (%d:%dm:%ds) and expected values are (%d:%dm:%ds)", - initial_hours,initial_minutes,initial_seconds,hours,minutes,seconds,expected_hours,expected_minutes,expected_seconds); - - remove_and_destroy_time_editor(showed_window,&time_editor); - - - /* Test 7: Set time value to 0:80:80 to test with duration mode */ - initial_hours=0; - initial_minutes=80; - initial_seconds=80; - expected_hours=1; - expected_minutes=21; - expected_seconds=20; - - time_editor = create_and_show_time_editor(showed_window,TRUE,TRUE); - - hildon_time_editor_set_time(time_editor,initial_hours,initial_minutes,initial_seconds); - - hildon_time_editor_get_time(time_editor,&hours,&minutes,&seconds); - - fail_if((expected_hours != hours) || (expected_minutes != minutes) || (expected_seconds != seconds), - "hildon-time-editor: set_time/get_time failed with values (%d:%d:%d). Result values are (%d:%d:%d) and expected values are (%d:%d:%d)", - initial_hours,initial_minutes,initial_seconds,hours,minutes,seconds,expected_hours,expected_minutes,expected_seconds); - - remove_and_destroy_time_editor(showed_window,&time_editor); - - /* Test 8: Set time value to 110:80:80 to test with duration mode */ - initial_hours=110; - initial_minutes=80; - initial_seconds=80; - expected_hours=99; - expected_minutes=59; - expected_seconds=59; - - time_editor = create_and_show_time_editor(showed_window,TRUE,TRUE); - - hildon_time_editor_set_time(time_editor,initial_hours,initial_minutes,initial_seconds); - - hildon_time_editor_get_time(time_editor,&hours,&minutes,&seconds); - - - fail_if((expected_hours != hours) || (expected_minutes != minutes) || (expected_seconds != seconds), - "hildon-time-editor: set_time/get_time failed with values (%d:%d:%d). Result values are (%d:%d:%d) and expected values are (%d:%d:%d)", - initial_hours,initial_minutes,initial_seconds,hours,minutes,seconds,expected_hours,expected_minutes,expected_seconds); - - remove_and_destroy_time_editor(showed_window,&time_editor); - -} -END_TEST - - -/* ----- Test case for set_ticks -----*/ - -/** - * Purpose: Check that regular ticks values are set and get properly - * Cases considered: - * - Set and get ticks to 45660s using time editor object with time mode. - * - Set and get ticks to 124860s using time editor object with duration mode. - */ -START_TEST (test_set_ticks_regular) -{ - guint initial_ticks; - guint ticks; - HildonTimeEditor *time_editor = NULL; - - /* Test 1: Set tick to 45660 seconds to test set_ticks */ - - initial_ticks=45660; - time_editor = create_and_show_time_editor(showed_window,FALSE,FALSE); - - hildon_time_editor_set_ticks(time_editor,initial_ticks); - - ticks = hildon_time_editor_get_ticks(time_editor); - - fail_if(( initial_ticks!=ticks ), - "hildon-time-editor: set_ticks or get_ticks failed with %d. Expected result is %d",initial_ticks,ticks); - - remove_and_destroy_time_editor(showed_window,&time_editor); - - - /* Test 2: Set tick to 124860 seconds to test set_ticks */ - - initial_ticks=124860; - - time_editor = create_and_show_time_editor(showed_window,FALSE,TRUE); - - hildon_time_editor_set_ticks(time_editor,initial_ticks); - - ticks = hildon_time_editor_get_ticks(time_editor); - - fail_if(( initial_ticks!=ticks ), - "hildon-time-editor: set_ticks or get_ticks failed with %d. Expected result is %d",initial_ticks,ticks); - - remove_and_destroy_time_editor(showed_window,&time_editor); - -} -END_TEST - -/** - * Purpose: Check that limit ticks values are set and get properly - * Cases considered: - * - Set and get ticks to 0s using time editor object with time mode. - * - Set and get ticks to 86399s using time editor object with time mode. 86399 seconds are 23h 59m 59s. - * - Set and get ticks to 0s using time editor object with duration mode. - * - Set and get ticks to 359999s using time editor object with duration mode. 359999 seconds are 99:59:59. - */ -START_TEST (test_set_ticks_limits) -{ - guint initial_ticks; - guint ticks; - HildonTimeEditor *time_editor = NULL; - - /* Test 1: Set ticks to 0 seconds to test set_ticks with */ - - initial_ticks=0; - time_editor = create_and_show_time_editor(showed_window,FALSE,FALSE); - - hildon_time_editor_set_ticks(time_editor,initial_ticks); - - ticks = hildon_time_editor_get_ticks(time_editor); - - fail_if(( initial_ticks!=ticks ), - "hildon-time-editor: set_ticks or get_ticks failed with %d. Expected result is %d",initial_ticks,ticks); - - remove_and_destroy_time_editor(showed_window,&time_editor); - - /* Test 2: Set ticks to 86399 seconds to test set_ticks */ - initial_ticks=86399; - time_editor = create_and_show_time_editor(showed_window,TRUE,FALSE); - - hildon_time_editor_set_ticks(time_editor,initial_ticks); - - ticks = hildon_time_editor_get_ticks(time_editor); - - fail_if(( initial_ticks!=ticks ), - "hildon-time-editor: set_ticks or get_ticks failed with %d. Expected result is %d",initial_ticks,ticks); - - remove_and_destroy_time_editor(showed_window,&time_editor); - - - /* Test 3: Set ticks to 0 seconds to test set_ticks */ - - initial_ticks=0; - time_editor = create_and_show_time_editor(showed_window,FALSE,TRUE); - - hildon_time_editor_set_ticks(time_editor,initial_ticks); - - ticks = hildon_time_editor_get_ticks(time_editor); - - fail_if(( initial_ticks!=ticks ), - "hildon-time-editor: set_ticks or get_ticks failed with %d. Expected result is %d",initial_ticks,ticks); - - remove_and_destroy_time_editor(showed_window,&time_editor); - - /* Test 4: Set ticks to 359999 seconds to test set_ticks */ - - initial_ticks=359999; - time_editor = create_and_show_time_editor(showed_window,TRUE,TRUE); - - hildon_time_editor_set_ticks(time_editor,initial_ticks); - - ticks = hildon_time_editor_get_ticks(time_editor); - - fail_if(( initial_ticks!=ticks ), - "hildon-time-editor: set_ticks or get_ticks failed with %d. Expected result is %d",initial_ticks,ticks); - remove_and_destroy_time_editor(showed_window,&time_editor); - -} -END_TEST - -/** - * Purpose: Check that invalid ticks values are set and get properly. In this tests we'll test several invalid - * values with the same case because the "mod" operator will define the time set. - * Cases considered: - * - Set and get ticks to 86400s using time editor object with time mode. 86399 seconds are 23h 59m 59s. - * - Set and get ticks to 360000s using time editor object with time mode. - * - Set and get ticks to 90060s using time editor object with time. - * - Set and get ticks to 360000s using time editor object with duration mode. 359999 seconds are 99:59:59. - * - Set and get ticks to 654333s using time editor object with duration mode. - * - Set ticks on NULL object. - */ -START_TEST (test_set_ticks_invalid) -{ - guint initial_ticks; - guint expected_ticks; - guint ticks; - HildonTimeEditor *time_editor = NULL; - - initial_ticks=86400; - expected_ticks=82800; - - /* Test 1: Set ticks to 86400 seconds to test set_ticks */ - time_editor = create_and_show_time_editor(showed_window,TRUE,FALSE); - - hildon_time_editor_set_ticks(time_editor,initial_ticks); - - ticks = hildon_time_editor_get_ticks(time_editor); - - fail_if(( expected_ticks!=ticks ), - "hildon-time-editor: set_ticks or get_ticks failed with %d. Expected result is %d and result is %d", - initial_ticks,expected_ticks,ticks); - - remove_and_destroy_time_editor(showed_window,&time_editor); - - /* Test 2: Set ticks to 360000 seconds to test set_ticks */ - initial_ticks=360001; - expected_ticks=82801; - - time_editor = create_and_show_time_editor(showed_window,TRUE,FALSE); - - hildon_time_editor_set_ticks(time_editor,initial_ticks); - - ticks = hildon_time_editor_get_ticks(time_editor); - - fail_if(( expected_ticks!=ticks ), - "hildon-time-editor: set_ticks or get_ticks failed with %d. Expected result is %d and result is %d", - initial_ticks,expected_ticks,ticks); - - remove_and_destroy_time_editor(showed_window,&time_editor); - - /* Test 3: Set ticks to 90060 seconds to test set_ticks */ - initial_ticks=90060; - expected_ticks=82860; - - time_editor = create_and_show_time_editor(showed_window,TRUE,FALSE); - - hildon_time_editor_set_ticks(time_editor,initial_ticks); - - ticks = hildon_time_editor_get_ticks(time_editor); - - fail_if(( expected_ticks!=ticks ), - "hildon-time-editor: set_ticks or get_ticks failed with %d. Expected result is %d and result is %d", - initial_ticks,expected_ticks,ticks); - - remove_and_destroy_time_editor(showed_window,&time_editor); - - /* Test 4: Set ticks to 360000 seconds to test set_ticks */ - - initial_ticks=360000; - expected_ticks=359999; - - time_editor = create_and_show_time_editor(showed_window,TRUE,TRUE); - - hildon_time_editor_set_ticks(time_editor,initial_ticks); - - ticks = hildon_time_editor_get_ticks(time_editor); - - fail_if(( expected_ticks!=ticks ), - "hildon-time-editor: set_ticks or get_ticks failed with %d. Expected result is %d and result is %d", - initial_ticks,expected_ticks,ticks); - - remove_and_destroy_time_editor(showed_window,&time_editor); - - /* Test 5: Set ticks to 654333 seconds to test set_ticks */ - - initial_ticks=654333; - expected_ticks=359999; - - time_editor = create_and_show_time_editor(showed_window,TRUE,TRUE); - - hildon_time_editor_set_ticks(time_editor,initial_ticks); - - ticks = hildon_time_editor_get_ticks(time_editor); - - fail_if(( expected_ticks!=ticks ), - "hildon-time-editor: set_ticks or get_ticks failed with %d. Expected result is %d and result is %d", - initial_ticks,expected_ticks,ticks); - - remove_and_destroy_time_editor(showed_window,&time_editor); - - /* Test 6: Set initial_ticks on NULL */ - hildon_time_editor_set_ticks(NULL,initial_ticks); -} -END_TEST - - -/* ----- Test case for set_duration_min_set_duration_max -----*/ - -/** - * Purpose: Check that regular minimum/maximum values are set/get properly and check that set_duration_mode works well, - * because min and max can not be set without duration mode set. - * Cases considered: - * - Set and get minimum duration to 100000 having ticks under 100000 using time editor object with duration mode. - * - Set and get minimum duration to 100000 having ticks over 100000 using time editor object with duration mode. - * - Set and get maximum duration to 200000 having ticks under 200000 using time editor object with duration mode. - * - Set and get maximum duration to 200000 having ticks over 200000 using time editor object with duration mode. - */ -START_TEST (test_set_duration_min_set_duration_max_regular) -{ - guint initial_duration_min; - guint duration_min; - guint initial_duration_max; - guint duration_max; - guint expected_ticks; - guint ticks; - HildonTimeEditor *time_editor = NULL; - - time_editor = create_and_show_time_editor(showed_window,FALSE,TRUE); - /* Initialize values in order to avoid side effects from previous tests */ - hildon_time_editor_set_duration_min(time_editor,MIN_DURATION); - hildon_time_editor_set_duration_max(time_editor,MAX_DURATION); - - /* set_min tests*/ - - /* Test 1: Set and get minimum duration to 100000 having ticks under 100000 using time editor object with duration mode. */ - initial_duration_min=100000; - expected_ticks=initial_duration_min; - - hildon_time_editor_set_ticks(time_editor,initial_duration_min-1000); - hildon_time_editor_set_duration_min(time_editor,initial_duration_min); - duration_min = hildon_time_editor_get_duration_min(time_editor); - ticks = hildon_time_editor_get_ticks(time_editor); - - fail_if(( initial_duration_min!=duration_min) | (ticks!=expected_ticks), - "hildon-time-editor: set_duration_min or get_duration_min failed with %d. Expected result is %d. Set ticks to %d, expected ticks are %d and result is %d", - initial_duration_min,duration_min,initial_duration_min-1000,expected_ticks,ticks); - - remove_and_destroy_time_editor(showed_window,&time_editor); - - /* Test 2: Set and get minimum duration to 100000 having ticks over 100000 using time editor object with duration mode.*/ - initial_duration_min=100000; - expected_ticks=initial_duration_min+980; - - time_editor = create_and_show_time_editor(showed_window,FALSE,TRUE); - - hildon_time_editor_set_ticks(time_editor,expected_ticks); - hildon_time_editor_set_duration_min(time_editor,initial_duration_min); - duration_min = hildon_time_editor_get_duration_min(time_editor); - ticks = hildon_time_editor_get_ticks(time_editor); - - fail_if(( initial_duration_min!=duration_min) | (ticks!=expected_ticks), - "hildon-time-editor: set_duration_min or get_duration_min failed with %d. Expected result is %d. Set ticks to %d and result is %d", - initial_duration_min,duration_min,ticks,expected_ticks); - - remove_and_destroy_time_editor(showed_window,&time_editor); - - - - /* Test 3: Set and get maximum duration to 200000 having ticks under 200000 using time editor object with duration mode. */ - initial_duration_max=200000; - expected_ticks=initial_duration_max-1040; - time_editor = create_and_show_time_editor(showed_window,FALSE,TRUE); - - hildon_time_editor_set_ticks(time_editor,expected_ticks); - hildon_time_editor_set_duration_max(time_editor,initial_duration_max); - duration_max = hildon_time_editor_get_duration_max(time_editor); - ticks = hildon_time_editor_get_ticks(time_editor); - - fail_if(( initial_duration_max!=duration_max) | (ticks!=expected_ticks), - "hildon-time-editor: set_duration_max or get_duration_max failed with %d. Expected result is %d. Set ticks to %d and result is %d", - initial_duration_max,duration_max,ticks,expected_ticks); - - remove_and_destroy_time_editor(showed_window,&time_editor); - - /* Test 4: Set and get maximum duration to 200000 having ticks over 200000 using time editor object with duration mode.*/ - initial_duration_max=200000; - expected_ticks=initial_duration_max+1000; - time_editor = create_and_show_time_editor(showed_window,FALSE,TRUE); - - hildon_time_editor_set_ticks(time_editor,expected_ticks); - hildon_time_editor_set_duration_max(time_editor,initial_duration_max); - duration_max = hildon_time_editor_get_duration_max(time_editor); - ticks = hildon_time_editor_get_ticks(time_editor); - - fail_if(( initial_duration_max!=duration_max) | (ticks!=initial_duration_max), - "hildon-time-editor: set_duration_max or get_duration_max failed with %d. Expected result is %d. Set ticks to %d, expected result is %d and result is %d", - initial_duration_max,duration_max,expected_ticks,initial_duration_max,ticks); - - remove_and_destroy_time_editor(showed_window,&time_editor); - -} -END_TEST - - -/** - * Purpose: Check that limits duration minimum/maximum values are set and get properly. - * Cases considered: - * - Set and get minimum duration to MIN_DURATION having ticks over MIN_DURATION using time editor object with duration mode. - * - Set and get maximum duration to MAX_DURATION having ticks under MAX_DURATION. - * using time editor object with duration mode. 359940 seconds are 99:59:00. - * - Set and get maximum duration to MIN_DURATION having ticks over MIN_DURATION using time editor object with duration mode. - * - Set and get minimum duration to MAX_DURATION having ticks under MAX_DURATION. - * using time editor object with duration mode. 359999 seconds are 99:59:59. - */ -START_TEST (test_set_duration_min_set_duration_max_limits) -{ - guint initial_duration_min; - guint duration_min; - guint initial_duration_max; - guint duration_max; - guint expected_ticks; - guint ticks; - HildonTimeEditor *time_editor = NULL; - - - /* Test 1: Set minimum duration to MAX_DURATION seconds having ticks under MAX_DURATION. */ - expected_ticks=MIN_DURATION+1; - initial_duration_min=MIN_DURATION; - - time_editor = create_and_show_time_editor(showed_window,TRUE,TRUE); - - hildon_time_editor_set_ticks(time_editor,expected_ticks); - hildon_time_editor_set_duration_min(time_editor,initial_duration_min); - duration_min = hildon_time_editor_get_duration_min(time_editor); - ticks = hildon_time_editor_get_ticks(time_editor); - - fail_if(( initial_duration_min!=duration_min) | (ticks!=expected_ticks), - "hildon-time-editor: set_duration_min or get_duration_min failed with %d. Expected result is %d. Set ticks to %d and result is %d", - initial_duration_min,duration_min,expected_ticks,ticks); - - remove_and_destroy_time_editor(showed_window,&time_editor); - - /* Test 2: Set maximum duration to MAX_DURATION seconds having ticks under MAX_DURATION. */ - expected_ticks=MAX_DURATION-59; - initial_duration_max=MAX_DURATION; - - time_editor = create_and_show_time_editor(showed_window,TRUE,TRUE); - - hildon_time_editor_set_ticks(time_editor,expected_ticks); - hildon_time_editor_set_duration_max(time_editor,initial_duration_max); - duration_max = hildon_time_editor_get_duration_max(time_editor); - ticks = hildon_time_editor_get_ticks(time_editor); - - fail_if(( initial_duration_max!=duration_max) | (ticks!=expected_ticks), - "hildon-time-editor: set_duration_max or get_duration_max failed with %d. Expected result is %d. Set ticks to %d and result is %d", - initial_duration_max,duration_max,expected_ticks,ticks); - - remove_and_destroy_time_editor(showed_window,&time_editor); - - /* Test 3: Set and get maximum duration to MIN_DURATION having ticks over MIN_DURATION - using time editor object with duration mode. */ - expected_ticks=MIN_DURATION+1; - initial_duration_max=MIN_DURATION; - - time_editor = create_and_show_time_editor(showed_window,TRUE,TRUE); - - hildon_time_editor_set_ticks(time_editor,expected_ticks); - hildon_time_editor_set_duration_max(time_editor,initial_duration_max); - duration_max = hildon_time_editor_get_duration_max(time_editor); - ticks = hildon_time_editor_get_ticks(time_editor); - - fail_if(( initial_duration_max!=duration_max) | (ticks!=MIN_DURATION), - "hildon-time-editor: set_duration_max or get_duration_max failed with %d. Expected result is %d. Set ticks to %d and result is %d", - initial_duration_max,duration_max,expected_ticks,ticks); - - remove_and_destroy_time_editor(showed_window,&time_editor); - - /* Test 4: Set and get minimum duration to MIN_DURATION having ticks over MIN_DURATION - using time editor object with duration mode. */ - expected_ticks=MAX_DURATION-1; - initial_duration_min=MAX_DURATION; - - time_editor = create_and_show_time_editor(showed_window,TRUE,TRUE); - - hildon_time_editor_set_ticks(time_editor,expected_ticks); - hildon_time_editor_set_duration_min(time_editor,initial_duration_min); - duration_min = hildon_time_editor_get_duration_min(time_editor); - ticks = hildon_time_editor_get_ticks(time_editor); - - fail_if(( initial_duration_min!=duration_min) | (ticks!=MAX_DURATION), - "hildon-time-editor: set_duration_min or get_duration_min failed with %d. Expected result is %d. Set ticks to %d and result is %d", - initial_duration_min,duration_min,ticks,MAX_DURATION); - - remove_and_destroy_time_editor(showed_window,&time_editor); - -} -END_TEST - -/** - * Purpose: Check that invalid minimum/maximum duration values are set and get properly. - * Cases considered: - * - Set duration_min on NULL object. - * - Set and get minimum duration to MAX_DURATION+1 using time editor object with duration mode - * setting ticks previously with a value under MAX_DURATION. - * - Set and get minimum duration to MAX_DURATION+1 using time editor object with duration mode - * setting ticks previously with a value over MAX_DURATION. - * - Set duration_max on NULL object. - * - Set and get maximum duration to MAX_DURATION+1 using time editor object with duration mode - * setting ticks previously with a value under MAX_DURATION. - * - Set and get maximum duration to MAX_DURATION+1 using time editor object with duration mode - * setting ticks previously with a value over MAX_DURATION. - */ -START_TEST (test_set_duration_min_set_duration_max_invalid) -{ - guint initial_duration_min; - guint expected_duration_min; - guint duration_min; - guint initial_duration_max; - guint expected_duration_max; - guint duration_max; - guint expected_ticks; - guint ticks; - HildonTimeEditor *time_editor = NULL; - - - /* Test 1: Set minimum duration on NULL object */ - hildon_time_editor_set_duration_min(NULL,MIN_DURATION); - - /* Test 2: Set minimum duration to MAX_DURATION+1 seconds to test set_duration_min */ - initial_duration_min=MAX_DURATION+1; - expected_duration_min=MAX_DURATION+1; - expected_ticks=MAX_DURATION-1; - - time_editor = create_and_show_time_editor(showed_window,TRUE,TRUE); - - hildon_time_editor_set_ticks(time_editor,expected_ticks); - hildon_time_editor_set_duration_min(time_editor,initial_duration_min); - duration_min = hildon_time_editor_get_duration_min(time_editor); - ticks = hildon_time_editor_get_ticks(time_editor); - - fail_if(( expected_duration_min!=duration_min) | (ticks!=MAX_DURATION), - "hildon-time-editor: set_duration_min or get_duration_min failed with %d. Expected result is %d and result is %d. Set ticks to %d, expected result is %d and result is %d", - initial_duration_min,duration_min,expected_duration_min,expected_ticks,MAX_DURATION,ticks); - - remove_and_destroy_time_editor(showed_window,&time_editor); - - /* Test 3: Set minimum duration to MAX_DURATION+1 seconds to test set_duration_min */ - initial_duration_min=MAX_DURATION+1; - expected_duration_min=MAX_DURATION+1; - expected_ticks=MAX_DURATION+2; - - time_editor = create_and_show_time_editor(showed_window,TRUE,TRUE); - - hildon_time_editor_set_ticks(time_editor,expected_ticks); - hildon_time_editor_set_duration_min(time_editor,initial_duration_min); - duration_min = hildon_time_editor_get_duration_min(time_editor); - ticks = hildon_time_editor_get_ticks(time_editor); - - fail_if(( expected_duration_min!=duration_min) | (ticks!=MAX_DURATION), - "hildon-time-editor: set_duration_min or get_duration_min failed with %d. Expected result is %d and result is %d. Set ticks to %d, expected result is %d and result is %d", - initial_duration_min,duration_min,expected_duration_min,expected_ticks,MAX_DURATION,ticks); - - remove_and_destroy_time_editor(showed_window,&time_editor); - - /* Test 4: Set maximum duration on NULL object */ - hildon_time_editor_set_duration_max(NULL,MAX_DURATION); - - /* Test 5: Set maximum duration to MAX_DURATION+1 seconds to test set_duration_max settings ticks under MAX_DURATION*/ - initial_duration_max=MAX_DURATION+1; - expected_duration_max=MAX_DURATION; - expected_ticks=MAX_DURATION-59; - - time_editor = create_and_show_time_editor(showed_window,TRUE,TRUE); - - hildon_time_editor_set_ticks(time_editor,expected_ticks); - hildon_time_editor_set_duration_max(time_editor,initial_duration_max); - duration_max = hildon_time_editor_get_duration_max(time_editor); - ticks = hildon_time_editor_get_ticks(time_editor); - - fail_if(( expected_duration_max!=duration_max) | (ticks!=expected_ticks), - "hildon-time-editor: set_duration_max or get_duration_max failed with %d. Expected result is %d and result is %d. Set ticks to %d, expected result is %d and result is %d", - initial_duration_max,duration_max,expected_duration_max,expected_ticks,expected_ticks,ticks); - - remove_and_destroy_time_editor(showed_window,&time_editor); - - /* Initialize values in order to avoid side effects from previous tests */ - initial_duration_max=MAX_DURATION+1; - expected_duration_max=MAX_DURATION; - expected_ticks=MAX_DURATION+1; - - /* Test 6: Set maximum duration to MAX_DURATION+1 seconds to test set_duration_max setting ticks over MAX_DURATION */ - time_editor = create_and_show_time_editor(showed_window,TRUE,TRUE); - - hildon_time_editor_set_ticks(time_editor,expected_ticks); - hildon_time_editor_set_duration_max(time_editor,initial_duration_max); - duration_max = hildon_time_editor_get_duration_max(time_editor); - ticks = hildon_time_editor_get_ticks(time_editor); - fail_if(( expected_duration_max!=duration_max), - "hildon-time-editor: set_duration_max or get_duration_max failed with %d. Expected result is %d and result is %d. Set ticks to %d, expected result is %d and result is %d", - initial_duration_max,duration_max,expected_duration_max,expected_ticks,MAX_DURATION,ticks); - - /* fail_if(( expected_duration_max!=duration_max) | (ticks!=MAX_DURATION), - "hildon-time-editor: set_duration_max or get_duration_max failed with %d. Expected result is %d and result is %d. Set ticks to %d, expected result is %d and result is %d", - initial_duration_max,duration_max,expected_duration_max,expected_ticks,MAX_DURATION,ticks); - */ - remove_and_destroy_time_editor(showed_window,&time_editor); - - -} -END_TEST - -/* ----- Test case for set_duration_range -----*/ - -/** - * Purpose: Check that regular range values are set and get properly - * Cases considered: - * - Set and get duration range (100000,200000) having ticks under 100000 using time editor object with duration mode. - * - Set and get duration range (100000,200000) having ticks between 100000 and 200000 using time editor object with duration mode. - * - Set and get duration range (100000,200000) having ticks over 200000 using time editor object with duration mode. - * - Set and get duration range (100000,100000) having ticks under 100000 using time editor object with duration mode. - * - Set and get duration range (100000,100000) having ticks equal to 100000 using time editor object with duration mode. - * - Set and get duration range (100000,100000) having ticks over 100000 using time editor object with duration mode. - * - */ -START_TEST (test_set_duration_range_regular) -{ - guint initial_duration_min; - guint initial_duration_max; - guint duration_min; - guint duration_max; - guint expected_ticks; - guint ticks; - HildonTimeEditor *time_editor = NULL; - - /* Test 1: Set duration range to (100000,200000) seconds to test set_duration_range having ticks under 100000 */ - initial_duration_min=100000; - initial_duration_max=200000; - expected_ticks=90000; - - /* Initialize values in order to avoid side effects from previous tests */ - time_editor = create_and_show_time_editor(showed_window,TRUE,TRUE); - - hildon_time_editor_set_ticks(time_editor,expected_ticks); - hildon_time_editor_set_duration_range(time_editor,initial_duration_min,initial_duration_max); - hildon_time_editor_get_duration_range(time_editor,&duration_min,&duration_max); - ticks = hildon_time_editor_get_ticks(time_editor); - - fail_if( ( (initial_duration_min!=duration_min) | (initial_duration_max!=duration_max) | ( ticks!=initial_duration_min )), - "hildon-time-editor: set_duration_range or get_duration_range failed with (minimum,maximum) as (%d,%d). Expected range is (%d,%d). Set ticks to %d and expected ticks are %d ", - initial_duration_min,initial_duration_max,duration_min,duration_max,ticks,initial_duration_min); - - remove_and_destroy_time_editor(showed_window,&time_editor); - - /* Test 2: Set duration range to (100000,200000) seconds to test set_duration_range having ticks between 100000 and 200000 */ - initial_duration_min=100000; - initial_duration_max=200000; - expected_ticks=150000; - time_editor = create_and_show_time_editor(showed_window,TRUE,TRUE); - - hildon_time_editor_set_ticks(time_editor,expected_ticks); - hildon_time_editor_set_duration_range(time_editor,initial_duration_min,initial_duration_max); - hildon_time_editor_get_duration_range(time_editor,&duration_min,&duration_max); - ticks = hildon_time_editor_get_ticks(time_editor); - - fail_if( ( (initial_duration_min!=duration_min) | (initial_duration_max!=duration_max) | ( ticks!=initial_duration_min )), - "hildon-time-editor: set_duration_range or get_duration_range failed with (minimum,maximum) as (%d,%d). Expected range is (%d,%d). Set ticks to %d and expected ticks are %d ", - initial_duration_min,initial_duration_max,duration_min,duration_max,ticks,initial_duration_min); - - remove_and_destroy_time_editor(showed_window,&time_editor); - - - /* Test 3: Set duration range to (100000,200000) seconds to test set_duration_range having ticks over 200000*/ - initial_duration_min=100000; - initial_duration_max=200000; - expected_ticks=220000; - - time_editor = create_and_show_time_editor(showed_window,TRUE,TRUE); - - hildon_time_editor_set_ticks(time_editor,expected_ticks); - hildon_time_editor_set_duration_range(time_editor,initial_duration_min,initial_duration_max); - hildon_time_editor_get_duration_range(time_editor,&duration_min,&duration_max); - ticks = hildon_time_editor_get_ticks(time_editor); - - fail_if( ( (initial_duration_min!=duration_min) | (initial_duration_max!=duration_max) | ( ticks!=initial_duration_min )), - "hildon-time-editor: set_duration_range or get_duration_range failed with (minimum,maximum) as (%d,%d). Expected range is (%d,%d). Set ticks to %d and expected ticks are %d ", - initial_duration_min,initial_duration_max,duration_min,duration_max,ticks,initial_duration_min); - - remove_and_destroy_time_editor(showed_window,&time_editor); - - /* Test 4: Set duration range to (100000,100000) seconds to test set_duration_range having ticks under 100000 */ - initial_duration_min=100000; - initial_duration_max=100000; - expected_ticks=90000; - - time_editor = create_and_show_time_editor(showed_window,TRUE,TRUE); - - hildon_time_editor_set_ticks(time_editor,expected_ticks); - hildon_time_editor_set_duration_range(time_editor,initial_duration_min,initial_duration_max); - hildon_time_editor_get_duration_range(time_editor,&duration_min,&duration_max); - ticks = hildon_time_editor_get_ticks(time_editor); - - fail_if( ( (initial_duration_min!=duration_min) | (initial_duration_max!=duration_max) | ( ticks!=initial_duration_min )), - "hildon-time-editor: set_duration_range or get_duration_range failed with (minimum,maximum) as (%d,%d). Expected range is (%d,%d). Set ticks to %d and expected ticks are %d ", - initial_duration_min,initial_duration_max,duration_min,duration_max,ticks,initial_duration_min); - - remove_and_destroy_time_editor(showed_window,&time_editor); - - /* Test 5: Set duration range to (100000,100000) seconds to test set_duration_range having ticks equal to 100000 */ - initial_duration_min=100000; - initial_duration_max=100000; - expected_ticks=100000; - - time_editor = create_and_show_time_editor(showed_window,TRUE,TRUE); - - hildon_time_editor_set_ticks(time_editor,expected_ticks); - hildon_time_editor_set_duration_range(time_editor,initial_duration_min,initial_duration_max); - hildon_time_editor_get_duration_range(time_editor,&duration_min,&duration_max); - ticks = hildon_time_editor_get_ticks(time_editor); - - fail_if( ( (initial_duration_min!=duration_min) | (initial_duration_max!=duration_max) | ( ticks!=initial_duration_min )), - "hildon-time-editor: set_duration_range or get_duration_range failed with (minimum,maximum) as (%d,%d). Expected range is (%d,%d). Set ticks to %d and expected ticks are %d ", - initial_duration_min,initial_duration_max,duration_min,duration_max,ticks,initial_duration_min); - - remove_and_destroy_time_editor(showed_window,&time_editor); - - /* Test 6: Set duration range to (100000,100000) seconds to test set_duration_range having ticks over 100000 */ - initial_duration_min=100000; - initial_duration_max=100000; - expected_ticks=120000; - - time_editor = create_and_show_time_editor(showed_window,TRUE,TRUE); - - hildon_time_editor_set_ticks(time_editor,expected_ticks); - hildon_time_editor_set_duration_range(time_editor,initial_duration_min,initial_duration_max); - hildon_time_editor_get_duration_range(time_editor,&duration_min,&duration_max); - ticks = hildon_time_editor_get_ticks(time_editor); - - fail_if( ( (initial_duration_min!=duration_min) | (initial_duration_max!=duration_max) | ( ticks!=initial_duration_min )), - "hildon-time-editor: set_duration_range or get_duration_range failed with (minimum,maximum) as (%d,%d). Expected range is (%d,%d). Set ticks to %d and expected ticks are %d ", - initial_duration_min,initial_duration_max,duration_min,duration_max,ticks,initial_duration_min); - - remove_and_destroy_time_editor(showed_window,&time_editor); - - -} -END_TEST - -/** - * Purpose: Check that limits range values are set and get properly - * Cases considered: - * - Set and get duration range to (MIN_DURATION,MAX_DURATION) having ticks between MIN_DURATION and MAX_DURATION - * using time editor object with duration mode. - * - Set and get duration range to (MIN_DURATION,MIN_DURATION) having ticks over MIN_DURATION - * using time editor object with duration mode. - * - Set and get duration range to (MAX_DURATION,MAX_DURATION) having ticks under MAX_DURATION - * using time editor object with duration mode. - * - */ -START_TEST (test_set_duration_range_limits) -{ - guint initial_duration_min; - guint initial_duration_max; - guint duration_min; - guint duration_max; - guint expected_ticks; - guint ticks; - HildonTimeEditor *time_editor = NULL; - - - /* Test 1: Set duration range to (MIN_DURATION,MAX_DURATION) seconds to test set_duration_range having ticks under MIN_DURATION */ - initial_duration_min=MIN_DURATION; - initial_duration_max=MAX_DURATION; - expected_ticks=MIN_DURATION+1; - - time_editor = create_and_show_time_editor(showed_window,TRUE,TRUE); - - /* Initialize values in order to avoid side effects from previous tests */ - hildon_time_editor_set_duration_min(time_editor,MIN_DURATION); - hildon_time_editor_set_duration_max(time_editor,MAX_DURATION); - - hildon_time_editor_set_ticks(time_editor,expected_ticks); - hildon_time_editor_set_duration_range(time_editor,initial_duration_min,initial_duration_max); - hildon_time_editor_get_duration_range(time_editor,&duration_min,&duration_max); - ticks = hildon_time_editor_get_ticks(time_editor); - - fail_if( ( (initial_duration_min!=duration_min) | (initial_duration_max!=duration_max) | ( ticks!=initial_duration_min )), - "hildon-time-editor: set_duration_range or get_duration_range failed with (minimum,maximum) as (%d,%d). Expected range is (%d,%d). Set ticks to %d and expected ticks are %d ", - initial_duration_min,initial_duration_max,duration_min,duration_max,ticks,initial_duration_min); - - remove_and_destroy_time_editor(showed_window,&time_editor); - - - /* Test 2: Set duration range to (MIN_DURATION,MIN_DURATION) seconds to test set_duration_range having ticks over MIN_DURATION */ - initial_duration_min=MIN_DURATION; - initial_duration_max=MIN_DURATION; - expected_ticks=MIN_DURATION+1; - - time_editor = create_and_show_time_editor(showed_window,TRUE,TRUE); - - hildon_time_editor_set_ticks(time_editor,expected_ticks); - hildon_time_editor_set_duration_range(time_editor,initial_duration_min,initial_duration_max); - hildon_time_editor_get_duration_range(time_editor,&duration_min,&duration_max); - ticks = hildon_time_editor_get_ticks(time_editor); - - fail_if( ( (initial_duration_min!=duration_min) | (initial_duration_max!=duration_max) | ( ticks!=initial_duration_min )), - "hildon-time-editor: set_duration_range or get_duration_range failed with (minimum,maximum) as (%d,%d). Expected range is (%d,%d). Set ticks to %d and expected ticks are %d ", - initial_duration_min,initial_duration_max,duration_min,duration_max,ticks,initial_duration_min); - - remove_and_destroy_time_editor(showed_window,&time_editor); - - /* Test 3: Set duration range to (MAX_DURATION,MAX_DURATION) seconds to test set_duration_range having ticks under MAX_DURATION */ - initial_duration_min=MAX_DURATION; - initial_duration_max=MAX_DURATION; - expected_ticks=MAX_DURATION-1; - - time_editor = create_and_show_time_editor(showed_window,TRUE,TRUE); - - hildon_time_editor_set_ticks(time_editor,expected_ticks); - hildon_time_editor_set_duration_range(time_editor,initial_duration_min,initial_duration_max); - hildon_time_editor_get_duration_range(time_editor,&duration_min,&duration_max); - ticks = hildon_time_editor_get_ticks(time_editor); - - fail_if( ( (initial_duration_min!=duration_min) | (initial_duration_max!=duration_max) | ( ticks!=initial_duration_min )), - "hildon-time-editor: set_duration_range or get_duration_range failed with (minimum,maximum) as (%d,%d). Expected range is (%d,%d). Set ticks to %d and expected ticks are %d ", - initial_duration_min,initial_duration_max,duration_min,duration_max,ticks,initial_duration_min); - - remove_and_destroy_time_editor(showed_window,&time_editor); - - -} -END_TEST - -/** - * Purpose: Check that invalid range values are set and get properly - * Cases considered: - * - Set duration_range on NULL object. - * - Set and get duration range to (MAX_DURATION,MIN_DURATION) using time editor object with duration mode. - * - Set and get duration range to (MIN_DURATION,MAX_DURATION+1) having ticks between MIN_DURATION and MAX_DURATION - * using time editor object with duration mode. - * - Set and get duration range to (MAX_DURATION+1,MIN_DURATION) using time editor object with duration mode. - * - Set and get duration range to (MAX_DURATION+1,MAX_DURATION+3) - * using time editor object with duration mode. - * - Set and get duration range to (MAX_DURATION+3,MAX_DURATION+1) - * using time editor object with duration mode. - * - */ -START_TEST (test_set_duration_range_invalid) -{ - guint initial_duration_min; - guint initial_duration_max; - guint duration_min; - guint duration_max; - guint expected_ticks; - guint ticks; - HildonTimeEditor *time_editor = NULL; - - - /* Test 1: Set duration range on NULL */ - hildon_time_editor_set_duration_range(NULL,MIN_DURATION,MAX_DURATION); - - /* Test 2: Set duration range to (MAX_DURATION,MIN_DURATION) seconds to test set_duration_range */ - initial_duration_min=MAX_DURATION; - initial_duration_max=MIN_DURATION; - expected_ticks=MIN_DURATION+1; - time_editor = create_and_show_time_editor(showed_window,TRUE,TRUE); - - hildon_time_editor_set_ticks(time_editor,expected_ticks); - hildon_time_editor_set_duration_range(time_editor,initial_duration_min,initial_duration_max); - hildon_time_editor_get_duration_range(time_editor,&duration_min,&duration_max); - ticks = hildon_time_editor_get_ticks(time_editor); - - fail_if( ( (MIN_DURATION!=duration_min) | (MAX_DURATION!=duration_max) | ( ticks!=MIN_DURATION )), - "hildon-time-editor: set_duration_range or get_duration_range failed with (minimum,maximum) as (%d,%d). Expected range is (%d,%d). Set ticks to %d and expected ticks are %d ", - MIN_DURATION,MAX_DURATION,duration_min,duration_max,ticks,MIN_DURATION); - - remove_and_destroy_time_editor(showed_window,&time_editor); - - /* Test 3: Set duration range to (MIN_DURATION,MAX_DURATION+1) seconds to test set_duration_range */ - initial_duration_min=MIN_DURATION; - initial_duration_max=MAX_DURATION+1; - expected_ticks=MAX_DURATION-59; - time_editor = create_and_show_time_editor(showed_window,TRUE,TRUE); - - hildon_time_editor_set_ticks(time_editor,expected_ticks); - hildon_time_editor_set_duration_range(time_editor,initial_duration_min,initial_duration_max); - hildon_time_editor_get_duration_range(time_editor,&duration_min,&duration_max); - ticks = hildon_time_editor_get_ticks(time_editor); - - fail_if( ( (MIN_DURATION!=duration_min) | (MAX_DURATION!=duration_max) | ( ticks!=MIN_DURATION )), - "hildon-time-editor: set_duration_range or get_duration_range failed with (minimum,maximum) as (%d,%d). Expected range is (%d,%d). Set ticks to %d and expected ticks are %d ", - MIN_DURATION,MAX_DURATION,duration_min,duration_max,ticks,MIN_DURATION); - - remove_and_destroy_time_editor(showed_window,&time_editor); - - - /* Test 4: Set duration range to (MAX_DURATION+1,MIN_DURATION) seconds to test set_duration_range */ - initial_duration_min=MAX_DURATION+1; - initial_duration_max=MIN_DURATION; - expected_ticks=MIN_DURATION-1; - time_editor = create_and_show_time_editor(showed_window,TRUE,TRUE); - - hildon_time_editor_set_duration_range(time_editor,initial_duration_min,initial_duration_max); - hildon_time_editor_get_duration_range(time_editor,&duration_min,&duration_max); - - fail_if( ( (MIN_DURATION!=duration_min) | (MAX_DURATION!=duration_max) ), - "hildon-time-editor: set_duration_range or get_duration_range failed with (minimum,maximum) as (%d,%d). Expected range is (%d,%d). ", - MIN_DURATION,MAX_DURATION,duration_min,duration_max); - - remove_and_destroy_time_editor(showed_window,&time_editor); - - - /* Test 5: Set duration range to (MAX_DURATION+1,MIN_DURATION+3) seconds to test set_duration_range */ - initial_duration_min=MAX_DURATION+1; - initial_duration_max=MAX_DURATION+3; - expected_ticks=MAX_DURATION+1; - - time_editor = create_and_show_time_editor(showed_window,TRUE,TRUE); - - hildon_time_editor_set_ticks(time_editor,expected_ticks); - hildon_time_editor_set_duration_range(time_editor,initial_duration_min,initial_duration_max); - hildon_time_editor_get_duration_range(time_editor,&duration_min,&duration_max); - ticks = hildon_time_editor_get_ticks(time_editor); - -/* fail_if( ( (initial_duration_min!=duration_min) | (MAX_DURATION!=duration_max) | ( ticks!=MAX_DURATION )), */ -/* "hildon-time-editor: set_duration_range or get_duration_range failed with (minimum,maximum) as (%d,%d). Expected range is (%d,%d). Set ticks to %d and expected ticks are %d ", */ -/* initial_duration_min,MAX_DURATION,duration_min,duration_max,ticks,MAX_DURATION); */ - - fail_if( ( (initial_duration_min!=duration_min) | (MAX_DURATION!=duration_max) ), - "hildon-time-editor: set_duration_range or get_duration_range failed with (minimum,maximum) as (%d,%d). Expected range is (%d,%d). Set ticks to %d and expected ticks are %d ", - initial_duration_min,MAX_DURATION,duration_min,duration_max,ticks,MAX_DURATION); - - remove_and_destroy_time_editor(showed_window,&time_editor); - - /* Test 6: Set duration range to (MAX_DURATION+3,MIN_DURATION+1) seconds to test set_duration_range */ - initial_duration_min=MAX_DURATION+3; - initial_duration_max=MAX_DURATION+1; - expected_ticks=MAX_DURATION+1; - - time_editor = create_and_show_time_editor(showed_window,TRUE,TRUE); - - hildon_time_editor_set_ticks(time_editor,expected_ticks); - hildon_time_editor_set_duration_range(time_editor,initial_duration_min,initial_duration_max); - hildon_time_editor_get_duration_range(time_editor,&duration_min,&duration_max); - ticks = hildon_time_editor_get_ticks(time_editor); - - fail_if( ( (initial_duration_max!=duration_min) | (MAX_DURATION!=duration_max) | ( ticks!=MAX_DURATION )), - "hildon-time-editor: set_duration_range or get_duration_range failed with (minimum,maximum) as (%d,%d). Expected range is (%d,%d). Set ticks to %d and expected ticks are %d ", - initial_duration_max,MAX_DURATION,duration_min,duration_max,ticks,MAX_DURATION); - - remove_and_destroy_time_editor(showed_window,&time_editor); - - -} -END_TEST - - -/* ---------- Suite creation ---------- */ - -Suite *create_hildon_time_editor_suite() -{ - /* Create the suite */ - Suite *s = suite_create("HildonTimeEditor"); - - /* Create test cases */ - TCase *tc1 = tcase_create("set_time"); - TCase *tc2 = tcase_create("set_ticks"); - TCase *tc3 = tcase_create("set_duration_min_set_duration_max"); - TCase *tc4 = tcase_create("set_duration_range"); - - /* Create test case for hildon_time_editor_set_time and add it to the suite */ - tcase_add_checked_fixture(tc1, fx_setup_default_time_editor, fx_teardown_default_time_editor); - tcase_add_test(tc1, test_set_time_regular); - tcase_add_test(tc1, test_set_time_limits); - tcase_add_test(tc1, test_set_time_invalid); - suite_add_tcase (s, tc1); - - /* Create test case for hildon_time_editor_set_ticks and add it to the suite */ - tcase_add_checked_fixture(tc2, fx_setup_default_time_editor, fx_teardown_default_time_editor); - tcase_add_test(tc2, test_set_ticks_regular); - tcase_add_test(tc2, test_set_ticks_limits); - tcase_add_test(tc2, test_set_ticks_invalid); - suite_add_tcase (s, tc2); - - /* Create test case for hildon_time_editor_set_duration_max and add it to the suite */ - tcase_add_checked_fixture(tc3, fx_setup_default_time_editor, fx_teardown_default_time_editor); - tcase_add_test(tc3, test_set_duration_min_set_duration_max_regular); - tcase_add_test(tc3, test_set_duration_min_set_duration_max_limits); - tcase_add_test(tc3, test_set_duration_min_set_duration_max_invalid); - suite_add_tcase (s, tc3); - - /* Create test case for hildon_time_editor_set_duration_range and add it to the suite */ - tcase_add_checked_fixture(tc4, fx_setup_default_time_editor, fx_teardown_default_time_editor); - tcase_add_test(tc4, test_set_duration_range_regular); - tcase_add_test(tc4, test_set_duration_range_limits); - tcase_add_test(tc4, test_set_duration_range_invalid); - suite_add_tcase (s, tc4); - - /* Return created suite */ - return s; -} diff --git a/tests/check-hildon-time-picker.c b/tests/check-hildon-time-picker.c deleted file mode 100644 index 7dfacb0..0000000 --- a/tests/check-hildon-time-picker.c +++ /dev/null @@ -1,277 +0,0 @@ -/* - * This file is a part of hildon tests - * - * Copyright (C) 2006, 2007 Nokia Corporation, all rights reserved. - * - * Contact: Michael Dominic Kostrzewa <michael.kostrzewa@nokia.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; version 2.1 of - * the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA - * - */ -#include <stdlib.h> -#include <check.h> -#include <gtk/gtkmain.h> -#include "test_suites.h" -#include "check_utils.h" - -#include <hildon/hildon-window.h> -#include <hildon/hildon-time-picker.h> - -/* -------------------- Fixtures -------------------- */ - -static HildonTimePicker *time_picker = NULL; -static HildonWindow *tp_window = NULL; - -static void -fx_setup_default_time_picker () -{ - int argc = 0; - gtk_init(&argc, NULL); - - tp_window = HILDON_WINDOW(hildon_window_new()); - /* Check window object has been created properly */ - fail_if(!HILDON_IS_WINDOW(tp_window), - "hildon-time-picker: Window creation failed."); - - time_picker = HILDON_TIME_PICKER(hildon_time_picker_new(GTK_WINDOW(tp_window))); - - /* Check time_picker object has been created properly */ - fail_if(!HILDON_IS_TIME_PICKER(time_picker), - "hildon-time-picker: Creation failed."); - - /* Displays the widget and the window */ - show_all_test_window (GTK_WIDGET (tp_window)); - show_all_test_window (GTK_WIDGET (time_picker)); - -} - -static void -fx_teardown_default_time_picker () -{ - gtk_widget_destroy (GTK_WIDGET (time_picker)); - gtk_widget_destroy (GTK_WIDGET (tp_window)); -} - -/* -------------------- Test cases -------------------- */ - -/* ----- Test case for set_time -----*/ - -/** - * Purpose: Check that regular time values are set and get properly - * Cases considered: - * - Set and get time to 5h 30m using time picker object. - * - Set and get time to 18h 2m using time picker object. - */ -START_TEST (test_set_time_regular) -{ - guint hours; - guint minutes; - guint ret_hours; - guint ret_minutes; - - /* Check time_picker object has been created properly */ - fail_if(!HILDON_IS_TIME_PICKER(time_picker), - "hildon-time-picker: Creation failed."); - - /* Test 1: Set and get time to 5h 30m using time picker object. */ - hours = 5; - minutes = 30; - - hildon_time_picker_set_time(time_picker,hours,minutes); - hildon_time_picker_get_time(time_picker,&ret_hours,&ret_minutes); - - fail_if (hours != ret_hours || minutes != ret_minutes, - "hildon-time-picker: Set time (%uh:%um) but returned time is (%uh:%um)", - hours, minutes, ret_hours, ret_minutes); - - /* Test 2: Set and get time to 18h 2m using time picker object. */ - hours = 18; - minutes = 2; - - hildon_time_picker_set_time(time_picker,hours,minutes); - hildon_time_picker_get_time(time_picker,&ret_hours,&ret_minutes); - - fail_if (hours != ret_hours || minutes != ret_minutes, - "hildon-time-picker: Set time (%uh:%um) but returned time is (%uh:%um)", - hours, minutes, ret_hours, ret_minutes); -} -END_TEST - -/** - * Purpose: Check that limit time values are set and get properly - * Cases considered: - * - Set and get time to 0h 0m using time picker object. - * - Set and get time to 0h 59m using time picker object. - * - Set and get time to 12h 59m using time picker object. - * - Set and get time to 23h 59m using time picker object. - */ -START_TEST (test_set_time_limits) -{ - guint hours; - guint minutes; - guint ret_hours; - guint ret_minutes; - - /* Check time_picker object has been created properly */ - fail_if(!HILDON_IS_TIME_PICKER(time_picker), - "hildon-time-picker: Creation failed."); - - /* Test 1: Set and get time to 0h 0m using time picker object. */ - hours = 0; - minutes = 0; - - hildon_time_picker_set_time(time_picker,hours,minutes); - hildon_time_picker_get_time(time_picker,&ret_hours,&ret_minutes); - - fail_if (hours != ret_hours || minutes != ret_minutes, - "hildon-time-picker: Set time (%uh:%um) but returned time is (%uh:%um)", - hours, minutes, ret_hours, ret_minutes); - - /* Test 2: Set and get time to 0h 59m using time picker object. */ - hours = 0; - minutes = 59; - - hildon_time_picker_set_time(time_picker,hours,minutes); - hildon_time_picker_get_time(time_picker,&ret_hours,&ret_minutes); - - fail_if (hours != ret_hours || minutes != ret_minutes, - "hildon-time-picker: Set time (%uh:%um) but returned time is (%uh:%um)", - hours, minutes, ret_hours, ret_minutes); - - /* Test 3: Set and get time to 12h 59m using time picker object. */ - hours = 12; - minutes = 59; - - hildon_time_picker_set_time(time_picker,hours,minutes); - hildon_time_picker_get_time(time_picker,&ret_hours,&ret_minutes); - - fail_if (hours != ret_hours || minutes != ret_minutes, - "hildon-time-picker: Set time (%uh:%um) but returned time is (%uh:%um)", - hours, minutes, ret_hours, ret_minutes); - - /* Test 4: Set and get time to 23h 59m using time picker object. */ - hours = 23; - minutes = 59; - - hildon_time_picker_set_time(time_picker,hours,minutes); - hildon_time_picker_get_time(time_picker,&ret_hours,&ret_minutes); - - fail_if (hours != ret_hours || minutes != ret_minutes, - "hildon-time-picker: Set time (%uh:%um) but returned time is (%uh:%um)", - hours, minutes, ret_hours, ret_minutes); -} -END_TEST - -/** - * Purpose: Check that limit time values are set and get properly - * Cases considered: - * - Set and get time using NULL time picker. - * - Set and get time to 0h 60m using time picker object. - * - Set and get time to 24h 0m using time picker object. - * - Set and get time to 24h 60m using time picker object. - * - Set and get time to 16000h 15533m using time picker object. - */ -START_TEST (test_set_time_invalid) -{ - guint hours; - guint minutes; - guint ret_hours; - guint ret_minutes; - guint expected_hours; - guint expected_minutes; - - /* Check time_picker object has been created properly */ - fail_if(!HILDON_IS_TIME_PICKER(time_picker), - "hildon-time-picker: Creation failed."); - - hours = 0; - minutes = 60; - expected_hours=1; - expected_minutes=0; - - /* Test 1: Set and get time using NULL time picker */ - hildon_time_picker_set_time(NULL,hours,minutes); - hildon_time_picker_get_time(NULL,&ret_hours,&ret_minutes); - - /* Test 2: Set and get time to 0h 60m using time picker object. */ - hildon_time_picker_set_time(time_picker,hours,minutes); - hildon_time_picker_get_time(time_picker,&ret_hours,&ret_minutes); - - fail_if (expected_hours != ret_hours || expected_minutes != ret_minutes, - "hildon-time-picker: Set time (%uh:%um), expected time is (%uh:%um) but returned time is (%uh:%um)", - hours, minutes, expected_hours, expected_minutes, ret_hours, ret_minutes); - - /* Test 3: Set and get time to 24h 0m using time picker object. */ - hours = 24; - minutes = 0; - expected_hours=0; - expected_minutes=0; - - hildon_time_picker_set_time(time_picker,hours,minutes); - hildon_time_picker_get_time(time_picker,&ret_hours,&ret_minutes); - - fail_if (expected_hours != ret_hours || expected_minutes != ret_minutes, - "hildon-time-picker: Set time (%uh:%um), expected time is (%uh:%um) but returned time is (%uh:%um)", - hours, minutes, expected_hours, expected_minutes, ret_hours, ret_minutes); - - /* Test 4: Set and get time to 24h 60m using time picker object. */ - hours = 24; - minutes = 60; - expected_hours=1; - expected_minutes=0; - - hildon_time_picker_set_time(time_picker,hours,minutes); - hildon_time_picker_get_time(time_picker,&ret_hours,&ret_minutes); - - fail_if (expected_hours != ret_hours || expected_minutes != ret_minutes, - "hildon-time-picker: Set time (%uh:%um), expected time is (%uh:%um) but returned time is (%uh:%um)", - hours, minutes, expected_hours, expected_minutes, ret_hours, ret_minutes); - - /* Test 5: Set and get time to 16000h 15533m using time picker object.*/ - hours = 16000; - minutes = 15533; - expected_hours=10; - expected_minutes=53; - - hildon_time_picker_set_time(time_picker,hours,minutes); - hildon_time_picker_get_time(time_picker,&ret_hours,&ret_minutes); - - fail_if (expected_hours != ret_hours || expected_minutes != ret_minutes, - "hildon-time-picker: Set time (%uh:%um), expected time is (%uh:%um) but returned time is (%uh:%um)", - hours, minutes, expected_hours, expected_minutes, ret_hours, ret_minutes); -} -END_TEST - -/* ---------- Suite creation ---------- */ - -Suite *create_hildon_time_picker_suite() -{ - /* Create the suite */ - Suite *s = suite_create("HildonTimePicker"); - - /* Create test cases */ - TCase *tc1 = tcase_create("set_time"); - - /* Create test case for hildon_time_picker_set_time and add it to the suite */ - tcase_add_checked_fixture(tc1, fx_setup_default_time_picker, fx_teardown_default_time_picker); - tcase_add_test(tc1, test_set_time_regular); - tcase_add_test(tc1, test_set_time_limits); - tcase_add_test(tc1, test_set_time_invalid); - suite_add_tcase(s, tc1); - - /* Return created suite */ - return s; -} diff --git a/tests/check-hildon-volumebar-range.c b/tests/check-hildon-volumebar-range.c deleted file mode 100644 index 921ef0a..0000000 --- a/tests/check-hildon-volumebar-range.c +++ /dev/null @@ -1,196 +0,0 @@ -/* - * This file is a part of hildon tests - * - * Copyright (C) 2006, 2007 Nokia Corporation, all rights reserved. - * - * Contact: Michael Dominic Kostrzewa <michael.kostrzewa@nokia.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; version 2.1 of - * the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA - * - */ -#include <stdlib.h> -#include <check.h> -#include <gtk/gtkmain.h> -#include <gtk/gtkcontainer.h> -#include "test_suites.h" -#include "check_utils.h" - -#include <hildon/hildon-volumebar-range.h> - -/* Copied from hildon-volumebar-range.h because - there is no way to retrieve this values */ -#define VOLUMEBAR_RANGE_INITIAL_VALUE 50.0 -#define VOLUMEBAR_RANGE_MINIMUM_VALUE 0.0 -#define VOLUMEBAR_RANGE_MAXIMUM_VALUE 100.0 -#define CHANGE_THRESHOLD 0.001 - -/* -------------------- Fixtures -------------------- */ - -static GtkWidget *showed_window = NULL; -static HildonVolumebarRange *volumebar_range = NULL; - -static void -fx_setup_default_volumebar_range () -{ - int argc = 0; - - gtk_init(&argc, NULL); - - volumebar_range = HILDON_VOLUMEBAR_RANGE(hildon_volumebar_range_new(GTK_ORIENTATION_VERTICAL)); - - showed_window = create_test_window (); - - /* This packs the widget into the window (a gtk container). */ - gtk_container_add (GTK_CONTAINER (showed_window), GTK_WIDGET (volumebar_range)); - - /* Displays the widget and the window */ - show_all_test_window (showed_window); - - /* Check volumebar range object has been created properly */ - fail_if(!HILDON_VOLUMEBAR_RANGE(volumebar_range), - "hildon-volumebar-range: Creation failed."); -} - -static void -fx_teardown_default_volumebar_range () -{ - - /* Destroy the window */ - gtk_widget_destroy (showed_window); -} - - -/* -------------------- Test cases -------------------- */ - -/* ----- Test case for set/get_level -----*/ - -/** - * Purpose: Check level usage - * Cases considered: - * - Set level over the threshold limit - * - Set level under the threshold limit. - */ -START_TEST (test_set_get_level_regular) -{ - gdouble old_level, level, ret_level; - - /* Test1: set level so change is over the threshold limit */ - level = VOLUMEBAR_RANGE_INITIAL_VALUE + 1.0 + CHANGE_THRESHOLD; - hildon_volumebar_range_set_level(volumebar_range, level); - ret_level = hildon_volumebar_range_get_level(volumebar_range); - fail_if(ret_level != level, - "hildon-volumebar-range: Set level to %.5f, but get level returned %.5f", - level, ret_level); - - /* Test2: set level so change is under the threshold limit */ - old_level = ret_level; - level += (gdouble) (CHANGE_THRESHOLD/2.0); - hildon_volumebar_range_set_level(volumebar_range, level); - ret_level = hildon_volumebar_range_get_level(volumebar_range); - fail_if(ret_level == level, - "hildon-volumebar-range: Set level to %.5f when current level is %.5f, but get level returned %.5f", - level, old_level, ret_level); -} -END_TEST - -/** - * Purpose: Test handling of limit values - * Cases considered: - * - Set level to VOLUMEBAR_RANGE_MINIMUM_VALUE - * - Set level to VOLUMEBAR_RANGE_MAXIMUM_VALUE - */ -START_TEST (test_set_get_level_limits) -{ - gdouble level, ret_level; - - /* Test1: Set level to minimum allowed (first set it the a different value) */ - level = (VOLUMEBAR_RANGE_MINIMUM_VALUE - VOLUMEBAR_RANGE_MINIMUM_VALUE) / 2.0; - hildon_volumebar_range_set_level(volumebar_range, level); - level = VOLUMEBAR_RANGE_MINIMUM_VALUE; - hildon_volumebar_range_set_level(volumebar_range, level); - ret_level = hildon_volumebar_range_get_level(volumebar_range); - fail_if(ret_level != level, - "hildon-volumebar-range: Set level to %.5f, but get level returned %.5f", - level, ret_level); - - /* Test2: Set level to maximum allowed */ - level = VOLUMEBAR_RANGE_MAXIMUM_VALUE; - hildon_volumebar_range_set_level(volumebar_range, level); - ret_level = hildon_volumebar_range_get_level(volumebar_range); - fail_if(ret_level != level, - "hildon-volumebar-range: Set level to %.5f, but get level returned %.5f", - level, ret_level); -} -END_TEST - -/** - * Purpose: Test handling of invalid values - * Cases considered: - * - Set level under the minimum value - * - Set level over the maximum value - * - Set level with NULL object - * - Get level with NULL object - */ -START_TEST (test_set_get_level_invalid) -{ - gdouble level, ret_level; - - /* Test1: Set level under minimum value */ - level = VOLUMEBAR_RANGE_MINIMUM_VALUE - 1.0 - CHANGE_THRESHOLD; - hildon_volumebar_range_set_level(volumebar_range, level); - ret_level = hildon_volumebar_range_get_level(volumebar_range); - fail_if(ret_level != VOLUMEBAR_RANGE_MINIMUM_VALUE, - "hildon-volumebar-range: Set level to %.5f (under the minimum allowed), and get level returned %.5f", - level, ret_level); - - /* Test2: Set level over maximum value */ - level = VOLUMEBAR_RANGE_MAXIMUM_VALUE + 1.0 + CHANGE_THRESHOLD; - hildon_volumebar_range_set_level(volumebar_range, level); - ret_level = hildon_volumebar_range_get_level(volumebar_range); - fail_if(ret_level != VOLUMEBAR_RANGE_MAXIMUM_VALUE, - "hildon-volumebar-range: Set level to %.5f (greater than maximum allowed), and get level returned %.5f", - level, ret_level); - - /* Test3: Set level with NULL object */ - hildon_volumebar_range_set_level(NULL, level); - - /* Test4: Get level with NULL object */ - hildon_volumebar_range_get_level(NULL); -} -END_TEST - -/* ---------- Suite creation ---------- */ - -Suite *create_hildon_volumebar_range_suite() -{ - /* Create the suite */ - Suite *s = suite_create("HildonVolumebarRange"); - - /* Create test cases */ - TCase *tc1 = tcase_create("set_get_level"); - - /* Create test case for set/get_mute and add it to the suite */ - tcase_add_checked_fixture(tc1, fx_setup_default_volumebar_range, fx_teardown_default_volumebar_range); - tcase_add_test(tc1, test_set_get_level_regular); - tcase_add_test(tc1, test_set_get_level_limits); - tcase_add_test(tc1, test_set_get_level_invalid); - suite_add_tcase (s, tc1); - - /* Return created suite */ - return s; -} - - diff --git a/tests/check-hildon-volumebar.c b/tests/check-hildon-volumebar.c deleted file mode 100644 index 1bc03c2..0000000 --- a/tests/check-hildon-volumebar.c +++ /dev/null @@ -1,199 +0,0 @@ -/* - * This file is a part of hildon tests - * - * Copyright (C) 2006, 2007 Nokia Corporation, all rights reserved. - * - * Contact: Michael Dominic Kostrzewa <michael.kostrzewa@nokia.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; version 2.1 of - * the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA - * - */ - -#include <stdlib.h> -#include <check.h> -#include <gtk/gtkmain.h> -#include "test_suites.h" -#include "check_utils.h" - -#include <hildon/hildon-window.h> -#include <hildon/hildon-volumebar.h> -#include <hildon/hildon-hvolumebar.h> -#include <hildon/hildon-vvolumebar.h> - -/* -------------------- Fixtures -------------------- */ - -static HildonVolumebar *volumebar = NULL; -static HildonWindow *window = NULL; - -static void -fx_setup_hvolumebar () -{ - int argc = 0; - - gtk_init(&argc, NULL); - - volumebar = HILDON_VOLUMEBAR(hildon_hvolumebar_new()); - - /* Check volumebar object has been created properly */ - fail_if(!HILDON_VOLUMEBAR(volumebar), - "hildon-volumebar: Creation failed."); - - /* Add volumebar to a window to avoid gtk warnings when - trying to set focus to parent window */ - window = HILDON_WINDOW(hildon_window_new()); - - /* Check window object has been created properly */ - fail_if(!HILDON_IS_WINDOW(window), - "hildon-window: Creation failed."); - - gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(volumebar)); - - /* Displays the widget and the window */ - show_all_test_window (GTK_WIDGET (window)); -} - -static void -fx_setup_vvolumebar () -{ - int argc = 0; - - gtk_init(&argc, NULL); - - volumebar = HILDON_VOLUMEBAR(hildon_vvolumebar_new()); - - /* Check volumebar object has been created properly */ - fail_if(!HILDON_VOLUMEBAR(volumebar), - "hildon-volumebar: Creation failed."); - - /* Add volumebar to a window to avoid gtk warnings when - trying to set focus to parent window */ - window = HILDON_WINDOW(hildon_window_new()); - - /* Check window object has been created properly */ - fail_if(!HILDON_IS_WINDOW(window), - "hildon-window: Creation failed."); - - gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(volumebar)); - - /* Displays the widget and the window */ - show_all_test_window (GTK_WIDGET (window)); -} - -static void -fx_teardown_volumebar() -{ - gtk_widget_destroy (GTK_WIDGET (window)); -} - - -/* -------------------- Test cases -------------------- */ - -/* ----- Test case for set/get_mute -----*/ - -/** - * Purpose: Check mute usage - * Cases considered: - * - Set mute ON when volumebar is focusable - * - Set mute OFF when volumebar is focusable - * - Set mute ON when volumebar is not focusable - * - Set mute OFF when volumebar is not focusable - */ -START_TEST (test_set_get_mute_regular) -{ - gboolean ret_mute; - GValue value = {0,}; - - /* Test1: Set mute in focusable state */ - g_value_init(&value, G_TYPE_BOOLEAN); - g_value_set_boolean(&value, TRUE); - g_object_set_property(G_OBJECT(volumebar), "can-focus", &value); - hildon_volumebar_set_mute(HILDON_VOLUMEBAR(volumebar), TRUE); - ret_mute = hildon_volumebar_get_mute(HILDON_VOLUMEBAR(volumebar)); - fail_if(ret_mute != TRUE, - "hildon-volumebar: Set mute to TRUE (volumebar is focusable), but get mute returned FALSE"); - - /* Test2: Unset mute in focusable state */ - hildon_volumebar_set_mute(HILDON_VOLUMEBAR(volumebar), FALSE); - ret_mute = hildon_volumebar_get_mute(HILDON_VOLUMEBAR(volumebar)); - fail_if(ret_mute != FALSE, - "hildon-volumebar: Set mute to FALSE (volumebar is focusable), but get mute returned TRUE"); - - /* Test3: Set mute in not focusable state */ - g_value_set_boolean(&value, FALSE); - g_object_set_property(G_OBJECT(volumebar), "can-focus", &value); - hildon_volumebar_set_mute(HILDON_VOLUMEBAR(volumebar), TRUE); - ret_mute = hildon_volumebar_get_mute(HILDON_VOLUMEBAR(volumebar)); - fail_if(ret_mute != TRUE, - "hildon-volumebar: Set mute to TRUE (volumebar is not focusable), but get mute returned FALSE"); - - /* Test4: Unset mute in not focusable state */ - hildon_volumebar_set_mute(HILDON_VOLUMEBAR(volumebar), FALSE); - ret_mute = hildon_volumebar_get_mute(HILDON_VOLUMEBAR(volumebar)); - fail_if(ret_mute != FALSE, - "hildon-volumebar: Set mute to FALSE (volumebar is not focusable), but get mute returned TRUE"); - fail_if(gtk_window_get_focus(GTK_WINDOW(window)) != NULL, - "hildon-volumebar: Set mute to FALSE (volumebar is not focusable), but parent window has focused child"); -} -END_TEST - -/** - * Purpose: Test handling of invalid values for get/set_mute interface - * Cases considered: - * - Set mute with NULL volumebar object - * - Get mute with NULL volumebar object - */ -START_TEST (test_set_get_mute_invalid) -{ - /* Check volumebar object has been created properly */ - fail_if(!HILDON_VOLUMEBAR(volumebar), - "hildon-volumebar: Creation failed."); - - /* Test1: Check set mute with NULL volumebar object */ - hildon_volumebar_set_mute(NULL, FALSE); - - /* Test2: Check get mute with NULL volumebar object */ - hildon_volumebar_get_mute(NULL); -} -END_TEST - -/* ---------- Suite creation ---------- */ - -Suite *create_hildon_volumebar_suite() -{ - /* Create the suite */ - Suite *s = suite_create("HildonVolumebar"); - - /* Create test cases */ - TCase *tc1 = tcase_create("set_get_mute_hvolumebar"); - TCase *tc2 = tcase_create("set_get_mute_vvolumebar"); - - /* Create test case for set/get_mute (hvolumebar) and add it to the suite */ - tcase_add_checked_fixture(tc1, fx_setup_hvolumebar, fx_teardown_volumebar); - tcase_add_test(tc1, test_set_get_mute_regular); - tcase_add_test(tc1, test_set_get_mute_invalid); - suite_add_tcase (s, tc1); - - /* Create test case for set/get_mute (vvolumebar) and add it to the suite */ - tcase_add_checked_fixture(tc2, fx_setup_vvolumebar, fx_teardown_volumebar); - tcase_add_test(tc2, test_set_get_mute_regular); - tcase_add_test(tc2, test_set_get_mute_invalid); - suite_add_tcase (s, tc2); - - /* Return created suite */ - return s; -} - - diff --git a/tests/check-hildon-weekday-picker.c b/tests/check-hildon-weekday-picker.c deleted file mode 100644 index e641805..0000000 --- a/tests/check-hildon-weekday-picker.c +++ /dev/null @@ -1,266 +0,0 @@ -/* - * This file is a part of hildon tests - * - * Copyright (C) 2006, 2007 Nokia Corporation, all rights reserved. - * - * Contact: Michael Dominic Kostrzewa <michael.kostrzewa@nokia.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; version 2.1 of - * the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA - * - */ - -#include <stdlib.h> -#include <check.h> -#include <gtk/gtkmain.h> -#include "test_suites.h" -#include "check_utils.h" - -#include <hildon/hildon-weekday-picker.h> -#include <hildon/hildon-window.h> -#include <hildon/hildon-caption.h> - -/* -------------------- Fixtures -------------------- */ - -static HildonWeekdayPicker *weekday_picker = NULL; -static GtkWidget *showed_window = NULL; - -static void -fx_setup_default_weekday_picker () -{ - int argc = 0; - - gtk_init(&argc, NULL); - - showed_window = create_test_window (); - - weekday_picker = HILDON_WEEKDAY_PICKER(hildon_weekday_picker_new()); - /* Check weekday_picker object has been created properly */ - fail_if(!HILDON_IS_WEEKDAY_PICKER(weekday_picker), - "hildon-weekday-picker: Creation failed."); - - /* This packs the widget into the window (a gtk container). */ - gtk_container_add (GTK_CONTAINER (showed_window), GTK_WIDGET (weekday_picker)); - - /* Displays the widget and the window */ - show_all_test_window (showed_window); - - -} - -static void -fx_teardown_default_weekday_picker () -{ - gtk_widget_destroy (GTK_WIDGET (showed_window)); -} - -/* -------------------- Test cases -------------------- */ - -/* ----- Test case for set_day / isset_day -----*/ - -/** - * Purpose: Check that regular day values are set and get properly - * Cases considered: - * - Set and isset the day "WEDNESDAY" on weekday picker. - * - Set and isset two days (WEDNESDAY and SATURDAY) on weekday picker and check that only the two selected days are set. - */ -START_TEST (test_set_day_regular) -{ - - /* Test 1: Set WEDNESDAY on weekday picker. */ - hildon_weekday_picker_set_day(weekday_picker,G_DATE_WEDNESDAY); - - fail_if(!hildon_weekday_picker_isset_day(weekday_picker,G_DATE_WEDNESDAY), "hildon-weekday-picker: set_day/isset_day to G_DATE_WEDNESDAY didn't set WEDNESDAY."); - fail_if(hildon_weekday_picker_isset_day(weekday_picker,G_DATE_MONDAY), "hildon-weekday-picker: set_day/isset_day to G_DATE_WEDNESDAY set MONDAY wrong."); - fail_if(hildon_weekday_picker_isset_day(weekday_picker,G_DATE_TUESDAY), "hildon-weekday-picker: set_day/isset_day to G_DATE_WEDNESDAY set TUESDAY wrong."); - fail_if(hildon_weekday_picker_isset_day(weekday_picker,G_DATE_THURSDAY), "hildon-weekday-picker: set_day/isset_day to G_DATE_WEDNESDAY set THURSDAY wrong."); - fail_if(hildon_weekday_picker_isset_day(weekday_picker,G_DATE_FRIDAY), "hildon-weekday-picker: set_day/isset_day to G_DATE_WEDNESDAY set FRIDAY wrong."); - fail_if(hildon_weekday_picker_isset_day(weekday_picker,G_DATE_SATURDAY), "hildon-weekday-picker: set_day/isset_day to G_DATE_WEDNESDAY set SATURDAY wrong."); - fail_if(hildon_weekday_picker_isset_day(weekday_picker,G_DATE_SUNDAY), "hildon-weekday-picker: set_day/isset_day to G_DATE_WEDNESDAY set SUNDAY wrong."); - fail_if(hildon_weekday_picker_isset_day(weekday_picker,G_DATE_BAD_WEEKDAY), "hildon-weekday-picker: set_day/isset_day to G_DATE_WEDNESDAY set G_DATE_BAD_WEEKDAY wrong."); - - hildon_weekday_picker_set_day(weekday_picker,G_DATE_WEDNESDAY); - hildon_weekday_picker_set_day(weekday_picker,G_DATE_SATURDAY); - - /* Test 1: Set WEDNESDAY and SATURDAY on weekday picker. */ - fail_if(!hildon_weekday_picker_isset_day(weekday_picker,G_DATE_WEDNESDAY), "hildon-weekday-picker: set_day/isset_day to G_DATE_WEDNESDAY and G_DATE_SATURDAY didn't set WEDNESDAY."); - fail_if(!hildon_weekday_picker_isset_day(weekday_picker,G_DATE_SATURDAY), "hildon-weekday-picker: set_day/isset_day to G_DATE_WEDNESDAY and G_DATE_SATURDAY didn't set SATURDAY."); - fail_if(hildon_weekday_picker_isset_day(weekday_picker,G_DATE_TUESDAY), "hildon-weekday-picker: set_day/isset_day to G_DATE_WEDNESDAY and G_DATE_SATURDAY set TUESDAY wrong."); - fail_if(hildon_weekday_picker_isset_day(weekday_picker,G_DATE_THURSDAY), "hildon-weekday-picker: set_day/isset_day to G_DATE_WEDNESDAY and G_DATE_SATURDAY set THURSDAY wrong."); - fail_if(hildon_weekday_picker_isset_day(weekday_picker,G_DATE_MONDAY), "hildon-weekday-picker: set_day/isset_day to G_DATE_WEDNESDAY and G_DATE_SATURDAY set MONDAY wrong."); - fail_if(hildon_weekday_picker_isset_day(weekday_picker,G_DATE_FRIDAY), "hildon-weekday-picker: set_day/isset_day to G_DATE_WEDNESDAY and G_DATE_SATURDAY set FRIDAY wrong."); - fail_if(hildon_weekday_picker_isset_day(weekday_picker,G_DATE_SUNDAY), "hildon-weekday-picker: set_day/isset_day to G_DATE_WEDNESDAY and G_DATE_SATURDAY set SUNDAY wrong."); - fail_if(hildon_weekday_picker_isset_day(weekday_picker,G_DATE_BAD_WEEKDAY), "hildon-weekday-picker: set_day/isset_day to G_DATE_WEDNESDAY and G_DATE_SATURDAY set G_DATE_BAD_WEEKDAY wrong."); - -} -END_TEST - -/** - * Purpose: Check that limit day values are set and get properly - * Cases considered: - * - Set and isset the day "MONDAY". - * - Set and isset the day "SUNDAY". - * - Set SUNDAY and MONDAY on weekday picker and check that the two selected days are set, but the others doesn't be set. - * - Set all days on weekday picker and check that all days are set. - */ -START_TEST (test_set_day_limits) -{ - - hildon_weekday_picker_unset_all(weekday_picker); - - /* Test 1: Set MONDAY on weekday picker. */ - hildon_weekday_picker_set_day(weekday_picker,G_DATE_MONDAY); - - fail_if(!hildon_weekday_picker_isset_day(weekday_picker,G_DATE_MONDAY), "hildon-weekday-picker: set_day/isset_day to G_DATE_MONDAY didn't set MONDAY."); - fail_if(hildon_weekday_picker_isset_day(weekday_picker,G_DATE_SUNDAY), "hildon-weekday-picker: set_day/isset_day to G_DATE_MONDAY set SUNDAY wrong."); - fail_if(hildon_weekday_picker_isset_day(weekday_picker,G_DATE_TUESDAY), "hildon-weekday-picker: set_day/isset_day to G_DATE_MONDAY set TUESDAY wrong."); - fail_if(hildon_weekday_picker_isset_day(weekday_picker,G_DATE_WEDNESDAY), "hildon-weekday-picker: set_day/isset_day to G_DATE_MONDAY set WEDNESDAY wrong."); - fail_if(hildon_weekday_picker_isset_day(weekday_picker,G_DATE_THURSDAY), "hildon-weekday-picker: set_day/isset_day to G_DATE_MONDAY set THURSDAY wrong."); - fail_if(hildon_weekday_picker_isset_day(weekday_picker,G_DATE_FRIDAY), "hildon-weekday-picker: set_day/isset_day to G_DATE_MONDAY set FRIDAY wrong."); - fail_if(hildon_weekday_picker_isset_day(weekday_picker,G_DATE_SATURDAY), "hildon-weekday-picker: set_day/isset_day to G_DATE_MONDAY set SATURDAY wrong."); - fail_if(hildon_weekday_picker_isset_day(weekday_picker,G_DATE_BAD_WEEKDAY), "hildon-weekday-picker: set_day/isset_day to G_DATE_MONDAY set G_DATE_BAD_WEEKDAY wrong."); - - hildon_weekday_picker_unset_all(weekday_picker); - - /* Test 2: Set SUNDAY on weekday picker. */ - hildon_weekday_picker_set_day(weekday_picker,G_DATE_SUNDAY); - - fail_if(!hildon_weekday_picker_isset_day(weekday_picker,G_DATE_SUNDAY), "hildon-weekday-picker: set_day/isset_day to G_DATE_SUNDAY didn't set SUNDAY."); - fail_if(hildon_weekday_picker_isset_day(weekday_picker,G_DATE_MONDAY), "hildon-weekday-picker: set_day/isset_day to G_DATE_MONDAY set MONDAY wrong."); - fail_if(hildon_weekday_picker_isset_day(weekday_picker,G_DATE_TUESDAY), "hildon-weekday-picker: set_day/isset_day to G_DATE_MONDAY set TUESDAY wrong."); - fail_if(hildon_weekday_picker_isset_day(weekday_picker,G_DATE_WEDNESDAY), "hildon-weekday-picker: set_day/isset_day to G_DATE_MONDAY set WEDNESDAY wrong."); - fail_if(hildon_weekday_picker_isset_day(weekday_picker,G_DATE_THURSDAY), "hildon-weekday-picker: set_day/isset_day to G_DATE_MONDAY set THURSDAY wrong."); - fail_if(hildon_weekday_picker_isset_day(weekday_picker,G_DATE_FRIDAY), "hildon-weekday-picker: set_day/isset_day to G_DATE_MONDAY set FRIDAY wrong."); - fail_if(hildon_weekday_picker_isset_day(weekday_picker,G_DATE_SATURDAY), "hildon-weekday-picker: set_day/isset_day to G_DATE_MONDAY set SATURDAY wrong."); - fail_if(hildon_weekday_picker_isset_day(weekday_picker,G_DATE_BAD_WEEKDAY), "hildon-weekday-picker: set_day/isset_day to G_DATE_MONDAY set G_DATE_BAD_WEEKDAY wrong."); - - hildon_weekday_picker_unset_all(weekday_picker); - - hildon_weekday_picker_set_day(weekday_picker,G_DATE_SUNDAY); - hildon_weekday_picker_set_day(weekday_picker,G_DATE_MONDAY); - - /* Test 3: Set MONDAY and SUNDAY on weekday picker. */ - fail_if(!hildon_weekday_picker_isset_day(weekday_picker,G_DATE_MONDAY), "hildon-weekday-picker: set_day/isset_day to G_DATE_MONDAY and G_DATE_SUNDAY didn't set MONDAY."); - fail_if(!hildon_weekday_picker_isset_day(weekday_picker,G_DATE_SUNDAY), "hildon-weekday-picker: set_day/isset_day to G_DATE_MONDAY and G_DATE_SUNDAY didn't set SUNDAY."); - fail_if(hildon_weekday_picker_isset_day(weekday_picker,G_DATE_TUESDAY), "hildon-weekday-picker: set_day/isset_day to G_DATE_MONDAY and G_DATE_SUNDAY set TUESDAY wrong."); - fail_if(hildon_weekday_picker_isset_day(weekday_picker,G_DATE_WEDNESDAY), "hildon-weekday-picker: set_day/isset_day to G_DATE_MONDAY and G_DATE_SUNDAY set WEDNESDAY wrong."); - fail_if(hildon_weekday_picker_isset_day(weekday_picker,G_DATE_THURSDAY), "hildon-weekday-picker: set_day/isset_day to G_DATE_MONDAY and G_DATE_SUNDAY set THURSDAY wrong."); - fail_if(hildon_weekday_picker_isset_day(weekday_picker,G_DATE_FRIDAY), "hildon-weekday-picker: set_day/isset_day to G_DATE_MONDAY and G_DATE_SUNDAY set FRIDAY wrong."); - fail_if(hildon_weekday_picker_isset_day(weekday_picker,G_DATE_SATURDAY), "hildon-weekday-picker: set_day/isset_day to G_DATE_MONDAY and G_DATE_SUNDAY set SATURDAY wrong."); - - hildon_weekday_picker_unset_all(weekday_picker); - - /* Test 4: Set all days on weekday picker. */ - hildon_weekday_picker_set_day(weekday_picker,G_DATE_MONDAY); - hildon_weekday_picker_set_day(weekday_picker,G_DATE_TUESDAY); - hildon_weekday_picker_set_day(weekday_picker,G_DATE_WEDNESDAY); - hildon_weekday_picker_set_day(weekday_picker,G_DATE_THURSDAY); - hildon_weekday_picker_set_day(weekday_picker,G_DATE_FRIDAY); - hildon_weekday_picker_set_day(weekday_picker,G_DATE_SATURDAY); - hildon_weekday_picker_set_day(weekday_picker,G_DATE_SUNDAY); - - fail_if(!hildon_weekday_picker_isset_day(weekday_picker,G_DATE_MONDAY), "hildon-weekday-picker: set_day/isset_day all days did not set MONDAY."); - fail_if(!hildon_weekday_picker_isset_day(weekday_picker,G_DATE_SUNDAY), "hildon-weekday-picker: set_day/isset_day all days did not set SUNDAY."); - fail_if(!hildon_weekday_picker_isset_day(weekday_picker,G_DATE_TUESDAY), "hildon-weekday-picker: set_day/isset_day all days did not set TUESDAY."); - fail_if(!hildon_weekday_picker_isset_day(weekday_picker,G_DATE_WEDNESDAY), "hildon-weekday-picker: set_day/isset_day all days did not set WEDNESDAY."); - fail_if(!hildon_weekday_picker_isset_day(weekday_picker,G_DATE_THURSDAY), "hildon-weekday-picker: set_day/isset_day all days did not set THURSDAY."); - fail_if(!hildon_weekday_picker_isset_day(weekday_picker,G_DATE_FRIDAY), "hildon-weekday-picker: set_day/isset_day all days did not set FRIDAY."); - fail_if(!hildon_weekday_picker_isset_day(weekday_picker,G_DATE_SATURDAY), "hildon-weekday-picker: set_day/isset_day all days did not set SATURDAY."); - -} -END_TEST - -/** - * Purpose: Check that invalid day values are set and get properly - * Cases considered: - * - Set MONDAY on NULL weekday picker. - * - Set G_DATE_BAD_WEEKDAY on weekday picker. - * - Set 8 on weekday picker. - * - Set -2 on weekday picker. - * - isset_day from NULL weekday picker - */ -START_TEST (test_set_day_invalid) -{ - - hildon_weekday_picker_unset_all(weekday_picker); - - /* Test 1: Set MONDAY on NULL weekday picker. */ - hildon_weekday_picker_set_day(NULL,G_DATE_MONDAY); - fail_if(hildon_weekday_picker_isset_day(weekday_picker,G_DATE_MONDAY), "hildon-weekday-picker: set_day on NULL object set MONDAY wrong"); - fail_if(hildon_weekday_picker_isset_day(weekday_picker,G_DATE_SUNDAY), "hildon-weekday-picker: set_day on NULL object set SUNDAY wrong."); - fail_if(hildon_weekday_picker_isset_day(weekday_picker,G_DATE_WEDNESDAY), "hildon-weekday-picker: set_day on NULL object set WEDNESDAY wrong."); - - /* Test 2: Set G_DATE_BAD_WEEKDAY on weekday picker. */ - - hildon_weekday_picker_set_day(weekday_picker,G_DATE_BAD_WEEKDAY); - - fail_if(hildon_weekday_picker_isset_day(weekday_picker,G_DATE_BAD_WEEKDAY), "hildon-weekday-picker: set_day/isset_day to G_DATE_BAD_WEEKDAY set G_DATE_BAD_WEEKDAY wrong."); - fail_if(hildon_weekday_picker_isset_day(weekday_picker,G_DATE_MONDAY), "hildon-weekday-picker: set_day/isset_day to G_DATE_BAD_WEEKDAY set MONDAY wrong."); - fail_if(hildon_weekday_picker_isset_day(weekday_picker,G_DATE_TUESDAY), "hildon-weekday-picker: set_day/isset_day to G_DATE_BAD_WEEKDAY set TUESDAY wrong."); - fail_if(hildon_weekday_picker_isset_day(weekday_picker,G_DATE_WEDNESDAY), "hildon-weekday-picker: set_day/isset_day to G_DATE_BAD_WEEKDAY set WEDNESDAY wrong."); - fail_if(hildon_weekday_picker_isset_day(weekday_picker,G_DATE_THURSDAY), "hildon-weekday-picker: set_day/isset_day to G_DATE_BAD_WEEKDAY set THURSDAY wrong."); - fail_if(hildon_weekday_picker_isset_day(weekday_picker,G_DATE_FRIDAY), "hildon-weekday-picker: set_day/isset_day to G_DATE_BAD_WEEKDAY set FRIDAY wrong."); - fail_if(hildon_weekday_picker_isset_day(weekday_picker,G_DATE_SATURDAY), "hildon-weekday-picker: set_day/isset_day to G_DATE_BAD_WEEKDAY set SATURDAY wrong."); - fail_if(hildon_weekday_picker_isset_day(weekday_picker,G_DATE_SUNDAY), "hildon-weekday-picker: set_day/isset_day to G_DATE_BAD_WEEKDAY set SUNDAY wrong."); - - /* Test 3: Set 8 on weekday picker. */ - hildon_weekday_picker_set_day(weekday_picker,8); - - fail_if(hildon_weekday_picker_isset_day(weekday_picker,G_DATE_BAD_WEEKDAY), "hildon-weekday-picker: set_day/isset_day to 8 set G_DATE_BAD_WEEKDAY wrong."); - fail_if(hildon_weekday_picker_isset_day(weekday_picker,G_DATE_MONDAY), "hildon-weekday-picker: set_day/isset_day to 8 set MONDAY wrong."); - fail_if(hildon_weekday_picker_isset_day(weekday_picker,G_DATE_TUESDAY), "hildon-weekday-picker: set_day/isset_day to 8 set TUESDAY wrong."); - fail_if(hildon_weekday_picker_isset_day(weekday_picker,G_DATE_WEDNESDAY), "hildon-weekday-picker: set_day/isset_day to 8 set WEDNESDAY wrong."); - fail_if(hildon_weekday_picker_isset_day(weekday_picker,G_DATE_THURSDAY), "hildon-weekday-picker: set_day/isset_day to 8 set THURSDAY wrong."); - fail_if(hildon_weekday_picker_isset_day(weekday_picker,G_DATE_FRIDAY), "hildon-weekday-picker: set_day/isset_day to 8 set FRIDAY wrong."); - fail_if(hildon_weekday_picker_isset_day(weekday_picker,G_DATE_SATURDAY), "hildon-weekday-picker: set_day/isset_day to 8 set SATURDAY wrong."); - fail_if(hildon_weekday_picker_isset_day(weekday_picker,G_DATE_SUNDAY), "hildon-weekday-picker: set_day/isset_day to 8 set SUNDAY wrong."); - - /* Test 4: Set -2 on weekday picker. */ - hildon_weekday_picker_set_day(weekday_picker,-2); - - fail_if(hildon_weekday_picker_isset_day(weekday_picker,G_DATE_BAD_WEEKDAY), "hildon-weekday-picker: set_day/isset_day to -2 set G_DATE_BAD_WEEKDAY wrong."); - fail_if(hildon_weekday_picker_isset_day(weekday_picker,G_DATE_MONDAY), "hildon-weekday-picker: set_day/isset_day to -2 set MONDAY wrong."); - fail_if(hildon_weekday_picker_isset_day(weekday_picker,G_DATE_TUESDAY), "hildon-weekday-picker: set_day/isset_day to -2 set TUESDAY wrong."); - fail_if(hildon_weekday_picker_isset_day(weekday_picker,G_DATE_WEDNESDAY), "hildon-weekday-picker: set_day/isset_day to -2 set WEDNESDAY wrong."); - fail_if(hildon_weekday_picker_isset_day(weekday_picker,G_DATE_THURSDAY), "hildon-weekday-picker: set_day/isset_day to -2 set THURSDAY wrong."); - fail_if(hildon_weekday_picker_isset_day(weekday_picker,G_DATE_FRIDAY), "hildon-weekday-picker: set_day/isset_day to -2 set FRIDAY wrong."); - fail_if(hildon_weekday_picker_isset_day(weekday_picker,G_DATE_SATURDAY), "hildon-weekday-picker: set_day/isset_day to -2 set SATURDAY wrong."); - fail_if(hildon_weekday_picker_isset_day(weekday_picker,G_DATE_SUNDAY), "hildon-weekday-picker: set_day/isset_day to -2 set SUNDAY wrong."); - - /* Test 4: isset_day from NULL weekday picker. */ - hildon_weekday_picker_isset_day(NULL,G_DATE_BAD_WEEKDAY); -} -END_TEST - -/* ---------- Suite creation ---------- */ - -Suite *create_hildon_weekday_picker_suite() -{ - /* Create the suite */ - Suite *s = suite_create("HildonWeekdayPicker"); - - /* Create test cases */ - TCase *tc1 = tcase_create("set_day"); - - /* Create test case for hildon_weekday_picker_set_day and hildon_weekday_picker_isset_day and add it to the suite */ - tcase_add_checked_fixture(tc1, fx_setup_default_weekday_picker, fx_teardown_default_weekday_picker); - tcase_add_test(tc1, test_set_day_regular); - tcase_add_test(tc1, test_set_day_limits); - tcase_add_test(tc1, test_set_day_invalid); - suite_add_tcase (s, tc1); - - /* Return created suite */ - return s; -} diff --git a/tests/check_test.c b/tests/check_test.c index c82c438..a701935 100644 --- a/tests/check_test.c +++ b/tests/check_test.c @@ -52,38 +52,11 @@ configure_tests(gint environment) /* Create srunner object with the first test suite */ sr = srunner_create(create_hildon_caption_suite()); -#ifndef HILDON_DISABLE_DEPRECATED - srunner_add_suite(sr, create_hildon_number_editor_suite()); - srunner_add_suite(sr, create_hildon_time_editor_suite()); - srunner_add_suite(sr, create_hildon_time_picker_suite()); - srunner_add_suite(sr, create_hildon_date_editor_suite()); - srunner_add_suite(sr, create_hildon_weekday_picker_suite()); - srunner_add_suite(sr, create_hildon_controlbar_suite()); - srunner_add_suite(sr, create_hildon_color_button_suite()); - srunner_add_suite(sr, create_hildon_color_chooser_suite()); - srunner_add_suite(sr, create_hildon_seekbar_suite()); - /* srunner_add_suite(sr, create_hildon_dialoghelp_suite()); */ - srunner_add_suite(sr, create_hildon_calendar_popup_suite()); - srunner_add_suite(sr, create_hildon_range_editor_suite()); - /* srunner_add_suite(sr, create_hildon_name_password_dialog_suite()); - srunner_add_suite(sr, create_hildon_get_password_dialog_suite()); - srunner_add_suite(sr, create_hildon_set_password_dialog_suite()); */ - srunner_add_suite(sr, create_hildon_sort_dialog_suite()); - srunner_add_suite(sr, create_hildon_code_dialog_suite()); - srunner_add_suite(sr, create_hildon_volumebar_suite()); - srunner_add_suite(sr, create_hildon_volumebar_range_suite()); - srunner_add_suite(sr, create_hildon_font_selection_dialog_suite()); -#endif /* HILDON_DISABLE_DEPRECATED */ srunner_add_suite(sr, create_hildon_find_toolbar_suite()); srunner_add_suite(sr, create_hildon_note_suite()); srunner_add_suite(sr, create_hildon_wizard_dialog_suite()); /* srunner_add_suite(sr, create_hildon_scroll_area_suite()); */ -#ifndef HILDON_DISABLE_DEPRECATED - /* HildonBanner is not deprecated, but all the functions tested in - this suite are deprecated*/ - srunner_add_suite(sr, create_hildon_banner_suite()); -#endif srunner_add_suite(sr, create_hildon_window_suite()); srunner_add_suite(sr, create_hildon_helper_suite()); srunner_add_suite(sr, create_hildon_picker_button_suite()); diff --git a/tests/test_suites.h b/tests/test_suites.h index c0b6b29..93c897b 100644 --- a/tests/test_suites.h +++ b/tests/test_suites.h @@ -51,11 +51,6 @@ Suite *create_hildon_note_suite(void); Suite *create_hildon_volumebar_suite(void); Suite *create_hildon_volumebar_range_suite(void); Suite *create_hildon_wizard_dialog_suite(void); -#ifndef HILDON_DISABLE_DEPRECATED -/* HildonBanner is not deprecated, but all the functions tested in - this suite are deprecated*/ -Suite *create_hildon_banner_suite(void); -#endif Suite *create_hildon_font_selection_dialog_suite(void); Suite *create_hildon_system_sound_suite(void); Suite *create_hildon_scroll_area_suite(void); |