Fixing the tests a little. Fixing some mem problems in the time editor.
authorMichael Dominic Kostrzewa <michael.kostrzewa@nokia.com>
Thu, 15 Feb 2007 12:37:20 +0000 (12:37 +0000)
committerMichael Dominic Kostrzewa <michael.kostrzewa@nokia.com>
Thu, 15 Feb 2007 12:37:20 +0000 (12:37 +0000)
ChangeLog.2
src/hildon-caption.c
src/hildon-time-editor.c
tests/check-hildon-caption.c
tests/check-hildon-controlbar.c
tests/check-hildon-date-editor.c
tests/check-hildon-font-selection-dialog.c
tests/check-hildon-note.c

index 280fc81..a6e2490 100644 (file)
@@ -1,3 +1,14 @@
+2007-02-15  Michael Dominic Kostrzewa  <michael.kostrzewa@nokia.com> 
+
+       * src/hildon-time-editor.c: Check before freeing am/pm strings in
+       finalize.
+
+       * tests/check-hildon-caption.c: 
+       * tests/check-hildon-controlbar.c:
+       * tests/check-hildon-date-editor.c:
+       * tests/check-hildon-font-selection-dialog.c:
+       * tests/check-hildon-note.c: Fixing the tests a little.
+
 2007-02-14  Michael Dominic Kostrzewa  <michael.kostrzewa@nokia.com> 
 
        * examples/Makefile.am:
index 44574ae..74f754c 100644 (file)
@@ -1059,7 +1059,7 @@ hildon_caption_get_label                        (const HildonCaption *caption)
     priv = HILDON_CAPTION_GET_PRIVATE (caption);
     g_assert (priv);
 
-    return (gchar*) gtk_label_get_text (GTK_LABEL (GTK_LABEL (priv->label)));
+    return (gchar*) gtk_label_get_text (GTK_LABEL (priv->label));
 }
 
 /**
index ec5edcb..dde8dbb 100644 (file)
@@ -698,8 +698,11 @@ hildon_time_editor_finalize                     (GObject *obj_self)
     HildonTimeEditorPrivate *priv = HILDON_TIME_EDITOR_GET_PRIVATE (obj_self);
     g_assert (priv);
 
-    g_free (priv->am_symbol);
-    g_free (priv->pm_symbol);
+    if (priv->am_symbol) 
+            g_free (priv->am_symbol);
+
+    if (priv->pm_symbol)
+            g_free (priv->pm_symbol);
 
     if (priv->highlight_idle)
         g_source_remove (priv->highlight_idle);
@@ -793,7 +796,7 @@ hildon_time_editor_set_ticks                    (HildonTimeEditor *editor,
     guint i, h, m, s;
     gchar str[3];
 
-    g_assert (HILDON_IS_TIME_EDITOR (editor));
+    g_return_if_fail (HILDON_IS_TIME_EDITOR (editor));
 
     priv = HILDON_TIME_EDITOR_GET_PRIVATE (editor);
     g_assert (priv);
index a4f8e3a..f17d74a 100644 (file)
@@ -38,6 +38,8 @@
 
 #include <libintl.h>
 
+#define _(String) dgettext("hildon-libs", String)
+
 /* -------------------- Fixtures -------------------- */
 
 static HildonCaption *caption = NULL;
@@ -285,7 +287,7 @@ START_TEST (test_set_label_regular)
   /* We control i18n so we will never set it properly because apparently it will not be useful for testing */
   /* so _("ecdg_ti_caption_separato") should return the same result that "ecdg_ti_caption_separator" */
   /* If in the future we decide activate internationalization we must modify test implementation */
-  expected_ret_label = g_strconcat(TEST_LABEL,"ecdg_ti_caption_separator",NULL);
+  expected_ret_label = g_strconcat(TEST_LABEL,_("ecdg_ti_caption_separator"),NULL);
 
   /* Test 1 */
   hildon_caption_set_label (caption, TEST_LABEL);
@@ -303,7 +305,7 @@ START_TEST (test_set_label_regular)
   /* Test 2 */
   hildon_caption_set_label (caption, "");
   
-  fail_if (strcmp (hildon_caption_get_label (caption),"ecdg_ti_caption_separator") != 0,
+  fail_if (strcmp (hildon_caption_get_label (caption),_("ecdg_ti_caption_separator")) != 0,
            "hildon-caption: the returned label is %s and should be default separator",
            hildon_caption_get_label (caption));
 }
@@ -363,7 +365,7 @@ START_TEST (test_get_label_regular)
 
   /* Test 1 */
   hildon_caption_set_label (caption, TEST_LABEL);
-  expected_ret_label = g_strconcat(TEST_LABEL,"ecdg_ti_caption_separator",NULL);
+  expected_ret_label = g_strconcat(TEST_LABEL, _("ecdg_ti_caption_separator"),NULL);
 
   fail_if (strcmp (hildon_caption_get_label (caption), expected_ret_label) != 0,
           "hildon-caption: the returned label is %s and should be %s",
@@ -374,7 +376,7 @@ START_TEST (test_get_label_regular)
   /* Test 2 */
   hildon_caption_set_label (caption, "");
 
-  fail_if (strcmp (hildon_caption_get_label (caption), "ecdg_ti_caption_separator") != 0,
+  fail_if (strcmp (hildon_caption_get_label (caption), _("ecdg_ti_caption_separator")) != 0,
           "hildon-caption: the returned label is %s and should be default separator",
           hildon_caption_get_label (caption));
 }
index daf2e57..993b2c9 100644 (file)
@@ -176,9 +176,9 @@ START_TEST (test_set_range_invalid)
 
   min=hildon_controlbar_get_min(controlbar);
 
-  fail_if (min != 0,
-           "hildon-controlbar: The returned min is %d and should be 0",
-           min);
+  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);
 
@@ -193,14 +193,14 @@ START_TEST (test_set_range_invalid)
 
   min=hildon_controlbar_get_min(controlbar);
 
-  fail_if (min != 0,
-           "hildon-controlbar: The returned min is %d and should be 0",
-           min, 0);
+  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 != 0,
-           "hildon-controlbar: The returned max is %d and should be 0",
-           max);
+  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;
@@ -209,15 +209,15 @@ START_TEST (test_set_range_invalid)
 
   max=hildon_controlbar_get_max(controlbar);
 
-  fail_if (max != 0,
-           "hildon-controlbar: The returned max is %d and should be 0",
-           max);
+  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 != 0,
-           "hildon-controlbar: The returned min is %d and should be 0",
-           min);
+  fail_if (min != init_max,
+           "hildon-controlbar: The returned min is %d and should be %d",
+           min, init_max);
 
   /* Test 5: Set a range of [1,G_MININT] */
   init_min = 1;
@@ -226,15 +226,15 @@ START_TEST (test_set_range_invalid)
 
   max=hildon_controlbar_get_max(controlbar);
 
-  fail_if (max != 0,
-           "hildon-controlbar: The returned max is %d and should be 0",
-           max);
+  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 != 0,
-           "hildon-controlbar: The returned min is %d and should be 0",
-           min);
+  fail_if (min != init_min,
+           "hildon-controlbar: The returned min is %d and should be %d",
+           min, init_min);
 }
 END_TEST
 
index a5c2ef5..dafe5e4 100644 (file)
@@ -871,7 +871,7 @@ START_TEST (test_set_day_regular)
   guint day;
   guint ret_day;
 
-  day = 30;
+  day = 25;
 
   /* Test 1: Try day 30 */
   hildon_date_editor_set_day (date_editor, day);
index b2ff0a4..5424af9 100644 (file)
@@ -33,7 +33,7 @@
 #include "hildon-font-selection-dialog.h"
 
 #define PREVIEW_TEXT TEST_STRING
-#define DEFAULT_FONT_FAMILY "Nokia Sans"
+#define DEFAULT_FONT_FAMILY "Sans"
 
 static const guint16 N_FONT_SIZES = 7;
 static const guint16 FONT_SIZES[] = 
index 8f1ad9b..43b5f61 100644 (file)
@@ -89,8 +89,8 @@ START_TEST (test_new_confirmation_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_CONFIRMATION_TYPE,
-          "hildon-note: Type was not set property on creation (HILDON_NOTE_CONFIRMATION_TYPE)",note_type);
+  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 (note));
   note=NULL;
@@ -109,8 +109,8 @@ START_TEST (test_new_confirmation_regular)
 
   g_object_get_property(G_OBJECT (note),"note_type",&enum_value);
   note_type = g_value_get_int(&enum_value);
-  fail_unless( note_type == HILDON_NOTE_CONFIRMATION_TYPE,
-               "hildon-note: Type was not set property on creation (HILDON_NOTE_CONFIRMATION_TYPE)",note_type);
+  fail_unless( 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 (note));
   note=NULL;
@@ -152,8 +152,8 @@ START_TEST (test_new_confirmation_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_CONFIRMATION_TYPE,
-          "hildon-note: Type was not set property on creation (HILDON_NOTE_CONFIRMATION_TYPE)",note_type);
+  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;
@@ -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_INFORMATION_THEME_TYPE,
-          "hildon-note: Type was not set property on creation (HILDON_NOTE_INFORMATION_THEME_TYPE)",note_type);
+  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);
 
   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_INFORMATION_THEME_TYPE,
-          "hildon-note: Type was not set property on creation (HILDON_NOTE_INFORMATION_THEME_TYPE)",note_type);
+  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);
 
   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_INFORMATION_THEME_TYPE,
-          "hildon-note: Type was not set property on creation (HILDON_NOTE_INFORMATION_THEME_TYPE)",note_type);
+  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);
     
   gtk_widget_destroy (GTK_WIDGET (invalid_note));
   invalid_note=NULL;
@@ -318,8 +318,8 @@ START_TEST (test_new_confirmation_with_icon_name_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_CONFIRMATION_TYPE,
-          "hildon-note: Type was not set property on creation (HILDON_NOTE_CONFIRMATION_TYPE)",note_type);
+  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);
@@ -345,8 +345,8 @@ START_TEST (test_new_confirmation_with_icon_name_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_CONFIRMATION_TYPE,
-          "hildon-note: Type was not set property on creation (HILDON_NOTE_CONFIRMATION_TYPE)",note_type);
+  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);
@@ -404,8 +404,8 @@ START_TEST (test_new_confirmation_with_icon_name_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_CONFIRMATION_TYPE,
-          "hildon-note: Type was not set property on creation (HILDON_NOTE_CONFIRMATION_TYPE)",note_type);
+  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;
@@ -457,8 +457,8 @@ START_TEST (test_new_cancel_with_progress_bar_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_PROGRESSBAR_TYPE,
-          "hildon-note: Type was not set property on creation (HILDON_NOTE_PROGRESSBAR_TYPE)",note_type);
+  fail_if( note_type != HILDON_NOTE_TYPE_PROGRESSBAR,
+          "hildon-note: Type was not set property on creation (HILDON_NOTE_TYPE_PROGRESSBAR)",note_type);
 
   gtk_widget_destroy (GTK_WIDGET (note));
   note=NULL;
@@ -483,8 +483,8 @@ START_TEST (test_new_cancel_with_progress_bar_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_PROGRESSBAR_TYPE,
-          "hildon-note: Type was not set property on creation (HILDON_NOTE_PROGRESSBAR_TYPE)",note_type);
+  fail_if( note_type != HILDON_NOTE_TYPE_PROGRESSBAR,
+          "hildon-note: Type was not set property on creation (HILDON_NOTE_TYPE_PROGRESSBAR)",note_type);
 
   gtk_widget_destroy (GTK_WIDGET (progress_bar));
   gtk_widget_destroy (GTK_WIDGET (note));
@@ -534,8 +534,8 @@ START_TEST (test_new_cancel_with_progress_bar_invalid)
 
   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_PROGRESSBAR_TYPE,
-          "hildon-note: Type was not set property on creation (HILDON_NOTE_PROGRESSBAR_TYPE)",note_type);
+  fail_if( note_type != HILDON_NOTE_TYPE_PROGRESSBAR,
+          "hildon-note: Type was not set property on creation (HILDON_NOTE_TYPE_PROGRESSBAR)",note_type);
 
   gtk_widget_destroy (GTK_WIDGET (note));
   note=NULL;